#!/bin/sh mkdir -p web mkdir -p gem orig=$(date +"%s" -d "1989-07-27") fecha=$(date +"%s") let "sem=(${fecha} - ${orig})/3600/24/7" let "dia=(${fecha} - ${orig})/3600/24%7 + 1" fechasjm="sejmana-${sem}, día ${dia}" echo "empezando conversión, estamos en ${fechasjm}" echo "revisando y copiando imágenes..." for f in $(find src/ -regextype awk -regex ".*(jpg|png|gif)") do path="web/${f#src/}" # quita el prefijo de src/ y agrega web/ gempath="gem/${f#src/}" # quita el prefijo de src/ y agrega gem/ mkdir -p $(dirname $path) # crea directorio si no existe mkdir -p $(dirname $gempath) # crea directorio si no existe cp -vu $f $path cp -vu $f $gempath done cp src/tw.txt web/ cp src/tw.txt gem/ cp src/llave_sejo.asc web/ cp src/llave_sejo.asc gem/ cp src/actualizaciones.xml web/ cp src/tiempo.xml web/ cp src/estilo.css web/static/ # limpia echo "limpiando archivos previos..." rm web/*html rm gem/*gmi # crea índice echo "generando índice..." rm src/índice.gmo ls -t src/*gmo | awk -f genindice.awk > src/índice.gmo echo "revisando y convirtiendo archivimos gmo a html y gmi..." i=0 # convierte y actualiza archivos gmi a html for f in $(find src/ -iname *.gmo) do path=${f#src/} # quita el prefijo de "src/" htmlpath="web/${path%gmo}html" # agrega "web/" y cambia el sufijo gempath="gem/${path%gmo}gmi" # agrega "gem/" fecha=$(date -r $f +"%s") # sem=$(echo "(${fecha} - ${orig})/3600/24/7" | bc) # dia=$(echo "(${fecha} - ${orig})/3600/24%7 + 1" | bc) let "sem=(${fecha} - ${orig})/3600/24/7" let "dia=(${fecha} - ${orig})/3600/24%7 + 1" fechasjm="sejmana-${sem}, día ${dia}" fecha=$(date -r $f --rfc-3339=date) # echo "${f}" # echo "${f} -> ${htmlpath}" # echo "${f} -> ${gempath}" # haz la conversión awk -v fecha=$fecha -v fechasjm="$fechasjm" -f gemtext2html.awk $f > $htmlpath awk -v fecha=$fecha -v fechasjm="$fechasjm" -f gmo2gmi.awk $f > $gempath (( i++ )) done echo "convertidas ${i} páginas!"