diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index fbdb27a..ccd604c 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,6 +1,6 @@ FROM gitpod/workspace-python-3.12 -ARG SHELLCHECK_VERSION=0.9.0 +ARG SHELLCHECK_VERSION=0.10.0 ARG HADOLINT_VERSION=2.12.0 RUN curl -sSL https://raw.githubusercontent.com/upciti/wakemeops/main/assets/install_repository | sudo bash \ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 9423c44..f999830 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -38,7 +38,11 @@ "vscode": { "extensions": [ "denoland.vscode-deno", - "laurencebahiirwa.deno-std-lib-snippets" + "laurencebahiirwa.deno-std-lib-snippets", + "redhat.vscode-yaml", + "foam.foam-vscode", + "vivaxy.vscode-conventional-commits", + "eamodio.gitlens" ] } } diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 943c275..0289191 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,6 +1,10 @@ { "recommendations": [ "denoland.vscode-deno", - "laurencebahiirwa.deno-std-lib-snippets" + "laurencebahiirwa.deno-std-lib-snippets", + "redhat.vscode-yaml", + "foam.foam-vscode", + "vivaxy.vscode-conventional-commits", + "eamodio.gitlens" ] } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 2909ba6..4764ff3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,9 +11,14 @@ "conventionalCommits.scopes": [ "api", "global", - "mkdocs" + "mkdocs", + "pipenv", + "stylesheets", + "announcement" ], - "python.analysis.autoImportCompletions": true + "conventionalCommits.autoCommit": false, + "git.alwaysSignOff": true, + "python.analysis.autoImportCompletions": true, "json.schemaDownload.enable": true, "json.schemas": [ { @@ -23,5 +28,17 @@ "schema": true, "url": "https://raw.githubusercontent.com/skymethod/denoflare/v0.5.12/common/config.schema.json" } - ] + ], + "yaml.schemas": { + "https://squidfunk.github.io/mkdocs-material/schema.json": "mkdocs.yml" + }, + "yaml.customTags": [ + "!ENV scalar", + "!ENV sequence", + "!relative scalar", + "tag:yaml.org,2002:python/name:material.extensions.emoji.to_svg", + "tag:yaml.org,2002:python/name:material.extensions.emoji.twemoji", + "tag:yaml.org,2002:python/name:pymdownx.superfences.fence_code_format" + ], + "livePreview.defaultPreviewPath": "/overrides/main.html" } diff --git a/README.md b/README.md index ecccebb..286b17d 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,37 @@ -# ~ajhalili2006's digital garden website +# ~ajhalili2006's personal wiki and digital garden [![open in agora badge](https://img.shields.io/badge/open%20in%20agora-black?style=for-the-badge)](https://anagora.org/@ajhalili2006) -[![kooky insane stuff repo](https://img.shields.io/badge/Jiroh's%20Kooky%20Insane%20Stuff-blue?style=for-the-badge)](https://garden.andreijiroh.xyz/garden/kooky-insane-stuff) -[![gitlab pages](https://img.shields.io/badge/hosted%20via-GitLab%20Pages-8A2BE2?style=for-the-badge&logo=gitlab)](https://garden.andreijiroh.xyz) -[![pipeline status](https://mau.dev/andreijiroh-dev/webapps/garden-monorepo/badges/main/pipeline.svg?style=for-the-badge)](https://mau.dev/andreijiroh-dev/webapps/garden-monorepo/-/commits/main) +[![kooky insane stuff repo](https://img.shields.io/badge/Jiroh's%20Kooky%20Insane%20Stuff-blue?style=for-the-badge)](https://wiki.andreijiroh.xyz/garden/kooky-insane-stuff) +[![gitlab pages](https://img.shields.io/badge/hosted%20via-Cloudflare%20Pages-f38020?style=for-the-badge&logo=cloudflare)](https://wiki.andreijiroh.xyz) +[![pipeline status](https://mau.dev/andreijiroh-dev/wiki/badges/main/pipeline.svg?style=for-the-badge)](https://mau.dev/andreijiroh-dev/wiki/-/commits/main) [![Built with Material for MkDocs](https://img.shields.io/badge/Material_for_MkDocs-526CFE?style=for-the-badge&logo=MaterialForMkDocs&logoColor=white)](https://squidfunk.github.io/mkdocs-material/) ## Directory Map -``` -TBD -``` +
+. You are here!
+├── .devcontainer - Devcontainer files for GitHub Codespaces and Remote Dev Containers
+├── .foam
+    ├── templates - Foam templates, including daily notes
+├── api - Experimential API to compliment with the wiki, currently prototyping in local devenv.
+│   └── lib
+├── overrides - theme overrides
+│   ├── assets
+│   └── hooks
+└── src - Source Markdown and other files
+    ├── garden - Digital garden
+    │   └── daily-notes
+    │       └── posts
+    └── multiverse
+
+ +## Contributing + +I'll be open this up for community contributions once I ironed up the +needed infrastructure on it soon. ## License -MPL-2.0 for the source code, CC-BY-SA-4.0 for digital garden website contents, +MPL-2.0 for the source code, CC-BY-SA-4.0 for the wiki content + original media, unless otherwise specified. diff --git a/mkdocs.yml b/mkdocs.yml index 82b6521..aaccb9f 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -145,7 +145,7 @@ plugins: - search # Wiki Changelog feed - blog: - blog_dir: updates + blog_dir: changelog post_url_format: "{slug}" post_url_max_categories: 5 post_slugify: !!python/object/apply:pymdownx.slugs.slugify @@ -178,7 +178,7 @@ plugins: post_readtime: true - rss: enabled: true - match_path: (updates|garden/daily-notes)/posts/.* + match_path: (changelog|garden/daily-notes)/posts/.* date_from_meta: as_creation: date categories: diff --git a/src/updates/daily-updates/.gitkeep b/overrides/hooks/.gitkeep similarity index 100% rename from src/updates/daily-updates/.gitkeep rename to overrides/hooks/.gitkeep diff --git a/overrides/hooks/badges_shortcodes.py b/overrides/hooks/badges_shortcodes.py new file mode 100644 index 0000000..ab24a4d --- /dev/null +++ b/overrides/hooks/badges_shortcodes.py @@ -0,0 +1,156 @@ +from __future__ import annotations + +import posixpath +import re + +from mkdocs.config.defaults import MkDocsConfig +from mkdocs.structure.files import File, Files +from mkdocs.structure.pages import Page +from re import Match + + +# ----------------------------------------------------------------------------- +# Hooks +# ----------------------------------------------------------------------------- + +# @todo +def on_page_markdown( + markdown: str, *, page: Page, config: MkDocsConfig, files: Files +): + + # Replace callback + def replace(match: Match): + type, args = match.groups() + args = args.strip() + # Otherwise, raise an error + raise RuntimeError(f"Unknown shortcode: {type}") + + # Find and replace all external asset URLs in current page + return re.sub( + r"", + replace, markdown, flags = re.I | re.M + ) + +# ----------------------------------------------------------------------------- +# Helper functions +# ----------------------------------------------------------------------------- + +# Create a flag of a specific type +def flag(args: str, page: Page, files: Files): + type, *_ = args.split(" ", 1) + if type == "experimental": return _badge_for_experimental(page, files) + elif type == "required": return _badge_for_required(page, files) + elif type == "customization": return _badge_for_customization(page, files) + elif type == "metadata": return _badge_for_metadata(page, files) + elif type == "multiple": return _badge_for_multiple(page, files) + raise RuntimeError(f"Unknown type: {type}") + +# Create a linkable option +def option(type: str): + _, *_, name = re.split(r"[.:]", type) + return f"[`{name}`](#+{type}){{ #+{type} }}\n\n" + +# Create a linkable setting - @todo append them to the bottom of the page +def setting(type: str): + _, *_, name = re.split(r"[.*]", type) + return f"`{name}` {{ #{type} }}\n\n[{type}]: #{type}\n\n" +# ----------------------------------------------------------------------------- + +# Resolve path of file relative to given page - the posixpath always includes +# one additional level of `..` which we need to remove +def _resolve_path(path: str, page: Page, files: Files): + path, anchor, *_ = f"{path}#".split("#") + path = _resolve(files.get_file_from_path(path), page) + return "#".join([path, anchor]) if anchor else path + +# Resolve path of file relative to given page - the posixpath always includes +# one additional level of `..` which we need to remove +def _resolve(file: File, page: Page): + path = posixpath.relpath(file.src_uri, page.file.src_uri) + return posixpath.sep.join(path.split(posixpath.sep)[1:]) + +# ----------------------------------------------------------------------------- + +# Create badge +def _badge(icon: str, text: str = "", type: str = ""): + classes = f"mdx-badge mdx-badge--{type}" if type else "mdx-badge" + return "".join([ + f"", + *([f"{icon}"] if icon else []), + *([f"{text}"] if text else []), + f"", + ]) + +# Create sponsors badge +def _badge_for_sponsors(page: Page, files: Files): + icon = "material-heart" + href = _resolve_path("insiders/index.md", page, files) + return _badge( + icon = f"[:{icon}:]({href} 'Sponsors only')", + type = "heart" + ) + +# Create badge for default value +def _badge_for_default(text: str, page: Page, files: Files): + icon = "material-water" + href = _resolve_path("conventions.md#default", page, files) + return _badge( + icon = f"[:{icon}:]({href} 'Default value')", + text = text + ) + +# Create badge for empty default value +def _badge_for_default_none(page: Page, files: Files): + icon = "material-water-outline" + href = _resolve_path("conventions.md#default", page, files) + return _badge( + icon = f"[:{icon}:]({href} 'Default value is empty')" + ) + +# Create badge for computed default value +def _badge_for_default_computed(page: Page, files: Files): + icon = "material-water-check" + href = _resolve_path("conventions.md#default", page, files) + return _badge( + icon = f"[:{icon}:]({href} 'Default value is computed')" + ) + +# Create badge for metadata property flag +def _badge_for_metadata(page: Page, files: Files): + icon = "material-list-box-outline" + href = _resolve_path("conventions.md#metadata", page, files) + return _badge( + icon = f"[:{icon}:]({href} 'Metadata property')" + ) + +# Create badge for required value flag +def _badge_for_required(page: Page, files: Files): + icon = "material-alert" + href = _resolve_path("conventions.md#required", page, files) + return _badge( + icon = f"[:{icon}:]({href} 'Required value')" + ) + +# Create badge for customization flag +def _badge_for_customization(page: Page, files: Files): + icon = "material-brush-variant" + href = _resolve_path("conventions.md#customization", page, files) + return _badge( + icon = f"[:{icon}:]({href} 'Customization')" + ) + +# Create badge for multiple instance flag +def _badge_for_multiple(page: Page, files: Files): + icon = "material-inbox-multiple" + href = _resolve_path("conventions.md#multiple-instances", page, files) + return _badge( + icon = f"[:{icon}:]({href} 'Multiple instances')" + ) + +# Create badge for experimental flag +def _badge_for_experimental(page: Page, files: Files): + icon = "material-flask-outline" + href = _resolve_path("conventions.md#experimental", page, files) + return _badge( + icon = f"[:{icon}:]({href} 'Experimental')" + ) \ No newline at end of file diff --git a/overrides/hooks/magiclinks_rewriter.py b/overrides/hooks/magiclinks_rewriter.py index e8e3172..f339a04 100644 --- a/overrides/hooks/magiclinks_rewriter.py +++ b/overrides/hooks/magiclinks_rewriter.py @@ -1,4 +1,5 @@ -# This is a workaround for self-hosted GitLab instance +# This is a workaround for configuring self-hosted GitLab instance +# as base URL import pymdownx.magiclink base_url = "https://mau.dev" diff --git a/src/authors.yml b/src/authors.yml new file mode 100644 index 0000000..2d84f94 --- /dev/null +++ b/src/authors.yml @@ -0,0 +1,6 @@ +authors: + ajhalili2006: + name: Andrei Jiroh Halili + description: "#ActuallyAutistic SABDFL and maintainer at RecapTime.dev and writer outside school" + avatar: https://1.gravatar.com/avatar/177f692336ad517e8c70c622dc5abe9b?size=256 + url: https://wiki.andreijiroh.xyz/go/ajhalili2006 \ No newline at end of file diff --git a/src/updates/index.md b/src/changelog/index.md similarity index 100% rename from src/updates/index.md rename to src/changelog/index.md