-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a searchable website of formulas similar to Homebew (#174)
- Loading branch information
Showing
11 changed files
with
2,639 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: deploy-pages | ||
on: | ||
push: | ||
branches: "v3" | ||
paths-ignore: | ||
- README.md | ||
- CONTRIBUTING.md | ||
- LICENSE | ||
- .gitignore | ||
- .github/** | ||
- "!.github/workflows/deploy-pages.yml" | ||
workflow_dispatch: | ||
concurrency: | ||
group: ${{ github.workflow }} | ||
cancel-in-progress: true | ||
jobs: | ||
deploy-pages: | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deploy-pages.outputs.page_url }} | ||
permissions: | ||
pages: write | ||
id-token: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: latest | ||
# Lockfile is in subfolder | ||
# cache: npm | ||
- run: npm install | ||
working-directory: docs | ||
- id: configure-pages | ||
uses: actions/configure-pages@v4 | ||
- run: npm run build | ||
working-directory: docs | ||
env: | ||
BASE_PATH: ${{ steps.configure-pages.outputs.base_path }}/ | ||
- uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: docs/.vitepress/dist | ||
- id: deploy-pages | ||
uses: actions/deploy-pages@v4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# http://help.houndci.com/en/articles/2138473-hound | ||
|
||
# http://help.houndci.com/en/articles/2138497-jshint | ||
jshint: | ||
enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
# https://vitepress.dev/ | ||
**/.vitepress/cache | ||
**/.vitepress/dist | ||
|
||
# Custom pre-build step | ||
/formulas/ | ||
|
||
#region https://github.com/github/gitignore/blob/main/Node.gitignore | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
web_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional stylelint cache | ||
.stylelintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variable files | ||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
.parcel-cache | ||
|
||
# Next.js build output | ||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# vuepress v2.x temp and cache directory | ||
.temp | ||
.cache | ||
|
||
# Docusaurus cache and generated files | ||
.docusaurus | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test | ||
|
||
# yarn v2 | ||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
#endregion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { defineConfig } from "vitepress"; | ||
|
||
// https://vitepress.dev/reference/site-config | ||
export default defineConfig({ | ||
ignoreDeadLinks: [ | ||
"./www.woowahan.com", | ||
"./www.woowahan.comm", | ||
"./http//scripts.sil.org/OFL", | ||
], | ||
|
||
// https://vitepress.dev/guide/routing#generating-clean-url | ||
cleanUrls: true, | ||
|
||
title: "Fontist Formulas", | ||
description: "Index of all Fontist Formulas", | ||
|
||
// https://github.com/vuejs/vitepress/issues/3508 | ||
base: process.env.BASE_PATH, | ||
|
||
themeConfig: { | ||
logo: "/logo.png", | ||
|
||
// https://vitepress.dev/reference/default-theme-config | ||
nav: [ | ||
{ text: "Home", link: "/" }, | ||
{ text: "Guide", link: "/guide/" }, | ||
{ text: "Formulas", link: "/formulas/" }, | ||
], | ||
|
||
// https://vitepress.dev/reference/default-theme-search | ||
search: { | ||
provider: "local", | ||
}, | ||
|
||
sidebar: { | ||
"/guide/": [ | ||
{ | ||
text: "Guide", | ||
items: [ | ||
{ text: "Create a Formula", link: "/guide/create-formula" }, | ||
{ | ||
text: "Private repositories", | ||
link: "/guide/private-repositories", | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
|
||
socialLinks: [ | ||
{ icon: "github", link: "https://github.com/fontist/formulas" }, | ||
], | ||
|
||
footer: { | ||
message: `Fontist is <a href="https://open.ribose.com/">riboseopen</a>`, | ||
copyright: `Copyright © 2023 Ribose Group Inc. All rights reserved.`, | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
#!/usr/bin/env node | ||
import * as YAML from "yaml"; | ||
import { mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises"; | ||
import { resolve, join, basename, dirname } from "node:path"; | ||
// import { marked } from 'marked' | ||
import { glob } from "glob"; | ||
|
||
const projectRoot = resolve(process.cwd(), ".."); | ||
|
||
await rm("formulas", { recursive: true, force: true }); | ||
await mkdir("formulas", { recursive: true }); | ||
|
||
function escapeHTML(html) { | ||
return html | ||
.replace(/&/g, "&") | ||
.replace(/</g, "<") | ||
.replace(/>/g, ">") | ||
.replace(/"/g, """) | ||
.replace(/'/g, "'"); | ||
} | ||
|
||
const allFormulas = []; | ||
|
||
for (const relativeFilePath of await glob("**/*.y{a,}ml", { | ||
cwd: join(projectRoot, "Formulas"), | ||
nodir: true, | ||
})) { | ||
const absoluteFilePath = join(projectRoot, "Formulas", relativeFilePath); | ||
const text = await readFile(absoluteFilePath, "utf8"); | ||
const yamls = YAML.parseAllDocuments(text).map((x) => x.toJSON()); | ||
const yaml = yamls.reduce((a, x) => Object.assign(a, x), {}); | ||
const slug = relativeFilePath.replace(/\.ya?ml$/, ""); | ||
// const licenseHTML = marked(yaml.requires_license_agreement || "", { breaks: true }) | ||
const fontNames = (yaml.fonts ?? []) | ||
.flatMap((font) => font.styles ?? []) | ||
.map((style) => { | ||
if (style.type) { | ||
return `${style.family_name} (${style.type})`; | ||
} else { | ||
return style.family_name; | ||
} | ||
}); | ||
const githubURL = `https://github.com/fontist/formulas/blob/main/Formulas/${relativeFilePath}`; | ||
|
||
const name = yaml.name || yaml.description || basename(slug); | ||
|
||
// TODO: Get the local search to only search specific parts of this | ||
// generated markdown. Namely just the name, description, and list of fonts. | ||
const md = `\ | ||
--- | ||
outline: false | ||
--- | ||
# ${name} | ||
${yaml.description || ""} | ||
[📜 View source](${githubURL}) | ||
${fontNames.map((font) => `- ${font}`).join("\n")} | ||
${escapeHTML(yaml.copyright || "")} | ||
${yaml.license_url ? `[${yaml.license_url}](${yaml.license_url})` : ""}`; | ||
|
||
await mkdir(dirname(`formulas/${slug}.md`), { recursive: true }); | ||
await writeFile(`formulas/${slug}.md`, md); | ||
// console.log(`Wrote formula/${slug}.md`) | ||
|
||
allFormulas.push({ | ||
name, | ||
slug, | ||
fontNames, | ||
githubURL, | ||
}); | ||
} | ||
|
||
const md = `\ | ||
--- | ||
search: false | ||
outline: false | ||
--- | ||
# All Formulas | ||
${allFormulas | ||
.map( | ||
(formula) => `\ | ||
- [${formula.name}](/formulas/${formula.slug}) \\ | ||
${formula.fontNames.join(", ")}`, | ||
) | ||
.join("\n\n")} | ||
`; | ||
await writeFile(`formulas/index.md`, md); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
search: false | ||
--- | ||
|
||
# Create a Formula | ||
|
||
The purpose of a formula is to allow Fontist to determine where to download fonts. | ||
|
||
There is a command that can generate a formula by an archive's link: | ||
|
||
```sh | ||
fontist create-formula https://quoteunquoteapps.com/courierprime/downloads/courier-prime.zip | ||
``` | ||
|
||
The result of its execution would be a YAML file. It can be changed with a text editor. | ||
|
||
You may need to change it manually when: | ||
|
||
- the script could not detect proper license text | ||
- you would like to change a name of a formula (may use the `--name` option) | ||
- the archive is private (see [private-formula-authentication](/guide/private-repositories#private-formula-authentication)) | ||
|
||
The formula can be proposed to be merged to [the main repository](https://github.com/fontist/formulas), or added to a private repository. |
Oops, something went wrong.