Skip to content

Commit

Permalink
Fixes to search, local-file-tweaks, test ajax-navigation, update Butt…
Browse files Browse the repository at this point in the history
…ons, add offline.zip packaging
  • Loading branch information
octospacc committed Aug 30, 2024
1 parent 745267c commit 89134ff
Show file tree
Hide file tree
Showing 25 changed files with 199 additions and 85 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/build/
/dist/
/resources/
/public/
/public.Content/
/public.gmi/*
/public.Plain/*
/Scripts/.bak/*
#/Scripts/package.json
#/Scripts/package-lock.json
Expand Down
5 changes: 2 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 4 additions & 2 deletions Scripts/Build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 14 additions & 0 deletions Scripts/Deploy.sh
Original file line number Diff line number Diff line change
@@ -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}"
14 changes: 14 additions & 0 deletions Scripts/Package.sh
Original file line number Diff line number Diff line change
@@ -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}"
1 change: 1 addition & 0 deletions Scripts/Produce.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
cd "${swd}/.."

export HUGO_ENV=production
sh "${swd}/Clean.sh"
sh "${swd}/Update.sh"
sh "${swd}/Redirects.sh"

Expand Down
6 changes: 5 additions & 1 deletion Scripts/Redirects.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion assets/ButtonBadges.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

#######################################

Expand Down
8 changes: 5 additions & 3 deletions content/it/miscellanea/Raccolta-Siti-Internet.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)&nbsp;
[![OpenBooks]({{< assetsRoot >}}/Media/Buttons/Sites/OpenBooks-88x31.gif)](#-s-a-6)&nbsp;
</marquee> -->
</marquee>
_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..

Expand Down Expand Up @@ -153,7 +153,9 @@ Un museo virtuale dedicato ad illustrare quei rari contenuti informatici e video

## Attenzione

<marquee><i>Però, oh voi persone che fate i sitarelli, mannaggia, non mettete testo importante nell'infernale tag &lt;marquee&gt;, che non si legge niente e fa il mal di testa!</i></marquee>
<marquee>
<i>Però, oh voi persone che fate i sitarelli, mannaggia, non mettete testo importante nell'infernale tag &lt;marquee&gt;, che non si legge niente e fa il mal di testa!</i>
</marquee>

## {{% i18n notes-refs %}}

Expand Down
11 changes: 8 additions & 3 deletions hugo.toml
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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]
Expand Down
19 changes: 19 additions & 0 deletions layouts/alias.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="{{ site.Language.LanguageCode }}"><!--
{{- $canonicalBase := site.Params.canonicalUrlOverride -}}
{{- $canonicalUrl := (or
(and
$canonicalBase
(printf "%s%s"
$canonicalBase
(relURL .Permalink)))
.Permalink) -}}
-->
<head>
<title>{{ .Permalink }}</title>
<link rel="canonical" href="{{ $canonicalUrl }}" />
<meta name="robots" content="noindex" />
<meta charset="utf-8" />
<meta http-equiv="refresh" content="0; url={{ .Permalink }}" />
</head>
</html>
3 changes: 2 additions & 1 deletion layouts/partials/ImgButton.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
{{- $style = "image-rendering: pixelated;" -}}
{{- end -}}
{{/* TODO: maybe set rendering via a class instead of inline CSS? */}}
{{- $img := (printf `<img src="%s" style="%s" alt="%s" title="%s" width="%spx" height="%spx" />`
{{- $img := (printf `<img src="%s" style="%s" alt="%s" title="%s" width="%spx" height="%spx" decoding="%s" />`
$src $style
$alt $alt
(index $sizes 0) (index $sizes 1)
(or .decoding "async")
) | safeHTML -}}
{{ if .href }}
{{ partial "anchor.html" (dict
Expand Down
5 changes: 4 additions & 1 deletion layouts/partials/footer-buttons.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
Expand Down
10 changes: 0 additions & 10 deletions redirectTemplate.html

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}
Expand Down
64 changes: 42 additions & 22 deletions static/ajax-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand All @@ -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('DOMContentLoaded', initPage);

window.addEventListener('popstate', (stateEvent) => {
if (location.href.split('#')[0] !== oldUrl.split('#')[0]) {
window.addEventListener('popstate', (function(stateEvent){
if (toPathUrl(location.href) !== toPathUrl(oldUrl)) {
loadContent(location.href, false);
}
oldUrl = location.href;
});
}));

})();
Loading

0 comments on commit 89134ff

Please sign in to comment.