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
|
@ -149,20 +149,53 @@ function countFreeEvaluators_macro() {
|
|||
|
||||
|
||||
/**
|
||||
* Macro formatting the 5min average of requests.
|
||||
* Macro returning the current number of objects in the cache
|
||||
*/
|
||||
function getRequestAvg_macro(par) {
|
||||
if ( app.requestStat==null || app.requestStat.get(this.name)==null )
|
||||
return 0;
|
||||
if ( this.isActive() ) {
|
||||
var obj = app.requestStat.get(this.name);
|
||||
return obj.last5Min + formatCount(obj.last5Min,par);
|
||||
function cacheusage_macro (param) {
|
||||
return this.getCacheUsage ();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro returning the number of objects allowed in the cache
|
||||
*/
|
||||
function cachesize_macro (param) {
|
||||
return this.getProperty ("cachesize", "1000");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro formatting the number of requests in the last 5 minutes
|
||||
*/
|
||||
function requestCount_macro(par) {
|
||||
if (app.data.stat==null || app.data.stat.get (this.name)==null)
|
||||
return "not available";
|
||||
if (this.isActive()) {
|
||||
var obj = app.data.stat.get (this.name);
|
||||
return obj.requestCount + formatCount (obj.requestCount, par);
|
||||
} else {
|
||||
return 0 + formatCount(0,par);
|
||||
return 0 + formatCount (0,par);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro formatting the number of errors in the last 5 minutes
|
||||
*/
|
||||
function errorCount_macro(par) {
|
||||
if (app.data.stat==null || app.data.stat.get (this.name)==null)
|
||||
return "not available";
|
||||
if (this.isActive()) {
|
||||
var obj = app.data.stat.get (this.name);
|
||||
return obj.errorCount + formatCount (obj.errorCount, par);
|
||||
} else {
|
||||
return 0 + formatCount (0,par);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Macro formatting app.properties
|
||||
*/
|
||||
|
@ -170,3 +203,8 @@ function properties_macro(par) {
|
|||
formatProperties( this.getProperties(), par );
|
||||
}
|
||||
|
||||
|
||||
function appdir_macro (param) {
|
||||
return this.getAppDir ().toString ();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
* renders AppManager
|
||||
*/
|
||||
|
||||
if ( checkAddress()==false ) return;
|
||||
if ( checkAuth(this)==false ) return;
|
||||
if (checkAddress()==false)
|
||||
return;
|
||||
if (checkAuth(this)==false)
|
||||
return;
|
||||
|
||||
res.data.body = this.renderSkinAsString("main");
|
||||
renderSkin ("global");
|
||||
|
|
|
@ -1,42 +1,62 @@
|
|||
<% this.skin name="head" %>
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="3">
|
||||
<tr>
|
||||
<td class="list_separator" colspan="3">application</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table border="0" cellspacing="0" cellpadding="3">
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">active sessions:</td>
|
||||
<td class="list_property" align="left">active sessions</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.countSessions %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200"><a href="<% this.href action="main" %>?showusers=true">logged-in users:</a></td>
|
||||
<td class="list_property" align="left"><a href="<% this.href action="main" %>?showusers=true">logged-in users</a></td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.users %> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">active evaluators:</td>
|
||||
<td class="list_property" align="left">active evaluators</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.countActiveEvaluators %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">free evaluators:</td>
|
||||
<td class="list_property" align="left">free evaluators</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.countFreeEvaluators %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">requests / 5 min:</td>
|
||||
<td class="list_property" align="left">requests / 5 min</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.getRequestAvg %></td>
|
||||
<td class="list_property" align="left"><% this.requestCount %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">uptime:</td>
|
||||
<td class="list_property" align="left">errors / 5 min</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.errorCount %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="list_property" align="left">cache usage</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.cacheusage %> objects of <% this.cachesize %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="list_property" align="left">uptime</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.uptime %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="list_separator" colspan="3">app.properties</td>
|
||||
<td class="list_property" align="left">app directory</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.appdir %></td>
|
||||
</tr>
|
||||
<% this.properties itemprefix='<tr><td class="list_property" align="right" valign="top" width="200">' separator='</td><td class="list_property" width="5"> </td><td class="list_property" align="left" valign="top">' itemsuffix='</td></tr>' % -->
|
||||
</table>
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="3">
|
||||
<tr>
|
||||
<td class="list_separator" colspan="3">app.properties</td>
|
||||
</tr>
|
||||
<% this.properties itemprefix='<tr><td class="list_property" valign="top">' separator='</td><td class="list_property" width="5"> </td><td class="list_property" valign="top">' itemsuffix='</td></tr>' %>
|
||||
</table>
|
||||
|
||||
|
|
|
@ -1,23 +1,42 @@
|
|||
|
||||
/**
|
||||
* prints session- and thread-stats for mrtg-tool
|
||||
* doesn't check username or password, so that we don't have
|
||||
* to write them cleartext in a mrtg-configfile
|
||||
* to write them cleartext in a mrtg-configfile but checks the
|
||||
* remote address.
|
||||
*/
|
||||
|
||||
if ( checkAddress()==false ) return;
|
||||
if ( checkAddress()==false )
|
||||
return;
|
||||
|
||||
if ( this.isActive()==false ) {
|
||||
res.write ( "0\n0\n0\n0\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if ( req.data.action=="sessions" ) {
|
||||
res.write ( this.sessions.size() + "\n0\n0\n0\n" );
|
||||
return;
|
||||
if (req.data.action=="sessions") {
|
||||
|
||||
res.write (this.sessions.size());
|
||||
res.write ("\n0\n0\n0\n");
|
||||
|
||||
} else if (req.data.action=="threads") {
|
||||
|
||||
res.write (this.countActiveEvaluators () + "\n");
|
||||
res.write (this.countEvaluators () + "\n");
|
||||
res.write ("0\n0\n");
|
||||
|
||||
} else if (req.data.action=="cache") {
|
||||
|
||||
res.write (this.getCacheUsage () + "\n");
|
||||
res.write (this.getProperty ("cachesize", "1000") + "\n");
|
||||
res.write ("0\n0\n");
|
||||
|
||||
} else if (req.data.action=="requests") {
|
||||
|
||||
// res.write (
|
||||
|
||||
} else {
|
||||
res.write ( "0\n0\n0\n0\n");
|
||||
}
|
||||
|
||||
if ( req.data.action=="threads" ) {
|
||||
res.write ( this.countActiveEvaluators() + "\n" + this.countFreeEvaluators() + "\n0\n0\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,14 +2,15 @@
|
|||
<b><a href="<% this.href action="main" %>"><% this.title %></a></b><br />
|
||||
<small><% this.countSessions singular=" Session" plural=" Sessions" %>, <% this.getRequestAvg singular=" Request" plural=" Requests" %>/5min</small>
|
||||
<div align="right">
|
||||
<!--<table border="0" cellspacing="0" cellpadding="0">
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td align="right" valign="top"><small>
|
||||
<a href="<% this.href action="api" %>/render">render AppDoc</a>
|
||||
<a href="<% this.href action="api" %>/main">AppDoc</a>
|
||||
<a href="<% root.href action="main" %>?app=<% this.title %>&action=flush">flush</a>
|
||||
<a href="<% root.href action="main" %>?app=<% this.title %>&action=restart">restart</a>
|
||||
</small></td>
|
||||
</tr>
|
||||
</table>-->
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
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" %>
|
||||
|
8
DocFunction/actions.js
Normal file
8
DocFunction/actions.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
function main_action () {
|
||||
this.getParentElement ().readFiles ();
|
||||
res.data.body = this.renderSkinAsString ("main");
|
||||
renderSkin ("api");
|
||||
}
|
||||
|
||||
|
||||
|
7
DocFunction/asLargeListItem.skin
Normal file
7
DocFunction/asLargeListItem.skin
Normal file
|
@ -0,0 +1,7 @@
|
|||
<tr><td>
|
||||
<a href="<% this.href action="main" %>" target="main"><% this.link %></a><br/>
|
||||
<% this.comment length="200" %>
|
||||
</td></tr>
|
||||
|
||||
|
||||
|
8
DocFunction/asLargeListItemSkin.skin
Normal file
8
DocFunction/asLargeListItemSkin.skin
Normal file
|
@ -0,0 +1,8 @@
|
|||
<tr><td>
|
||||
<a href="<% this.href action="main" %>" target="main"><% this.link %></a><br/>
|
||||
<% this.comment length="200" %>
|
||||
<% this.skinparameters separator=", "%>
|
||||
</td></tr>
|
||||
|
||||
|
||||
|
2
DocFunction/asListItem.skin
Normal file
2
DocFunction/asListItem.skin
Normal file
|
@ -0,0 +1,2 @@
|
|||
<% this.link %><br>
|
||||
|
1
DocFunction/asParentListItem.skin
Normal file
1
DocFunction/asParentListItem.skin
Normal file
|
@ -0,0 +1 @@
|
|||
<% this.link %>
|
|
@ -1,7 +0,0 @@
|
|||
|
||||
|
||||
function getApplication() {
|
||||
return this.getParentElement().getParentElement();
|
||||
}
|
||||
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<tr>
|
||||
<td width="200" class="list_property"><b><a href="<% this.prototypehref %>#<% this.name %>"><% this.name %></a></b></td>
|
||||
<td class="list_property"><% this.typename %> in <% this.prototypename %>
|
||||
<td class="list_property"><small>(<a href="<% this.href action="main" %>"><% this.prototypename %>/<% this.location %></a>)</small></td>
|
||||
</tr>
|
|
@ -1,3 +0,0 @@
|
|||
<tr>
|
||||
<td class="list_separator" colspan="3"><b> <% param.letter %></b></td>
|
||||
</tr>
|
|
@ -1,7 +0,0 @@
|
|||
<tr>
|
||||
<td class="list_property" align="right" valign="top" width="70" height="40"><font size=-1><a name="<% this.name %>"><!----></a>
|
||||
<code> <% param.group %></code></font></td>
|
||||
<td class="list_property" valign="top"><DL><DT><CODE><B>
|
||||
<a href="<% this.href action="main" %>"><% this.name %></a></B></CODE><DT><DL><% this.comment %><br><small><% this.tags %></small></DT></DL></TD>
|
||||
</tr>
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
<tr>
|
||||
<td class="list_property" align="right" valign="top" width="70" height="40"><font size=-1><a name="<% this.name %>"><!----></a>
|
||||
<code> <% param.group %></code></font></td>
|
||||
<td class="list_property" valign="top"><DL><DT><CODE><B>
|
||||
<a href="<% this.href action="main" %>"><% this.name %> (<% this.args %>)</a></B></CODE><small><i> in <% docprototype.name %>/<% this.location %></i></small><DT><DL><% this.comment %><br><small><% this.tags %></small></DT></DL></TD>
|
||||
</tr>
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
<tr>
|
||||
<td class="list_property" align="right" valign="top" width="70" height="40"><font size=-1><a name="<% this.name %>"><!----></a>
|
||||
<code> <% param.group %></code></font></td>
|
||||
<td class="list_property" valign="top"><dl><dt><code><b>
|
||||
<a href="<% this.href action="main" %>"><% docprototype.name %>.<% this.name %></a></B></code>
|
||||
<small><i> in <% docprototype.name %>/<% this.location %></i></small>
|
||||
<dt><dl><% this.comment %><br><small><% this.tags %></small></dt></dl></td>
|
||||
</tr>
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
<tr>
|
||||
<td class="list_property" align="right" valign="top" width="70" height="40"><font size=-1><a name="<% this.name %>"><!----></a>
|
||||
<code> <% param.group %></code></font></td>
|
||||
<td class="list_property" valign="top"><dl><dt><code><b>
|
||||
<a href="<% this.href action="main" %>"><% docprototype.name %>.<% this.name %></a></B></CODE><DT><DL><% this.comment %><br><small><% this.tags %></small></dt></dl></td>
|
||||
</tr>
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
<tr>
|
||||
<td class="list_property" align="right" valign="top" width="70" height="40"><font size=-1><a name="<% this.name %>"><!----></a>
|
||||
<code> <% param.group %></code></font></td>
|
||||
<td class="list_property" valign="top"><DL><DT><CODE><B>
|
||||
<a href="<% this.href action="main" %>"><% this.name %>()</a></B></CODE><DT><DL><% this.comment %><br><small><% this.tags %></small></DT></DL></TD>
|
||||
</tr>
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
/**
|
||||
* macro rendering a skin
|
||||
* @param name name of skin
|
||||
|
@ -8,120 +9,83 @@ 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
|
||||
|
||||
|
||||
/**
|
||||
* macro rendering page head
|
||||
*/
|
||||
function head_macro(par) {
|
||||
var obj = new Object();
|
||||
obj.path = this.getPath();
|
||||
var appObj = this.getApplication();
|
||||
appObj.renderSkin("head",obj);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* utility function for head_macro, rendering link to app and to prototype
|
||||
*/
|
||||
function getPath() {
|
||||
var protoObj = this.getDocPrototype();
|
||||
var str = protoObj.getPath() + "/" + this.getFullName();
|
||||
return( str );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro returning name of file this method resides in
|
||||
*/
|
||||
function location_macro(par) {
|
||||
var f = new File ( this.getLocation() );
|
||||
return f.getName();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro returning the type of this method (Action, Template, Skin, Macro, Function)
|
||||
*/
|
||||
function typename_macro(par) {
|
||||
return this.getTypeName();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro returning a link to the prototype page
|
||||
* @param action name of action to call on this prototype, default main
|
||||
*/
|
||||
function prototypehref_macro(par) {
|
||||
return this.getDocPrototype().href( (par&&par.action)?par.action:"main" )
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro returning the name of the prototype this method belongs to
|
||||
*/
|
||||
function prototypename_macro(par) {
|
||||
return this.getDocPrototype().getName();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro returning the comment text of this method
|
||||
* (excluding the tags!)
|
||||
* @param size (optional) text is cutoff after a number of chars
|
||||
*/
|
||||
function comment_macro(par) {
|
||||
var str = this.getComment();
|
||||
if ( par && par.length && str.length > par.size ) {
|
||||
return ( str.substring(0,par.size) );
|
||||
} else {
|
||||
return ( str );
|
||||
function headline_macro (param) {
|
||||
var p = this.getParentElement ();
|
||||
var handler = (p!=null) ? p.getName () : "";
|
||||
if (this.getType () == this.ACTION) {
|
||||
res.write ("/" + this.getName ());
|
||||
} else if (this.getType () == this.FUNCTION) {
|
||||
if (handler!="" && handler!="global")
|
||||
res.write (handler + ".");
|
||||
res.write (this.getName () + " (");
|
||||
var arr = this.listParameters ();
|
||||
for (var i=0; i<arr.length; i++) {
|
||||
res.write (arr[i]);
|
||||
if (i<arr.length-1) {
|
||||
res.write (", ");
|
||||
}
|
||||
}
|
||||
res.write (")");
|
||||
} else if (this.getType () == this.MACRO) {
|
||||
res.write ("<% ");
|
||||
if (handler!="" && handler!="global")
|
||||
res.write (handler + ".");
|
||||
var name = this.getName ();
|
||||
if (name.indexOf("_macro")>-1)
|
||||
name = name.substring (0, name.length-6);
|
||||
res.write (name);
|
||||
res.write (" %>");
|
||||
} else if (this.getType () == this.SKIN) {
|
||||
if (handler!="" && handler!="global")
|
||||
res.write (handler + "/");
|
||||
res.write (this.getName ());
|
||||
res.write (".skin");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro rendering the list of tags
|
||||
*/
|
||||
function tags_macro() {
|
||||
var arr = this.listTags();
|
||||
var argCt = 0;
|
||||
for ( var i in arr ) {
|
||||
if ( arr[i].getKind()==Packages.helma.doc.DocTag.ARG )
|
||||
argCt++;
|
||||
res.write( arr[i].render(argCt,this) );
|
||||
function skinparameters_macro (param) {
|
||||
if (this.getType () == this.SKIN) {
|
||||
this.parameters_macro (param);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro rendering sequence of arg1, arg2 etc
|
||||
* according to number of arguments in doctags.
|
||||
*/
|
||||
function args_macro() {
|
||||
var ct = this.countTags(Packages.helma.doc.DocTag.ARG);
|
||||
for ( var i=0; i<ct; i++) {
|
||||
res.write ( "arg" + (i+1) );
|
||||
if ( i<(ct-1) ) res.write (", ");
|
||||
else res.write ("");
|
||||
function parameters_macro (param) {
|
||||
var separator = (param.separator) ? param.separator : ", ";
|
||||
var arr = this.listParameters ();
|
||||
for (var i=0; i<arr.length ;i++) {
|
||||
res.write (arr[i]);
|
||||
if (i<arr.length-1)
|
||||
res.write (separator);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* macro returning nicely formatted sourcecode of this method.
|
||||
* code is encoded, >% %<-tags are colorcoded, line numbers are added
|
||||
*/
|
||||
function source_macro(par) {
|
||||
var str = this.getSource();
|
||||
var str = this.getContent ();
|
||||
var arr = str.split("<%");
|
||||
var str2 = "";
|
||||
for ( var i=0; i<arr.length; i++ ) {
|
||||
|
@ -140,18 +104,12 @@ function source_macro(par) {
|
|||
var str4 = "";
|
||||
for ( var i=0; i<arr.length; i++ ) {
|
||||
str4 += '<font color="#aaaaaa">' + (i+1) + ':</font> '
|
||||
if ( i<100 ) str4+=' ';
|
||||
if (i<99) str4+=' ';
|
||||
if (i<9) str4+=' ';
|
||||
str4 += arr[i] + "<br>";
|
||||
}
|
||||
return ( str4 );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro returning the fullname of this method
|
||||
*/
|
||||
function fullname_macro(par) {
|
||||
return this.getFullName();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
if ( checkAddress()==false ) return;
|
||||
if ( checkAuth(this)==false ) return;
|
||||
|
||||
res.data.body = this.renderSkinAsString("main");
|
||||
res.data.title = "Application " + this.name;
|
||||
renderSkin("api");
|
||||
|
||||
|
|
@ -1,9 +1,34 @@
|
|||
<% this.head %>
|
||||
<table width="90%" border="0" cellspacing="1" cellpadding="5">
|
||||
<tr>
|
||||
<td class="headline">
|
||||
<big><tt><% this.headline %></tt></big><br>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<div class="list_property">
|
||||
<small> <i>in <% docprototype.name%>/<% this.location %>:</i></small>
|
||||
</div>
|
||||
<tr>
|
||||
<td class="mainbox">
|
||||
<% this.comment suffix="<br><br>" %>
|
||||
<% this.skinparameters prefix="general parameters used in this skin:<ul><li><code>" separator="</code><li><code>" suffix="</code></ul><br>" %>
|
||||
<ul>
|
||||
<% this.tags type="param" skin="parameter" %>
|
||||
<% this.tags type="return" skin="return" %>
|
||||
<% this.tags type="author" skin="author" %>
|
||||
<% this.tags type="see" skin="see" %>
|
||||
<% this.tags type="deprecated" skin="deprecated" %>
|
||||
<% this.tags type="overrides" skin="overrides" %>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table width="90%" border="0" cellspacing="1" cellpadding="5">
|
||||
<tr>
|
||||
<td>Sourcecode in <% this.location %>:
|
||||
<pre><% this.source %></pre>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
<pre><% this.source %></pre>
|
||||
|
||||
|
|
10
DocPrototype/actions.js
Normal file
10
DocPrototype/actions.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
function list_action () {
|
||||
res.data.body = this.renderSkinAsString ("list");
|
||||
renderSkin ("api");
|
||||
}
|
||||
|
||||
function main_action () {
|
||||
res.data.body = this.renderSkinAsString ("main");
|
||||
renderSkin ("api");
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
<tr>
|
||||
|
||||
<td class="list_property" align="right" valign="top" width="1%"><font size="-1"><a name="<% this.name %>"><!-- --></a><code> Prototype</code></font>
|
||||
<br></td>
|
||||
<td class="list_property" valign="top"><code><b><a href="<% this.href action="main" %>"><% this.name %></a></b></code><br />
|
||||
<% this.comment %>
|
||||
<br />
|
||||
</td>
|
||||
|
||||
</tr>
|
1
DocPrototype/asInheritanceLink.skin
Normal file
1
DocPrototype/asInheritanceLink.skin
Normal file
|
@ -0,0 +1 @@
|
|||
extends Prototype <a href="<% this.href action="list" %>"><% this.name %></a>
|
17
DocPrototype/asParentList.skin
Normal file
17
DocPrototype/asParentList.skin
Normal file
|
@ -0,0 +1,17 @@
|
|||
|
||||
<tr><td class='headline'><b>Inherited from prototype <% this.link %>:</b><br></td></tr>
|
||||
|
||||
<tr><td>
|
||||
|
||||
<% this.methods separator=", " filter="actions" skin="asParentListItem" prefix="<b>Actions: </b>" suffix="<br/>" %>
|
||||
<% this.methods separator=", " filter="functions" skin="asParentListItem" prefix="<b>Functions: </b>" suffix="<br/>" %>
|
||||
<% this.methods separator=", " filter="macros" skin="asParentListItem" prefix="<b>Macros: </b>" suffix="<br/>" %>
|
||||
<% this.methods separator=", " filter="skins" skin="asParentListItem" prefix="<b>Skins: </b>" suffix="<br/>" %>
|
||||
<% this.methods separator=", " filter="templates" skin="asParentListItem" prefix="<b>Templates: </b>" suffix="<br/>" %>
|
||||
|
||||
</td></tr>
|
||||
|
||||
|
||||
|
||||
|
||||
|
10
DocPrototype/asPrototypeList.skin
Normal file
10
DocPrototype/asPrototypeList.skin
Normal file
|
@ -0,0 +1,10 @@
|
|||
|
||||
<a href="<% this.href action="main" %>" onClick="parent.changePrototypeList(this);" target="main"><% this.name %></a>
|
||||
|
||||
<%
|
||||
this.inheritance action="main" target="main"
|
||||
onClick="parent.changePrototypeList(this);" hopobject="false"
|
||||
prefix=" (extends " suffix=")"
|
||||
%>
|
||||
|
||||
<br />
|
29
DocPrototype/functions.js
Normal file
29
DocPrototype/functions.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
|
||||
///**
|
||||
// * utility function for head_macro, rendering link to app and to prototype
|
||||
// */
|
||||
//function getPath() {
|
||||
// var appObj = this.getParentElement ();
|
||||
// var str = appObj.getPath();
|
||||
// str += '/<a href="' + this.href("main") + '">' + this.name + '</a>';
|
||||
// return( str );
|
||||
//}
|
||||
|
||||
|
||||
|
||||
function translateType (filter) {
|
||||
if (filter=="actions")
|
||||
return Packages.helma.doc.DocElement.ACTION;
|
||||
else if (filter=="templates")
|
||||
return Packages.helma.doc.DocElement.TEMPLATE;
|
||||
else if (filter=="functions")
|
||||
return Packages.helma.doc.DocElement.FUNCTION;
|
||||
else if (filter=="macros")
|
||||
return Packages.helma.doc.DocElement.MACRO;
|
||||
else if (filter=="skins")
|
||||
return Packages.helma.doc.DocElement.SKIN;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
11
DocPrototype/list.skin
Normal file
11
DocPrototype/list.skin
Normal file
|
@ -0,0 +1,11 @@
|
|||
<h3>Prototype <a href="<% this.href action="main" %>" target="main"><% this.name %></a></h3>
|
||||
<% this.inheritance action="list" %>
|
||||
<% this.inheritance deep="true" hopobject="true" action="main" target="main" onClick="parent.changePrototypeList(this);" separator=", " prefix="extends: " suffix="<br>" %><br>
|
||||
|
||||
|
||||
<% this.methods filter="actions" skin="asListItem" prefix="<p><b>Actions:</b><br/>" suffix="</p> %>
|
||||
<% this.methods filter="functions" skin="asListItem" prefix="<p><b>Functions:</b><br/>" suffix="</p> %>
|
||||
<% this.methods filter="macros" skin="asListItem" prefix="<p><b>Macros:</b><br/>" suffix="</p> %>
|
||||
<% this.methods filter="skins" skin="asListItem" prefix="<p><b>Skins:</b><br/>" suffix="</p> %>
|
||||
<% this.methods filter="templates" skin="asListItem" prefix="<p><b>Templates:</b><br/>" suffix="</p> %>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
</table>
|
||||
<br />
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
<a name="<% param.desc %>"><!-- --></a>
|
||||
|
||||
|
||||
<table width="100%" border="0" cellspacing="0" cellpadding="3">
|
||||
<tr>
|
||||
<td class="list_separator" colspan="3"><% param.desc %></td>
|
||||
</tr>
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
/**
|
||||
* macro rendering a skin
|
||||
* @param name name of skin
|
||||
|
@ -8,105 +9,105 @@ 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
|
||||
* macro formatting list of methods of this prototype
|
||||
* @param filter actions | functions | macros | templates | skins
|
||||
* @param skin skin to apply to the docfunction object
|
||||
* @param separator
|
||||
* @param desc Description that is passed on to the called skin
|
||||
*/
|
||||
function head_macro(par) {
|
||||
var obj = new Object();
|
||||
obj.path = this.getPath();
|
||||
var appObj = this.getApplication();
|
||||
appObj.renderSkin("head",obj);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* utility function for head_macro, rendering link to app and to prototype
|
||||
*/
|
||||
function getPath() {
|
||||
var appObj = this.getApplication();
|
||||
var str = appObj.getPath();
|
||||
str += '/<a href="' + this.href("main") + '">' + this.name + '</a>';
|
||||
return( str );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro returning the comment for this prototype
|
||||
*/
|
||||
function comment_macro(par) {
|
||||
return this.getComment();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro formatting list of actions of this prototype
|
||||
*/
|
||||
function actions_macro(par) {
|
||||
this.printMethods( Packages.helma.doc.DocElement.ACTION, "listElementAction","Actions" );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro formatting list of templates of this prototype
|
||||
*/
|
||||
function templates_macro(par) {
|
||||
this.printMethods( Packages.helma.doc.DocElement.TEMPLATE, "listElementTemplate","Templates" );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro formatting list of functions of this prototype
|
||||
*/
|
||||
function functions_macro(par) {
|
||||
this.printMethods( Packages.helma.doc.DocElement.FUNCTION, "listElementFunction","Functions" );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro formatting list of skins of this prototype
|
||||
*/
|
||||
function skins_macro(par) {
|
||||
this.printMethods( Packages.helma.doc.DocElement.SKIN, "listElementSkin","Skins" );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro formatting list of macros of this prototype
|
||||
*/
|
||||
function macros_macro(par) {
|
||||
this.printMethods( Packages.helma.doc.DocElement.MACRO, "listElementMacro","Macros" );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro-utility: renders a list of methods of this prototype
|
||||
* usage of docprototype.listHeader/listFooter skin is hardcoded
|
||||
* @arg type integer - which type of methods are listed
|
||||
* @arg skin skin to be called on method
|
||||
* @arg desc string describing the type of method (ie "Skins", "Actions")
|
||||
*/
|
||||
function printMethods(type,skin,desc) {
|
||||
var arr = this.listFunctions(type);
|
||||
if ( arr.length > 0 ) {
|
||||
var obj = new Object();
|
||||
obj.desc = desc;
|
||||
this.renderSkin("listHeader",obj);
|
||||
for ( var i in arr ) {
|
||||
arr[i].renderSkin(skin,obj);
|
||||
function methods_macro (param) {
|
||||
var skinname = (param.skin) ? param.skin : "list";
|
||||
var separator = (param.separator) ? param.separator : "";
|
||||
var arr = this.listChildren ();
|
||||
var type = this.translateType (param.filter);
|
||||
var sb = new java.lang.StringBuffer ();
|
||||
for (var i=0; i<arr.length; i++) {
|
||||
if (arr[i].getType () == type) {
|
||||
sb.append (arr[i].renderSkinAsString (skinname, param));
|
||||
sb.append (separator);
|
||||
}
|
||||
this.renderSkin("listFooter",obj);
|
||||
}
|
||||
var str = sb.toString ();
|
||||
if (str.length>0)
|
||||
return str.substring (0, str.length - separator.length);
|
||||
else
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
function inheritance_macro (param) {
|
||||
var action = param.action ? param.action : "main";
|
||||
var target = param.target ? ('target="' + param.target + '" ') : '';
|
||||
var obj = this.getParentPrototype ();
|
||||
if (obj!=null) {
|
||||
obj = this.inheritanceUtil (obj, param);
|
||||
}
|
||||
if (param.deep=="true") {
|
||||
while (obj!=null) {
|
||||
obj = this.inheritanceUtil (obj, param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function inheritanceUtil (obj, param) {
|
||||
if (obj.getName ()=="hopobject" && param.hopobject!="true")
|
||||
return null;
|
||||
var tmp = new Object ();
|
||||
for (var i in param)
|
||||
tmp[i] = param[i];
|
||||
tmp.href = obj.href ((param.action) ? param.action : "main");
|
||||
delete tmp.hopobject;
|
||||
delete tmp.action;
|
||||
delete tmp.deep;
|
||||
delete tmp.separator;
|
||||
res.write (renderLinkTag (tmp));
|
||||
res.write (obj.getName () + "</a>");
|
||||
if (obj.getParentPrototype ())
|
||||
res.write (param.separator);
|
||||
return obj.getParentPrototype ();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* loops through the parent prototypes and renders a skin on each
|
||||
* @param skin
|
||||
*/
|
||||
function parentPrototype_macro (param) {
|
||||
var skinname = (param.skin) ? param.skin : "asParentList";
|
||||
var obj = this.getParentPrototype ();
|
||||
while (obj!=null) {
|
||||
obj.renderSkin (skinname);
|
||||
obj = obj.getParentPrototype ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function typeProperties_macro (param) {
|
||||
var props = this.getTypeProperties ();
|
||||
if (props!=null) {
|
||||
res.encode(props.getContent ());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
if ( checkAddress()==false ) return;
|
||||
if ( checkAuth(this)==false ) return;
|
||||
|
||||
res.data.body = this.renderSkinAsString("main");
|
||||
res.data.title = "Application " + this.name;
|
||||
renderSkin ("api");
|
||||
|
||||
|
|
@ -1,8 +1,82 @@
|
|||
<% this.head %>
|
||||
<table width="90%" border="0" cellspacing="1" cellpadding="5">
|
||||
<tr>
|
||||
<td class="headline">
|
||||
<big><tt>Prototype <% this.headline %></tt></big><br>
|
||||
<% this.inheritance deep="true" hopobject="true" action="main" target="main" onClick="parent.changePrototypeList(this);" separator=", " prefix="extends: " suffix="<br>" %>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<a class="navig" href="#actions">ACTIONS</a> |
|
||||
<a class="navig" href="#functions">FUNCTIONS</a> |
|
||||
<a class="navig" href="#macros">MACROS</a> |
|
||||
<a class="navig" href="#skins">SKINS</a> |
|
||||
<a class="navig" href="#templates">TEMPLATES</a> |
|
||||
<a class="navig" href="#typeproperties">TYPE.PROPERTIES</a>
|
||||
|
||||
|
||||
|
||||
<table width="90%" border="0" cellspacing="1" cellpadding="5">
|
||||
<tr>
|
||||
<td class="mainbox">
|
||||
<% this.comment suffix="<br><br>" %>
|
||||
<ul>
|
||||
<% this.tags type="author" skin="author" %>
|
||||
<% this.tags type="see" skin="see" %>
|
||||
<% this.tags type="deprecated" skin="deprecated" %>
|
||||
<% this.tags type="overrides" skin="overrides" %>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table width="90%" border="0" cellspacing="1" cellpadding="3">
|
||||
|
||||
<% this.methods separator="<tr><td class='mainbox'><img src='' width=0 height=0></td></tr>"
|
||||
filter="actions"
|
||||
skin="asLargeListItem"
|
||||
prefix="<tr><td class='headline'>Actions<a name='actions'><!-- --></a></td></tr>"
|
||||
%>
|
||||
|
||||
<% this.methods separator="<tr><td class='mainbox'><img src='' width=0 height=0></td></tr>"
|
||||
filter="functions"
|
||||
skin="asLargeListItem"
|
||||
prefix="<tr><td class='headline'>Functions<a name='functions'><!-- --></a></td></tr>"
|
||||
%>
|
||||
|
||||
<% this.methods separator="<tr><td class='mainbox'><img src='' width=0 height=0></td></tr>"
|
||||
filter="macros"
|
||||
skin="asLargeListItem"
|
||||
prefix="<tr><td class='headline'>Macros<a name='macros'><!-- --></a></td></tr>"
|
||||
%>
|
||||
|
||||
<% this.methods separator="<tr><td class='mainbox'><img src='' width=0 height=0></td></tr>"
|
||||
filter="skins"
|
||||
skin="asLargeListItemSkin"
|
||||
prefix="<tr><td class='headline'>Skins<a name='skins'><!-- --></a></td></tr>"
|
||||
%>
|
||||
|
||||
<% this.methods separator="<tr><td class='mainbox'><img src='' width=0 height=0></td></tr>"
|
||||
filter="templates"
|
||||
skin="asLargeListItem"
|
||||
prefix="<tr><td class='headline'>Templates<a name='templates'><!-- --></a></td></tr>"
|
||||
%>
|
||||
|
||||
<% this.parentPrototype skin="asParentList" %>
|
||||
</table>
|
||||
|
||||
<br/><br/><a name='typeproperties'><!-- --></a><table width='90%' border='0' cellspacing='1' cellpadding='5'><tr>
|
||||
<td class="headline">type.properties</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="mainbox"><% this.typeProperties prefix="<pre>" suffix="</pre>" %></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<% this.actions %>
|
||||
<% this.skins %>
|
||||
<% this.macros %>
|
||||
<% this.functions %>
|
||||
<% this.templates %>
|
||||
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
|
||||
<a href="<% this.href action="main" %>"><% this.name %></a><br>
|
2
DocTag/author.skin
Normal file
2
DocTag/author.skin
Normal file
|
@ -0,0 +1,2 @@
|
|||
<li><b>Author</b><br/>
|
||||
<% this.text %>
|
2
DocTag/deprecated.skin
Normal file
2
DocTag/deprecated.skin
Normal file
|
@ -0,0 +1,2 @@
|
|||
<li><b>Deprecated</b><br/>
|
||||
<% this.text %>
|
1
DocTag/main.skin
Normal file
1
DocTag/main.skin
Normal file
|
@ -0,0 +1 @@
|
|||
<li><% this.text %>
|
3
DocTag/overrides.skin
Normal file
3
DocTag/overrides.skin
Normal file
|
@ -0,0 +1,3 @@
|
|||
<li><b>Overrides</b><br/>
|
||||
<% param.link %>
|
||||
|
2
DocTag/parameter.skin
Normal file
2
DocTag/parameter.skin
Normal file
|
@ -0,0 +1,2 @@
|
|||
<li><b>Parameter</b> <code><% this.name %></code>:<br/>
|
||||
<% this.text %>
|
|
@ -1,46 +0,0 @@
|
|||
/**
|
||||
* function renders list of tags, language is hardcoded here
|
||||
* @arg number of current argument (for formatting arg1, arg2 etc)
|
||||
* @arg method method-object from which we try to find other prototypes/methods
|
||||
* when we're formatting a see tag
|
||||
*/
|
||||
function render(argCt,docFunc) {
|
||||
var str = "";
|
||||
if ( this.getKind() == this.ARG ) {
|
||||
str = "<b>arg" + argCt + ":</b> " + format(this.text);
|
||||
} else if ( this.getKind() == this.PARAM ) {
|
||||
str = "<b>Parameter " + this.name;
|
||||
if ( this.text!=null && this.text!="" ) {
|
||||
str += ":</b> " + format(this.text);
|
||||
}
|
||||
} else if ( this.getKind() == this.RETURNS ) {
|
||||
str = "<b>Returns:</b> " + format(this.text);
|
||||
} else if ( this.getKind() == this.AUTHOR ) {
|
||||
str = "<b>by " + format(this.text) + "</b>";
|
||||
} else if ( this.getKind() == this.VERSION ) {
|
||||
str = "<b>Version " + format(this.text) + "</b>";
|
||||
} else if ( this.getKind() == this.RELEASE ) {
|
||||
str = "<b>since" + format(this.text) + "</b>";
|
||||
} else if ( this.getKind() == this.SEE ) {
|
||||
if ( this.text.indexOf("http://")==0 ) {
|
||||
str = '<a href="' + this.text + '">' + this.text + '</a>';
|
||||
} else {
|
||||
var tmp = new java.lang.String(this.text);
|
||||
tmp = tmp.trim();
|
||||
var arr = tmp.split(".");
|
||||
var obj = docFunc.getApplication().getDocPrototype(arr[0]);
|
||||
if( arr.length>1 && obj.getFunction(arr[1])!=null ) {
|
||||
str = '<b>See also: <a href="' + obj.href("main") + '#' + obj.getFunction(arr[1]).name + '">' + format(tmp) + '</a></b>';
|
||||
} else if ( obj!=null ) {
|
||||
str = '<b>See also: <a href="' + obj.href("main") + '">' + format(tmp) + '</a></b>';
|
||||
}
|
||||
}
|
||||
if ( str=="" ) {
|
||||
str = "<b>See also:</b> " + format(this.text);
|
||||
}
|
||||
}
|
||||
return str + "<br />";
|
||||
}
|
||||
|
||||
|
||||
|
2
DocTag/return.skin
Normal file
2
DocTag/return.skin
Normal file
|
@ -0,0 +1,2 @@
|
|||
<li><b>Returns</b><br>
|
||||
<% this.text %>
|
2
DocTag/see.skin
Normal file
2
DocTag/see.skin
Normal file
|
@ -0,0 +1,2 @@
|
|||
<li><b>See also</b><br>
|
||||
<% param.link %>
|
|
@ -1,17 +1,67 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
||||
<HTML>
|
||||
<% skin name="head" %>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title></title>
|
||||
<style type="text/css">
|
||||
|
||||
body, p, td, th, li {
|
||||
font-family: verdana, sans-serif;
|
||||
font-size: 10pt;
|
||||
}
|
||||
|
||||
big.top {
|
||||
font-size: 18pt;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
big {
|
||||
font-size: 13pt;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
a {
|
||||
font-weight:bold;
|
||||
color: #cc3333;
|
||||
text-decoration:none;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration:underline;
|
||||
}
|
||||
|
||||
.navig {
|
||||
font-size: 9px;
|
||||
text-decoration: none;
|
||||
font-weight:normal;
|
||||
}
|
||||
|
||||
li {
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
|
||||
.mainbox {
|
||||
border-color:#999999;
|
||||
padding-top:5px;
|
||||
padding-bottom:5px;
|
||||
border-bottom-width:1px;
|
||||
border-bottom-style:dotted;
|
||||
}
|
||||
|
||||
.headline {
|
||||
font-weight:bold;
|
||||
background:#dfdfdf;
|
||||
border-color:#999999;
|
||||
padding-top:5px;
|
||||
padding-bottom:5px;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<table width="90%" border="0" cellspacing="1" cellpadding="5" bgcolor="#000000">
|
||||
<tr>
|
||||
<td width="200" nowrap align="left" valign="top" bgcolor="#cccc99">
|
||||
<p><a href="<% root.href action="main" %>"><img src="<% root.href action="image" %>" title="helma" border="0" width="174" height="35" align="baseline" style="border-width:3px;border-color:white;"></a></p>
|
||||
<% docapplication.skin name="navig" %></td>
|
||||
<td align="left" valign="top" bgcolor="#ffffff"><% response.body %></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<% response.body %>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -10,11 +10,10 @@ function scheduler() {
|
|||
|
||||
|
||||
/**
|
||||
* initializes app.data.requestStat storage on startup,
|
||||
* initializes app.data.stat storage on startup,
|
||||
* creates app.data.addressFilter
|
||||
*/
|
||||
function onStart() {
|
||||
app.data.requestStat = new HopObject();
|
||||
app.data.addressFilter = createAddressFilter();
|
||||
}
|
||||
|
||||
|
@ -47,29 +46,28 @@ function createAddressFilter() {
|
|||
|
||||
|
||||
/**
|
||||
* updates the request stats in app.data.requestStat every 5 minutes
|
||||
* updates the stats in app.data.stat every 5 minutes
|
||||
*/
|
||||
function appStat() {
|
||||
if ( app.data.requestStat==null ) {
|
||||
app.data.requestStat = new HopObject();
|
||||
}
|
||||
if( (new Date()-300000) < app.data.requestStat.lastRun ) {
|
||||
function appStat () {
|
||||
if (app.data.stat==null)
|
||||
app.data.stat = new HopObject ();
|
||||
if ((new Date()-300000) < app.data.stat.lastRun)
|
||||
return;
|
||||
}
|
||||
var arr = root.getApplications();
|
||||
for ( var i=0; i<arr.length; i++ ) {
|
||||
var tmp = app.data.requestStat.get(arr[i].getName());
|
||||
if ( tmp==null ) {
|
||||
var arr = root.getApplications ();
|
||||
for (var i=0; i<arr.length; i++) {
|
||||
var tmp = app.data.stat.get (arr[i].getName());
|
||||
if (tmp==null) {
|
||||
tmp = new HopObject();
|
||||
tmp.lastTotal = 0;
|
||||
tmp.last5Min = 0;
|
||||
}
|
||||
var ct = arr[i].getRequestCount();
|
||||
tmp.last5Min = ct - tmp.lastTotal;
|
||||
tmp.lastTotal = ct;
|
||||
app.data.requestStat.set(arr[i].getName(), tmp);
|
||||
tmp.lastTotalRequestCount = 0;
|
||||
tmp.lastTotalErrorCount = 0;
|
||||
}
|
||||
tmp.requestCount = arr[i].getRequestCount () - tmp.lastTotalRequestCount;
|
||||
tmp.lastTotalRequestCount = arr[i].getRequestCount ();
|
||||
tmp.errorCount = arr[i].getErrorCount () - tmp.lastTotalErrorCount;
|
||||
tmp.lastTotalErrorCount = arr[i].getErrorCount ();
|
||||
app.data.stat.set (arr[i].getName(), tmp);
|
||||
}
|
||||
app.data.requestStat.lastRun = new Date();
|
||||
app.data.stat.lastRun = new Date();
|
||||
}
|
||||
|
||||
|
||||
|
@ -77,7 +75,7 @@ function appStat() {
|
|||
* utility function to sort object-arrays by name
|
||||
*/
|
||||
function sortByName(a,b) {
|
||||
if ( a.name>b.name )
|
||||
if ( a.name>b.name)
|
||||
return 1;
|
||||
else if ( a.name==b.name )
|
||||
return 0;
|
||||
|
@ -132,8 +130,6 @@ function checkAuth(appObj) {
|
|||
// check against application
|
||||
var appUsername = appObj.getProperty("adminusername");
|
||||
var appPassword = appObj.getProperty("adminpassword");
|
||||
if ( appUsername==null || appUsername=="" || appPassword==null || appPassword=="" )
|
||||
return forceStealth();
|
||||
if ( md5username==appUsername && md5password==appPassword )
|
||||
return true;
|
||||
}
|
||||
|
@ -149,7 +145,7 @@ function checkAddress() {
|
|||
app.log("denied request from " + req.data.http_remotehost );
|
||||
// forceStealth seems a bit like overkill here.
|
||||
// display a message that the ip address must be added to server.properties
|
||||
res.write ("Access to address "+req.data.http_remotehost+" denied.");
|
||||
res.write ("Access from address "+req.data.http_remotehost+" denied.");
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
|
@ -169,14 +165,7 @@ function forceAuth(realm) {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* response is reset to 404 / notfound
|
||||
*/
|
||||
function forceStealth() {
|
||||
res.reset();
|
||||
res.status = 404;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -302,3 +291,16 @@ function formatCount(ct, par) {
|
|||
else
|
||||
return par.plural;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* tries to make out if this server is running linux from java's system properties
|
||||
*/
|
||||
function isLinux () {
|
||||
var str = java.lang.System.getProperty("os.name");
|
||||
return (str!=null && str.toLowerCase().indexOf("linux")!=-1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
176
Global/renderFunctions.js
Normal file
176
Global/renderFunctions.js
Normal file
|
@ -0,0 +1,176 @@
|
|||
|
||||
|
||||
function renderLink (docEl, param) {
|
||||
var text = "";
|
||||
if (docEl.getType () == docEl.APPLICATION || docEl.getType () == docEl.PROTOTYPE) {
|
||||
text = docEl.getName ();
|
||||
} else if (docEl.getType () == docEl.SKIN) {
|
||||
text = docEl.getName () + ".skin";
|
||||
} else if (docEl.getType () == docEl.MACRO) {
|
||||
if (docEl.getParentElement () && docEl.getParentElement().getName()!="global") {
|
||||
text = docEl.getParentElement ().getName () + ".";
|
||||
}
|
||||
var str = docEl.getName ();
|
||||
if (str.indexOf("_macro")) {
|
||||
text += str.substring (0, str.length-6);
|
||||
}
|
||||
} else if (docEl.getType () == docEl.FUNCTION) {
|
||||
var text = docEl.getName () + " (";
|
||||
var arr = docEl.listParameters ();
|
||||
for (var i=0; i<arr.length ;i++) {
|
||||
text += arr[i];
|
||||
if (i<arr.length-1)
|
||||
text += ", ";
|
||||
}
|
||||
text += ")";
|
||||
} else {
|
||||
text = docEl.getName ();
|
||||
}
|
||||
param.href = docEl.href ("main");
|
||||
if (!param.target) {
|
||||
param.target = "main";
|
||||
}
|
||||
return renderLinkTag (param) + text + '</a>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function renderLinkTag (param) {
|
||||
var sb = new java.lang.StringBuffer ();
|
||||
sb.append ('<a');
|
||||
for (var i in param) {
|
||||
sb.append (' ');
|
||||
sb.append (i);
|
||||
sb.append ('="');
|
||||
sb.append (param[i]);
|
||||
sb.append ('"');
|
||||
}
|
||||
sb.append ('>');
|
||||
return sb.toString ();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* renders the name of the location relative to the application
|
||||
* root.
|
||||
*/
|
||||
function renderLocation (docEl, param) {
|
||||
var f = docEl.getLocation ();
|
||||
if (f.isDirectory ())
|
||||
return f.getName ();
|
||||
else {
|
||||
return f.getParentFile ().getName () + "/" + f.getName ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* renders tag list.
|
||||
* @param param.skin skin to render on found DocTags
|
||||
* @param param.separator String printed between tags
|
||||
* @param param.type type string (param|return|author|version|see) to filter tags.
|
||||
*/
|
||||
function renderTags (docEl, param) {
|
||||
var skinname = (param.skin) ? param.skin : "main";
|
||||
var type = -1;
|
||||
if (param.type=="param" || param.type=="params")
|
||||
type = Packages.helma.doc.DocTag.PARAMETER;
|
||||
else if (param.type=="return" || param.type=="returns")
|
||||
type = Packages.helma.doc.DocTag.RETURN;
|
||||
else if (param.type=="author")
|
||||
type = Packages.helma.doc.DocTag.AUTHOR;
|
||||
else if (param.type=="version")
|
||||
type = Packages.helma.doc.DocTag.VERSION;
|
||||
else if (param.type=="see")
|
||||
type = Packages.helma.doc.DocTag.SEE;
|
||||
else if (param.type=="deprecated")
|
||||
type = Packages.helma.doc.DocTag.DEPRECATED;
|
||||
else if (param.type=="overrides")
|
||||
type = Packages.helma.doc.DocTag.OVERRIDES;
|
||||
var str = "";
|
||||
var arr = docEl.listTags ();
|
||||
for (var i=0; i<arr.length; i++) {
|
||||
if (arr[i].getType () == type) {
|
||||
if (param.type=="see" || param.type=="overrides") {
|
||||
param.link = renderReference (arr[i], docEl);
|
||||
}
|
||||
str += arr[i].renderSkinAsString (skinname, param);
|
||||
str += (param.separator) ? param.separator : "";
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* renders a reference to functions in other prototypes, masks
|
||||
* urls in a see tag
|
||||
* (see- and overrides-tags)
|
||||
* @param docTagObj
|
||||
* @param docEl needed to be able to walk up to application object
|
||||
*/
|
||||
function renderReference (docTagObj, docEl) {
|
||||
// prepare the text:
|
||||
var text = docTagObj.getText ();
|
||||
text = new java.lang.String (text);
|
||||
text = text.trim ();
|
||||
if (text.indexOf("http://")==0) {
|
||||
// an url is a simple job
|
||||
return '<a href="' + text + '" target="_new">' + text + '</a>';
|
||||
} else {
|
||||
// make sure we only use the first item in the text so that unlinked comments
|
||||
// can follow, store & split the that
|
||||
var tok = new java.util.StringTokenizer (text);
|
||||
var tmp = tok.nextToken ();
|
||||
text = " " + text.substring (tmp.length + 1);
|
||||
var parts = tmp.split(".");
|
||||
// try to find the application object
|
||||
var obj = docEl;
|
||||
while (obj!=null) {
|
||||
if (obj.getType () == Packages.helma.doc.DocElement.APPLICATION) {
|
||||
var appObj = obj;
|
||||
break;
|
||||
}
|
||||
obj = obj.getParentElement ();
|
||||
}
|
||||
var protoObj = appObj.getChildElement ("prototype_" + parts[0]);
|
||||
if (protoObj==null) {
|
||||
// prototype wasn't found, return the unlinked tag
|
||||
return tmp + text;
|
||||
}
|
||||
if (parts.length==1) {
|
||||
// no function specified, return the linked prototype
|
||||
return '<a href="' + protoObj.href ("main") + '">' + format (tmp) + '</a>' + text;
|
||||
}
|
||||
// try to find a function object:
|
||||
var arr = protoObj.listChildren ();
|
||||
for (var i=0; i<arr.length; i++) {
|
||||
if (arr[i].getName () == parts [1]) {
|
||||
return '<a href="' + arr[i].href("main") + '">' + format(tmp) + '</a>' + text;
|
||||
}
|
||||
}
|
||||
// function not found:
|
||||
return tmp + text;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* function rendering a comment.
|
||||
* @param param.length comment is shortened to the given length.
|
||||
* @returns string
|
||||
*/
|
||||
function renderComment (docEl, param) {
|
||||
var str = docEl.getComment ();
|
||||
if (param.length) {
|
||||
if (param.length < str.length) {
|
||||
return str.substring (0, param.length) + " ...";
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
|
@ -35,27 +35,50 @@ function countSessions_macro(par) {
|
|||
|
||||
|
||||
/**
|
||||
* macro returning the total number of sessions on this server
|
||||
* macro returning the number of requests during the last 5 minutes
|
||||
* @see global.formatCount
|
||||
*/
|
||||
function countRequests_macro(par) {
|
||||
if ( app.requestStat==null ) {
|
||||
function requestCount_macro(par) {
|
||||
if (app.data.stat==null) {
|
||||
return;
|
||||
}
|
||||
var arr = this.getApplications();
|
||||
var arr = this.getApplications ();
|
||||
var sum = 0;
|
||||
for ( var i=0; i<arr.length; i++ ) {
|
||||
if ( arr[i].getName()!=app.__app__.getName() ) {
|
||||
var obj = app.requestStat.get(arr[i].name);
|
||||
for (var i=0; i<arr.length; i++) {
|
||||
if (arr[i].getName() != app.__app__.getName() ) { // don't include manage app
|
||||
var obj = app.data.stat.get (arr[i].name);
|
||||
if ( obj!=null ) {
|
||||
sum += obj.last5Min;
|
||||
sum += obj.requestCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
return sum + formatCount(sum,par);
|
||||
return sum + formatCount (sum,par);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* macro returning the number of errors during the last 5 minutes
|
||||
* @see global.formatCount
|
||||
*/
|
||||
function errorCount_macro(par) {
|
||||
if (app.data.stat==null) {
|
||||
return;
|
||||
}
|
||||
var arr = this.getApplications ();
|
||||
var sum = 0;
|
||||
for (var i=0; i<arr.length; i++) {
|
||||
if (arr[i].getName() != app.__app__.getName() ) { // don't include manage app
|
||||
var obj = app.data.stat.get (arr[i].name);
|
||||
if ( obj!=null ) {
|
||||
sum += obj.errorCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
return sum + formatCount (sum,par);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function extensions_macro (par) {
|
||||
var vec = this.getExtensions ();
|
||||
var str = "";
|
||||
|
@ -65,7 +88,7 @@ function extensions_macro (par) {
|
|||
str += (par && par.separator) ? par.separator : ", ";
|
||||
}
|
||||
}
|
||||
return str;
|
||||
return (str=="") ? null : str;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -163,28 +186,31 @@ function home_macro() {
|
|||
|
||||
/**
|
||||
* Macro that returns the free memory in the java virtual machine
|
||||
* @param format if "hr", value will be printed human readable
|
||||
*/
|
||||
function jvmFreeMemory_macro() {
|
||||
var m = java.lang.Runtime.getRuntime().freeMemory();
|
||||
return formatBytes(m);
|
||||
function jvmFreeMemory_macro (param) {
|
||||
var m = java.lang.Runtime.getRuntime ().freeMemory ();
|
||||
return (param && param.hr) ? formatBytes (m) : m;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro that returns the total memory available to the java virtual machine
|
||||
* @param format if "hr", value will be printed human readable
|
||||
*/
|
||||
function jvmTotalMemory_macro() {
|
||||
function jvmTotalMemory_macro (param) {
|
||||
var m = java.lang.Runtime.getRuntime().totalMemory();
|
||||
return formatBytes(m);
|
||||
return (param && param.hr) ? formatBytes (m) : m;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Macro that returns the used memory in the java virtual machine
|
||||
* @param format if "hr", value will be printed human readable
|
||||
*/
|
||||
function jvmUsedMemory_macro() {
|
||||
var m = java.lang.Runtime.getRuntime().totalMemory() - java.lang.Runtime.getRuntime().freeMemory();
|
||||
return formatBytes(m);
|
||||
function jvmUsedMemory_macro(param) {
|
||||
var m = java.lang.Runtime.getRuntime ().totalMemory () - java.lang.Runtime.getRuntime ().freeMemory ();
|
||||
return (param && param.hr) ? formatBytes (m) : m;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -7,35 +7,40 @@
|
|||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">uptime:</td>
|
||||
<td class="list_property">uptime:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.uptime %></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">version:</td>
|
||||
<td class="list_property">version:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.version %></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">homedir:</td>
|
||||
<td class="list_property">homedir:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.home %></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200" valign="top">total active sessions:</td>
|
||||
<td class="list_property" valign="top">total active sessions:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.countSessions default=" " %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200" valign="top">total requests / 5 min:</td>
|
||||
<td class="list_property" nowrap valign="top">total requests / 5 min:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.countRequests default=" " %></td>
|
||||
<td class="list_property" align="left"><% this.requestCount default=" " %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200" valign="top">loaded extensions:</td>
|
||||
<td class="list_property" norwrap valign="top">total errors / 5 min:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.errorCount default=" " %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="list_property" valign="top">loaded extensions:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.extensions default=" " %></td>
|
||||
</tr>
|
||||
|
@ -45,51 +50,51 @@
|
|||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">free memory:</td>
|
||||
<td class="list_property">free memory:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.jvmFreeMemory %></td>
|
||||
<td class="list_property" align="left"><% this.jvmFreeMemory hr="true" %></td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">used memory:</td>
|
||||
<td class="list_property">used memory:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.jvmUsedMemory %></td>
|
||||
<td class="list_property" align="left"><% this.jvmUsedMemory hr="true" %></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">total memory:</td>
|
||||
<td class="list_property">total memory:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.jvmTotalMemory %></td>
|
||||
<td class="list_property" align="left"><% this.jvmTotalMemory hr="true" %></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">java:</td>
|
||||
<td class="list_property">java:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.jvm %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">javahome:</td>
|
||||
<td class="list_property">javahome:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.jvmHome %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">os:</td>
|
||||
<td class="list_property">os:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.os %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200">localtime:</td>
|
||||
<td class="list_property">localtime:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% now %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200" valign="top">timezone:</td>
|
||||
<td class="list_property" valign="top">timezone:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.timezone %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="list_property" align="right" width="200" valign="top">loaded Jars:</td>
|
||||
<td class="list_property" valign="top">loaded Jars:</td>
|
||||
<td class="list_property" width="5"> </td>
|
||||
<td class="list_property" align="left"><% this.jvmJars %></td>
|
||||
</tr>
|
||||
|
@ -98,7 +103,7 @@
|
|||
<td class="list_separator" colspan="3">server.properties</td>
|
||||
</tr>
|
||||
|
||||
<% this.properties itemprefix='<tr><td class="list_property" align="right" width="200">' separator='</td><td class="list_property" width="5"> </td><td class="list_property" align="left">' itemsuffix='</td></tr>' %>
|
||||
<% this.properties itemprefix='<tr><td class="list_property">' separator='</td><td class="list_property" width="5"> </td><td class="list_property" align="left">' itemsuffix='</td></tr>' %>
|
||||
</table>
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
|
||||
// strictly limit access to localhost:
|
||||
if ( req.data.http_remotehost!="localhost" && req.data.http_remotehost!="127.0.0.1" ) {
|
||||
app.__app__.logEvent( req.data.http_remotehost + " tried to access makekey");
|
||||
return;
|
||||
}
|
||||
//// strictly limit access to localhost:
|
||||
//if ( req.data.http_remotehost!="localhost" && req.data.http_remotehost!="127.0.0.1" ) {
|
||||
// app.logEvent( req.data.http_remotehost + " tried to access makekey");
|
||||
// return;
|
||||
//}
|
||||
|
||||
if ( checkAuth()==false ) return;
|
||||
if ( checkAuth()==false )
|
||||
return;
|
||||
|
||||
createAuth();
|
||||
|
||||
|
|
37
Root/mrtg.hac
Normal file
37
Root/mrtg.hac
Normal file
|
@ -0,0 +1,37 @@
|
|||
|
||||
/**
|
||||
* prints server-stats for mrtg-tool.
|
||||
* doesn't check username or password, so that we don't have
|
||||
* to write them cleartext in a mrtg-configfile but checks the
|
||||
* remote address.
|
||||
*/
|
||||
|
||||
if ( checkAddress()==false )
|
||||
return;
|
||||
|
||||
|
||||
if (req.data.action=="memory") {
|
||||
|
||||
res.write (this.jvmTotalMemory_macro () + "\n");
|
||||
res.write (this.jvmFreeMemory_macro () + "\n");
|
||||
res.write ("0\n0\n");
|
||||
|
||||
} else if (req.data.action=="netstat" && isLinux ()) {
|
||||
|
||||
var str = (new File("/proc/net/tcp")).readAll();
|
||||
var arr = str.split("\n");
|
||||
res.write (arr.length-2 + "\n");
|
||||
res.write ("0\n0\n0\n");
|
||||
|
||||
} else if (req.data.action=="loadavg" && isLinux ()) {
|
||||
|
||||
// load average of last 5 minutes:
|
||||
var str = (new File("/proc/loadavg")).readAll();
|
||||
var arr = str.split(" ");
|
||||
res.write (arr[1]*100 + "\n");
|
||||
res.write ("0\n0\n0\n");
|
||||
|
||||
} else {
|
||||
res.write ( "0\n0\n0\n0\n");
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue