]> git.draconx.ca Git - homepage.git/blobdiff - Rules
cdecl99-1.3 bash-5 hotfix
[homepage.git] / Rules
diff --git a/Rules b/Rules
index d3247cb8e2be32b62a75789495b9ed79ae29c05e..1aa5907bcd4185432355a52907218eea35f4b4d2 100644 (file)
--- a/Rules
+++ b/Rules
@@ -1,6 +1,6 @@
 #!/usr/bin/env ruby
 #
-# Copyright © 2018-2020 Nick Bowler
+# Copyright © 2018-2022 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
@@ -68,20 +68,24 @@ preprocess do
 
         @items.create("", attrs, "#{dir}/index.lst")
     end
+
+    create_wkd_items(@items["/pubring.gpg"])
+    create_hkp_items(@items["/pubring.gpg"])
 end
 
 postprocess do
     # Gzip all text items for nginx http_static
-    if !ENV['GZIP_SITE'].to_s.empty?
+    gzip_site = !ENV['GZIP_SITE'].to_s.empty?
+    if gzip_site
         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")
+            next if rep.binary?
+            rep.instance_variable_get(:@item_rep).raw_paths[:last].each do |f|
+                if system("gzip", "-nck9", f, [:out]=>["#{f}.gz.tmp", "wb"])
+                    system("touch", "-r", f, "#{f}.gz.tmp")
+                    File.rename("#{f}.gz.tmp", "#{f}.gz")
+                else
+                    File.unlink("#{f}.gz.tmp")
+                end
             end
         end
     end
@@ -100,6 +104,7 @@ postprocess do
 
                 # Find output reps corresponding to this key, if any
                 item.reps.each do |rep|
+                    next if rep.raw_path.nil?
                     next unless
                         FileUtils.identical?(item.raw_filename, rep.raw_path)
 
@@ -179,11 +184,21 @@ compile '/license/cc*.xhtml' do
 end
 
 compile '/images/*.jpg', rep: :large do
+    w, h = FastImage.size(item.raw_filename)
     filename = item.identifier.without_ext + '-t1200.' + item.identifier.ext
-    filter :imgresize, width: 1200, height: 1200, cache: filename
+    filter :imgresize, width: [w, 1200].min, height: [h, 1200].min, cache: filename
     write filename
 end
 
+compile '/images/*.jpg', rep: :medium do
+    w, h = FastImage.size(item.raw_filename)
+    filename = item.identifier.without_ext + '-t800.' + item.identifier.ext
+    if w > 900 or h > 900
+        filter :imgresize, width: 800, height: 800, cache: filename
+        write filename
+    end
+end
+
 compile '/images/*.jpg', rep: :info do
     filter :imginfo
     layout '/imginfo.xsl'
@@ -195,16 +210,39 @@ compile '/images/*.jpg', rep: :info do
 end
 
 compile '/**/*.scss' do
-    filter :sass, syntax: :scss
+    filter :sass, syntax: :scss, load_paths: ["."]
     filter :css_source, uribase: \
         "https://git.draconx.ca/gitweb/homepage.git/blob/" +
         @item[:gitrev] + ":"
     filter :css_clean_selectors, \
         preserve_comments: true, \
         preserve_hacks: true
+    snapshot :before_darkmode
+    filter :css_darkmode
     write @item.identifier.without_ext + '.css'
 end
 
+compile '/style.scss', rep: :dark do
+    filter :compiled_content, snapshot: :before_darkmode
+    filter :css_darkmode, alternate: true
+    write "/dark.css"
+end
+
+compile '/gpg/*' do
+    filter :wkd_export_armor
+    write "/pubring/#{@item.identifier.components.last}.asc"
+    write "/pubring/#{@item[:id64]}.asc" if @item[:id64]
+    write "/pubring/#{@item[:id32]}.asc" if @item[:id32]
+end
+
+compile '/gpg/*', rep: :hu do
+    if @item[:wkd_hash]
+        filter :wkd_export
+        write "/pubring/wkd/" + @item[:wkd_hash]
+    end
+end
+ignore '/*.gpg'
+
 compile '/**/*.svg' do
     filter :scour, comment_stripping: true
     write @item.identifier.to_s