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 tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/f31d2d90-29f6-49bc-80e6-f2d4163d10fen%40googlegroups.com.

Reply via email to