]> git.draconx.ca Git - homepage.git/commitdiff
Improve source references for binary items.
authorNick Bowler <nbowler@draconx.ca>
Fri, 26 Jun 2020 04:11:38 +0000 (00:11 -0400)
committerNick Bowler <nbowler@draconx.ca>
Fri, 26 Jun 2020 04:11:38 +0000 (00:11 -0400)
Since we binary items are probably annexed it is not particularly
helpful to provide direct links to the symlink in the repository,
as this contains basically zero helpful information.

Instead, let's link to the metadata file when available as that should
at least contain _something_ interesting.

lib/helpers.rb

index 742507580cabdf2f1e5e59c63cd12084d0d231a7..acaa61289dd8352c66d6e1273773ef83c78eb893 100644 (file)
@@ -35,12 +35,10 @@ end
 
 def item_source(item = @item)
     filename = "content" + item.identifier
+    filebase = filename.chomp(File.extname(filename))
 
-    if File.file? filename then
-        return filename
-    end
-
-    return nil
+    [ if item.binary? then filebase + ".yaml" end,
+      filename].compact.find { |f| File.file? f }
 end
 
 def item_uri(item = @item, rep: :default)