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
26 GH_PAGES_SIMPLE = style.css CNAME README robots.txt
27 GH_PAGES_PUBLIC = ${GH_PAGES_SIMPLE} pipeglade.1.html pipeglade.1.pdf clock.jpg clock.ui.txt clock.sh.txt 404.html
28 GH_PAGES_TEMP = LICENSE gallery.html index-hrefs
29 .if ${.MAKE.LEVEL} == 0
30 WIDGETS != make man-widgets
32 WIDGET_TXTS != ls -1 widget-examples | grep "\.txt$$"
33 SNAPSHOTS = ${WIDGETS:C|(.*)|gh-pages/\1.jpg|}
35 gh-pages: gh-pages-untested test-index-hrefs
36 rm -f ${GH_PAGES_TEMP:S|^|gh-pages/|}
38 gh-pages-untested: ${GH_PAGES_PUBLIC:S|^|gh-pages/|} ${SNAPSHOTS} gh-pages/index.html
40 .for FILE in ${GH_PAGES_SIMPLE}
41 gh-pages/${FILE}: www-template/${FILE}
43 cp ${.ALLSRC} ${.TARGET}
46 gh-pages/index.html: pipeglade gh-pages/pipeglade.1.html www-template/index.html \
47 gh-pages/gallery.html gh-pages/LICENSE \
48 www-template/statcounter.html www-template/index-toc.xsl Makefile
49 xsltproc --html -o ${.TARGET} www-template/index-toc.xsl www-template/index.html
50 echo -e '/<!-- replace_with_widget_gallery -->/d\n-r gh-pages/gallery.html\nwq' | ed -s gh-pages/index.html
51 echo -e '/<!-- replace_with_license_text -->/d\n-r gh-pages/LICENSE\nwq' | ed -s gh-pages/index.html
52 echo -e ',s/_PUT_VERSION_HERE_/$(VERSION)/g\nwq' | ed -s gh-pages/index.html
53 echo -e '/<\/body>/-r www-template/statcounter.html\nwq' | ed -s gh-pages/index.html
55 gh-pages/LICENSE: LICENSE Makefile
57 sed 's/&/\&/g; s/</\</g; s/>/\>/g; s/"/\"/g; s/'"'"'/\'/g; s|^$$|<p/>|g' <LICENSE >${.TARGET}
59 gh-pages/404.html: gh-pages/pipeglade.1.html Makefile www-template/statcounter.html
61 cp www-template/404.html gh-pages/
62 echo -e '/<\/body>/-r www-template/statcounter.html\nwq' | ed -s gh-pages/404.html
64 gh-pages/clock.sh.txt gh-pages/clock.ui.txt: clock.sh clock.ui
66 cp clock.sh gh-pages/clock.sh.txt
67 cp clock.ui gh-pages/clock.ui.txt
69 gh-pages/pipeglade.1.html gh-pages/pipeglade.1.pdf: pipeglade.1 Makefile www-template/statcounter.html
71 mandoc -Wall -T xhtml -O style=style.css pipeglade.1 > gh-pages/pipeglade.1.html
72 mandoc -Wall -T pdf -O paper=a4 pipeglade.1 > gh-pages/pipeglade.1.pdf
73 echo -e '/<\/body>/-r www-template/statcounter.html\nwq' | ed -s gh-pages/pipeglade.1.html
75 gh-pages/clock.jpg: clock.svg
77 convert "${.ALLSRC}" -frame 2 "${.TARGET}"
79 clock.svg: clock.sh clock.ui pipeglade
82 # Screenshots of the widget examples
85 .if exists(widget-examples/${W:S/Gtk//:tl}.txt)
86 gh-pages/${W:S/$/.jpg/}: widget-examples/${W:S/Gtk//:tl}.ui widget-examples/${W:S/Gtk//:tl}.txt
87 @echo "creating widget snapshot ${.TARGET}"
89 @echo "_:load widget-examples/${W:S/Gtk//:tl}.txt" | \
90 ./pipeglade -u widget-examples/${W:S/Gtk//:tl}.ui >/dev/null
91 @convert "${.TARGET:R}.svg" -resize 80% -frame 2 "${.TARGET}" && rm "${.TARGET:R}.svg"
93 gh-pages/${W:S/$/.jpg/}: widget-examples/${W:S/Gtk//:tl}.ui
94 @echo "creating widget snapshot ${.TARGET}"
96 @(echo "main:snapshot ${.TARGET:R}.svg"; echo "_:main_quit") | \
97 ./pipeglade -u ${.ALLSRC} >/dev/null
98 @convert "${.TARGET:R}.svg" -resize 80% -frame 2 "${.TARGET}" && rm "${.TARGET:R}.svg"
102 gh-pages/gallery.html: ${SNAPSHOTS}
103 @echo "writing html for widget snapshots: ${SNAPSHOTS:T:R}"
104 @for i in ${.ALLSRC:T:R}; do \
106 echo "<div class=\"display\">"; \
107 echo " <i class=\"link-sec\">"; \
108 echo -n " <a href=\"pipeglade.1.html#"; \
109 xmllint --html --xpath "string(//div[@class=\"section\"]/h1[text()=\"WIDGETS\"]/../div[@class=\"subsection\"]/h2[text()=\"$${i}\"]/@id)" gh-pages/pipeglade.1.html; \
110 echo -n "\">$${i}</a>"; \
112 echo " (cf. <a class=\"link-ext\" href=\"https://developer.gnome.org/gtk3/stable/$${i}.html\">GTK+ 3 Reference Manual</a>)"; \
114 echo " <img src=\"$${i}.jpg\">"; \
119 # Do we have dead links?
120 gh-pages/index-hrefs: gh-pages/index.html www-template/a-hrefs.xsl
121 xsltproc --html www-template/a-hrefs.xsl gh-pages/index.html | grep -E "^http.?://" | grep -v "../github.com/trebb/pipeglade" > ${.TARGET}
123 test-index-hrefs: gh-pages/index-hrefs
124 @echo "checking for dead links..."
125 @for i in `cat ${.ALLSRC}`; do \
126 if curl -w %{http_code} -s -o /dev/null $$i | grep -q 200; then \
129 echo; echo "dead link: $$i"; \
136 # Push the www directory to Github Pages
141 git commit -a -m "gh-pages pseudo commit"; \
142 git push git@github.com:trebb/pipeglade.git +master:gh-pages)