]> git.draconx.ca Git - homepage.git/blobdiff - Rules
Remove dead definition list cruft.
[homepage.git] / Rules
diff --git a/Rules b/Rules
index 547a0a9dd340c32fd19c6ee58d7671c1febcee28..d0a81fb8c496c7f2232393bdba6f32dbd68fdc30 100644 (file)
--- a/Rules
+++ b/Rules
@@ -1,6 +1,6 @@
 #!/usr/bin/env ruby
 #
-# Copyright © 2018 Nick Bowler
+# Copyright © 2018-2019 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
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
+preprocess do
+    commit = nil
+    Open3.popen2("git", "rev-parse", "HEAD") do |stdin, stdout, result|
+        stdin.close
+        val = stdout.gets
+        stdout.close
+        commit = val.chomp if result.value.success?
+    end
+
+    if commit then
+        @items.each do |item|
+            item[:gitrev] = commit if item_source(item)
+        end
+    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 :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 :remove_wj
+    write to_xhtml
+end
+
+compile '/license/cc*.sgml' do
+    filter :sgml2xml
+    layout '/creativecommons.xsl'
+    layout '/default.xml'
+    layout '/default.xsl'
+    filter :relativize_paths, type: :xml
+    filter :remove_wj
+    write to_xhtml
+end
+
+compile '/license/cc*.xhtml' do
+    layout '/creativecommons.xsl'
     layout '/default.xml'
     layout '/default.xsl'
     filter :relativize_paths, type: :xml
+    filter :remove_wj
     write to_xhtml
 end