]> git.draconx.ca Git - homepage.git/blobdiff - Rules
Add links from generated pages to source code on gitweb.
[homepage.git] / Rules
diff --git a/Rules b/Rules
index 547a0a9dd340c32fd19c6ee58d7671c1febcee28..477d46dabc28c5c605813a4d700b70b14399a1a7 100644 (file)
--- a/Rules
+++ b/Rules
 # 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
+        if result.value.success? then commit = val.chomp end
+    end
+
+    if commit then
+        @items.each do |item|
+            if item_source(item) then
+                item[:gitrev] = commit
+            end
+        end
+    end
+end
+
 compile '/**/*.md' do
     filter :kramdown, header_offset: 1
     layout '/default.xml'