]> git.draconx.ca Git - homepage.git/blobdiff - Rules
Improve script hack compatibility.
[homepage.git] / Rules
diff --git a/Rules b/Rules
index a881607f9b3211cd296780c97a8bdf4678883a61..2460c14ba315339e7e4ca55479480101b97a6de1 100644 (file)
--- a/Rules
+++ b/Rules
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 preprocess do
+    system("git", "submodule", "update", "--init")
+
     # 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/}
+        l = File.readlink(item.raw_filename)
+        true if !File.exists?(item.raw_filename) and l =~ %r{/annex/objects/}
     rescue Errno::EINVAL
     end
 
@@ -47,6 +49,25 @@ preprocess do
         item[:updated_at] ||=
             item[:updated] || File.stat(item.raw_filename).mtime
     end
+
+    archivedirs = {}
+    @items.find_all('/archive/**/*').each do |item|
+        dir = File.dirname(item.identifier)
+        while dir != "/"
+            archivedirs[dir] = true
+            dir = File.dirname(dir)
+        end
+    end
+
+    archivedirs.keys.sort_by{ |s| -s.length }.each do |dir|
+        attrs = {
+            pattern: "#{dir}/*{,/index.lst}",
+            title: "Index of #{dir}",
+            gitrev: commit,
+        }
+
+        @items.create("", attrs, "#{dir}/index.lst")
+    end
 end
 
 postprocess do
@@ -67,8 +88,11 @@ postprocess do
 
     # Register URLs for git-annex keys
     unless (uribase = ENV['ANNEX_URI_BASE'].to_s.chomp("/")).empty?
-        Open3.popen2("git", "annex", "registerurl") do |stdin, stdout, result|
+        Open3.popen2("git", "-c", "core.bare=false", "annex", "registerurl") do
+        |stdin, stdout, result|
             @items.each do |item|
+                next if item.raw_filename.nil?
+
                 l = File.readlink(item.raw_filename)
                 next unless l =~ %r{/annex/objects/}
 
@@ -104,6 +128,17 @@ postprocess do
     end
 end
 
+compile '/**/index.lst' do
+    layout '/listing.xhtml'
+    filter :erb
+    layout '/default.xml'
+    layout '/default.xsl'
+    filter :relativize_paths, type: :xml
+    filter :xhtml_compat
+    filter :remove_wj
+    write item.identifier.without_ext + ".xhtml"
+end
+
 compile '/license/gpl*.md' do
     filter :kramdown, auto_ids: false, header_offset: -1
     layout '/default.xml'
@@ -149,8 +184,9 @@ compile '/license/cc*.xhtml' do
 end
 
 compile '/images/*.jpg', rep: :large do
-    filter :imgresize, width: 1200, height: 1200
-    write item.identifier.without_ext + '-t1200.' + item.identifier.ext
+    filename = item.identifier.without_ext + '-t1200.' + item.identifier.ext
+    filter :imgresize, width: 1200, height: 1200, cache: filename
+    write filename
 end
 
 compile '/images/*.jpg', rep: :info do