Swiftpack.co - christopherweems/Sight as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
christopherweems/Sight v0.2.0
Generate search query urls via a convenience initializer on URL
⭐️ 0
🕓 37 weeks ago
.package(url: "https://github.com/christopherweems/Sight.git", from: "v0.2.0")

Sight

Generate search query urls via a convenience initializer on URL. Also acts as a local index of thousands of websites.

Usage

Sight

Create a url for the site's query results page:

import Sight

let searchURL = try? URL(site: "imdb.com", .unencodedQuery("Titanic II"))
// searchURL == `https://www.imdb.com/find?q=Titanic+II`

Spaces in .unencodedQuery(..) are automatically percent encoded.

Create a fully qualified root url, using https where available:

let homepage = try? URL(site: "github.com") // https://github.com/

SightBuilder

Internal library defining workings of Site object, used to build directory in SightIndex.

Sites are defined by their root url (scheme & authority), and optionally the path of their query page:

Site("https://github.com")
    .queryURL(path: "/search?q=%s", method: .get)

Describe query urls for sites with language or locale variations:

Site("https://www.wikipedia.org")
    .queryURL("https://en.wikipedia.org/w/index.php?search=%s", language: .english)
    .queryURL("https://fr.wikipedia.org/w/index.php?search=%s", language: .french)

Sites without a .queryURL(..) return false for Site.isQueryable.

SightIndex

Defines the sites that can be queried from the URL extension in Sight.

Exact matches are O(n) for first & O(1) for repeated access:

let github = Site(authority: "github.com", match: .exact)

Best match is O(n^2) and uncached: (Not yet implemented)

let apple = Site(authority: "aple.com", match: .best)

Where n is the count of Site indexed. (actually ~n/27), as sites are split into buckets a-z + misc)

[These O(n) values are goals and may not be accurate until v1.0]

SightInspector

Generate site query urls from the command line:

swift run SightInspector swiftpackageindex.com "Sight"

Search sites from the command line, opening in your default browser (macOS only):

swift run SightInspector -o wikipedia.org Khruangbin

Related Links

Smart bookmark - Wikipedia

GitHub

link
Stars: 0
Last commit: 5 days ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

Sight 0.3.0
3 weeks ago

Update swift-argument-parser version to 1.0.0 Fix compile warning on Linux for SightInspector Add new site definitions (Newest updates are always on main branch)

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics