mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Add FeedFinder package.
This commit is contained in:
@@ -13,6 +13,7 @@ dependencies.append(contentsOf: [
|
||||
.package(path: "../AccountError"),
|
||||
.package(path: "../Articles"),
|
||||
.package(path: "../ArticlesDatabase"),
|
||||
.package(path: "../FeedFinder"),
|
||||
.package(path: "../Secrets"),
|
||||
.package(path: "../SyncDatabase"),
|
||||
.package(path: "../SyncClients/NewsBlur"),
|
||||
@@ -30,7 +31,7 @@ dependencies.append(contentsOf: [
|
||||
let package = Package(
|
||||
name: "Account",
|
||||
defaultLocalization: "en",
|
||||
platforms: [.macOS(SupportedPlatform.MacOSVersion.v13), .iOS(SupportedPlatform.IOSVersion.v16)],
|
||||
platforms: [.macOS(.v13), .iOS(.v16)],
|
||||
products: [
|
||||
.library(
|
||||
name: "Account",
|
||||
@@ -49,6 +50,7 @@ let package = Package(
|
||||
"AccountError",
|
||||
"Articles",
|
||||
"ArticlesDatabase",
|
||||
"FeedFinder",
|
||||
"Secrets",
|
||||
"SyncDatabase",
|
||||
"NewsBlur",
|
||||
|
||||
@@ -17,6 +17,7 @@ import Articles
|
||||
import ArticlesDatabase
|
||||
import RSWeb
|
||||
import Secrets
|
||||
import FeedFinder
|
||||
|
||||
enum CloudKitAccountDelegateError: LocalizedError {
|
||||
case invalidParameter
|
||||
|
||||
@@ -14,6 +14,7 @@ import RSParser
|
||||
import RSWeb
|
||||
import SyncDatabase
|
||||
import Secrets
|
||||
import FeedFinder
|
||||
|
||||
public enum FeedbinAccountDelegateError: String, Error {
|
||||
case invalidParameter = "There was an invalid parameter passed."
|
||||
|
||||
@@ -14,6 +14,7 @@ import ArticlesDatabase
|
||||
import RSWeb
|
||||
import Secrets
|
||||
import AccountError
|
||||
import FeedFinder
|
||||
|
||||
public enum LocalAccountDelegateError: String, Error {
|
||||
case invalidParameter = "An invalid parameter was used."
|
||||
|
||||
@@ -14,6 +14,7 @@ import SyncDatabase
|
||||
import Secrets
|
||||
import ReaderAPI
|
||||
import AccountError
|
||||
import FeedFinder
|
||||
|
||||
public enum ReaderAPIAccountDelegateError: LocalizedError {
|
||||
case unknown
|
||||
|
||||
@@ -3,7 +3,7 @@ import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "Articles",
|
||||
platforms: [.macOS(SupportedPlatform.MacOSVersion.v13), .iOS(SupportedPlatform.IOSVersion.v16)],
|
||||
platforms: [.macOS(.v13), .iOS(.v16)],
|
||||
products: [
|
||||
.library(
|
||||
name: "Articles",
|
||||
|
||||
@@ -21,7 +21,7 @@ dependencies.append(contentsOf: [
|
||||
|
||||
let package = Package(
|
||||
name: "ArticlesDatabase",
|
||||
platforms: [.macOS(SupportedPlatform.MacOSVersion.v13), .iOS(SupportedPlatform.IOSVersion.v16)],
|
||||
platforms: [.macOS(.v13), .iOS(.v16)],
|
||||
products: [
|
||||
.library(
|
||||
name: "ArticlesDatabase",
|
||||
|
||||
9
FeedFinder/.gitignore
vendored
Normal file
9
FeedFinder/.gitignore
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
.DS_Store
|
||||
/.build
|
||||
/Packages
|
||||
/*.xcodeproj
|
||||
xcuserdata/
|
||||
DerivedData/
|
||||
.swiftpm/config/registries.json
|
||||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
||||
.netrc
|
||||
32
FeedFinder/Package.resolved
Normal file
32
FeedFinder/Package.resolved
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"pins" : [
|
||||
{
|
||||
"identity" : "rscore",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/Ranchero-Software/RSCore.git",
|
||||
"state" : {
|
||||
"revision" : "55644a3a037fed14f22ee2c0b531808f95051708",
|
||||
"version" : "2.0.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "rsparser",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/Ranchero-Software/RSParser.git",
|
||||
"state" : {
|
||||
"revision" : "d5b50ff78905ebfaf26dd698e0e5d3ed8269dd9b",
|
||||
"version" : "2.0.3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"identity" : "rsweb",
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/Ranchero-Software/RSWeb.git",
|
||||
"state" : {
|
||||
"revision" : "aca2db763e3404757b273821f058bed2bbe02fcf",
|
||||
"version" : "1.0.7"
|
||||
}
|
||||
}
|
||||
],
|
||||
"version" : 2
|
||||
}
|
||||
36
FeedFinder/Package.swift
Normal file
36
FeedFinder/Package.swift
Normal file
@@ -0,0 +1,36 @@
|
||||
// swift-tools-version: 5.8
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "FeedFinder",
|
||||
platforms: [.macOS(.v13), .iOS(.v16)],
|
||||
products: [
|
||||
// Products define the executables and libraries a package produces, and make them visible to other packages.
|
||||
.library(
|
||||
name: "FeedFinder",
|
||||
targets: ["FeedFinder"]),
|
||||
],
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/Ranchero-Software/RSCore.git", .upToNextMajor(from: "2.0.1")),
|
||||
.package(url: "https://github.com/Ranchero-Software/RSParser.git", .upToNextMajor(from: "2.0.2")),
|
||||
.package(url: "https://github.com/Ranchero-Software/RSWeb.git", .upToNextMajor(from: "1.0.0")),
|
||||
.package(path: "../AccountError"),
|
||||
],
|
||||
targets: [
|
||||
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
||||
// Targets can depend on other targets in this package, and on products in packages this package depends on.
|
||||
.target(
|
||||
name: "FeedFinder",
|
||||
dependencies: [
|
||||
"RSCore",
|
||||
"RSParser",
|
||||
"RSWeb",
|
||||
"AccountError"
|
||||
]),
|
||||
.testTarget(
|
||||
name: "FeedFinderTests",
|
||||
dependencies: ["FeedFinder"]),
|
||||
]
|
||||
)
|
||||
3
FeedFinder/README.md
Normal file
3
FeedFinder/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# FeedFinder
|
||||
|
||||
A description of this package.
|
||||
@@ -12,9 +12,9 @@ import RSWeb
|
||||
import RSCore
|
||||
import AccountError
|
||||
|
||||
class FeedFinder {
|
||||
public final class FeedFinder {
|
||||
|
||||
static func find(url: URL, completion: @escaping (Result<Set<FeedSpecifier>, Error>) -> Void) {
|
||||
public static func find(url: URL, completion: @escaping (Result<Set<FeedSpecifier>, Error>) -> Void) {
|
||||
downloadAddingToCache(url) { (data, response, error) in
|
||||
|
||||
if response?.forcedStatusCode == 404 {
|
||||
@@ -8,9 +8,9 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
struct FeedSpecifier: Hashable {
|
||||
public struct FeedSpecifier: Hashable {
|
||||
|
||||
enum Source: Int {
|
||||
public enum Source: Int {
|
||||
case UserEntered = 0, HTMLHead, HTMLLink
|
||||
|
||||
func equalToOrBetterThan(_ otherSource: Source) -> Bool {
|
||||
@@ -26,6 +26,13 @@ struct FeedSpecifier: Hashable {
|
||||
return calculatedScore()
|
||||
}
|
||||
|
||||
public init(title: String?, urlString: String, source: Source, orderFound: Int) {
|
||||
self.title = title
|
||||
self.urlString = urlString
|
||||
self.source = source
|
||||
self.orderFound = orderFound
|
||||
}
|
||||
|
||||
func feedSpecifierByMerging(_ feedSpecifier: FeedSpecifier) -> FeedSpecifier {
|
||||
// Take the best data (non-nil title, better source) to create a new feed specifier;
|
||||
|
||||
2
FeedFinder/Tests/FeedFinderTests/FeedFinderTests.swift
Normal file
2
FeedFinder/Tests/FeedFinderTests/FeedFinderTests.swift
Normal file
@@ -0,0 +1,2 @@
|
||||
import XCTest
|
||||
@testable import FeedFinder
|
||||
@@ -1344,6 +1344,7 @@
|
||||
841ABA4D20145E7300980E11 /* NothingInspectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NothingInspectorViewController.swift; sourceTree = "<group>"; };
|
||||
841ABA5D20145E9200980E11 /* FolderInspectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FolderInspectorViewController.swift; sourceTree = "<group>"; };
|
||||
841ABA5F20145EC100980E11 /* BuiltinSmartFeedInspectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BuiltinSmartFeedInspectorViewController.swift; sourceTree = "<group>"; };
|
||||
84208B732A9CEE2B009FE5B9 /* FeedFinder */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = FeedFinder; sourceTree = "<group>"; };
|
||||
84216D0222128B9D0049B9B9 /* DetailWebViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailWebViewController.swift; sourceTree = "<group>"; };
|
||||
842611891FCB67AA0086A189 /* FeedIconDownloader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedIconDownloader.swift; sourceTree = "<group>"; };
|
||||
8426119D1FCB6ED40086A189 /* HTMLMetadataDownloader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HTMLMetadataDownloader.swift; sourceTree = "<group>"; };
|
||||
@@ -2505,6 +2506,7 @@
|
||||
51C452B22265141B00C03939 /* Frameworks */,
|
||||
51CD32C624D2DEF9009ABAEF /* Account */,
|
||||
8486EC402A9C2EFE007EF90D /* AccountError */,
|
||||
84208B732A9CEE2B009FE5B9 /* FeedFinder */,
|
||||
8486EC3F2A9C2431007EF90D /* ReaderAPI */,
|
||||
8486EC3E2A9BE083007EF90D /* NewsBlur */,
|
||||
51CD32C424D2CF1D009ABAEF /* Articles */,
|
||||
|
||||
@@ -3,7 +3,7 @@ import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "Secrets",
|
||||
platforms: [.macOS(SupportedPlatform.MacOSVersion.v11), .iOS(SupportedPlatform.IOSVersion.v14)],
|
||||
platforms: [.macOS(.v13), .iOS(.v16)],
|
||||
products: [
|
||||
.library(
|
||||
name: "Secrets",
|
||||
|
||||
Reference in New Issue
Block a user