3 # Copyright © 2018-2020 Nick Bowler
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 # Remove dead annex keys from processing
20 @items.delete_if do |item|
21 l = File.readlink(item.raw_filename)
22 true if !File.exists?(item.raw_filename) and l =~ %r{/annex/objects/}
27 Open3.popen2("git", "rev-parse", "HEAD") do |stdin, stdout, result|
31 commit = val.chomp if result.value.success?
36 item[:gitrev] = commit if item_source(item)
42 # Gzip all text items for nginx http_static
43 if !ENV['GZIP_SITE'].to_s.empty?
44 reps = @items.flat_map(&:reps).each do |rep|
46 next if !file or rep.binary?
48 if system("gzip", "-ck9", file, [:out]=>[file + ".gz.tmp", "wb"])
49 system("touch", "-r", file, file + ".gz.tmp")
50 File.rename(file + ".gz.tmp", file + ".gz")
52 File.unlink(file + ".gz.tmp")
57 # Register URLs for git-annex keys
58 unless (uribase = ENV['ANNEX_URI_BASE'].to_s.chomp("/")).empty?
59 Open3.popen2("git", "annex", "registerurl") do |stdin, stdout, result|
61 l = File.readlink(item.raw_filename)
62 next unless l =~ %r{/annex/objects/}
64 key = File.basename(l)
66 # Find output reps corresponding to this key, if any
67 item.reps.each do |rep|
69 FileUtils.identical?(item.raw_filename, rep.raw_path)
72 STDOUT.write(stdout.read_nonblock(100))
73 rescue EOFError, IO::WaitReadable
77 stdin.printf("%s %s%s\n", key, uribase, rep.path)
84 STDOUT.write(stdout.readpartial(100))
89 unless (rc = result.value).success?
90 printf("git annex registerurl failed: %s\n", rc.to_s)
96 compile '/license/gpl*.md' do
97 filter :kramdown, auto_ids: false, header_offset: -1
100 layout '/default.xsl'
101 filter :relativize_paths, type: :xml
107 compile '/**/*.md' do
109 filter :kramdown, auto_ids: false, header_offset: 1
111 layout '/default.xml'
112 layout '/default.xsl'
113 filter :relativize_paths, type: :xml
119 compile '/license/cc*.sgml' do
121 layout '/creativecommons.xsl'
122 layout '/default.xml'
123 layout '/default.xsl', "section-links": "yes"
124 filter :relativize_paths, type: :xml
130 compile '/license/cc*.xhtml' do
131 layout '/creativecommons.xsl'
132 layout '/default.xml'
133 layout '/default.xsl', "section-links": "yes"
134 filter :relativize_paths, type: :xml
140 compile '/images/*.jpg', rep: :large do
141 filter :imgresize, width: 1200, height: 1200
142 write item.identifier.without_ext + '-t1200.' + item.identifier.ext
145 compile '/images/*.jpg', rep: :info do
147 layout '/imginfo.xsl'
148 layout '/default.xml'
149 layout '/default.xsl'
150 filter :relativize_paths, type: :xml
156 compile '/**/*.scss' do
157 filter :sass, syntax: :scss
158 filter :css_source, uribase: \
159 "https://git.draconx.ca/gitweb/homepage.git/blob/" +
161 filter :css_clean_selectors, \
162 preserve_comments: true, \
164 write @item.identifier.without_ext + '.css'
168 filter :copybin if @item.binary?
169 write @item.identifier.to_s
172 layout '/**/*.xsl', :xsl