major overhaul of the manage app's api-documentation functions.
things can now be rendered to static html, new helma features are supported (prototype extension), everyhting is done in a nice and clean way with skins.
This commit is contained in:
parent
76bbe4053b
commit
7633e98eea
59 changed files with 1052 additions and 578 deletions
95
DocApplication/actions.js
Normal file
95
DocApplication/actions.js
Normal file
|
@ -0,0 +1,95 @@
|
|||
function main_action () {
|
||||
this.renderSkin ("frameset");
|
||||
}
|
||||
|
||||
|
||||
function prototypes_action () {
|
||||
res.data.body = this.renderSkinAsString ("prototypes");
|
||||
renderSkin ("api");
|
||||
}
|
||||
|
||||
|
||||
function summary_action () {
|
||||
res.data.body = this.renderSkinAsString ("summary");
|
||||
renderSkin ("api");
|
||||
}
|
||||
|
||||
|
||||
|
||||
function render_action () {
|
||||
res.write ("<html><head><title>render</title></head><body>rendering ... " + new Date () );
|
||||
var prefix = this.href ("");
|
||||
this.storePage (this, "main");
|
||||
this.storePage (this, "prototypes");
|
||||
this.storePage (this, "summary");
|
||||
var arr = this.listChildren ();
|
||||
for (var i=0; i<arr.length; i++) {
|
||||
this.storePage (arr[i], "list", "../");
|
||||
this.storePage (arr[i], "main", "../");
|
||||
res.writeln (arr[i]);
|
||||
var subarr = arr[i].listChildren ();
|
||||
for (var j=0; j<subarr.length; j++) {
|
||||
this.storePage (subarr[j], "main", "../../");
|
||||
res.writeln (subarr[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getDocPrototype (obj) {
|
||||
var tmp = obj;
|
||||
while (tmp!=null && tmp.getType () != this.PROTOTYPE) {
|
||||
tmp = tmp.getParentElement ();
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
function getDir (dir, obj) {
|
||||
dir.mkdir ();
|
||||
if (obj.getType () == this.APPLICATION) {
|
||||
return dir;
|
||||
} else if (obj.getType () == this.PROTOTYPE) {
|
||||
var protoObj = this.getDocPrototype (obj);
|
||||
var dir = new File (dir, protoObj.getElementName ());
|
||||
dir.mkdir ();
|
||||
return dir;
|
||||
} else {
|
||||
var protoObj = this.getDocPrototype (obj);
|
||||
var dir = this.getDir (dir, protoObj);
|
||||
res.writeln("dir="+dir);
|
||||
dir = new File (dir, obj.getElementName ());
|
||||
res.writeln("dir="+dir);
|
||||
dir.mkdir ();
|
||||
return dir;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function storePage (obj, action, backPath) {
|
||||
var str = this.getPage (obj, action, backPath);
|
||||
var appObj = this.getParentElement ();
|
||||
var dir = new File (appObj.getAppDir ().getAbsolutePath (), ".docs");
|
||||
dir = this.getDir (dir, obj);
|
||||
var f = new File (dir, action + ".html");
|
||||
f.remove ();
|
||||
f.open ();
|
||||
f.write (str);
|
||||
f.close ();
|
||||
}
|
||||
|
||||
|
||||
function getPage (obj, action, backPath) {
|
||||
backPath = (backPath==null) ? "" : backPath;
|
||||
res.pushStringBuffer ();
|
||||
eval ("obj." + action + "_action ();");
|
||||
var str = res.popStringBuffer ();
|
||||
var reg = new RegExp ("href=\"" + this.href ("") + "([^\"]+)\"");
|
||||
reg.global = true;
|
||||
str = str.replace (reg, "href=\"" + backPath + "$1.html\"");
|
||||
var reg = new RegExp ("src=\"" + this.href ("") + "([^\"]+)\"");
|
||||
reg.global = true;
|
||||
str = str.replace (reg, "src=\"" + backPath + "$1.html\"");
|
||||
return str;
|
||||
}
|
||||
|
||||
|
31
DocApplication/frameset.skin
Normal file
31
DocApplication/frameset.skin
Normal file
|
@ -0,0 +1,31 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>helma api / <% this.name %></title>
|
||||
<script language="javascript"><!--
|
||||
function changePrototypeList (obj) {
|
||||
if (obj.href.indexOf (".html")>-1)
|
||||
var newhref = obj.href.substring (0, obj.href.length-9) + "list.html";
|
||||
else
|
||||
var newhref = obj.href.substring (0, obj.href.length-4) + "list";
|
||||
functions.location.href = newhref;
|
||||
}
|
||||
//--></script>
|
||||
</head>
|
||||
|
||||
<frameset cols="30%,70%">
|
||||
<frameset rows="40%,60%">
|
||||
<frame src="<% this.href action="prototypes" %>" name="prototypes">
|
||||
<frame src="<% this.hrefRoot action="list" %>" name="functions">
|
||||
</frameset>
|
||||
<frame src="<% this.href action="summary" %>" name="main">
|
||||
</frameset>
|
||||
<noframes>
|
||||
<h2>
|
||||
Frame Alert</h2>
|
||||
|
||||
<p>
|
||||
This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
|
||||
</noframes>
|
||||
</html>
|
||||
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
<P><big>AppDoc <% this.name %><br/></big></p>
|
||||
<p><% param.path %></p>
|
||||
<p> ->
|
||||
<a href="<% this.parentlink %>">AppManager</a> |
|
||||
<a href="<% this.parentlink action="redirectpublic" %>">public</a>
|
||||
</p>
|
||||
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
<h2>AppDoc <% this.name %></h2>
|
||||
<a name="Index"><!-- --></a>
|
||||
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="3">
|
||||
<% this.index skin="indexList" %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
/**
|
||||
* macro rendering a skin
|
||||
* @param name name of skin
|
||||
|
@ -8,43 +9,33 @@ function skin_macro(par) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro-wrapper for href-function
|
||||
* @param action name of action to call on this prototype, default main
|
||||
*/
|
||||
function href_macro(par) {
|
||||
return this.href( (par&&par.action)?par.action:"main" );
|
||||
function href_macro(param) { return this.href ((param && param.action) ? param.action : "main"); }
|
||||
|
||||
function comment_macro (param) { return renderComment (this, param); }
|
||||
function content_macro (param) { return this.getContent (); }
|
||||
function tags_macro (param) { return renderTags (this, param); }
|
||||
function location_macro (param) { return renderLocation (this, param); }
|
||||
function link_macro (param) { return renderLink (this, param); }
|
||||
|
||||
//// END OF COPIED FUNCTIONS
|
||||
|
||||
|
||||
function headline_macro (param) {
|
||||
res.write (this.getName ());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro rendering page head
|
||||
*/
|
||||
function head_macro(par) {
|
||||
var obj = new Object();
|
||||
obj.path = this.getPath();
|
||||
this.renderSkin("head",obj);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* utility function for head_macro, rendering link to app
|
||||
*/
|
||||
function getPath() {
|
||||
return( '<a href="' + this.href("main") + '">' + this.name + '</a>' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* link to the "real" application object (ie not the DocApplication)
|
||||
*/
|
||||
function parentlink_macro(par) {
|
||||
var url = getProperty("baseURI");
|
||||
url = (url==null || url=="null") ? "" : url;
|
||||
url += this.name + "/";
|
||||
url += (par&&par.action)?par.action:"main";
|
||||
return url;
|
||||
function hrefRoot_macro (param) {
|
||||
var obj = this.getChildElement ("prototype_root");
|
||||
if (obj!=null) {
|
||||
var action = (param.action) ? param.action : "main";
|
||||
return obj.href (action);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -53,40 +44,33 @@ function parentlink_macro(par) {
|
|||
* @param skin name of skin to render on prototype
|
||||
*/
|
||||
function prototypes_macro(par) {
|
||||
var skin = (par && par.skin&&par.skin!="")?par.skin:"appList";
|
||||
var arr = this.listPrototypes();
|
||||
var skin = (par && par.skin&&par.skin!="") ? par.skin : "asPrototypeList";
|
||||
var arr = this.listChildren ();
|
||||
for ( var i=0; i<arr.length; i++ ) {
|
||||
arr[i].renderSkin(skin);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* list all methods of all prototypes, sort and separate them alphabetically
|
||||
* @param skin name of skin to render on method
|
||||
* @param skinSeparator name of skin to render separator between start-letters
|
||||
*/
|
||||
function index_macro(par) {
|
||||
var skin = (par && par.skin && par.skin!="") ? par.skin : "indexList";
|
||||
var skinSeparator = (par && par.skinSeparator && par.skinSeparator!="") ? par.skinSeparator : "indexListSeparator";
|
||||
var arr = this.listFunctions();
|
||||
var lastLetter = '';
|
||||
for ( var i=0; i<arr.length; i++ ) {
|
||||
if ( arr[i].name.substring(0,1)!=lastLetter ) {
|
||||
lastLetter = arr[i].name.substring(0,1);
|
||||
var obj = new Object();
|
||||
obj.letter = lastLetter.toUpperCase();
|
||||
arr[i].renderSkin(skinSeparator,obj);
|
||||
}
|
||||
arr[i].renderSkin(skin);
|
||||
}
|
||||
}
|
||||
///**
|
||||
// * list all methods of all prototypes, sort and separate them alphabetically
|
||||
// * @param skin name of skin to render on method
|
||||
// * @param skinSeparator name of skin to render separator between start-letters
|
||||
// */
|
||||
//function index_macro(par) {
|
||||
// var skin = (par && par.skin && par.skin!="") ? par.skin : "indexList";
|
||||
// var skinSeparator = (par && par.skinSeparator && par.skinSeparator!="") ? par.skinSeparator : "indexListSeparator";
|
||||
// var arr = this.listFunctions();
|
||||
// var lastLetter = '';
|
||||
// for ( var i=0; i<arr.length; i++ ) {
|
||||
// if ( arr[i].name.substring(0,1)!=lastLetter ) {
|
||||
// lastLetter = arr[i].name.substring(0,1);
|
||||
// var obj = new Object();
|
||||
// obj.letter = lastLetter.toUpperCase();
|
||||
// arr[i].renderSkin(skinSeparator,obj);
|
||||
// }
|
||||
// arr[i].renderSkin(skin);
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
/**
|
||||
* macro escaping the request-path, used for handing over redirect urls
|
||||
*/
|
||||
function requestpath_macro(par) {
|
||||
res.write( escape(req.path) );
|
||||
}
|
||||
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
if ( checkAddress()==false ) return;
|
||||
if ( checkAuth(this)==false ) return;
|
||||
|
||||
if ( req.data.action=="reload" ) {
|
||||
var appObj = root.getChildElement(this.name);
|
||||
appObj.docApp = new Packages.helma.doc.DocApplication( this.name, this.location );
|
||||
if ( req.data.redirect != null && req.data.redirect != "" )
|
||||
res.redirect ( getProperty("baseURI") + req.data.redirect );
|
||||
else
|
||||
res.redirect ( this.href("main") );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( req.data.action=="index" ) {
|
||||
res.data.body = this.renderSkinAsString("index");
|
||||
} else {
|
||||
res.data.body = this.renderSkinAsString("main");
|
||||
}
|
||||
|
||||
res.data.title = "Application " + this.name;
|
||||
renderSkin("api");
|
||||
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
<% this.head %>
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="3">
|
||||
<tr>
|
||||
<td class="list_separator" colspan="3">Prototypes</td>
|
||||
</tr>
|
||||
<% this.prototypes skin="appList" %>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
<font size="+1"><b><% this.name %></b></font>
|
||||
|
||||
<div class="list_apps">
|
||||
<li><b><a href="<% this.href action="main" %>?action=reload&redirect=<% this.requestpath %>">reload AppDoc</a>
|
||||
<li><b><a href="<% this.href action="main" %>">Application</a></b>
|
||||
<li><b><a href="<% this.href action="main" %>?action=index">Index</a>
|
||||
</div>
|
||||
|
||||
<p></p>
|
||||
<p>
|
||||
<i>Prototypes:</i><br />
|
||||
<% this.prototypes skin="navig" %>
|
||||
</p>
|
||||
|
10
DocApplication/prototypes.skin
Normal file
10
DocApplication/prototypes.skin
Normal file
|
@ -0,0 +1,10 @@
|
|||
|
||||
|
||||
<big class="top">Application <a href="<% this.href action="summary" %>" target="main"><% this.name %></a></big><br><br>
|
||||
|
||||
<% this.prototypes %>
|
||||
|
||||
|
||||
|
||||
|
||||
|
4
DocApplication/summary.skin
Normal file
4
DocApplication/summary.skin
Normal file
|
@ -0,0 +1,4 @@
|
|||
<h2>Application <% this.headline %></h2>
|
||||
|
||||
<% this.comment encoding="html" %>
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue