publication of html from Tiddlywiki with templates

48 views
Skip to first unread message

ian

unread,
Jun 23, 2008, 10:54:47 AM6/23/08
to TiddlyWiki
Hi,
I know this topic has been discussed in the past, I'm just summarizing
my limited experiences for anyone interested, or with comments on how
they have handled this task. My wife volunteers to maintain a very
simple non profit web site (header an footer, and a handful of content
pages that change frequently), and my initial solution was to give her
my favorite text editor, but after viewing some of her struggles I
thought wiki syntax (or possibly inclusion of one of the several
wysiwyg plugins) would be a more productive path for her.

I'll note, one of the difficulties (an benefits) of Tiddlywiki is the
number of plugins with overlap, it requires some time from the user to
investigate what is the optimal solution for their problem. My
understanding is that there are three plugins suitable for html
publication:


1. http://www.tiddlytools.com/#SnapshotPluginInfo
This is a nice plugin, an it comes with a print command too, but the
html it produced was not ideal for my needs, and it did not appear to
be easily templated.
*also, does not have ability to export based on tag, but this could
easily be added - it uses the story function to export all open
tiddlers though - which may be preferential for some use cases
*there is more control over what is exported from the tiddlywiki with
this plugin (based on DOM id, etc.), but all I need is the tiddler
content, and maybe the title of the tiddler as the page name, and this
is already handled nicely by the PublishMacro - this plugin requests a
filename each time you save too which seems bothersome and prone to
errors when maintaining the url space between the different pages
(e.g. what did I call the link to this page again?), compared to the
default (TiddlerTitle) used by the PublishMacro


2. http://jackparke.googlepages.com/jtw.html#PublishMacro
This is my current choice, since it has easy to modify templates. She
can publish all the pages based on tag, or an individual page.

3. http://www.tiddlywiki.org/wiki/TiddlyTemplating
This seems to be the most flexible, and I certainly like the idea of
publishing to multiple formats as this is a goal I have for another
project I am interested to apply Tiddlywiki. However, it did not pass
the ten minute test, there are several plugins associated with this
package and I did not invest the time to get my hands around
everything happening. I did look at the iwab demo (I believe this is
the only html example), but again the other two plugins seemed simpler
to get me where I needed to be.

okay, I do not believe any are what most people are looking for when
maintaining a simple static site - e.g. both plugins handle
TiddlyLinks in a less than optimal way, but the PublishMacro is still
the better of the two, but if you have a wiki word (camelcase) in your
content it will assume there is a link there an write an href in the
html

to illustrate the differences, here is the simple test case I ran,
using the default plugin setup, keeping in mind the PublishMacro has
templates that seem very easy to modify (although I haven't tried
yet):

My Tiddler content - for atiddler name qwert
------------------------------------
foo

PublisherTest1
PublisherTest2
PublisherTest3 (this tiddler does not actually exist)


PublishMacro Output
-------------------------------
<html>
<head>
<title> - qwert</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
<meta name="keywords" content=""/>
</head>
<body>
<h1></h1>
<h2>qwert</h2>
foo<br><br><a class="externalLink"
href="publishertest1.html">PublisherTest1</a><br><a
class="externalLink" href="publishertest2.html">PublisherTest2</
a><br><a class="externalLink"
href="publishertest3.html">PublisherTest3</a>
<hr>Tags:
<hr>IanW, Sunday, June 22, 2008 8:27:30 PM&nbsp;(created Sunday, June
22, 2008 8:17:26 PM)
</body>
</html>

SnapshotPlugin Output
----------------------------------
<html><head>
</head><body>

<div class='tiddler viewer'>foo<br><br><a tiddlylink="PublisherTest1"
refresh="link" class="tiddlyLink tiddlyLinkExisting"
title="PublisherTest1 - IanW, Monday, June 16, 2008 2:58:00 PM"
href="javascript:;">PublisherTest1</a><br><a
tiddlylink="PublisherTest2" refresh="link" class="tiddlyLink
tiddlyLinkExisting" title="PublisherTest2 - IanW, Sunday, June 22,
2008 7:58:00 PM" href="javascript:;">PublisherTest2</a><br><a
tiddlylink="PublisherTest3" refresh="link" class="tiddlyLink
tiddlyLinkNonExisting" title="The tiddler 'PublisherTest3' doesn't yet
exist" href="javascript:;">PublisherTest3</a></div>

</body>
</html>


Hopefully a listing of my brief experience is helpful to someone else.
Of course, I'm also curious to here anyone's comments or solutions
they applied, since it seems like a common use case.

Since this is my first post, I also want to thank everyone for a
useful piece of software. Like many people, I see Tiddlywiki as a nice
client api, that has potential to become much more.

ian w.

FND

unread,
Jun 25, 2008, 5:47:28 AM6/25/08
to Tiddl...@googlegroups.com
> I know this topic has been discussed in the past, I'm just summarizing
> my limited experiences for anyone interested

Thanks for that, Ian!
It would be great to have this on the community wiki - so I've created a
page with your summary:
http://www.tiddlywiki.org/wiki/How_To/HTML_Publication
Feel free to improve upon that.

With regards to TiddlyTemplating, it is indeed a bit hard to grasp.
Hopefully that will change soon.


-- F.

ian

unread,
Jun 25, 2008, 4:55:36 PM6/25/08
to TiddlyWiki
Thanks FND!

I will update here and on the wiki with any new information. I will
try to post a condensed version of the tiddlywiki I am working on for
others to use too. For the editing functions, I am making good use of
Eric's preview and quickedit plugins - my wife seemed happy with how
condensed I was able to make her editing experience in wiki syntax
relative to the messy FrontPage code (generated by the previous
maintainer) she was working from in notepad++.

I am using Eric's ImageSize plugin too, although I'm not sure this is
needed since it seems I could just use an appropriate css designation
to scale images, and then access this style from the QuickEdit bar -
but I had some issues with applying external stylesheets from this
plugin. The stylesheet used to publish a tiddler by the various
plugins is the default TW StyleSheet, it would be nice to select a
stylesheet when publishing the html, or perhaps from within the
QuickEdit bar. I tried creating a publisher_stylesheet and then
referencing through the quickedit toolbar, but have not had success
yet - it seems you also have to modify the toolbar code each time you
want to reference a new style from it. Perhaps I am missing something
though. So from the format toolbar, maybe an 'add new format' option
in the dropdown, or a separate dropdown referencing some other
stylesheet based on the tag of a document.

I had some problems with image references too, since I would like to
sync the publish/* directory output with the server where the site is
hosted from (perhaps using LaunchApplication plugin an rsync or one of
the php wrappers being developed by various people in this community).
My images directory for the site is below publish/ so I suspect I will
need to apply Eric's relative image path plugin (unsure why such a
plugin does not apply to every referenced relative path in a tiddler
though e.g. pdf).

Anyway, still a ways off from a solution I am happy with.

I am eager to see how TiddlyTemplating progresses, as it seems to have
a lot of potential.

BTW, I am using your MasterIncludes plugin too - the only annoyance
I've found is that the html entity codes do not seem to propagate
through the include - so, a drop down arrow shows as "a3/4", etc.. Am
I missing a quick solution to this problem? I had planned to replace
codes with images, as a work around.

Eric, if you any comments, since I am using several of your plugins, I
would be grateful for the insight. Either way, thank you for a useful
collection of plugins.

ian

FND

unread,
Jun 26, 2008, 7:28:33 AM6/26/08
to Tiddl...@googlegroups.com
> I am using your MasterIncludes plugin too - the only annoyance
> I've found is that the html entity codes do not seem to propagate
> through the include - so, a drop down arrow shows as "a3/4", etc.

Unfortunately, I haven't been able to look into the MIP for months. I
think there was some kind of unicode issue, but I don't remember.
So I'm afraid I can't offer you a solution, and it will probably be a
while before I'll start working on the MIP again.


-- F.

jayfresh

unread,
Jul 3, 2008, 10:46:24 AM7/3/08
to TiddlyWiki
Ian,

Great that you looked at TiddlyTemplating! I get you that it's a *bit*
tricky to understand the first time you see it. I'd really appreciate
it if you'd explain what's in your "ten minute test", as I'd love to
make TiddlyTemplating instantly graspable...


J.

On Jun 25, 9:55 pm, ian <lister...@gmail.com> wrote:
> Thanks FND!
>
> I will update here and on the wiki with any new information. I will
> try to post a condensed version of thetiddlywikiI am working on for
> others to use too. For the editing functions, I am making good use of
> Eric's preview and quickedit plugins - my wife seemed happy with how
> condensed I was able to make her editing experience in wiki syntax
> relative to the messy FrontPage code (generated by the previous
> maintainer) she was working from in notepad++.
>
> I am using Eric's ImageSize plugin too, although I'm not sure this is
> needed since it seems I could just use an appropriate css designation
> to scale images, and then access this style from the QuickEdit bar -
> but I had some issues with applying external stylesheets from this
> plugin. The stylesheet used to publish a tiddler by the various
> plugins is the default TW StyleSheet, it would be nice to select a
> stylesheet when publishing thehtml, or perhaps from within the
> QuickEdit bar. I tried creating a publisher_stylesheet and then
> referencing through the quickedit toolbar, but have not had success
> yet - it seems you also have to modify the toolbar code each time you
> want to reference a new style from it. Perhaps I am missing something
> though. So from the format toolbar, maybe an 'add new format' option
> in the dropdown, or a separate dropdown referencing some other
> stylesheet based on the tag of a document.
>
> I had some problems with image references too, since I would like to
> sync the publish/* directory output with the server where the site is
> hosted from (perhaps using LaunchApplication plugin an rsync or one of
> the php wrappers being developed by various people in this community).
> My images directory for the site is below publish/ so I suspect I will
> need to apply Eric's relative image path plugin (unsure why such a
> plugin does not apply to every referenced relative path in a tiddler
> though e.g. pdf).
>
> Anyway, still a ways off from a solution I am happy with.
>
> I am eager to see how TiddlyTemplating progresses, as it seems to have
> a lot of potential.
>
> BTW, I am using your MasterIncludes plugin too - the only annoyance
> I've found is that thehtmlentity codes do not seem to propagate

ian

unread,
Jul 3, 2008, 3:09:43 PM7/3/08
to TiddlyWiki
Hi Jay,
It seemed this package was abstracted into more plugin parts, and this
was likely why I thought it was more complex than it seems now. My
need at the moment was just a simple HTML export and the other two
plugins were a single systemConfig tiddler with a single command added
to the editbar <<publishTiddler>>

I just quickly reviewed this demo to better understand
TiddlyTemplating:
http://jonny.jonathan.googlepages.com/TiddlyTemplating.html

let me know if I am understanding correctly:

these are the plugins:
http://jonny.jonathan.googlepages.com/TiddlyTemplating.html#TemplateFormatterPlugin
this option seems helpful: <!--@@comment@@-->> : a comment that is not
included in the output (can be used to document the template itself)

http://jonny.jonathan.googlepages.com/TiddlyTemplating.html#RssSavingPlugin
for saving RSS content

http://jonny.jonathan.googlepages.com/TiddlyTemplating.html#TiddlyTemplatingPlugin
this plugin publishes a single tiddler through a template

http://jonny.jonathan.googlepages.com/TiddlyTemplating.html#TemplatePlugin
this plugin publishes multiple tiddlers through a template

http://jonny.jonathan.googlepages.com/TiddlyTemplating.html#HtmlPagePostTemplate
This post template makes sense to me - since I can see the parameters
inline, it is nice the parameters are named instead of having to
remember mappings
e.g in PublishMacro %2 references viewer contents, %1 the title

I think this page also threw me at the time:
http://jonny.jonathan.googlepages.com/TiddlyTemplating.html#HtmlPageTemplate
since it is very large and I didn't see this reference in the
template:
<<ListTemplate filter:[tag[post]] template:HtmlPagePostTemplate>>
I understand what you are doing now, but you might want to include a
simpler html example for people new to the plugin - for whatever
reason, I found TiddlyTemplating hard to follow when I first glanced
it over.

to understand how I used the PublishMacro:

I templated the html I inherited as:
<title>my title</title>
<!— css is exported from Tiddlywiki>
<link rel="stylesheet" type="text/css" href="style.css"/>
<meta name="keywords" content="some keywords">
<body><DIV align=center>
<TABLE cellSpacing=0 cellPadding=0 width=750 border=0>
<TBODY>
<TR>
<TD>
[[MyMenubarText]]
%2
</TD>
</TR>
<TR>
<TD>
[[MyFooterText]]
</TD></TR></TBODY></TABLE></DIV></body>
<!— comment generated with user and pubish time %4, %5>

The Tiddler Title (%1 parameter) is applied as the default filename
when the macro publishes, so I don't set this.
With your plugin I believe this is the command: <<TiddlyTemplating
blogpage.html HtmlPageTemplate>>
Question: can the saved filename be parameterized with the tiddler
title, or a custom field in the tiddler storing a page alias?

Also, is the generated html scrubbed of some of the less desirable TW
specific markup?
e.g. the html comparison further up in this thread, and the linking
issue discussed here: via http://groups.google.com/group/TiddlyWiki/browse_thread/thread/7ef69292c20bec0e/

I also use the ForEach macro in one of my tiddlers to aggregate data
from several forms to publish a sorted list of animals for adoption.
I'm assuming this would still work fine.

I'll have need for import/export of csv and possibly rdf data in the
future and will invest more time in TiddlyTemplating at this point.

ian

Jonathan Lister

unread,
Jul 9, 2008, 11:10:57 AM7/9/08
to Tiddl...@googlegroups.com
Hi Ian,

Thanks for providing such detailed feedback. I can see that I have a long way to go before TiddlyTemplating becomes really easy to understand.

In that vein, I've tried to clean up what is there at the moment and I'm making an effort to get the plugins consolidated into what's required for the basics vs. what's required for the more advanced use cases.

I've reworked a lot of the documentation on TiddlyWiki.org and I hope that is helpful to you. There are lots of examples for the various use cases.


Let me know if that makes more sense,


J.

ian

unread,
Jul 9, 2008, 2:14:50 PM7/9/08
to TiddlyWiki
Hi J,

Thanks, the documentation updates were helpful. Sorry, I got your name
wrong as 'Jay' in my last post.

I noticed you have a recent thread on the Dev list:
http://groups.google.com/group/TiddlyWikiDev/browse_thread/thread/6726c2b16eb138f0/
I can continue discussion there but I just joined the Dev list
yesterday, so I'm still awaiting approval to post messages. Until
then, I'll continue here.
From this message, I understand your plugin package will move into
core - this change will allow consolidation of several export
functions and resulting in a smaller footprint.
So, I'd love to understand it better - and determine how it would work
for my TW file - hopefully it's also helpful for you to understand the
various uses people will have in mind when applying TiddlyTemplating

Some comments:
-----
1. In Jack's latest plugin update, I found the listing of parameters
available to templates helpful - a list of the parameters distilled by
TiddlyTemplating would be appreciated by the template developer.
http://jackparke.googlepages.com/jtw.html#PublishMacro

!Template placeholders
|!Placeholder|!Meaning|
|%0|Your SiteTitle "<<tiddler SiteTitle>>"|
|%1|The current tiddler title|
|%2|The rendered tiddler HTML|
|%3|CSV list of tags|
|%4|Tiddler modifier|
|%5|Tiddler modified date|
|%6|Tiddler creation date|
|%7|Tiddler wiki text|

-----
2. parameterization of the saved filename will likely be needed - e.g.
backup files, link managegment of multiple html pages
I believe this is the function you call:

var defaultFileName=output.txt
TiddlyTemplating.getFileName = function(p)
{
var filename = getParam(p,"filename");
if(!filename) {
filename = this.defaultFileName;
}
};

*Is a macro needed that handles parameter substitution for filename?
e.g. a template parameter, such as the list referenced in item 1

-----
3. it was not clear to me how output is formatted to handle link
rewriting, etc..
Would I add this logic in the new macro referenced above?

I believe the relevant bit of code from Jack's plugin, that gets me to
a format I am happy with, is this regex set:

// Convert wikified text to html
function wiki2Web(wikiHTML) {
var regexpLinks = /<a[^>]+tiddlylink\s*=\s*["']?\s*?([^ "'>]*)\s*["']?
[^>]*>[^<]+<\/a>/img;
var result = wikiHTML.match(regexpLinks);
if (result) {
for (i = 0; i < result.length; i++) {
var className = result[i].match(/ class="(.*?)"/i) ?
result[i].match(/ class="(.*?)"/i)[1] : "";
var tiddlerName = result[i].match(/ tiddlylink="(.*?)"/i)[1];
var url = tiddlerName.htmlDecode().filenameEncode() + ".html";

var tiddlerLabel = result[i].match(/">(.*?)<\/a>/i)[1];

if (!className.match(/tiddlyLinkNonExisting/i))
wikiHTML = wikiHTML.myReplace(result[i], "<a class=\"" + className
+ "\" href=\"" + url + "\">" + tiddlerLabel + "</a>");
else
wikiHTML = wikiHTML.myReplace(result[i], "<a class=\"" + className
+ "\" title=\"Page does not exist\" href=\"#\">" + tiddlerName + "</
a>");

}
wikiHTML = wikiHTML.replace(/ href="http:\/\//gi, " target=\"_blank
\" href=\"http://");

}
return wikiHTML

}

ian

jnthnlstr

unread,
Jul 14, 2008, 4:37:20 AM7/14/08
to TiddlyWiki
Ian,

Thanks for the feedback. I've tried to address your comments below.

> 1. In Jack's latest plugin update, I found the listing of parameters
> available to templates helpful - a list of the parameters distilled by
> TiddlyTemplating would be appreciated by the template developer.http://jackparke.googlepages.com/jtw.html#PublishMacro

I made a choice not to push in default parameters to a template,
instead leaving it up to the template author to use macros such as
'<<view text>>', '<<view modified>>', to substitute data from a
tiddler.

> 2. parameterization of the saved filename will likely be needed - e.g.
> backup files, link managegment of multiple html pages
> I believe this is the function you call:

This is a good point. Currently, the core code that I have suggested
through Trac ticket #700 (http://trac.tiddlywiki.org/ticket/700)
doesn't include the "TiddlyTemplating" macro, which I have used in the
past to do actual publishing. This macro is still immature, and the
recent effort has gone into creating a solid set of core functions
that other macros can build upon to provide publishing abilities.

Sorry if that sounds like I'm sidestepping the problem, but publishing
(i.e. the saving of files) and templating are distinct, so I'm taking
templating first.

> 3. it was not clear to me how output is formatted to handle link
> rewriting, etc..
> Would I add this logic in the new macro referenced above?
>
> I believe the relevant bit of code from Jack's plugin, that gets me to
> a format I am happy with, is this regex set:

I haven't really addressed this, so thanks for that piece of code, I'm
sure it will be useful when I do!



J.

ian

unread,
Jul 14, 2008, 12:29:28 PM7/14/08
to TiddlyWiki
J,

> I made a choice not to push in default parameters to a template,
> instead leaving it up to the template author to use macros such as
> '<<view text>>', '<<view modified>>', to substitute data from a
> tiddler.

I understand now, I should have looked closer at the code - the macro
call approach is simpler.

> This is a good point. Currently, the core code that I have suggested
> through Trac ticket #700 (http://trac.tiddlywiki.org/ticket/700)
> doesn't include the "TiddlyTemplating" macro, which I have used in the
> past to do actual publishing. This macro is still immature, and the
> recent effort has gone into creating a solid set of core functions
> that other macros can build upon to provide publishing abilities.
>
> Sorry if that sounds like I'm sidestepping the problem, but publishing
> (i.e. the saving of files) and templating are distinct, so I'm taking
> templating first.

No, I understand - I look forward to seeing the TiddlyTemplatingMacro
development, since it seems this will evolve the various publishing
plugins into a simpler set of abstractions.

Thanks for the explanations!

ian


Reply all
Reply to author
Forward
0 new messages