diff --git a/.github/workflows/update-frontmatter.yml b/.github/workflows/update-frontmatter.yml new file mode 100644 index 0000000..c5b3550 --- /dev/null +++ b/.github/workflows/update-frontmatter.yml @@ -0,0 +1,28 @@ +name: Update Front Matter + +on: + schedule: + - cron: '0 0 */2 * *' # Runs at 00:00 UTC every 2 days + +jobs: + update-front-matter: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Install Dependencies + run: | + python3 -m pip install --upgrade pip + pip3 install python-frontmatter pyyaml + + - name: Update Front Matter in Markdown Files + run: python3 update_frontmatter.py + + - name: Commit changes + run: | + git config --global user.email "action@github.com" + git config --global user.name "GitHub Action" + git add -A + git diff --staged --quiet || git commit -m "Update front matter tags based on dates" + git push diff --git a/docs/cip-workflow.md b/docs/cip-workflow.md index bae6fc9..8c38758 100755 --- a/docs/cip-workflow.md +++ b/docs/cip-workflow.md @@ -83,7 +83,7 @@ Supported formats: - `First Last `: Email address. - `First Last (@github)`: GitHub username. - `First Last (@nickname@pod.tld)`: Nickname and pod (e.g., @coretalk.space). -- `First Last` `(cb00…@cp)` or ``: CoreID from CorePass. +- `First Last` `[cb00…@coreid]` or ``: CoreID from CorePass. ## Auxiliary Files diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 609fb91..aa14daf 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -2,6 +2,10 @@ import {themes as prismThemes} from 'prism-react-renderer'; import type {Config} from '@docusaurus/types'; import type * as Preset from '@docusaurus/preset-classic'; +import fediverseUser from "remark-fediverse-user"; +import remarkCorepass from "remark-corepass"; +import remarkCorebc from "remark-corebc"; + const config: Config = { title: process.env.title || 'CIP', tagline: process.env.tagline || 'Core Improvement Proposals', @@ -89,6 +93,11 @@ const config: Config = { }); }, }, + remarkPlugins: [ + fediverseUser, + remarkCorepass, + remarkCorebc, + ], }, theme: { customCss: './src/css/custom.css', @@ -106,10 +115,42 @@ const config: Config = { { property: 'og:description', content: 'Core Improvement Proposals' }, { property: 'og:type', content: 'website' }, { - "name": "keywords", - "content": "author, categories, champion, cip, cips, consensus, core, design, document, each, editor, editors, encompassing, features, flow, fork, github, have, improvement, improvements, information, intended, key, mechanisms, members, new, offers, platform, primary, proposal, proposing, protocol, rationale, require, responsibilities, serve, sets, six, specifications, stakeholders, standards, stands, team, we, what, work, you", + name: "keywords", + content: "author, categories, champion, cip, cips, consensus, core, design, document, each, editor, editors, encompassing, features, flow, fork, github, have, improvement, improvements, information, intended, key, mechanisms, members, new, offers, platform, primary, proposal, proposing, protocol, rationale, require, responsibilities, serve, sets, six, specifications, stakeholders, standards, stands, team, we, what, work, you", }, { property: 'ican:xcb', content: 'cb57bbbb54cdf60fa666fd741be78f794d4608d67109' }, + { name: "theme-color", content: "#3b9a3e"}, + { name: "apple-mobile-web-app-capable", content: "yes"}, + { name: "apple-mobile-web-app-status-bar-style", content: "black-translucent"}, + ], + headTags: [ + { + tagName: "link", + attributes: { + rel: "manifest", + href: "/manifest.json", + }, + }, + { + tagName: "meta", + attributes: { + name: "generator", + content: "CoreWeb Generator", + }, + }, + { + tagName: 'script', + attributes: { + type: 'application/ld+json', + }, + innerHTML: JSON.stringify({ + '@context': 'https://schema.org/', + '@type': 'Organization', + name: 'CORE FOUNDATION', + url: 'https://coreblockchain.net', + logo: 'https://cip.coreblockchain.net/img/logo.svg', + }), + }, ], colorMode: { defaultMode: 'light', diff --git a/package.json b/package.json index 77f40a2..c225ff7 100644 --- a/package.json +++ b/package.json @@ -15,20 +15,24 @@ "typecheck": "tsc" }, "dependencies": { - "@docusaurus/core": "3.0.0", - "@docusaurus/preset-classic": "3.0.0", - "@mdx-js/react": "^3.0.0", - "clsx": "^2.0.0", + "@docusaurus/core": "3.1.1", + "@docusaurus/preset-classic": "3.1.1", + "@mdx-js/react": "^3.0.1", + "clsx": "^2.1.0", "cryptocons": "^1.3.3", - "prism-react-renderer": "^2.1.0", + "prism-react-renderer": "^2.3.1", "react": "^18.2.0", - "react-dom": "^18.2.0" + "react-dom": "^18.2.0", + "remark-abbr": "^1.4.1", + "remark-corebc": "^0.1.1", + "remark-corepass": "^0.1.3", + "remark-fediverse-user": "^0.1.8" }, "devDependencies": { - "@docusaurus/module-type-aliases": "^3.0.0", - "@docusaurus/tsconfig": "^3.0.0", - "@docusaurus/types": "^3.0.0", - "typescript": "^5.2.2" + "@docusaurus/module-type-aliases": "^3.1.1", + "@docusaurus/tsconfig": "^3.1.1", + "@docusaurus/types": "^3.1.1", + "typescript": "^5.3.3" }, "browserslist": { "production": [ diff --git a/src/theme/BlogPostItem/Header/Author/index.tsx b/src/theme/BlogPostItem/Header/Author/index.tsx index 885342e..ba960b8 100644 --- a/src/theme/BlogPostItem/Header/Author/index.tsx +++ b/src/theme/BlogPostItem/Header/Author/index.tsx @@ -31,7 +31,7 @@ export default function BlogPostItemHeaderAuthor({author, className}) { if (corepassMatchInside) { link = `corepass:${corepassMatchInside[1]}`; const shortened = corepassMatchInside[1].slice(0, 4) + '…' + corepassMatchInside[1].slice(-4); - displayName = name.replace(corepassPatternInside, `<${shortened}@cp>`); + displayName = name.replace(corepassPatternInside, `[${shortened}@coreid]`); } else if (websiteMatch) { link = websiteMatch[1]; if (!link.includes(':')) { diff --git a/static/img/icons/icon-128.png b/static/img/icons/icon-128.png new file mode 100755 index 0000000..f4d85f2 Binary files /dev/null and b/static/img/icons/icon-128.png differ diff --git a/static/img/icons/icon-256.png b/static/img/icons/icon-256.png new file mode 100755 index 0000000..468111d Binary files /dev/null and b/static/img/icons/icon-256.png differ diff --git a/static/img/icons/icon-32.png b/static/img/icons/icon-32.png new file mode 100755 index 0000000..30e31d7 Binary files /dev/null and b/static/img/icons/icon-32.png differ diff --git a/static/img/icons/icon-48.png b/static/img/icons/icon-48.png new file mode 100755 index 0000000..25cb5f6 Binary files /dev/null and b/static/img/icons/icon-48.png differ diff --git a/static/img/icons/icon-64.png b/static/img/icons/icon-64.png new file mode 100755 index 0000000..c454ae5 Binary files /dev/null and b/static/img/icons/icon-64.png differ diff --git a/static/manifest.json b/static/manifest.json new file mode 100644 index 0000000..ce62ad6 --- /dev/null +++ b/static/manifest.json @@ -0,0 +1,42 @@ +{ + "name": "Core CIP", + "short_name": "CoreCip", + "start_url": "./index.html", + "display": "standalone", + "theme_color": "#3b9a3e", + "background_color": "#1c1e21", + "description": "Core Improvement Proposals", + "icons": [ + { + "src": "img/icons/icon-32.png", + "sizes": "32x32", + "type": "image/png" + }, + { + "src": "img/icons/icon-48.png", + "sizes": "48x48", + "type": "image/png" + }, + { + "src": "img/icons/icon-64.png", + "sizes": "64x64", + "type": "image/png" + }, + { + "src": "img/icons/icon-128.png", + "sizes": "128x128", + "type": "image/png" + }, + { + "src": "img/icons/icon-256.png", + "sizes": "256x256", + "type": "image/png" + } + ], + "related_applications": [ + { + "platform": "webapp", + "url": "https://cip.coreblockchain.net/manifest.json" + } + ] +} diff --git a/update_frontmatter.py b/update_frontmatter.py new file mode 100644 index 0000000..90419d5 --- /dev/null +++ b/update_frontmatter.py @@ -0,0 +1,52 @@ +import frontmatter +import os +from datetime import datetime, timedelta + +def parse_date(date_str): + formats = ['%Y-%m-%d', '%Y-%m-%dT%H:%M:%S.%fZ', '%Y-%m-%dT%H:%M:%SZ'] + for fmt in formats: + try: + return datetime.strptime(date_str, fmt) + except ValueError: + pass + raise ValueError(f"Date format not recognized: {date_str}") + +def update_tags(post, today): + try: + creation_date = parse_date(post['date']) + except ValueError as e: + print(e) + return False + + diff = today - creation_date + new_tag = None + + if diff.days >= 42: + new_tag = 'final' + elif diff.days >= 28: + new_tag = 'accepted' + elif diff.days >= 14: + new_tag = 'last call' + + if new_tag: + tags = post.get('tags', []) + if new_tag not in tags: + tags = [tag for tag in tags if tag not in ['draft', 'last call', 'accepted', 'final']] + tags.append(new_tag) + post['tags'] = tags + return True + return False + +def process_markdown_files(): + for subdir, dirs, files in os.walk('cip'): + for file in files: + if file.endswith('.md') or file.endswith('.mdx'): + filepath = os.path.join(subdir, file) + with open(filepath, 'r', encoding='utf-8') as f: + post = frontmatter.load(f) + if update_tags(post, datetime.now()): + with open(filepath, 'w', encoding='utf-8') as f: + frontmatter.dump(post, f) + +if __name__ == "__main__": + process_markdown_files()