All the code

This commit is contained in:
c0dev0id
2022-12-27 22:04:45 +01:00
parent a4251bf6ae
commit 3ed25b5b3f
47 changed files with 4200 additions and 0 deletions

36
scripts/mkphotoindex.sh Normal file
View File

@@ -0,0 +1,36 @@
#!/bin/sh -e
echo "<h1>My Photos</h1>"
[ -f index.txt ] && cat index.txt
makelink() {
_text="$(echo "$1" | sed 's/-/ /g;s/_/ - /g;s/\(....\) \(..\) \(..\)/\1-\2-\3/')"
echo "<li><a href=\"${_dir}\">${_text}</a></li>"
}
echo "<h3>Events:</h3>"
echo "<ul>"
find * -maxdepth 0 -mindepth 0 -type d \
| grep "^20" \
| grep -v "unlisted" \
| sort -r \
| while read _dir
do
makelink "$_dir"
done
echo "</ul>"
echo "<h3>Collections:</h3>"
echo "<ul>"
find * -maxdepth 0 -mindepth 0 -type d \
| grep -v "^20" \
| grep -v "unlisted" \
| sort -r \
| while read _dir
do
makelink "$_dir"
done
echo "</ul>"

90
scripts/mkphotos.sh Normal file
View File

@@ -0,0 +1,90 @@
#!/bin/sh -e
## settings
DIR="$(basename "$PWD")"
TITLE="$(basename "$PWD" |sed 's/unlisted-//g' | cut -d"_" -f2- | tr '-' ' ')"
mkdir -p thm mid
echo "<h1>$TITLE</h1>"
[ -f index.txt ] && cat index.txt
echo "<p>"
echo "<table class=\"photo-table\">"
echo "<tr>"
_count=0
find * -maxdepth 0 -mindepth 0 -type f \( -iname "*.jpg" \
-o -iname "*.jpeg" \
-o -iname "*.png" \
-o -iname "*.gif" \
\) \
| sort -r | while read _file
do
_file_thm="thm/${_file%%.*}.jpg"
_file_mid="mid/${_file%%.*}.jpg"
_file_html="${_file%%.*}.html"
_file_descr="${_file%%.*}.txt"
# increase file counter
_count=$(( _count + 1))
if [ ! -f "${_file_thm}" ]
then
convert -quality 73 \
-sharpen 2x2 \
-auto-orient \
-define jpeg:size=440x440 \
"$_file" \
-thumbnail 220x220^ \
-gravity center \
-extent 220x220 \
"${_file_thm}" \
>/dev/null 2>&1 &
fi
if [ ! -f "${_file_mid}" ]
then
convert -quality 83 \
-sharpen 2x2 \
-auto-orient \
-define jpeg:size=1440x2400 \
"$_file" \
-thumbnail 720x1600 \
"${_file_mid}" \
>/dev/null 2>&1 &
fi
if [ ! -f "${_file_html}" ]
then
echo "<h1>$TITLE</h1>" > "${_file_html}"
echo "<p>File: ${_file} (<a href=\"/photos/$DIR/${_file}\" target=_blank>Open Original</a>)</p>" >> "${_file_html}"
echo "<p><img class=\"photo-mid\" src=\"/photos/$DIR/${_file_mid}\"></p>" >> "${_file_html}"
[ -f "${_file_descr}" ] && cat "${_file_descr}" >> "${_file_html}"
echo "<p><a href=index.html>Back to Index</a></p>" >> "${_file_html}"
fi
echo "<td class=\"photo-td\" ><a href=\"/photos/$DIR/${_file_html}\"><img class=\"photo-img\" src=\"${_file_thm}\"></a></td>"
if [ $(( _count % 3 )) -eq 0 ]
then
echo "</tr><tr>"
fi
while [ $(pgrep convert | wc -l) -ge 15 ]
do sleep 0.3; done
done
echo "</tr>"
echo "</table>"
echo "</p>"
echo "<p><a href=../index.html>Back to the gallery index</a></p>"
echo "section: photos" > dir.meta
wait
# it looks like wait doesn't catch processes spawned
# in a subshell. So we check explicitely for running
# convert processes. XXX
while [ $(pgrep convert | wc -l) -ge 1 ]
do sleep 1; done

16
scripts/mkuugcalendar.sh Normal file
View File

@@ -0,0 +1,16 @@
#!/bin/sh
REM=$(curl -s "https://raw.githubusercontent.com/c0dev0id/dotfiles/main/.reminders/uugrn.rem")
rm -f uugrn-calendar.*
echo "$REM" | remind -b1 -p24 - 2>/dev/null | rem2pdf > uugrn-calendar.pdf
echo "$REM" | remind -b1 -p24 - 2>/dev/null | rem2html --nostyle --tableonly > uugrn-calendar.html
echo "$REM" | remind -b1 -p24 - 2>/dev/null | rem2ics > uugrn-calendar.ics
echo "<h1>UUGRN Calendar</h1>"
echo "<ul>"
echo "<li><a href=uugrn-calendar.html>HTML Format</a></li>"
echo "<li><a href=uugrn-calendar.pdf>PDF Format</a></li>"
echo "<li><a href=uugrn-calendar.ics>iCAL Format</a></li>"
echo "</ul>"

30
scripts/reposync.sh Executable file
View File

@@ -0,0 +1,30 @@
#!/bin/sh -e
add_repo() {(
_dir="$(basename "$1")"
if [ -d "code/${_dir}" ]
then
( cd code/${_dir} && git pull )
else
( cd code && git clone "https://$1" )
fi
_fulldir=$(readlink -f "code/${_dir}")
mkdir -p www/code/${_dir}
cp site/code/*.{css,png} www/code/${_dir}/
cd www/code/${_dir}
stagit -u https://stefanhagen.de/code ${_fulldir}
)}
mkdir -p code
add_repo "github.com/c0dev0id/dotfiles"
add_repo "github.com/c0dev0id/mkpicindex"
add_repo "github.com/c0dev0id/mystuff"
add_repo "github.com/c0dev0id/website"
add_repo "github.com/c0dev0id/xpick"
add_repo "github.com/luakit/luakit"
_repos="$(find code/* -mindepth 0 -maxdepth 0 -type d)"
stagit-index ${_repos} > www/code/index.html

65
scripts/tikz.lua Normal file
View File

@@ -0,0 +1,65 @@
local system = require 'pandoc.system'
local tikz_doc_template = [[
\documentclass{standalone}
\usepackage[pdftex]{graphics}
\usepackage[pdftex]{graphicx}
\usepackage{xcolor}
\usepackage{tikz}
\begin{document}
\nopagecolor
%s
\end{document}
]]
local function tikz2image(src, filetype, outfile)
system.with_temporary_directory('tikz2image', function (tmpdir)
system.with_working_directory(tmpdir, function()
local f = io.open('tikz.tex', 'w')
f:write(tikz_doc_template:format(src))
f:close()
os.execute('pdflatex tikz.tex >/dev/null 2>&1')
if filetype == 'pdf' then
os.rename('tikz.pdf', outfile)
else
os.execute('pdf2svg tikz.pdf ' .. outfile .. '>/dev/null 2>&1')
end
end)
end)
end
extension_for = {
html = 'svg',
html4 = 'svg',
html5 = 'svg',
latex = 'pdf',
beamer = 'pdf' }
local function file_exists(name)
local f = io.open(name, 'r')
if f ~= nil then
io.close(f)
return true
else
return false
end
end
local function starts_with(start, str)
return str:sub(1, #start) == start
end
function RawBlock(el)
if starts_with('\\begin{tikzpicture}', el.text) then
local filetype = extension_for[FORMAT] or 'svg'
local fbasename = pandoc.sha1(el.text) .. '.' .. filetype
local fname = system.get_working_directory() .. '/' .. fbasename
if not file_exists(fname) then
tikz2image(el.text, filetype, fname)
end
return pandoc.Para({pandoc.Image({}, fbasename)})
else
return el
end
end