mirror of
https://gitlab.com/octtspacc/sitoctt
synced 2025-06-05 22:09:20 +02:00
.
This commit is contained in:
@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
RepoUrl="https://gitlab.com/octtspacc/sitoctt.git"
|
||||
BranchThis="sitoctt-next"
|
||||
BranchTranslate="translate-cache"
|
||||
|
||||
#/bin/sh!
|
||||
|
||||
set -e
|
||||
owd="$(pwd)"
|
||||
swd="$(dirname "$(realpath "$0")")"
|
||||
|
@ -1,18 +1,18 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$(realpath "$0")")/.Globals.sh"
|
||||
. "$(dirname "$(realpath "$0")")/Lib/Globals.sh"
|
||||
cd "${swd}/.."
|
||||
|
||||
mkdir -p ./build
|
||||
cd ./build
|
||||
cp -r \
|
||||
../i18n \
|
||||
../archetypes ../content \
|
||||
../layouts ../themes \
|
||||
../config.toml ../hugo.toml \
|
||||
./
|
||||
sh "${swd}/Translate.Get.sh"
|
||||
$([ -n "$(which python3)" ] && echo python3 || echo python) "${swd}/Translate.Main.py"
|
||||
sh "${swd}/Translate.Apply.sh"
|
||||
hugo
|
||||
sh "${swd}/Translate.Push.sh"
|
||||
|
||||
sh "${swd}/Translate/Get.sh"
|
||||
sh "${swd}/Translate/Apply.sh"
|
||||
hugo $@
|
||||
|
||||
cd "${owd}"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$(realpath "$0")")/.Globals.sh"
|
||||
. "$(dirname "$(realpath "$0")")/Lib/Globals.sh"
|
||||
cd "${swd}/.."
|
||||
|
||||
rm -rf ./build ./public ./resources
|
||||
|
@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
GetArchive() {
|
||||
# $1: Branch name or commit hash
|
||||
wget \
|
||||
-O ./staticoso.tar.bz2 \
|
||||
https://gitlab.com/octtspacc/staticoso/-/archive/$1/staticoso-$1.tar.bz2
|
||||
tar xf ./staticoso.tar.bz2
|
||||
mv ./staticoso-$1 ./staticoso
|
||||
}
|
||||
|
||||
GetArchive Dev
|
18
Scripts/Lib/Globals.sh
Normal file
18
Scripts/Lib/Globals.sh
Normal file
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
RepoUrl="https://gitlab.com/octtspacc/sitoctt.git"
|
||||
BranchThis="sitoctt-next"
|
||||
BranchTranslate="translate-cache"
|
||||
HugoVersion="0.133.0"
|
||||
|
||||
#/bin/sh!
|
||||
|
||||
set -e
|
||||
owd="$(pwd)"
|
||||
swd="$(dirname "$(realpath "$0")")"
|
||||
if [ ! -e "${swd}/Lib/Globals.sh" ]
|
||||
then swd="${swd}/.."
|
||||
fi
|
||||
eval "$(sed -e 's| = |=|g' "${swd}/../config.toml")"
|
||||
|
||||
Python3="$([ -n "$(which python3)" ] && echo python3 || echo python)"
|
@ -1,11 +1,18 @@
|
||||
#!/usr/bin/env -S node --experimental-fetch
|
||||
require('./Lib/Syncers.js').importAll();
|
||||
const JSDOM = require('jsdom').JSDOM;
|
||||
// TODO: turndown HTML to Markdown
|
||||
|
||||
const BlogURL = 'https://listed.to/@u8'; // Full base URL of the Listed blog (any server)
|
||||
const SiteName = 'sitoctt';
|
||||
//const DefaultMode = 'Include' // 'Include' or 'Exclude' | Not implemented
|
||||
const PostsFileDate = true; // Append dates (YYYY-MM-DD) to posts file names
|
||||
const FrontmatterNew = {
|
||||
createdon: "Date",
|
||||
updatedon: "Lastmod",
|
||||
categories: Array,
|
||||
htmltitle: false,
|
||||
};
|
||||
let Replacements = { // Format: { ReplaceWithString: [ToFindString] }
|
||||
"<h2>[:HNotesRefsHTML:]</h2>": "<h2>🏷️ Note e Riferimenti</h2>",
|
||||
'<div class="footnotes">': ['<div class="footnotes"><hr>', '<div class="footnotes">\n<hr>'],
|
||||
@ -90,8 +97,16 @@ const MakeMetaStr = Post => {
|
||||
const Marks = { Meta: "%", Macros: "$" };
|
||||
Object.keys(Post[Type]).forEach((Key) => {
|
||||
//Str += `// ${Marks[Type]} ${Key} = ${Post[Type][Key]}\n`;
|
||||
// TODO: should this properly handle non-strings?
|
||||
Str += `${Key} = ${JSON.stringify(Post[Type][Key])}\n`;
|
||||
// TODO: should this handle bools properly?
|
||||
let Value = Post[Type][Key];
|
||||
const KeyNew = FrontmatterNew[Key.toLowerCase()];
|
||||
if (KeyNew === false) {
|
||||
return;
|
||||
} else if (KeyNew === Array) {
|
||||
KeyNew = null;
|
||||
Value = `[ "${Value.split(' ').join('", "')}" ]`;
|
||||
}
|
||||
Str += `${KeyNew || Key} = ${isNaN(Value.replaceAll('-', '')) ? JSON.stringify(Value) : Value}\n`;
|
||||
});
|
||||
});
|
||||
return `+++\n${Str}+++\n`; //Str;
|
||||
@ -200,9 +215,8 @@ const HandlePost = (PostSrc, Output) => {
|
||||
if (Output == 'file') {
|
||||
TryMkdirSync(PathDir);
|
||||
Fs.writeFileSync(FinalFilePath, `\
|
||||
${/* Post.IsToml ? Post.RawMeta : */ MakeMetaStr(Post)}
|
||||
${Post.IsToml ? Post.RawMeta : MakeMetaStr(Post)}
|
||||
<!-- Autogenerated by ListedDownsync.js. Do not edit (unless also set "% Downsync = False") - it would be overwritten. -->
|
||||
<h1>${Post.Meta.HTMLTitle ? Post.Meta.HTMLTitle : Post.Meta.Title}</h1>
|
||||
|
||||
${Post.Content}
|
||||
`);
|
||||
|
9
Scripts/Produce.sh
Executable file
9
Scripts/Produce.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$(realpath "$0")")/Lib/Globals.sh"
|
||||
cd "${swd}/.."
|
||||
|
||||
export HUGO_ENV=production
|
||||
sh "${swd}/Update.sh"
|
||||
sh "${swd}/Redirects.sh"
|
||||
|
||||
cd "${owd}"
|
@ -1,16 +0,0 @@
|
||||
#!/bin/sh
|
||||
[ -e ./.env ] && . ./.env
|
||||
Time=time
|
||||
|
||||
python3 -m cProfile \
|
||||
-s $Time \
|
||||
../staticoso/App/Source/Build.py \
|
||||
--SiteDomain="https://sitoctt.octt.eu.org" \
|
||||
--FolderRoots="{'*':'https://octtspacc.gitlab.io', 'Assets':'https://octtspacc.gitlab.io/sitoctt-assets'}" \
|
||||
--Minify="False" \
|
||||
--DiffBuild="True" \
|
||||
> /tmp/staticoso-$Time.txt
|
||||
|
||||
|
||||
#--DiffBuild="True" \
|
||||
#--GemtextOutput=True \
|
12
Scripts/Redirects.sh
Executable file
12
Scripts/Redirects.sh
Executable file
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$(realpath "$0")")/Lib/Globals.sh"
|
||||
cd "${swd}/.."
|
||||
|
||||
cd ./build/public
|
||||
find . -type f -name index.html -exec sh -c '
|
||||
nicepath="$(echo "{}" | rev | cut -d/ -f2- | rev)"
|
||||
niceurl="./$(echo "${nicepath}" | rev | cut -d/ -f1 | rev)/"
|
||||
sed -e "s|{URL}|${niceurl}|g" ../../redirectTemplate.html > "${nicepath}.html"
|
||||
' \;
|
||||
|
||||
cd "${owd}"
|
59
Scripts/Requirements.sh
Executable file
59
Scripts/Requirements.sh
Executable file
@ -0,0 +1,59 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$(realpath "$0")")/Lib/Globals.sh"
|
||||
cd "${swd}/.."
|
||||
|
||||
hugoexternal=true
|
||||
if [ -n "$(which apt)" ]
|
||||
then
|
||||
apt update
|
||||
apt install -y python3 nodejs findutils git tar gzip wget
|
||||
if [ "$(uname -o)" != Android ]
|
||||
then apt install -y npm
|
||||
else
|
||||
apt install -y hugo
|
||||
hugoexternal=false
|
||||
fi
|
||||
elif [ -n "$(which apk)" ]
|
||||
then
|
||||
apk update
|
||||
apk add hugo python3 py3-pip nodejs npm findutils git tar gzip wget
|
||||
hugoexternal=false
|
||||
fi
|
||||
|
||||
if [ "${hugoexternal}" = true ]
|
||||
then
|
||||
exehome="$([ -n "${XDG_DATA_HOME}" ] \
|
||||
&& echo "${XDG_DATA_HOME}" \
|
||||
|| echo "${HOME}/.local" \
|
||||
)/bin"
|
||||
exedepot="${exehome}/hugo.tmp"
|
||||
exearchive="${exedepot}/hugo_extended.tar.gz"
|
||||
|
||||
sysarch="$(uname -m)"
|
||||
if [ "${sysarch}" = x86_64 ]
|
||||
then sysarch=amd64
|
||||
elif [ "${sysarch}" = aarch64 ]
|
||||
then sysarch=arm64
|
||||
fi
|
||||
|
||||
mkdir -p "${exedepot}"
|
||||
wget -O "${exearchive}" "https://github.com/gohugoio/hugo/releases/download/v${HugoVersion}/hugo_extended_${HugoVersion}_linux-${sysarch}.tar.gz"
|
||||
tar xvf "${exearchive}" --directory "${exedepot}"
|
||||
mv "${exedepot}/hugo" "${exehome}/hugo"
|
||||
chmod +x "${exehome}/hugo"
|
||||
rm -rf "${exedepot}"
|
||||
|
||||
if [ -z "$(which hugo)" ]
|
||||
then
|
||||
BinaryPath='PATH="${PATH}:'"${BinaryHome}"'"'
|
||||
eval "${BinaryPath}"
|
||||
echo >> ~/.profile
|
||||
echo "${BinaryPath}" >> ~/.profile
|
||||
fi
|
||||
fi
|
||||
|
||||
cd ./Scripts
|
||||
"${Python3}" -m pip install -U -r ./requirements.txt --break-system-packages
|
||||
#npm install
|
||||
|
||||
cd "${owd}"
|
@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$(realpath "$0")")/.Globals.sh"
|
||||
|
||||
if [ -n "$(ls ./translate)" ]
|
||||
then cp -r ./translate/* ./content/
|
||||
fi
|
@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$(realpath "$0")")/.Globals.sh"
|
||||
|
||||
cd ./translate
|
||||
git add . && git commit -m . && git push || true
|
||||
cd ..
|
9
Scripts/Translate/Apply.sh
Executable file
9
Scripts/Translate/Apply.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$(realpath "$0")")/../Lib/Globals.sh"
|
||||
cd "${swd}/../build"
|
||||
|
||||
if [ -n "$(ls ./translate)" ]
|
||||
then cp -r ./translate/* ./content/
|
||||
fi
|
||||
|
||||
cd "${owd}"
|
@ -1,6 +1,9 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$(realpath "$0")")/.Globals.sh"
|
||||
. "$(dirname "$(realpath "$0")")/../Lib/Globals.sh"
|
||||
cd "${swd}/../build"
|
||||
|
||||
if [ ! -d ./translate ]
|
||||
then git clone --depth 1 --branch "${BranchTranslate}" "${RepoUrl}" ./translate
|
||||
fi
|
||||
|
||||
cd "${owd}"
|
@ -13,8 +13,6 @@ from translate_shell.translate import translate
|
||||
# TODO add warning about automatic translation at the beginning
|
||||
# TODO handle deleted files? (it should probably be done in another sh script, not here)
|
||||
|
||||
#
|
||||
|
||||
def printf(*objects):
|
||||
print(*objects, end='')
|
||||
|
||||
@ -76,7 +74,7 @@ def translate_document(document_path, documents):
|
||||
translated_preamble = ("\n\n{{< noticeAutomaticTranslation " + source_language + " >}}\n\n")
|
||||
if text_header in ["---", "+++"]:
|
||||
text_tokens = translated_text.split(text_header)
|
||||
translated_text = (text_header.join(text_tokens[:2]) + translated_preamble + text_header.join(text_tokens[2:]))
|
||||
translated_text = (text_header + text_tokens[:1] + translated_preamble + text_header.join([''] + text_tokens[2:]))
|
||||
else:
|
||||
translated_text = (translated_preamble + translated_text)
|
||||
destination_path = make_destination_path(document_path, destination_language)
|
||||
@ -92,7 +90,11 @@ def main():
|
||||
if len(documents[document_path]):
|
||||
translate_document(document_path, documents)
|
||||
|
||||
def read_from_scripts(relative_path:str):
|
||||
return open((dirname(realpath(__file__)) + '/../' + relative_path), 'r').read()
|
||||
|
||||
if __name__ == "__main__":
|
||||
globals_text = open(dirname(realpath(__file__)) + '/.Globals.sh').read()
|
||||
globals_text = read_from_scripts('Lib/Globals.sh')
|
||||
exec(globals_text.split('#' + globals_text.splitlines()[0].split('#!')[1] + '!')[0])
|
||||
exec(read_from_scripts('../config.toml'))
|
||||
main()
|
9
Scripts/Translate/Push.sh
Executable file
9
Scripts/Translate/Push.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$(realpath "$0")")/../Lib/Globals.sh"
|
||||
cd "${swd}/../build"
|
||||
|
||||
cd ./translate
|
||||
git add . && git commit -m . && git push || true
|
||||
cd ..
|
||||
|
||||
cd "${owd}"
|
14
Scripts/Update.sh
Executable file
14
Scripts/Update.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$(realpath "$0")")/Lib/Globals.sh"
|
||||
cd "${swd}/.."
|
||||
|
||||
mkdir -p ./build
|
||||
cd ./build
|
||||
sh "${swd}/Build.sh"
|
||||
|
||||
"${Python3}" "${swd}/Translate/Main.py"
|
||||
sh "${swd}/Translate/Apply.sh"
|
||||
hugo $@
|
||||
sh "${swd}/Translate/Push.sh"
|
||||
|
||||
cd "${owd}"
|
1
Scripts/requirements.txt
Normal file
1
Scripts/requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
translate-shell
|
Reference in New Issue
Block a user