diff options
Diffstat (limited to 'packages')
| -rw-r--r-- | packages/atomfeed.source.sh | 4 | ||||
| -rw-r--r-- | packages/gemfeed.source.sh | 6 | ||||
| -rw-r--r-- | packages/generate.source.sh | 48 | ||||
| -rw-r--r-- | packages/html.source.sh | 4 |
4 files changed, 31 insertions, 31 deletions
diff --git a/packages/atomfeed.source.sh b/packages/atomfeed.source.sh index 3a3e1e73..6d5a8f47 100644 --- a/packages/atomfeed.source.sh +++ b/packages/atomfeed.source.sh @@ -1,4 +1,4 @@ -# Retrieves meta data of a given blog post. Generate new meta info if not yet exists. +# Retrieve meta data of a given blog post. Generate new meta info if not yet exists. atomfeed::meta () { local -r gmi_file_path="$1"; shift local -r meta_file=$($SED 's|gemtext|meta|; s|.gmi$|.meta|;' <<< "$gmi_file_path") @@ -37,7 +37,7 @@ META test $is_draft == yes && rm "$meta_file" } -# Retrieves the core content as XHTML of the blog post, to include to the feed. +# Retrieve the core content as XHTML of the blog post. atomfeed::content () { local -r gmi_file_path="$1"; shift log VERBOSE "Retrieving feed content from $gmi_file_path" diff --git a/packages/gemfeed.source.sh b/packages/gemfeed.source.sh index c68c5070..182d6eb0 100644 --- a/packages/gemfeed.source.sh +++ b/packages/gemfeed.source.sh @@ -1,4 +1,4 @@ -# Filters out blog posts from other files in the gemfeed dir. +# Filter out blog posts from other files in the gemfeed dir. gemfeed::get_posts () { local -r gemfeed_dir="$CONTENT_DIR/gemtext/gemfeed" local -r gmi_pattern='^[0-9]{4}-[0-9]{2}-[0-9]{2}-.*\.gmi$' @@ -7,7 +7,7 @@ gemfeed::get_posts () { ls "$gemfeed_dir" | grep -E "$gmi_pattern" | grep -E -v "$draft_pattern" | sort -r } -# Adds the links from gemfeed/index.gmi to the main index site. +# Add the links from gemfeed/index.gmi to the main index site. gemfeed::updatemainindex () { local -r index_gmi="$CONTENT_DIR/gemtext/index.gmi" local -r gemfeed_dir="$CONTENT_DIR/gemtext/gemfeed" @@ -23,7 +23,7 @@ gemfeed::updatemainindex () { test "$ADD_GIT" == yes && git add "$index_gmi" } -# This generates a index.gmi in the ./gemfeed subdir. +# Generate a index.gmi in the ./gemfeed subdir. gemfeed::generate () { local -r gemfeed_dir="$CONTENT_DIR/gemtext/gemfeed" log INFO "Generating Gemfeed index for $gemfeed_dir" diff --git a/packages/generate.source.sh b/packages/generate.source.sh index 67a9b7e5..e74d2995 100644 --- a/packages/generate.source.sh +++ b/packages/generate.source.sh @@ -1,4 +1,4 @@ -# Generates a HTML or Markdown link from given Gemtext link. +# Generate a HTML or Markdown link from given Gemtext link. generate::make_link () { local -r what="$1"; shift local -r line="${1/=> }"; shift @@ -31,28 +31,7 @@ generate::make_link () { fi } -# Internal helper function for generate::fromgmi -generate::_fromgmi () { - local -r src="$1"; shift - local -r format="$1"; shift - local dest=${src/gemtext/$format} - dest=${dest/.gmi/.$format} - local dest_dir=$(dirname "$dest") - - test ! -d "$dest_dir" && mkdir -p "$dest_dir" - if [[ "$format" == html ]]; then - cat header.html.part > "$dest.tmp" - html::fromgmi < "$src" >> "$dest.tmp" - cat footer.html.part >> "$dest.tmp" - elif [[ "$format" == md ]]; then - md::fromgmi < "$src" >> "$dest.tmp" - fi - - mv "$dest.tmp" "$dest" - test "$ADD_GIT" == yes && git add "$dest" -} - -# Adds other docs (e.g. images, videos) from Gemtext to output format. +# Add other docs (e.g. images, videos) from Gemtext to output format. generate::fromgmi_add_docs () { local -r src="$1"; shift local -r format="$1"; shift @@ -74,7 +53,7 @@ generate::fromgmi_cleanup_docs () { test ! -f "$dest" && test "$ADD_GIT" == yes && git rm "$src" } -# Converts the Gemtext Atom feed to a HTML Atom feed. +# Convert the Gemtext Atom feed to a HTML Atom feed. generate::convert_gmi_atom_to_html_atom () { local -r format="$1"; shift test "$format" != html && return @@ -88,6 +67,27 @@ generate::convert_gmi_atom_to_html_atom () { test "$ADD_GIT" == yes && git add "$CONTENT_DIR/html/gemfeed/atom.xml" } +# Internal helper function for generate::fromgmi +generate::_fromgmi () { + local -r src="$1"; shift + local -r format="$1"; shift + local dest=${src/gemtext/$format} + dest=${dest/.gmi/.$format} + local dest_dir=$(dirname "$dest") + + test ! -d "$dest_dir" && mkdir -p "$dest_dir" + if [[ "$format" == html ]]; then + cat header.html.part > "$dest.tmp" + html::fromgmi < "$src" >> "$dest.tmp" + cat footer.html.part >> "$dest.tmp" + elif [[ "$format" == md ]]; then + md::fromgmi < "$src" >> "$dest.tmp" + fi + + mv "$dest.tmp" "$dest" + test "$ADD_GIT" == yes && git add "$dest" +} + # Generate a given output format from a Gemtext file. generate::fromgmi () { local -i num_gmi_files=0 diff --git a/packages/html.source.sh b/packages/html.source.sh index d295c7a7..cc79e612 100644 --- a/packages/html.source.sh +++ b/packages/html.source.sh @@ -51,7 +51,7 @@ html::make_link () { echo "<a class=\"textlink\" href=\"$link\">$descr</a><br />" } -## Convert Gemtext to HTML +# Convert Gemtext to HTML html::fromgmi () { local is_list=no local is_plain=no @@ -108,7 +108,7 @@ html::fromgmi () { done } -## Test HTML package. +# Test HTML package. html::test () { local line='Hello world! This is a paragraph.' assert::equals "$(html::make_paragraph "$line")" '<p>Hello world! This is a paragraph.</p>' |
