2024-10-30 08:25:43 +00:00
|
|
|
#!/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"
|
2024-10-30 11:17:17 +00:00
|
|
|
#FIXME
|
|
|
|
#TODO
|
|
|
|
# es werden nur assets von oer.community heruntergeladen und z. B. nicht von pad.gwdg.de
|
2024-10-30 08:25:43 +00:00
|
|
|
#rm $(basename $wp_content_asset)
|
|
|
|
done
|
|
|
|
|
|
|
|
cd ../../../
|
|
|
|
|
|
|
|
done
|