Oh, sorry about that. I had another tiddler generate the html file. Here is
everything in one file, I am also adding it to the plugin development repo.
The formatting for the html file output isn't great, but it should work:
\define makeHTML(json)
`
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="application-name" content="TiddlyWiki Plugin Library" />
<meta name="application-version" content="v0.0.0" />
<meta name="copyright" content="Copyright 2015 Jeremy Ruston" />
<link id="faviconLink" rel="shortcut icon" href="favicon.ico">
<title>Plugin Library</title>
<script>
var assetList = $(JSONLISTING)$
/*\
title: $:/plugins/tiddlywiki/pluginlibrary/libraryserver.js
type: application/javascript
module-type: library
A simple HTTP-over-window.postMessage implementation of a standard
TiddlyWeb-compatible server. It uses real HTTP to load the individual
tiddler JSON files.
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
// Listen for window messages
window.addEventListener("message",function listener(event){
console.log("plugin library: Received message from",event.origin);
console.log("plugin library: Message content",event.data);
switch(event.data.verb) {
case "GET":
if(event.data.url === "recipes/library/tiddlers.json") {
// Route for recipes/library/tiddlers.json
event.source.postMessage({
verb: "GET-RESPONSE",
status: "200",
cookies: event.data.cookies,
url: event.data.url,
type: "application/json",
body: JSON.stringify(assetList,null,4)
},"*");
} else if(event.data.url.indexOf("recipes/library/tiddlers/") === 0) {
var url = "recipes/library/tiddlers/" +
encodeURIComponent(removePrefix(event.data.url,"recipes/library/tiddlers/"));
// Route for recipes/library/tiddlers/<uri-encoded-tiddler-title>.json
httpGet(url,function(err,responseText) {
if(err) {
event.source.postMessage({
verb: "GET-RESPONSE",
status: "404",
cookies: event.data.cookies,
url: event.data.url,
type: "text/plain",
body: "Not found"
},"*");
} else {
event.source.postMessage({
verb: "GET-RESPONSE",
status: "200",
cookies: event.data.cookies,
url: event.data.url,
type: "application/json",
body: responseText
},"*");
}
});
} else {
event.source.postMessage({
verb: "GET-RESPONSE",
status: "404",
cookies: event.data.cookies,
url: event.data.url,
type: "text/plain",
body: "Not found"
},"*");
}
break;
}
},false);
// Helper to remove string prefixes
function removePrefix(string,prefix) {
if(string.indexOf(prefix) === 0) {
return string.substr(prefix.length);
} else {
return string;
}
}
// Helper for HTTP GET
function httpGet(url,callback) {
var http = new XMLHttpRequest();
http.open("GET",url,true);
http.onreadystatechange = function() {
if(http.readyState == 4 && http.status == 200) {
callback(null,http.responseText);
}
};
http.send();
}
})();
</script>
</head>
<body>
<h1>HelloThere</h1>
<p>This is the TiddlyWiki plugin library. It is not intended to be opened
directly in the browser.</p>
<p>See <a href="https://tiddlywiki.com/"
target="_blank">https://tiddlywiki.com/</a> for details of how to install
plugins.</p>
</body>
</html>
`
\end
\define oneTiddler()
<$list
filter='[<theTiddler>fields[]] -text +[bl[]]'
>
<br>
"<$view field='title' jsencoded/>": "<$view
tiddler=<<theTiddler>> field=<<currentTiddler>> format=jsencoded/>",
</$list>
<$list
filter='[<theTiddler>fields[]] -text +[bl[]]'
>
<br>
"<$view field='title' jsencoded/>": "<$view
tiddler=<<theTiddler>> field=<<currentTiddler>> format=jsencoded/>"
</$list>
\end
\define jsonListing()
[<br>
<$list
filter='[subfilter{$:/state/PluginLibrary!!filter}] +[bl[]]'
variable=theTiddler
>
{
<<oneTiddler>>
<br>
},
<br>
</$list>
<$list
filter='[subfilter{$:/state/PluginLibrary!!filter}] +[last[]]'
variable=theTiddler
>
{
<<oneTiddler>>
<br>
}
<br>
</$list>
]
\end
This packages the plugins returned by this filter into the format needed by
a plugin library.
The file structure needs to be:
*Library Folder
** recipes
*** library
**** tiddlers
***** //individual tiddler json files//
**** tiddlers.json
** index.html
filter: <$edit-text tiddler='$:/state/PluginLibrary' field=filter/>
!! tiddlers.json
''filename:'' tiddlers.json
''contents:''
<<jsonListing>>
!! Tiddler JSON files:
<$list filter={{$:/state/PluginLibrary!!filter}}>
---
''filename:'' <$view field='title' format='urlencoded'/>.json
''contents:''
<$text text=<<jsontiddler>>/>
</$list>
---
''filename:'' index.html
''contents:''
<$wikify name=JSONLISTING text=<<jsonListing>>>
<pre>
<<makeHTML>>
</pre>
</$wikify>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/648ee829-7bf8-49b0-abcc-fa3d0214b637%40googlegroups.com.