I absolutely love tw-receiver it is so incredibly useful. This looks
really interesting I will definitely give it a try. There are so many php
enabled hosts out there I hope folks will look further into this method of
hosting and saving as they look for alternatives to tiddlyspot.
On Friday, November 20, 2020 at 8:59:08 AM UTC-5 Anjar wrote:
> Hi all,
>
> I know there has been some discussions on how to manage to have both
> public and private tiddlers, so here is my take on the problem:
>
> If we use tw-receiver as the saving mechanism, we can post-process the
> html file after saving with PHP. The most brutal form would be to simply add
>
> // make a public version
> $doc = new DOMDocument();
> $doc->loadHTML(file_get_contents($destinationfile));
> $selector = new DOMXPath($doc);
>
> // search for private tiddlers
> $result = $selector->query('//div[contains(@tags, "Private")]');
>
> // loop through all private tiddlers
> $titletext = array();
> foreach($result as $item) {
> $titletext[] = $item->getAttribute("title"); //save the title
> for later
> $item->parentNode->removeChild($item); // remove the tiddler
> }
> $str_doc = $doc->saveHTML(); // convert to string
> $str_doc = str_replace($titletext, '%%%', $str_doc); // remove all
> mentions of the private tiddler
> $doc->loadHTML($str_doc); //convert back
> $doc->saveHTMLFile("./public.html"); // save public version
>
> to tw-receiver-server.php (see https://github.com/andjar/tw-receiver).
> This would create a third output file called public.html and remove all the
> tiddlers tagged with Private and also replace all mentions of it with %%%
> (tags, text, links, field etc.). I will try to refine it so that a private
> tiddler called "link" would not mess up all the html link attributes and so
> on. Maybe it would be enough to replace in-text links only (and the
> occurence in the tiddler list in the beginning of the html)?
>
> So one can have an admin wiki protected by basic http auth with drafts and
> so on, and each time one saves, the public version is updated as well. Then
> it may be useful to have the tw-receiver password hard coded so that one
> authentication is enough
>
> Best,
> Anders
>
--
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/a0a2e4e5-c60d-4568-a6fb-874fe02598fcn%40googlegroups.com.