1 # Copyright (c) 2014-2017 Bert Burgemeister <trebbu@googlemail.com>
3 # Permission is hereby granted, free of charge, to any person
4 # obtaining a copy of this software and associated documentation files
5 # (the "Software"), to deal in the Software without restriction,
6 # including without limitation the rights to use, copy, modify, merge,
7 # publish, distribute, sublicense, and/or sell copies of the Software,
8 # and to permit persons to whom the Software is furnished to do so,
9 # subject to the following conditions:
11 # The above copyright notice and this permission notice shall be
12 # included in all copies or substantial portions of the Software.
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18 # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 # Prepare the www directory
29 VERSION != (which git >/dev/null && git describe --tags || echo "NONE") | cut -d "-" -f 1
30 GH_PAGES_SIMPLE = style.css CNAME README robots.txt
31 GH_PAGES_PUBLIC = ${GH_PAGES_SIMPLE} pipeglade.1.html pipeglade.1.pdf clock.jpg clock.ui.txt clock.sh.txt 404.html
32 GH_PAGES_TEMP = LICENSE gallery.html index-hrefs
33 .if ${.MAKE.LEVEL} == 0
34 WIDGETS != make man-widgets
36 WIDGET_TXTS != ls -1 widget-examples | grep "\.txt$$"
37 SNAPSHOTS = ${WIDGETS:C|(.*)|gh-pages/\1.jpg|}
39 gh-pages: gh-pages-untested test-index-hrefs
40 rm -f ${GH_PAGES_TEMP:S|^|gh-pages/|}
42 gh-pages-untested: ${GH_PAGES_PUBLIC:S|^|gh-pages/|} $(SNAPSHOTS) gh-pages/index.html
44 .for FILE in ${GH_PAGES_SIMPLE}
45 gh-pages/${FILE}: www-template/${FILE}
47 cp ${.ALLSRC} ${.TARGET}
50 gh-pages/index.html: pipeglade gh-pages/pipeglade.1.html www-template/index.html \
51 gh-pages/gallery.html gh-pages/LICENSE \
52 www-template/statcounter.html www-template/index-toc.xsl Makefile
53 xsltproc --html -o ${.TARGET} www-template/index-toc.xsl www-template/index.html
54 echo -e '/<!-- replace_with_widget_gallery -->/d\n-r gh-pages/gallery.html\nwq' | ed -s gh-pages/index.html
55 echo -e '/<!-- replace_with_license_text -->/d\n-r gh-pages/LICENSE\nwq' | ed -s gh-pages/index.html
56 echo -e ',s/_PUT_VERSION_HERE_/$(VERSION)/g\nwq' | ed -s gh-pages/index.html
57 echo -e '/<\/body>/-r www-template/statcounter.html\nwq' | ed -s gh-pages/index.html
59 gh-pages/LICENSE: LICENSE Makefile Makefile.publish
61 sed 's/&/\&/g; s/</\</g; s/>/\>/g; s/"/\"/g; s/'"'"'/\'/g; s|^$$|<p/>|g' <LICENSE >${.TARGET}
63 gh-pages/404.html: gh-pages/pipeglade.1.html Makefile www-template/statcounter.html
65 cp www-template/404.html gh-pages/
66 echo -e '/<\/body>/-r www-template/statcounter.html\nwq' | ed -s gh-pages/404.html
68 gh-pages/clock.sh.txt gh-pages/clock.ui.txt: clock.sh clock.ui
70 cp clock.sh gh-pages/clock.sh.txt
71 cp clock.ui gh-pages/clock.ui.txt
73 gh-pages/pipeglade.1.html gh-pages/pipeglade.1.pdf: pipeglade.1 Makefile www-template/statcounter.html
75 mandoc -Wall -T xhtml -O style=style.css pipeglade.1 > gh-pages/pipeglade.1.html
76 mandoc -Wall -T pdf -O paper=a4 pipeglade.1 > gh-pages/pipeglade.1.pdf
77 echo -e '/<\/body>/-r www-template/statcounter.html\nwq' | ed -s gh-pages/pipeglade.1.html
79 gh-pages/clock.jpg: clock.svg
81 convert "${.ALLSRC}" -frame 2 "${.TARGET}"
83 clock.svg: clock.sh clock.ui pipeglade
86 # Our collection of simple test widgets
88 @ls -1 widget-examples | grep "\.ui$$"
90 # Screenshots of the widget examples
93 .if exists(widget-examples/${W:S/Gtk//:tl}.txt)
94 gh-pages/${W:S/$/.jpg/}: widget-examples/${W:S/Gtk//:tl}.ui widget-examples/${W:S/Gtk//:tl}.txt
95 @echo "creating widget snapshot ${.TARGET}"
97 @echo "_:load widget-examples/${W:S/Gtk//:tl}.txt" | \
98 ./pipeglade -u widget-examples/${W:S/Gtk//:tl}.ui >/dev/null
99 @convert "${.TARGET:R}.svg" -resize 80% -frame 2 "${.TARGET}" && rm "${.TARGET:R}.svg"
101 gh-pages/${W:S/$/.jpg/}: widget-examples/${W:S/Gtk//:tl}.ui
102 @echo "creating widget snapshot ${.TARGET}"
104 @(echo "main:snapshot ${.TARGET:R}.svg"; echo "_:main_quit") | \
105 ./pipeglade -u ${.ALLSRC} >/dev/null
106 @convert "${.TARGET:R}.svg" -resize 80% -frame 2 "${.TARGET}" && rm "${.TARGET:R}.svg"
110 gh-pages/gallery.html: ${SNAPSHOTS}
111 @echo "writing html for widget snapshots: ${SNAPSHOTS:T:R}"
112 @for i in ${.ALLSRC:T:R}; do \
114 echo "<div class=\"display\">"; \
115 echo " <i class=\"link-sec\">"; \
116 echo -n " <a href=\"pipeglade.1.html#"; \
117 xmllint --html --xpath "string(//div[@class=\"section\"]/h1[text()=\"WIDGETS\"]/../div[@class=\"subsection\"]/h2[text()=\"$${i}\"]/@id)" gh-pages/pipeglade.1.html; \
118 echo -n "\">$${i}</a>"; \
120 echo " (cf. <a class=\"link-ext\" href=\"https://developer.gnome.org/gtk3/stable/$${i}.html\">GTK+ 3 Reference Manual</a>)"; \
122 echo " <img src=\"$${i}.jpg\">"; \
127 # Do we have dead links?
128 gh-pages/index-hrefs: gh-pages/index.html www-template/a-hrefs.xsl
129 xsltproc --html www-template/a-hrefs.xsl gh-pages/index.html | grep -E "^http.?://" | grep -v "../github.com/trebb/pipeglade" > ${.TARGET}
131 test-index-hrefs: gh-pages/index-hrefs
132 @echo "checking for dead links..."
133 @for i in `cat ${.ALLSRC}`; do \
134 if curl -w %{http_code} -s -o /dev/null $$i | grep -q 200; then \
137 echo; echo "dead link: $$i"; \
144 # Push the www directory to Github Pages
149 git commit -a -m "gh-pages pseudo commit"; \
150 git push git@github.com:trebb/pipeglade.git +master:gh-pages)