Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Library #16

Merged
merged 21 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
generated/
output/
19 changes: 15 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
# Contributing guide

Thank you for investing your time in contributing to our project! Any contribution you make will be reflected on [mshibanami.github.io/redirect-web](https://mshibanami.github.io/redirect-web/).
Thank you for investing your time in contributing to our project!

## Livereload
## File structure

This website is powered by Docsify, and you can livereload it with their `docsify-cli`.
- `docs/`: A documentation of Redirect Web for Safari, which is hosted as [mshibanami.github.io/redirect-web](https://mshibanami.github.io/redirect-web/).
- `library/`: Data of the library available on the app, such as rules and categories.

### Documentation

#### Livereload

The documentation is powered by Docsify, and you can livereload it with their `docsify-cli`.
Please check [their repository](https://github.com/docsifyjs/docsify-cli), and install it.

Once it's ready, run this command in the repository root of redirect-web.
Once it's ready, run this command in the repository root:

```sh
$ docsify serve docs/
```

Livereload makes maintaining the documentation easier.

### Library

Please check [Library's README](./library/README.md).
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Redirect Web for Safari

This is a repository for [the support website of Redirect Web for Safari](https://mshibanami.github.io/redirect-web).
This is a repository for [the support website of Redirect Web for Safari](https://mshibanami.github.io/redirect-web) and a library of redirect rules.

In addition, we provides these on GitHub:

Expand Down
9 changes: 9 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

cd "$(dirname "${BASH_SOURCE:-$0}")"

./docs/scripts/generate-rule-set-list.sh

rm -rf output
mkdir -p output/redirect-web
cp -R docs/* output/redirect-web
2 changes: 2 additions & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
- How to Use
- [Redirect Rule](redirect-rule)
- [Export/Import Rules](export-or-import-rules)
- Library
- [Add Your Rules to Library](add-your-rules-to-library)
- Q&A
- [FAQ](faq)
- [Contact Us](contact-us)
Expand Down
20 changes: 0 additions & 20 deletions docs/rules-in-library/8_twitter_redirect_to_nitter/rule-set.json

This file was deleted.

39 changes: 0 additions & 39 deletions docs/scripts/generate-rule-set-list.sh

This file was deleted.

93 changes: 93 additions & 0 deletions library/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Library

The library is shown in the Redirect Web apps and the data under the `library` folder may be used in the app.

## Rule Sets

Rule sets within the library are managed at [library/rule-sets](https://github.com/mshibanami/redirect-web/tree/main/library/rule-sets).

Each rule is identified by a unique integer ID. All data in a rule set should be in a folder named `{id}_{short-title-of-rule-set}`. This folder should contain:

- `rule-set.json`
- `metadata.json`

Folders of deleted rule sets remain like `8_DELETED`, ensuring that IDs remain unique.

You can submit a pull request to add your rule to the library.

> [!WARNING]
> Old rules will persist in the Git history, although you can modify or remove your rules after creation.

## `rule-set.json`

This file defines a rule set containing one or more rules. It's essentially equivalent to the `redirectweb` file you can get by exporting your rules from the Redirect Web apps.

> [!NOTE]
> The file extension is `json` because it's easier to browse on GitHub.

Below is an example of `rule-set.json` that configures Google Meet links to open in Google Chrome:

```json
{
"bundleID": "io.github.mshibanami.RedirectWebForSafari",
"kind": "RedirectList",
"redirects": [
{
"appURL": "file:\/\/\/Applications\/Google%20Chrome.app",
"comments": "This is a rule to open Google Meet links in Google Chrome automatically.",
"destinationURLPattern": "$0",
"exampleURLs": [
"https:\/\/meet.google.com\/xxx-yyyy-zzz"
],
"kind": "Redirect",
"sourceURLPattern": {
"type": "regularExpression",
"value": "https:\/\/meet.google.com\/[a-z]*-[a-z]*-[a-z]*"
},
"title": "Google Meet: Open in Chrome"
}
]
}
```

## `metadata.json`

This file contains metadata of a rule set.

```json
{
"authors": [
{
"name": "Author Name 1",
"gitHubID": "author-github-id1"
},
{
"name": "Author Name 2",
"gitHubID": "author-github-id2",
}
],
"imageURLs": [
"https://somewhere-on-the-internet.com/path/to/your-rule-set-image.jpg"
],
"aboutURL": "https://somewhere-on-the-internet.com/path/to/the-rule-set-details.html",
"title": "A title of the rule set",
"description": "A description of the rule set.",
"version": "1.0.0",
"primaryCategoryID": "gaming",
"secondaryCategoryID": "productivity"
}
```

- `authors`: A list of rule set's authors.
- `name`: The name of an author.
- `gitHubID`: The GitHub ID of an author.
- `imageURLs` (optional): A list of image URLs of the rule set.
- `videoURLs` (optional): A list of video URLs for the rule set, including:
- A direct link to a video file that QuickTime Player can play, or,
- A YouTube video URL.
- `aboutURL` (optional): A link to a webpage where users can learn more about the rule set.
- `title`: A short title of the rule set.
- `description`: A description of the rule set. This is optional when the first rule in the rule set has non-empty `comments`.
- `version`: A version of the rule set, which should follow [Semantic Versioning](https://semver.org).
- `primaryCategoryID`: A primary category ID of the rule set. Find a list of the categories in [categories.json](./categories.json).
- `secondaryCategoryID` (optional): A secondary category ID of the rule set.
134 changes: 134 additions & 0 deletions library/categories.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
{
"categories": [
{
"id": "social_media",
"name": "Social Media",
"emoji": "👍"
},
{
"id": "search",
"name": "Search",
"emoji": "🔍"
},
{
"id": "education",
"name": "Education",
"emoji": "🎓"
},
{
"id": "reference",
"name": "Reference",
"emoji": "📖"
},
{
"id": "productivity",
"name": "Productivity",
"emoji": "🧠"
},
{
"id": "software_development",
"name": "Software Development",
"emoji": "💻"
},
{
"id": "entertainment",
"name": "Entertainment",
"emoji": "🍿"
},
{
"id": "shopping",
"name": "Shopping",
"emoji": "👜"
},
{
"id": "health_and_fitness",
"name": "Health",
"emoji": "💊"
},
{
"id": "travel",
"name": "Travel",
"emoji": "🏝️"
},
{
"id": "news",
"name": "News",
"emoji": "🗞️"
},
{
"id": "finance",
"name": "Finance",
"emoji": "📈"
},
{
"id": "business",
"name": "Business",
"emoji": "📊"
},
{
"id": "government",
"name": "Government",
"emoji": "🏢"
},
{
"id": "science",
"name": "Science",
"emoji": "🔬"
},
{
"id": "arts_and_crafts",
"name": "Arts & Crafts",
"emoji": "🎨"
},
{
"id": "sports",
"name": "Sports",
"emoji": "⚽️"
},
{
"id": "photo_and_video",
"name": "Lifestyle",
"emoji": "🌇"
},
{
"id": "legal",
"name": "Legal",
"emoji": "🧑‍⚖️"
},
{
"id": "gaming",
"name": "Gaming",
"emoji": "🎮"
},
{
"id": "real_estate",
"name": "Real Estate",
"emoji": "🏠"
},
{
"id": "transport",
"name": "Transport",
"emoji": "🚅"
},
{
"id": "jobs_and_careers",
"name": "Jobs & Careers",
"emoji": "🧑‍💼"
},
{
"id": "nonprofits",
"name": "Nonprofits",
"emoji": "🖐️"
},
{
"id": "food_and_cooking",
"name": "Food & Cooking",
"emoji": "🥗"
},
{
"id": "other",
"name": "Other",
"emoji": null
}
]
}
15 changes: 15 additions & 0 deletions library/rule-sets/0_example-rule/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"authors": [
{
"name": "Manabu Nakazawa",
"gitHubID": "mshibanami"
}
],
"imageURLs": null,
"videoURLs": null,
"aboutURL": null,
"title": "Example Redirect Rule",
"description": "An example rule.",
"version": "1.0.0",
"primaryCategoryID": "other"
}
16 changes: 16 additions & 0 deletions library/rule-sets/1_google-meet-open-in-chrome/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"authors": [
{
"name": "Manabu Nakazawa",
"gitHubID": "mshibanami"
}
],
"imageURLs": null,
"videoURLs": null,
"aboutURL": null,
"title": "Google Meet: Open in Chrome",
"description": "A rule to open Google Meet links in Google Chrome automatically.",
"version": "1.0.0",
"primaryCategoryID": "productivity",
"secondaryCategoryID": "business"
}
Loading