I am doing some experiments with JBake (used in a maven Build). I am really happy with my first results. My blog isn’t published online yet, but I am playing with the jbake-sample project (see what I have done on my fork: https://github.com/jmini/jbake-sample)
I would like to propose a “View post source on GitHub” link on each post page. For that I need to know the relative path within the repository (relative to the root of the repository).
I was’nt able to figure out all the possibility of the content variable: ${content.xxxxx}. To reverse engineer I have use the keys built in function of Freemarker and I have replaced the content of post.ftl with this:
<#include "header.ftl">
<#include "menu.ftl">
<ul>
<#assign keys = content?keys>
<#list keys as key>
<li>${key}</li>
</#list>
</ul>
<#include "footer.ftl">
For this page:
http://jmini.github.io/jbake-sample/blog/2013/third-post.html
${content.uri} is for
the output document:
blog/2013/third-post.html
${content.file} is
interesting, but it correspond to the file on my machine: (on windows):
C:\******\jbake-sample\src\main\jbake\content\blog\2013\third-post.adoc
I think I could replace all backslashes with slashes, but I wonder how I can eliminate the path to the repository ( C:\******\jbake-sample in this example, that I should replace with https://github.com/jmini/jbake-sample/blob/master/).
Thank you for your help.
<%
def urlsrc = content.file
def i = urlsrc.indexOf('jbake-sample')
urlsrc = "https://github.com/jmini/jbake-sample/tree/master" + urlsrc.substring(i + 12).replaceAll('\\\\','/')
%>
<a href="${urlsrc}">Post source on GitHub</a>
--
You received this message because you are subscribed to the Google Groups "JBake Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jbake-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.