[TW5] How to get the base html code and POST it to PHP server?

98 views
Skip to first unread message

sini-Kit

unread,
Apr 12, 2017, 3:52:55 PM4/12/17
to tiddl...@googlegroups.com
Hi! I want to make very simple "Publish button" in javascript.  This button  must take all wiki html code, put it to <form> and POST it to my PHP server.
How can I get wiki html code by javascript. When  I try
var html = document.documentElement.innerHTML;


 I get code of rendered by browser result but not base code.
I want to get this code $:/core/templates/tiddlywiki5.html and send it to server by form.

Tristan Kohl

unread,
Apr 13, 2017, 3:06:04 AM4/13/17
to TiddlyWiki
I do not know if I get you right, but when the file is loadad you can simply run:

var html = $tw.wiki.getTiddler("$:/core/templates/tiddlywiki5.html")

That will return a Tiddler object with the tiddlers content stored in the property "fields" -> "text"

Cheers,
Tristan

Jeremy Ruston

unread,
Apr 13, 2017, 4:48:09 AM4/13/17
to tiddl...@googlegroups.com
Hi sini-Kit

You can obtain the HTML text that would be used for saving with this snippet:

$tw.wiki.renderTiddler("text/plain","$:/core/save/all")

In terms of POSTing the wiki to a server you may want to try re-using some of the code in $:/core/modules/savers/upload.js or $:/core/modules/savers/put.js

Best wishes

Jeremy



--
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 https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/91997afc-5a69-4895-bb2e-8e17fdcc0410%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

sini-Kit

unread,
Apr 13, 2017, 1:20:57 PM4/13/17
to TiddlyWiki
Thank you Jeremy, but $tw.wiki.renderTiddler("text/plain","$:/core/save/all") put lots of \" is it possible to get this code without them?


<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />
<meta name=\"application-name\" content=\"TiddlyWiki\" />
<meta name=\"generator\" content=\"TiddlyWiki\" />
<meta name=\"tiddlywiki-version\" content=\"5.1.12\" />
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />
<meta name=\"apple-mobile-web-app-capable\" content=\"yes\" />
<meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black-translucent\" />
<meta name=\"format-detection\" content=\"telephone=no\" />
<meta name=\"copyright\" content=\"TiddlyWiki created by Jeremy Ruston, (jeremy [at] jermolene [dot] com)


I try to use http://tiddlywiki.com/#Saving%20on%20a%20PHP%20Server but it don't work with store.php on my server.




четверг, 13 апреля 2017 г., 11:48:09 UTC+3 пользователь Jeremy Ruston написал:

Jeremy Ruston

unread,
Apr 13, 2017, 1:31:25 PM4/13/17
to tiddl...@googlegroups.com
Hi sini-Kit

Thank you Jeremy, but $tw.wiki.renderTiddler("text/plain","$:/core/save/all") put lots of \" is it possible to get this code without them?

That looks like JavaScript string escaping; is that something that the console is adding for the display? I don't see that encoding in my tests.

I try to use http://tiddlywiki.com/#Saving%20on%20a%20PHP%20Server but it don't work with store.php on my server.

Well, your original request is to do something that is already done by the core, so you might want to start with the existing code.

Best wishes

Jeremy

sini-Kit

unread,
Apr 13, 2017, 1:58:37 PM4/13/17
to TiddlyWiki
Yes! It was problem with my PHP I put
$mail=get_magic_quotes_gpc()?stripslashes($mail):$mail;

and \" disappear  now I can publish my wiki by php) )

It is not possible to use store.php, because variant I have found  don't work. So I try to make the absolutely  same feature again.

четверг, 13 апреля 2017 г., 20:31:25 UTC+3 пользователь Jeremy Ruston написал:
Reply all
Reply to author
Forward
0 new messages