Swiftpack.co - Package - christopherweems/Sight
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.


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



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/


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:

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

Describe query urls for sites with language or locale variations:

    .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.


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]


Generate site query urls from the command line:

swift run SightInspector wikipedia.org "Dig Dug"

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


Stars: 0


- 2020-07-02T21:08:49

- 2020-06-30T00:29:18

SightIndex now defines over 2,300 queryable sites.

- 2020-06-26T20:11:15

Fix SightInspector tool for opening localized search queries with no specified locale

- 2020-06-24T06:02:24

SightIndex now indexes over 2200 websites! Add support for generating locale or language specific variation of select sites via locale & language arguments on Site.queryURL(..)

Add `count` command to `SightInspector` executable - 2020-06-21T01:11:06

Count returns the total, queryable, or non-queryable count of websites tracked by Sight.

- 2020-06-20T20:31:25