]> git.draconx.ca Git - homepage.git/blobdiff - Rules
Improve script hack compatibility.
[homepage.git] / Rules
diff --git a/Rules b/Rules
index f3f1f0a197c6f67c3dec7d13a593beef126cf1da..2460c14ba315339e7e4ca55479480101b97a6de1 100644 (file)
--- a/Rules
+++ b/Rules
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 preprocess do
 # 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|
     # 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
 
     rescue Errno::EINVAL
     end
 
@@ -36,6 +38,36 @@ preprocess do
             item[:gitrev] = commit if item_source(item)
         end
     end
             item[:gitrev] = commit if item_source(item)
         end
     end
+
+    @items.find_all('/weblog/*.md').each do |item|
+        item[:kind] ||= 'article'
+    end
+
+    @items.each do |item|
+        item[:created_at] ||=
+            item[:published] || File.stat(item.raw_filename).mtime
+        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
 end
 
 postprocess do
@@ -56,8 +88,11 @@ postprocess do
 
     # Register URLs for git-annex keys
     unless (uribase = ENV['ANNEX_URI_BASE'].to_s.chomp("/")).empty?
 
     # 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|
             @items.each do |item|
+                next if item.raw_filename.nil?
+
                 l = File.readlink(item.raw_filename)
                 next unless l =~ %r{/annex/objects/}
 
                 l = File.readlink(item.raw_filename)
                 next unless l =~ %r{/annex/objects/}
 
@@ -93,6 +128,17 @@ postprocess do
     end
 end
 
     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'
 compile '/license/gpl*.md' do
     filter :kramdown, auto_ids: false, header_offset: -1
     layout '/default.xml'
@@ -138,8 +184,9 @@ compile '/license/cc*.xhtml' do
 end
 
 compile '/images/*.jpg', rep: :large 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
 end
 
 compile '/images/*.jpg', rep: :info do
@@ -165,8 +212,8 @@ compile '/**/*.scss' do
 end
 
 compile '/**/*' do
 end
 
 compile '/**/*' do
-  filter :copybin if @item.binary?
-  write @item.identifier.to_s
+    filter :copybin if @item.binary?
+    write @item.identifier.to_s
 end
 
 layout '/**/*.xsl', :xsl
 end
 
 layout '/**/*.xsl', :xsl