From 7633e98eea2834e1e4bd330cddd5301902d5a4ae Mon Sep 17 00:00:00 2001 From: stefanp Date: Thu, 21 Nov 2002 18:36:03 +0000 Subject: [PATCH] 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. --- Application/macros.js | 54 ++++++-- Application/main.hac | 6 +- Application/main.skin | 40 ++++-- Application/mrtg.hac | 37 ++++-- Application/navig_active.skin | 5 +- DocApplication/actions.js | 95 ++++++++++++++ DocApplication/frameset.skin | 31 +++++ DocApplication/head.skin | 8 -- DocApplication/index.skin | 11 -- DocApplication/macros.js | 100 +++++++-------- DocApplication/main.hac | 23 ---- DocApplication/main.skin | 11 -- DocApplication/navig.skin | 14 --- DocApplication/prototypes.skin | 10 ++ DocApplication/summary.skin | 4 + DocFunction/actions.js | 8 ++ DocFunction/asLargeListItem.skin | 7 ++ DocFunction/asLargeListItemSkin.skin | 8 ++ DocFunction/asListItem.skin | 2 + DocFunction/asParentListItem.skin | 1 + DocFunction/functions.js | 7 -- DocFunction/indexList.skin | 5 - DocFunction/indexListSeparator.skin | 3 - DocFunction/listElementAction.skin | 7 -- DocFunction/listElementFunction.skin | 7 -- DocFunction/listElementMacro.skin | 9 -- DocFunction/listElementSkin.skin | 7 -- DocFunction/listElementTemplate.skin | 7 -- DocFunction/macros.js | 156 +++++++++-------------- DocFunction/main.hac | 8 -- DocFunction/main.skin | 35 +++++- DocPrototype/actions.js | 10 ++ DocPrototype/appList.skin | 10 -- DocPrototype/asInheritanceLink.skin | 1 + DocPrototype/asParentList.skin | 17 +++ DocPrototype/asPrototypeList.skin | 10 ++ DocPrototype/functions.js | 29 +++++ DocPrototype/list.skin | 11 ++ DocPrototype/listFooter.skin | 3 - DocPrototype/listHeader.skin | 7 -- DocPrototype/macros.js | 177 ++++++++++++++------------- DocPrototype/main.hac | 8 -- DocPrototype/main.skin | 86 ++++++++++++- DocPrototype/navig.skin | 2 - DocTag/author.skin | 2 + DocTag/deprecated.skin | 2 + DocTag/main.skin | 1 + DocTag/overrides.skin | 3 + DocTag/parameter.skin | 2 + DocTag/renderfunctions.js | 46 ------- DocTag/return.skin | 2 + DocTag/see.skin | 2 + Global/api.skin | 72 +++++++++-- Global/functions.js | 68 +++++----- Global/renderFunctions.js | 176 ++++++++++++++++++++++++++ Root/macros.js | 62 +++++++--- Root/main.skin | 45 ++++--- Root/makekey.hac | 13 +- Root/mrtg.hac | 37 ++++++ 59 files changed, 1052 insertions(+), 578 deletions(-) create mode 100644 DocApplication/actions.js create mode 100644 DocApplication/frameset.skin delete mode 100644 DocApplication/head.skin delete mode 100644 DocApplication/index.skin delete mode 100644 DocApplication/main.hac delete mode 100644 DocApplication/main.skin delete mode 100644 DocApplication/navig.skin create mode 100644 DocApplication/prototypes.skin create mode 100644 DocApplication/summary.skin create mode 100644 DocFunction/actions.js create mode 100644 DocFunction/asLargeListItem.skin create mode 100644 DocFunction/asLargeListItemSkin.skin create mode 100644 DocFunction/asListItem.skin create mode 100644 DocFunction/asParentListItem.skin delete mode 100644 DocFunction/functions.js delete mode 100644 DocFunction/indexList.skin delete mode 100644 DocFunction/indexListSeparator.skin delete mode 100644 DocFunction/listElementAction.skin delete mode 100644 DocFunction/listElementFunction.skin delete mode 100644 DocFunction/listElementMacro.skin delete mode 100644 DocFunction/listElementSkin.skin delete mode 100644 DocFunction/listElementTemplate.skin delete mode 100644 DocFunction/main.hac create mode 100644 DocPrototype/actions.js delete mode 100644 DocPrototype/appList.skin create mode 100644 DocPrototype/asInheritanceLink.skin create mode 100644 DocPrototype/asParentList.skin create mode 100644 DocPrototype/asPrototypeList.skin create mode 100644 DocPrototype/functions.js create mode 100644 DocPrototype/list.skin delete mode 100644 DocPrototype/listFooter.skin delete mode 100644 DocPrototype/listHeader.skin delete mode 100644 DocPrototype/main.hac delete mode 100644 DocPrototype/navig.skin create mode 100644 DocTag/author.skin create mode 100644 DocTag/deprecated.skin create mode 100644 DocTag/main.skin create mode 100644 DocTag/overrides.skin create mode 100644 DocTag/parameter.skin delete mode 100644 DocTag/renderfunctions.js create mode 100644 DocTag/return.skin create mode 100644 DocTag/see.skin create mode 100644 Global/renderFunctions.js create mode 100644 Root/mrtg.hac diff --git a/Application/macros.js b/Application/macros.js index 9eec3fe5..219a2a86 100644 --- a/Application/macros.js +++ b/Application/macros.js @@ -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 (); +} + diff --git a/Application/main.hac b/Application/main.hac index 016058d0..7faa81af 100644 --- a/Application/main.hac +++ b/Application/main.hac @@ -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"); diff --git a/Application/main.skin b/Application/main.skin index 4bc3e011..c689c6a9 100644 --- a/Application/main.skin +++ b/Application/main.skin @@ -1,42 +1,62 @@ <% this.skin name="head" %> - +
application
+ + - + - + - + - + - + - + - + + + + + + + + + + + - + + + -<% this.properties itemprefix='' % --> +
active sessions:active sessions   <% this.countSessions %>
?showusers=true">logged-in users:?showusers=true">logged-in users   <% this.users %> 
active evaluators:active evaluators   <% this.countActiveEvaluators %>
free evaluators:free evaluators   <% this.countFreeEvaluators %>
requests / 5 min:requests / 5 min  <% this.getRequestAvg %><% this.requestCount %>
uptime:errors / 5 min <% this.errorCount %>
cache usage <% this.cacheusage %> objects of <% this.cachesize %>
uptime   <% this.uptime %>
app.propertiesapp directory <% this.appdir %>
' separator=' ' itemsuffix='
+ + + + + +<% this.properties itemprefix='' %>
app.properties
' separator=' ' itemsuffix='
diff --git a/Application/mrtg.hac b/Application/mrtg.hac index fb324794..b6129f21 100644 --- a/Application/mrtg.hac +++ b/Application/mrtg.hac @@ -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") { -if ( req.data.action=="threads" ) { - res.write ( this.countActiveEvaluators() + "\n" + this.countFreeEvaluators() + "\n0\n0\n"); - return; + 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"); } + diff --git a/Application/navig_active.skin b/Application/navig_active.skin index afd05311..9bb568a8 100644 --- a/Application/navig_active.skin +++ b/Application/navig_active.skin @@ -2,14 +2,15 @@ "><% this.title %>
<% this.countSessions singular=" Session" plural=" Sessions" %>, <% this.getRequestAvg singular=" Request" plural=" Requests" %>/5min
- +
diff --git a/DocApplication/actions.js b/DocApplication/actions.js new file mode 100644 index 00000000..cbc1d907 --- /dev/null +++ b/DocApplication/actions.js @@ -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 ("renderrendering ... " + 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 + + helma api / <% this.name %> + + + + + +" name="prototypes"> +" name="functions"> + +" name="main"> + + +<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. + + + + diff --git a/DocApplication/head.skin b/DocApplication/head.skin deleted file mode 100644 index 56c9c797..00000000 --- a/DocApplication/head.skin +++ /dev/null @@ -1,8 +0,0 @@ -

AppDoc <% this.name %>

-

<% param.path %>

-

-> - AppManager | - ">public -

- - diff --git a/DocApplication/index.skin b/DocApplication/index.skin deleted file mode 100644 index 51fc7746..00000000 --- a/DocApplication/index.skin +++ /dev/null @@ -1,11 +0,0 @@ - -

AppDoc <% this.name %>

- - - - -<% this.index skin="indexList" %> -
- -
- diff --git a/DocApplication/macros.js b/DocApplication/macros.js index beb71311..d14126df 100644 --- a/DocApplication/macros.js +++ b/DocApplication/macros.js @@ -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( '' + this.name + '' ); -} - - -/** - * 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 - - - - - - <% this.prototypes skin="appList" %> -
Prototypes
- -
- diff --git a/DocApplication/navig.skin b/DocApplication/navig.skin deleted file mode 100644 index f639e52a..00000000 --- a/DocApplication/navig.skin +++ /dev/null @@ -1,14 +0,0 @@ -<% this.name %> - - - -

-

- Prototypes:
- <% this.prototypes skin="navig" %> -

- diff --git a/DocApplication/prototypes.skin b/DocApplication/prototypes.skin new file mode 100644 index 00000000..cdbcc472 --- /dev/null +++ b/DocApplication/prototypes.skin @@ -0,0 +1,10 @@ + + +Application " target="main"><% this.name %>

+ +<% this.prototypes %> + + + + + diff --git a/DocApplication/summary.skin b/DocApplication/summary.skin new file mode 100644 index 00000000..a030a136 --- /dev/null +++ b/DocApplication/summary.skin @@ -0,0 +1,4 @@ +

Application <% this.headline %>

+ +<% this.comment encoding="html" %> + diff --git a/DocFunction/actions.js b/DocFunction/actions.js new file mode 100644 index 00000000..b7ce0e01 --- /dev/null +++ b/DocFunction/actions.js @@ -0,0 +1,8 @@ +function main_action () { + this.getParentElement ().readFiles (); + res.data.body = this.renderSkinAsString ("main"); + renderSkin ("api"); +} + + + diff --git a/DocFunction/asLargeListItem.skin b/DocFunction/asLargeListItem.skin new file mode 100644 index 00000000..584d72f1 --- /dev/null +++ b/DocFunction/asLargeListItem.skin @@ -0,0 +1,7 @@ + +" target="main"><% this.link %>
+<% this.comment length="200" %> + + + + diff --git a/DocFunction/asLargeListItemSkin.skin b/DocFunction/asLargeListItemSkin.skin new file mode 100644 index 00000000..c659c611 --- /dev/null +++ b/DocFunction/asLargeListItemSkin.skin @@ -0,0 +1,8 @@ + +" target="main"><% this.link %>
+<% this.comment length="200" %> +<% this.skinparameters separator=", "%> + + + + diff --git a/DocFunction/asListItem.skin b/DocFunction/asListItem.skin new file mode 100644 index 00000000..30df0ea1 --- /dev/null +++ b/DocFunction/asListItem.skin @@ -0,0 +1,2 @@ +<% this.link %>
+ diff --git a/DocFunction/asParentListItem.skin b/DocFunction/asParentListItem.skin new file mode 100644 index 00000000..0822c4cc --- /dev/null +++ b/DocFunction/asParentListItem.skin @@ -0,0 +1 @@ +<% this.link %> \ No newline at end of file diff --git a/DocFunction/functions.js b/DocFunction/functions.js deleted file mode 100644 index c903ff5f..00000000 --- a/DocFunction/functions.js +++ /dev/null @@ -1,7 +0,0 @@ - - -function getApplication() { - return this.getParentElement().getParentElement(); -} - - diff --git a/DocFunction/indexList.skin b/DocFunction/indexList.skin deleted file mode 100644 index 3c0bc71f..00000000 --- a/DocFunction/indexList.skin +++ /dev/null @@ -1,5 +0,0 @@ - - <% this.name %> - <% this.typename %> in <% this.prototypename %> - ("><% this.prototypename %>/<% this.location %>) - diff --git a/DocFunction/indexListSeparator.skin b/DocFunction/indexListSeparator.skin deleted file mode 100644 index f8d0edd0..00000000 --- a/DocFunction/indexListSeparator.skin +++ /dev/null @@ -1,3 +0,0 @@ - -  <% param.letter %> - diff --git a/DocFunction/listElementAction.skin b/DocFunction/listElementAction.skin deleted file mode 100644 index 67c5da69..00000000 --- a/DocFunction/listElementAction.skin +++ /dev/null @@ -1,7 +0,0 @@ - - -  <% param.group %> -
- "><% this.name %>
<% this.comment %>
<% this.tags %>
- - diff --git a/DocFunction/listElementFunction.skin b/DocFunction/listElementFunction.skin deleted file mode 100644 index 67686f30..00000000 --- a/DocFunction/listElementFunction.skin +++ /dev/null @@ -1,7 +0,0 @@ - - -  <% param.group %> -
- "><% this.name %> (<% this.args %>) in <% docprototype.name %>/<% this.location %>
<% this.comment %>
<% this.tags %>
- - diff --git a/DocFunction/listElementMacro.skin b/DocFunction/listElementMacro.skin deleted file mode 100644 index 52a10dbd..00000000 --- a/DocFunction/listElementMacro.skin +++ /dev/null @@ -1,9 +0,0 @@ - - -  <% param.group %> -
- "><% docprototype.name %>.<% this.name %> - in <% docprototype.name %>/<% this.location %> -
<% this.comment %>
<% this.tags %>
- - diff --git a/DocFunction/listElementSkin.skin b/DocFunction/listElementSkin.skin deleted file mode 100644 index 71185419..00000000 --- a/DocFunction/listElementSkin.skin +++ /dev/null @@ -1,7 +0,0 @@ - - -  <% param.group %> -
- "><% docprototype.name %>.<% this.name %>
<% this.comment %>
<% this.tags %>
- - diff --git a/DocFunction/listElementTemplate.skin b/DocFunction/listElementTemplate.skin deleted file mode 100644 index 81893dd8..00000000 --- a/DocFunction/listElementTemplate.skin +++ /dev/null @@ -1,7 +0,0 @@ - - -  <% param.group %> -
- "><% this.name %>()
<% this.comment %>
<% this.tags %>
- - diff --git a/DocFunction/macros.js b/DocFunction/macros.js index 24b45320..679de5ba 100644 --- a/DocFunction/macros.js +++ b/DocFunction/macros.js @@ -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-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 ' - if ( i<100 ) str4+=' '; + if (i<99) str4+=' '; + if (i<9) str4+=' '; str4 += arr[i] + "
"; } return ( str4 ); } -/** - * macro returning the fullname of this method - */ -function fullname_macro(par) { - return this.getFullName(); -} - diff --git a/DocFunction/main.hac b/DocFunction/main.hac deleted file mode 100644 index 6faae50d..00000000 --- a/DocFunction/main.hac +++ /dev/null @@ -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"); - - diff --git a/DocFunction/main.skin b/DocFunction/main.skin index 26420fb2..f9546829 100644 --- a/DocFunction/main.skin +++ b/DocFunction/main.skin @@ -1,9 +1,34 @@ -<% this.head %> + + + + -
- in <% docprototype.name%>/<% this.location %>: -
+ + + +
+ <% this.headline %>
+
+ <% this.comment suffix="

" %> + <% this.skinparameters prefix="general parameters used in this skin:
  • " separator="
  • " suffix="

" %> +
    + <% 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" %> +
+
+ + + + + + +
Sourcecode in <% this.location %>: +
<% this.source %>
+
-
<% this.source %>
diff --git a/DocPrototype/actions.js b/DocPrototype/actions.js new file mode 100644 index 00000000..62ee1460 --- /dev/null +++ b/DocPrototype/actions.js @@ -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"); +} + diff --git a/DocPrototype/appList.skin b/DocPrototype/appList.skin deleted file mode 100644 index e132ca63..00000000 --- a/DocPrototype/appList.skin +++ /dev/null @@ -1,10 +0,0 @@ - - -  Prototype -
- "><% this.name %>
- <% this.comment %> -
- - - diff --git a/DocPrototype/asInheritanceLink.skin b/DocPrototype/asInheritanceLink.skin new file mode 100644 index 00000000..42449c89 --- /dev/null +++ b/DocPrototype/asInheritanceLink.skin @@ -0,0 +1 @@ +extends Prototype "><% this.name %> \ No newline at end of file diff --git a/DocPrototype/asParentList.skin b/DocPrototype/asParentList.skin new file mode 100644 index 00000000..cfdc8989 --- /dev/null +++ b/DocPrototype/asParentList.skin @@ -0,0 +1,17 @@ + +Inherited from prototype <% this.link %>:
+ + + +<% this.methods separator=", " filter="actions" skin="asParentListItem" prefix="Actions: " suffix="
" %> +<% this.methods separator=", " filter="functions" skin="asParentListItem" prefix="Functions: " suffix="
" %> +<% this.methods separator=", " filter="macros" skin="asParentListItem" prefix="Macros: " suffix="
" %> +<% this.methods separator=", " filter="skins" skin="asParentListItem" prefix="Skins: " suffix="
" %> +<% this.methods separator=", " filter="templates" skin="asParentListItem" prefix="Templates: " suffix="
" %> + + + + + + + diff --git a/DocPrototype/asPrototypeList.skin b/DocPrototype/asPrototypeList.skin new file mode 100644 index 00000000..0f3762aa --- /dev/null +++ b/DocPrototype/asPrototypeList.skin @@ -0,0 +1,10 @@ + +" onClick="parent.changePrototypeList(this);" target="main"><% this.name %> + +<% + this.inheritance action="main" target="main" + onClick="parent.changePrototypeList(this);" hopobject="false" + prefix=" (extends " suffix=")" +%> + +
diff --git a/DocPrototype/functions.js b/DocPrototype/functions.js new file mode 100644 index 00000000..c0bb39c9 --- /dev/null +++ b/DocPrototype/functions.js @@ -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 += '/' + this.name + ''; +// 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; +} + + diff --git a/DocPrototype/list.skin b/DocPrototype/list.skin new file mode 100644 index 00000000..afb66787 --- /dev/null +++ b/DocPrototype/list.skin @@ -0,0 +1,11 @@ +

Prototype " target="main"><% this.name %>

+<% this.inheritance action="list" %> +<% this.inheritance deep="true" hopobject="true" action="main" target="main" onClick="parent.changePrototypeList(this);" separator=", " prefix="extends: " suffix="
" %>
+ + +<% this.methods filter="actions" skin="asListItem" prefix="

Actions:
" suffix="

%> +<% this.methods filter="functions" skin="asListItem" prefix="

Functions:
" suffix="

%> +<% this.methods filter="macros" skin="asListItem" prefix="

Macros:
" suffix="

%> +<% this.methods filter="skins" skin="asListItem" prefix="

Skins:
" suffix="

%> +<% this.methods filter="templates" skin="asListItem" prefix="

Templates:
" suffix="

%> + diff --git a/DocPrototype/listFooter.skin b/DocPrototype/listFooter.skin deleted file mode 100644 index d3f6097b..00000000 --- a/DocPrototype/listFooter.skin +++ /dev/null @@ -1,3 +0,0 @@ - -
- diff --git a/DocPrototype/listHeader.skin b/DocPrototype/listHeader.skin deleted file mode 100644 index bbe57421..00000000 --- a/DocPrototype/listHeader.skin +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/DocPrototype/macros.js b/DocPrototype/macros.js index 4334e1bf..9d509458 100644 --- a/DocPrototype/macros.js +++ b/DocPrototype/macros.js @@ -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 += '/' + this.name + ''; - 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; i0) + 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 () + ""); + 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 ()); + } +} + diff --git a/DocPrototype/main.hac b/DocPrototype/main.hac deleted file mode 100644 index 77ebcb02..00000000 --- a/DocPrototype/main.hac +++ /dev/null @@ -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"); - - diff --git a/DocPrototype/main.skin b/DocPrototype/main.skin index 20cc8ec5..ec24d999 100644 --- a/DocPrototype/main.skin +++ b/DocPrototype/main.skin @@ -1,8 +1,82 @@ -<% this.head %> +
<% param.desc %>
+ + + +
+ Prototype <% this.headline %>
+ <% this.inheritance deep="true" hopobject="true" action="main" target="main" onClick="parent.changePrototypeList(this);" separator=", " prefix="extends: " suffix="
" %> +
+ +ACTIONS | +FUNCTIONS | +MACROS | +SKINS | +TEMPLATES | +TYPE.PROPERTIES + + + + + + + +
+ <% this.comment suffix="

" %> +
    + <% this.tags type="author" skin="author" %> + <% this.tags type="see" skin="see" %> + <% this.tags type="deprecated" skin="deprecated" %> + <% this.tags type="overrides" skin="overrides" %> +
+
+ + + + <% this.methods separator="" + filter="actions" + skin="asLargeListItem" + prefix="" + %> + + <% this.methods separator="" + filter="functions" + skin="asLargeListItem" + prefix="" + %> + + <% this.methods separator="" + filter="macros" + skin="asLargeListItem" + prefix="" + %> + + <% this.methods separator="" + filter="skins" + skin="asLargeListItemSkin" + prefix="" + %> + + <% this.methods separator="" + filter="templates" + skin="asLargeListItem" + prefix="" + %> + + <% this.parentPrototype skin="asParentList" %> +
Actions
Functions
Macros
Skins
Templates
+ +

+ + + + + +
type.properties
<% this.typeProperties prefix="
" suffix="
" %>
+ + + + + + -<% this.actions %> -<% this.skins %> -<% this.macros %> -<% this.functions %> -<% this.templates %> diff --git a/DocPrototype/navig.skin b/DocPrototype/navig.skin deleted file mode 100644 index cc6f041f..00000000 --- a/DocPrototype/navig.skin +++ /dev/null @@ -1,2 +0,0 @@ - -"><% this.name %>
diff --git a/DocTag/author.skin b/DocTag/author.skin new file mode 100644 index 00000000..c319829d --- /dev/null +++ b/DocTag/author.skin @@ -0,0 +1,2 @@ +
  • Author
    +<% this.text %> \ No newline at end of file diff --git a/DocTag/deprecated.skin b/DocTag/deprecated.skin new file mode 100644 index 00000000..57cb4d4e --- /dev/null +++ b/DocTag/deprecated.skin @@ -0,0 +1,2 @@ +
  • Deprecated
    +<% this.text %> diff --git a/DocTag/main.skin b/DocTag/main.skin new file mode 100644 index 00000000..dca81089 --- /dev/null +++ b/DocTag/main.skin @@ -0,0 +1 @@ +
  • <% this.text %> \ No newline at end of file diff --git a/DocTag/overrides.skin b/DocTag/overrides.skin new file mode 100644 index 00000000..4616af7f --- /dev/null +++ b/DocTag/overrides.skin @@ -0,0 +1,3 @@ +
  • Overrides
    +<% param.link %> + diff --git a/DocTag/parameter.skin b/DocTag/parameter.skin new file mode 100644 index 00000000..deeed157 --- /dev/null +++ b/DocTag/parameter.skin @@ -0,0 +1,2 @@ +
  • Parameter <% this.name %>:
    +<% this.text %> \ No newline at end of file diff --git a/DocTag/renderfunctions.js b/DocTag/renderfunctions.js deleted file mode 100644 index ede11b25..00000000 --- a/DocTag/renderfunctions.js +++ /dev/null @@ -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 = "arg" + argCt + ": " + format(this.text); - } else if ( this.getKind() == this.PARAM ) { - str = "Parameter " + this.name; - if ( this.text!=null && this.text!="" ) { - str += ": " + format(this.text); - } - } else if ( this.getKind() == this.RETURNS ) { - str = "Returns: " + format(this.text); - } else if ( this.getKind() == this.AUTHOR ) { - str = "by " + format(this.text) + ""; - } else if ( this.getKind() == this.VERSION ) { - str = "Version " + format(this.text) + ""; - } else if ( this.getKind() == this.RELEASE ) { - str = "since" + format(this.text) + ""; - } else if ( this.getKind() == this.SEE ) { - if ( this.text.indexOf("http://")==0 ) { - str = '' + this.text + ''; - } 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 = 'See also: ' + format(tmp) + ''; - } else if ( obj!=null ) { - str = 'See also: ' + format(tmp) + ''; - } - } - if ( str=="" ) { - str = "See also: " + format(this.text); - } - } - return str + "
    "; -} - - - diff --git a/DocTag/return.skin b/DocTag/return.skin new file mode 100644 index 00000000..a421d33c --- /dev/null +++ b/DocTag/return.skin @@ -0,0 +1,2 @@ +
  • Returns
    +<% this.text %> diff --git a/DocTag/see.skin b/DocTag/see.skin new file mode 100644 index 00000000..5e66957d --- /dev/null +++ b/DocTag/see.skin @@ -0,0 +1,2 @@ +
  • See also
    +<% param.link %> diff --git a/Global/api.skin b/Global/api.skin index d152e04d..9fb798d9 100644 --- a/Global/api.skin +++ b/Global/api.skin @@ -1,17 +1,67 @@ - -<% skin name="head" %> + + + + + + + - - - - - -
    -

    ">" title="helma" border="0" width="174" height="35" align="baseline" style="border-width:3px;border-color:white;">

    - <% docapplication.skin name="navig" %>
    <% response.body %>
    - +<% response.body %> diff --git a/Global/functions.js b/Global/functions.js index 578ef6eb..5e678c23 100644 --- a/Global/functions.js +++ b/Global/functions.js @@ -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; ib.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); +} + + + + diff --git a/Global/renderFunctions.js b/Global/renderFunctions.js new file mode 100644 index 00000000..c8c17ea7 --- /dev/null +++ b/Global/renderFunctions.js @@ -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'; +} + + + + +function renderLinkTag (param) { + var sb = new java.lang.StringBuffer (); + 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' + text + ''; + } 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 '' + format (tmp) + '' + text; + } + // try to find a function object: + var arr = protoObj.listChildren (); + for (var i=0; i' + format(tmp) + '' + 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; +} + diff --git a/Root/macros.js b/Root/macros.js index 8108ec3f..fe3c30de 100644 --- a/Root/macros.js +++ b/Root/macros.js @@ -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 - uptime: + uptime:   <% this.uptime %> - version: + version:   <% this.version %> - homedir: + homedir:   <% this.home %> - total active sessions: + total active sessions:   <% this.countSessions default=" " %> - total requests / 5 min: + total requests / 5 min:   - <% this.countRequests default=" " %> + <% this.requestCount default=" " %> - loaded extensions: + total errors / 5 min: +   + <% this.errorCount default=" " %> + + + loaded extensions:   <% this.extensions default=" " %> @@ -45,51 +50,51 @@ - free memory: + free memory:   - <% this.jvmFreeMemory %> + <% this.jvmFreeMemory hr="true" %> - used memory: + used memory:   - <% this.jvmUsedMemory %> + <% this.jvmUsedMemory hr="true" %> - total memory: + total memory:   - <% this.jvmTotalMemory %> + <% this.jvmTotalMemory hr="true" %> - java: + java:   <% this.jvm %> - javahome: + javahome:   <% this.jvmHome %> - os: + os:   <% this.os %> - localtime: + localtime:   <% now %> - timezone: + timezone:   <% this.timezone %> - loaded Jars: + loaded Jars:   <% this.jvmJars %> @@ -98,7 +103,7 @@ server.properties -<% this.properties itemprefix='' separator=' ' itemsuffix='' %> +<% this.properties itemprefix='' separator=' ' itemsuffix='' %> diff --git a/Root/makekey.hac b/Root/makekey.hac index 1ba50f12..4800e2e4 100644 --- a/Root/makekey.hac +++ b/Root/makekey.hac @@ -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(); diff --git a/Root/mrtg.hac b/Root/mrtg.hac new file mode 100644 index 00000000..44b672c8 --- /dev/null +++ b/Root/mrtg.hac @@ -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"); +} +