Skip to content

Commit

Permalink
Auto update status
Browse files Browse the repository at this point in the history
  • Loading branch information
rastislavcore committed Feb 25, 2024
1 parent 1e415ac commit 72108b3
Show file tree
Hide file tree
Showing 12 changed files with 183 additions and 14 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/update-frontmatter.yml
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
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
2 changes: 1 addition & 1 deletion docs/cip-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Supported formats:
- `First Last <email>`: Email address.
- `First Last (@github)`: GitHub username.
- `First Last (@[email protected])`: Nickname and pod (e.g., @coretalk.space).
- `First Last` `(cb00…@cp)` or `<corepass:cb00…>`: CoreID from CorePass.
- `First Last` `[cb00…@coreid]` or `<corepass:cb00…>`: CoreID from CorePass.

## Auxiliary Files

Expand Down
47 changes: 45 additions & 2 deletions docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import {themes as prismThemes} from 'prism-react-renderer';
import type {Config} from '@docusaurus/types';
import type * as Preset from '@docusaurus/preset-classic';

import remarkAbbr from 'remark-abbr';
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',
Expand Down Expand Up @@ -89,6 +94,12 @@ const config: Config = {
});
},
},
remarkPlugins: [
[remarkAbbr, { expandFirst: true }],
fediverseUser,
remarkCorepass,
remarkCorebc,
],
},
theme: {
customCss: './src/css/custom.css',
Expand All @@ -106,10 +117,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',
Expand Down
24 changes: 14 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion src/theme/BlogPostItem/Header/Author/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(':')) {
Expand Down
Binary file added static/img/icons/icon-128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/icons/icon-256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/icons/icon-32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/icons/icon-48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/icons/icon-64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions static/manifest.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
52 changes: 52 additions & 0 deletions update_frontmatter.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 72108b3

Please sign in to comment.