Add .config/DankMaterialShell/firefox.css
Add .config/DankMaterialShell/plugin_settings.json Add .config/DankMaterialShell/plugins/dankDesktopWeather.meta Add .config/DankMaterialShell/plugins/dankHooks.meta Add .config/DankMaterialShell/plugins/desktopCommand/LICENSE Add .config/DankMaterialShell/plugins/desktopCommand/README.md Add .config/DankMaterialShell/plugins/desktopCommand/Settings.qml Add .config/DankMaterialShell/plugins/desktopCommand/Widget.qml Add .config/DankMaterialShell/plugins/desktopCommand/assets/screenshot.jpg Add .config/DankMaterialShell/plugins/desktopCommand/.git/HEAD Add .config/DankMaterialShell/plugins/desktopCommand/.git/config Add .config/DankMaterialShell/plugins/desktopCommand/.git/index Add .config/DankMaterialShell/plugins/desktopCommand/.git/objects/info/.keep Add .config/DankMaterialShell/plugins/desktopCommand/.git/objects/pack/pack-c2ca48eacecc3ab45931476641d058a89d755775.idx Add .config/DankMaterialShell/plugins/desktopCommand/.git/objects/pack/pack-c2ca48eacecc3ab45931476641d058a89d755775.rev Add .config/DankMaterialShell/plugins/desktopCommand/.git/objects/pack/pack-c2ca48eacecc3ab45931476641d058a89d755775.pack Add .config/DankMaterialShell/plugins/desktopCommand/.git/refs/heads/main Add .config/DankMaterialShell/plugins/desktopCommand/.git/refs/remotes/origin/main Add .config/DankMaterialShell/plugins/desktopCommand/.git/refs/tags/.keep Add .config/DankMaterialShell/plugins/desktopCommand/.gitignore Add .config/DankMaterialShell/plugins/desktopCommand/wrapCommand Add .config/DankMaterialShell/plugins/desktopCommand/plugin.json Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/DankActions/DankActionsSettings.qml Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/DankActions/DankActionsWidget.qml Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/DankActions/plugin.json Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/DankBatteryAlerts/DankBatteryAlerts.qml Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/DankBatteryAlerts/DankBatteryAlertsSettings.qml Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/DankBatteryAlerts/plugin.json Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/DankDesktopWeather/DankDesktopWeather.qml Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/DankDesktopWeather/DankDesktopWeatherSettings.qml Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/DankDesktopWeather/plugin.json Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/DankHooks/DankHooks.qml Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/DankHooks/DankHooksSettings.qml Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/DankHooks/README.md Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/DankHooks/plugin.json Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/DankPomodoroTimer/DankPomodoroSettings.qml Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/DankPomodoroTimer/DankPomodoroWidget.qml Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/DankPomodoroTimer/plugin.json Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/LICENSE Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/README.md Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/.git/HEAD Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/.git/config Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/.git/index Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/.git/objects/info/.keep Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/.git/objects/pack/pack-3221a15c022ef4a7bb6bf2c47e40068b66b3588b.idx Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/.git/objects/pack/pack-3221a15c022ef4a7bb6bf2c47e40068b66b3588b.rev Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/.git/objects/pack/pack-9aca069a8b76b40fcc472eba1ed9b8219a87776b.idx Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/.git/objects/pack/pack-9aca069a8b76b40fcc472eba1ed9b8219a87776b.rev Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/.git/objects/pack/pack-e6f6cdfe9914bfb4a5717ef6036821794d59ab4b.idx Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/.git/objects/pack/pack-e6f6cdfe9914bfb4a5717ef6036821794d59ab4b.rev Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/.git/objects/pack/pack-3221a15c022ef4a7bb6bf2c47e40068b66b3588b.pack Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/.git/objects/pack/pack-9aca069a8b76b40fcc472eba1ed9b8219a87776b.pack Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/.git/objects/pack/pack-e6f6cdfe9914bfb4a5717ef6036821794d59ab4b.pack Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/.git/refs/heads/master Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/.git/refs/remotes/origin/master Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/.git/refs/tags/.keep Add .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/.gitignore Add .config/DankMaterialShell/plugins/emojiLauncher/EmojiLauncher.qml Add .config/DankMaterialShell/plugins/emojiLauncher/EmojiLauncherSettings.qml Add .config/DankMaterialShell/plugins/emojiLauncher/LICENSE Add .config/DankMaterialShell/plugins/emojiLauncher/README.md Add .config/DankMaterialShell/plugins/emojiLauncher/catalog.js Add .config/DankMaterialShell/plugins/emojiLauncher/data/emojis.txt Add .config/DankMaterialShell/plugins/emojiLauncher/data/math.txt Add .config/DankMaterialShell/plugins/emojiLauncher/data/nerdfont.txt Add .config/DankMaterialShell/plugins/emojiLauncher/.git/HEAD Add .config/DankMaterialShell/plugins/emojiLauncher/.git/config Add .config/DankMaterialShell/plugins/emojiLauncher/.git/index Add .config/DankMaterialShell/plugins/emojiLauncher/.git/objects/info/.keep Add .config/DankMaterialShell/plugins/emojiLauncher/.git/objects/pack/pack-e04a5b1ea381dc3a792b8bf08cf70e735b195c0d.idx Add .config/DankMaterialShell/plugins/emojiLauncher/.git/objects/pack/pack-e04a5b1ea381dc3a792b8bf08cf70e735b195c0d.rev Add .config/DankMaterialShell/plugins/emojiLauncher/.git/objects/pack/pack-e04a5b1ea381dc3a792b8bf08cf70e735b195c0d.pack Add .config/DankMaterialShell/plugins/emojiLauncher/.git/refs/heads/main Add .config/DankMaterialShell/plugins/emojiLauncher/.git/refs/remotes/origin/main Add .config/DankMaterialShell/plugins/emojiLauncher/.git/refs/tags/.keep Add .config/DankMaterialShell/plugins/emojiLauncher/plugin.json Add .config/DankMaterialShell/plugins/emojiLauncher/screenshot.png Add .config/DankMaterialShell/plugins/emojiLauncher/scripts/generate_catalog.py Add .config/DankMaterialShell/plugins/mediaPlayer/MediaPlayerSettings.qml Add .config/DankMaterialShell/plugins/mediaPlayer/MediaPlayerTab.qml Add .config/DankMaterialShell/plugins/mediaPlayer/README.md Add .config/DankMaterialShell/plugins/mediaPlayer/.git/HEAD Add .config/DankMaterialShell/plugins/mediaPlayer/.git/config Add .config/DankMaterialShell/plugins/mediaPlayer/.git/index Add .config/DankMaterialShell/plugins/mediaPlayer/.git/objects/info/.keep Add .config/DankMaterialShell/plugins/mediaPlayer/.git/objects/pack/pack-0b9cb33f7da23f6ff361ee3aa5117928714bc3be.idx Add .config/DankMaterialShell/plugins/mediaPlayer/.git/objects/pack/pack-0b9cb33f7da23f6ff361ee3aa5117928714bc3be.rev Add .config/DankMaterialShell/plugins/mediaPlayer/.git/objects/pack/pack-0b9cb33f7da23f6ff361ee3aa5117928714bc3be.pack Add .config/DankMaterialShell/plugins/mediaPlayer/.git/refs/heads/main Add .config/DankMaterialShell/plugins/mediaPlayer/.git/refs/remotes/origin/main Add .config/DankMaterialShell/plugins/mediaPlayer/.git/refs/tags/.keep Add .config/DankMaterialShell/plugins/mediaPlayer/plugin.json Add .config/DankMaterialShell/plugins/mediaPlayer/screenshot_8.png Add .config/DankMaterialShell/plugins/dankDesktopWeather Add .config/DankMaterialShell/plugins/dankHooks Add .config/DankMaterialShell/settings.json
This commit is contained in:
parent
9d16d6e6b0
commit
b18328bbad
96 changed files with 24119 additions and 0 deletions
|
|
@ -0,0 +1,161 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Builds the catalog.js bundle from the plain-text data sources."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
DATA = ROOT / "data"
|
||||
OUTPUT = ROOT / "catalog.js"
|
||||
|
||||
|
||||
def main() -> None:
|
||||
emoji_entries = parse_emoji(DATA / "emojis.txt")
|
||||
unicode_entries = parse_unicode(DATA / "math.txt")
|
||||
nerd_font_entries = parse_nerdfont(DATA / "nerdfont.txt")
|
||||
|
||||
write_catalog(
|
||||
emoji_entries=emoji_entries,
|
||||
unicode_entries=unicode_entries,
|
||||
nerd_font_entries=nerd_font_entries,
|
||||
)
|
||||
|
||||
|
||||
def parse_emoji(path: Path) -> list[dict]:
|
||||
return _parse_symbol_file(
|
||||
path,
|
||||
key_name="emoji",
|
||||
extra_keywords=lambda raw: [],
|
||||
)
|
||||
|
||||
|
||||
def parse_unicode(path: Path) -> list[dict]:
|
||||
return _parse_symbol_file(
|
||||
path,
|
||||
key_name="char",
|
||||
extra_keywords=lambda raw: [],
|
||||
)
|
||||
|
||||
|
||||
def parse_nerdfont(path: Path) -> list[dict]:
|
||||
def extra_keywords(raw: str) -> list[str]:
|
||||
extras = ["nerdfont", raw]
|
||||
if raw.startswith("ple-"):
|
||||
extras.extend(["powerline", "ple"])
|
||||
return extras
|
||||
|
||||
entries = _parse_symbol_file(
|
||||
path,
|
||||
key_name="char",
|
||||
preprocess_name=lambda name: re.sub(r"[_-]+", " ", name).strip(),
|
||||
extra_keywords=extra_keywords,
|
||||
)
|
||||
|
||||
for entry in entries:
|
||||
name = entry.get("name", "")
|
||||
if name.startswith("Ple "):
|
||||
entry["name"] = "Powerline " + name[4:]
|
||||
|
||||
return entries
|
||||
|
||||
|
||||
def _parse_symbol_file(
|
||||
path: Path,
|
||||
*,
|
||||
key_name: str,
|
||||
preprocess_name=lambda name: name,
|
||||
extra_keywords=lambda raw: [],
|
||||
) -> list[dict]:
|
||||
text = path.read_text(encoding="utf-8")
|
||||
entries: list[dict] = []
|
||||
|
||||
for raw_line in text.splitlines():
|
||||
if not raw_line:
|
||||
continue
|
||||
trimmed = raw_line.strip()
|
||||
if not trimmed or trimmed.startswith("#"):
|
||||
continue
|
||||
|
||||
match = re.match(r"^(\S+|\s)\s+(.*)$", raw_line)
|
||||
if not match:
|
||||
continue
|
||||
|
||||
symbol = match.group(1)
|
||||
raw_name = match.group(2).strip()
|
||||
|
||||
if not raw_name or ".." in symbol:
|
||||
continue
|
||||
|
||||
cleaned_name = preprocess_name(raw_name) or raw_name
|
||||
friendly = prettify_name(cleaned_name)
|
||||
keywords = build_keywords(cleaned_name, extra_keywords(raw_name))
|
||||
|
||||
entry = {
|
||||
key_name: symbol,
|
||||
"name": friendly,
|
||||
"keywords": keywords,
|
||||
}
|
||||
entries.append(entry)
|
||||
|
||||
return entries
|
||||
|
||||
|
||||
def prettify_name(raw: str) -> str:
|
||||
tokens = [token for token in re.split(r"\s+", raw) if token]
|
||||
return " ".join(token.capitalize() for token in tokens)
|
||||
|
||||
|
||||
def build_keywords(raw: str, extras: list[str]) -> list[str]:
|
||||
seen: set[str] = set()
|
||||
keywords: list[str] = []
|
||||
|
||||
def add_token(token: str) -> None:
|
||||
lowered = token.lower()
|
||||
if lowered and lowered not in seen:
|
||||
seen.add(lowered)
|
||||
keywords.append(lowered)
|
||||
|
||||
def tokenize(value: str) -> list[str]:
|
||||
return [part for part in re.split(r"[^a-zA-Z0-9+]+", value.lower()) if part]
|
||||
|
||||
for token in tokenize(raw):
|
||||
add_token(token)
|
||||
|
||||
for extra in extras:
|
||||
for token in tokenize(extra):
|
||||
add_token(token)
|
||||
|
||||
return keywords
|
||||
|
||||
|
||||
def write_catalog(*, emoji_entries, unicode_entries, nerd_font_entries) -> None:
|
||||
OUTPUT.write_text(
|
||||
"\n".join(
|
||||
[
|
||||
"// Auto-generated by scripts/generate_catalog.py",
|
||||
"// Do not edit manually.",
|
||||
".pragma library",
|
||||
"",
|
||||
f"var emojiEntries = {json.dumps(emoji_entries, ensure_ascii=False)};",
|
||||
f"var unicodeEntries = {json.dumps(unicode_entries, ensure_ascii=False)};",
|
||||
f"var nerdFontEntries = {json.dumps(nerd_font_entries, ensure_ascii=False)};",
|
||||
"",
|
||||
"function clone(array) {",
|
||||
" return array ? array.slice() : [];",
|
||||
"}",
|
||||
"",
|
||||
"function getEmojiEntries() { return clone(emojiEntries); }",
|
||||
"function getUnicodeEntries() { return clone(unicodeEntries); }",
|
||||
"function getNerdFontEntries() { return clone(nerdFontEntries); }",
|
||||
]
|
||||
)
|
||||
+ "\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue