diff options
| author | Paul Buetow <paul@buetow.org> | 2022-05-29 08:55:15 +0100 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2022-05-29 08:55:15 +0100 |
| commit | 05760b5505df4356e5b076a3e6bf0fd0056e052f (patch) | |
| tree | 015ec3549040f38da696eaab99e129d407a5f139 | |
| parent | 252432fae23e58f97b825f855ece4f6e8e1cf39f (diff) | |
strip out the git auto commit feature - as it was partly broken and difficult to fix
| -rw-r--r-- | README.md | 14 | ||||
| -rwxr-xr-x | gemtexter | 12 | ||||
| -rw-r--r-- | lib/atomfeed.source.sh | 3 | ||||
| -rw-r--r-- | lib/gemfeed.source.sh | 2 | ||||
| -rw-r--r-- | lib/generate.source.sh | 16 | ||||
| -rw-r--r-- | lib/git.source.sh | 81 | ||||
| -rw-r--r-- | lib/notes.source.sh | 12 |
7 files changed, 13 insertions, 127 deletions
@@ -77,19 +77,7 @@ You will find the `./htmlextras/header.html.part` and `./htmlextras/footer.html. ## Store all formats in Git -I personally have for each directory in `../foo.zone-content/` a separate Git repository configured. So whenever something has changed, it will be updated/added/removed to version control. The following will run the generator and commit everything to Git: - -``` -USE_GIT=yes ./gemtexter --generate -``` - -And the following will additionally perform a `git pull` and `git push` afterwards; - -``` -USE_GIT=yes GIT_PUSH=yes ./gemtexter --generate -``` - -You could add the `USE_GIT` and `GIT_PUSH` options to the `gemtexter.conf` config file too. +I personally have for each directory in `../foo.zone-content/` a separate Git repository configured. So whenever something changes I commit and push the content to git. ## Publishing a blog post @@ -27,7 +27,6 @@ else fi source ./lib/assert.source.sh -source ./lib/git.source.sh source ./lib/atomfeed.source.sh source ./lib/gemfeed.source.sh source ./lib/notes.source.sh @@ -41,13 +40,11 @@ help () { $0's possible arguments: --feed Generates Gemtext Atom feed and Gemfeed. --generate Generates all known output formats (html, md, ...). - If USE_GIT=yes set, all files will be commited to git too. - If GIT_PUSH=yes is set, all content will be pushed to origin. --test Only runs some shellcheck and unit tests. --version Prints out the version of gemtexter --help Prints this retty text. Example: - USE_GIT=yes GIT_PUSH=yes $0 --generate + $0 --generate HELPHERE } @@ -68,11 +65,6 @@ again. For a list of other available arguments run $0 --help - -Pro tip: You could make all the directories in $CONTENT_BASE_DIR separate git -repositories or branches. You can then run - USE_GIT=yes $0 --generate -so that all static files are commited to the content repositories too. END exit 1 fi @@ -91,14 +83,12 @@ main () { md::test ;; --feed) - git::cleanup html::test md::test gemfeed::generate atomfeed::generate ;; --generate) - git::cleanup html::test md::test gemfeed::generate & diff --git a/lib/atomfeed.source.sh b/lib/atomfeed.source.sh index dd2b28c..716ef5c 100644 --- a/lib/atomfeed.source.sh +++ b/lib/atomfeed.source.sh @@ -26,12 +26,10 @@ local meta_email="$EMAIL" local meta_title="$title" local meta_summary="$summary. .....to read on please visit my site." META - git::add meta "$meta_file" return fi cat "$meta_file" - git::add meta "$meta_file" } # Retrieve the core content as XHTML of the blog post. @@ -111,7 +109,6 @@ ATOMFOOTER if ! diff -u <($SED 3d "$atom_file") <($SED 3d "$atom_file.tmp"); then log INFO 'Feed got something new!' mv "$atom_file.tmp" "$atom_file" - git::add gemtext "$atom_file" else log INFO 'Nothing really new in the feed' rm "$atom_file.tmp" diff --git a/lib/gemfeed.source.sh b/lib/gemfeed.source.sh index ee5623f..1b2ee5c 100644 --- a/lib/gemfeed.source.sh +++ b/lib/gemfeed.source.sh @@ -22,7 +22,6 @@ gemfeed::updatemainindex () { "$gemfeed_dir/index.gmi" >> "$index_gmi.tmp" mv "$index_gmi.tmp" "$index_gmi" - git::add gemtext "$index_gmi" } gemfeed::_get_word_count () { @@ -58,7 +57,6 @@ GEMFEED done < <(gemfeed::get_posts) mv "$gemfeed_dir/index.gmi.tmp" "$gemfeed_dir/index.gmi" - git::add gemtext "$gemfeed_dir/index.gmi" gemfeed::updatemainindex } diff --git a/lib/generate.source.sh b/lib/generate.source.sh index 14642af..5482beb 100644 --- a/lib/generate.source.sh +++ b/lib/generate.source.sh @@ -42,7 +42,6 @@ generate::fromgmi_add_docs () { mkdir -p "$dest_dir" fi cp "$src" "$dest" - git::add "$format" "$dest" } # Remove docs from output format which aren't present in Gemtext anymore. @@ -53,7 +52,7 @@ generate::fromgmi_cleanup_docs () { dest=${dest/$format/gemtext} if [[ ! -f "$dest" ]]; then - git::rm "$format" "$src" + rm "$src" fi } @@ -69,8 +68,6 @@ generate::convert_gmi_atom_to_html_atom () { $SED 's|.gmi|.html|g; s|gemini://|https://|g' \ < $CONTENT_BASE_DIR/gemtext/gemfeed/atom.xml \ > $CONTENT_BASE_DIR/html/gemfeed/atom.xml - - git::add "$format" "$CONTENT_BASE_DIR/html/gemfeed/atom.xml" } # Internal helper function for generate::fromgmi @@ -111,8 +108,6 @@ generate::_fromgmi () { s|%%STYLESHEET_OVERRIDE%%|$stylesheet_override|g;" "$dest.tmp" mv "$dest.tmp" "$dest" fi - - git::add "$format" "$dest" } # Generate a given output format from a Gemtext file. @@ -124,6 +119,7 @@ generate::fromgmi () { while read -r src; do num_gmi_files=$(( num_gmi_files + 1 )) + log INFO "Generating output formats from $src" for format in "$@"; do generate::_fromgmi "$src" "$format" & done @@ -183,14 +179,8 @@ generate::fromgmi () { # Cleanup HTML extras rm $CONTENT_BASE_DIR/gemtext/{style.css,*.ttf} - if [[ -z "$GIT_COMMIT_MESSAGE" ]]; then - GIT_COMMIT_MESSAGE='Publishing new version' - fi - git::commit gemtext "$GIT_COMMIT_MESSAGE" - git::commit meta "$GIT_COMMIT_MESSAGE" - for format in "$@"; do - git::commit "$format" "$GIT_COMMIT_MESSAGE" log INFO "$format can be found in $CONTENT_BASE_DIR/$format now" done + log INFO "You may want to commit all changes to version control!" } diff --git a/lib/git.source.sh b/lib/git.source.sh deleted file mode 100644 index c51707b..0000000 --- a/lib/git.source.sh +++ /dev/null @@ -1,81 +0,0 @@ -# Git can not run concurrently -git::_lock () { - local -r lock="${CONTENT_BASE_DIR}/git.lock" - - while test -d $lock; do - sleep 0.1 - done - while ! mkdir $lock 2>/dev/null; do - sleep 0.1 - done -} - -git::_unlock () { - local -r lock="${CONTENT_BASE_DIR}/git.lock" - rmdir $lock - # log DEBUG "Removed $lock" -} - -git::cleanup () { - local -r lock="${CONTENT_BASE_DIR}/git.lock" - if [ -d "$lock" ]; then - git::_unlock - fi -} - -# Add a static content file to git -git::add () { - if [[ "$USE_GIT" != yes ]]; then - return - fi - - local -r content_dir="$CONTENT_BASE_DIR/$1"; shift - local file="$1"; shift - file=${file/$content_dir/.\/} - - git::_lock - cd "$content_dir" &>/dev/null - git add "$file" - cd - &>/dev/null - git::_unlock -} - -# Remove a static content file from git -git::rm () { - if [[ "$USE_GIT" != yes ]]; then - return - fi - - local -r content_dir="$CONTENT_BASE_DIR/$1"; shift - local file="$1"; shift - file=${file/$content_dir/.\/} - - git::_lock - cd "$content_dir" &>/dev/null - git rm "$file" - cd - &>/dev/null - git::_unlock -} - -# Commit all changes -git::commit () { - if [[ "$USE_GIT" != yes ]]; then - return - fi - - local -r content_dir="$CONTENT_BASE_DIR/$1"; shift - local -r message="$1"; shift - - git::_lock - cd "$content_dir" &>/dev/null - set +e - git commit -a -m "$message" - if [[ "$GIT_PUSH" == yes ]]; then - log INFO "Invoking git pull/push in $content_dir" - git pull - git push - fi - set -e - cd - &>/dev/null - git::_unlock -} diff --git a/lib/notes.source.sh b/lib/notes.source.sh index 559b218..b82631d 100644 --- a/lib/notes.source.sh +++ b/lib/notes.source.sh @@ -24,11 +24,15 @@ NOTES # Extract first heading as post title. local title=$($SED -n '/^# / { s/# //; p; q; }' \ "$notes_dir/$gmi_file" | tr '"' "'") - - echo "=> ./$gmi_file $title" >> \ - "$notes_dir/index.gmi.tmp" + echo "=> ./$gmi_file $title" >> "$notes_dir/index.gmi.tmp" done < <(notes::_get_notes) +cat <<NOTES >> "$notes_dir/index.gmi.tmp" + +That were all notes. Hope they were useful! + +=> ../ Go back to main site +NOTES + mv "$notes_dir/index.gmi.tmp" "$notes_dir/index.gmi" - git::add gemtext "$notes_dir/index.gmi" } |
