43 lines
1.3 KiB
Bash
Executable file
43 lines
1.3 KiB
Bash
Executable file
#!/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"
|
|
#FIXME
|
|
#TODO
|
|
# es werden nur assets von oer.community heruntergeladen und z. B. nicht von pad.gwdg.de
|
|
#rm $(basename $wp_content_asset)
|
|
done
|
|
|
|
cd ../../../
|
|
|
|
done
|