Mercurial > dottes
comparison makeWeb.sh @ 588:afc031477784
Replace sed substitution with Python templating for HTML and LaTeX output.
author | Jim Hague <jim.hague@acm.org> |
---|---|
date | Wed, 02 Nov 2016 00:21:18 +0000 |
parents | daa3b76bd11f |
children | 4e92928fcfc2 |
comparison
equal
deleted
inserted
replaced
587:1b79867b4f35 | 588:afc031477784 |
---|---|
64 find $bookedir -name "*.abc" | sort | | 64 find $bookedir -name "*.abc" | sort | |
65 while read filename | 65 while read filename |
66 do | 66 do |
67 name=`basename $filename .abc` | 67 name=`basename $filename .abc` |
68 | 68 |
69 # Extract items to substitute in the web page. | |
70 title=`$dir/abcfield.py --field T --display $filename` | |
71 subtitle=`$dir/abcfield.py --index 2 --field T --display $filename` | |
72 composer=`$dir/abcfield.py --field C $filename` | |
73 changefile=`$dir/abcfield.py --field N --starts "Change:" $filename` | |
74 changetitle="" | |
75 changevisibility="no" | |
76 if [ -n "$changefile" ]; then | |
77 changetitle=`$dir/abcfield.py --field T --display $bookedir/$changefile` | |
78 changevisibility="yes" | |
79 fi | |
80 credit=`$dir/abcfield.py --field N --starts "Credit:" $filename` | |
81 creditvisibility="no" | |
82 if [ -n "$credit" ]; then | |
83 creditvisibility="yes" | |
84 fi | |
85 lastchanged=`hg log --limit 1 --template "{date|shortdate}" $masterbookedir/${name}.abc` | |
86 key=`$dir/abcfield.py --field K --display $filename` | |
87 | |
88 # Copy the ABC into the web. | 69 # Copy the ABC into the web. |
89 cp $filename $webdir | 70 cp $filename $webdir |
90 | 71 |
91 # Generate MusicXML into the web. | 72 # Generate MusicXML into the web. |
92 python $abc2xml $filename > ${webdir}/${name}.xml | 73 python $abc2xml $filename > ${webdir}/${name}.xml |
99 pushd ${webdir} > /dev/null | 80 pushd ${webdir} > /dev/null |
100 ln -f -s ../${masterbooke}/*${name}.mp3 . | 81 ln -f -s ../${masterbooke}/*${name}.mp3 . |
101 popd > /dev/null | 82 popd > /dev/null |
102 fi | 83 fi |
103 | 84 |
85 # Get date and time of last change to tune. | |
86 lastchanged=`hg log --limit 1 --template "{date|shortdate}" $masterbookedir/${name}.abc` | |
87 | |
104 # Generate the tune web page. | 88 # Generate the tune web page. |
105 tunepage=${name}.html | 89 tunepage=${name}.html |
106 learnerpage=learner-${name}.html | 90 learnerpage=learner-${name}.html |
107 | 91 |
108 # If the title contains HTML character entities, escape | 92 $dir/abctemplate.py --value "masterbooke=${masterbooke}" --value "lastchanged=${lastchanged}" --template dottes.html.tune $filename > $webdir/$tunepage |
109 # initial '&' in the title - it means things to sed. | 93 $dir/abctemplate.py --value "masterbooke=${masterbooke}" --value "lastchanged=${lastchanged}" --template dottes.html.learnertune $filename > $webdir/$learnerpage |
110 sed -e "s/@TITLE@/${title//&/\\&}/" \ | 94 $dir/abctemplate.py --template dottes.html.tuneindex $filename >> $webdir/$tunelist |
111 -e "s/@SUBTITLE@/${subtitle}/" \ | |
112 -e "s/@COMPOSER@/${composer}/" \ | |
113 -e "s/@KEY@/${key}/" \ | |
114 -e "s/@MASTERBOOKE@/${masterbooke}/" \ | |
115 -e "s/@CHANGETITLE@/${changetitle//&/\\&}/" \ | |
116 -e "s/@CHANGETUNE@/${changefile/.abc/.html}/" \ | |
117 -e "s/@CHANGEVISIBILITY@/${changevisibility}/" \ | |
118 -e "s/@CREDIT@/${credit}/" \ | |
119 -e "s/@CREDITVISIBILITY@/${creditvisibility}/" \ | |
120 -e "s/@LASTCHANGED@/${lastchanged}/" \ | |
121 -e "s/@TUNE@/${name}/" dottes.html.tune > $webdir/$tunepage | |
122 | |
123 sed -e "s/@TITLE@/${title//&/\\&}/" \ | |
124 -e "s/@SUBTITLE@/${subtitle}/" \ | |
125 -e "s/@COMPOSER@/${composer}/" \ | |
126 -e "s/@KEY@/${key}/" \ | |
127 -e "s/@MASTERBOOKE@/${masterbooke}/" \ | |
128 -e "s/@CHANGETITLE@/${changetitle//&/\\&}/" \ | |
129 -e "s/@CHANGETUNE@/${changefile/.abc/.html}/" \ | |
130 -e "s/@CHANGEVISIBILITY@/${changevisibility}/" \ | |
131 -e "s/@CREDIT@/${credit}/" \ | |
132 -e "s/@CREDITVISIBILITY@/${creditvisibility}/" \ | |
133 -e "s/@LASTCHANGED@/${lastchanged}/" \ | |
134 -e "s/@TUNE@/${name}/" dottes.html.learnertune > $webdir/$learnerpage | |
135 | |
136 sed -e "s/@TITLE@/${title//&/\\&}/" \ | |
137 -e "s/@TUNE@/${name}/" dottes.html.tuneindex >> $webdir/$tunelist | |
138 done | 95 done |