# makefile -- what I use to manage my website
# Copyright : http://www.fsf.org/copyleft/gpl.html
# Author : Dan Jacobson -- http://jidanni.org/
# Created On : Jan 2001
# Last Modified On: Thu Jun 12 02:53:12 2008
# Update Count : 1381
P=sitecopy
S=dreamhost #radioscanningtw #taizhongbus
show:english
$P $S
W=../.website_update_time
$W:
touch -d 1/1/2000 $@
update:english
#worried so make backup
for i in $S; do \
cp --backup=t /home/jidanni/.$P/$$i /var/tmp/$P-$$i; done
until test $$((retrys++)) -gt 9 || $P --update $S;do sleep 4;done
$P --update $S #to set the return code from this makefile...
touch $W
~/$P-dont-update:
touch $@
dont-update: ~/$P-dont-update
latest.txt:$W
#??? if test -f $@; then test "$$(find * -type f -newer $@)"; fi
{ d=30; echo http://jidanni.org/ $$d days\' changes since \
$$(date '+%F %T %z');\
find * -type f -mtime -$$d ! -name $@|xargs --no-run-if-empty ls -lt|\
perl -nalwe 'if($$.==30){print "[etc.]";exit};$(\
)$$F[5]=~s/.....//;print"$$F[5] $$F[7]"';}>$@
nof=../.website_number_of_files #but not if we changed just titles!!!!
sitemap.html:$W
if ! find * -type f|wc -l|diff $(nof) -; then set -e;\
comp/sitemap-jidanni-ch>$@;\
$(tidyline);\
perl -plwe 'if(m/
/s...0 and m/\.html"/s)$(\
){@F=split/"/;$$F[1]=~s/\.html/_en.html/;$(\
)if(-f$$F[1]){$$F[2]=~s/\.html/_en.html/;$$_=join(q!"!,@F)}};$(\
)s/$(Nonascii)//g;s/\s*<\/dd>//;$(\
)if(1..m//s){s/="zh-tw"/="en-us"/s}' \
$@|$(tidy0) -q > sitemap-en.html; fi; find * -type f|wc -l >$(nof)
E=*_en.html
english: $E */$E */*/$E */*/*/$E */*/*/*/$E dotindexes
#$(shell) wasteful
#depth checks, equivalent:
depth0:;find * -name \*_en.html|perl -pwletr@/@@cd|sort|uniq -c|sort -k 2
depth1: #could even combine the find into perl one day too
find * -name \*_en.html|\
perl -we 'use strict;my %v;while(<>){tr@/@@cd;$$v{$$_}++}$(\
)for(sort keys %v){printf "%3d %s\n",$$v{$$_},$$_}'
Nonascii=[^[:ascii:]]#one day strip less, e.g., symbols, accents... IPA?!
tidy0=tidy --tidy-mark no -utf8
tidy=$(tidy0) -qm $@
tidyline=$(tidy)||$(tidy)||$(tidy)||$(tidy)||$(tidy) #Until clothes are clean!
%_en.html: %.html
perl -pwle \
's/$(Nonascii)//g; s/ +$$//; $(\
)if(1../<\/head>/i){s/\bzh-tw\b/en-us/g}' $< >$@
$(tidyline)
#remove empty former Chinese links:
perl -wpi -e 'BEGIN{$$/=""}s@@@g' $@
$(tidyline)
getp:
sh ~/bin/update-website-programs
disallow_images_check:
find * -name images -type d -printf "Disallow: /%p/\n"|\
sort robots.txt -|uniq -u
robots_all_valid_check:robots.txt
perl -nwe 'next unless s@^Disallow: /@@;chomp;$(\
)if(!-e$$_){print"gone: $$_\n"}' $?
#"When defining fragment identifiers
#to be backward-compatible, only strings matching the pattern
#[A-Za-z][A-Za-z0-9:_.-]* should be used. See Section 6.2 of [HTML4]
#for more information. http://www.w3.org/TR/html/#ref-html4"
name_check:
find * -name \*.html ! -name \*_en.html|\
xargs lynx -listonly -dump|perl -nwe \
'if(/#/&&!/#[A-Za-z][A-Za-z0-9:_.-]*$$/){s@.*jidanni.org/@@;print}'
access:
find * -name \*.html ! -name \*_en.html|\
xargs $(tidy0) -e -access 3 2>&1|\
perl -pwe 'if(/^line/){s/[^-]+//}'|sort|uniq -c
access2:
set -e -- $$(find * -name \*.html ! -name \*_en.html);\
for i do echo $$i:; $(tidy0) -e -access 3 $$i 2>&1|sed '/^$$/d'; done
#One day clean up comments in HTML
#GREAT analysis of long lines
zf8:#/tmp/zhlist
set -e -- $$(find $(uhrange) -name \*.html);\
for i do echo $$i:;perl -C -nlwe \
'$$l=$$_;s/$(Nonascii)/12/g;print $$l if length>80' $$i;done
Noenus:
find * -name \*html|\
xargs grep --files-without-match content=\"..-..\"|tee /tmp/$@
tggz:
find * -name \*.zip -o -name \*.gz
show_filetypes:
find * -type f|perl -pwe's/[^.]*//'|sort|uniq -c|sort -rn
lastmod1:
find * -name \*.html ! -name \*_en.html|\
xargs grep --files-without-match Last\ modified:
nocharset:
find * -name \*.html ! -name \*_en.html|\
xargs grep --files-without-match charset=
nostrict:
find * -name \*.html ! -name \*_en.html|\
xargs fgrep --files-without-match \
'"http://www.w3.org/TR/html4/strict.dtd">'
wide_whitespace:
find * -type f ! -name \*_en.html|\
xargs fgrep -n ' '
### before connecting modem
any_leftover_backups:
if find .|grep \#;\
then echo BACKUP FILES LEFT OVER, TURKEY; exit 99; fi
#b5char=[\x80-\xFE][\x40-\x7E\xA1-\xFE]#but not below
find_big5:
set -e -- $$(find . -type f ! -name '*'.png ! \
-name '*'.jpg ! -name '*'.zip ! -name '*'.gz ! -name '*'.tgz \
! -name '*'.pdf ! -name '*'.ico)&&\
for i do perl -nlwe \
'if(/[[:print:]][\x80-\xFE][\x40-\x7E]/){print$$ARGV;exit}' $$i;done
valid:#the last step of all
find . -name '*.html' -newer $W|xargs -r validate -w --emacs
overlyenglish:
set -- $$(find -name \*.html ! -name \*_en.html);\
for i do test -f $${i/.html/_en.html}||echo $$i; done|\
xargs fgrep -l content=\"en-us|xargs fgrep _en.html
modem:
make any_leftover_backups
make english
make sitemap.html
# make latest.txt
make valid
#http://wiki.dreamhost.com/index.php/KB_/_Web_Programming_/_Error_messages
hardlinks:
find . -type f ! -links 1 -ls
orphan:english
linklint -root ~/jidanni.org/ -orphan -warn -limit 1111 \
-doc /tmp/$@ -dont_output skipped -dont_output A$$ \
-dont_output F$$ -dont_output warn \
-dont_output file -skip /sitemap@.html -htmlonly /@
sitemap_orphan:#guessing
linklint -root ~/jidanni.org/ -orphan -warn -limit 1111 \
-doc /tmp/$@ -dont_output skipped -dont_output A$$ \
-dont_output F$$ -dont_output warn \
-dont_output file -htmlonly /sitemap.html /sitemap-en.html
todays_changes:
find . -mtime -1 -type f ! -name \*_en.html|cpio -ov|\
gzip>/tmp/`hostname`.org.`date +%s`.cpio.gz
z-variants: #see also comp/index.html
find -wholename ./lang/dongshike -prune -o \( \
! -name \*_en.html \( -name \*.html -o -name \*.txt \) \
-print -exec decompozdiff {} \; \)
dotindexes:comp/configuration/index.html#override apache index
comp/configuration/index.html:comp/configuration
{ cd $? && echo "Dan Jacobson's configuration files";\
find `ls -A` -maxdepth 1 -type f \
! -name index.html -printf '%f\n';}|\
txt2html --no-xhtml --no-ec --titlefirst>$@