From 4c693622e5a0a9a41f630a934f39a66b09bbcbe7 Mon Sep 17 00:00:00 2001 From: Ludger Sicking Date: Wed, 30 Oct 2024 09:25:43 +0100 Subject: [PATCH] Hilfsskripte, um Blog-Posts in Hugos "content" Ordner zu migrieren --- sb/scripts/asset-extensions-in-folder-Blog.sh | 23 +++++++++++ .../move-blog-posts-to-hugo-content-dir.sh | 39 +++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 sb/scripts/asset-extensions-in-folder-Blog.sh create mode 100755 sb/scripts/move-blog-posts-to-hugo-content-dir.sh diff --git a/sb/scripts/asset-extensions-in-folder-Blog.sh b/sb/scripts/asset-extensions-in-folder-Blog.sh new file mode 100644 index 0000000..d367ed3 --- /dev/null +++ b/sb/scripts/asset-extensions-in-folder-Blog.sh @@ -0,0 +1,23 @@ +#welche Dateiendungen sind in den Markdown-Dateien in Verweisen enthalten: +grep -r -E '\.\w\w\w+\)' Blog/ | grep -v -E '\.html\)' \ +| grep -v -E '\.de\)' | grep -v -E '\.org\)' | grep -v -E '\.nrw\)' \ +| cut -d')' -f 1 | rev | cut -d'.' -f 1 | rev | sort -u + +# jpeg +# jpg +# JPG +# mp4 +# pdf +# png + +# 1970520 => AKRK.md +# education => GwR-Tagung + +# $grep -r -E '\.\w\w\w+\)' Blog/ | grep -v -E '\.html\)' | grep -v -E '\.de\)' | grep -v -E '\.org\)' | grep -v -E '\.nrw\)' | cut -d')' -f 1 | grep educa +# Blog/2024-09-17-GwR-Tagung.md:Unter dem spannenden Motto „...hier sollte eigentlich ein Titel stehen“ fand die diesjährige [GwR-Tagung](https://gwr.education + +# $grep -r -E '\.\w\w\w+\)' Blog/ | grep -v -E '\.html\)' | grep -v -E '\.de\)' | grep -v -E '\.org\)' | grep -v -E '\.nrw\)' | cut -d')' -f 1 | grep 1970 +# Blog/2024-10-02 AKRK.md:Wie OER insgesamt didaktische Prozesse verändern können und die Perspektive auf die Lernenden richten, beleuchtet auch die Forschung von [Eric Werth und Katherine Williams](https://doi.org/10.1080/02680513.2021.1970520 + +#welche Zeilen in Markdown Dateien enthalten "Asset"-Links,, die nicht in den Wordpress-Uploads vorhanden sind? +grep -r -E '\.\w\w\w+\)' Blog/ | grep -v -E '\.html\)' | grep -v -E '\.de\)' | grep -v -E '\.org\)' | grep -v -E '\.nrw\)' | cut -d')' -f 1 | grep -v 'oer\.comm' diff --git a/sb/scripts/move-blog-posts-to-hugo-content-dir.sh b/sb/scripts/move-blog-posts-to-hugo-content-dir.sh new file mode 100755 index 0000000..b889452 --- /dev/null +++ b/sb/scripts/move-blog-posts-to-hugo-content-dir.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -e + +working_directory=$(basename $(pwd)) +if [ "$working_directory" != "FOERBICO" ]; then + echo "not in root dir 'FOERBICO'" + exit 1 +fi + +OURTMPDIR='tmp-8JmqbYUnu' + +# script im root dir ausführen +find Blog -type f -name '*.md' | while read FILE ; do + echo 'erstelle Verzeichnis für Post' $FILE + post_directory=$(grep 'oerCommunityPermalink' "$FILE" | cut -d'/' -f 4) # "..." beachtet Leerzeichen im Dateinamen + + mkdir -p $OURTMPDIR + echo $post_directory >> $OURTMPDIR/permalink-all.txt + + mkdir -p sb/content/$post_directory + + echo 'kopiere' $FILE 'ins Verzeichnis als index.md' + cp "$FILE" sb/content/$post_directory/index.md + + #assets aus "wp-content" holen + asset_link_list=$(grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*" "$FILE" | grep wp-content | grep "oer\.community" | sed 's/http:/https:/g' | sort -u) + + cd "sb/content/$post_directory/" + + for wp_content_asset in $asset_link_list + do + asset_output_file_name=$(echo $wp_content_asset | rev | cut -d'/' -f 1 | rev) + curl -s --remote-name $wp_content_asset --output "$asset_output_file_name" + #rm $(basename $wp_content_asset) + done + + cd ../../../ + +done