swish/commit

New upstream files

authorJan Wielemaker
Mon May 2 16:29:40 2016 +0200
committerJan Wielemaker
Mon May 2 16:29:40 2016 +0200
commitde67c90e212c11fc718d9a817f3dfeb9f73e6410
treeb6af2ca0d26a2f9c32d787979539f89dca4604ea
parent821cd6913112d2fac323d07a74697b4e42695376
Diff style: patch stat
diff --git a/lib/swish/page.pl b/lib/swish/page.pl
index 0778187..702f355 100644
--- a/lib/swish/page.pl
+++ b/lib/swish/page.pl
@@ -491,7 +491,7 @@ notebooks(swinb, Options) -->
 	  download_source(Spec, NoteBookText, Options),
 	  phrase(source_data_attrs(Options), Extra)
 	},
-	html(div([ class('notebook'),
+	html(div([ class('notebook fullscreen'),
 		   'data-label'('Notebook')		% Use file?
 		 ],
 		 [ pre([ class('notebook-data'),
diff --git a/lib/swish/render/table.pl b/lib/swish/render/table.pl
index 400c852..6bd6639 100644
--- a/lib/swish/render/table.pl
+++ b/lib/swish/render/table.pl
@@ -69,26 +69,26 @@ term_rendering(Term, _Vars, Options) -->
 		 ])).
 term_rendering(Term, _Vars, Options) -->
 	{ is_list_of_terms(Term, _Rows, _Cols),
-	  header(Term, Header, Options)
+	  header(Term, Header, Options, Options1)
 	}, !,
 	html(div([ style('display:inline-block'),
 		   'data-render'('List of terms as a table')
 		 ],
 		 [ table(class('render-table'),
 			 [ \header_row(Header),
-			   \rows(Term, Options)
+			   \rows(Term, Options1)
 			 ])
 		 ])).
 term_rendering(Term, _Vars, Options) -->
 	{ is_list_of_lists(Term, _Rows, _Cols),
-	  header(Term, Header, Options)
+	  header(Term, Header, Options, Options1)
 	}, !,
 	html(div([ style('display:inline-block'),
 		   'data-render'('List of lists as a table')
 		 ],
 		 [ table(class('render-table'),
 			 [ \header_row(Header),
-			   \rows(Term, Options)
+			   \rows(Term, Options1)
 			 ])
 		 ])).
 
@@ -117,19 +117,29 @@ cells(Row, Cells) :-
 	compound(Row),
 	compound_name_arguments(Row, _, Cells).
 
-%%	header(+Table, -Header:list(Term), +Options) is semidet.
+%%	header(+Table, -Header:list(Term), +Options, -RestOptions) is semidet.
 %
 %	Compute the header to use. Fails if   a  header is specified but
 %	does not match.
 
-header(_, _, Options) :-
-	\+ option(header(_), Options), !.
-header([Row|_], ColHead, Options) :-
-	member(header(Header), Options),
+header(_, _, Options0, Options) :-
+	\+ option(header(_), Options0), !,
+	Options = Options0.
+header([Row|_], ColHead, Options0, Options) :-
+	partition(is_header, Options0, HeaderOptions, Options),
+	member(HeaderOption, HeaderOptions),
+	header(HeaderOption, Header),
 	generalise(Row, GRow),
 	generalise(Header, GRow), !,
 	header_list(Header, ColHead).
 
+is_header(0) :- !, fail.
+is_header(header(_)).
+is_header(header=_).
+
+header(header(H), H).
+header(header=H, H).
+
 generalise(List, VList) :-
 	is_list(List), !,
 	length(List, Len),
diff --git a/lib/swish/swish_csv.pl b/lib/swish/swish_csv.pl
index a721b0e..1e7bd43 100644
--- a/lib/swish/swish_csv.pl
+++ b/lib/swish/swish_csv.pl
@@ -47,6 +47,7 @@ SWISH program and obtain the results using   a simple web client such as
 
 :- multifile
 	pengines:write_result/3,
+	pengines:write_result/4,
 	write_answers/2,		% Answers, Bindings
 	write_answers/3.		% Answers, Bindings, Options
 
@@ -57,6 +58,12 @@ SWISH program and obtain the results using   a simple web client such as
 
 pengines:write_result(csv, Event, VarNames) :-
 	csv(Event, VarNames, []).
+pengines:write_result(csv, Event, VarNames, OptionDict) :-
+	(   Disposition = OptionDict.get(disposition)
+	->  Options = [disposition(Disposition)]
+	;   Options = []
+	),
+	csv(Event, VarNames, Options).
 
 csv(create(_Id, Features), VarNames, Options) :- !,
 	memberchk(answer(Answer), Features),
@@ -75,8 +82,8 @@ csv(output(_Id, message(_Term, _Class, HTML, _Where)), _VarNames, _Opts) :- !,
 	format('Status: 400 Bad request~n'),
 	format('Content-type: text/html~n~n'),
 	format('<html>~n~s~n</html>~n', [HTML]).
-csv(page(Page, Event), VarNames, _Options) :-
-	csv(Event, VarNames, [page(Page)]).
+csv(page(Page, Event), VarNames, Options) :-
+	csv(Event, VarNames, [page(Page)|Options]).
 csv(Event, _VarNames, _) :-
 	print_term(Event, [output(user_error)]).
 
@@ -91,10 +98,11 @@ success(Answers, _VarTerm, Options) :-
 	maplist(csv_answer, Answers, Rows),
 	forall(paginate(100, OutPage, Rows),
 	       csv_write_stream(current_output, OutPage, [])).
-success(Answers, VarTerm, _Options) :-
+success(Answers, VarTerm, Options) :-
+	option(disposition(Disposition), Options, 'swish-result.csv'),
 	maplist(csv_answer, Answers, Rows),
 	format('Content-encoding: chunked~n'),
-	format('Content-disposition: attachment; filename="swish-result.csv"~n'),
+	format('Content-disposition: attachment; filename="~w"~n', [Disposition]),
 	format('Content-type: text/csv~n~n'),
 	csv_write_stream(current_output, [VarTerm], []),
 	forall(paginate(100, Page, Rows),
diff --git a/web/help/editor.html b/web/help/editor.html
new file mode 100644
index 0000000..b97bf76
--- /dev/null
+++ b/web/help/editor.html
@@ -0,0 +1,25 @@
+<!DOCTYPE HTML>
+
+<html>
+  <head>
+  <title>Using the Prolog editor</title>
+  </head>
+  <body>
+
+<h2>Navigating</h2>
+
+<p>
+If a token is related to one or more source locations, a <b>long click</b> (&gt;
+500 millseconds) opens a menu below the cursor that allows for jumping to the
+related location.  Currently, these are:
+
+  <ul>
+    <li>:- include(<a>file</a>).
+    <li>a predicate all written as <a>name</a>(arg, ...).
+  </ul>
+
+<p>
+Future versions are likely to add more options, such as jumping to caller
+locations, open the documentation, listing predicates, etc.
+</body>
+</html>
diff --git a/web/help/help.html b/web/help/help.html
index a47ac56..a3d7bfc 100644
--- a/web/help/help.html
+++ b/web/help/help.html
@@ -194,7 +194,7 @@ You can make <span style="color:darkblue">SWI</span><span style="color:maroon">S
 start with a loaded program using the URL <code>http://swish.swi-prolog.org/</code> and
 providing the parameters below.  The URL accepts both `GET` and `POST` requests.
 
-  <dl>
+  <dl class="dl-horizontal">
   <dt>code<dd>
   Either the concrete code or a URL from which the code will be downloaded.
   </dd>
diff --git a/web/help/notebook.html b/web/help/notebook.html
index ef786d8..534496e 100644
--- a/web/help/notebook.html
+++ b/web/help/notebook.html
@@ -24,6 +24,9 @@ A Prolog notebook supports three types of cells:
   <ul>
     <li><b>Markdown</b> cells allow you to write text in the SWI-Prolog
     <a href="/pldoc/man?section=wiki">PlDoc</a> variation of markdown.
+    <li><b>HTML</b> cells allow you to write custom style web pages
+    as well as interative web applications.  See the
+    <a class="file" href="/example/htmlcell.swinb">HTML cell</a> demo.
     <li><b>Program</b> cells contain a Prolog program.
     <li><b>Query</b> cells contain a Prolog query, operating
     on the nearest program above it.