Minibar can now display grammar documentation.

The documentation is taken from a file called Grammar.pgf_info, located
next to the Grammar.pgf file on the server.

The first line of the documentation is displayed below the menu bar in
the minibar. The rest of the documentation is displayed when you press
the "More info" button (or the "i" button).

The documentation can contain HTML markup. Blank lines are treated as
paragraph breaks.
This commit is contained in:
Thomas Hallgren
2019-08-05 15:25:29 +02:00
parent 12079550f8
commit 81362ed7b7
3 changed files with 50 additions and 7 deletions

View File

@@ -10,8 +10,10 @@
</head>
<body class=minibar>
<header>
<h1>About Minibar</h1>
</header>
<main>
<a href="minibar.html">Minibar</a> is an alternative implementation of the
<a href="http://www.grammaticalframework.org/">GF</a> web app
<a href="http://www.grammaticalframework.org:41296/fridge/">Fridge Poetry</a>.
@@ -233,14 +235,23 @@ Some implementation details:
category names.
<li>[Added 2013-04-02] Minibar now remembers from one visit to the next
the selected set of target languages for each grammar.
<li>[Added 2019-08-05] Minibar can now display grammar documentation.
The documentation is taken from a file called
<var>Grammar</var><code>.pgf_info</code>, located
next to the <var>Grammar</var><code>.pgf</code> file on the server.
The first line of the documentation is displayed below the menu bar in
the minibar. The rest of the documentation is displayed when you press
the <b>More info</b> button (or the <b>i</b> button). The documentation
can contain HTML markup. Blank lines are treated as paragraph breaks.
</ul>
</main>
<footer>
<hr>
<div class=modtime><small>
<!-- hhmts start -->Last modified: Tue Apr 2 15:49:32 CEST 2013 <!-- hhmts end -->
<!-- hhmts start -->Last modified: Mon Aug 5 15:22:46 CEST 2019 <!-- hhmts end -->
</small></div>
<address>
<a href="http://www.cse.chalmers.se/~hallgren/">TH</a>
<img src="http://www.altocumulus.org/~hallgren/online.cgi?icon" alt="">
<a href="http://www.cse.chalmers.se/~hallgren/">Thomas Hallgren</a>
</address>
</footer>
</body> </html>

View File

@@ -10,6 +10,7 @@ h1:first-child, h2:first-child { margin-top: 0; margin-bottom: 1ex; }
th, td { vertical-align: baseline; text-align: left; }
div.menubar { font-family: sans-serif; font-size: small; }
div.infobar { margin: 5px; }
div#surface {
min-height: 3ex;

View File

@@ -53,13 +53,14 @@ function Minibar(server,opts) {
/* --- Creating user interface elements --------------------------------- */
this.menubar=div_class("menubar");
this.infobar=div_class("infobar");
this.extra=div_id("extra");
this.minibar=element(this.options.target);
this.minibar.innerHTML="";
with(this) {
appendChildren(menubar,[input.menus,translations.menus,input.buttons])
appendChildren(minibar,[menubar,input.main,translations.main,extra]);
appendChildren(minibar,[menubar,infobar,input.main,translations.main,extra]);
if(options.help_url)
menubar.appendChild(button("Help",bind(open_help,this)));
append_extra_buttons(extra,options);
@@ -205,6 +206,30 @@ Minibar.prototype.change_grammar=function(grammar_info) {
t.grammar=grammar_info;
t.input.change_grammar(grammar_info)
t.translations.change_grammar(grammar_info)
t.get_pgf_info()
}
Minibar.prototype.get_pgf_info=function() {
var t=this;
var info_url=t.server.current_grammar_url+"_info";
clear(t.infobar)
t.pgf_info=null;
ajax_http_get(info_url,bind(t.show_pgf_info,t),function(){})
}
Minibar.prototype.show_pgf_info=function(info) {
var t=this;
var cnt=0;
console.log(info)
info=info.split("\n");
for(var i=0;i<info.length;i++) {
if(info[i]=="") info[i]="<p>"
else cnt++
}
t.pgf_info=info.join("\n")
t.infobar.innerHTML=info[0]+" "
if(cnt>1)
t.infobar.appendChild(button("More info",bind(t.show_grammarinfo,t)))
}
Minibar.prototype.show_grammarinfo=function() {
@@ -241,7 +266,10 @@ Minibar.prototype.show_grammarinfo=function() {
var cats=wrap("div",text(g.categories.join(", ")))
var funs=wrap("div",text(g.functions.join(", ")))
var btn=button("More info",more)
var btn=button("Show more details",more)
var info=empty("div")
if(t.pgf_info) info.innerHTML=t.pgf_info
clear(t.translations.main)
var hdr=[text(g.name)]
@@ -249,8 +277,11 @@ Minibar.prototype.show_grammarinfo=function() {
hdr.push(text(" "))
hdr.push(wrap("small",text("("+g.lastmodified+")")))
}
appendChildren(this.translations.main,
[wrap("h3",hdr),
info,
text("The categories and functions in the grammar are listed below."),
btn,
wrap("h4",text("Start category")), text(g.startcat || ""),
wrap("h4",text("Categories")), cats,