Static files configuration

219 views
Skip to first unread message

Devin Weaver

unread,
Jun 21, 2015, 9:28:40 PM6/21/15
to tiddl...@googlegroups.com
The documentation is a little sparse on this. When attempting to render static files is there a way to choose the output path/filename or is is based on the tiddlers directory structure or the tiddler titles?

PMario

unread,
Jun 22, 2015, 3:09:16 PM6/22/15
to tiddl...@googlegroups.com
IMO can be defined with the output parameter. see: http://tiddlywiki.com/#OutputCommand, http://tiddlywiki.com/#Commands

How does you command look like?

-m

Devin Weaver

unread,
Jun 22, 2015, 8:52:23 PM6/22/15
to tiddl...@googlegroups.com
I appreciate your reply but that isn't quite the question I was attempting to ask. Perhaps a little context:

When a static rendertiddler command is run (with out --output) it will save the static files to output/static/balh/blah/blah.html

The tiddler files however could have any title. So the real question is how does the rendertiddler command know what path and filename to output to? Is it the tiddler title? or the original tiddler path with .tid turned to .html?

And Finally does TiddlyWiki have a way to customize that path?

Can the file tiddlers/foo/bar.tid with a title: "baz bar froboz" be outputted to output/static/all/the/good/stuff/baz-bar-froboz.html ?

PMario

unread,
Jun 23, 2015, 5:16:34 PM6/23/15
to tiddl...@googlegroups.com
I just did build editions/tw5.com, where the tiddlers are grouped in paths. Creating the static tiddlers, didn't preserve the path structure.
I did rename About.tid to aaaaaa.tid   it was still rendered to About.html

So It uses the tiddler name inside of TW to create the .html files. There are some character substitutions eg space -> %20 and so on.

So at the moment, IMO the core doesn't know a way to create a directory structure and define the exported html names.
TW has a parameter for tiddlywiki.info

    "config": {
        "retain-original-tiddler-path": true
    }

So it should be possible to recreate the directory structure for static files, but it's not used atm.

-mario

Jeremy Ruston

unread,
Jun 25, 2015, 7:29:19 AM6/25/15
to TiddlyWiki
Hi Devin

On Tue, Jun 23, 2015 at 1:52 AM, Devin Weaver <weaver...@gmail.com> wrote:

The tiddler files however could have any title. So the real question is how does the rendertiddler command know what path and filename to output to? Is it the tiddler title? or the original tiddler path with .tid turned to .html?

The rendertiddlers command uses the URI encoded tiddler title for the filename:


I'd considered extending the mechanism with some kind of filter-based cascading rules. For example:

/tasks/$encoded-title$: [tag[Task]]
/ideas/$encoded-title$: [tag[Ideas]]
/archive/$encoded-title$: [is[tiddler]]

That example would save tiddlers tagged task to /tasks, and those tagged ideas to /ideas, with the remainder getting an /archive URL.

Best wishes

Jeremy.


 

And Finally does TiddlyWiki have a way to customize that path?

Can the file tiddlers/foo/bar.tid with a title: "baz bar froboz" be outputted to output/static/all/the/good/stuff/baz-bar-froboz.html ?

On Monday, June 22, 2015 at 3:09:16 PM UTC-4, PMario wrote:
IMO can be defined with the output parameter. see: http://tiddlywiki.com/#OutputCommand, http://tiddlywiki.com/#Commands

How does you command look like?

-m

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/97af8ea8-0184-4bd8-adeb-a21dfb880415%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Jeremy Ruston
mailto:jeremy...@gmail.com

PMario

unread,
Jun 25, 2015, 8:19:31 AM6/25/15
to tiddl...@googlegroups.com, jeremy...@gmail.com
On Thursday, June 25, 2015 at 1:29:19 PM UTC+2, Jeremy Ruston wrote:
I'd considered extending the mechanism with some kind of filter-based cascading rules. For example:

/tasks/$encoded-title$: [tag[Task]]
/ideas/$encoded-title$: [tag[Ideas]]
/archive/$encoded-title$: [is[tiddler]]

That example would save tiddlers tagged task to /tasks, and those tagged ideas to /ideas, with the remainder getting an /archive URL.

I like this idea. But what if a tiddler has 2 tags eg: Task Ideas ?
-m
 

Jeremy Ruston

unread,
Jun 25, 2015, 9:24:54 AM6/25/15
to PMario, TiddlyWiki
Hi Mario

I like this idea. But what if a tiddler has 2 tags eg: Task Ideas ?

The cascading part of the idea would be to use the first matching rule.

Best wishes

Jeremy
 
-m
 

Devin Weaver

unread,
Jun 30, 2015, 5:47:30 PM6/30/15
to tiddl...@googlegroups.com
So here is my use case and I'd like to propose a feature (obviously I would implement and send a pull request).

I have a static site blog (http://tritarget.org/) And to be honest the build is way to complicated for my liking. Jekyl kept fighting me and using metelsmith now is like a 10 minute deploy step. It's silly. None of which takes in to account JavaScript. I'm a JS developer by day. I love frameworks like Ember.JS and such. But these frameworks are not so useful as a blog because search engines can't crawl it well. Then I saw hoe tiddlywiki.com does it! Perfect a fully fledged (and I'll admit, beautiful) single page app that does everything I want including writing out tiddlers to static files. Perfect!

The gotcha: the current site already has several back links to it. Changing the names and file structure of those static HTML files would trash the current search results and break a lot of other people's links. So what I want to to recreate the site in TiddlyWiki and have my build process also render the static files but use a field to determine the outputs file/directory names. This way new content can easily be managed and created while old content can keep it's legacy paths.

I'd propose to add a feature to look at a tiddlers fields for something like "_static_path" and use that (kinda like how external images use "_cononical_url").

I'd like to work on this and would be happy to send a PR. Is it worth it for the community?

Devin Weaver

unread,
Jun 30, 2015, 9:54:32 PM6/30/15
to tiddl...@googlegroups.com
Wait this feature seems to already be there: http://tiddlywiki.com/#tv-get-export-path%20Variable

Suzanne McHale

unread,
Jun 30, 2015, 10:52:57 PM6/30/15
to tiddl...@googlegroups.com
Is there a way of writing a macro so dashes (-) are used rather than %-encoded spaces for the static site pages?

Devin Weaver

unread,
Jun 30, 2015, 11:17:11 PM6/30/15
to tiddl...@googlegroups.com
The proof is in the pudding. Huzah!

/*\
title: $:/core/macros/tv-get-export-path
type: application/javascript
module-type: macro

Customize the static output.
\*/

(function() {

 
/*jshint node: true, browser: true, sub: true */
 
/*global $tw: false */
 
"use strict";

  exports
.name = "tv-get-export-path";

  exports
.params = [{name: "title"}];

  exports
.run = function(title) {
   
// A falsey return value means use the default path.
   
return $tw.wiki.getTiddler(title).fields["_static_path"];
 
};

})();

Devin Weaver

unread,
Jun 30, 2015, 11:20:53 PM6/30/15
to tiddl...@googlegroups.com
Yes, try adding this as a tiddler:

/*\
title: $:/core/macros/tv-get-export-
path
type: application/javascript
module-type: macro

Customize the static output.
\*/

(function() {


 
/*jshint node: true, browser: true */

 
/*global $tw: false */
 
"use strict";

  exports
.name = "tv-get-export-path";

  exports
.params = [{name: "title"}];

  exports
.run = function(title) {

   
return encodeURIComponent(title.replace(/\s/g, "-"));
 
};

})();
Reply all
Reply to author
Forward
0 new messages