[rkward] doc/rkwardplugins: Update custom preview example. HTML previews have dedicated support, anyway, now.

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Wed Jan 13 14:47:01 UTC 2016


Git commit 1cee395b77225bf813c41b6ec716e20b72492630 by Thomas Friedrichsmeier.
Committed on 13/01/2016 at 14:46.
Pushed by tfry into branch 'master'.

Update custom preview example. HTML previews have dedicated support, anyway, now.

M  +11   -10   doc/rkwardplugins/index.docbook

http://commits.kde.org/rkward/1cee395b77225bf813c41b6ec716e20b72492630

diff --git a/doc/rkwardplugins/index.docbook b/doc/rkwardplugins/index.docbook
index ee0ff69..bb5a9bf 100644
--- a/doc/rkwardplugins/index.docbook
+++ b/doc/rkwardplugins/index.docbook
@@ -1552,21 +1552,22 @@ This chapter contains information on some topics that are useful only to certain
 			The <command><preview></command> element can be used to create previews for any type of "document" window that can be attached to &kapp;'s workplace. In addition to <link linkend="preview_plots">plots</link> and <link linkend="preview_data">data windows</link>, this includes HTML files, R scripts, and object summary windows. For the latter ones, you will have to use <command><preview mode="custom"></command>.
 		</para>
 		<para>
-			If you have read the sections describing plot preview and data previews, you should have a general idea on the procedure, but "custom" previews require slightly more manual work behind the scenes. The most important R function to look at is <command>rk.assign.preview.data()</command>, here. The following short listing shows what your generated (preview) R code could look like:
+			If you have read the sections describing plot preview and data previews, you should have a general idea on the procedure, but "custom" previews require slightly more manual work behind the scenes. The most important R function to look at is <command>rk.assign.preview.data()</command>, here. The following short listing shows what your generated (preview) R code could look like for a plugin creating a text file output:
 		</para>
 		<programlisting>
 	## To be generated in the preview() code section of a plugin
-	outfile <- rk.get.tempfile.name(prefix="preview", extension=".html")
-	rk.assign.preview.data("SOMEID", list(filename=outfile, on.delete=function (id) {
-		unlink(rk.get.preview.data(id)$filename)
-	}))
-	oldfile <- rk.set.output.html.file(f)
+	pdata <- rk.get.preview.data("SOMEID")
+	if (is.null (pdata)) {
+		outfile <- rk.get.tempfile.name(prefix="preview", extension=".txt")
+		pdata <- list(filename=outfile, on.delete=function (id) {
+			unlink(rk.get.preview.data(id)$filename)
+		})
+		rk.assign.preview.data("SOMEID", pdata)
+	}
 	try ({
-		rk.header("This is a preview of what will happen")
-		rk.show.html(rk.get.output.html.file())
-		rk.flush.output()
+		cat ("This is a test", pdata$filename)
+		rk.edit.files(file=pdata$filename)
 	})
-	rk.set.output.html.file(outfile)
 		</programlisting>
 		<para>
 			Here you should get the value <parameter>SOMEID</parameter> from the <parameter>id</parameter> property of the <command><preview></command>-element. I.e. using <command>getString ("preview.id")</command> in the plugin's .js file.



More information about the rkward-tracker mailing list