X-Git-Url: https://git.draconx.ca/gitweb/homepage.git/blobdiff_plain/da4a13ce4868f32787813c76898cc9b39dec1bcc..da38a0de6d2814c450ea356412faa03ee54cad68:/Rules diff --git a/Rules b/Rules index 06f3a11..5473788 100644 --- a/Rules +++ b/Rules @@ -1,6 +1,6 @@ #!/usr/bin/env ruby # -# Copyright © 2018 Nick Bowler +# Copyright © 2018-2020 Nick Bowler # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,6 +16,13 @@ # along with this program. If not, see . preprocess do + # Remove dead annex keys from processing + @items.delete_if do |item| + l = File.readlink(item.raw_filename) + true if !File.exists?(item.raw_filename) and l =~ %r{/annex/objects/} + rescue Errno::EINVAL + end + commit = nil Open3.popen2("git", "rev-parse", "HEAD") do |stdin, stdout, result| stdin.close @@ -31,11 +38,43 @@ preprocess do end end +postprocess do + # Gzip all text items for nginx http_static + if !ENV['GZIP_SITE'].to_s.empty? + reps = @items.flat_map(&:reps).each do |rep| + file = rep.raw_path + next if !file or rep.binary? + + if system("gzip", "-ck9", file, [:out]=>[file + ".gz.tmp", "wb"]) + system("touch", "-r", file, file + ".gz.tmp") + File.rename(file + ".gz.tmp", file + ".gz") + else + File.unlink(file + ".gz.tmp") + end + end + end +end + +compile '/license/gpl*.md' do + filter :kramdown, auto_ids: false, header_offset: -1 + layout '/default.xml' + layout '/gpl.xsl' + layout '/default.xsl' + filter :relativize_paths, type: :xml + filter :xhtml_compat + filter :remove_wj + write to_xhtml +end + compile '/**/*.md' do - filter :kramdown, header_offset: 1 + filter :erb + filter :kramdown, auto_ids: false, header_offset: 1 + snapshot :rawbody layout '/default.xml' layout '/default.xsl' filter :relativize_paths, type: :xml + filter :xhtml_compat + filter :remove_wj write to_xhtml end @@ -43,19 +82,38 @@ compile '/license/cc*.sgml' do filter :sgml2xml layout '/creativecommons.xsl' layout '/default.xml' - layout '/default.xsl' + layout '/default.xsl', "section-links": "yes" filter :relativize_paths, type: :xml + filter :xhtml_compat + filter :remove_wj write to_xhtml end compile '/license/cc*.xhtml' do layout '/creativecommons.xsl' layout '/default.xml' - layout '/default.xsl' + layout '/default.xsl', "section-links": "yes" filter :relativize_paths, type: :xml + filter :xhtml_compat + filter :remove_wj write to_xhtml end -passthrough '/**/*' +compile '/**/*.scss' do + filter :sass, syntax: :scss + filter :css_source, uribase: \ + "https://git.draconx.ca/gitweb/homepage.git/blob/" + + @item[:gitrev] + ":" + filter :css_clean_selectors, \ + preserve_comments: true, \ + preserve_hacks: true + write @item.identifier.without_ext + '.css' +end + +compile '/**/*' do + filter :copybin if @item.binary? + write @item.identifier.to_s +end + layout '/**/*.xsl', :xsl layout '/**/*', :erb