diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index c2d1c29..a90c10a 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -1,26 +1,19 @@
name: Build and Deploy
-
on:
push:
branches: [ "sitoctt-next" ]
pull_request:
branches: [ "sitoctt-next" ]
-
- workflow_dispatch:
-
jobs:
page_build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
-
- name: Build
run: |
export sitocttEnv=GitHub
- sh ./Scripts/Requirements.sh
- sh ./Scripts/Produce.sh
-
+ sh ./Scripts/Deploy.sh
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
with:
diff --git a/.gitignore b/.gitignore
index d318c46..a6b4f37 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,9 +1,8 @@
/build/
+/dist/
/resources/
/public/
-/public.Content/
/public.gmi/*
-/public.Plain/*
/Scripts/.bak/*
#/Scripts/package.json
#/Scripts/package-lock.json
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a2e17b8..2a731b6 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,10 +1,9 @@
image: alpine:latest
-
pages:
stage: deploy
script: |
- sh ./Scripts/Requirements.sh
- sh ./Scripts/Produce.sh
+ export sitocttEnv=GitLab
+ sh ./Scripts/Deploy.sh
artifacts:
paths:
- build/public
diff --git a/Scripts/Build.sh b/Scripts/Build.sh
index c0d05a8..75c6b1a 100755
--- a/Scripts/Build.sh
+++ b/Scripts/Build.sh
@@ -11,8 +11,10 @@ cp -r \
../hugo.toml ../static \
./
-if [ "${sitocttEnv}" = GitHub ]
-then cp ./layouts/partials/assetsRoot.GitHub.html ./layouts/partials/assetsRoot.html
+if [ -n "${sitocttEnv}" ]
+then
+ sed -i -e "s|#${sitocttEnv}:||g" ./hugo.toml
+ mv "./layouts/partials/assetsRoot.${sitocttEnv}.html" ./layouts/partials/assetsRoot.html || true
fi
sh "${swd}/Translate/Get.sh"
diff --git a/Scripts/Deploy.sh b/Scripts/Deploy.sh
new file mode 100755
index 0000000..d6e106a
--- /dev/null
+++ b/Scripts/Deploy.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+. "$(dirname "$(realpath "$0")")/Lib/Globals.sh"
+cd "${swd}/.."
+
+sh "${swd}/Requirements.sh"
+rm -rf ./dist
+
+sh "${swd}/Produce.sh"
+mv ./build/public ./dist
+
+sh "${swd}/Package.sh"
+mv ./build/public/offline.zip ./dist/
+
+cd "${owd}"
diff --git a/Scripts/Package.sh b/Scripts/Package.sh
new file mode 100755
index 0000000..6e11d74
--- /dev/null
+++ b/Scripts/Package.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+. "$(dirname "$(realpath "$0")")/Lib/Globals.sh"
+cd "${swd}/.."
+
+export sitocttEnv=Offline
+export HUGO_ENV=production
+sh "${swd}/Clean.sh"
+sh "${swd}/Update.sh"
+
+cd ./build/public
+#zip -9 -r ./offline.zip *
+7z a -tzip -mcp=437 -mx9 ./offline.zip *
+
+cd "${owd}"
diff --git a/Scripts/Produce.sh b/Scripts/Produce.sh
index 9c62ec6..3011e2e 100755
--- a/Scripts/Produce.sh
+++ b/Scripts/Produce.sh
@@ -3,6 +3,7 @@
cd "${swd}/.."
export HUGO_ENV=production
+sh "${swd}/Clean.sh"
sh "${swd}/Update.sh"
sh "${swd}/Redirects.sh"
diff --git a/Scripts/Redirects.sh b/Scripts/Redirects.sh
index 565f80d..5983f11 100755
--- a/Scripts/Redirects.sh
+++ b/Scripts/Redirects.sh
@@ -37,7 +37,11 @@ nicename="$(echo "${nicepath}" | rev | cut -d/ -f1 | rev)"
# fi
#done
for path in "${nicepath}" #${extrapaths}
-do sed -e "s|{URL}|./${nicename}/|g" ../../redirectTemplate.html > "${path}.html"
+do cat ../layouts/alias.html \
+ | sed -e "s|{{ .Permalink }}|./${nicename}/|g" \
+ | sed -e "s|{{ $canonicalUrl }}|./${nicename}/|g" \
+ | sed -e "s|{{ site.Language.LanguageCode }}||g" \
+> "${path}.html"
done
#if [ "$(echo "{}" | cut -d/ -f2)" = it ]
#then
diff --git a/Scripts/Requirements.sh b/Scripts/Requirements.sh
index f7f0cc5..f0c3061 100755
--- a/Scripts/Requirements.sh
+++ b/Scripts/Requirements.sh
@@ -11,7 +11,7 @@ hugoexternal=true
if [ -n "$(which apt)" ]
then
asroot apt update
- asroot apt install -y python3 nodejs findutils git tar gzip wget
+ asroot apt install -y python3 nodejs findutils git wget tar gzip p7zip-full #zip
if [ "$(uname -o)" != Android ]
then asroot apt install -y npm
else
@@ -21,7 +21,7 @@ then
elif [ -n "$(which apk)" ]
then
asroot apk update
- asroot apk add hugo python3 py3-pip nodejs npm findutils git tar gzip wget
+ asroot apk add hugo python3 py3-pip nodejs npm findutils git wget tar gzip 7zip #zip
hugoexternal=false
fi
diff --git a/assets/ButtonBadges.toml b/assets/ButtonBadges.toml
index f9865dc..08fb514 100644
--- a/assets/ButtonBadges.toml
+++ b/assets/ButtonBadges.toml
@@ -59,7 +59,7 @@ href = "http://http.sitoctt.octt.eu.org"
[[10-site]]
alt = "Download Offline Version"
file = "OFF-LINE-VERSION.png"
-href = "https://github.com/octospacc/sitoctt/archive/refs/heads/gh-pages.zip"
+href = "https://sitoctt.octt.eu.org/offline.zip"
#######################################
diff --git a/content/it/miscellanea/Raccolta-Siti-Internet.md b/content/it/miscellanea/Raccolta-Siti-Internet.md
index a7262ad..0898174 100644
--- a/content/it/miscellanea/Raccolta-Siti-Internet.md
+++ b/content/it/miscellanea/Raccolta-Siti-Internet.md
@@ -24,9 +24,9 @@ Le bandiere di nazione (emoji, forse non visibili su browser antichi) accanto ai
[![Yesterweb]({{< assetsRoot >}}/Media/Buttons/Sites/Yesterweb-88x31.png)](#-s-a-5)
[![OpenBooks]({{< assetsRoot >}}/Media/Buttons/Sites/OpenBooks-88x31.gif)](#-s-a-6)
- -->
+
-_Questi sopra sono i siti della lista che hanno un bottone 88x31. Vuoi anche tu il privilegio di stare anche in cima? Allora muoviti a disegnare st'immaginetta, su!_
+_Questi sopra sono i siti della lista che hanno un bottone 88x31. Vuoi anche tu il privilegio di stare anche in cima? Allora muoviti a disegnare st'immaginetta, su!_ -->
## Il mio..
@@ -153,7 +153,9 @@ Un museo virtuale dedicato ad illustrare quei rari contenuti informatici e video
## Attenzione
-
+
## {{% i18n notes-refs %}}
diff --git a/hugo.toml b/hugo.toml
index 4b86928..75a2f1d 100644
--- a/hugo.toml
+++ b/hugo.toml
@@ -1,11 +1,14 @@
title = "✨sitoctt✨"
-baseURL = "https://sitoctt.octt.eu.org/"
-#relativeURLs = true
-theme = ["hugo-notice", "ananke"]
+#GitLab:baseURL = "https://sitoctt.octt.eu.org/"
+#GitHub:baseURL = "http://http.sitoctt.octt.eu.org/"
+#Offline:relativeURLs = true
+#Offline:disableAliases = true
+canonifyURLs = true
disablePathToLower = true
sectionPagesMenu = "main"
defaultContentLanguage = "it"
defaultContentLanguageInSubdir = true
+theme = ["hugo-notice", "ananke"]
[permalinks]
[permalinks.page]
@@ -50,6 +53,8 @@ defaultContentLanguageInSubdir = true
other_posts_number = 5
toc = true
show_reading_time = true
+ canonicalUrlOverride = "https://sitoctt.octt.eu.org"
+ #canonicalUrlOverride = "http://http.sitoctt.octt.eu.org"
#custom_css = [ "Global.scss", "sitoctt.scss" ]
[outputFormats]
diff --git a/layouts/alias.html b/layouts/alias.html
new file mode 100644
index 0000000..808f53b
--- /dev/null
+++ b/layouts/alias.html
@@ -0,0 +1,19 @@
+
+
+
+ {{ .Permalink }}
+
+
+
+
+
+
diff --git a/layouts/partials/ImgButton.html b/layouts/partials/ImgButton.html
index c6434d0..dc6d5da 100644
--- a/layouts/partials/ImgButton.html
+++ b/layouts/partials/ImgButton.html
@@ -12,10 +12,11 @@
{{- $style = "image-rendering: pixelated;" -}}
{{- end -}}
{{/* TODO: maybe set rendering via a class instead of inline CSS? */}}
-{{- $img := (printf ``
+{{- $img := (printf ``
$src $style
$alt $alt
(index $sizes 0) (index $sizes 1)
+ (or .decoding "async")
) | safeHTML -}}
{{ if .href }}
{{ partial "anchor.html" (dict
diff --git a/layouts/partials/footer-buttons.html b/layouts/partials/footer-buttons.html
index 4b149a6..cdc5f99 100644
--- a/layouts/partials/footer-buttons.html
+++ b/layouts/partials/footer-buttons.html
@@ -10,12 +10,15 @@
{{ $src = (partial "functions/ParseFileUrl.html" $src) }}
{{- end -}}
{{- $newprops := (dict
+ "decoding" "async"
"src" $src
"srcRelative" .file
"hrefLinkback" .linkback
) -}}
{{- if .spam -}}
- {{- $newprops = (merge $newprops (dict "rel" "nofollow noopener" "target" "_blank")) -}}
+ {{- $newprops = (merge $newprops (dict
+ "rel" "nofollow noopener"
+ "target" "_blank")) -}}
{{- end -}}
{{ partial "ImgButton.html" (merge . $newprops) }}
{{- else -}}
diff --git a/redirectTemplate.html b/redirectTemplate.html
deleted file mode 100644
index 416c86e..0000000
--- a/redirectTemplate.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
- {URL}
-
-
-
-
-
-
diff --git a/Assets.old/Assets/MinesweeperEmbed.js b/static/MinesweeperEmbed.js
similarity index 95%
rename from Assets.old/Assets/MinesweeperEmbed.js
rename to static/MinesweeperEmbed.js
index 25b7a7f..b024304 100644
--- a/Assets.old/Assets/MinesweeperEmbed.js
+++ b/static/MinesweeperEmbed.js
@@ -1,4 +1,5 @@
// Multipurpose embeddable Minesweeper game on top of vuesweeper
+// TODO game iframe must be re-set to be transparent and color scheme set to same as the website (light)
// How many pixels one square takes up
var MineSquareSize = 32;
@@ -17,12 +18,15 @@ var ResizeAlerted = false;
// Add styles to current page
var New = document.createElement('style');
New.innerHTML = `
-/* Don't know what's up with the percentages */
+/* TODO must set position:relative to parent div */
.Minesweeper {
- width: calc(100% - 5% - 1.25%);
+ /* Don't know what's up with the percentages */
+ /* width: calc(100% - 5% - 1.25%); */
+ width: 100%;
z-index: 4;
}
.Minesweeper > iframe {
+ width: 100%;
max-height: none !important;
border: none;
}
diff --git a/static/ajax-navigation.js b/static/ajax-navigation.js
index e737e26..bf02aa8 100644
--- a/static/ajax-navigation.js
+++ b/static/ajax-navigation.js
@@ -2,31 +2,40 @@
// TODO investigate/fix strange screen flash when navigating back from an hash URL
// TODO error handling, caching, loading indication, totally handle hash change
-var oldUrl = null;
-var firstLoad = true;
window.SiteInitOnLoad = [];
+var oldUrl = null;
+
+// TODO before deploying this: handle page-specific scripts (comments, etc...)
+//if (location.protocol === 'file:') {
+ window.PatchAjaxNavigationAnchor = Void;
+ return; // HTTP requests don't work on local files with default browser configuration
+//}
+
+function toPathUrl (url) {
+ return url.split('#')[0];
+}
function initPage () {
- oldUrl = location.href;
- document.body.scrollIntoView();
- Array.from(document.querySelectorAll('a')).forEach(function(anchorEl){
- var isInternalLink = anchorEl.href.startsWith(location.protocol + '//' + location.host);
- var isPagewideLink = (anchorEl.href.split('#')[0] === location.href.split('#')[0]);
- if (isInternalLink && !isPagewideLink) {
- anchorEl.onclick = (function(clickEvent){
- clickEvent.preventDefault();
- loadContent(anchorEl.href, true);
- });
- }
- });
- if (!firstLoad) {
+ if (oldUrl !== null) {
+ document.body.scrollIntoView();
SiteInitOnLoad.forEach(function(routine){ routine(); });
}
- firstLoad = false;
+ oldUrl = location.href;
+ var langToken = ('/' + document.documentElement.lang + '/');
+ var baseHref = (location.href.split(langToken)[0] + langToken);
+ Array.from(document.querySelectorAll('a[href]')).filter(function(anchorEl){
+ //var tokens = href.split('/' + document.documentElement.lang + '/');
+ //if (location.href.slice(0, href[0]))
+ //return (anchorEl.getAttribute('href').replace(location.host, '').replace(/^(\.\.\/)+/, '').replace(/^(\/)+/, '').split('/')[1] === document.documentElement.lang);
+ return (anchorEl.href.slice(0, baseHref.length) === baseHref);
+ }).forEach(PatchAjaxNavigationAnchor);
}
function loadContent (url, push) {
- var fallbackTimeout = setTimeout((function(){ location.href = url; }), 3e3);
+ function useFallback () {
+ location.href = url;
+ }
+ var fallbackTimeout = setTimeout(useFallback, 3000);
fetch(url)
.then(function(request){ return request.text(); })
.then(function(html){
@@ -40,17 +49,28 @@ function loadContent (url, push) {
clearTimeout(fallbackTimeout);
}).catch(function(err){
console.error(err);
- location.href = url;
+ useFallback();
});
}
-window.addEventListener('load', initPage);
+window.PatchAjaxNavigationAnchor = (function PatchAjaxNavigationAnchor (anchorEl) {
+ var isSitewideLink = anchorEl.href.startsWith(location.protocol + '//' + location.host);
+ var isPagewideLink = (toPathUrl(anchorEl.href) === toPathUrl(location.href));
+ if (isSitewideLink && !isPagewideLink) {
+ anchorEl.addEventListener('click', (function(clickEvent){
+ clickEvent.preventDefault();
+ loadContent(anchorEl.href, true);
+ }));
+ }
+});
-window.addEventListener('popstate', (stateEvent) => {
- if (location.href.split('#')[0] !== oldUrl.split('#')[0]) {
+window.addEventListener('DOMContentLoaded', initPage);
+
+window.addEventListener('popstate', (function(stateEvent){
+ if (toPathUrl(location.href) !== toPathUrl(oldUrl)) {
loadContent(location.href, false);
}
oldUrl = location.href;
-});
+}));
})();
diff --git a/static/local-file-tweaks.js b/static/local-file-tweaks.js
index 0cf4517..684e9cd 100644
--- a/static/local-file-tweaks.js
+++ b/static/local-file-tweaks.js
@@ -1,15 +1,28 @@
(function(){
if (location.protocol !== 'file:') {
+ window.PatchLocalFileAnchor = Void;
return;
}
-window.addEventListener('load', (function(){
- Array.from(document.querySelectorAll('a[href]')).forEach(function(linkEl){
- if (linkEl.href.startsWith('file://') && linkEl.href.endsWith('/')) {
- linkEl.href += 'index.html';
+window.PatchLocalFileAnchor = (function PatchLocalFileAnchor (anchorEl) {
+ var href = anchorEl.href;
+ if (href.startsWith('file://')) {
+ var tokens = href.split('#');
+ href = tokens[0];
+ if (href.endsWith('/')) {
+ href += 'index.html';
}
- });
+ tokens = tokens.slice(1);
+ if (tokens.length) {
+ href += ('#' + tokens.join('#'));
+ }
+ anchorEl.href = href;
+ }
+});
+
+window.addEventListener('DOMContentLoaded', (function(){
+ Array.from(document.querySelectorAll('a[href]')).forEach(PatchLocalFileAnchor);
}));
})();
diff --git a/static/site-search.js b/static/site-search.js
index f244404..6bcc053 100644
--- a/static/site-search.js
+++ b/static/site-search.js
@@ -1,4 +1,9 @@
(function(){
+// TODO make links work on file:/// (must be relative)
+// TODO fix ajax navigation to different-language page, doesn't currently load the index for the selected language
+// TODO better perf
+// TODO thumbnails?
+// TODO highlight found word in text summary? we must handle generating summary client-side at different points of text for it to work
function init () {
@@ -14,14 +19,23 @@ var searchVisible = false;
var indexed = false;
var hasResults = false;
-hideButton.addEventListener("click", hideSearch);
-wrapper.addEventListener("click", hideSearch);
-modal.addEventListener("click", function (event) {
+hideButton.addEventListener('click', hideSearch);
+wrapper.addEventListener('click', hideSearch);
+modal.addEventListener('click', (function(){
event.stopPropagation();
event.stopImmediatePropagation();
return false;
-});
-document.addEventListener("keydown", function (event) {
+}));
+document.removeEventListener('keydown', window.SiteSearchOnKeyHandler);
+window.SiteSearchOnKeyHandler = documentOnKeyDown;
+document.addEventListener('keydown', SiteSearchOnKeyHandler);
+
+// Update search on each keypress
+input.onkeyup = function (event) {
+ executeQuery(this.value);
+};
+
+function documentOnKeyDown (event) {
if (event.key == "/") {
if (!searchVisible) {
event.preventDefault();
@@ -72,13 +86,7 @@ document.addEventListener("keydown", function (event) {
}
}
}
-
-});
-
-// Update search on each keypress
-input.onkeyup = function (event) {
- executeQuery(this.value);
-};
+}
function displaySearch() {
if (!indexed) {
@@ -129,7 +137,17 @@ function executeQuery(term) {
if (results.length > 0) {
results.forEach(function (value, key) {
var title = value.item.externalUrl? value.item.title + ''+value.item.externalUrl+'' : value.item.title;
- var linkconfig = value.item.externalUrl? 'target="_blank" rel="noopener" href="'+value.item.externalUrl+'"' : 'href="'+value.item.permalink+'"';
+ var linkconfig;
+ if (value.item.externalUrl) {
+ linkconfig = 'target="_blank" rel="noopener" href="'+value.item.externalUrl+'"';
+ } else {
+ var dataUrl = wrapper.dataset.url;
+ if (dataUrl.startsWith('../')) {
+ linkconfig = 'href="'+('..' + '/..'.repeat(dataUrl.split('/').length - 3) + value.item.permalink)+'"';
+ } else {
+ linkconfig = 'href="'+value.item.permalink+'"';
+ }
+ }
resultsHTML =
resultsHTML +
`
@@ -154,6 +172,11 @@ function executeQuery(term) {
}
output.innerHTML = resultsHTML;
+ Array.from(output.querySelectorAll('a')).forEach(function(anchorEl){
+ anchorEl.addEventListener('click', hideSearch);
+ PatchLocalFileAnchor(anchorEl);
+ PatchAjaxNavigationAnchor(anchorEl);
+ });
if (results.length > 0) {
first = output.firstChild.firstElementChild;
last = output.lastChild.firstElementChild;
@@ -166,6 +189,7 @@ document.querySelector('.SiteSearchForm').innerHTML = document.querySelector('.S
var inputEl = document.querySelector('.SiteSearchForm > input');
//inputEl.classList.add('bg-transparent', 'white');
+inputEl.style.width = '10rem';
inputEl.placeholder = (inputText + '... 🔎️ [CTRL+/]');
inputEl.onclick = inputEl.oninput = inputEl.onchange = inputEl.onpaste = displaySearch;
inputEl.onkeydown = (function(event){
diff --git a/themes/ananke/layouts/_default/baseof.html b/themes/ananke/layouts/_default/baseof.html
index e2ac605..ca5fff2 100644
--- a/themes/ananke/layouts/_default/baseof.html
+++ b/themes/ananke/layouts/_default/baseof.html
@@ -40,7 +40,9 @@
{{ end }}
{{ end }}
- {{ if .Params.canonicalUrl }}
+ {{ if .Site.Params.canonicalUrlOverride }}
+
+ {{ else if .Params.canonicalUrl }}
{{ else }}
diff --git a/themes/ananke/layouts/partials/page-header.html b/themes/ananke/layouts/partials/page-header.html
index 62bbea5..270b2db 100644
--- a/themes/ananke/layouts/partials/page-header.html
+++ b/themes/ananke/layouts/partials/page-header.html
@@ -17,7 +17,7 @@
{{ else }}
-