#!/bin/bash # # Generator vizitek z brmlabi wiki # $1 = nazev projektu pro ktery se ma vizitka vygenerovat, pokud neni zadano, vygeneruji se vsechny # Zavislosti: pdflatex (+ amssymb, tikz, multicol, xcolor, calc, graphicx), wget # if [ "$1" = "WikiViz" ]; then echo "Too meta" exit fi wiki=$(wget https://brmlab.cz/project/start -O - 2>/dev/null | grep -e '^
.*$' | sed -e $"s/<\/a>/<\/a>\n/g") if [ "$1" != "" ]; then wiki=$(echo "$wiki" | grep "$1") fi while IFS='' read -r w || [[ -n "$w" ]]; do t=$(echo "$w" | grep -o -e ' title="[A-Za-z0-9_+ -]*">' | sed -e 's/ title="//g' -e 's/>//g' | tr -d '"') i=$(echo "$w" | grep -o -e 'background-image:url([^?]*' | sed -e 's/background-image:url(//g') u=$(echo "$w" | grep -o -e 'href="[^"]*' | cut -b 6- | tr -d '"') img=$(echo "$i" | grep -o -e '[^/]*$') url=$(echo "$u" | sed -e 's/\//%2F/g' -e 's/:/%3A/g') echo "$t $i $img $u" wget "$i" -O "$img" 2>/dev/null wget "https://api.qrserver.com/v1/create-qr-code/?data=$url&size=220x220&margin=10" -O ./qr.png 2>/dev/null cat ./wikiviz_sample.tex | sed -e "s/__LOGO__/$img/g" | sed -e "s/__PROJECT__/$t/g" > "./$t.tex" # Pustit dvakrat kvuli prepoctu velikosti pdflatex -synctex=1 -interaction=nonstopmode "./$t.tex" >/dev/null sleep 1 pdflatex -synctex=1 -interaction=nonstopmode "./$t.tex" >/dev/null #atril "./$t.pdf" done <<< "$wiki"