small fixes

This commit is contained in:
teldra 2022-06-26 15:04:39 +02:00
parent 10cbba1935
commit a3cdc52a9f
11 changed files with 185 additions and 174 deletions

55
add_archive.sh Executable file
View File

@ -0,0 +1,55 @@
#!/bin/bash
err() {
echo "${1}"
zenity --error --no-wrap --text "${1}"
}
warn() {
echo "${1}"
zenity --warning --no-wrap --text "${1}"
}
if ! command -v unzip &> /dev/null
then
err "'unzip' could not be found"
exit 1
fi
if [ ${#@} -eq 0 ]; then
# no arguments
IFS=$'\n' files=($(zenity --file-selection --multiple --separator=$'\n' --title="Choose files"))
else
# arguments
echo ""
fi
for i in "${files[@]}"; do
if ! unzip -l "${i}"|grep -q "index.de.md"; then
err "maybe wrong archive, this is not compatible"
exit 1
fi
fname="$(basename ${i%.*})"
if ! [ -d content ]; then
err "folder 'content' not found"
exit 1
fi
set -x
mkdir -p "content/posts/${fname}/"
unzip -d "content/posts/${fname}/" "${i}"
done
output="Done."
output_temp=""
for i in "${files[@]}"; do
fname="$(basename ${i%.*})"
folder="content/posts/${fname}"
if ! [ -e "${folder}/banner*" ]; then
output_temp="${output_temp}banner missing\n "
fi
done
warn "${output_temp}"

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 KiB

View File

@ -0,0 +1,11 @@
---
title: "a"
date: 2022-06-26T13:55:00+02:00
---
![Describe the Picture for the Blind](redarrot.png)
[Describe the File for the Blind](t60.conf)
![Describe the Picture for the Blind](Buntes.Haus.Celle.Logo.5.png)
[Describe the File for the Blind](reconfigure_pipewire.sh)

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 KiB

43
new.sh
View File

@ -1,43 +0,0 @@
#!/bin/bash
echo "Titel des Artikels"
read -p ": " title
title=${title//[^[:print:]]/}
title=${title//#/}
newfoldername="${title//[^[:alnum:][:blank:]-]/}"
newfoldername=${newfoldername// /-}
newfoldername=${newfoldername/%-/}
newfoldername=${newfoldername/-/}
title="${title//\//\\\/}" # / -> \/
title="${title//\"/\\\"}" # " -> \"
date_long=$(date +%Y-%m-%dT%H:%M:00+0200)
date=$(date +%Y-%m-%d)
mkdir -p "content/posts/${date}-${newfoldername}"
touch "content/posts/${date}-${newfoldername}/index.de.md"
# echo "---" > "content/posts/${date}-${newfoldername}/index.de.md"
# echo "title: \"${title}\"" >> "content/posts/${date}-${newfoldername}/index.de.md"
# echo "date: ${date_long}" >> "content/posts/${date}-${newfoldername}/index.de.md"
# echo "---" >> "content/posts/${date}-${newfoldername}/index.de.md"
git add "content/posts/${date}-${newfoldername}/"
git commit -m "New Post: ${date}-${newfoldername}"
for i in vim nano gedit kate; do
if command -v $i > /dev/null; then
editor="$i"
fi
done
echo ""
echo ""
echo "Schreibe nun mit einem einfachen Editor deinen Artikel."
echo ""
echo "'${editor} content/posts/${date}-${newfoldername}/index.de.md'"
echo ""
echo "'https://buha.rotce.de/de/tools/generator/' hilft dir!"
echo ""
echo "Lege vielleicht noch Bilder in den Ordner 'content/posts/${date}-${newfoldername}'"
echo ""
echo "Wenn du fertig bist, nutze './push.sh' um das hochzuladen."

View File

@ -11,15 +11,10 @@ fieldset {
}
#result {
white-space: pre; display: flex; background: var(--background-alt);
padding: 1rem 0 1rem 1rem;
margin-top: 1rem;
-webkit-user-select: all;
user-select: all;
margin-bottom: 1rem;
word-wrap: break-word;
overflow-wrap: break-word;
max-width: 100vw;
margin: 1em;
display: flex;
flex-direction: column;
max-width: 80%;
}
form {

View File

@ -21,15 +21,16 @@ forms:
input_type: textarea
name: "Zusammenfassung"
expanded: true
buttons: "url,URL;pic,Bild;bold,Fett;strike,Durchgestrichen;paragraph,Absatz;newline,Neue Zeile"
buttons: "url,URL;bold,Fett;strike,Durchgestrichen;paragraph,Absatz;newline,Neue Zeile"
placeholder: "Der erste Absatz des Artkels. Eine Zusammenfassung des Inhalts. Gerne einladend bis reisserisch oder zusammenfassend. Denke an die Formatierungshilfe hinter dem Link oben."
help: ""
- title: content
input_type: textarea
name: "Inhalt"
buttons: "headline,Überschrift;url,URL;pic,Bild;bold,Fett;strike,Durchgestrichen;paragraph,Absatz;newline,Neue Zeile"
buttons: "headline,Überschrift;url,URL;picurl,Bild URL;bold,Fett;strike,Durchgestrichen;paragraph,Absatz;newline,Neue Zeile"
required: true
placeholder: "Der Inhalt des Artikels. Denke an die Formatierungshilfe hinter dem Link oben."
pictures: "Dateien Auswählen"
- title: news
input_type: categories
name: "Kategorie"

View File

@ -7,38 +7,19 @@
<div class="dfjcc">{{ .Text }}</div>
</a>
{{- else -}}
{{ $ignore := slice (.Page.Resources.GetMatch "banner*") }}
{{ $images := .Page.Resources.ByType "image" }}
{{ $images = complement $ignore $images }}
{{ if where (.Page.Resources.ByType "image") ".File.TranslationBaseName" "!=" "banner*" }}
{{ $img_tmp := "" }}
{{ $dest := string (printf "%s.*" .Destination) }}
{{ if .Page.Resources.GetMatch $dest }}
{{- $img_tmp = .Page.Resources.GetMatch $dest -}}
{{ else }}
{{ $nr := .Destination }}
{{- $img_tmp = index $images (sub (int $nr) 1) -}}
{{ end }}
{{ if $img_tmp }}
{{- $image := .Page.Resources.GetMatch (printf "%s" ($img_tmp | safeURL)) -}}
{{- $permalink := "" -}}
{{- if ne $image nil -}}
{{- $permalink = $image.Permalink -}}
{{- else -}}
{{- $image = imageConfig (printf "static/%s" (.Destination | safeURL)) -}}
{{- $permalink = (printf "/%s" (.Destination | safeURL)) -}}
{{- end -}}
<a href="{{- $image.Permalink -}}" class="article_image no_underline">
<img loading="lazy"
src="{{ $permalink }}"
alt="{{ .Text }}"
{{ with .Title}} title="{{ . }}"{{ end }}
width={{ $image.Width }}
height="{{ $image.Height }}" /><br>
{{ .Text }}
</a>
{{ end }}
{{ $dest := string (printf "%s*" .Destination) }}
{{ if .Page.Resources.GetMatch $dest }}
{{- $image := .Page.Resources.GetMatch $dest -}}
<a href="{{- $image.Permalink -}}" class="article_image no_underline">
<img loading="lazy"
src="{{ $image.Permalink }}"
alt="{{ .Text }}"
{{ with .Title}} title="{{ . }}"{{ end }}
width={{ $image.Width }}
height="{{ $image.Height }}" /><br>
{{ .Text }}
</a>
{{ else }}
{{ .Destination }} missing..
{{ end }}
{{- end -}}

View File

@ -1,34 +0,0 @@
{{ define "main" }}
{{- $all := where (where .Site.RegularPages "Permalink" "!=" .Permalink) "Type" "in" .Site.Params.searchSections }}
{{ $days := int (mul (mul (int .Site.Params.featured_expire) 7) -1) }}
{{ $featured := where (where (where $all ".Params.featured" "=" true) "Type" "in" .Site.Params.searchSections) ".Params.Lastmod" "gt" (now.AddDate 0 0 $days) }}
{{ $featured = $all | intersect $featured }}
{{ $posts := $all | complement $featured }}
{{- $paginator := .Paginate $posts -}}
{{ if eq $paginator.PageNumber 1 }}
{{ if ne .Content "" }}
<article>
{{ .Content }}
</article>
{{ end }}
{{ if gt (len $featured) 0 }}
<a href="/featured"><h2 style="margin-left: .5rem;">{{if "featured" | i18n }}{{ "featured" | i18n }}{{ else }}{{ "Featured" }}{{ end }}</h2></a>
{{ partial "contentlayouts/list.html" (dict "context" . "pages" $featured "amount" "3" ) }}
{{ end }}
{{ end }}
{{ if gt (len $posts) 1 }}
<a href="/news"><h2 style="margin-left: .5rem;">{{ if "news" | i18n }}{{ "news" | i18n }}{{ else }}{{ "News" }}{{ end }}</h2></a>
{{ partial "contentlayouts/list.html" (dict "context" . "paginator" $paginator "amount" "5") }}
<div id="pagination_outer" style="display: flex; justify-content: center;">
{{ partial "structure/paginator" (dict "paginator" $paginator) }}
</div>
{{ end }}
{{ end }}
{{ define "sidebar" }}
{{- partial "contentlayouts/menu.html" . }}
{{ end }}

View File

@ -39,8 +39,12 @@
{{ end }}
</div>
<textarea class="w100 textarea" name="{{ .title }}" id="{{ .title }}" rows="10" {{ if .placeholder }}placeholder="{{ .placeholder }}"{{ end }}></textarea>
{{ if eq .title "content" }}
<div id="added-files" style="display: flex; flex-direction: column;"></div>
{{ if .pictures }}
{{ $nn := printf "%s;%s" .title "addfiles"}}
<div style="margin-top: .5em; margin-bottom: .5em;">
<button class="button" onclick="addfiles({{- $nn -}})" type="button" value="addfiles">{{ .pictures }}</button>
<div id="added-files" style="display: flex; flex-direction: column; margin-top: 1em;"></div>
</div>
{{ end }}
</div>
{{ else if eq .input_type "radio" }}

View File

@ -1,4 +1,10 @@
var zip = new JSZip();
var archive_name = "";
var fout = document.getElementById('added-files');
function isFileImage(file) {
return file && file['type'].split('/')[0] === 'image';
}
function check_checkboxes(name) {
const checkboxes = document.querySelectorAll(`input[name="${name}"]:checked`);
@ -58,6 +64,56 @@ function rm_file(fname) {
zip.remove(fname);
}
function insert_file(fname) {
var arr = fname.split(";");
let t = arr[2];
let x = arr[1];
let target = arr[0];
var id = document.getElementById(target);
function typeInTextarea(newText, el = id) {
const [start, end] = [el.selectionStart, el.selectionEnd];
el.setRangeText(newText, start, end);
}
if (t == "image") {
var desc = prompt("Desc for ", "Describe the Picture for the Blind");
var out = "![" + desc + "](" + x + ") \n\n";
} else if (t == "other") {
var desc = prompt("Desc for ", "Describe the File for the Blind");
var out = "[" + desc + "](" + x + ") \n\n";
}
if (out != null) {
typeInTextarea(out);
var end = id.value.length;
id.setSelectionRange(end, end);
id.focus({preventScroll: true});
}
}
function addfiles(str) {
var arr = str.split(";");
let x = arr[1];
let target = arr[0];
var input = document.createElement('input');
var type = "image";
input.type = 'file';
input.multiple = 'multiple';
input.id = 'inpic';
input.click();
input.onchange = e => {
var files = e.target.files;
for (var i = 0; i < files.length; i++) {
var name = files[i].name.trim();
if (isFileImage(files[i])) {
type = "image";
} else {
type = "other"
}
zip.file(name, files[i]);
fout.innerHTML += "<div id=\"" + name + "\" style=\"display: flex; flex-direction: row;\">" + "<button type=\"button\" onclick=\"insert_file('" + target + ";" + name + ";" + type + "')\" value=\"" + name + "\" id=\"" + name + "\" class=\"button\">Einfügen</button>" + "<button type=\"button\" onclick=\"rm_file('" + name + "')\" value=\"" + name + "\" id=\"" + name + "\" class=\"button\">Entfernen</button>" + name + "</div>";
}
}
}
function button(str) {
var arr = str.split(";");
let x = arr[1];
@ -74,39 +130,17 @@ function button(str) {
if (desc != null) {var out = "[" + desc + "](" + url + ") ";}
}
}
if (x == "picurl") {
let url = prompt("Please enter Link to an image", "https://de.wikipedia.org/static/images/project-logos/dewiki.png");
if (url != null) {
let desc = prompt("Description", "Wikipedia logo");
if (desc != null) {var out = "![" + desc + "](" + url + ") ";}
}
}
if (x == "headline") {
let headline = prompt("Headline", "Act One");
if (headline != null) {var out = "## " + headline + "\n\n";}
}
if (x == "pic") {
var input = document.createElement('input');
var fout = document.getElementById('added-files');
input.type = 'file';
input.multiple = 'multiple';
input.id = 'inpic';
input.click();
input.onchange = e => {
var files = e.target.files;
for (var i = 0; i < files.length; i++) {
var name = files[i].name.trim();
var p = "Desc for " + name;
var desc = prompt(p, "Wikipedia logo");
if (desc) {
zip.file(name, files[i]);
var pic = name;
var out = "![" + desc + "](" + pic + ") \n\n";
typeInTextarea(out);
var end = id.value.length;
id.setSelectionRange(end, end);
id.focus({preventScroll: true});
fout.innerHTML += "<div id=\"" + name + "\" style=\"display: flex; flex-direction: row;\">" + pic + "<button type=\"button\" onclick=\"rm_file('" + name + "')\" value=\"" + name + "\" id=\"" + name + "\">remove</button></div>";
}
}
}
}
if (x == "bold") {
let bold = prompt("Bold", "");
if (bold != null) {var out = "\*\*" + bold + "\*\* ";}
@ -145,13 +179,11 @@ function testor(input) {
}
function showInput(e) {
document.getElementById("result").innerHTML = '';
e.preventDefault();
document.getElementById("result").style.display = "flex";
var display = document.getElementById("result");
display.innerHTML = '';
e.preventDefault();
display.style.display = "flex";
var d = new Date();
var datestring = d.getFullYear() + "-" + ("0"+(d.getMonth()+1)).slice(-2) + "-" + ("0" + d.getDate()).slice(-2) + "T" + ("0" + d.getHours()).slice(-2) + ":" + ("0" + d.getMinutes()).slice(-2) + ":00+02:00";
var datestring_shorter = d.getFullYear() + "-" + ("0"+(d.getMonth()+1)).slice(-2) + "-" + ("0" + d.getDate()).slice(-2);
@ -271,14 +303,13 @@ function showInput(e) {
if (title) {
var output = "---\n";
var output = output + "title: \"" + title.trim() + "\"\n";
if (lastmod) {
var output = output + "lastmod: " + lastmod.trim() + "\n";
} else {
var output = output + "date: " + datestring.trim() + "\n";
}
if (featured != '') {
var output = output + "featured: true\n";
}
@ -294,7 +325,7 @@ function showInput(e) {
if (when) {
var output = output + "when: \"" + when + "\"\n";
}
if (nnews) {
var output = output + "news: \[" + nnews + "]\n";
}
@ -302,11 +333,11 @@ function showInput(e) {
if (nevents) {
var output = output + "events: \[" + nevents + "]\n";
}
if (nfoundations) {
var output = output + "foundations: \[" + nfoundations + "]\n";
}
if (alltags) {
var output = output + "tags: \[" + alltags + "]\n";
}
@ -325,14 +356,11 @@ function showInput(e) {
}
var output = output + "---\n";
if (summary) {
var output = output + summary.trim() + "\n" + "&lt;!--more--&gt;" + "\n";
var output = output + summary.trim() + "\n" + "<!--more-->" + "\n";
}
if (content) {
var output = output + content.trim();
}
if (output) {
display.innerHTML += output.trim();
}
// Add an top-level, arbitrary text file with contents
zip.file("index.de.md", output);
@ -342,15 +370,28 @@ function showInput(e) {
var t = t.replaceAll(/\s+/g, '-');
var t = t.replace(/[^\w.-]+/g, "");
archive_name = datestring_shorter + "-" + t + ".zip";
var archive_name = datestring_shorter + "-" + t + ".zip";
var check_banner = false;
// Generate the zip file asynchronously
zip.generateAsync({type:"blob"})
.then(function(cont) {
// Force down of the Zip file
saveAs(cont, archive_name);
});
for(let [filename, file] of Object.entries(zip.files)) {
console.log(filename);
if (filename.startsWith("banner")) { check_banner = true; }
}
if (output) {
display.innerHTML += "<button style=\"background: #69c839;\" class=\"button\" onclick=\"dl_archive()\" type=\"button\" \">Save Archive</button><br>";
if (check_banner == false) {
display.innerHTML += "<br>\n<div>A Nice Banner (1920x850px) is missing</div>"
}
}
}
}
function dl_archive() {
// Generate the zip file asynchronously
zip.generateAsync({type:"blob"})
.then(function(cont) {
// Force down of the Zip file
saveAs(cont, archive_name);
});
}