# 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'
max-width: 50em;
}
+#footer {
+ border-top: 1px solid lightgray;
+ max-width: 50em;
+ margin: 0;
+ padding: 0;
+}
+
+#footer>p {
+ text-align: center;
+ font-size: 0.9em;
+ max-width: none;
+}
+
@media (max-width: 512px) {
- p { text-align: left; }
+ p, #footer>p { text-align: left; }
}
-->
<document>
<title><%= @item[:title] %></title>
+ <source>
+ <file><%= item_source(@item) %></file>
+ <revision><%= item.fetch(:gitrev) %></revision>
+ <compiletime><%=
+ Time.now.gmtime.strftime "%Y-%m-%d %H:%M UTC"
+ %></compiletime>
+ </source>
<html xmlns="http://www.w3.org/1999/xhtml">
<h1><%= @item.fetch(:header, @item[:title]) %></h1>
<%= yield() %>
doctype-system='http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd' />
<xsl:strip-space elements='*' />
+<xsl:param name='source-uri'
+ select='"//git.draconx.ca/gitweb/homepage.git/blob/"' />
<xsl:param name='site-title' select='"The Citrine Citadel"' />
<xsl:template match='node()|@*'>
<xsl:copy><xsl:apply-templates select='node()|@*' /></xsl:copy>
</xsl:template>
+<xsl:template match='source'>
+ <p>
+ <xsl:text>This document was compiled from </xsl:text>
+ <a href='{concat($source-uri, revision, ":", file)}'>
+ <xsl:value-of select='file' />
+ </a>
+ <xsl:text> on </xsl:text>
+ <xsl:value-of select='compiletime' />
+ <xsl:text>.</xsl:text>
+ </p>
+</xsl:template>
+
<xsl:template match='/'>
<html>
<head>
<body>
<xsl:apply-templates select='/document/xhtml:html/@*' />
<xsl:apply-templates select='/document/xhtml:html/node()' />
+
+ <div id='footer'>
+ <xsl:apply-templates select='/document/source' />
+ </div>
</body>
</html>
</xsl:template>
return ret.gsub(/\/+/, "/")
end
+
+def item_source(item = @item)
+ filename = "content" + item.identifier
+
+ if File.file? filename then
+ return filename
+ end
+
+ return nil
+end