From 437dfb94d3adab49d5176680d5998c5ef29de1e3 Mon Sep 17 00:00:00 2001 From: hns Date: Wed, 31 Aug 2005 13:16:21 +0000 Subject: [PATCH] * Bring manage app up to date with current Helma. --- Application/actions.js | 67 +++++++ Application/functions.js | 25 ++- Application/macros.js | 176 +++++++++--------- Application/main.hac | 12 -- Application/main.skin | 4 +- Application/mrtg.hac | 42 ----- Application/redirectpublic.hac | 10 - DocApplication/actions.js | 88 ++++----- DocApplication/functions.js | 135 +++++++------- DocApplication/macros.js | 127 +++++++------ DocFunction/actions.js | 14 +- DocFunction/macros.js | 170 +++++++++-------- DocPrototype/actions.js | 28 +-- DocPrototype/asParentList.skin | 1 - DocPrototype/functions.js | 32 ++-- DocPrototype/list.skin | 1 - DocPrototype/macros.js | 225 ++++++++++++----------- DocPrototype/main.skin | 9 +- DocPrototype/typeproperties.skin | 2 +- Global/functions.js | 303 +++++++++++++++---------------- Global/macros.js | 12 +- Global/navig.skin | 4 +- Global/renderFunctions.js | 264 +++++++++++++-------------- Root/actions.js | 130 +++++++++++++ Root/functions.js | 39 ++-- Root/image.hac | 11 -- Root/macros.js | 273 ++++++++++++++-------------- Root/main.hac | 44 ----- Root/makekey.hac | 33 ---- Root/mrtg.hac | 37 ---- app.properties | 4 +- class.properties | 13 +- readme.txt | 2 +- 33 files changed, 1185 insertions(+), 1152 deletions(-) create mode 100644 Application/actions.js delete mode 100644 Application/main.hac delete mode 100644 Application/mrtg.hac delete mode 100644 Application/redirectpublic.hac create mode 100644 Root/actions.js delete mode 100644 Root/image.hac delete mode 100644 Root/main.hac delete mode 100644 Root/makekey.hac delete mode 100644 Root/mrtg.hac diff --git a/Application/actions.js b/Application/actions.js new file mode 100644 index 00000000..ddbedc75 --- /dev/null +++ b/Application/actions.js @@ -0,0 +1,67 @@ +/** +* renders AppManager +*/ +function main_action() { + if (checkAddress() == false) + return; + if (checkAuth(this) == false) + return; + + res.data.body = this.renderSkinAsString("main"); + renderSkin("global"); +} + + +/** +* 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 but checks the +* remote address. +*/ +function mrtg_action() { + 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()); + 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"); + } + +} + +/** +* performs a redirect to the public site +* (workaround, we can't access application object from docapplication for some reason) +* @see application.url_macro +*/ +function redirectpublic_action() { + if (checkAddress() == false) return; + if (checkAuth(this) == false) return; + + res.redirect(this.url_macro()); +} diff --git a/Application/functions.js b/Application/functions.js index 63d7278f..cdf0af56 100644 --- a/Application/functions.js +++ b/Application/functions.js @@ -1,29 +1,28 @@ - /** - * construct an application object so that we can use - * skins for non-active applications too - * @arg name - */ -function constructor(name) { - this.name = name; +* construct an application object so that we can use +* skins for non-active applications too +* @arg name +*/ +function constructor(name) { + this.name = name; } /** * of no use, just to avoid error message */ -function onRequest () { +function onRequest() { } /** * return true/false to determine if application is running */ -function isActive() { - if ( root.getApplication(this.name)==null ) - return false; - else - return true; +function isActive() { + if (root.getApplication(this.name) == null) + return false; + else + return true; } diff --git a/Application/macros.js b/Application/macros.js index 219a2a86..22c32903 100644 --- a/Application/macros.js +++ b/Application/macros.js @@ -2,10 +2,10 @@ * macro rendering a skin * @param name name of skin */ -function skin_macro(par) { - if ( par && par.name ) { - this.renderSkin(par.name); - } +function skin_macro(par) { + if (par && par.name) { + this.renderSkin(par.name); + } } @@ -13,8 +13,8 @@ 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(par) { + return this.href((par && par.action) ? par.action : "main"); } @@ -24,12 +24,12 @@ function href_macro(par) { * the application (which is using baseURI if set) */ function url_macro() { - var str = this.getProperty("absoluteuri"); - if ( str!=null && str!="" ) { - return str; - } else { - return this.getRootHref(); - } + var str = this.getProperty("absoluteuri"); + if (str != null && str != "") { + return str; + } else { + return this.getRootHref(); + } } @@ -37,8 +37,8 @@ function url_macro() { * Macro returning the title of an application */ function title_macro() { - var title = this.name; - return(title); + var title = this.name; + return(title); } @@ -49,25 +49,25 @@ function title_macro() { * @param Object Macro parameter object */ function description_macro(param) { - var str = ""; - var appHome = this.getAppDir(); - var f = new File(this.getAppDir().toString(), "description.txt"); - if (!f.exists()) - f = new File(this.getAppDir().toString(), "doc.html"); - if (f.exists()) { - str = f.readAll(); - if (str.length > 200) - str = str.substring(0, 200) + "..."; - } - return(str); + var str = ""; + var appHome = this.getAppDir(); + var f = new File(this.getAppDir().toString(), "description.txt"); + if (!f.exists()) + f = new File(this.getAppDir().toString(), "doc.html"); + if (f.exists()) { + str = f.readAll(); + if (str.length > 200) + str = str.substring(0, 200) + "..."; + } + return(str); } /** * Macro returning the server's uptime nicely formatted */ -function uptime_macro() { - return formatAge( (java.lang.System.currentTimeMillis()-this.starttime) / 1000 ); +function uptime_macro() { + return formatAge((java.lang.System.currentTimeMillis() - this.starttime) / 1000); } @@ -76,11 +76,11 @@ function uptime_macro() { * parameter used by global.formatCount * @see global.formatCount */ -function countSessions_macro(par) { - if ( this.isActive()==true ) - return this.sessions.size() + formatCount(this.sessions.size(),par); - else - return 0; +function countSessions_macro(par) { + if (this.isActive() == true) + return this.sessions.size() + formatCount(this.sessions.size(), par); + else + return 0; } @@ -91,12 +91,12 @@ function countSessions_macro(par) { * @see application.countUsers_macro * @see application.listUsers_macro */ -function users_macro(par) { - if ( req.data.showusers=="true" ) { - this.listUsers_macro(par); - } else { - this.countUsers_macro(par); - } +function users_macro(par) { + if (req.data.showusers == "true") { + this.listUsers_macro(par); + } else { + this.countUsers_macro(par); + } } @@ -106,11 +106,11 @@ function users_macro(par) { * parameter used by global.formatCount * @see global.formatCount */ -function countUsers_macro(par) { - if ( this.isActive()==true ) - return this.activeUsers.size() + formatCount(this.activeUsers.size(),par); - else - return 0; +function countUsers_macro(par) { + if (this.isActive() == true) + return this.activeUsers.size() + formatCount(this.activeUsers.size(), par); + else + return 0; } @@ -118,93 +118,93 @@ function countUsers_macro(par) { * Macro rendering the list of logged-in users if application is active * @param separator html-code written between elements */ -function listUsers_macro(par) { - var separator = (par && par.separator) ? par.separator : ", "; - if ( this.activeUsers.size()==0 ) - return ""; - var e = this.activeUsers.keys(); - while ( e.hasMoreElements() ) { - res.write ( e.nextElement() ); - if ( e.hasMoreElements() ) { - res.write ( separator ); - } - } +function listUsers_macro(par) { + var separator = (par && par.separator) ? par.separator : ", "; + if (this.activeUsers.size() == 0) + return ""; + var users = this.activeUsers.iterator(); + while (users.hasNext()) { + res.write(users.next().__name__); + if (users.hasNext()) { + res.write(separator); + } + } } /** * Macro returning the number of active evaluators (=threads) */ -function countActiveEvaluators_macro() { - return this.countActiveEvaluators(); +function countActiveEvaluators_macro() { + return this.countActiveEvaluators(); } /** * Macro returning the number of free evaluators (=threads) */ -function countFreeEvaluators_macro() { - return this.countFreeEvaluators(); +function countFreeEvaluators_macro() { + return this.countFreeEvaluators(); } /** * Macro returning the current number of objects in the cache */ -function cacheusage_macro (param) { - return this.getCacheUsage (); +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"); +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); - } +function requestCount_macro(par) { + if (app.data.stat == null || app.data.stat[this.name] == null) + return "not available"; + if (this.isActive()) { + var obj = app.data.stat[this.name]; + return obj.requestCount + formatCount(obj.requestCount, par); + } else { + 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); - } +function errorCount_macro(par) { + if (app.data.stat == null || app.data.stat[this.name] == null) + return "not available"; + if (this.isActive()) { + var obj = app.data.stat[this.name]; + return obj.errorCount + formatCount(obj.errorCount, par); + } else { + return 0 + formatCount(0, par); + } } - - /** - * Macro formatting app.properties - */ -function properties_macro(par) { - formatProperties( this.getProperties(), par ); +* Macro formatting app.properties +*/ +function properties_macro(par) { + formatProperties(this.getProperties(), par); } -function appdir_macro (param) { - return this.getAppDir ().toString (); +function repositories_macro(param) { + var repos = this.getRepositories().iterator(); + while (repos.hasNext()) + res.writeln(repos.next().getName()); } diff --git a/Application/main.hac b/Application/main.hac deleted file mode 100644 index 7faa81af..00000000 --- a/Application/main.hac +++ /dev/null @@ -1,12 +0,0 @@ -/** - * renders AppManager - */ - -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 c689c6a9..455e77d2 100644 --- a/Application/main.skin +++ b/Application/main.skin @@ -47,9 +47,9 @@ <% this.uptime %> - app directory + repositories   - <% this.appdir %> + <% this.repositories %> diff --git a/Application/mrtg.hac b/Application/mrtg.hac deleted file mode 100644 index b6129f21..00000000 --- a/Application/mrtg.hac +++ /dev/null @@ -1,42 +0,0 @@ - -/** - * 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 but checks the - * remote address. - */ - -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()); - 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/redirectpublic.hac b/Application/redirectpublic.hac deleted file mode 100644 index 7ead5169..00000000 --- a/Application/redirectpublic.hac +++ /dev/null @@ -1,10 +0,0 @@ -/** - * performs a redirect to the public site - * (workaround, we can't access application object from docapplication for some reason) - * @see application.url_macro - */ - -if ( checkAddress()==false ) return; -if ( checkAuth(this)==false ) return; - -res.redirect ( this.url_macro() ); diff --git a/DocApplication/actions.js b/DocApplication/actions.js index 573947a5..7c1efcfa 100644 --- a/DocApplication/actions.js +++ b/DocApplication/actions.js @@ -1,59 +1,59 @@ -function read_action () { - this.readApplication (); - res.redirect (this.href("main")); +function read_action() { + this.readApplication(); + res.redirect(this.href("main")); } -function main_action () { - if (checkAddress()==false) - return; - if (checkAuth(this.getParentElement ())==false) - return; - this.renderSkin ("frameset"); +function main_action() { + if (checkAddress() == false) + return; + if (checkAuth(this.getParentElement()) == false) + return; + this.renderSkin("frameset"); } -function prototypes_action () { - if (checkAddress()==false) - return; - if (checkAuth(this.getParentElement ())==false) - return; - res.data.body = this.renderSkinAsString ("prototypes"); - renderSkin ("api"); +function prototypes_action() { + if (checkAddress() == false) + return; + if (checkAuth(this.getParentElement()) == false) + return; + res.data.body = this.renderSkinAsString("prototypes"); + renderSkin("api"); } -function summary_action () { - if (checkAddress()==false) - return; - if (checkAuth(this.getParentElement ())==false) - return; - res.data.body = this.renderSkinAsString ("summary"); - renderSkin ("api"); +function summary_action() { + if (checkAddress() == false) + return; + if (checkAuth(this.getParentElement()) == false) + return; + res.data.body = this.renderSkinAsString("summary"); + renderSkin("api"); } -function functionindex_action () { - if (checkAddress()==false) - return; - if (checkAuth(this.getParentElement ())==false) - return; - res.data.body = this.renderSkinAsString ("functionindex"); - renderSkin ("api"); +function functionindex_action() { + if (checkAddress() == false) + return; + if (checkAuth(this.getParentElement()) == false) + return; + res.data.body = this.renderSkinAsString("functionindex"); + renderSkin("api"); } -function render_action () { - // set res.data.rendering, this will suppress the link back to the manage - // console in the apidocs actions - res.data.rendering = true; - if (checkAddress()==false) - return; - if (checkAuth(this.getParentElement ())==false) - return; - var ct = this.renderApi(); - res.data.body = 'rendering API ...
wrote ' + ct + ' files

'; - res.data.body += 'back to manage console'; - res.data.title = "rendering helma api"; - res.data.head = renderSkinAsString("head"); - renderSkin ("basic"); +function render_action() { + // set res.data.rendering, this will suppress the link back to the manage + // console in the apidocs actions + res.data.rendering = true; + if (checkAddress() == false) + return; + if (checkAuth(this.getParentElement()) == false) + return; + var ct = this.renderApi(); + res.data.body = 'rendering API ...
wrote ' + ct + ' files

'; + res.data.body += 'back to manage console'; + res.data.title = "rendering helma api"; + res.data.head = renderSkinAsString("head"); + renderSkin("basic"); } diff --git a/DocApplication/functions.js b/DocApplication/functions.js index 14393695..e3769a61 100644 --- a/DocApplication/functions.js +++ b/DocApplication/functions.js @@ -1,90 +1,89 @@ - /** - * get the prototype of any doc-object (either a prototype, a function or a tag) - */ -function getDocPrototype (obj) { - var tmp = obj; - while (tmp!=null && tmp.getType () != this.PROTOTYPE) { - tmp = tmp.getParentElement (); - } - return tmp; +* get the prototype of any doc-object (either a prototype, a function or a tag) +*/ +function getDocPrototype(obj) { + var tmp = obj; + while (tmp != null && tmp.getType() != this.PROTOTYPE) { + tmp = tmp.getParentElement(); + } + return tmp; } /** * get a prototype of this docapplication, ie get on of the children of this object */ -function getPrototype (name) { - return this.getChildElement ("prototype_" + name); +function getPrototype(name) { + return this.getChildElement("prototype_" + name); } -function getDir (dir, obj) { - dir.mkdir (); - if (obj.getType () == this.APPLICATION) { - return dir; - } else { - var protoObj = this.getDocPrototype (obj); - var dir = new File (dir, protoObj.getElementName ()); - dir.mkdir (); - return dir; - } +function getDir(dir, obj) { + dir.mkdir(); + if (obj.getType() == this.APPLICATION) { + return dir; + } else { + var protoObj = this.getDocPrototype(obj); + var dir = new File (dir, protoObj.getElementName()); + dir.mkdir(); + return dir; + } } function renderApi() { - var prefix = this.href (""); - this.storePage (this, "main", "", "index.html"); - this.storePage (this, "prototypes"); - this.storePage (this, "summary"); - this.storePage (this, "functionindex"); - var ct = 4; - var arr = this.listChildren (); - for (var i=0; iback to manage console'); - } +function linkToManage_macro(param) { + if (res.data.rendering != true) { + return ('back to manage console'); + } } -function headline_macro (param) { - res.write (this.getName ()); +function headline_macro(param) { + res.write(this.getName()); } - -function hrefRoot_macro (param) { - var obj = this.getChildElement ("prototype_root"); - if (obj == null) { - var obj = this.getChildElement ("prototype_Root"); - } - if (obj!=null) { - var action = (param.action) ? param.action : "main"; - return obj.href (action); - } +function hrefRoot_macro(param) { + var obj = this.getChildElement("prototype_root"); + if (obj == null) { + var obj = this.getChildElement("prototype_Root"); + } + if (obj != null) { + var action = (param.action) ? param.action : "main"; + return obj.href(action); + } } @@ -54,15 +67,15 @@ function hrefRoot_macro (param) { * @param skin name of skin to render on prototype * @param separator */ -function prototypes_macro(param) { - var skin = (param.skin) ? param.skin : "asPrototypeList"; - var separator = (param.separator) ? param.separator : ""; - var arr = this.listChildren (); - 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"); - } +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"); + } else if (this.getType() == this.PROPERTIES) { + res.write(this.getName()); + } } -function skinparameters_macro (param) { - if (this.getType () == this.SKIN) { - this.parameters_macro (param); - } +function skinparameters_macro(param) { + if (this.getType() == this.SKIN) { + this.parameters_macro(param); + } } -function parameters_macro (param) { - var separator = (param.separator) ? param.separator : ", "; - var arr = this.listParameters (); - for (var i=0; i<%'); - r = new RegExp("%>","gim"); + r = new RegExp("%>", "gim"); sourcecode = sourcecode.replace(r, '%>'); // highlight js-comments @@ -113,24 +125,24 @@ function source_macro(param) { } // remove all CR and LF, just
remains - var r = new RegExp("[\\r\\n]","gm"); + var r = new RegExp("[\\r\\n]", "gm"); sourcecode = sourcecode.replace(r, ""); - var arr = sourcecode.split("
"); - for (var i=0; i' + (i+1) + ': '); - if (i<99) { - res.write(' '); - } - if (i<9) { - res.write(' '); - } - res.write(arr[i] + "\n"); - } + var arr = sourcecode.split("
"); + for (var i = 0; i < arr.length; i++) { + res.write('' + (i + 1) + ': '); + if (i < 99) { + res.write(' '); + } + if (i < 9) { + res.write(' '); + } + res.write(arr[i] + "\n"); + } - } else { - res.write(sourcecode); - } + } else { + res.write(sourcecode); + } } diff --git a/DocPrototype/actions.js b/DocPrototype/actions.js index 853c8b66..a9b9c873 100644 --- a/DocPrototype/actions.js +++ b/DocPrototype/actions.js @@ -1,18 +1,18 @@ -function list_action () { - if (checkAddress()==false) - return; - if (checkAuth()==false) - return; - res.data.body = this.renderSkinAsString ("list"); - renderSkin ("api"); +function list_action() { + if (checkAddress() == false) + return; + if (checkAuth() == false) + return; + res.data.body = this.renderSkinAsString("list"); + renderSkin("api"); } -function main_action () { - if (checkAddress()==false) - return; - if (checkAuth()==false) - return; - res.data.body = this.renderSkinAsString ("main"); - renderSkin ("api"); +function main_action() { + if (checkAddress() == false) + return; + if (checkAuth() == false) + return; + res.data.body = this.renderSkinAsString("main"); + renderSkin("api"); } diff --git a/DocPrototype/asParentList.skin b/DocPrototype/asParentList.skin index cfdc8989..34208c8a 100644 --- a/DocPrototype/asParentList.skin +++ b/DocPrototype/asParentList.skin @@ -7,7 +7,6 @@ <% 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/functions.js b/DocPrototype/functions.js index 020052d2..b418b24b 100644 --- a/DocPrototype/functions.js +++ b/DocPrototype/functions.js @@ -1,4 +1,3 @@ - ///** // * utility function for head_macro, rendering link to app and to prototype // */ @@ -10,25 +9,24 @@ //} - -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; +function translateType(filter) { + if (filter == "actions") + return Packages.helma.doc.DocElement.ACTION; + 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 if (filter == "properties") + return Packages.helma.doc.DocElement.PROPERTIES; + else + return -1; } -function getApplication () { - return this.getParentElement (); +function getApplication() { + return this.getParentElement(); } diff --git a/DocPrototype/list.skin b/DocPrototype/list.skin index b9a23cc5..55620dac 100644 --- a/DocPrototype/list.skin +++ b/DocPrototype/list.skin @@ -7,5 +7,4 @@ <% 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/macros.js b/DocPrototype/macros.js index 7ffbaed9..7b2915e1 100644 --- a/DocPrototype/macros.js +++ b/DocPrototype/macros.js @@ -1,91 +1,105 @@ - /** - * macro rendering a skin - * @param name name of skin - */ -function skin_macro(par) { - if ( par && par.name ) { - this.renderSkin(par.name); - } +* macro rendering a skin +* @param name name of skin +*/ +function skin_macro(par) { + if (par && par.name) { + this.renderSkin(par.name); + } } /** * macro-wrapper for href-function * @param action name of action to call on this prototype, default main */ -function href_macro(param) { return this.href ((param && param.action) ? param.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); } +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 ()); +function headline_macro(param) { + res.write(this.getName()); } /** * macro formatting list of methods of this prototype - * @param filter actions | functions | macros | templates | skins + * @param filter actions | functions | macros | skins * @param skin skin to apply to the docfunction object * @param separator * @param desc Description that is passed on to the called skin */ -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 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); + } + } + 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 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 (); +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(); } @@ -94,15 +108,15 @@ function inheritanceUtil (obj, param) { * if it has got any functions. * @param skin */ -function parentPrototype_macro (param) { - var skinname = (param.skin) ? param.skin : "asParentList"; - var obj = this.getParentPrototype (); - while (obj!=null) { - if (obj.listChildren ().length>0) { - obj.renderSkin (skinname); - } - obj = obj.getParentPrototype (); - } +function parentPrototype_macro(param) { + var skinname = (param.skin) ? param.skin : "asParentList"; + var obj = this.getParentPrototype(); + while (obj != null) { + if (obj.listChildren().length > 0) { + obj.renderSkin(skinname); + } + obj = obj.getParentPrototype(); + } } /** @@ -110,33 +124,42 @@ function parentPrototype_macro (param) { * type-properties or not. * @param skin */ -function typeProperties_macro (param) { - var props = this.getTypeProperties (); - if (props!=null && props.getContent ()!="" ) { - var sb = new java.lang.StringBuffer (); - // map of all mappings.... - var mappings = props.getMappings (); - // parse type.properties linewise: - var arr = props.getContent ().split ("\n"); - for (var i=0; i' + arr[i] + ''; - } - } - } - sb.append (arr[i] + "\n"); - } - var tmp = new Object (); - tmp.content = sb.toString (); - var skinname = (param.skinname) ? param.skinname : "typeproperties"; - this.renderSkin (skinname, tmp); - } +function typeProperties_macro(param) { + var props = this.getTypeProperties(); + var iter = props.getResources(); + while (iter.hasNext()) { + var tmp = this.renderTypePropertiesResource(iter.next(), props); + var skinname = (param.skinname) ? param.skinname : "typeproperties"; + this.renderSkin(skinname, tmp); + } +} + +function renderTypePropertiesResource(res, props) { + if (res.getContent() != "") { + var sb = new java.lang.StringBuffer (); + // map of all mappings.... + var mappings = props.getMappings(); + // parse type.properties linewise: + var arr = res.getContent().split("\n"); + for (var i = 0; i < arr.length; i++) { + arr [i] = arr[i].trim(); + // look up in mappings table if line matches: + for (var e = mappings.keys(); e.hasMoreElements();) { + var key = e.nextElement(); + var reg = new RegExp ('^' + key + '\\s'); + if (arr[i].match(reg)) { + // it matched, wrap line in a link to that prototype: + var docProtoObj = this.getApplication().getPrototype(mappings.getProperty(key)); + if (docProtoObj != null) { + arr[i] = '' + arr[i] + ''; + } + } + } + sb.append(arr[i] + "\n"); + } + var tmp = new Object (); + tmp.content = sb.toString(); + tmp.source = res.getName(); + return tmp; + } } diff --git a/DocPrototype/main.skin b/DocPrototype/main.skin index 318ffaed..afaf2ab8 100644 --- a/DocPrototype/main.skin +++ b/DocPrototype/main.skin @@ -11,7 +11,6 @@ FUNCTIONS | MACROS | SKINS | -TEMPLATES | TYPE.PROPERTIES

@@ -62,9 +61,9 @@ %> <% this.methods separator="" - filter="templates" - skin="asLargeListItem" - prefix="Templates" + filter="properties" + skin="asLargeListItemSkin" + prefix="type.properties" suffix="  %> @@ -73,7 +72,7 @@

-<% this.typeProperties %> + diff --git a/DocPrototype/typeproperties.skin b/DocPrototype/typeproperties.skin index 2a0ffd32..e1975b32 100644 --- a/DocPrototype/typeproperties.skin +++ b/DocPrototype/typeproperties.skin @@ -1,6 +1,6 @@ - + diff --git a/Global/functions.js b/Global/functions.js index 6f506f3d..7c40b5b7 100644 --- a/Global/functions.js +++ b/Global/functions.js @@ -1,11 +1,9 @@ - - /** - * scheduler function, runs global.appStat every minute - */ +* scheduler function, runs global.appStat every minute +*/ function scheduler() { - appStat(); - return 60000; + appStat(); + return 60000; } @@ -14,8 +12,8 @@ function scheduler() { * creates app.data.addressFilter */ function onStart() { - app.data.addressFilter = createAddressFilter(); - app.data.addressString = root.getProperty ("allowadmin"); + app.data.addressFilter = createAddressFilter(); + app.data.addressString = root.getProperty("allowadmin"); } /** @@ -23,80 +21,80 @@ function onStart() { * hostnames are converted, wildcards are only allowed in ip-addresses * (so, no network-names, sorry) */ -function createAddressFilter() { - var filter = new Packages.helma.util.InetAddressFilter(); - var str = root.getProperty("allowadmin"); - if ( str!=null && str!="" ) { - var arr = str.split(","); - for ( var i in arr ) { - var str = new java.lang.String(arr[i]); +function createAddressFilter() { + var filter = new Packages.helma.util.InetAddressFilter(); + var str = root.getProperty("allowadmin"); + if (str != null && str != "") { + var arr = str.split(","); + for (var i in arr) { + str = new java.lang.String(arr[i]); try { filter.addAddress(str.trim()); } catch (a) { try { - var str = java.net.InetAddress.getByName(str.trim()).getHostAddress(); - filter.addAddress (str); + str = java.net.InetAddress.getByName(str.trim()).getHostAddress(); + filter.addAddress(str); } catch (b) { - app.log ("error using address " + arr[i] + ": " + b); + app.log("error using address " + arr[i] + ": " + b); } } - } - } else { - app.log("no addresses allowed for app manage, all access will be denied"); - } - return filter; + } + } else { + app.log("no addresses allowed for app manage, all access will be denied"); + } + return filter; } /** * updates the stats in app.data.stat every 5 minutes */ -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 b.name) - return 1; - else if (a.name == b.name) - return 0; - else - return -1; +function sortByName(a, b) { + if (a.name > b.name) + return 1; + else if (a.name == b.name) + return 0; + else + return -1; } /** * utility function to sort property-arrays by key */ -function sortProps(a,b) { - if ( a>b ) - return 1; - else if ( a==b ) - return 0; - else - return -1; +function sortProps(a, b) { + if (a > b) + return 1; + else if (a == b) + return 0; + else + return -1; } /** @@ -106,62 +104,62 @@ function sortProps(a,b) { * object for http-auth and return false. * @arg appObj application object to check against (if adminUsername etc are set in app.properties) */ -function checkAuth(appObj) { - if (res && res.data.noWeb==true) { +function checkAuth(appObj) { + if (res && res.data.noWeb == true) { return true; } - var ok = false; + var ok = false; - // check against root - var adminAccess = root.getProperty("adminAccess"); + // check against root + var adminAccess = root.getProperty("adminAccess"); - if (adminAccess==null || adminAccess=="") { - res.redirect (root.href ("makekey")); - } + if (adminAccess == null || adminAccess == "") { + res.redirect(root.href("makekey")); + } - var uname = req.username; - var pwd = req.password; + var uname = req.username; + var pwd = req.password; - if ( uname==null || uname=="" || pwd==null || pwd=="" ) - return forceAuth(); + if (uname == null || uname == "" || pwd == null || pwd == "") + return forceAuth(); - var md5key = Packages.helma.util.MD5Encoder.encode(uname + "-" + pwd); + var md5key = Packages.helma.util.MD5Encoder.encode(uname + "-" + pwd); - if (md5key==adminAccess) - return true; + if (md5key == adminAccess) + return true; - if (appObj!=null && appObj.isActive()) { - // check against application - adminAccess = appObj.getProperty("adminAccess"); - if (md5key==adminAccess) - return true; - } - return forceAuth(); + if (appObj != null && appObj.isActive()) { + // check against application + adminAccess = appObj.getProperty("adminAccess"); + if (md5key == adminAccess) + return true; + } + return forceAuth(); } /** * check access to the manage-app by ip-addresses */ -function checkAddress() { - if (res && res.data.noWeb==true) { +function checkAddress() { + if (res && res.data.noWeb == true) { + return true; + } + // if allowadmin value in server.properties has changed, + // re-construct the addressFilter + if (app.data.addressString != root.getProperty("allowadmin")) { + app.data.addressFilter = createAddressFilter(); + app.data.addressString = root.getProperty("allowadmin"); + } + if (!app.data.addressFilter.matches(java.net.InetAddress.getByName(req.data.http_remotehost))) { + 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 from address " + req.data.http_remotehost + " denied."); + return false; + } else { return true; } - // if allowadmin value in server.properties has changed, - // re-construct the addressFilter - if (app.data.addressString != root.getProperty ("allowadmin")){ - app.data.addressFilter = createAddressFilter(); - app.data.addressString = root.getProperty ("allowadmin"); - } - if ( !app.data.addressFilter.matches(java.net.InetAddress.getByName(req.data.http_remotehost)) ) { - 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 from address "+req.data.http_remotehost+" denied."); - return false; - } else { - return true; - } } @@ -169,68 +167,67 @@ function checkAddress() { * response is reset to 401 / authorization required * @arg realm realm for http-auth */ -function forceAuth(realm) { - res.reset(); - res.status = 401; - res.realm = (realm!=null) ? realm : "helma"; - res.write ("Authorization Required. The server could not verify that you are authorized to access the requested page."); - return false; +function forceAuth(realm) { + res.reset(); + res.status = 401; + res.realm = (realm != null) ? realm : "helma"; + res.write("Authorization Required. The server could not verify that you are authorized to access the requested page."); + return false; } - /** - * macro-utility: formatting property lists - */ -function formatProperties(props,par) { - if ( props.size()==0 ) - return ""; - var e = props.keys(); - var arr = new Array(); - while ( e.hasMoreElements() ) { - arr[arr.length] = e.nextElement(); - } - arr.sort(sortProps); - for ( var i in arr ) { - // don't print the admin-password - if ( arr[i].toLowerCase()=="adminusername" || arr[i].toLowerCase()=="adminpassword" ) continue; - res.write ( par.itemprefix + arr[i] + par.separator + props.getProperty(arr[i]) + par.itemsuffix ); - } +* macro-utility: formatting property lists +*/ +function formatProperties(props, par) { + if (props.size() == 0) + return ""; + var e = props.keys(); + var arr = new Array(); + while (e.hasMoreElements()) { + arr[arr.length] = e.nextElement(); + } + arr.sort(sortProps); + for (var i in arr) { + // don't print the admin-password + if (arr[i].toLowerCase() == "adminusername" || arr[i].toLowerCase() == "adminpassword") continue; + res.write(par.itemprefix + arr[i] + par.separator + props.getProperty(arr[i]) + par.itemsuffix); + } } /** * macro-utility: formatting an integer value as human readable bytes */ -function formatBytes(bytes) { - if ( bytes > Math.pow(2,30) ) { - res.write( Math.round( 100*bytes/Math.pow(2,30) ) / 100 + "gb" ); - } else if ( bytes > Math.pow(2,20) ) { - res.write( Math.round( 100*bytes/Math.pow(2,20) ) / 100 + "mb" ); - } else { - res.write( Math.round( 100*bytes/Math.pow(2,10) ) / 100 + "kb" ); - } +function formatBytes(bytes) { + if (bytes > Math.pow(2, 30)) { + res.write(Math.round(100 * bytes / Math.pow(2, 30)) / 100 + "gb"); + } else if (bytes > Math.pow(2, 20)) { + res.write(Math.round(100 * bytes / Math.pow(2, 20)) / 100 + "mb"); + } else { + res.write(Math.round(100 * bytes / Math.pow(2, 10)) / 100 + "kb"); + } } /** * macro-utility: formatting time in millis as human readable age */ -function formatAge(age) { - var str = ""; - var days = Math.floor(age/86400); - var age = age - days * 86400; - var hours = Math.floor(age / 3600); - var age = age - hours * 3600; - var minutes = Math.floor(age / 60); - var seconds = Math.floor(age - minutes * 60); - if (days > 0) - str += (days + " days, "); - if (hours>0) - str += (hours + "h, "); - str += (minutes + "min"); - if (days == 0) str += (", " + seconds + "sec"); - return(str); +function formatAge(age) { + var str = ""; + var days = Math.floor(age / 86400); + age = age - days * 86400; + var hours = Math.floor(age / 3600); + age = age - hours * 3600; + var minutes = Math.floor(age / 60); + var seconds = Math.floor(age - minutes * 60); + if (days > 0) + str += (days + " days, "); + if (hours > 0) + str += (hours + "h, "); + str += (minutes + "min"); + if (days == 0) str += (", " + seconds + "sec"); + return(str); } @@ -241,23 +238,23 @@ function formatAge(age) { * @param singular string used for value==1 * @param plural string used for value!=1 */ -function formatCount(ct, par) { - if ( !par || !par.singular || !par.plural ) { - return ""; - } - if ( ct==1 ) - return par.singular; - else - return par.plural; +function formatCount(ct, par) { + if (!par || !par.singular || !par.plural) { + return ""; + } + if (ct == 1) + return par.singular; + 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); +function isLinux() { + var str = java.lang.System.getProperty("os.name"); + return (str != null && str.toLowerCase().indexOf("linux") != -1); } diff --git a/Global/macros.js b/Global/macros.js index 13408e7a..ee3fe97a 100644 --- a/Global/macros.js +++ b/Global/macros.js @@ -2,10 +2,10 @@ * macro rendering a skin * @param name name of skin */ -function skin_macro(par) { - if ( par && par.name ) { - renderSkin(par.name); - } +function skin_macro(par) { + if (par && par.name) { + renderSkin(par.name); + } } @@ -13,6 +13,6 @@ function skin_macro(par) { * Macro returning the actual date and time. */ function now_macro() { - var date = new Date(); - return(date.format("dd.MM.yyyy, HH:mm'h' zzz")); + var date = new Date(); + return(date.format("dd.MM.yyyy, HH:mm'h' zzz")); } diff --git a/Global/navig.skin b/Global/navig.skin index fecbbaf7..044e081d 100644 --- a/Global/navig.skin +++ b/Global/navig.skin @@ -11,7 +11,7 @@

- and <% root.appCount filter="disabled" %> disabled apps: + disabled apps:
<% root.appList filter="disabled" skin="navig_disabled" %> @@ -27,4 +27,4 @@

  • ">generate server password -

    \ No newline at end of file +

    diff --git a/Global/renderFunctions.js b/Global/renderFunctions.js index 2b7c4057..280c5168 100644 --- a/Global/renderFunctions.js +++ b/Global/renderFunctions.js @@ -1,95 +1,85 @@ - - -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 (param.handler!="false" && 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 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 (param.handler != "false" && 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) { + 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 + ''; } - - -function renderLinkTag (param) { - var sb = new java.lang.StringBuffer (); - sb.append (''); - return sb.toString (); +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. - */ + * renders the name of the location of a doc element. + */ function renderLocation (docEl, param) { - var f = docEl.getLocation (); - // with repositories, always display full file path - return f.getAbsolutePath(); + return docEl.toString(); } - - /** - * 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 = param.type; - if (type=="params") - type = "param"; - else if (type=="returns") - type = "return"; - else if (type=="arg") +* 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 = param.type; + if (type == "params") type = "param"; - 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 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 '' + 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 < arr.length; i++) { + if (arr[i].getName() == parts [1]) { + return '' + 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; +* 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/actions.js b/Root/actions.js new file mode 100644 index 00000000..aac54dc7 --- /dev/null +++ b/Root/actions.js @@ -0,0 +1,130 @@ +/** + * main action, show server-stats + * perform start, stop, restart and flush-action + * + */ +function main_action() { + + if (checkAddress() == false) return; + + if (req.data.app != null && req.data.app != "" && req.data.action != null && req.data.action != "") { + + var appObj = root.getApp(req.data.app); + // check access for application. md5-encoded uname/pwd can also be put in + // app.properties to limit access to a single app + if (checkAuth(appObj) == false) return; + + if (req.data.action == "start") { + this.startApplication(req.data.app); + res.redirect(appObj.href("main")); + + } else if (req.data.action == "stop") { + if (checkAuth() == false) return; + this.stopApplication(req.data.app); + res.redirect(root.href("main")); + + } else if (req.data.action == "restart") { + this.stopApplication(req.data.app); + this.startApplication(req.data.app); + res.redirect(appObj.href("main")); + + } else if (req.data.action == "flush") { + appObj.clearCache(); + res.redirect(appObj.href("main")); + + } + + } + + // output only to root + if (checkAuth() == false) return; + + res.data.title = "Helma Object Publisher - Serverinfo"; + res.data.body = this.renderSkinAsString("main"); + renderSkin("global"); +} + +/** +* return the helma object publisher logo, built into hop core +* to be independent of static html-paths +*/ +function image_action() { + if (checkAddress() == false) return; + + res.contentType = "image/gif"; + res.writeBinary(Packages.helma.util.Logo.hop); +} + +function makekey_action() { + + if (checkAddress() == false) + return; + + var obj = new Object(); + obj.msg = ""; + if (req.data.username != null && req.data.password != null) { + + // we have input from webform + if (req.data.username == "") + obj.msg += "username can't be left empty!
    "; + if (req.data.password == "") + obj.msg += "password can't be left empty!
    "; + if (obj.msg != "") { + obj.username = req.data.username; + res.reset(); + res.data.body = renderSkinAsString("pwdform", obj); + } else { + // render the md5-string: + obj.propsString = "adminAccess=" + Packages.helma.util.MD5Encoder.encode(req.data.username + "-" + req.data.password) + "
    \n"; + res.data.body = renderSkinAsString("pwdfeedback", obj); + } + + } else { + + // no input from webform, so print it + res.data.body = renderSkinAsString("pwdform", obj); + + } + + res.data.title = "username & password on " + root.hostname_macro(); + res.data.head = renderSkinAsString("head"); + renderSkin("basic"); +} + +/** +* 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. +*/ +function mrtg_action() { + + 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"); + } +} \ No newline at end of file diff --git a/Root/functions.js b/Root/functions.js index b5c26f9e..dc6405f6 100644 --- a/Root/functions.js +++ b/Root/functions.js @@ -1,7 +1,6 @@ - /** - * renders the api of a given application. used from commandline. - */ +* renders the api of a given application. used from commandline. +*/ function renderApi(appName) { // supress security checks when accessing actions @@ -15,7 +14,7 @@ function renderApi(appName) { // now render the api var ct = docApp.renderApi(); writeln("rendered " + ct + " files"); - + // cleanup this.stopApplication(appName); } @@ -25,15 +24,15 @@ function renderApi(appName) { * lists all applications in appdir. * for active apps use this.getApplications() = helma.main.Server.getApplications() */ -function getAllApplications() { - var appsDir = this.getAppsHome(); - var dir = appsDir.list(); - var arr = new Array(); - for ( var i=0; i str.lastIndexOf('/') ) ? str.lastIndexOf('\\') : str.lastIndexOf('/'); - res.write ( arr[i].substring(pos+1) + ".jar" ); - if ( i < arr.length-1 ) res.write ( separator ); - } +function jvmJars_macro(par) { + var separator = (par && par.separator ) ? par.separator : ", "; + var str = java.lang.System.getProperty("java.class.path"); + var arr = str.split(".jar"); + for (var i in arr) { + var str = arr[i]; + var pos = ( str.lastIndexOf('\\') > str.lastIndexOf('/') ) ? str.lastIndexOf('\\') : str.lastIndexOf('/'); + res.write(arr[i].substring(pos + 1) + ".jar"); + if (i < arr.length - 1) res.write(separator); + } } /** * Macro that returns the name and version of the server's os */ -function os_macro() { - return java.lang.System.getProperty("os.name") + " " + java.lang.System.getProperty("os.arch") + " " + java.lang.System.getProperty("os.version"); +function os_macro() { + return java.lang.System.getProperty("os.name") + " " + java.lang.System.getProperty("os.arch") + " " + java.lang.System.getProperty("os.version"); } /** * Macro that returns anything from server.properties */ -function property_macro(par) { - if ( par && par.key ) { - return this.getProperty(key); - } else { - return ""; - } +function property_macro(par) { + if (par && par.key) { + return this.getProperty(key); + } else { + return ""; + } } /** * Macro formatting server.properties */ -function properties_macro(par) { - formatProperties(this.getProperties(),par); +function properties_macro(par) { + formatProperties(this.getProperties(), par); } /** * Macro that returns the timezone of this server */ -function timezone_macro(par) { - return java.util.TimeZone.getDefault().getDisplayName(false, java.util.TimeZone.LONG) + " (" + java.util.TimeZone.getDefault().getID() + ")"; +function timezone_macro(par) { + return java.util.TimeZone.getDefault().getDisplayName(false, java.util.TimeZone.LONG) + " (" + java.util.TimeZone.getDefault().getID() + ")"; } diff --git a/Root/main.hac b/Root/main.hac deleted file mode 100644 index f05009fa..00000000 --- a/Root/main.hac +++ /dev/null @@ -1,44 +0,0 @@ -/** - * main action, show server-stats - * perform start, stop, restart and flush-action - * - */ - - -if ( checkAddress()==false ) return; - -if ( req.data.app!=null && req.data.app!="" && req.data.action!=null && req.data.action!="" ) { - - var appObj = root.getApp(req.data.app); - // check access for application. md5-encoded uname/pwd can also be put in - // app.properties to limit access to a single app - if ( checkAuth(appObj)==false ) return; - - if ( req.data.action=="start" ) { - this.startApplication(req.data.app); - res.redirect ( appObj.href("main") ); - - } else if ( req.data.action=="stop" ) { - if ( checkAuth()==false ) return; - this.stopApplication(req.data.app); - res.redirect ( root.href("main") ); - - } else if ( req.data.action=="restart" ) { - this.stopApplication(req.data.app); - this.startApplication(req.data.app); - res.redirect ( appObj.href("main") ); - - } else if ( req.data.action=="flush" ) { - appObj.clearCache(); - res.redirect ( appObj.href("main") ); - - } - -} - -// output only to root -if ( checkAuth()==false ) return; - -res.data.title = "Helma Object Publisher - Serverinfo"; -res.data.body = this.renderSkinAsString("main"); -renderSkin("global"); diff --git a/Root/makekey.hac b/Root/makekey.hac deleted file mode 100644 index 6eb739fb..00000000 --- a/Root/makekey.hac +++ /dev/null @@ -1,33 +0,0 @@ - -if (checkAddress()==false) - return; - -var obj = new Object(); -obj.msg = ""; -if (req.data.username!=null && req.data.password!=null) { - - // we have input from webform - if ( req.data.username=="" ) - obj.msg += "username can't be left empty!
    "; - if ( req.data.password=="" ) - obj.msg += "password can't be left empty!
    "; - if ( obj.msg!="" ) { - obj.username = req.data.username; - res.reset(); - res.data.body = renderSkinAsString ("pwdform",obj); - } else { - // render the md5-string: - obj.propsString = "adminAccess=" + Packages.helma.util.MD5Encoder.encode(req.data.username + "-" + req.data.password) + "
    \n"; - res.data.body = renderSkinAsString ("pwdfeedback", obj); - } - -} else { - - // no input from webform, so print it - res.data.body = renderSkinAsString("pwdform",obj); - -} - -res.data.title = "username & password on " + root.hostname_macro(); -res.data.head = renderSkinAsString("head"); -renderSkin("basic"); diff --git a/Root/mrtg.hac b/Root/mrtg.hac deleted file mode 100644 index 44b672c8..00000000 --- a/Root/mrtg.hac +++ /dev/null @@ -1,37 +0,0 @@ - -/** - * 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"); -} - diff --git a/app.properties b/app.properties index d8232b4f..83e08c43 100644 --- a/app.properties +++ b/app.properties @@ -1,5 +1,5 @@ # Set baseURI for application generated URLs, if necessary. -#baseURI = /manage +# baseURI = /manage # A short description of what this application is about: _description = Helma's server management console. Start applications, introspection etc. @@ -8,3 +8,5 @@ _description = Helma's server management console. Start applications, introspect # might take more than one minute on a slow computer requestTimeout = 300 +# run scheduler function each minute +cron.scheduler.function = scheduler diff --git a/class.properties b/class.properties index 57808b22..6a51df81 100644 --- a/class.properties +++ b/class.properties @@ -1,4 +1,3 @@ - # # define the root class of this application # @@ -17,10 +16,10 @@ root.factory.method = getServer # and, yes, map the root class again. # -helma.main.Server = root -helma.framework.core.Application = application -helma.doc.DocApplication = docapplication -helma.doc.DocPrototype = docprototype -helma.doc.DocFunction = docfunction -helma.doc.DocTag = doctag +helma.main.Server = Root +helma.framework.core.Application = Application +helma.doc.DocApplication = DocApplication +helma.doc.DocPrototype = DocPrototype +helma.doc.DocFunction = DocFunction +helma.doc.DocTag = DocTag diff --git a/readme.txt b/readme.txt index 180a849d..8e271c95 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ To get the manage-application to work you must: - add it to the apps.properties file with the following line: manage - - use helma distribution 1.2-RC1 or later. + - use helma distribution 1.5 or later. - add the following properties to server.properties:
  • type.propertiestype.properties in <% param.source %>
    <% param.content %>