From d8bd82570d9b83e7ec125d37e3af22bbd0b02eb9 Mon Sep 17 00:00:00 2001 From: Ryan Kes <> Date: Mon, 6 Jul 2020 17:07:22 +0200 Subject: [PATCH] added script to export wiki --- README.org | 6 ++++++ blog/.local/bin/exportWiki | 17 +++++++++++++++++ .../.local/share/pandoc/filters/convertLinks.py | 17 +++++++++++++++++ install | 7 ++++++- 4 files changed, 46 insertions(+), 1 deletion(-) create mode 100755 blog/.local/bin/exportWiki create mode 100755 blog/.local/share/pandoc/filters/convertLinks.py diff --git a/README.org b/README.org index d5999cd..421b335 100644 --- a/README.org +++ b/README.org @@ -10,6 +10,8 @@ - [[#applications-installed-by-script][Applications installed by script]] - [[#applications][Applications]] - [[#fonts][Fonts]] + - [[#libraries][Libraries]] + - [[#python][Python]] - [[#lsp-backends][LSP Backends]] - [[#configured-applications-also-installed-by-script][Configured Applications (also installed by script)]] - [[#configured-locales][Configured Locales]] @@ -66,6 +68,7 @@ A repository of my personal configuration files. - [[https://mpv.io/][mpv]] - [[https://www.npmjs.com/get-npm][npm]] - [[https://github.com/cdemoulins/pamixer][pamixer]] +- [[https://pandoc.org/][Pandoc]] - [[https://github.com/dylanaraps/pfetch][pfetch]] - [[https://github.com/altdesktop/playerctl][Playerctl]] - [[https://www.freedesktop.org/wiki/Software/PulseAudio/][Pulseaudio]] @@ -86,6 +89,9 @@ A repository of my personal configuration files. - [[https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts/FiraCode][Fira Code Nerd Patched]] - [[https://www.google.com/get/noto/][Noto]] - [[https://savannah.gnu.org/projects/unifont/][Unifont]] +** Libraries +*** Python +- [[http://scorreia.com/software/panflute/][Panflute]] ** LSP Backends - [[https://github.com/mads-hartmann/bash-language-server][bash-language-server]] - [[https://github.com/MaskRay/ccls][ccls]] diff --git a/blog/.local/bin/exportWiki b/blog/.local/bin/exportWiki new file mode 100755 index 0000000..e5feec1 --- /dev/null +++ b/blog/.local/bin/exportWiki @@ -0,0 +1,17 @@ +#!/bin/sh + +fromDir="$HOME/Documents/org-roam/" +toDir="$HOME/devel/personal/Ryankes.eu/wiki" +date=$(date) + +rm -rf "$toDir"/wiki/* +grep -ril "^\#+tags:[\ a-zA-Z0-9]namepage" "$fromDir"*.org | while read -r line; do + baseName="$(basename "$line")" + markdownFilename="$(echo "$baseName" | cut -f 1 -d '.').md" + pandoc "$line" --filter convertLinks.py -t markdown_mmd+yaml_metadata_block -o "$toDir/wiki/$markdownFilename" -s + echo "Exporting $baseName to $markdownFilename" +done + +git -C "$toDir" add . +git -C "$toDir" commit -m "Update $date" +git -C "$toDir" push origin master diff --git a/blog/.local/share/pandoc/filters/convertLinks.py b/blog/.local/share/pandoc/filters/convertLinks.py new file mode 100755 index 0000000..8ddc4e9 --- /dev/null +++ b/blog/.local/share/pandoc/filters/convertLinks.py @@ -0,0 +1,17 @@ +#!/usr/bin/python + +import re +import panflute as pf + +# Convert org mode links to links Gatsby will understand +def action(elem, doc): + if isinstance(elem, pf.Link): + matches = list(re.finditer(r"(\.org)", elem.url)) + if matches: + m = matches[-1] + elem.url = "/wiki/" + elem.url[: m.start(1)] + elem.url[m.end(1) :] + return elem + + +if __name__ == "__main__": + pf.run_filter(action) diff --git a/install b/install index f349090..46f7138 100755 --- a/install +++ b/install @@ -1,8 +1,9 @@ #!/usr/bin/env fish # Prerequisite & inistalled apps -set prerequisiteApps bat broot brave caffeine-ng exa fslint fzf graphviz isync imagemagick lightdm-gtk-greeter mailcap deadd-notification-center-bin npm pamixer pfetch playerctl pulseaudio pulsemixer python pywal stow sxiv tldr trayer udisks2 xwallpaper yarn xprop zathura +set prerequisiteApps bat broot brave caffeine-ng exa fslint fzf graphviz isync imagemagick lightdm-gtk-greeter mailcap deadd-notification-center-bin npm pandoc-bin pamixer pfetch playerctl pulseaudio pulsemixer python pywal stow sxiv tldr trayer udisks2 xwallpaper yarn xprop zathura set prerequisiteFonts otf-nerd-fonts-fira-code noto-fonts ttf-unifont +set prerequisiteLibraries python-panflute set prerequisiteLsp bash-language-server ccls php-language-server python-language-server typescript-language-server-bin vscode-css-languageserver-bin vscode-html-languageserver-bin nodejs-intelephense set configuredApps alacritty bspwm castero emacs firejail git gnupg gtk lf deadd-notification-center-bin mpd mpv mpv-mpris ncmpcpp neomutt neovim picom redshift spotifyd-dbus-mpris sxhkd tmux tuir weechat set locales aspell-en hunspell-en_GB hunspell-en_US hunspell-nl @@ -45,6 +46,10 @@ for font in $prerequisiteFonts install_app_if_not_exist "$font" end +for library in $prerequisiteLibraries + install_app_if_not_exist "$library" +end + for lsp in $prerequisiteLsp install_app_if_not_exist "$lsp" end