initial commit with stuff from arise
Some checks are pending
Deploy Arise to html branch / Deploy Arise (push) Waiting to run
Some checks are pending
Deploy Arise to html branch / Deploy Arise (push) Waiting to run
This commit is contained in:
commit
0faf445b39
62 changed files with 3401 additions and 0 deletions
37
lib/functions/inline/arise_help.sh
Normal file
37
lib/functions/inline/arise_help.sh
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#!/bin/bash
|
||||
#############
|
||||
# DESCRIPTION
|
||||
#############
|
||||
# Prints help
|
||||
#
|
||||
#############
|
||||
# Usage:
|
||||
# arise_help
|
||||
|
||||
arise_help() {
|
||||
cat <<EOF
|
||||
Arise, v$arise_version
|
||||
|
||||
Welcome to Arise, a static site generator written in Bash
|
||||
|
||||
Usage:
|
||||
------
|
||||
bash arise build -[k][f]
|
||||
# Builds the entire site
|
||||
available in all build modes:
|
||||
-k: Keeps source files in output
|
||||
-f: Force overwrite pre-existing output
|
||||
bash arise -[p|s|r][k][f]
|
||||
# Builds only specific parts of the site
|
||||
# Useful for testing purposes
|
||||
mutually exclusive options:
|
||||
-p: Build pages only mode
|
||||
-s: Build sitemap only mode
|
||||
-r: Build rss only mode
|
||||
|
||||
------
|
||||
Please visit GitHub for more detailed info:
|
||||
https://github.com/spectrasecure/arise
|
||||
|
||||
EOF
|
||||
}
|
||||
37
lib/functions/inline/arise_logo.sh
Normal file
37
lib/functions/inline/arise_logo.sh
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#!/bin/bash
|
||||
#############
|
||||
# DESCRIPTION
|
||||
#############
|
||||
# Displays ASCII art of the Arise logo :)
|
||||
#
|
||||
#############
|
||||
# Usage:
|
||||
# arise_logo
|
||||
|
||||
arise_logo() {
|
||||
cat <<EOF
|
||||
=========================================================
|
||||
=========================================================
|
||||
|
||||
@@@
|
||||
@@#@ @####@@@ ##@ @@@#+@@@@@ @@@@@@@@@@
|
||||
@++@ @+++++++@ ++@ @+++++++@ @++++++++@
|
||||
@+++@ @++@@@*++@ ++@ @++++++++@ @+++++++@
|
||||
@@+*+@ @++@ @@+@ ++@ @++@#+@@@ @@@@@@@@@
|
||||
@++@+@ @++@ @++@ ++@ @++@#+@
|
||||
@++@@+@ @++@ @++@ ++@ @++@#+@@@ @@@@@@@@@
|
||||
@#+#@@+@ @++@ @++@ ++@ *+++++++@ @+++++++@
|
||||
@+++@@+@ @++@++@ ++@ @@+++++++ @+++++++@
|
||||
@++++@@+@ @@@@@++++@ ++@ @@#+@@++@ @@@@@@@@@
|
||||
@#+@@++@+@ @++++++#@ ++@ #+@@++@
|
||||
@++@ @+++@ @+@@@@++@ ++@ @@@#+@@++@ @@@@@@@@@@
|
||||
@++@ @+++@ @+@ @++@ ++@ @++++++++ @++++++++@
|
||||
@*+@@ @++@ @+@ @++@ ++@ ++++++++@ @++++++++@
|
||||
@@@@ @@@ @@@ @@@@ @@@ @@@@#+@@@ @@@@@@@@@@
|
||||
@@@
|
||||
|
||||
=========================================================
|
||||
=========================================================
|
||||
|
||||
EOF
|
||||
}
|
||||
13
lib/functions/inline/build_footer.sh
Normal file
13
lib/functions/inline/build_footer.sh
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
#############
|
||||
# DESCRIPTION
|
||||
#############
|
||||
# Appends the footer/closing tags to a page.
|
||||
#
|
||||
#############
|
||||
# Usage:
|
||||
# build_footer destination.html
|
||||
|
||||
build_footer() {
|
||||
cat $config/footer.html >> $1
|
||||
}
|
||||
38
lib/functions/inline/build_header.sh
Normal file
38
lib/functions/inline/build_header.sh
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#!/bin/bash
|
||||
#############
|
||||
# DESCRIPTION
|
||||
#############
|
||||
# Builds the page header
|
||||
#
|
||||
# This function assumes that metadata has already been fetched in the current subshell. If no metadata is present, it will do nothing.
|
||||
#
|
||||
#############
|
||||
# Usage:
|
||||
# build_header destination.html
|
||||
|
||||
build_header() {
|
||||
# Verify that metadata variables are populated before running.
|
||||
[[ $title != '' ]] && {
|
||||
cat $config/header.html > $1
|
||||
|
||||
# If enabled (default:true), add a configurable content header after the metadata header. The purpose of this is to enable a standardised header for stuff like post dates that should be on *most* pages, but can be disabled on pages the user considers special and wants to build out completely on their own.
|
||||
[[ $content_header == "true" ]] && cat $config/content_header.html >> $1
|
||||
|
||||
# Replace all tags in {{this format}} with their value. We do this using Bash pattern replacement.
|
||||
page_contents="$(cat $1)"
|
||||
|
||||
page_contents="${page_contents//\{\{title\}\}/"$title"}"
|
||||
page_contents="${page_contents//\{\{author\}\}/"$author"}"
|
||||
page_contents="${page_contents//\{\{description\}\}/"$description"}"
|
||||
page_contents="${page_contents//\{\{language\}\}/"$language"}"
|
||||
page_contents="${page_contents//\{\{thumbnail\}\}/"$thumbnail"}"
|
||||
page_contents="${page_contents//\{\{published_date\}\}/"$published_date"}"
|
||||
page_contents="${page_contents//\{\{modified_date\}\}/"$modified_date"}"
|
||||
page_contents="${page_contents//\{\{canonical_url\}\}/"$canonical_url"}"
|
||||
page_contents="${page_contents//\{\{base_url\}\}/"$base_url"}"
|
||||
page_contents="${page_contents//\{\{global_name\}\}/"$global_name"}"
|
||||
|
||||
echo "$page_contents" > $1
|
||||
page_contents=""
|
||||
}
|
||||
}
|
||||
25
lib/functions/inline/clean_xml_string.sh
Normal file
25
lib/functions/inline/clean_xml_string.sh
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#!/bin/bash
|
||||
#############
|
||||
# DESCRIPTION
|
||||
#############
|
||||
# Cleans special characters out of a string intended for use in xml format
|
||||
#
|
||||
#############
|
||||
# Usage:
|
||||
# clean_xml_string "string with special characters"
|
||||
|
||||
clean_xml_string() {
|
||||
# unclean string -> clean string
|
||||
input_string="$1"
|
||||
# replace & with &
|
||||
input_string=${input_string//\&/\&}
|
||||
# replace < with <
|
||||
input_string=${input_string//</\<}
|
||||
# replace > with >
|
||||
input_string=${input_string//>/\>}
|
||||
# replace ' with '
|
||||
input_string=${input_string//\'/\'}
|
||||
# replace " with "
|
||||
input_string=${input_string//\"/\"}
|
||||
echo "$input_string"
|
||||
}
|
||||
22
lib/functions/inline/clear_metadata.sh
Normal file
22
lib/functions/inline/clear_metadata.sh
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
#############
|
||||
# DESCRIPTION
|
||||
#############
|
||||
# Clears the metadata variables to prevent metadata from carrying over to the wrong page. This is important because of how promiscuous bash is with its variables.
|
||||
#
|
||||
#############
|
||||
# Usage:
|
||||
# clear_metadata
|
||||
|
||||
clear_metadata() {
|
||||
metadata=''
|
||||
title=''
|
||||
author=''
|
||||
description=''
|
||||
language=''
|
||||
thumbnail=''
|
||||
published_date=''
|
||||
modified_date=''
|
||||
relative_url=''
|
||||
canonical_url=''
|
||||
}
|
||||
96
lib/functions/inline/get_page_metadata.sh
Normal file
96
lib/functions/inline/get_page_metadata.sh
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
#!/bin/bash
|
||||
#############
|
||||
# DESCRIPTION
|
||||
#############
|
||||
# Pulls all the Arise-specific metadata from the header of a given page.
|
||||
#
|
||||
# This function is meant to be run inline before other functions so that it can populate the information other functions need to operate upon.
|
||||
#
|
||||
#############
|
||||
# Usage:
|
||||
# get_page_metadata source.md
|
||||
|
||||
get_page_metadata() {
|
||||
if [[ -e $1 ]]; then
|
||||
metadata=$(sed -e '/END ARISE/,$d' < $1)
|
||||
|
||||
# Main page metadata
|
||||
title="$(grep "Title::" <<< $metadata)" # Grab the line with the metadata we want
|
||||
title="${title%\"}" # Remove the trailing quote at the end
|
||||
title="${title#Title:: }" # Remove the name of the metadata variable from the start
|
||||
title="${title#\"}" # Remove the quote at the start of the parsed variable
|
||||
|
||||
author="$(grep "Author::" <<< $metadata)"
|
||||
author="${author%\"}"
|
||||
author="${author#Author:: }"
|
||||
author="${author#\"}"
|
||||
|
||||
description="$(grep "Description::" <<< $metadata)"
|
||||
description="${description%\"}"
|
||||
description="${description#Description:: }"
|
||||
description="${description#\"}"
|
||||
|
||||
language="$(grep "Language::" <<< $metadata)"
|
||||
language="${language%\"}"
|
||||
language="${language#Language:: }"
|
||||
language="${language#\"}"
|
||||
|
||||
thumbnail="$(grep "Thumbnail::" <<< $metadata)"
|
||||
thumbnail="${thumbnail%\"}"
|
||||
thumbnail="${thumbnail#Thumbnail:: }"
|
||||
thumbnail="${thumbnail#\"}"
|
||||
|
||||
published_date="$(grep "Published Date::" <<< $metadata)"
|
||||
published_date="${published_date%\"}"
|
||||
published_date="${published_date#Published Date:: }"
|
||||
published_date="${published_date#\"}"
|
||||
|
||||
modified_date="$(grep "Modified Date::" <<< $metadata)"
|
||||
modified_date="${modified_date%\"}"
|
||||
modified_date="${modified_date#Modified Date:: }"
|
||||
modified_date="${modified_date#\"}"
|
||||
|
||||
# Clean metadata of XML special characters so we don't break the sitemap or RSS feed
|
||||
title="$(clean_xml_string "$title")"
|
||||
author="$(clean_xml_string "$author")"
|
||||
description="$(clean_xml_string "$description")"
|
||||
language="$(clean_xml_string "$language")"
|
||||
thumbnail="$(clean_xml_string "$thumbnail")"
|
||||
published_date="$(clean_xml_string "$published_date")"
|
||||
modified_date="$(clean_xml_string "$modified_date")"
|
||||
|
||||
# Optional page settings with default settings
|
||||
|
||||
# is_toc default: false
|
||||
is_toc=$(grep "toc::" <<< $metadata | cut -d '"' -f2)
|
||||
if [[ $is_toc != "true" ]]; then
|
||||
is_toc="false"
|
||||
fi
|
||||
|
||||
# process_markdown default: true
|
||||
process_markdown=$(grep "process_markdown::" <<< $metadata | cut -d '"' -f2)
|
||||
if [[ $process_markdown != "false" ]]; then
|
||||
process_markdown="true"
|
||||
fi
|
||||
|
||||
# content_header default: true
|
||||
content_header=$(grep "content_header::" <<< $metadata | cut -d '"' -f2)
|
||||
if [[ $content_header != "false" ]]; then
|
||||
content_header="true"
|
||||
fi
|
||||
|
||||
# rss_hide default: false
|
||||
rss_hide=$(grep "rss_hide::" <<< $metadata | cut -d '"' -f2)
|
||||
if [[ $rss_hide != "true" ]]; then
|
||||
rss_hide="false"
|
||||
fi
|
||||
|
||||
# URL
|
||||
relative_url="$(realpath $(dirname $1) | sed 's@.*arise-out@@g')"'/'
|
||||
canonical_url="$base_url""$relative_url"
|
||||
else
|
||||
# Clear out metadata so that anything calling this function expecting to get new data cannot get old values on accident if the requested file does not exist.
|
||||
clear_metadata
|
||||
fi
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue