initial commit with stuff from arise
Some checks are pending
Deploy Arise to html branch / Deploy Arise (push) Waiting to run

This commit is contained in:
Wheaterwax 2025-09-01 18:57:24 -03:00
commit 0faf445b39
62 changed files with 3401 additions and 0 deletions

View 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
}

View file

@ -0,0 +1,37 @@
#!/bin/bash
#############
# DESCRIPTION
#############
# Displays ASCII art of the Arise logo :)
#
#############
# Usage:
# arise_logo
arise_logo() {
cat <<EOF
=========================================================
=========================================================
@@@
@@#@ @####@@@ ##@ @@@#+@@@@@ @@@@@@@@@@
@++@ @+++++++@ ++@ @+++++++@ @++++++++@
@+++@ @++@@@*++@ ++@ @++++++++@ @+++++++@
@@+*+@ @++@ @@+@ ++@ @++@#+@@@ @@@@@@@@@
@++@+@ @++@ @++@ ++@ @++@#+@
@++@@+@ @++@ @++@ ++@ @++@#+@@@ @@@@@@@@@
@#+#@@+@ @++@ @++@ ++@ *+++++++@ @+++++++@
@+++@@+@ @++@++@ ++@ @@+++++++ @+++++++@
@++++@@+@ @@@@@++++@ ++@ @@#+@@++@ @@@@@@@@@
@#+@@++@+@ @++++++#@ ++@ #+@@++@
@++@ @+++@ @+@@@@++@ ++@ @@@#+@@++@ @@@@@@@@@@
@++@ @+++@ @+@ @++@ ++@ @++++++++ @++++++++@
@*+@@ @++@ @+@ @++@ ++@ ++++++++@ @++++++++@
@@@@ @@@ @@@ @@@@ @@@ @@@@#+@@@ @@@@@@@@@@
@@@
=========================================================
=========================================================
EOF
}

View 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
}

View 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=""
}
}

View 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 &amp;
input_string=${input_string//\&/\&#38;}
# replace < with &lt;
input_string=${input_string//</\&#60;}
# replace > with &gt;
input_string=${input_string//>/\&#62;}
# replace ' with &apos;
input_string=${input_string//\'/\&#39;}
# replace " with &quot;
input_string=${input_string//\"/\&#34;}
echo "$input_string"
}

View 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=''
}

View 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
}