!Monmaster Overview\n!!Feature summary\nMonmaster has been evolving since 2000 to detect and correct functional problems in production applications and servers that are part of a clustered, multitiered server environment.\n\nExpanded, that sentence captures many of Monmaster's features:\n*evolving\n> Monmaster has been an essential tool in supporting a corporate web application as it has evolved over several years. Monmaster has become quite robust and featureful.\n*detect\n> Monmaster performs functional testing of web applications - essentially emulating user actions. Some test scenarios consist of nothing more than a user login - that simple test may effectively verify that a critical database is available, or that two web applications are "talking". Other test scenarios may include multiple steps across multiple web pages. Monmaster determines success or failure by looking for matches within the text returned for a request.\n*correct\n> Monmaster can perform scripted recovery sequences, such as making a telnet connection to a server and running a shell script to restart a server. If Monmaster is unable to correct a problem, staff can be notified via email/pager.\n*functional problems\n> Monmaster follow a defined path to traverse a web application, including moving from page to page, filling in and submitting forms, essentially emulating a browser session - and verifying what a user would see\n*productions applications\n> Monmaster was designed for monitoring and recovering web applications in a production environment and only escalating problems when necessary. Monmaster can help oncall staff have a life!\n*and servers\n> Monmaster can check and recover various types of applications common in web environments: web servers, J2EE instances, and DBMSs\n*clustered\n> As long as Monmaster is running inside the corporate firewall and can access clustered application servers individually, then it can distinguish between servers that are responding correctly and those that are not, and recover only the servers with errors. This avoids unnecessary downtime and application unavailability.\n*multitiered server environment\n> To fully test applications that use sessions in a multitiered environment, Monmaster supports a multipage sessiontest and can initiate a session on the web tier and then modify cookies to continue the session on an application server. This is necessary for enviromnets where the web tier in a one domain and the application tier is in another (perhaps bogus) domain, and where cookies are used to maintain session state.
You will need to use an ''ssh'' client to get to a command line on [[YourServer]].\n\nYou can download and install [[Putty for Windows|http://www.chiark.greenend.org.uk/~sgtatham/putty/]].\n\nSimilarly, you must use ''scp'' to transfer files to YourServer.\n\nYou can download and install [[WinSCP|http://winscp.net/]] for Windows. Perhaps even better is [[Filezilla|http://filezilla.sourceforge.net/]], which supports sftp (FTP over ssh). \n\nUse your network username and password to authenticate.\n\nAfter you login as yourself, you can use the su command to get access to the monmaster installation:\n{{{\n su - monmaster\n}}}\nYou will be prompted for the password. After entering the password for the monmaster account, your current directory will be /home/monmaster, where various files and directories are located.
Unfortunately, this system-generated collation is in a random sequence. Use the links on the upper left or the search function on the upper right to find specific subsections.\n\n<<forEachTiddler\n where\n 'tiddler.tags.contains("MonmasterDocs")'\n write\n '"----\sn!" + tiddler.title + "\sn<<tiddler [["+tiddler.title+"]]$))\sn"'\n>>
!!Monmaster Configuration Guide - Applications\n!!Overview of application processing\n An application is what Monmaster can attempt to fix - usually by restarting a program or daemon. Examples of applications would be web server instances, application server instances, middleware, reporting servers, database instances, etc.\n\n Monmaster creates instances of the Application class at startup and refreshes the list of application objects\n at the start of each test cycle. Each Application object is defined in the application list element in the \n parameter file, and to an application in your server environment. \n\n For more information, see Operational Overview\n\n!!Application Parameters\nEach ''application'' element may have the following children:\n> name\n>> the string that should be used to identify the application instance; used for display purposes but also provides the handle for other Monmaster modules to acces an Application object\n> severity\n>> a string that indicates the consequences of an error for the application; valid values are:\n>>> //ERROR// restart the server (unless a global or application-specific restart ''blackout'' period is in effect\n>>> //WARN// send email (unless a global notification ''blackout'' period is in effect)\n> blackoutlist\n>> an list of zeroOrMore **blackout** elements that allow restarting of an application in case of an error to be skipped for defined periods\n>>> blackout\n>>>> a period definition for a an application restart blackout period\n> servername\n>> the hostname or IP address of the server, used if Monmaster must initiate a telnet session to restart an application\n> restart_timeout\n>> the number of seconds to allow for a network socket connection to be open before aborting the request; this overrides the global **timeout_seconds** setting for a specific application **restart_sequence** so that long-running start scripts can complete before the telnet session is aborted by Monmaster, but keeps requests that never return to keep from hanging the restart process.\n> restart_sequence\n>>\n\nTODO: This section is incomplete\n \n!!Relax NG Compact (RNC) schema fragment for ''application list'' element:\n{{{\n ../..\n element applicationlist { application+ }\n ../..\n application =\n element application {\n (text\n | blackoutlist\n | element name { text }\n | element restart_sequence {\n element restart-action { xsd:NCName },\n username,\n password,\n element command_list {\n element command {\n element waitfor { text },\n element command_timeout { xsd:integer }?,\n element command_line { text }\n }*\n }\n }\n | element restart_timeout { xsd:integer }\n | element server-name { text }\n | element severity { xsd:NCName })+\n }\n username = element username { text }\n password = element password { text }\n blackoutlist =\n element blackoutlist {\n notification_blackout?,\n element restart_blackout { blackout+ }\n }\n notification_blackout = element notification_blackout { blackout* }\n blackout = element blackout { text }\n ../..\n}}}
!Monmaster Configuration Guide\n\n!Table of Contents\n[[System Requirements]]\n[[Installation and setup]]\n[[Parameter File]]\n\n [[global parameters]]\n [[test list]]\n [[page list]]\n [[logical server list]]\n [[application list]]\n [[notification groups]]\n\n[[Logging]]
Your Name here\nYour contact info here
[[About Monmaster]]\n
!!Overview\n\nIn the current release, Monmaster supports limited editing of the parameter file using the web user interface. Specifically, the following parameters may be viewed and updated:\n* global blackout periods \n* page match strings\n* user IDs and passwords used for testing or application restarting.\n\nUpdates are made to the parameter file currently in use, and changes are saved upon submission. The parameter file is reloaded at the start of each test cycle, and updated parameters fill take effect at that time.\n\nNote\n>You can force a test cycle to be initiated immediately by pausing and resuming monitoring using the links on the main Monmaster web page.\n\n!!Updating global blackout periods\n\n!!Updating page match strings\n\nIf the content (either static or dynamic) of a page that you monitor on your web site changes because of a new release or because of a data change, you may need to update the search strings that Monmaster uses to check the page.\n\nIn many cases, you will be forced to do this because Monmaster reports an error when the page is actually correct. Accordingly, the Monmaster web UI will show you the strings it searches for on a page, as well as the HTML content of any pages that were considered to have an error.\n\nNote\n>Monmaster keeps the content of pages with error indefinitely, so it may show you page content that is very outdated. The timestamp showing when the page was retrieved is displayed, so you should consider how relevant any error content is.\n\n!!Updating user IDs and passwords\n
<<exportTiddlers inline>>
/***\n''Export Tiddlers Plugin for TiddlyWiki version 2.0''\n^^author: Eric Shulman - ELS Design Studios\nsource: http://www.TiddlyTools.com/#ExportTiddlersPlugin\nlicense: [[Creative Commons Attribution-ShareAlike 2.5 License|http://creativecommons.org/licenses/by-sa/2.5/]]^^\n\nWhen many people edit copies of the same TiddlyWiki document, the ability to easily copy and share these changes so they can then be redistributed to the entire group is very important. This ability is also very useful when moving your own tiddlers from document to document (e.g., when upgrading to the latest version of TiddlyWiki, or 'pre-loading' your favorite stylesheets into a new 'empty' TiddlyWiki document.)\n\nExportTiddlersPlugin let you ''select and extract tiddlers from your ~TiddlyWiki documents and save them to a local file'' or a remote server (requires installation of compatible server-side scripting, still under development...). An interactive control panel lets you specify a destination, and then select which tiddlers to export. A convenient 'selection filter' helps you pick desired tiddlers by specifying a combination of modification dates, tags, or tiddler text to be matched or excluded. ''Tiddler data can be output as ~TiddlyWiki "storeArea ~DIVs" that can be imported into another ~TiddlyWiki or as ~RSS-compatible XML that can be published for RSS syndication.''\n\n!!!!!Inline interface (live)\n<<<\n<<exportTiddlers inline>>\n<<<\n!!!!!Usage\n<<<\nOptional "special tiddlers" used by this plugin:\n* SiteUrl^^\nURL for official server-published version of document being viewed\ndefault: //none//^^\n* SiteHost^^\nhost name/address for remote server (e.g., "www.server.com" or "192.168.1.27")\ndefault: //none//^^\n* SitePost^^\nremote path/filename for submitting changes (e.g., "/cgi-bin/submit.cgi")\ndefault: //none//^^\n* SiteParams^^\narguments (if any) for server-side receiving script\ndefault: //none//^^\n* SiteID^^\nusername or other authorization identifier for login-controlled access to remote server\ndefault: current TiddlyWiki username (e.g., "YourName")^^\n* SiteDate^^\nstored date/time stamp for most recent published version of document\ndefault: current document.modified value (i.e., the 'file date')^^\n<<<\n!!!!!Example\n<<<\n<<exportTiddlers>>\n<<<\n!!!!!Installation\n<<<\nImport (or copy/paste) the following tiddlers into your document:\n''ExportTiddlersPlugin'' (tagged with <<tag systemConfig>>)\n\ncreate/edit ''SideBarOptions'': (sidebar menu items) \n^^Add "< < exportTiddlers > >" macro^^\n<<<\n!!!!!Revision History\n<<<\n''2006.02.12 [2.1.2]''^^\nadded var to unintended global 'tags' in matchTags(). Avoids FF1501 bug when filtering by tags. (based on report by TedPavlic)\n''2006.02.04 [2.1.1]''^^\nadded var to variables that were unintentionally global. Avoids FireFox 1.5.0.1 crash bug when referencing global variables\n''2006.02.02 [2.1.0]''^^\nAdded support for output of complete TiddlyWiki documents. Let's you use ExportTiddlers to generate 'starter' documents from selected tiddlers.^^\n''2006.01.21 [2.0.1]''^^\nDefer initial panel creation and only register a notification function when panel first is created\nin saveChanges 'hijack', create panel as needed. Note: if window.event is not available to identify the click location, the export panel is positioned relative to the 'tiddlerDisplay' element of the TW document.\n^^\n''2005.12.27 [2.0.0]''^^\nUpdate for TW2.0\nDefer initial panel creation and only register a notification function when panel first is created\n^^\n''2005.12.24 [0.9.5]''^^\nMinor adjustments to CSS to force correct link colors regardless of TW stylesheet selection\n^^\n''2005.12.16 [0.9.4]''^^\nDynamically create/remove exportPanel as needed to ensure only one instance of interface elements exists, even if there are multiple instances of macro embedding.\n^^\n''2005.11.15 [0.9.2]''^^\nadded non-Ajax post function to bypass javascript security restrictions on cross-domain I/O. Moved AJAX functions to separate tiddler (no longer needed here). Generalized HTTP server to support UnaWiki servers\n^^\n+++[previous releases...]\n''2005.11.08 [0.9.1]''^^\nmoved HTML, CSS and control initialization into exportInit() function and call from macro handler instead of at load time. This allows exportPanel to be placed within the same containing element as the "export tiddlers" button, so that relative positioning can be achieved.\n^^\n''2005.10.28 [0.9.0]''^^\nadded 'select opened tiddlers' feature\nBased on a suggestion by Geoff Slocock\n^^\n''2005.10.24 [0.8.3]''^^\nCorrected hijack of 'save changes' when using http:\n^^\n''2005.10.18 [0.8.2]''^^\nadded AJAX functions\n^^\n''2005.10.18 [0.8.1]''^^\nCorrected timezone handling when filtering for date ranges.\nImproved error checking/reporting for invalid filter values and filters that don't match any tiddlers.\nExporting localfile-to-localfile is working for IE and FF\nExporting server-to-localfile works in IE (after ActiveX warnings), but has security issues in FF\nCross-domain exporting (localfile/server-to-server) is under development\nCookies to remember filter settings - coming soon\nMore style tweaks, minor text changes and some assorted layout cleanup.\n^^\n''2005.10.17 [0.8.0]''^^\nFirst pre-release.\n^^\n''2005.10.16 [0.7.0]''^^\nfilter by tags\n^^\n''2005.10.15 [0.6.0]''^^\nfilter by title/text\n^^\n''2005.10.14 [0.5.0]''^^\nexport to local file (DIV or XML)\n^^\n''2005.10.14 [0.4.0]''^^\nfilter by start/end date\n^^\n''2005.10.13 [0.3.0]''^^\npanel interaction\n^^\n''2005.10.11 [0.2.0]''^^\npanel layout\n^^\n''2005.10.10 [0.1.0]''^^\ncode framework\n^^\n''2005.10.09 [0.0.0]''^^\ndevelopment started\n^^\n===\n<<<\n!!!!!Credits\n<<<\nThis feature was developed by EricShulman from [[ELS Design Studios|http:/www.elsdesign.com]]\n<<<\n!!!!!Code\n***/\n// // +++[version]\n//{{{\nversion.extensions.exportTiddlers = {major: 2, minor: 1, revision: 2, date: new Date(2006,2,12)};\n//}}}\n// //===\n\n// // +++[macro handler]\n//{{{\nconfig.macros.exportTiddlers = {\n label: "export tiddlers",\n prompt: "Copy selected tiddlers to an export document",\n datetimefmt: "0MM/0DD/YYYY 0hh:0mm:0ss" // for "filter date/time" edit fields\n};\n\nconfig.macros.exportTiddlers.handler = function(place,macroName,params) {\n if (params[0]!="inline")\n { createTiddlyButton(place,this.label,this.prompt,onClickExportMenu); return; }\n var panel=createExportPanel(place);\n panel.style.position="static";\n panel.style.display="block";\n}\n\nfunction createExportPanel(place) {\n var panel=document.getElementById("exportPanel");\n if (panel) { panel.parentNode.removeChild(panel); }\n setStylesheet(config.macros.exportTiddlers.css,"exportTiddlers");\n panel=createTiddlyElement(place,"span","exportPanel",null,null)\n panel.innerHTML=config.macros.exportTiddlers.html;\n exportShowPanel(document.location.protocol);\n exportInitFilter();\n refreshExportList(0);\n store.addNotification(null,refreshExportList); // refresh listbox after every tiddler change\n return panel;\n}\n\nfunction onClickExportMenu(e)\n{\n if (!e) var e = window.event;\n var parent=resolveTarget(e).parentNode;\n var panel = document.getElementById("exportPanel");\n if (panel==undefined || panel.parentNode!=parent)\n panel=createExportPanel(parent);\n var isOpen = panel.style.display=="block";\n if(config.options.chkAnimate)\n anim.startAnimating(new Slider(panel,!isOpen,e.shiftKey || e.altKey,"none"));\n else\n panel.style.display = isOpen ? "none" : "block" ;\n e.cancelBubble = true;\n if (e.stopPropagation) e.stopPropagation();\n return(false);\n}\n//}}}\n// //===\n\n// // +++[Hijack saveChanges] diverts 'notFileUrlError' to display export control panel instead\n//{{{\nwindow.coreSaveChanges=window.saveChanges;\nwindow.saveChanges = function()\n{\n if (document.location.protocol=="file:") { coreSaveChanges(); return; }\n var e = window.event;\n var parent=e?resolveTarget(e).parentNode:document.body;\n var panel = document.getElementById("exportPanel");\n if (panel==undefined || panel.parentNode!=parent) panel=createExportPanel(parent);\n exportShowPanel(document.location.protocol);\n if (parent==document.body) { panel.style.left="30%"; panel.style.top="30%"; }\n panel.style.display = "block" ;\n}\n//}}}\n// //===\n\n// // +++[IE needs explicit scoping] for functions called by browser events\n//{{{\nwindow.onClickExportMenu=onClickExportMenu;\nwindow.onClickExportButton=onClickExportButton;\nwindow.exportShowPanel=exportShowPanel;\nwindow.exportShowFilterFields=exportShowFilterFields;\nwindow.refreshExportList=refreshExportList;\n//}}}\n// //===\n\n// // +++[CSS] for floating export control panel\n//{{{\nconfig.macros.exportTiddlers.css = '\s\n#exportPanel {\s\n display: none; position:absolute; z-index:12; width:35em; right:105%; top:6em;\s\n background-color: #eee; color:#000; font-size: 8pt; line-height:110%;\s\n border:1px solid black; border-bottom-width: 3px; border-right-width: 3px;\s\n padding: 0.5em; margin:0em; -moz-border-radius:1em;\s\n}\s\n#exportPanel a, #exportPanel td a { color:#009; display:inline; margin:0px; padding:1px; }\s\n#exportPanel table { width:100%; border:0px; padding:0px; margin:0px; font-size:8pt; line-height:110%; background:transparent; }\s\n#exportPanel tr { border:0px;padding:0px;margin:0px; background:transparent; }\s\n#exportPanel td { color:#000; border:0px;padding:0px;margin:0px; background:transparent; }\s\n#exportPanel select { width:98%;margin:0px;font-size:8pt;line-height:110%;}\s\n#exportPanel input { width:98%;padding:0px;margin:0px;font-size:8pt;line-height:110%}\s\n#exportPanel .box { border:1px solid black; padding:3px; margin-bottom:5px; background:#f8f8f8; -moz-border-radius:5px;}\s\n#exportPanel .topline { border-top:2px solid black; padding-top:3px; margin-bottom:5px; }\s\n#exportPanel .rad { width:auto; }\s\n#exportPanel .chk { width:auto; }\s\n#exportPanel .btn { width:auto; }\s\n#exportPanel .btn1 { width:98%; }\s\n#exportPanel .btn2 { width:48%; }\s\n#exportPanel .btn3 { width:32%; }\s\n#exportPanel .btn4 { width:24%; }\s\n#exportPanel .btn5 { width:19%; }\s\n';\n//}}}\n// //===\n\n// // +++[HTML] for export control panel interface\n//{{{\nconfig.macros.exportTiddlers.html = '\s\n<!-- output target and format -->\s\n<table cellpadding="0" cellspacing="0"><tr><td width=50%>\s\n export to\s\n <select size=1 id="exportTo" onchange="exportShowPanel(this.value);">\s\n <option value="file:" SELECTED>this computer</option>\s\n <option value="http:">web server (http)</option>\s\n <option value="https:">secure web server (https)</option>\s\n <option value="ftp:">file server (ftp)</option>\s\n </select>\s\n</td><td width=50%>\s\n output format\s\n <select id="exportFormat" size=1>\s\n <option value="DIV">TiddlyWiki export file</option>\s\n <option value="TW">TiddlyWiki document</option>\s\n <option value="XML">RSS feed (XML)</option>\s\n </select>\s\n</td></tr></table>\s\n\s\n<!-- export to local file -->\s\n<div id="exportLocalPanel" style="margin-bottom:5px;margin-top:5px;">\s\nlocal path/filename<br>\s\n<input type="file" id="exportFilename" size=56 style="width:100%"><br>\s\n</div><!--panel-->\s\n\s\n<!-- export to http server -->\s\n<div id="exportHTTPPanel" style="display:none;margin-bottom:5px;margin-top:5px;">\s\ndocument URL<br>\s\n<input type="text" id="exportHTTPSiteURL" onfocus="this.select()"><br>\s\nserver script / parameters<br>\s\n<input type="text" id="exportHTTPServerURL" onfocus="this.select()"><br>\s\n</div><!--panel-->\s\n\s\n<!-- export to ftp server -->\s\n<div id="exportFTPPanel" style="display:none;margin-bottom:5px;margin-top:5px;">\s\n<table cellpadding="0" cellspacing="0" width="33%"><tr valign="top"><td>\s\n host server<br>\s\n <input type="text" id="exportFTPHost" onfocus="this.select()"><br>\s\n</td><td width="33%">\s\n username<br>\s\n <input type="text" id="exportFTPID" onfocus="this.select()"><br>\s\n</td><td width="33%">\s\n password<br>\s\n <input type="password" id="exportFTPPW" onfocus="this.select()"><br>\s\n</td></tr></table>\s\nFTP path/filename<br>\s\n<input type="text" id="exportFTPFilename" onfocus="this.select()"><br>\s\n</div><!--panel-->\s\n\s\n<!-- list of tiddlers -->\s\n<table><tr align="left"><td>\s\n select:\s\n <a href="JavaScript:;" id="exportSelectAll"\s\n onclick="onClickExportButton(this)" title="select all tiddlers">\s\n all </a>\s\n <a href="JavaScript:;" id="exportSelectChanges"\s\n onclick="onClickExportButton(this)" title="select tiddlers changed since last save">\s\n changes </a> \s\n <a href="JavaScript:;" id="exportSelectOpened"\s\n onclick="onClickExportButton(this)" title="select tiddlers currently being displayed">\s\n opened </a> \s\n <a href="JavaScript:;" id="exportToggleFilter"\s\n onclick="onClickExportButton(this)" title="show/hide selection filter">\s\n filter </a> \s\n</td><td align="right">\s\n <a href="JavaScript:;" id="exportListSmaller"\s\n onclick="onClickExportButton(this)" title="reduce list size">\s\n – </a>\s\n <a href="JavaScript:;" id="exportListLarger"\s\n onclick="onClickExportButton(this)" title="increase list size">\s\n + </a>\s\n</td></tr></table>\s\n<select id="exportList" multiple size="10" style="margin-bottom:5px;"\s\n onchange="refreshExportList(this.selectedIndex)">\s\n</select><br>\s\n\s\n<!-- selection filter -->\s\n<div id="exportFilterPanel" style="display:none">\s\n<table><tr align="left"><td>\s\n selection filter\s\n</td><td align="right">\s\n <a href="JavaScript:;" id="exportHideFilter"\s\n onclick="onClickExportButton(this)" title="hide selection filter">hide</a>\s\n</td></tr></table>\s\n<div class="box">\s\n<input type="checkbox" class="chk" id="exportFilterStart" value="1"\s\n onclick="exportShowFilterFields(this)"> starting date/time<br>\s\n<table cellpadding="0" cellspacing="0"><tr valign="center"><td width="50%">\s\n <select size=1 id="exportFilterStartBy" onchange="exportShowFilterFields(this);">\s\n <option value="0">today</option>\s\n <option value="1">yesterday</option>\s\n <option value="7">a week ago</option>\s\n <option value="30">a month ago</option>\s\n <option value="site">SiteDate</option>\s\n <option value="file">file date</option>\s\n <option value="other">other (mm/dd/yyyy hh:mm)</option>\s\n </select>\s\n</td><td width="50%">\s\n <input type="text" id="exportStartDate" onfocus="this.select()"\s\n onchange="document.getElementById(\s'exportFilterStartBy\s').value=\s'other\s';">\s\n</td></tr></table>\s\n<input type="checkbox" class="chk" id="exportFilterEnd" value="1"\s\n onclick="exportShowFilterFields(this)"> ending date/time<br>\s\n<table cellpadding="0" cellspacing="0"><tr valign="center"><td width="50%">\s\n <select size=1 id="exportFilterEndBy" onchange="exportShowFilterFields(this);">\s\n <option value="0">today</option>\s\n <option value="1">yesterday</option>\s\n <option value="7">a week ago</option>\s\n <option value="30">a month ago</option>\s\n <option value="site">SiteDate</option>\s\n <option value="file">file date</option>\s\n <option value="other">other (mm/dd/yyyy hh:mm)</option>\s\n </select>\s\n</td><td width="50%">\s\n <input type="text" id="exportEndDate" onfocus="this.select()"\s\n onchange="document.getElementById(\s'exportFilterEndBy\s').value=\s'other\s';">\s\n</td></tr></table>\s\n<input type="checkbox" class="chk" id=exportFilterTags value="1"\s\n onclick="exportShowFilterFields(this)"> match tags<br>\s\n<input type="text" id="exportTags" onfocus="this.select()">\s\n<input type="checkbox" class="chk" id=exportFilterText value="1"\s\n onclick="exportShowFilterFields(this)"> match titles/tiddler text<br>\s\n<input type="text" id="exportText" onfocus="this.select()">\s\n</div> <!--box-->\s\n</div> <!--panel-->\s\n\s\n<!-- action buttons -->\s\n<div style="text-align:center">\s\n<input type=button class="btn3" onclick="onClickExportButton(this)"\s\n id="exportFilter" value="apply filter">\s\n<input type=button class="btn3" onclick="onClickExportButton(this)"\s\n id="exportStart" value="export tiddlers">\s\n<input type=button class="btn3" onclick="onClickExportButton(this)"\s\n id="exportClose" value="close">\s\n</div><!--center-->\s\n';\n//}}}\n// //===\n\n// // +++[initialize interface]>\n// // +++[exportShowPanel(which)]\n//{{{\nfunction exportShowPanel(which) {\n var index=0; var panel='exportLocalPanel';\n switch (which) {\n case 'file:':\n case undefined:\n index=0; panel='exportLocalPanel'; break;\n case 'http:':\n index=1; panel='exportHTTPPanel'; break;\n case 'https:':\n index=2; panel='exportHTTPPanel'; break;\n case 'ftp:':\n index=3; panel='exportFTPPanel'; break;\n default:\n alert("Sorry, export to "+which+" is not yet available");\n break;\n }\n exportInitPanel(which);\n document.getElementById('exportTo').selectedIndex=index;\n document.getElementById('exportLocalPanel').style.display='none';\n document.getElementById('exportHTTPPanel').style.display='none';\n document.getElementById('exportFTPPanel').style.display='none';\n document.getElementById(panel).style.display='block';\n}\n//}}}\n// //===\n\n// // +++[exportInitPanel(which)]\n//{{{\nfunction exportInitPanel(which) {\n switch (which) {\n case "file:": // LOCAL EXPORT PANEL: file/path:\n // ** no init - security issues in IE **\n break;\n case "http:": // WEB EXPORT PANEL\n case "https:": // SECURE WEB EXPORT PANEL\n // url\n var siteURL=store.getTiddlerText("SiteUrl");\n if (store.tiddlerExists("unawiki_download")) {\n var theURL=store.getTiddlerText("unawiki_download");\n theURL=theURL.replace(/\s[\s[download\s|/,'').replace(/\s]\s]/,'');\n var title=(store.tiddlerExists("unawiki_host"))?"unawiki_host":"SiteHost";\n var theHost=store.getTiddlerText(title);\n if (!theHost || !theHost.length) theHost=document.location.host;\n if (!theHost || !theHost.length) theHost=title;\n siteURL=which+"//"+theHost+theURL\n }\n if (!siteURL) siteURL="SiteUrl";\n document.getElementById("exportHTTPSiteURL").value=siteURL;;\n // server script/params\n var title=(store.tiddlerExists("unawiki_host"))?"unawiki_host":"SiteHost";\n var theHost=store.getTiddlerText(title);\n if (!theHost || !theHost.length) theHost=document.location.host;\n if (!theHost || !theHost.length) theHost=title;\n // get POST\n var title=(store.tiddlerExists("unawiki_post"))?"unawiki_post":"SitePost";\n var thePost=store.getTiddlerText(title);\n if (!thePost || !thePost.length) thePost="/"+title;\n // get PARAMS\n var title=(store.tiddlerExists("unawiki_params"))?"unawiki_params":"SiteParams";\n var theParams=store.getTiddlerText(title);\n if (!theParams|| !theParams.length) theParams=title;\n var serverURL = which+"//"+theHost+thePost+"?"+theParams;\n document.getElementById("exportHTTPServerURL").value=serverURL;\n break;\n case "ftp:": // FTP EXPORT PANEL\n // host\n var siteHost=store.getTiddlerText("SiteHost");\n if (!siteHost || !siteHost.length) siteHost=document.location.host;\n if (!siteHost || !siteHost.length) siteHost="SiteHost";\n document.getElementById("exportFTPHost").value=siteHost;\n // username\n var siteID=store.getTiddlerText("SiteID");\n if (!siteID || !siteID.length) siteID=config.options.txtUserName;\n document.getElementById("exportFTPID").value=siteID;\n // password\n document.getElementById("exportFTPPW").value="";\n // file/path\n document.getElementById("exportFTPFilename").value="";\n break;\n }\n}\n//}}}\n// //===\n\n// // +++[exportInitFilter()]\n//{{{\nfunction exportInitFilter() {\n // TBD: persistent settings via local cookies\n // start date\n document.getElementById("exportFilterStart").checked=false;\n document.getElementById("exportStartDate").value="";\n // end date\n document.getElementById("exportFilterEnd").checked=false;\n document.getElementById("exportEndDate").value="";\n // tags\n document.getElementById("exportFilterTags").checked=false;\n document.getElementById("exportTags").value="not excludeExport";\n // text\n document.getElementById("exportFilterText").checked=false;\n document.getElementById("exportText").value="";\n // show/hide filter input fields\n exportShowFilterFields();\n}\n//}}}\n// //===\n\n// // +++[exportShowFilterFields(which)]\n//{{{\nfunction exportShowFilterFields(which) {\n var show;\n\n show=document.getElementById('exportFilterStart').checked;\n document.getElementById('exportFilterStartBy').style.display=show?"block":"none";\n document.getElementById('exportStartDate').style.display=show?"block":"none";\n var val=document.getElementById('exportFilterStartBy').value;\n document.getElementById('exportStartDate').value\n =getFilterDate(val,'exportStartDate').formatString(config.macros.exportTiddlers.datetimefmt);\n if (which && (which.id=='exportFilterStartBy') && (val=='other'))\n document.getElementById('exportStartDate').focus();\n\n show=document.getElementById('exportFilterEnd').checked;\n document.getElementById('exportFilterEndBy').style.display=show?"block":"none";\n document.getElementById('exportEndDate').style.display=show?"block":"none";\n var val=document.getElementById('exportFilterEndBy').value;\n document.getElementById('exportEndDate').value\n =getFilterDate(val,'exportEndDate').formatString(config.macros.exportTiddlers.datetimefmt);\n if (which && (which.id=='exportFilterEndBy') && (val=='other'))\n document.getElementById('exportEndDate').focus();\n\n show=document.getElementById('exportFilterTags').checked;\n document.getElementById('exportTags').style.display=show?"block":"none";\n\n show=document.getElementById('exportFilterText').checked;\n document.getElementById('exportText').style.display=show?"block":"none";\n}\n//}}}\n// //===\n// //===\n\n// // +++[onClickExportButton(which): control interactions]\n//{{{\nfunction onClickExportButton(which)\n{\n // DEBUG alert(which.id);\n var theList=document.getElementById('exportList'); if (!theList) return;\n var count = 0;\n var total = store.getTiddlers('title').length;\n switch (which.id)\n {\n case 'exportFilter':\n count=filterExportList();\n var panel=document.getElementById('exportFilterPanel');\n if (count==-1) { panel.style.display='block'; break; }\n theList.options[0].text=formatExportListHeader(count,total);\n document.getElementById("exportStart").disabled=(count==0);\n clearMessage(); displayMessage("filtered "+theList.options[0].text);\n if (count==0) { alert("No tiddlers were selected"); panel.style.display='block'; }\n break;\n case 'exportStart':\n exportTiddlers();\n break;\n case 'exportHideFilter':\n case 'exportToggleFilter':\n var panel=document.getElementById('exportFilterPanel')\n panel.style.display=(panel.style.display=='block')?'none':'block';\n break;\n case 'exportSelectChanges':\n var lastmod=new Date(document.lastModified);\n for (var t = 0; t < theList.options.length; t++) {\n if (theList.options[t].value=="") continue;\n var tiddler=store.getTiddler(theList.options[t].value); if (!tiddler) continue;\n theList.options[t].selected=(tiddler.modified>lastmod);\n count += (tiddler.modified>lastmod)?1:0;\n }\n theList.options[0].text=formatExportListHeader(count,total);\n document.getElementById("exportStart").disabled=(count==0);\n clearMessage(); displayMessage(theList.options[0].text);\n if (count==0) alert("There are no unsaved changes");\n break;\n case 'exportSelectAll':\n for (var t = 0; t < theList.options.length; t++) {\n if (theList.options[t].value=="") continue;\n theList.options[t].selected=true;\n count += 1;\n }\n theList.options[0].text=formatExportListHeader(count,count);\n document.getElementById("exportStart").disabled=(count==0);\n clearMessage(); displayMessage(theList.options[0].text);\n break;\n case 'exportSelectOpened':\n for (var t = 0; t < theList.options.length; t++) theList.options[t].selected=false;\n var tiddlerDisplay = document.getElementById("tiddlerDisplay");\n for (var t=0;t<tiddlerDisplay.childNodes.length;t++) {\n var tiddler=tiddlerDisplay.childNodes[t].id.substr(7);\n for (var i = 0; i < theList.options.length; i++) {\n if (theList.options[i].value!=tiddler) continue;\n theList.options[i].selected=true; count++; break;\n }\n }\n theList.options[0].text=formatExportListHeader(count,total);\n document.getElementById("exportStart").disabled=(count==0);\n clearMessage(); displayMessage(theList.options[0].text);\n if (count==0) alert("There are no tiddlers currently opened");\n break;\n case 'exportListSmaller': // decrease current listbox size\n var min=5;\n theList.size-=(theList.size>min)?1:0;\n break;\n case 'exportListLarger': // increase current listbox size\n var max=(theList.options.length>25)?theList.options.length:25;\n theList.size+=(theList.size<max)?1:0;\n break;\n case 'exportClose':\n document.getElementById('exportPanel').style.display='none';\n break;\n }\n}\n//}}}\n// //===\n\n// // +++[list display]\n//{{{\nfunction formatExportListHeader(count,total)\n{\n var txt=total+' tiddler'+((total!=1)?'s':'')+" - ";\n txt += (count==0)?"none":(count==total)?"all":count;\n txt += " selected for export";\n return txt;\n}\n\nfunction refreshExportList(selectedIndex)\n{\n var theList = document.getElementById("exportList");\n var sort;\n if (!theList) return;\n // get the sort order\n if (!selectedIndex) selectedIndex=0;\n if (selectedIndex==0) sort='modified';\n if (selectedIndex==1) sort='title';\n if (selectedIndex==2) sort='modified';\n if (selectedIndex==3) sort='modifier';\n\n // get the alphasorted list of tiddlers\n var tiddlers = store.getTiddlers('title');\n // unselect headings and count number of tiddlers actually selected\n var count=0;\n for (var i=0; i<theList.options.length; i++) {\n if (theList.options[i].value=="") theList.options[i].selected=false;\n count+=theList.options[i].selected?1:0;\n }\n // disable "export" button if no tiddlers selected\n document.getElementById("exportStart").disabled=(count==0);\n // update listbox heading to show selection count\n if (theList.options.length)\n theList.options[0].text=formatExportListHeader(count,tiddlers.length);\n\n // if a [command] item, reload list... otherwise, no further refresh needed\n if (selectedIndex>3) return;\n\n // clear current list contents\n while (theList.length > 0) { theList.options[0] = null; }\n // add heading and control items to list\n var i=0;\n var indent=String.fromCharCode(160)+String.fromCharCode(160);\n theList.options[i++]=\n new Option(formatExportListHeader(0,tiddlers.length), "",false,false);\n theList.options[i++]=\n new Option(((sort=="title" )?">":indent)+' [by title]', "",false,false);\n theList.options[i++]=\n new Option(((sort=="modified")?">":indent)+' [by date]', "",false,false);\n theList.options[i++]=\n new Option(((sort=="modifier")?">":indent)+' [by author]', "",false,false);\n // output the tiddler list\n switch(sort)\n {\n case "title":\n for(var t = 0; t < tiddlers.length; t++)\n theList.options[i++] = new Option(tiddlers[t].title,tiddlers[t].title,false,false);\n break;\n case "modifier":\n case "modified":\n var tiddlers = store.getTiddlers(sort);\n // sort descending for newest date first\n tiddlers.sort(function (a,b) {if(a[sort] == b[sort]) return(0); else return (a[sort] > b[sort]) ? -1 : +1; });\n var lastSection = "";\n for(var t = 0; t < tiddlers.length; t++)\n {\n var tiddler = tiddlers[t];\n var theSection = "";\n if (sort=="modified") theSection=tiddler.modified.toLocaleDateString();\n if (sort=="modifier") theSection=tiddler.modifier;\n if (theSection != lastSection)\n {\n theList.options[i++] = new Option(theSection,"",false,false);\n lastSection = theSection;\n }\n theList.options[i++] = new Option(indent+indent+tiddler.title,tiddler.title,false,false);\n }\n break;\n }\n theList.selectedIndex=selectedIndex; // select current control item\n}\n//}}}\n// //===\n\n// // +++[list filtering]\n//{{{\nfunction getFilterDate(val,id)\n{\n var result=0;\n switch (val) {\n case 'site':\n var timestamp=store.getTiddlerText("SiteDate");\n if (!timestamp) timestamp=document.lastModified;\n result=new Date(timestamp);\n break;\n case 'file':\n result=new Date(document.lastModified);\n break;\n case 'other':\n result=new Date(document.getElementById(id).value);\n break;\n default: // today=0, yesterday=1, one week=7, two weeks=14, a month=31\n var now=new Date(); var tz=now.getTimezoneOffset()*60000; now-=tz;\n var oneday=86400000;\n if (id=='exportStartDate')\n result=new Date((Math.floor(now/oneday)-val)*oneday+tz);\n else\n result=new Date((Math.floor(now/oneday)-val+1)*oneday+tz-1);\n break;\n }\n // DEBUG alert('getFilterDate('+val+','+id+')=='+result+"\snnow="+now);\n return result;\n}\n\nfunction filterExportList()\n{\n var theList = document.getElementById("exportList"); if (!theList) return -1;\n\n var filterStart=document.getElementById("exportFilterStart").checked;\n var val=document.getElementById("exportFilterStartBy").value;\n var startDate=getFilterDate(val,'exportStartDate');\n\n var filterEnd=document.getElementById("exportFilterEnd").checked;\n var val=document.getElementById("exportFilterEndBy").value;\n var endDate=getFilterDate(val,'exportEndDate');\n\n var filterTags=document.getElementById("exportFilterTags").checked;\n var tags=document.getElementById("exportTags").value;\n\n var filterText=document.getElementById("exportFilterText").checked;\n var text=document.getElementById("exportText").value;\n\n if (!(filterStart||filterEnd||filterTags||filterText)) {\n alert("Please set the selection filter");\n document.getElementById('exportFilterPanel').style.display="block";\n return -1;\n }\n if (filterStart&&filterEnd&&(startDate>endDate)) {\n var msg="starting date/time:\sn"\n msg+=startDate.toLocaleString()+"\sn";\n msg+="is later than ending date/time:\sn"\n msg+=endDate.toLocaleString()\n alert(msg);\n return -1;\n }\n\n // scan list and select tiddlers that match all applicable criteria\n var total=0;\n var count=0;\n for (var i=0; i<theList.options.length; i++) {\n // get item, skip non-tiddler list items (section headings)\n var opt=theList.options[i]; if (opt.value=="") continue;\n // get tiddler, skip missing tiddlers (this should NOT happen)\n var tiddler=store.getTiddler(opt.value); if (!tiddler) continue; \n var sel=true;\n if ( (filterStart && tiddler.modified<startDate)\n || (filterEnd && tiddler.modified>endDate)\n || (filterTags && !matchTags(tiddler,tags))\n || (filterText && (tiddler.text.indexOf(text)==-1) && (tiddler.title.indexOf(text)==-1)))\n sel=false;\n opt.selected=sel;\n count+=sel?1:0;\n total++;\n }\n return count;\n}\n//}}}\n\n//{{{\nfunction matchTags(tiddler,cond)\n{\n if (!cond||!cond.trim().length) return false;\n\n // build a regex of all tags as a big-old regex that \n // OR's the tags together (tag1|tag2|tag3...) in length order\n var tgs = store.getTags();\n if ( tgs.length == 0 ) return results ;\n var tags = tgs.sort( function(a,b){return (a[0].length<b[0].length)-(a[0].length>b[0].length);});\n var exp = "(" + tags.join("|") + ")" ;\n exp = exp.replace( /(,[\sd]+)/g, "" ) ;\n var regex = new RegExp( exp, "ig" );\n\n // build a string such that an expression that looks like this: tag1 AND tag2 OR NOT tag3\n // turns into : /tag1/.test(...) && /tag2/.test(...) || ! /tag2/.test(...)\n cond = cond.replace( regex, "/$1\s\s|/.test(tiddlerTags)" );\n cond = cond.replace( /\ssand\ss/ig, " && " ) ;\n cond = cond.replace( /\ssor\ss/ig, " || " ) ;\n cond = cond.replace( /\ss?not\ss/ig, " ! " ) ;\n\n // if a boolean uses a tag that doesn't exist - it will get left alone \n // (we only turn existing tags into actual tests).\n // replace anything that wasn't found as a tag, AND, OR, or NOT with the string "false"\n // if the tag doesn't exist then /tag/.test(...) will always return false.\n cond = cond.replace( /(\ss|^)+[^\s/\s|&!][^\ss]*/g, "false" ) ;\n\n // make a string of the tags in the tiddler and eval the 'cond' string against that string \n // if it's TRUE then the tiddler qualifies!\n var tiddlerTags = (tiddler.tags?tiddler.tags.join("|"):"")+"|" ;\n try { if ( eval( cond ) ) return true; }\n catch( e ) { displayMessage("Error in tag filter '" + e + "'" ); }\n return false;\n}\n//}}}\n// //===\n\n// // +++[output data formatting]>\n// // +++[exportHeader(format)]\n//{{{\nfunction exportHeader(format)\n{\n switch (format) {\n case "TW": return exportTWHeader();\n case "DIV": return exportDIVHeader();\n case "XML": return exportXMLHeader();\n }\n}\n//}}}\n// //===\n\n// // +++[exportFooter(format)]\n//{{{\nfunction exportFooter(format)\n{\n switch (format) {\n case "TW": return exportDIVFooter();\n case "DIV": return exportDIVFooter();\n case "XML": return exportXMLFooter();\n }\n}\n//}}}\n// //===\n\n// // +++[exportTWHeader()]\n//{{{\nfunction exportTWHeader()\n{\n // Get the URL of the document\n var originalPath = document.location.toString();\n // Check we were loaded from a file URL\n if(originalPath.substr(0,5) != "file:")\n { alert(config.messages.notFileUrlError); return; }\n // Remove any location part of the URL\n var hashPos = originalPath.indexOf("#"); if(hashPos != -1) originalPath = originalPath.substr(0,hashPos);\n // Convert to a native file format assuming\n // "file:///x:/path/path/path..." - pc local file --> "x:\spath\spath\spath..."\n // "file://///server/share/path/path/path..." - FireFox pc network file --> "\s\sserver\sshare\spath\spath\spath..."\n // "file:///path/path/path..." - mac/unix local file --> "/path/path/path..."\n // "file://server/share/path/path/path..." - pc network file --> "\s\sserver\sshare\spath\spath\spath..."\n var localPath;\n if(originalPath.charAt(9) == ":") // pc local file\n localPath = unescape(originalPath.substr(8)).replace(new RegExp("/","g"),"\s\s");\n else if(originalPath.indexOf("file://///") == 0) // FireFox pc network file\n localPath = "\s\s\s\s" + unescape(originalPath.substr(10)).replace(new RegExp("/","g"),"\s\s");\n else if(originalPath.indexOf("file:///") == 0) // mac/unix local file\n localPath = unescape(originalPath.substr(7));\n else if(originalPath.indexOf("file:/") == 0) // mac/unix local file\n localPath = unescape(originalPath.substr(5));\n else // pc network file\n localPath = "\s\s\s\s" + unescape(originalPath.substr(7)).replace(new RegExp("/","g"),"\s\s");\n // Load the original file\n var original = loadFile(localPath);\n if(original == null)\n { alert(config.messages.cantSaveError); return; }\n // Locate the storeArea div's\n var posOpeningDiv = original.indexOf(startSaveArea);\n var posClosingDiv = original.lastIndexOf(endSaveArea);\n if((posOpeningDiv == -1) || (posClosingDiv == -1))\n { alert(config.messages.invalidFileError.format([localPath])); return; }\n return original.substr(0,posOpeningDiv+startSaveArea.length)\n}\n//}}}\n// //===\n\n// // +++[exportDIVHeader()]\n//{{{\nfunction exportDIVHeader()\n{\n var out=[];\n var now = new Date();\n var u = store.getTiddlerText("SiteUrl",null);\n var title = wikifyPlain("SiteTitle").htmlEncode();\n var subtitle = wikifyPlain("SiteSubtitle").htmlEncode();\n var user = config.options.txtUserName.htmlEncode();\n var twver = version.major+"."+version.minor+"."+version.revision;\n var pver = version.extensions.exportTiddlers.major+"."\n +version.extensions.exportTiddlers.minor+"."+version.extensions.exportTiddlers.revision;\n out.push("<html><body>");\n out.push("<style type=\s"text/css\s">");\n out.push("#storeArea {display:block;margin:1em;}");\n out.push("#storeArea div");\n out.push("{padding:0.5em;margin:1em;border:2px solid black;height:10em;overflow:auto;}");\n out.push("#javascriptWarning");\n out.push("{width:100%;text-align:left;background-color:#eeeeee;padding:1em;}");\n out.push("</style>");\n out.push("<div id=\s"javascriptWarning\s">");\n out.push("TiddlyWiki export file<br>");\n out.push("Source: <b>"+document.location+"</b><br>");\n out.push("Title: <b>"+title+"</b><br>");\n out.push("Subtitle: <b>"+subtitle+"</b><br>");\n out.push("Created: <b>"+now.toLocaleString()+"</b> by <b>"+user+"</b><br>");\n out.push("TiddlyWiki "+twver+" / "+"ExportTiddlersPlugin "+pver+"<br>");\n out.push("</div>");\n out.push("<div id=\s"storeArea\s">");\n return out;\n}\n//}}}\n// //===\n\n// // +++[exportDIVFooter()]\n//{{{\nfunction exportDIVFooter()\n{\n var out=[];\n out.push("</div></body></html>");\n return out;\n}\n//}}}\n// //===\n\n// // +++[exportXMLHeader()]\n//{{{\nfunction exportXMLHeader()\n{\n var out=[];\n var now = new Date();\n var u = store.getTiddlerText("SiteUrl",null);\n var title = wikifyPlain("SiteTitle").htmlEncode();\n var subtitle = wikifyPlain("SiteSubtitle").htmlEncode();\n var user = config.options.txtUserName.htmlEncode();\n var twver = version.major+"."+version.minor+"."+version.revision;\n var pver = version.extensions.exportTiddlers.major+"."\n +version.extensions.exportTiddlers.minor+"."+version.extensions.exportTiddlers.revision;\n out.push("<" + "?xml version=\s"1.0\s"?" + ">");\n out.push("<rss version=\s"2.0\s">");\n out.push("<channel>");\n out.push("<title>" + title + "</title>");\n if(u) out.push("<link>" + u.htmlEncode() + "</link>");\n out.push("<description>" + subtitle + "</description>");\n out.push("<language>en-us</language>");\n out.push("<copyright>Copyright " + now.getFullYear() + " " + user + "</copyright>");\n out.push("<pubDate>" + now.toGMTString() + "</pubDate>");\n out.push("<lastBuildDate>" + now.toGMTString() + "</lastBuildDate>");\n out.push("<docs>http://blogs.law.harvard.edu/tech/rss</docs>");\n out.push("<generator>TiddlyWiki "+twver+" plus ExportTiddlersPlugin "+pver+"</generator>");\n return out;\n}\n//}}}\n// //===\n\n// // +++[exportXMLFooter()]\n//{{{\nfunction exportXMLFooter()\n{\n var out=[];\n out.push("</channel></rss>");\n return out;\n}\n//}}}\n// //===\n\n// // +++[exportData()]\n//{{{\nfunction exportData(theList,theFormat)\n{\n // scan export listbox and collect DIVs or XML for selected tiddler content\n var out=[];\n for (var i=0; i<theList.options.length; i++) {\n // get item, skip non-selected items and section headings\n var opt=theList.options[i]; if (!opt.selected||(opt.value=="")) continue;\n // get tiddler, skip missing tiddlers (this should NOT happen)\n var thisTiddler=store.getTiddler(opt.value); if (!thisTiddler) continue; \n if (theFormat=="TW") out.push(thisTiddler.saveToDiv());\n if (theFormat=="DIV") out.push(thisTiddler.title+"\sn"+thisTiddler.saveToDiv());\n if (theFormat=="XML") out.push(thisTiddler.saveToRss());\n }\n return out;\n}\n//}}}\n// //===\n// //===\n\n// // +++[exportTiddlers(): output selected data to local or server]\n//{{{\nfunction exportTiddlers()\n{\n var theList = document.getElementById("exportList"); if (!theList) return;\n\n // get the export settings\n var theProtocol = document.getElementById("exportTo").value;\n var theFormat = document.getElementById("exportFormat").value;\n\n // assemble output: header + tiddlers + footer\n var theData=exportData(theList,theFormat);\n var count=theData.length;\n var out=[]; var txt=out.concat(exportHeader(theFormat),theData,exportFooter(theFormat)).join("\sn");\n var msg="";\n switch (theProtocol) {\n case "file:":\n var theTarget = document.getElementById("exportFilename").value.trim();\n if (!theTarget.length) msg = "A local path/filename is required\sn";\n if (!msg && saveFile(theTarget,txt))\n msg=count+" tiddler"+((count!=1)?"s":"")+" exported to local file";\n else if (!msg)\n msg+="An error occurred while saving to "+theTarget;\n break;\n case "http:":\n case "https:":\n var theTarget = document.getElementById("exportHTTPServerURL").value.trim();\n if (!theTarget.length) msg = "A server URL is required\sn";\n if (!msg && exportPost(theTarget+encodeURIComponent(txt)))\n msg=count+" tiddler"+((count!=1)?"s":"")+" exported to "+theProtocol+" server";\n else if (!msg)\n msg+="An error occurred while saving to "+theTarget;\n break;\n case "ftp:":\n default:\n msg="Sorry, export to "+theLocation+" is not yet available";\n break;\n }\n clearMessage(); displayMessage(msg,theTarget);\n}\n//}}}\n// //===\n\n// // +++[exportPost(url): cross-domain post] uses hidden iframe to submit url and capture responses\n//{{{\nfunction exportPost(url)\n{\n var f=document.getElementById("exportFrame"); if (f) document.body.removeChild(f);\n f=document.createElement("iframe"); f.id="exportFrame";\n f.style.width="0px"; f.style.height="0px"; f.style.border="0px";\n document.body.appendChild(f);\n var d=f.document;\n if (f.contentDocument) d=f.contentDocument; // For NS6\n else if (f.contentWindow) d=f.contentWindow.document; // For IE5.5 and IE6\n d.location.replace(url);\n return true;\n}\n//}}}\n// //===\n
!!Monmaster directory structure\ntop level - currently /projects/monmaster:\n> files:\n>> monmaster.py\n>> monmaster - executable symlink to monmaster.py\n>> logging.cfg - used by snakeserver\n> directories:\n>> in each testsuite configuration directory (e.g., production):\n>>> files:\n>>>> logging.cfg - for monmaster logs\n>>>> testsuite.xml - parameter files for testsuite\n>>>> production.log - log file\n>>>> production.pid - file containing process id if currently running in daemon mode\n>>> directories:\n>>>> dump - stores HTML pages with errors for this testsuite FIXME\n>> snakeserver\n>>> all snakelets program modules, configuration, and subdirectories\n>>> webapps - holds all snakelets application files\n>>> ROOT - this is the snakelets application for Monmaster's web UI\n>>>> files:\n>>>>> {{{__init__.py}}}\n ... FIXME\n\n ... FIXME\n
/***\n|''Name:''|ForEachTiddlerPlugin|\n|''Version:''|1.0.5 (2006-02-05)|\n|''Source:''|http://tiddlywiki.abego-software.de/#ForEachTiddlerPlugin|\n|''Author:''|UdoBorkowski (ub [at] abego-software [dot] de)|\n|''Licence:''|[[BSD open source license]]|\n|''Macros:''|[[ForEachTiddlerMacro]] v1.0.5|\n|''TiddlyWiki:''|1.2.38+, 2.0|\n|''Browser:''|Firefox 1.0.4+; Firefox 1.5; InternetExplorer 6.0|\n!Description\n\nCreate customizable lists, tables etc. for your selections of tiddlers. Specify the tiddlers to include and their order through a powerful language.\n\n''Syntax:'' \n|>|{{{<<}}}''forEachTiddler'' [''in'' //tiddlyWikiPath//] [''where'' //whereCondition//] [''sortBy'' //sortExpression// [''ascending'' //or// ''descending'']] [''script'' //scriptText//] [//action// [//actionParameters//]]{{{>>}}}|\n|//tiddlyWikiPath//|The filepath to the TiddlyWiki the macro should work on. When missing the current TiddlyWiki is used.|\n|//whereCondition//|(quoted) JavaScript boolean expression. May refer to the build-in variables {{{tiddler}}} and {{{context}}}.|\n|//sortExpression//|(quoted) JavaScript expression returning "comparable" objects (using '{{{<}}}','{{{>}}}','{{{==}}}'. May refer to the build-in variables {{{tiddler}}} and {{{context}}}.|\n|//scriptText//|(quoted) JavaScript text. Typically defines JavaScript functions that are called by the various JavaScript expressions (whereClause, sortClause, action arguments,...)|\n|//action//|The action that should be performed on every selected tiddler, in the given order. By default the actions [[addToList|AddToListAction]] and [[write|WriteAction]] are supported. When no action is specified [[addToList|AddToListAction]] is used.|\n|//actionParameters//|(action specific) parameters the action may refer while processing the tiddlers (see action descriptions for details). <<tiddler [[JavaScript in actionParameters]]>>|\n|>|~~Syntax formatting: Keywords in ''bold'', optional parts in [...]. 'or' means that exactly one of the two alternatives must exist.~~|\n\nSee details see [[ForEachTiddlerMacro]] and [[ForEachTiddlerExamples]].\n\n!Revision history\n* v1.0.5\n** Pass tiddler containing the macro with wikify, context object also holds reference to tiddler containing the macro ("inTiddler"). Thanks to SimonBaird.\n** Support Firefox 1.5.0.1\n** Internal\n*** Make "JSLint" conform\n*** "Only install once"\n* v1.0.4 (2006-01-06)\n** Support TiddlyWiki 2.0\n* v1.0.3 (2005-12-22)\n** Features: \n*** Write output to a file supports multi-byte environments (Thanks to Bram Chen) \n*** Provide API to access the forEachTiddler functionality directly through JavaScript (see getTiddlers and performMacro)\n** Enhancements:\n*** Improved error messages on InternetExplorer.\n* v1.0.2 (2005-12-10)\n** Features: \n*** context object also holds reference to store (TiddlyWiki)\n** Fixed Bugs: \n*** ForEachTiddler 1.0.1 has broken support on win32 Opera 8.51 (Thanks to BrunoSabin for reporting)\n* v1.0.1 (2005-12-08)\n** Features: \n*** Access tiddlers stored in separated TiddlyWikis through the "in" option. I.e. you are no longer limited to only work on the "current TiddlyWiki".\n*** Write output to an external file using the "toFile" option of the "write" action. With this option you may write your customized tiddler exports.\n*** Use the "script" section to define "helper" JavaScript functions etc. to be used in the various JavaScript expressions (whereClause, sortClause, action arguments,...).\n*** Access and store context information for the current forEachTiddler invocation (through the build-in "context" object) .\n*** Improved script evaluation (for where/sort clause and write scripts).\n* v1.0.0 (2005-11-20)\n** initial version\n\n!Code\n***/\n//{{{\n\n \n//============================================================================\n//============================================================================\n// ForEachTiddlerPlugin\n//============================================================================\n//============================================================================\n\n// Only install once\nif (!version.extensions.ForEachTiddlerPlugin) {\n\nversion.extensions.ForEachTiddlerPlugin = {major: 1, minor: 0, revision: 5, date: new Date(2006,2,5), source: "http://tiddlywiki.abego-software.de/#ForEachTiddlergPlugin"};\n\n// For backward compatibility with TW 1.2.x\n//\nif (!TiddlyWiki.prototype.forEachTiddler) {\n TiddlyWiki.prototype.forEachTiddler = function(callback) {\n for(var t in this.tiddlers) {\n callback.call(this,t,this.tiddlers[t]);\n }\n };\n}\n\n//============================================================================\n// forEachTiddler Macro\n//============================================================================\n\nversion.extensions.forEachTiddler = {major: 1, minor: 0, revision: 5, date: new Date(2006,2,5), provider: "http://tiddlywiki.abego-software.de"};\n\n// ---------------------------------------------------------------------------\n// Configurations and constants \n// ---------------------------------------------------------------------------\n\nconfig.macros.forEachTiddler = {\n // Standard Properties\n label: "forEachTiddler",\n prompt: "Perform actions on a (sorted) selection of tiddlers",\n\n // actions\n actions: {\n addToList: {},\n write: {}\n }\n};\n\n// ---------------------------------------------------------------------------\n// The forEachTiddler Macro Handler \n// ---------------------------------------------------------------------------\n\nconfig.macros.forEachTiddler.getContainingTiddler = function(e) {\n while(e && !hasClass(e,"tiddler"))\n e = e.parentNode;\n var title = e ? e.getAttribute("tiddler") : null; \n return title ? store.getTiddler(title) : null;\n};\n\nconfig.macros.forEachTiddler.handler = function(place,macroName,params,wikifier,paramString,tiddler) {\n // config.macros.forEachTiddler.traceMacroCall(place,macroName,params,wikifier,paramString,tiddler);\n\n if (!tiddler) tiddler = config.macros.forEachTiddler.getContainingTiddler(place);\n // --- Parsing ------------------------------------------\n\n var i = 0; // index running over the params\n // Parse the "in" clause\n var tiddlyWikiPath = undefined;\n if ((i < params.length) && params[i] == "in") {\n i++;\n if (i >= params.length) {\n this.handleError(place, "TiddlyWiki path expected behind 'in'.");\n return;\n }\n tiddlyWikiPath = this.paramEncode((i < params.length) ? params[i] : "");\n i++;\n }\n\n // Parse the where clause\n var whereClause ="true";\n if ((i < params.length) && params[i] == "where") {\n i++;\n whereClause = this.paramEncode((i < params.length) ? params[i] : "");\n i++;\n }\n\n // Parse the sort stuff\n var sortClause = null;\n var sortAscending = true; \n if ((i < params.length) && params[i] == "sortBy") {\n i++;\n if (i >= params.length) {\n this.handleError(place, "sortClause missing behind 'sortBy'.");\n return;\n }\n sortClause = this.paramEncode(params[i]);\n i++;\n\n if ((i < params.length) && (params[i] == "ascending" || params[i] == "descending")) {\n sortAscending = params[i] == "ascending";\n i++;\n }\n }\n\n // Parse the script\n var scriptText = null;\n if ((i < params.length) && params[i] == "script") {\n i++;\n scriptText = this.paramEncode((i < params.length) ? params[i] : "");\n i++;\n }\n\n // Parse the action. \n // When we are already at the end use the default action\n var actionName = "addToList";\n if (i < params.length) {\n if (!config.macros.forEachTiddler.actions[params[i]]) {\n this.handleError(place, "Unknown action '"+params[i]+"'.");\n return;\n } else {\n actionName = params[i]; \n i++;\n }\n } \n \n // Get the action parameter\n // (the parsing is done inside the individual action implementation.)\n var actionParameter = params.slice(i);\n\n\n // --- Processing ------------------------------------------\n try {\n this.performMacro({\n place: place, \n inTiddler: tiddler,\n whereClause: whereClause, \n sortClause: sortClause, \n sortAscending: sortAscending, \n actionName: actionName, \n actionParameter: actionParameter, \n scriptText: scriptText, \n tiddlyWikiPath: tiddlyWikiPath});\n\n } catch (e) {\n this.handleError(place, e);\n }\n};\n\n// Returns an object with properties "tiddlers" and "context".\n// tiddlers holds the (sorted) tiddlers selected by the parameter,\n// context the context of the execution of the macro.\n//\n// The action is not yet performed.\n//\n// @parameter see performMacro\n//\nconfig.macros.forEachTiddler.getTiddlersAndContext = function(parameter) {\n\n var context = config.macros.forEachTiddler.createContext(parameter.place, parameter.whereClause, parameter.sortClause, parameter.sortAscending, parameter.actionName, parameter.actionParameter, parameter.scriptText, parameter.tiddlyWikiPath, parameter.inTiddler);\n\n var tiddlyWiki = parameter.tiddlyWikiPath ? this.loadTiddlyWiki(parameter.tiddlyWikiPath) : store;\n context["tiddlyWiki"] = tiddlyWiki;\n \n // Get the tiddlers, as defined by the whereClause\n var tiddlers = this.findTiddlers(parameter.whereClause, context, tiddlyWiki);\n context["tiddlers"] = tiddlers;\n\n // Sort the tiddlers, when sorting is required.\n if (parameter.sortClause) {\n this.sortTiddlers(tiddlers, parameter.sortClause, parameter.sortAscending, context);\n }\n\n return {tiddlers: tiddlers, context: context};\n};\n\n// Returns the (sorted) tiddlers selected by the parameter.\n//\n// The action is not yet performed.\n//\n// @parameter see performMacro\n//\nconfig.macros.forEachTiddler.getTiddlers = function(parameter) {\n return this.getTiddlersAndContext(parameter).tiddlers;\n};\n\n// Performs the macros with the given parameter.\n//\n// @param parameter holds the parameter of the macro as separate properties.\n// The following properties are supported:\n//\n// place\n// whereClause\n// sortClause\n// sortAscending\n// actionName\n// actionParameter\n// scriptText\n// tiddlyWikiPath\n//\n// All properties are optional. \n// For most actions the place property must be defined.\n//\nconfig.macros.forEachTiddler.performMacro = function(parameter) {\n var tiddlersAndContext = this.getTiddlersAndContext(parameter);\n\n // Perform the action\n var actionName = parameter.actionName ? parameter.actionName : "addToList";\n var action = config.macros.forEachTiddler.actions[actionName];\n if (!action) {\n this.handleError(parameter.place, "Unknown action '"+actionName+"'.");\n return;\n }\n\n var actionHandler = action.handler;\n actionHandler(parameter.place, tiddlersAndContext.tiddlers, parameter.actionParameter, tiddlersAndContext.context);\n};\n\n// ---------------------------------------------------------------------------\n// The actions \n// ---------------------------------------------------------------------------\n\n// Internal.\n//\n// --- The addToList Action -----------------------------------------------\n//\nconfig.macros.forEachTiddler.actions.addToList.handler = function(place, tiddlers, parameter, context) {\n // Parse the parameter\n var p = 0;\n\n // Check for extra parameters\n if (parameter.length > p) {\n config.macros.forEachTiddler.createExtraParameterErrorElement(place, "addToList", parameter, p);\n return;\n }\n\n // Perform the action.\n var list = document.createElement("ul");\n place.appendChild(list);\n for (var i = 0; i < tiddlers.length; i++) {\n var tiddler = tiddlers[i];\n var listItem = document.createElement("li");\n list.appendChild(listItem);\n createTiddlyLink(listItem, tiddler.title, true);\n }\n};\n\n// Internal.\n//\n// --- The write Action ---------------------------------------------------\n//\nconfig.macros.forEachTiddler.actions.write.handler = function(place, tiddlers, parameter, context) {\n // Parse the parameter\n var p = 0;\n if (p >= parameter.length) {\n this.handleError(place, "Missing expression behind 'write'.");\n return;\n }\n\n var textExpression = config.macros.forEachTiddler.paramEncode(parameter[p]);\n p++;\n\n // Parse the "toFile" option\n var filename = null;\n var lineSeparator = undefined;\n if ((p < parameter.length) && parameter[p] == "toFile") {\n p++;\n if (p >= parameter.length) {\n this.handleError(place, "Filename expected behind 'toFile' of 'write' action.");\n return;\n }\n \n filename = config.macros.forEachTiddler.getLocalPath(config.macros.forEachTiddler.paramEncode(parameter[p]));\n p++;\n if ((p < parameter.length) && parameter[p] == "withLineSeparator") {\n p++;\n if (p >= parameter.length) {\n this.handleError(place, "Line separator text expected behind 'withLineSeparator' of 'write' action.");\n return;\n }\n lineSeparator = config.macros.forEachTiddler.paramEncode(parameter[p]);\n p++;\n }\n }\n \n // Check for extra parameters\n if (parameter.length > p) {\n config.macros.forEachTiddler.createExtraParameterErrorElement(place, "write", parameter, p);\n return;\n }\n\n // Perform the action.\n var func = config.macros.forEachTiddler.getEvalTiddlerFunction(textExpression, context);\n var count = tiddlers.length;\n var text = "";\n for (var i = 0; i < count; i++) {\n var tiddler = tiddlers[i];\n text += func(tiddler, context, count, i);\n }\n \n if (filename) {\n if (lineSeparator !== undefined) {\n lineSeparator = lineSeparator.replace(/\s\sn/mg, "\sn").replace(/\s\sr/mg, "\sr");\n text = text.replace(/\sn/mg,lineSeparator);\n }\n saveFile(filename, convertUnicodeToUTF8(text));\n } else {\n var wrapper = createTiddlyElement(place, "span");\n wikify(text, wrapper, null/* highlightRegExp */, context.inTiddler);\n }\n};\n\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n// Internal.\n//\nconfig.macros.forEachTiddler.createContext = function(placeParam, whereClauseParam, sortClauseParam, sortAscendingParam, actionNameParam, actionParameterParam, scriptText, tiddlyWikiPathParam, inTiddlerParam) {\n return {\n place : placeParam, \n whereClause : whereClauseParam, \n sortClause : sortClauseParam, \n sortAscending : sortAscendingParam, \n script : scriptText,\n actionName : actionNameParam, \n actionParameter : actionParameterParam,\n tiddlyWikiPath : tiddlyWikiPathParam,\n inTiddler : inTiddlerParam\n };\n};\n\n// Internal.\n//\n// Returns a TiddlyWiki with the tiddlers loaded from the TiddlyWiki of \n// the given path.\n//\nconfig.macros.forEachTiddler.loadTiddlyWiki = function(path, idPrefix) {\n if (!idPrefix) {\n idPrefix = "store";\n }\n var lenPrefix = idPrefix.length;\n \n // Read the content of the given file\n var content = loadFile(this.getLocalPath(path));\n if(content === null) {\n throw "TiddlyWiki '"+path+"' not found.";\n }\n \n // Locate the storeArea div's\n var posOpeningDiv = content.indexOf(startSaveArea);\n var posClosingDiv = content.lastIndexOf(endSaveArea);\n if((posOpeningDiv == -1) || (posClosingDiv == -1)) {\n throw "File '"+path+"' is not a TiddlyWiki.";\n }\n var storageText = content.substr(posOpeningDiv + startSaveArea.length, posClosingDiv);\n \n // Create a "div" element that contains the storage text\n var myStorageDiv = document.createElement("div");\n myStorageDiv.innerHTML = storageText;\n myStorageDiv.normalize();\n \n // Create all tiddlers in a new TiddlyWiki\n // (following code is modified copy of TiddlyWiki.prototype.loadFromDiv)\n var tiddlyWiki = new TiddlyWiki();\n var store = myStorageDiv.childNodes;\n for(var t = 0; t < store.length; t++) {\n var e = store[t];\n var title = null;\n if(e.getAttribute)\n title = e.getAttribute("tiddler");\n if(!title && e.id && e.id.substr(0,lenPrefix) == idPrefix)\n title = e.id.substr(lenPrefix);\n if(title && title !== "") {\n var tiddler = tiddlyWiki.createTiddler(title);\n tiddler.loadFromDiv(e,title);\n }\n }\n tiddlyWiki.dirty = false;\n\n return tiddlyWiki;\n};\n\n\n \n// Internal.\n//\n// Returns a function that has a function body returning the given javaScriptExpression.\n// The function has the parameters:\n// \n// (tiddler, context, count, index)\n//\nconfig.macros.forEachTiddler.getEvalTiddlerFunction = function (javaScriptExpression, context) {\n var script = context["script"];\n var functionText = "var theFunction = function(tiddler, context, count, index) { return "+javaScriptExpression+"}";\n var fullText = (script ? script+";" : "")+functionText+";theFunction;";\n return eval(fullText);\n};\n\n// Internal.\n//\nconfig.macros.forEachTiddler.findTiddlers = function(whereClause, context, tiddlyWiki) {\n var result = [];\n var func = config.macros.forEachTiddler.getEvalTiddlerFunction(whereClause, context);\n tiddlyWiki.forEachTiddler(function(title,tiddler) {\n if (func(tiddler, context, undefined, undefined)) {\n result.push(tiddler);\n }\n });\n return result;\n};\n\n// Internal.\n//\nconfig.macros.forEachTiddler.createExtraParameterErrorElement = function(place, actionName, parameter, firstUnusedIndex) {\n var message = "Extra parameter behind '"+actionName+"':";\n for (var i = firstUnusedIndex; i < parameter.length; i++) {\n message += " "+parameter[i];\n }\n this.handleError(place, message);\n};\n\n// Internal.\n//\nconfig.macros.forEachTiddler.sortAscending = function(tiddlerA, tiddlerB) {\n var result = \n (tiddlerA.forEachTiddlerSortValue == tiddlerB.forEachTiddlerSortValue) \n ? 0\n : (tiddlerA.forEachTiddlerSortValue < tiddlerB.forEachTiddlerSortValue)\n ? -1 \n : +1; \n return result;\n};\n\n// Internal.\n//\nconfig.macros.forEachTiddler.sortDescending = function(tiddlerA, tiddlerB) {\n var result = \n (tiddlerA.forEachTiddlerSortValue == tiddlerB.forEachTiddlerSortValue) \n ? 0\n : (tiddlerA.forEachTiddlerSortValue < tiddlerB.forEachTiddlerSortValue)\n ? +1 \n : -1; \n return result;\n};\n\n// Internal.\n//\nconfig.macros.forEachTiddler.sortTiddlers = function(tiddlers, sortClause, ascending, context) {\n // To avoid evaluating the sortClause whenever two items are compared \n // we pre-calculate the sortValue for every item in the array and store it in a \n // temporary property ("forEachTiddlerSortValue") of the tiddlers.\n var func = config.macros.forEachTiddler.getEvalTiddlerFunction(sortClause, context);\n var count = tiddlers.length;\n var i;\n for (i = 0; i < count; i++) {\n var tiddler = tiddlers[i];\n tiddler.forEachTiddlerSortValue = func(tiddler,context, undefined, undefined);\n }\n\n // Do the sorting\n tiddlers.sort(ascending ? this.sortAscending : this.sortDescending);\n\n // Delete the temporary property that holds the sortValue. \n for (i = 0; i < tiddlers.length; i++) {\n delete tiddlers[i].forEachTiddlerSortValue;\n }\n};\n\n\n// Internal.\n//\nconfig.macros.forEachTiddler.trace = function(message) {\n displayMessage(message);\n};\n\n// Internal.\n//\nconfig.macros.forEachTiddler.traceMacroCall = function(place,macroName,params) {\n var message ="<<"+macroName;\n for (var i = 0; i < params.length; i++) {\n message += " "+params[i];\n }\n message += ">>";\n displayMessage(message);\n};\n\n\n// Internal.\n//\n// Creates an element that holds an error message\n// \nconfig.macros.forEachTiddler.createErrorElement = function(place, exception) {\n var message = (exception.description) ? exception.description : exception.toString();\n return createTiddlyElement(place,"span",null,"forEachTiddlerError","<<forEachTiddler ...>>: "+message);\n};\n\n// Internal.\n//\n// @param place [may be null]\n//\nconfig.macros.forEachTiddler.handleError = function(place, exception) {\n if (place) {\n this.createErrorElement(place, exception);\n } else {\n throw exception;\n }\n};\n\n// Internal.\n//\n// Encodes the given string.\n//\n// Replaces \n// "$))" to ">>"\n// "$)" to ">"\n//\nconfig.macros.forEachTiddler.paramEncode = function(s) {\n var reGTGT = new RegExp("\s\s$\s\s)\s\s)","mg");\n var reGT = new RegExp("\s\s$\s\s)","mg");\n return s.replace(reGTGT, ">>").replace(reGT, ">");\n};\n\n// Internal.\n//\n// Returns the given original path (that is a file path, starting with "file:")\n// as a path to a local file, in the systems native file format.\n//\n// Location information in the originalPath (i.e. the "#" and stuff following)\n// is stripped.\n// \nconfig.macros.forEachTiddler.getLocalPath = function(originalPath) {\n // Remove any location part of the URL\n var hashPos = originalPath.indexOf("#");\n if(hashPos != -1)\n originalPath = originalPath.substr(0,hashPos);\n // Convert to a native file format assuming\n // "file:///x:/path/path/path..." - pc local file --> "x:\spath\spath\spath..."\n // "file://///server/share/path/path/path..." - FireFox pc network file --> "\s\sserver\sshare\spath\spath\spath..."\n // "file:///path/path/path..." - mac/unix local file --> "/path/path/path..."\n // "file://server/share/path/path/path..." - pc network file --> "\s\sserver\sshare\spath\spath\spath..."\n var localPath;\n if(originalPath.charAt(9) == ":") // pc local file\n localPath = unescape(originalPath.substr(8)).replace(new RegExp("/","g"),"\s\s");\n else if(originalPath.indexOf("file://///") === 0) // FireFox pc network file\n localPath = "\s\s\s\s" + unescape(originalPath.substr(10)).replace(new RegExp("/","g"),"\s\s");\n else if(originalPath.indexOf("file:///") === 0) // mac/unix local file\n localPath = unescape(originalPath.substr(7));\n else if(originalPath.indexOf("file:/") === 0) // mac/unix local file\n localPath = unescape(originalPath.substr(5));\n else // pc network file\n localPath = "\s\s\s\s" + unescape(originalPath.substr(7)).replace(new RegExp("/","g"),"\s\s"); \n return localPath;\n};\n\n// ---------------------------------------------------------------------------\n// Stylesheet Extensions (may be overridden by local StyleSheet)\n// ---------------------------------------------------------------------------\n//\nsetStylesheet(\n ".forEachTiddlerError{color: #ffffff;background-color: #880000;}",\n "forEachTiddler");\n\n//============================================================================\n// End of forEachTiddler Macro\n//============================================================================\n\n\n//============================================================================\n// String.startsWith Function\n//============================================================================\n//\n// Returns true if the string starts with the given prefix, false otherwise.\n//\nversion.extensions["String.startsWith"] = {major: 1, minor: 0, revision: 0, date: new Date(2005,11,20), provider: "http://tiddlywiki.abego-software.de"};\n//\nString.prototype.startsWith = function(prefix) {\n var n = prefix.length;\n return (this.length >= n) && (this.slice(0, n) == prefix);\n};\n\n\n\n//============================================================================\n// String.endsWith Function\n//============================================================================\n//\n// Returns true if the string ends with the given suffix, false otherwise.\n//\nversion.extensions["String.endsWith"] = {major: 1, minor: 0, revision: 0, date: new Date(2005,11,20), provider: "http://tiddlywiki.abego-software.de"};\n//\nString.prototype.endsWith = function(suffix) {\n var n = suffix.length;\n return (this.length >= n) && (this.right(n) == suffix);\n};\n\n\n//============================================================================\n// String.contains Function\n//============================================================================\n//\n// Returns true when the string contains the given substring, false otherwise.\n//\nversion.extensions["String.contains"] = {major: 1, minor: 0, revision: 0, date: new Date(2005,11,20), provider: "http://tiddlywiki.abego-software.de"};\n//\nString.prototype.contains = function(substring) {\n return this.indexOf(substring) >= 0;\n};\n\n//============================================================================\n// Array.indexOf Function\n//============================================================================\n//\n// Returns the index of the first occurance of the given item in the array or \n// -1 when no such item exists.\n//\n// @param item [may be null]\n//\nversion.extensions["Array.indexOf"] = {major: 1, minor: 0, revision: 0, date: new Date(2005,11,20), provider: "http://tiddlywiki.abego-software.de"};\n//\nArray.prototype.indexOf = function(item) {\n for (var i = 0; i < this.length; i++) {\n if (this[i] == item) {\n return i;\n }\n }\n return -1;\n};\n\n//============================================================================\n// Array.contains Function\n//============================================================================\n//\n// Returns true when the array contains the given item, otherwise false. \n//\n// @param item [may be null]\n//\nversion.extensions["Array.contains"] = {major: 1, minor: 0, revision: 0, date: new Date(2005,11,20), provider: "http://tiddlywiki.abego-software.de"};\n//\nArray.prototype.contains = function(item) {\n return (this.indexOf(item) >= 0);\n};\n\n//============================================================================\n// Array.containsAny Function\n//============================================================================\n//\n// Returns true when the array contains at least one of the elements \n// of the item. Otherwise (or when items contains no elements) false is returned.\n//\nversion.extensions["Array.containsAny"] = {major: 1, minor: 0, revision: 0, date: new Date(2005,11,20), provider: "http://tiddlywiki.abego-software.de"};\n//\nArray.prototype.containsAny = function(items) {\n for(var i = 0; i < items.length; i++) {\n if (this.contains(items[i])) {\n return true;\n }\n }\n return false;\n};\n\n\n//============================================================================\n// Array.containsAll Function\n//============================================================================\n//\n// Returns true when the array contains all the items, otherwise false.\n// \n// When items is null false is returned (even if the array contains a null).\n//\n// @param items [may be null] \n//\nversion.extensions["Array.containsAll"] = {major: 1, minor: 0, revision: 0, date: new Date(2005,11,20), provider: "http://tiddlywiki.abego-software.de"};\n//\nArray.prototype.containsAll = function(items) {\n for(var i = 0; i < items.length; i++) {\n if (!this.contains(items[i])) {\n return false;\n }\n }\n return true;\n};\n\n\n} // of "install only once"\n\n// Used Globals (for JSLint) ==============\n// ... DOM\n/*global document */\n// ... TiddlyWiki Core\n/*global convertUnicodeToUTF8, createTiddlyElement, createTiddlyLink, \n displayMessage, endSaveArea, hasClass, loadFile, saveFile, \n startSaveArea, store, wikify */\n//}}}\n\n\n/***\n!Licence and Copyright\nCopyright (c) abego Software ~GmbH, 2005 ([[www.abego-software.de|http://www.abego-software.de]])\n\nRedistribution and use in source and binary forms, with or without modification,\nare permitted provided that the following conditions are met:\n\nRedistributions of source code must retain the above copyright notice, this\nlist of conditions and the following disclaimer.\n\nRedistributions in binary form must reproduce the above copyright notice, this\nlist of conditions and the following disclaimer in the documentation and/or other\nmaterials provided with the distribution.\n\nNeither the name of abego Software nor the names of its contributors may be\nused to endorse or promote products derived from this software without specific\nprior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY\nEXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\nOF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT\nSHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\nTO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR\nBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\nCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\nANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH\nDAMAGE.\n***/\n\n
This tiddler demonstrates the use of the non-interactive mode of ImportTiddlersPlugin. The following macro is executed each time this tiddler is rendered and automatically imports all new/changed tiddlers from the indicated URL:\n\n{{{<<importTiddlers updates http://www.TiddlyTools.com/example.html ask>>}}}\n<<importTiddlers updates http://www.TiddlyTools.com/example.html ask>>\n
<<importTiddlers inline>>
/***\n''Import Tiddlers Plugin for TiddlyWiki version 1.2.x and 2.0''\n^^author: Eric Shulman - ELS Design Studios\nsource: http://www.TiddlyTools.com/#ImportTiddlersPlugin\nlicense: [[Creative Commons Attribution-ShareAlike 2.5 License|http://creativecommons.org/licenses/by-sa/2.5/]]^^\n\nWhen many people share and edit copies of the same TiddlyWiki document, the ability to quickly collect all these changes back into a single, updated document that can then be redistributed to the entire group is very important. This plugin lets you selectively combine tiddlers from any two TiddlyWiki documents. It can also be very useful when moving your own tiddlers from document to document (e.g., when upgrading to the latest version of TiddlyWiki, or 'pre-loading' your favorite stylesheets into a new 'empty' TiddlyWiki document.)\n\n!!!!!Inline interface (live)\n<<<\n<<importTiddlers inline>>\n<<<\n!!!!!Macro Syntax\n<<<\n{{{<<importTiddlers>>}}}\ncreates "import tiddlers" link. click to show/hide import control panel\n\n{{{<<importTiddlers inline>>}}}\ncreates import control panel directly in tiddler content\n\n{{{<<importTiddlers filter source quiet ask>>}}}\nnon-interactive 'automatic' import.\n''filter'' determines which tiddlers will be automatically selected for importing. Use one of the following keywords:\n>''"new"'' retrieves only tiddlers that are found in the import source document, but do not yet exist in the destination document\n>''"changes"'' retrieves only tiddlers that exist in both documents for which the import source tiddler is newer than the existing tiddler\n>''"updates"'' retrieves both ''new'' and ''changed'' tiddlers (this is the default action when none is specified)\n>''"all"'' retrieves ALL tiddlers from the import source document, even if they have not been changed.\n''source'' is the location of the imported document. It can be either a local document or an URL:\n>filename is any local path/file, in whatever format your system requires\n>URL is any remote web location that starts with "http://" or "https://"\n''"quiet"'' (optional)\n>supresses all status message during the import processing (e.g., "opening local file...", "found NN tiddlers..." etc). Note that if ANY tiddlers are actualy imported, a final information message will still be displayed (along with the ImportedTiddlers report), even when 'quiet' is specified. This ensures that changes to your document cannot occur without any visible indication at all.\n''"ask"'' (optional)\n>adds interactive confirmation. A browser message box (OK/Cancel) is displayed for each tiddler that will be imported, so that you can manually bypass any tiddlers that you do not want to import.\n\n''Special tag values: importReplace and importPublic''\n\nBy adding these special tags to an existing tiddler, you can precisely control whether or not to allow updates to that tiddler as well as decide which tiddlers in your document can be automatically imported by others.\n*''For maximum safety, the default action is to prevent existing tiddlers from being unintentionally overwritten by incoming tiddlers.'' To allow an existing tiddler to be overwritten by an imported tiddler, you must tag the existing tiddler with ''<<tag importReplace>>''\n*''For maximum privacy, the default action for //outgoing// tiddlers is to NOT automatically share your tiddlers with others.'' To allow a tiddler in your document to be shared via auto-import actions by others, you must tag it with ''<<tag importPublic>>''\n//Note: these tags are only applied when using the auto-import processing. When using the interactive control panel, all tiddlers in the imported document are available in the listbox, regardless of their tag values.//\n<<<\n!!!!!Interactive Usage\n<<<\nWhen used interactively, a control panel is displayed consisting of an "import source document" filename input (text field plus a ''[Browse...]'' button), a listbox of available tiddlers, a "differences only" checkbox, an "add tags" input field and four push buttons: ''[open]'', ''[select all]'', ''[import]'' and ''[close]''.\n\nPress ''[browse]'' to select a TiddlyWiki document file to import. You can also type in the path/filename or a remote document URL (starting with http://)and press ''[open]''. //Note: There may be some delay to permit the browser time to access and load the document before updating the listbox with the titles of all tiddlers that are available to be imported.//\n\nSelect one or more titles from the listbox (hold CTRL or SHIFT while clicking to add/remove the highlight from individual list items). You can press ''[select all]'' to quickly highlight all tiddler titles in the list. Use the ''[-]'', ''[+]'', or ''[=]'' links to adjust the listbox size so you can view more (or less) tiddler titles at one time. When you have chosen the tiddlers you want to import and entered any extra tags, press ''[import]'' to begin copying them to the current TiddlyWiki document.\n\n''select: all, new, changes, or differences''\n\nYou can click on ''all'', ''new'', ''changes'', or ''differences'' to automatically select a subset of tiddlers from the list. This makes it very quick and easy to find and import just the updated tiddlers you are interested in:\n>''"all"'' selects ALL tiddlers from the import source document, even if they have not been changed.\n>''"new"'' selects only tiddlers that are found in the import source document, but do not yet exist in the destination document\n>''"changes"'' selects only tiddlers that exist in both documents but that are newer in the source document\n>''"differences"'' selects all new and existing tiddlers that are different from the destination document (even if destination tiddler is newer)\n\n''Import Tagging:''\n\nTiddlers that have been imported can be automatically tagged, so they will be easier to find later on, after they have been added to your document. New tags are entered into the "add tags" input field, and then //added// to the existing tags for each tiddler as it is imported.\n\n''Skip, Rename, Merge, or Replace:''\n\nWhen importing a tiddler whose title is identical to one that already exists, the import process pauses and the tiddler title is displayed in an input field, along with four push buttons: ''[skip]'', ''[rename]'', ''[merge]'' and ''[replace]''.\n\nTo bypass importing this tiddler, press ''[skip]''. To import the tiddler with a different name (so that both the tiddlers will exist when the import is done), enter a new title in the input field and then press ''[rename]''. Press ''[merge]'' to combine the content from both tiddlers into a single tiddler. Press ''[replace]'' to overwrite the existing tiddler with the imported one, discarding the previous tiddler content.\n\n//Note: if both the title ''and'' modification date/////time match, the imported tiddler is assumed to be identical to the existing one, and will be automatically skipped (i.e., not imported) without asking.//\n\n''Import Report History''\n\nWhen tiddlers are imported, a report is generated into ImportedTiddlers, indicating when the latest import was performed, the number of tiddlers successfully imported, from what location, and by whom. It also includes a list with the title, date and author of each tiddler that was imported.\n\nWhen the import process is completed, the ImportedTiddlers report is automatically displayed for your review. If more tiddlers are subsequently imported, a new report is //added// to ImportedTiddlers, above the previous report (i.e., at the top of the tiddler), so that a reverse-chronological history of imports is maintained.\n\nIf a cumulative record is not desired, the ImportedTiddlers report may be deleted at any time. A new ImportedTiddlers report will be created the next time tiddlers are imported.\n\nNote: You can prevent the ImportedTiddlers report from being generated for any given import activity by clearing the "create a report" checkbox before beginning the import processing.\n\n<<<\n!!!!!Installation\n<<<\ncopy/paste the following tiddlers into your document:\n''ImportTiddlersPlugin'' (tagged with <<tag systemConfig>>)\n\ncreate/edit ''SideBarOptions'': (sidebar menu items) \n^^Add "< < ImportTiddlers > >" macro^^\n\n''Quick Installation Tip #1:''\nIf you are using an unmodified version of TiddlyWiki (core release version <<version>>), you can get a new, empty TiddlyWiki with the Import Tiddlers plugin pre-installed (''[[download from here|TW+ImportExport.html]]''), and then simply import all your content from your old document into this new, empty document.\n<<<\n!!!!!Revision History\n<<<\n''2006.02.21 [2.7.1]''\nClean up layout problems with IE. (Use tables for alignment instead of SPANs styled with float:left and float:right)\n''2006.02.21 [2.7.0]''\nAdded "local file" and "web server" radio buttons for selecting dynamic import source controls in ImportPanel. Default file control is replaced with URL text input field when "web server" is selected. Default remote document URL is defined in SiteURL tiddler. Also, added option for prepending SiteProxy URL as prefix to remote URL to mask cross-domain document access (requires compatible server-side script)\n''2006.02.17 [2.6.0]''\nRemoved "differences only" listbox display mode, replaced with selection filter 'presets': all/new/changes/differences. Also fixed initialization handling for "add new tags" so that checkbox state is correctly tracked when panel is first displayed.\n''2006.02.16 [2.5.4]''\nadded checkbox options to control "import remote tags" and "keep existing tags" behavior, in addition to existing "add new tags" functionality.\n''2006.02.14 [2.5.3]''\nFF1501 corrected unintended global 't' (loop index) in importReport() and autoImportTiddlers()\n''2006.02.10 [2.5.2]''\ncorrected unintended global variable in importReport().\n''2006.02.05 [2.5.1]''\nmoved globals from window.* to config.macros.importTiddlers.* to avoid FireFox 1.5.0.1 crash bug when referencing globals\n''2006.01.18 [2.5.0]''\nadded checkbox for "create a report". Default is to create/update the ImportedTiddlers report. Clear the checkbox to skip this step.\n''2006.01.15 [2.4.1]''\nadded "importPublic" tag and inverted default so that auto sharing is NOT done unless tagged with importPublic\n''2006.01.15 [2.4.0]''\nAdded support for tagging individual tiddlers with importSkip, importReplace, and/or importPrivate to control which tiddlers can be overwritten or shared with others when using auto-import macro syntax. Defaults are to SKIP overwriting existing tiddlers with imported tiddlers, and ALLOW your tiddlers to be auto-imported by others.\n''2006.01.15 [2.3.2]''\nAdded "ask" parameter to confirm each tiddler before importing (for use with auto-importing)\n''2006.01.15 [2.3.1]''\nStrip TW core scripts from import source content and load just the storeArea into the hidden IFRAME. Makes loading more efficient by reducing the document size and by preventing the import document from executing its TW initialization (including plugins). Seems to resolve the "Found 0 tiddlers" problem. Also, when importing local documents, use convertUTF8ToUnicode() to convert the file contents so support international characters sets.\n''2006.01.12 [2.3.0]''\nReorganized code to use callback function for loading import files to support event-driven I/O via an ASYNCHRONOUS XMLHttpRequest. Let's processing continue while waiting for remote hosts to respond to URL requests. Added non-interactive 'batch' macro mode, using parameters to specify which tiddlers to import, and from what document source. Improved error messages and diagnostics, plus an optional 'quiet' switch for batch mode to eliminate //most// feedback.\n''2006.01.11 [2.2.0]''\nAdded "[by tags]" to list of tiddlers, based on code submitted by BradleyMeck\n''2006.01.09 [2.1.1]''\nWhen a URL is typed in, and then the "open" button is pressed, it generates both an onChange event for the file input and a click event for open button. This results in multiple XMLHttpRequest()'s which seem to jam things up quite a bit. I removed the onChange handling for file input field. To open a file (local or URL), you must now explicitly press the "open" button in the control panel.\n''2006.01.08 [2.1.0]''\nIMPORT FROM ANYWHERE!!! re-write getImportedTiddlers() logic to either read a local file (using local I/O), OR... read a remote file, using a combination of XML and an iframe to permit cross-domain reading of DOM elements. Adapted from example code and techniques courtesy of Jonny LeRoy.\n''2006.01.06 [2.0.2]''\nWhen refreshing list contents, fixed check for tiddlerExists() when "show differences only" is selected, so that imported tiddlers that don't exist in the current file will be recognized as differences and included in the list.\n''2006.01.04 [2.0.1]''\nWhen "show differences only" is NOT checked, import all tiddlers that have been selected even when they have a matching title and date.\n''2005.12.27 [2.0.0]''\nUpdate for TW2.0\nDefer initial panel creation and only register a notification function when panel first is created\n''2005.12.22 [1.3.1]''\ntweak formatting in importReport() and add 'discard report' link to output\n''2005.12.03 [1.3.0]''\nDynamically create/remove importPanel as needed to ensure only one instance of interface elements exists, even if there are multiple instances of macro embedding. Also, dynamically create/recreate importFrame each time an external TW document is loaded for importation (reduces DOM overhead and ensures a 'fresh' frame for each document)\n''2005.11.29 [1.2.1]''\nfixed formatting of 'detail info' in importReport()\n''2005.11.11 [1.2.0]''\nadded 'inline' param to embed controls in a tiddler\n''2005.11.09 [1.1.0]''\nonly load HTML and CSS the first time the macro handler is called. Allows for redundant placement of the macro without creating multiple instances of controls with the same ID's.\n''2005.10.25 [1.0.5]''\nfixed typo in importReport() that prevented reports from being generated\n''2005.10.09 [1.0.4]''\ncombined documentation with plugin code instead of using separate tiddlers\n''2005.08.05 [1.0.3]''\nmoved CSS and HTML definitions into plugin code instead of using separate tiddlers\n''2005.07.27 [1.0.2]''\ncore update 1.2.29: custom overlayStyleSheet() replaced with new core setStylesheet()\n''2005.07.23 [1.0.1]''\nadded parameter checks and corrected addNotification() usage\n''2005.07.20 [1.0.0]''\nInitial Release\n<<<\n!!!!!Credits\n<<<\nThis feature was developed by EricShulman from [[ELS Design Studios|http:/www.elsdesign.com]]\n<<<\n!!!!!Code\n***/\n\n// // Version\n//{{{\nversion.extensions.importTiddlers = {major: 2, minor: 7, revision: 1, date: new Date(2006,2,21)};\n//}}}\n\n// // 1.2.x compatibility\n//{{{\nif (!window.story) window.story=window;\nif (!store.getTiddler) store.getTiddler=function(title){return store.tiddlers[title]}\nif (!store.addTiddler) store.addTiddler=function(tiddler){store.tiddlers[tiddler.title]=tiddler}\nif (!store.deleteTiddler) store.deleteTiddler=function(title){delete store.tiddlers[title]}\n//}}}\n\n// // IE needs explicit global scoping for functions/vars called from browser events\n//{{{\nwindow.onClickImportButton=onClickImportButton;\nwindow.loadImportFile=loadImportFile;\nwindow.refreshImportList=refreshImportList;\n//}}}\n\n// // default cookie/option values\n//{{{\nif (!config.options.chkImportReport) config.options.chkImportReport=true;\n//}}}\n\n\n// // ''MACRO DEFINITION''\n\n//{{{\nconfig.macros.importTiddlers = { };\nconfig.macros.importTiddlers = {\n label: "import tiddlers",\n prompt: "Copy tiddlers from another document",\n countMsg: "%0 tiddlers selected for import",\n src: "", // path/filename or URL of document to import (retrieved from SiteUrl tiddler)\n proxy: "", // URL for remote proxy script (retrieved from SiteProxy tiddler)\n useProxy: false, // use specific proxy script in front of remote URL\n inbound: null, // hash-indexed array of tiddlers from other document\n newTags: "", // text of tags added to imported tiddlers\n addTags: true, // add new tags to imported tiddlers\n listsize: 8, // # of lines to show in imported tiddler list\n importTags: true, // include tags from remote source document when importing a tiddler\n keepTags: true, // retain existing tags when replacing a tiddler\n index: 0, // current processing index in import list\n sort: "" // sort order for imported tiddler listbox\n};\n\nconfig.macros.importTiddlers.handler = function(place,macroName,params) {\n // LINK WITH FLOATING PANEL\n if (!params[0]) {\n createTiddlyButton(place,this.label,this.prompt,onClickImportMenu);\n return;\n }\n // INLINE TIDDLER CONTENT\n if (params[0]=="inline") {\n createImportPanel(place);\n document.getElementById("importPanel").style.position="static";\n document.getElementById("importPanel").style.display="block";\n return;\n }\n // NON-INTERACTIVE BATCH MODE\n switch (params[0]) {\n case 'all':\n case 'new':\n case 'changes':\n case 'updates':\n var filter=params.shift();\n break;\n default:\n var filter="updates";\n break;\n } \n if (!params[0]||!params[0].length) return; // filename is required\n config.macros.importTiddlers.src=params.shift();\n var quiet=(params[0]=="quiet"); if (quiet) params.shift();\n var ask=(params[0]=="ask"); if (ask) params.shift();\n config.macros.importTiddlers.inbound=null; // clear the imported tiddler buffer\n // load storeArea from a hidden IFRAME, then apply import rules and add/replace tiddlers\n loadImportFile(config.macros.importTiddlers.src,filter,quiet,ask,autoImportTiddlers);\n}\n//}}}\n\n// // ''READ TIDDLERS FROM ANOTHER DOCUMENT''\n\n//{{{\nfunction loadImportFile(src,filter,quiet,ask,callback) {\n if (!quiet) clearMessage();\n // LOCAL FILE\n if ((src.substr(0,7)!="http://")&&(src.substr(0,8)!="https://")) {\n if (!quiet) displayMessage("Opening local document: "+ src);\n var txt=loadFile(src);\n if(!txt) { if (!quiet) displayMessage("Could not open local document: "+src); }\n else {\n var s="<html><body>"+txt.substr(txt.indexOf('<div id="storeArea">'));\n if (!quiet) displayMessage(txt.length+" bytes in document. ("+s.length+" bytes used for tiddler storage)");\n config.macros.importTiddlers.inbound = readImportedTiddlers(convertUTF8ToUnicode(s));\n var count=config.macros.importTiddlers.inbound?config.macros.importTiddlers.inbound.length:0;\n if (!quiet) displayMessage("Found "+count+" tiddlers in "+src);\n if (callback) callback(src,filter,quiet,ask);\n }\n return;\n }\n // REMOTE FILE\n var x; // XML object\n try {x = new XMLHttpRequest()}\n catch(e) {\n try {x = new ActiveXObject("Msxml2.XMLHTTP")}\n catch (e) {\n try {x = new ActiveXObject("Microsoft.XMLHTTP")}\n catch (e) { return }\n }\n }\n x.onreadystatechange = function() {\n if (x.readyState == 4) {\n if (x.status == 200) {\n var sa="<html><body>"+x.responseText.substr(x.responseText.indexOf('<div id="storeArea">'));\n if (!quiet) displayMessage(x.responseText.length+" bytes in document. ("+sa.length+" bytes used for tiddler storage)");\n config.macros.importTiddlers.inbound = readImportedTiddlers(sa);\n var count=config.macros.importTiddlers.inbound?config.macros.importTiddlers.inbound.length:0;\n if (!quiet) displayMessage("Found "+count+" tiddlers in "+src);\n if (callback) callback(src,filter,quiet,ask);\n }\n else\n if (!quiet) displayMessage("Could not open remote document:"+ src+" (error="+x.status+")");\n }\n }\n if (document.location.protocol=="file:") { // UniversalBrowserRead only works from a local file context\n try {netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead')}\n catch (e) { if (!quiet) displayMessage(e.description?e.description:e.toString()); }\n }\n if (config.macros.importTiddlers.useProxy) src=config.macros.importTiddlers.proxy+src;\n if (!quiet) displayMessage("Opening remote document: "+ src);\n try {\n var url=src+(src.indexOf('?')<0?'?':'&')+'nocache='+Math.random();\n x.open("GET",url,true);\n x.overrideMimeType('text/html');\n x.send(null);\n }\n catch (e) {\n if (!quiet) {\n displayMessage("Could not open remote document: "+src);\n displayMessage(e.description?e.description:e.toString());\n }\n }\n}\n\nfunction readImportedTiddlers(txt)\n{\n var importedTiddlers = [];\n // create frame\n var f=document.getElementById("importFrame");\n if (f) document.body.removeChild(f);\n f=document.createElement("iframe");\n f.id="importFrame";\n f.style.width="0px"; f.style.height="0px"; f.style.border="0px";\n document.body.appendChild(f);\n // get document\n var d=f.document;\n if (f.contentDocument) d=f.contentDocument; // For NS6\n else if (f.contentWindow) d=f.contentWindow.document; // For IE5.5 and IE6\n // load source into document\n d.open(); d.writeln(txt); d.close();\n // read tiddler DIVs from storeArea DOM element \n var importStore = [];\n var importStoreArea = d.getElementById("storeArea");\n if (!importStoreArea || !(importStore=importStoreArea.childNodes) || (importStore.length==0)) { return null; }\n importStoreArea.normalize();\n for(var t = 0; t < importStore.length; t++) {\n var e = importStore[t];\n var title = null;\n if(e.getAttribute)\n title = e.getAttribute("tiddler");\n if(!title && e.id && (e.id.substr(0,5) == "store"))\n title = e.id.substr(5);\n if(title && title != "") {\n var theImported = new Tiddler();\n theImported.loadFromDiv(e,title);\n importedTiddlers.push(theImported);\n }\n }\n return importedTiddlers;\n}\n//}}}\n\n// // ''NON-INTERACTIVE IMPORT''\n\n// // import all/new/changed tiddlers into store, replacing or adding tiddlers as needed\n//{{{\nfunction autoImportTiddlers(src,filter,quiet,ask)\n{\n var count=0;\n if (config.macros.importTiddlers.inbound) for (var t=0;t<config.macros.importTiddlers.inbound.length;t++) {\n var theImported = config.macros.importTiddlers.inbound[t];\n var theExisting = store.getTiddler(theImported.title);\n\n // only import tiddlers if tagged with "importPublic"\n if (theImported.tags && theImported.tags.find("importPublic")==null)\n { config.macros.importTiddlers.inbound[t].status=""; continue; } // status=="" means don't show in report\n\n // never import the "ImportedTiddlers" history from the other document...\n if (theImported.title=='ImportedTiddlers')\n { config.macros.importTiddlers.inbound[t].status=""; continue; } // status=="" means don't show in report\n\n // check existing tiddler for importReplace, or systemConfig tags\n config.macros.importTiddlers.inbound[t].status="added"; // default - add any tiddlers not filtered out\n if (store.tiddlerExists(theImported.title)) {\n config.macros.importTiddlers.inbound[t].status="replaced";\n if (!theExisting.tags||(theExisting.tags.find("importReplace")==null))\n { config.macros.importTiddlers.inbound[t].status="not imported - tiddler already exists (use importReplace to allow changes)"; continue; }\n if ((theExisting.tags.find("systemConfig")!=null)||(theImported.tags.find("systemConfig")!=null))\n config.macros.importTiddlers.inbound[t].status+=" - WARNING: an active systemConfig plugin has been added or updated";\n }\n\n // apply the all/new/changes/updates filter \n if (filter!="all") {\n if ((filter=="new") && store.tiddlerExists(theImported.title))\n { config.macros.importTiddlers.inbound[t].status="not imported - tiddler already exists"; continue; }\n if ((filter=="changes") && !store.tiddlerExists(theImported.title))\n { config.macros.importTiddlers.inbound[t].status="not imported - new tiddler"; continue; }\n if (store.tiddlerExists(theImported.title) && ((theExisting.modified.getTime()-theImported.modified.getTime())>=0))\n { config.macros.importTiddlers.inbound[t].status="not imported - tiddler is unchanged"; continue; }\n }\n\n // get confirmation if required\n if (ask && !confirm("Import "+(theExisting?"updated":"new")+" tiddler '"+theImported.title+"'\snfrom "+src))\n { config.macros.importTiddlers.inbound[t].status="skipped - cancelled by user"; continue; }\n\n // DO THE IMPORT!!\n store.addTiddler(theImported); count++;\n }\n importReport(quiet); // generate a report (as needed) and display it if not 'quiet'\n if (count) store.setDirty(true); \n // always show final message when tiddlers were actually imported\n if (!quiet||count) displayMessage("Imported "+count+" tiddler"+(count!=1?"s":"")+" from "+src);\n}\n//}}}\n\n// // ''REPORT GENERATOR''\n\n//{{{\nfunction importReport(quiet)\n{\n if (!config.macros.importTiddlers.inbound) return;\n // DEBUG alert('importReport: start');\n\n // if import was not completed, the Ask panel will still be open... close it now.\n var askpanel=document.getElementById('importAskPanel'); if (askpanel) askpanel.style.display='none'; \n // get the alphasorted list of tiddlers\n var tiddlers = config.macros.importTiddlers.inbound;\n tiddlers.sort(function (a,b) {if(a['title'] == b['title']) return(0); else return (a['title'] < b['title']) ? -1 : +1; });\n // gather the statistics\n var count=tiddlers.length;\n var added=0; var replaced=0; var renamed=0; var skipped=0; var merged=0;\n for (var t=0; t<count; t++)\n if (tiddlers[t].status)\n {\n if (tiddlers[t].status=='added') added++;\n if (tiddlers[t].status.substr(0,7)=='skipped') skipped++;\n if (tiddlers[t].status.substr(0,6)=='rename') renamed++;\n if (tiddlers[t].status.substr(0,7)=='replace') replaced++;\n if (tiddlers[t].status.substr(0,6)=='merged') merged++;\n }\n var omitted=count-(added+replaced+renamed+skipped+merged);\n // DEBUG alert('stats done: '+count+' total, '+added+' added, '+skipped+' skipped, '+renamed+' renamed, '+replaced+' replaced, '+merged+' merged');\n // skip the report if nothing was imported\n if (added+replaced+renamed+merged==0) return;\n // skip the report if not desired by user\n if (!config.options.chkImportReport) {\n // reset status flags\n for (var t=0; t<count; t++) config.macros.importTiddlers.inbound[t].status="";\n // refresh display since tiddlers have been imported\n store.notifyAll();\n // quick message area summary report\n var msg=(added+replaced+renamed+merged)+' of '+count+' tiddler'+((count!=1)?'s':"");\n msg+=' imported from '+config.macros.importTiddlers.src.replace(/\s\s/g,'/')\n displayMessage(msg);\n return;\n }\n // create the report tiddler (if not already present)\n var tiddler = store.getTiddler('ImportedTiddlers');\n if (!tiddler) // create new report tiddler if it doesn't exist\n {\n tiddler = new Tiddler();\n tiddler.title = 'ImportedTiddlers';\n tiddler.text = "";\n }\n // format the report header\n var now = new Date();\n var newText = "";\n newText += "On "+now.toLocaleString()+", "+config.options.txtUserName+" imported tiddlers from\sn";\n newText += "[["+config.macros.importTiddlers.src+"|"+config.macros.importTiddlers.src+"]]:\sn";\n newText += "<"+"<"+"<\sn";\n newText += "Out of "+count+" tiddler"+((count!=1)?"s ":" ")+" in {{{"+config.macros.importTiddlers.src.replace(/\s\s/g,'/')+"}}}:\sn";\n if (added+renamed>0)\n newText += (added+renamed)+" new tiddler"+(((added+renamed)!=1)?"s were":" was")+" added to your document.\sn";\n if (merged>0)\n newText += merged+" tiddler"+((merged!=1)?"s were":" was")+" merged with "+((merged!=1)?"":"an ")+"existing tiddler"+((merged!=1)?"s":"")+".\sn"; \n if (replaced>0)\n newText += replaced+" existing tiddler"+((replaced!=1)?"s were":" was")+" replaced.\sn"; \n if (skipped>0)\n newText += skipped+" tiddler"+((skipped!=1)?"s were":" was")+" skipped after asking.\sn"; \n if (omitted>0)\n newText += omitted+" tiddler"+((omitted!=1)?"s":"")+((omitted!=1)?" were":" was")+" not imported.\sn";\n if (config.macros.importTiddlers.addTags && config.macros.importTiddlers.newTags.trim().length)\n newText += "imported tiddlers were tagged with: \s""+config.macros.importTiddlers.newTags+"\s"\sn";\n // output the tiddler detail and reset status flags\n for (var t=0; t<count; t++)\n if (tiddlers[t].status!="")\n {\n newText += "#["+"["+tiddlers[t].title+"]"+"]";\n newText += ((tiddlers[t].status!="added")?("^^\sn"+tiddlers[t].status+"^^"):"")+"\sn";\n config.macros.importTiddlers.inbound[t].status="";\n }\n newText += "<"+"<"+"<\sn";\n // output 'discard report' link\n newText += "<html><input type=\s"button\s" href=\s"javascript:;\s" ";\n newText += "onclick=\s"story.closeTiddler('"+tiddler.title+"'); store.deleteTiddler('"+tiddler.title+"');\s" ";\n newText += "value=\s"discard report\s"></html>";\n // update the ImportedTiddlers content and show the tiddler\n tiddler.text = newText+((tiddler.text!="")?'\sn----\sn':"")+tiddler.text;\n tiddler.modifier = config.options.txtUserName;\n tiddler.modified = new Date();\n store.addTiddler(tiddler);\n if (!quiet) story.displayTiddler(null,"ImportedTiddlers",1,null,null,false);\n story.refreshTiddler("ImportedTiddlers",1,true);\n // refresh the display\n store.notifyAll();\n}\n//}}}\n\n// // ''INTERFACE DEFINITION''\n\n// // Handle link click to create/show/hide control panel\n//{{{\nfunction onClickImportMenu(e)\n{\n if (!e) var e = window.event;\n var parent=resolveTarget(e).parentNode;\n var panel = document.getElementById("importPanel");\n if (panel==undefined || panel.parentNode!=parent)\n panel=createImportPanel(parent);\n var isOpen = panel.style.display=="block";\n if(config.options.chkAnimate)\n anim.startAnimating(new Slider(panel,!isOpen,e.shiftKey || e.altKey,"none"));\n else\n panel.style.display = isOpen ? "none" : "block" ;\n e.cancelBubble = true;\n if (e.stopPropagation) e.stopPropagation();\n return(false);\n}\n//}}}\n\n// // Create control panel: HTML, CSS, register for notification\n//{{{\nfunction createImportPanel(place) {\n var panel=document.getElementById("importPanel");\n if (panel) { panel.parentNode.removeChild(panel); }\n setStylesheet(config.macros.importTiddlers.css,"importTiddlers");\n panel=createTiddlyElement(place,"span","importPanel",null,null)\n panel.innerHTML=config.macros.importTiddlers.html;\n store.addNotification(null,refreshImportList); // refresh listbox after every tiddler change\n refreshImportList();\n var siteURL=store.getTiddlerText("SiteUrl"); if (!siteURL) siteURL="";\n document.getElementById("importSourceURL").value=siteURL;\n config.macros.importTiddlers.src=siteURL;\n var siteProxy=store.getTiddlerText("SiteProxy"); if (!siteProxy) siteProxy="SiteProxy";\n document.getElementById("importSiteProxy").value=siteProxy;\n config.macros.importTiddlers.proxy=siteProxy;\n return panel;\n}\n//}}}\n\n// // CSS\n//{{{\nconfig.macros.importTiddlers.css = '\s\n#importPanel {\s\n display: none; position:absolute; z-index:11; width:35em; right:105%; top:3em;\s\n background-color: #eee; color:#000; font-size: 8pt; line-height:110%;\s\n border:1px solid black; border-bottom-width: 3px; border-right-width: 3px;\s\n padding: 0.5em; margin:0em; -moz-border-radius:1em;\s\n}\s\n#importPanel a, #importPanel td a { color:#009; display:inline; margin:0px; padding:1px; }\s\n#importPanel table { width:100%; border:0px; padding:0px; margin:0px; font-size:8pt; line-height:110%; background:transparent; }\s\n#importPanel tr { border:0px;padding:0px;margin:0px; background:transparent; }\s\n#importPanel td { color:#000; border:0px;padding:0px;margin:0px; background:transparent; }\s\n#importPanel select { width:98%;margin:0px;font-size:8pt;line-height:110%;}\s\n#importPanel input { width:98%;padding:0px;margin:0px;font-size:8pt;line-height:110%}\s\n#importPanel .box { border:1px solid black; padding:3px; margin-bottom:5px; background:#f8f8f8; -moz-border-radius:5px;}\s\n#importPanel .topline { border-top:2px solid black; padding-top:3px; margin-bottom:5px; }\s\n#importPanel .rad { width:auto; }\s\n#importPanel .chk { width:auto; margin:1px; }\s\n#importPanel .btn { width:auto; }\s\n#importPanel .btn1 { width:98%; }\s\n#importPanel .btn2 { width:48%; }\s\n#importPanel .btn3 { width:32%; }\s\n#importPanel .btn4 { width:24%; }\s\n#importPanel .btn5 { width:19%; }\s\n#importPanel .importButton { padding: 0em; margin: 0px; font-size:8pt; }\s\n#importPanel .importListButton { padding:0em 0.25em 0em 0.25em; color: #000000; display:inline }\s\n#importAskPanel { display:none; margin:0.5em 0em 0em 0em; }\s\n';\n//}}}\n\n// // HTML \n//{{{\nconfig.macros.importTiddlers.html = '\s\n<!-- source and report -->\s\n<table><tr><td align=left>\s\n import from\s\n <input type="radio" class="rad" name="importFrom" value="file" CHECKED\s\n onClick="document.getElementById(\s'importLocalPanel\s').style.display=this.checked?\s'block\s':\s'none\s';\s\n document.getElementById(\s'importHTTPPanel\s').style.display=!this.checked?\s'block\s':\s'none\s'"> local file\s\n <input type="radio" class="rad" name="importFrom" value="http"\s\n onClick="document.getElementById(\s'importLocalPanel\s').style.display=!this.checked?\s'block\s':\s'none\s';\s\n document.getElementById(\s'importHTTPPanel\s').style.display=this.checked?\s'block\s':\s'none\s'"> web server\s\n</td><td align=right>\s\n <input type=checkbox class="chk" id="chkImportReport" checked\s\n onClick="config.options[\s'chkImportReport\s']=this.checked;"> create a report\s\n</td></tr></table>\s\n<!-- import from local file -->\s\n<div id="importLocalPanel" style="display:block;margin-bottom:5px;margin-top:5px;padding-top:3px;border-top:1px solid #999">\s\nlocal document path/filename:<br>\s\n<input type="file" id="fileImportSource" size=57 style="width:100%"\s\n onKeyUp="config.macros.importTiddlers.src=this.value"\s\n onChange="config.macros.importTiddlers.src=this.value;">\s\n</div><!--panel-->\s\n\s\n<!-- import from http server -->\s\n<div id="importHTTPPanel" style="display:none;margin-bottom:5px;margin-top:5px;padding-top:3px;border-top:1px solid #999">\s\n<table><tr><td align=left>\s\n remote document URL:<br>\s\n</td><td align=right>\s\n <input type="checkbox" class="chk" id="importUseProxy"\s\n onClick="config.macros.importTiddlers.useProxy=this.checked;\s\n document.getElementById(\s'importSiteProxy\s').style.display=this.checked?\s'block\s':\s'none\s'"> use a proxy script\s\n</td></tr></table>\s\n<input type="text" id="importSiteProxy" style="display:none;margin-bottom:1px" onfocus="this.select()" value="SiteProxy"\s\n onKeyUp="config.macros.importTiddlers.proxy=this.value"\s\n onChange="config.macros.importTiddlers.proxy=this.value;">\s\n<input type="text" id="importSourceURL" onfocus="this.select()" value="SiteUrl"\s\n onKeyUp="config.macros.importTiddlers.src=this.value"\s\n onChange="config.macros.importTiddlers.src=this.value;">\s\n</div><!--panel-->\s\n\s\n<table><tr><td align=left>\s\n select:\s\n <a href="JavaScript:;" id="importSelectAll"\s\n onclick="onClickImportButton(this)" title="select all tiddlers">\s\n all </a>\s\n <a href="JavaScript:;" id="importSelectNew"\s\n onclick="onClickImportButton(this)" title="select tiddlers not already in destination document">\s\n added </a> \s\n <a href="JavaScript:;" id="importSelectChanges"\s\n onclick="onClickImportButton(this)" title="select tiddlers that have been updated in source document">\s\n changes </a> \s\n <a href="JavaScript:;" id="importSelectDifferences"\s\n onclick="onClickImportButton(this)" title="select tiddlers that have been added or are different from existing tiddlers">\s\n differences </a> \s\n <a href="JavaScript:;" id="importToggleFilter"\s\n onclick="onClickImportButton(this)" title="show/hide selection filter">\s\n filter </a> \s\n</td><td align=right>\s\n <a href="JavaScript:;" id="importListSmaller"\s\n onclick="onClickImportButton(this)" title="reduce list size">\s\n – </a>\s\n <a href="JavaScript:;" id="importListLarger"\s\n onclick="onClickImportButton(this)" title="increase list size">\s\n + </a>\s\n <a href="JavaScript:;" id="importListMaximize"\s\n onclick="onClickImportButton(this)" title="maximize/restore list size">\s\n = </a>\s\n</td></tr></table>\s\n<select id="importList" size=8 multiple\s\n onchange="setTimeout(\s'refreshImportList(\s'+this.selectedIndex+\s')\s',1)">\s\n <!-- NOTE: delay refresh so list is updated AFTER onchange event is handled -->\s\n</select>\s\n<input type=checkbox class="chk" id="chkAddTags" checked\s\n onClick="config.macros.importTiddlers.addTags=this.checked;">add new tags \s\n<input type=checkbox class="chk" id="chkImportTags" checked\s\n onClick="config.macros.importTiddlers.importTags=this.checked;">import source tags \s\n<input type=checkbox class="chk" id="chkKeepTags" checked\s\n onClick="config.macros.importTiddlers.keepTags=this.checked;">keep existing tags<br>\s\n<input type=text id="txtNewTags" size=15 onKeyUp="config.macros.importTiddlers.newTags=this.value" autocomplete=off>\s\n<div align=center>\s\n <input type=button id="importOpen" class="importButton" style="width:32%" value="open"\s\n onclick="onClickImportButton(this)">\s\n <input type=button id="importStart" class="importButton" style="width:32%" value="import"\s\n onclick="onClickImportButton(this)">\s\n <input type=button id="importClose" class="importButton" style="width:32%" value="close"\s\n onclick="onClickImportButton(this)">\s\n</div>\s\n<div id="importAskPanel">\s\n tiddler already exists:\s\n <input type=text id="importNewTitle" size=15 autocomplete=off">\s\n <div align=center>\s\n <input type=button id="importSkip" class="importButton" style="width:23%" value="skip"\s\n onclick="onClickImportButton(this)">\s\n <input type=button id="importRename" class="importButton" style="width:23%" value="rename"\s\n onclick="onClickImportButton(this)">\s\n <input type=button id="importMerge" class="importButton" style="width:23%" value="merge"\s\n onclick="onClickImportButton(this)">\s\n <input type=button id="importReplace" class="importButton" style="width:23%" value="replace"\s\n onclick="onClickImportButton(this)">\s\n </div>\s\n</div>\s\n';\n//}}}\n\n// // refresh listbox\n//{{{\nfunction refreshImportList(selectedIndex)\n{\n var theList = document.getElementById("importList");\n if (!theList) return;\n // if nothing to show, reset list content and size\n if (!config.macros.importTiddlers.inbound) \n {\n while (theList.length > 0) { theList.options[0] = null; }\n theList.options[0]=new Option('please open a document...',"",false,false);\n theList.size=config.macros.importTiddlers.listsize;\n return;\n }\n // get the sort order\n if (!selectedIndex) selectedIndex=0;\n if (selectedIndex==0) config.macros.importTiddlers.sort='title'; // heading\n if (selectedIndex==1) config.macros.importTiddlers.sort='title';\n if (selectedIndex==2) config.macros.importTiddlers.sort='modified';\n if (selectedIndex==3) config.macros.importTiddlers.sort='tags';\n if (selectedIndex>3) {\n // display selected tiddler count\n for (var t=0,count=0; t < theList.options.length; t++) count+=(theList.options[t].selected&&theList.options[t].value!="")?1:0;\n clearMessage(); displayMessage(config.macros.importTiddlers.countMsg.format([count]));\n return; // no refresh needed\n }\n\n // get the alphasorted list of tiddlers (optionally, filter out unchanged tiddlers)\n var tiddlers=config.macros.importTiddlers.inbound;\n tiddlers.sort(function (a,b) {if(a['title'] == b['title']) return(0); else return (a['title'] < b['title']) ? -1 : +1; });\n // clear current list contents\n while (theList.length > 0) { theList.options[0] = null; }\n // add heading and control items to list\n var i=0;\n var indent=String.fromCharCode(160)+String.fromCharCode(160);\n theList.options[i++]=new Option(tiddlers.length+' tiddler'+((tiddlers.length!=1)?'s are':' is')+' in the document',"",false,false);\n theList.options[i++]=new Option(((config.macros.importTiddlers.sort=="title" )?">":indent)+' [by title]',"",false,false);\n theList.options[i++]=new Option(((config.macros.importTiddlers.sort=="modified")?">":indent)+' [by date]',"",false,false);\n theList.options[i++]=new Option(((config.macros.importTiddlers.sort=="tags")?">":indent)+' [by tags]',"",false,false);\n // output the tiddler list\n switch(config.macros.importTiddlers.sort)\n {\n case "title":\n for(var t = 0; t < tiddlers.length; t++)\n theList.options[i++] = new Option(tiddlers[t].title,tiddlers[t].title,false,false);\n break;\n case "modified":\n // sort descending for newest date first\n tiddlers.sort(function (a,b) {if(a['modified'] == b['modified']) return(0); else return (a['modified'] > b['modified']) ? -1 : +1; });\n var lastSection = "";\n for(var t = 0; t < tiddlers.length; t++) {\n var tiddler = tiddlers[t];\n var theSection = tiddler.modified.toLocaleDateString();\n if (theSection != lastSection) {\n theList.options[i++] = new Option(theSection,"",false,false);\n lastSection = theSection;\n }\n theList.options[i++] = new Option(indent+indent+tiddler.title,tiddler.title,false,false);\n }\n break;\n case "tags":\n var theTitles = {}; // all tiddler titles, hash indexed by tag value\n var theTags = new Array();\n for(var t=0; t<tiddlers.length; t++) {\n var title=tiddlers[t].title;\n var tags=tiddlers[t].tags;\n for(var s=0; s<tags.length; s++) {\n if (theTitles[tags[s]]==undefined) { theTags.push(tags[s]); theTitles[tags[s]]=new Array(); }\n theTitles[tags[s]].push(title);\n }\n }\n theTags.sort();\n for(var tagindex=0; tagindex<theTags.length; tagindex++) {\n var theTag=theTags[tagindex];\n theList.options[i++]=new Option(theTag,"",false,false);\n for(var t=0; t<theTitles[theTag].length; t++)\n theList.options[i++]=new Option(indent+indent+theTitles[theTag][t],theTitles[theTag][t],false,false);\n }\n break;\n }\n theList.selectedIndex=selectedIndex; // select current control item\n if (theList.size<config.macros.importTiddlers.listsize) theList.size=config.macros.importTiddlers.listsize;\n if (theList.size>theList.options.length) theList.size=theList.options.length;\n}\n//}}}\n\n// // Control interactions\n//{{{\nfunction onClickImportButton(which)\n{\n // DEBUG alert(which.id);\n var theList = document.getElementById('importList');\n if (!theList) return;\n var thePanel = document.getElementById('importPanel');\n var theAskPanel = document.getElementById('importAskPanel');\n var theNewTitle = document.getElementById('importNewTitle');\n var count=0;\n switch (which.id)\n {\n case 'fileImportSource':\n case 'importOpen': // load import source into hidden frame\n importReport(); // if an import was in progress, generate a report\n config.macros.importTiddlers.inbound=null; // clear the imported tiddler buffer\n refreshImportList(); // reset/resize the listbox\n if (config.macros.importTiddlers.src=="") break;\n // Load document into hidden iframe so we can read it's DOM and fill the list\n loadImportFile(config.macros.importTiddlers.src,"all",null,null,function(src,filter,quiet,ask){window.refreshImportList(0);});\n break;\n case 'importSelectAll': // select all tiddler list items (i.e., not headings)\n importReport(); // if an import was in progress, generate a report\n for (var t=0,count=0; t < theList.options.length; t++) {\n if (theList.options[t].value=="") continue;\n theList.options[t].selected=true;\n count++;\n }\n clearMessage(); displayMessage(config.macros.importTiddlers.countMsg.format([count]));\n break;\n case 'importSelectNew': // select tiddlers not in current document\n importReport(); // if an import was in progress, generate a report\n for (var t=0,count=0; t < theList.options.length; t++) {\n theList.options[t].selected=false;\n if (theList.options[t].value=="") continue;\n theList.options[t].selected=!store.tiddlerExists(theList.options[t].value);\n count+=theList.options[t].selected?1:0;\n }\n clearMessage(); displayMessage(config.macros.importTiddlers.countMsg.format([count]));\n break;\n case 'importSelectChanges': // select tiddlers that are updated from existing tiddlers\n importReport(); // if an import was in progress, generate a report\n for (var t=0,count=0; t < theList.options.length; t++) {\n theList.options[t].selected=false;\n if (theList.options[t].value==""||!store.tiddlerExists(theList.options[t].value)) continue;\n for (var i=0; i<config.macros.importTiddlers.inbound.length; i++) // find matching inbound tiddler\n { var inbound=config.macros.importTiddlers.inbound[i]; if (inbound.title==theList.options[t].value) break; }\n theList.options[t].selected=(inbound.modified-store.getTiddler(theList.options[t].value).modified>0); // updated tiddler\n count+=theList.options[t].selected?1:0;\n }\n clearMessage(); displayMessage(config.macros.importTiddlers.countMsg.format([count]));\n break;\n case 'importSelectDifferences': // select tiddlers that are new or different from existing tiddlers\n importReport(); // if an import was in progress, generate a report\n for (var t=0,count=0; t < theList.options.length; t++) {\n theList.options[t].selected=false;\n if (theList.options[t].value=="") continue;\n if (!store.tiddlerExists(theList.options[t].value)) { theList.options[t].selected=true; count++; continue; }\n for (var i=0; i<config.macros.importTiddlers.inbound.length; i++) // find matching inbound tiddler\n { var inbound=config.macros.importTiddlers.inbound[i]; if (inbound.title==theList.options[t].value) break; }\n theList.options[t].selected=(inbound.modified-store.getTiddler(theList.options[t].value).modified!=0); // changed tiddler\n count+=theList.options[t].selected?1:0;\n }\n clearMessage(); displayMessage(config.macros.importTiddlers.countMsg.format([count]));\n break;\n case 'importToggleFilter': // show/hide filter\n case 'importFilter': // apply filter\n alert("coming soon!");\n break;\n case 'importStart': // initiate the import processing\n importReport(); // if an import was in progress, generate a report\n config.macros.importTiddlers.index=0;\n config.macros.importTiddlers.index=importTiddlers(0);\n importStopped();\n break;\n case 'importClose': // unload imported tiddlers or hide the import control panel\n // if imported tiddlers not loaded, close the import control panel\n if (!config.macros.importTiddlers.inbound) { thePanel.style.display='none'; break; }\n importReport(); // if an import was in progress, generate a report\n config.macros.importTiddlers.inbound=null; // clear the imported tiddler buffer\n refreshImportList(); // reset/resize the listbox\n break;\n case 'importSkip': // don't import the tiddler\n var theItem = theList.options[config.macros.importTiddlers.index];\n for (var j=0;j<config.macros.importTiddlers.inbound.length;j++)\n if (config.macros.importTiddlers.inbound[j].title==theItem.value) break;\n var theImported = config.macros.importTiddlers.inbound[j];\n theImported.status='skipped after asking'; // mark item as skipped\n theAskPanel.style.display='none';\n config.macros.importTiddlers.index=importTiddlers(config.macros.importTiddlers.index+1); // resume with NEXT item\n importStopped();\n break;\n case 'importRename': // change name of imported tiddler\n var theItem = theList.options[config.macros.importTiddlers.index];\n for (var j=0;j<config.macros.importTiddlers.inbound.length;j++)\n if (config.macros.importTiddlers.inbound[j].title==theItem.value) break;\n var theImported = config.macros.importTiddlers.inbound[j];\n theImported.status = 'renamed from '+theImported.title; // mark item as renamed\n theImported.set(theNewTitle.value,null,null,null,null); // change the tiddler title\n theItem.value = theNewTitle.value; // change the listbox item text\n theItem.text = theNewTitle.value; // change the listbox item text\n theAskPanel.style.display='none';\n config.macros.importTiddlers.index=importTiddlers(config.macros.importTiddlers.index); // resume with THIS item\n importStopped();\n break;\n case 'importMerge': // join existing and imported tiddler content\n var theItem = theList.options[config.macros.importTiddlers.index];\n for (var j=0;j<config.macros.importTiddlers.inbound.length;j++)\n if (config.macros.importTiddlers.inbound[j].title==theItem.value) break;\n var theImported = config.macros.importTiddlers.inbound[j];\n var theExisting = store.getTiddler(theItem.value);\n var theText = theExisting.text+'\sn----\sn^^merged from: [['+config.macros.importTiddlers.src+'#'+theItem.value+'|'+config.macros.importTiddlers.src+'#'+theItem.value+']]^^\sn^^'+theImported.modified.toLocaleString()+' by '+theImported.modifier+'^^\sn'+theImported.text;\n var theDate = new Date();\n var theTags = theExisting.getTags()+' '+theImported.getTags();\n theImported.set(null,theText,null,theDate,theTags);\n theImported.status = 'merged with '+theExisting.title; // mark item as merged\n theImported.status += ' - '+theExisting.modified.formatString("MM/DD/YYYY hh:mm:ss");\n theImported.status += ' by '+theExisting.modifier;\n theAskPanel.style.display='none';\n config.macros.importTiddlers.index=importTiddlers(config.macros.importTiddlers.index); // resume with this item\n importStopped();\n break;\n case 'importReplace': // substitute imported tiddler for existing tiddler\n var theItem = theList.options[config.macros.importTiddlers.index];\n for (var j=0;j<config.macros.importTiddlers.inbound.length;j++)\n if (config.macros.importTiddlers.inbound[j].title==theItem.value) break;\n var theImported = config.macros.importTiddlers.inbound[j];\n var theExisting = store.getTiddler(theItem.value);\n theImported.status = 'replaces '+theExisting.title; // mark item for replace\n theImported.status += ' - '+theExisting.modified.formatString("MM/DD/YYYY hh:mm:ss");\n theImported.status += ' by '+theExisting.modifier;\n theAskPanel.style.display='none';\n config.macros.importTiddlers.index=importTiddlers(config.macros.importTiddlers.index); // resume with THIS item\n importStopped();\n break;\n case 'importListSmaller': // decrease current listbox size, minimum=5\n if (theList.options.length==1) break;\n theList.size-=(theList.size>5)?1:0;\n config.macros.importTiddlers.listsize=theList.size;\n break;\n case 'importListLarger': // increase current listbox size, maximum=number of items in list\n if (theList.options.length==1) break;\n theList.size+=(theList.size<theList.options.length)?1:0;\n config.macros.importTiddlers.listsize=theList.size;\n break;\n case 'importListMaximize': // toggle listbox size between current and maximum\n if (theList.options.length==1) break;\n theList.size=(theList.size==theList.options.length)?config.macros.importTiddlers.listsize:theList.options.length;\n break;\n }\n}\n//}}}\n\n// // re-entrant processing for handling import with interactive collision prompting\n//{{{\nfunction importTiddlers(startIndex)\n{\n if (!config.macros.importTiddlers.inbound) return -1;\n\n var theList = document.getElementById('importList');\n if (!theList) return;\n var t;\n // if starting new import, reset import status flags\n if (startIndex==0)\n for (var t=0;t<config.macros.importTiddlers.inbound.length;t++)\n config.macros.importTiddlers.inbound[t].status="";\n for (var i=startIndex; i<theList.options.length; i++)\n {\n // if list item is not selected or is a heading (i.e., has no value), skip it\n if ((!theList.options[i].selected) || ((t=theList.options[i].value)==""))\n continue;\n for (var j=0;j<config.macros.importTiddlers.inbound.length;j++)\n if (config.macros.importTiddlers.inbound[j].title==t) break;\n var theImported = config.macros.importTiddlers.inbound[j];\n var theExisting = store.getTiddler(theImported.title);\n // avoid redundant import for tiddlers that are listed multiple times (when 'by tags')\n if (theImported.status=="added")\n continue;\n // don't import the "ImportedTiddlers" history from the other document...\n if (theImported.title=='ImportedTiddlers')\n continue;\n // if tiddler exists and import not marked for replace or merge, stop importing\n if (theExisting && (theImported.status.substr(0,7)!="replace") && (theImported.status.substr(0,5)!="merge"))\n return i;\n // assemble tags (remote + existing + added)\n var newTags = "";\n if (config.macros.importTiddlers.importTags)\n newTags+=theImported.getTags() // import remote tags\n if (config.macros.importTiddlers.keepTags && theExisting)\n newTags+=" "+theExisting.getTags(); // keep existing tags\n if (config.macros.importTiddlers.addTags && config.macros.importTiddlers.newTags.trim().length)\n newTags+=" "+config.macros.importTiddlers.newTags; // add new tags\n theImported.set(null,null,null,null,newTags.trim());\n // set the status to 'added' (if not already set by the 'ask the user' UI)\n theImported.status=(theImported.status=="")?'added':theImported.status;\n // do the import!\n store.addTiddler(theImported);\n store.setDirty(true);\n }\n return(-1); // signals that we really finished the entire list\n}\n//}}}\n\n//{{{\nfunction importStopped()\n{\n var theList = document.getElementById('importList');\n var theNewTitle = document.getElementById('importNewTitle');\n if (!theList) return;\n if (config.macros.importTiddlers.index==-1)\n importReport(); // import finished... generate the report\n else\n {\n // DEBUG alert('import stopped at: '+config.macros.importTiddlers.index);\n // import collision... show the ask panel and set the title edit field\n document.getElementById('importAskPanel').style.display='block';\n theNewTitle.value=theList.options[config.macros.importTiddlers.index].value;\n }\n}\n//}}}\n
!Installation and setup\n*Monmaster is NOT usable out-of-the-box. You must do some analysis and configuration in order to make use of Monmaster.\nMonmaster comes with documentation so that it is (hopefully) feasible to start use Monmaster without too much frustration.\nIf you make the effort, Monmaster can make web application support less stressful.\n\n!!Downloading Monmaster\nYou can find Monmaster on Sourceforge at http://sourceforge.net/projects/monmaster/\n\nIn addition to Python 2.3, you will also need to have all the required libraries listed on the `System Requirements`_ page; you may want\nsome or all of the optional libraries listed there as well. Note that for some libraries, Monmaster expects a version older than the current one,\nand in some cases, newer versions will not work without modifying Monmaster.\n\nYou may unarchive the Monmaster download wherever you want. \n\nUnarchive the supporting libraries and install them in your Python path.\n\n!!Setup\n\nConfiguring Monmaster is largely a matter of creating an XML parameter file with data specific for your environment.\nBefore you start, it is recommended that you identify components of your environment that must be captured in the\nparameter file and gather details about them. \n\nSee the [[Parameter File]] pages and the [[Monmaster Object Model]] for more information.\n\nTo get started, the minimum amount of information you must have includes:\n* a web page that you want to test, including the full URL, form name/value pairs, etc.\n* a server that the page is hosted on\n* an application that would need to be restarted if the test of the page fails\n* who should be notified if restarting the application does not fix the problem.\n\n!!!Analyzing your environment\nWhile it is neither required nor suggested that you attempt to be exhaustive in inventorying the entities to be used by\nMonmaster in your environment, there are some steps that you will need to do along the way. These include:\n* identify the web requests that test aspects of your web application and capture details about each request\n* identify each of the servers that respond to the web requests\n* define tests by mapping page details to servers\n* identify the application that corresponds to each server\n* for tests that must maintain a session, identify the page/server combinations for each step and the application that corresponds to the sessiontest\n* identify who needs to be notified for what types and severity of problems\n\n!!!Creating a site-specific parameter file\nYou will probably want to use the example.xml file provided in the Monamster download as a starting point for \ncreating a site-customized version. The example file will *not work as is.\n\n!!Customizing the Monmaster application\n\n!!!Customization of authentication method for MonmasterUI\nThe __init__.py module in the webapps/monmasterUI subdirectory defines a function called *authenticate*\nthat needs to be customized. If you need to use an alternative to LDAP to perform authentication, then\nthis function will need to be replaced. \n\n!!Starting Monmaster\n!!!Creating a startup script\n
!!Overview of logging\nMonmaster logs informational, warning, and error messages in several ways:\n\n* on the console, if not in [[daemon mode|DeamonMode]] - this information may include Python tracebacks in case of uncaught exceptions\n* in the main log - this has name that matches the parameter file, with a .log extension\n* in the serverlog file, for log output from the Snakelets components\n\nMonmaster uses the standard Python 2.3 logging library.\n\n!!!Log message levels\nBy default, Python logging supports five logging levels: DEBUG, INFO, WARNING, ERROR and CRITICAL. Monmaster log levels\nare set in the appropriate logging.cfg file(s). *INFO* is the "normal" logging level and is suggested. *DEBUG* may be\nuseful during development, but the volume of output may need to be cut back (by commenting\nlog function calls) in order to focus on the problem being addressed.\n\nMonmaster uses the *INFO*, *WARNING*, *ERROR*, and (optionally) DEBUG log levels as follows:\n\nINFO: tracks Monmaster's normal operation\nWARNING: used to indicate that Monmaster has detected an error in the applications it monitors\nCRITICAL: indicates that there has been an error in Monmaster's normal operation, such as being unable to complete a\nrestart of a server, or an error that may cause Monmaster to be unable to continue operating correctly.\nDEBUG: displays informational messages that may assist in developing or debugging Monmaster, but that may obscure\nmeaningful log messages required for normal use.\n\n!!!Log rotation\nLogging for Monmaster is configured to use the Python logging RotatingFileHandler. This allows easy configuration of the maximum size that a log file will reach as well as the number of old log files to retain (with a numeric suffix).\n
!!Monmaster Configuration Guide -- Logical Server Parameters\n!!!Overview of logical server parameters\nThe logicalserverlist element contains children that define logical servers. A logical server corresponds to a\nnetwork-addressable instance of a server. A logical server may have one or more Page objects associated with it.\nA logical server corresponds to a single application.\n\n!!!Logical server parameter elements\n> logical_server_name\n>> a string referenced in ''test'' and ''sessiontest'' elements\n> display_name\n>> a string used for display in the web UI and logs\n> server_type\n>> a string that can be used to indicate the type of server, e.g. web, J2EE, Oracle, etc.; not used in Monmaster processing\n> protocol\n>> the communication protocol (HTTP or HTTPS) that should be used to acces this logical server when executing tests\n> applicationname\n>> the name of the application_ that this logical server corresponds to; applications may be restarted by Monmaster\n> host\n>> the host name to be used in creating a connection to the logical server\n> port\n>> the port number to be used in creating a connection to the logical server\n> prepend\n>> a string to be prepended to any path elements (defined in the parameters for a page)\n \n!!Relax NG Compact (RNC) schema fragment for ''logicalserverlist'' element:\n{{{\n ../..\n element logicalserverlist { logical_server+ }\n ../..\n logical_server =\n element logical_server {\n (text\n | display_name\n | protocol\n | element applicationname { text }\n | element host { xsd:NMTOKEN }\n | element logical_server_name { xsd:NCName }\n | element port { text }\n | element prepend { empty }\n | element server_type { xsd:NCName })+\n }\n protocol = element protocol { xsd:NCName }\n display_name = element display_name { text } ../..\n ../..\n}}}
[[About Monmaster]]\n[[System Requirements]]\n[[Installation and setup]]\n----\n[[Configuration]]\n[[Users Guide|Monmaster Users Guide]]\n----\n[[Technical documentation]]\n----\n[[Contact]]\n----\n^^[[tiddlywiki|http://www.tiddlywiki.com/]] <<version>>^^\n\n^^<<newTiddler>>^^
This contains current documentation on installing, configuring, and using the MonMaster monitoring system.\n\nThis documentation is contained in a single HTML file that uses Javascript and style data to provide a distinctive and powerful look, feel, and operation. It is based on a [[TiddlyWiki|http://www.tiddlywiki.com/]] with some enhancements, such as the editing toolbar that makes it easier for writers to format their content without learning all the wiki formatting syntax.
Monit is an application that monitors, controls, and restarts application on a server, like what MonMaster itself does. It can be used to ensure that Monmaster is running and has not become "stuck".\n\nFrom the [[monit home page|http://www.tildeslash.com/monit/]]:\n>''What monit can do''\n>Monit can start a process if it does not run, restart a process if it does not respond and stop a process if it uses to much resources. You can use monit to monitor files, directories and devices for changes, such as timestamp changes, checksum changes or size changes. You can also monitor remote hosts; monit can ping a remote host and can check TCP/IP port connections and server protocols. Monit is controlled via an easy to use control file based on a free-format, token-oriented syntax. Monit logs to syslog or to its own log file and notifies you about error conditions and recovery status via customizable alert. \n\n!!!To start monit \n''note:'' monit will be set up to run under the ''init'' process so that it will be automatically restarted by the system if it should ever fail, so it should never be necessary to start at the command line:\n {{{monit}}}\nThis should start monit (as a daemon), which includes the http interface on port 2812. [[Log in|Access to Server]] using the administrator's account and password.\n\nBy default, monit will restart all services that it monitors as soon as it starts up. If this is not desired, start monit using the command:\n {{{monit unmonitor all}}}\n\nIt will then be necessary to start monitoring - which will cause any monitored service that is not running to be started - for any/all service that should be running and monitored:\n {{{ monit -c monitrc monitor all}}}\nor:\n {{{monit monitor production.log}}}\n\n\n!!!Access to monit\nmonit runs a simple HTTP server on port 2812, so you can access monit at http://yourserver:2812\nYou will need to enter an ID and password. After authenticating, you can check the status of any Monmaster instances being controlled by monit. You can start and stop monmaster instances, and turn monit monitoring of an instance on or off. Note that if you use monit to start Monmaster, then monit will subsequently monitor that instance.\n\n''Please do not click the button captioned "Stop monit http server?" on the monit runtime status page''. This button stops monit's web UI but leaves monit running. If monit has no web UI, then the only way to control it is to use the command line - log in to YourServer\n{{{\nsu - monmaster\nmonit quit\n}}}\nand then \n{{{monit}}} \nto restart.
This information is intended for those who need to know how to use monmaster. This page is a brief overview;\nfor more detail, see [[Command Line|OperationalOverview]] and [[Monmaster parameter file|TestParameters]]\n\nFor more technical information about how Monmaster works and can be modified, see the [[Monmaster Configuration Guide|Configuration]] and OperationalOverview\n----\n!!!Starting monmaster\n* (Windows, if shortcut has been set up)\n** double click on start-monmaster shortcut (or whatever name has been given to the shortcut)\n* (Linux, Unix, Mac, or Windows)\n** see [[Command Line|OperationalOverview]]\n* You should see a bunch of initialization messages telling you what will be tested.\n* Monmaster will start it's main loop\n\n!!!Interpreting output from monmaster\nThe current version of monmaster endeavors to keep you informed about real and potential problems. Since it uses Python's standard logging module, messages show a log level - from INFO to WARN to ERROR (there is also a DEBUG level but you should not see these messages).\nObviously, WARN and ERROR mean that there is a problem.\n\nMonmaster uses the WARN level to indicate that it has found a problem, and is attempting to do something about it.\n\nMonmaster uses the ERROR level to indicate that it has been unable to do something it tried to do, and *needs attention!*\nIf you see an ERROR output line, please deal with it, or at least inform a system administrator for your web application/servers\n\nWith one exception, what you see in the console window will also be written to the log file (production.log). The exception\nis the error output if monmaster crashes, which only goes to the console. This is the reason why using the\nstart-monmaster shortcut is the preferred method of starting monmaster.\n\n!!!In case of trouble:\n* If monmaster is saying that a page is not being returned correctly but it works correctly and consistently for you in a browser, you might need to check and verify the match criteria monmaster is using to determinesuccess.\n* When monmaster finds an error, it writes each page in error that is has retrieved in a subdirectory called dump. The page is written as HTML, so you can look at it in a browser (but of course, all graphic elements will be unavailable and will not display). The filename is based on the server and page. Check the file timestamps to get the most recent problem page(s), since many old problem pages may exist in the dump directory.\n\n!!!Modifying monmaster parameters\nThe current version of monmaster uses pattern matching to determine whether a page that has been\nretrieved is correct or not. Consequently, unlike with the previous versions of monmaster, you should\nnot ordinarily need to modify the parameter file after deploying a new build to production.\n\nIf you do need to modify the parameter file, the simplest way to do this is via Monmaster [[Web UI|Editing Parameters Using the Web UI]]: select the link "Manage Monmaster parameters". Otherwise, if you have access to Monmaster's filesystem, you can edit the parameter file directly, but be prepared to edit XML. The parameter file is called testsuite.xml and is located in a subdirectory corresponding the the environment being tested, e.g. "production" or "QA". \n\nModifications would usually need to be made to one or more of the page definitions, which are near the\nbeginning of the file. Typically, the text that must be matched is the only detail that would change,\nalthough user !IDs and passwords may sometimes need to be updated. See the sample page definition.\n\nUse the contents of the dump subdirectory to get text strings for monmaster to match on - see above for more info.\n\n
!!Monmaster Configuration Guide -- Notification\n!!!Overview of notification processing\n When, during a test cycle, Monmaster detects non-transient errors in one or more applications,\n several actions occur:\n* the errors are logged\n* the errors are shown on the main Monmaster web page and on the server list page\n* the applications may be restarted, unless: \n** an application's ''severity'' is be set to //NOTIFY ONLY//\n** an application is in a restart ''blackout period''\n** a global restart ''blackout period'' is in effect\n** subscribers may be notified\n \n You can define one or more ''notification_group'' parameter elements. Each notification group can have distinct\n parameters, including address list, notification threshold, blackout period, and application subscriptions.\n \n In addition, there are several parameter elements that apply to all notification groups.\n \n!!!Notification Parameters\n!!!!Parameter elements that apply to all notification groups\n> smtp_server\n>> the hostname or IP address of the SMTP server or relay, where mail should be sent\n> from_address\n>> the email address that the notification emails will appear to come from\n> mail_interval\n>> the number of minutes that should pass between successive notifications about ongoing error - in other words, if you want to be notified no more frequently than every three hours, then use //180// as the ''mail_interval''\n\n!!!!Parameter elements that apply to each ''notification_group''\n> error_threshold\n>> the number of sequential error cycles that must occur in order to send notifications - if the first error cycle should be ignored, use //2// as the ''error_threshold''\n> subscriptions\n>> either the text //all// or the name of one application for which notifications should be sent for\nTODO: update this\n this **notification_group**\n> notification_blackout\n>> an option element that causes notifications not to be sent during a period\n> addresslist\n>> a parent element for one or more ''address'' elements\n>>> address\n>>>> an email address to which a notification email should be sent\n \n!!Relax NG Compact (RNC) schema fragment for ''notification'' element:\n{{{\n ../..\n element notification {\n element smtp_server { xsd:NCName },\n element from_address { text },\n element mail_interval { xsd:integer },\n element notification_group {\n element addresslist {\n element address { text }+\n },\n element error_threshold { xsd:integer },\n element subscriptions { xsd:NCName },\n notification_blackout?\n }+\n }\n ../..\n}}}
!Monmaster object model\nThe diagram below depicts several, although not all, of the principal classes used in Monmaster.\n[img[Object Model Diagram|docs/ObjectModel.png]]\n\nSee the [[Monmaster program documentation|docs/happydoc/monmaster/Application.html]] for more information as well as a Javadoc-like view of Monmaster.\n\nThe principal classes include:\n\n[[Page]]\n parameters for requesting a web page from a web server/application, and methods to evaluate the correctness of the response contents\n[[TestCaseOracle]]\n parameters for performing an Oracle query or other SQL statement, and a method to execute the query\n[[TestCaseWeb]]\n parameters for performing one or more web page requests and methods for performing the request as well as supporting methods.\n[[LogicalServer]]\n parameters for setting up a network connection to a specific machine and port \n[[Application]]\n parameters that define a software application that can be restarted, and methods to stop and start applications\n\n[[ParameterTree]]\n methods to parse the XML parameter file and instantiate Monmaster objects\n\n[[TestThread]]\n methods from the Python threading.thread class that create and run threads that run the tests\n\n[[monServer]]\n set up and runs the Snakelets server, providing a web UI to Monmaster; runs in a thread\n\nThe classes shown in the diagram above illustrate a key difference between a Test and a SessionTest: where a *Test* includes a single *Page* and a single *LogicalServer*, a *SessionTest* includes multiple *Page* and *LogicalServer* pairs (I don't know how the concept of Page/LogicalServer pairs should be depicted). See the SessionTest section for more information.\n
!Monmaster Operation Overview\n\n!!Command line\nThe minimal command line to start Monmaster is from the top level installation directory:\n{{{\n path-to-python-executable MonMaster/monmaster.py parameter-directory\n}}}\nwhere:\n> //path-to-python-executable// points to the python executable\n> //parameter-directory// points to a subdirectory that contains configuration files\n\nThere are several command line options, which have long and short forms::\n> //-s// or //--skip//\n>> invoke a test mode in which no emails are sent and no automatice application restarts are performed\n> //-d// or //--daemon//\n>> (not on Windows) runs in daemon mode, detaches from the console - requires -c or --command option\n> //-c// or //--command//\n>> a mode for daemon action, one of start, stop or restart\n\n!!Monmaster implementation walkthrough\nWhat follows is an attempt to summarize the processing flow within Monmaster.\n\n!!Overview\n!!!initialization - see //Initialization// below\n* read some parameters\n* start logging\n* [optionally] invoke daemon\n* read remaining parameters and instantiate objects used by Monmaster\n* start web server thread\n\n!!!main processing loop - see //Main processing// below\n* create and start threads for each test defined\n* aggregate results from tests\n* restart bad apps if appropriate\n* notify staff if appropriate\n* sleep\n\n!!!web/application server (Snakeserver) - see //Embedded web server// below\n* init in own thread\n* process requests:\n\n** display summary pages\n ** authenticate users\n ** perform Monmaster actions\n ** display certain configuration parameters and allow updates to them\n\n!!In more detail...\n!!!Initialization\nMonmaster instantiates the ParameterTree object, which uses the ElementTree library to process the XML parameter file.\n\nThe name of the parameter file was passed as a command line argument. Initing ParameterTree also grabs some application-level params,\nsome of which are defined as global variables. \si[Perhaps in a future release, Monmaster will use getters and setters to avoid the use of global variables.]\nUsing the log_level read from the parameter file, logging using log4py is initialized - but first, see if the log file is getting too big, and archive it and create a new one if it is.\n\nRead and process the other sections of the param file, and instantiate the various objects required for the web testing. See MonmasterObjectModel for more information. The objects that are created include:\n* Applications\n* LogicalServers\n* Pages\n* Tests\n* Notification groups\n\nThe web server that provides a web UI to Monmaster is started in its own thread.\n\nSince it is running in a thread, the testing functions may crash, but unless the error is severe\nenough to kill the whole application, then the web UI may stay up. Be aware that this does not\nmean Monmaster is really functioning.\n\nFinally, the main processing loop is created in a thread and started.\n\n!!!Main processing\nThe first thing Monmaster does in its main loop is to check whether it should sleep for a while, by checking whether its next test cycle\nstartup time *monstart* is later than now. *monstart* is a global variable that is updateable via the web UI, when a user stops Monmaster cycles.\n\nNext, Monmaster creates a thread for each test in its list of tests, and starts the thread. It sleeps a fraction of a second between each initiation so that the app servers aren't swamped (you wouldn't think this would be a problem, but it is). The test process is documented below.\n\nMonmaster goes into a loop waiting for the test threads to return. When no test threads remain active, the results are evaluated.\n\n>Note: \n>Within each test thread, a request is limited by the global **default_timeout** for socket connections, so no thread will remain active for much more than that number of seconds.\n\n!!!Testing\nEach test makes one or more requests; most are web requests using HTTP and/or HTTPS, but Oracle statements that return something that evaluates to true or false are also supported. The results returned indicate the application that has a problem, or are null.\n\n!!!!TestCaseWeb\nThe TestCaseWeb class handles both simple single page requests as well as multipage SessionTest requests; the page or pages for each instance is in a list, which may have a single item. The page(s) are looped through and processed sequentially.\n\nThe ClientCookie setup is performed; this supports SessionTests, but the URL opener in ClientCookie is used for all test types.\n\nFor each page, the request parameters are set up. If cookies are in play (i.e., this is a SessionTest), cookie manipulation is performed.\n\nThe page request is made. Assuming results are returned, they are evaluated by methods in the Page class; if no page is returned or the request times out, an error is set by the TestCaseWeb instance.\n\nPage results are evaluated by performing a regular expression match (in most cases using a simple string) on one or two strings that are expected within the page results. In addition, a further check may be performed to verify that a defined error string has not been returned.\n\nAn error is logged if appropriate.\n\n!!!!TestCaseOracle\nOracle testing is quite straightforward, and assumes that a query or request can be executed that returns something that evaluates to True for success. A database connection is created and broken down for each request cycle for each instance of a !TestCaseOracle class; no connection pooling is performed.\n\n!!!!SessionTest\nThe sessiontest type of test was created to solve a specific problem related to a specific web application server environment:\n* two web servers with domain names that are publicly visible\n* two J2EE applications servers inside the inner firewall that have domain names in a private domain\n* use of domain cookies to support access control\n* need to authenticate in the public realm to get appropriate cookies, but need to check functionality on specific application servers\n\nIn order to accomplish this, we follow this scenario:\n# Monmaster authenticates to a web server using appropriate page data\n# in response, the web application sets cookies with the public domain\n# Monmaster clones the cookies but sets the domain to be that of the next request\n# Monmaster makes the next request, sending old and new cookies, as well as the prior page as the http-referer (sic).\n\nThe cookie manipulation is done using a 3rd party Python library called ClientCookie. The ClientCookie module provides control over cookies used by a web client, as compared to the standard Python cookie module which is server-oriented.\n\n!!Evaluating test results\n>Note: \n>Some tests are associated with applications that are not to be restarted; these get a warning message in Monmaster's log but no further action.\nIf the current time falls in a restart blackout period, Monmaster logs a message and goes into it's end-of-cycle sleep.\n\nMonmaster may give the applications multiple chances to "get it right" - this is a Monmaster parameter. If the number of successive cycles with restartable errors is under this threshold (*retry_count*), then Monmaster sleeps a while (*retry_interval_seconds*). Otherwise, Monmaster restarts the ailing servers (if they are restartable).\n\n!!Application recovery processing\nAn application is what Monmaster can attempt to fix - usually by restarting a program or daemon. Examples of applications would be web server instances, application server instances, middleware, reporting servers, database instances, etc.\n\nMonmaster creates instances of the Application class at startup and refreshes the list of application objects at the start of each test cycle. Each Application object is defined in the application list element in the parameter file, and to an application in your server environment.\n\nApplication objects have three methods of importance:\n* start\n> executes the steps that have been defined to start a server\n* stop\n> executes the steps that have been defined to stop a server\n* restart\n> executes the stop method and then the start method\n\n>Note: \n>an optional parameter, *skip*, in the *restart*, *start* and *stop* methods force the action to be bypassed. This\n parameter is used primarily for testing of Monmaster, when it may be undesirable to actually carry out the action.\n\n!!The stop, start, and recover methods in detail\nThe *stop*, *start*, and *recover* methods will be invoked either because a test cycle has detected errors in an\napplication, or because an authenticated user has requested a method invocation using the web UI. If the application\nhas a *severity* of //ERROR//, then the method will continue. The method will not be executed, and a message will be\nwritten to the log indicating this, if:\n* the *severity* is //WARN//\n* optional *skip* argument is set to True in the method invocation\n* the application has a **restart_blackout** that is effective at that instant\n\nEach application has two *restart_sequence* elements - this first is used to stop the application and the second is used\nto start the application. In a future release, an attribute of the *restart_sequence* element will control this aspect.\n\nFor each *restart_sequence*, a *restart-action* defines how the sequence works.\n>Note:\n> Currently, the only *restart-action* supported is //telnet//; this means that any server can only be restarted using a telnet session as defined within the *restart-sequence*.\n\n!!!restart action*: //telnet//\nThe default socket timeout is set to the //restart_timeout// if it exists. This allows more time for a command to complete\nthan might be permitted based on the default timeout set in the global parameters section. A telnet session is initiated using the Python telnetlib library. The *username* and *password* are used to log in to the *server-name*.\n\nFor each *command* element:\n* if a *command_timeout* has been defined, then the socket timeout is set to this value\n* if a *waitfor* element has been defined, then this text must be received from the server before proceeding\n* the *command_line* text is sent to the server\n\nIf the *waitfor* text string is not received, or if nothing is received, and the *command_timeout* or *restart_timeout* expires, then this is considered to be an error, and this information is logged as a warning, but processing of the next *command*, if any continues.\n\nIf the telnet attempt fails, this is considered to be an error, and this information is logged as a warning.\n\nIf a restart attempt fails - errors such as a problem connecting, logging in, unexpected response, or timeout -\nthen an error is logged. Note that aside from failures such as those noted above, Monmaster does not know immediately\nafter a restart whether the restart has fixed the application's problem; this will be determined in the next cycle of testing.\n\n!!Notification\nIn addition to the state information available by looking at the log on the console or by using the web UI, Monmaster informs subscribed staff of problems using email. Since most pagers and text messaging capable cell phones have associated email addresses, this provides a standard way to notify people almost instantaneously if there is a persistent problem.\n\nMultiple notification lists can be defined in the parameter file; each list can have a notification threshhold. The notification threshhold allows a list to not be notified until errors were found in a defined number of successive cycles. For example, users may not wish to be paged unless there were two error cycles in a row, allowing Monmaster a chance to to restarts that may fix problems before sending email.\n\n!!End-of-cycle processing\nFinally, Monmaster sleeps for *check_interval_seconds* seconds; if there were problems, Monmaster sleep for *post_restart_check_interval_seconds* seconds; if a web user has requested that Monmaster suspend testing, then Monmaster sleeps for a very long time.\n\n!!Embedded Web Server\nMonmaster provides a web UI by embedding a slightly modified version of the Snakelets application server.\n\nFor more information on how Snakelets works, see the [[Snakelets quick reference|../snakelets/docs/index.html]]\n\n\n
!!Monmaster Configuration Guide -- Page Parameters\n!!!Overview of page parameters\n The ''pagelist'' element contains one or more ''page'' elements that define certain aspects of a web page request. Since web applications may be spread across multiple servers for load balancing or redundancy purposes, the specific details of the server are stored separately in the [[serverlist|LogicalServerList]] element.\n\n!!!!Page parameter elements:\n> display_name\n>> the name associated with a specific page specification element; this is used in web and log displays and in testlist_ elements\n> desc\n>> the description of the function of the page, displayed at Monmaster startup time only\n> protocol\n>> the protocol - HTTP or HTTPS - to be used for the page request.\n> path\n>> the path portion of the URL\n> paramlist\n>> this element may contain a list of name/value pairs to be used in a page request. Monmaster URL encodes parameter names and values. \n>>>Note that this element may be empty.\n> paramname\n>> the name of the request parameter.\n> paramvalue\n>> the value of the request parameter.\n> username\n>> an account ID to be used if basic HTTP authentication is required.\n> password\n>> a password to be used if basic HTTP authentication is required. \n>>>Note that the password and the corresponding username will be sent as part of the URL, which may not be secure.\n> search_strings\n>> a list of 2 lists of strings that may be found in the payload of a web response\n>> good_strings\n>>> a list of strings that may indicate a successful test; if any of the strings are matched, then the test is successful unless an error_string is found\n>>>> string\n>>>>> a text string that must be returned as part of the content of a page returned for a web request. This string is used in a regex match. \n>>>>>>Note that you should look at the source of a web page to derive this string, since invisible HTML elements may be sent.\n>> error_strings\n>>> a list of strings that indicate a failed test; if any of the strings are matched, then the test fails, even if a ''good_string'' has been found \n>>>> string\n>>>>> a text string that must be returned as part of the content of a page returned for a web request. This string is used in a regex match. \n>>>>>>Note that you should look at the source of a web page to derive this string, since invisible HTML elements may be sent.\n> cookie\n>> a parent element for a single cookie that should explicitly be set, in addition to any cookies that are automatically set by the ClientCookie_ processing logic\n>> cookiename\n>>> the cookie name\n>> cookievalue\n>>> the cookie value\n\n!!!Relax NG Compact (RNC) schema fragment for ''pagelist'' element:\n{{{\n element pagelist { page+ }\n ../..\n page =\n element page {\n (text\n | display_name\n | password\n | protocol\n | username\n | element cookie {\n element cookiename { xsd:NCName },\n element cookievalue { xsd:integer }\n }\n | element desc { text }\n | element paramlist {\n element param {\n element paramname { xsd:NCName },\n element paramvalue { text }\n }*\n }\n | element path { text }\n | element search_strings {\n element good_strings { \sstring+ },\n element error_strings { \sstring }\n })+\n }\n username = element username { text }\n password = element password { text }\n \sstring = element string { text }\n protocol = element protocol { xsd:NCName }\n display_name = element display_name { text }\n ../..\n}}}
<<search>><<closeAll>><<permaview>><<newTiddler>><<newJournal 'DD MMM YYYY'>><<importTiddlers>><<saveChanges>><<slider chkSliderOptionsPanel OptionsPanel 'options »' 'Change TiddlyWiki advanced options'>>
[[documentation|SiteSubtitle]]
MonMaster
!Monmaster System Requirements\n----\n\n*Monmaster requires Python 2.3 or better\nThere is one specific reason why version 2.3 or higher is required: socket timeouts. In Python 2.3, you have the\noption of setting a timeout (in seconds) for any subsequent socket operations. This is critical for a\nweb monitoring application - at least in our environment - because a web server/application can hang a\nrequest indefinitely, and thereby potentially hanging the monitoring application. Even the use of\nthreading - at least on Windows 2000 - does not prevent a hung web request from hanging the monitor application.\nUnder Python 2.3, this problem can be overcome.\n\n\n!!Third party Python applications that Monmaster embeds\n[[snakelets|http://snakelets.sourceforge.net/]]\n Monmaster *embeds* the Snakelets application server (it includes a very quick http server). The version that is\n currently embedded is 1.31, but newer versions may also work. The only change to the distribution is some additions\n to logging.cfg.\n\n!!Third party Python libraries that are required:\n\n[[elementtree|http://effbot.org/zone/element.htm]]\n elementtree provides an straightforward and fast interface\n to the XML-based parameter file. There are many Python XML packages, some are buggy, and many are convoluted.\n Monmaster's needs are simple, and elementtree works well.\n\n[[ClientCookie|http://wwwsearch.sourceforge.net/ClientCookie/]]\n Monmaster is an HTTP/HTTPS client and plays around with cookies, manipulating them in some cases for\n session-based web tests (see SessionTest). ClientCookie provides\n some useful tools for hacking these cookies. Monmaster uses an old version of ClientCookie, 0.3.1b,\n that is no longer available from the author, and will be distributed with Monmaster. Newer versions may\n *not* work correctly without changes to Monmaster logic.\n\n[[period|http://www.biostat.wisc.edu/~annis/creations/period.py.html]]\n Monmaster allows the setting of blackout period parameters for notifications and restarts.\n The period package provides a simple way to "specify":uploads/period.html and use these parameters.\n\n!!Standard and third party libraries that are supported but not required\n\n[[cx_oracle|http://www.computronix.com/utilities.shtml]]\n cx_oracle is used for the Oracle tests. It uses the Oracle client libraries that were installed separately from:\n* an Oracle distribution (the libraries require that the Oracle networking configuration be completed) or, \n* the Oracle Instant Client use the method below to set up the connection.\n>{{{connect( [user, password, dsn, mode, handle, pool, threaded, twophase])}}}\n>> Constructor for creating a connection to the database. Return a Connection object (2). All arguments are optional and can be specified as keyword parameters. The dsn (data source name) is the TNS entry (from the Oracle names server or tnsnames.ora file) or is a string like the one returned from makedsn().\n>{{{makedsn( host, port, sid)}}}\n>> Return a string suitable for use as the dsn for the connect() method. This string is identical to the strings that are defined by the Oracle names server or defined in the tnsnames.ora file.\n\n[[ldap (for Win32)|http://www.agescibs.org/mauro/\n]]\n[[ldap (other platforms)|http://python-ldap.sourceforge.net/]]\n Monmaster uses a Domino (Lotus Notes) LDAP server to provide authentication support for user logins\n to the Monmaster web UI. Other LDAP servers should work, although details of addressing may need tweaking.\n\nwinsound\n Monmaster can also use the winsound module, which of course only works on Windows, but it's necessity is minimal\n to nonexistent - it simply makes some noise when Monmaster has detected an error condition.\n\n!!Optional supporting applications\n\n[[monit|http://www.tildeslash.com/monit/]]\n Monit is a utility for monitoring ant managing processes, files, and other resources in a Unix environment. Monmaster is set up to run under monit with little, if any additional configuration.\n
ObjectModel and OperationalOverview\n\nTestParameters\n[[Logging]]\nTestList\nPageList\nApplicationList\nLogicalServerList\nNotificationGroups\n\nFileList\n\nWebUserInterface\n\nDaemonMode\n\nMonitMonitorsMonmaster
!Monmaster Configuration Guide -- Test Parameters\n!!Overview of test parameters\nMonmaster supports several types of tests: single page web page requests, using either GET or POST, multiple page web requests using session persistence and (optionally) cookie manipulation, and Oracle queries. Each single page web request or Oracle query is defined in an element called ''test'' and each multipage web request is defined in an element called [[sessiontest||SessionTest]].\n\nA ''sessiontest'' includes references to multiple page web requests using session persistence and (optionally) cookie manipulation. Note that the page requests may go against different servers - see SessionTest documentation.\n\nAll tests are children of the ''testlist'' element.\n\n!!!Test parameter elements:\n> test_type\n>> indicates the type of test, 'web' or 'Oracle'\n> page\n>> for a web test, the name of a page (see pagelist_) specification element\n> logical_server\n>> for a test, the name of a logical server (see serverlist_) specification element\n> application\n>> the application that is associated with the test (which may be restarted)\n> test_blackout\n>> an optional element that indicates periods when the test should not be performed\n> blackout\n>> indicates a period when the test should not be performed\n\n!!!optional parameter elements for Oracle tests\n> username\n>> for an Oracle test, the account ID to be used to connect to Oracle\n> password\n>> for an Oracle test, the password to be used to connect to Oracle\n> ora_instance\n>> for an Oracle test, the name of the Oracle instance (server) as defined in the tnsnames.ora file\n> query_string\n>> for an Oracle test, the query to be executed. This query must return what Monmaster (i.e. Python) considers a True or False response, where True indicates success.\n\n!!!Sessiontest parameter elements:\n> application\n>> the application that is associated with the test (which may be restarted)\n> sequence\n>> multiple sequence elements may be defined within a session_test element, each corresponding to a distinct web page request to be performed. Each sequence element includes an *order* attribute that keeps sequence items in the correct order at runtime.\n> page\n>> for a sequence element, the name of a page (see pagelist_) specification element\n> logical_server\n>> for a sequence element, the name of a logical server (see serverlist_) specification element\n\nRelax NG Compact (RNC) schema fragment for ''testlist'' element:\n{{{\n element testlist {\n (element sessiontest {\n application { text },\n test_blackout?,\n element sequence {\n attribute order { xsd:integer },\n page { text },\n logical_server { text }\n }+\n }\n | element test {\n element test_type { xsd:NCName },\n (username,\n password,\n element ora_instance { xsd:NCName },\n element query_string { text })?,\n test_blackout?,\n page? { text },\n logical_server { text },\n application? { text }\n })+\n },\n\n username = element username { text }\n password = element password { text }\n test_blackout = element test_blackout { blackout+ }\n blackout = element blackout { text }\n}}}
!Monmaster Configuration Guide -- Global Parameters\n!!Overview of global parameters\n During Monmaster's [[initialization phase|OperationalOverview]], the parameter \n file specified on the [[command line|OperationalOverview]] is processed by a ParameterFile instance and several \n parameters are set that control key aspects of Monmaster operation.\n\n During operation, the blackoutlist_ and certain other parameters are reset \n at the start of each test cycle. See the table in the next section for details.\n\nnote:\n The parameter file can be edited while Monmaster is running, and updated parameters \n will be applied going forward.\n\n!!Global Parameters\n\n|How Monmaster displays, uses, and refreshes global parameters|c\n|!element name|!displayed|!used|!refreshed|\n|log_level|Y|Y|N|\n|check_interval_seconds|Y|Y|Y|\n|retry_interval_seconds|N|Y|Y|\n|timeout_seconds|Y|Y|Y|\n|retry_times|N|Y|Y|\n|post_restart_check_interval_seconds|N|Y|Y|\n|http_port|Y|Y|N|\n|param_file_version|N|N|N|\n|blackoutlist|Y^^note 1^^|Y|Y|\n\n^^note 1:^^ blackout periods are displayed at startup; changes are displayed in the log; and the Monmaster home page shows the global blackout periods \n\n!!!Global parameter elements:\n\n''log_level''\n the severity of the log items that will be reported by log4py. Options are: Debug, Verbose (the recommended value), Info, Warning, and Error. Note that log4py does not behave like log4j in that setting the log_level to Info will result in ''only'' Info message being displayed, not Info and more severe. See [[logging|Logging]]\n''check_interval_seconds''\n the numbers of seconds that should elapse between the end of one test cycle - \n ''including any application restarting activity'' - and the initiation of the\n subsequent test cycle, if the results were OK. If a restart was performed, the ''post_restart_check_interval_seconds'' parameter applies.\n''retry_times''\n the maximum number of consecutive test failures that are allowed before Monmaster\n attempts any restarting of applications; in conjunction with ''retry_interval_seconds'',\n unnecessary restarts due to transient errors can be reduced\n'' retry_interval_seconds''\n the time period that Monmaster will delay before it retries tests after a bad test result, if the number of consecutive failures is no greater then ''retry_times''. This allows Monmaster to give the applications an opportunity to recover from transient errors, before restarting applications.\n'' timeout_seconds''\n the default socket timeout for connections, both test connections and restart activity. For\n application restarting, this value can be overridden to allow for lengthy restart durations.\n For testing, if a response has not been received at the end of this period, Monmaster \n considers this to be an error condition.\n'' post_restart_check_interval_seconds''\n the number of seconds that must elapse after applications have been restarted prior to\n initiating a new test cycle; this allows for a relatively low ''check_interval_seconds''\n but still allows for servers to fully restart before they are tested\n'' http_port''\n the port the embedded web server should bind to on the local machine \n '' param_file_version''\n this element is read and displayed in the log at startup time only\n'' testsuitename''\n this may be used for any purpose\n '' blackoutlist''\n this element can contain lists of blackout times for notification and/or restarts. For times specified as a blackout, the corrsponding action is suppressed. This prevents, for example, the sending of email or page notifications during scheduled application downtime. See period_ for details on the formatting of blackout period parameters. This element contains 2 lists:\n* notification_blackout contains zero or more of:\n**blackout - a single blackout period, in this case meaning that notification emails will not be sent during the specified period\n*restart_blackout contains zero or more of:\n** blackout a single blackout period, in this case meaning that applications will not be started during the specified period . Note that a restart blackout period can be specified at the application level, as well.\n \n!!Relax NG Compact (RNC) schema fragment for testparams element:\n{{{\n element testparams {\n element param_file_version { xsd:decimal },\n element testsuitename { xsd:NCName },\n element log_level { xsd:NCName },\n element check_interval_seconds { xsd:integer },\n element retry_interval_seconds { xsd:integer },\n element timeout_seconds { xsd:integer },\n element retry_times { xsd:integer },\n element post_restart_check_interval_seconds { xsd:integer },\n element http_port { xsd:integer },\n blackoutlist\n }\n\n blackoutlist =\n element blackoutlist {\n notification_blackout?,\n element restart_blackout { blackout+ }\n }\n notification_blackout = element notification_blackout { blackout* }\n blackout = element blackout { text }\n}}}\n\n
!The Monmaster Web User Interface\n!!Snakelets, the application server embedded in Monmaster\nMonmaster embeds a version of the Snakelets_ application server; the embedded version is 1.31, although\nother versions may also work. Newer versions of Snakelets (1.30 or greater) use the standard Python logging module,\nas does Monmaster, and they share the logging.cfg file - although the logging.cfg that comes with Snakelets has been\nmodified to support Monmaster.\n\n!!The Monmaster web application under Snakelets\nThe Monmaster web UI has been defined to be the root Snakelets web application, and corresponds to the subdirectory\n//ROOT// under the webapps directory.\n\nSnakelets defines web app functionality in several ways:\n* snakelets\n> Python modules that inherit from the snakelets class and provide a number of methods relevant to creating web functions, including dispatching to ypages. Snakelets are similar to servlets in the J2EE world, and service HTTP requests.\n* ypages\n> Ypages are similar to Java Server Pages (JSP) and can include HTML, Python code, and embedded Python attributes. Ypages can be either a template or embedded in a template, and can include other ypages or other files. Ypages are compiled into snakelets and include snakelet functionality.\n* normal Python modules\n> Snakelets and ypages can import any Python modules, including modules defined locally that are specific to the web app.\n\n!!!Shared module for data passing\nThe Monmaster application needs to be able to share objects with the main Monmaster processing loop. After considerable experimentation,\nthe solution implemented uses a Python module, mglobals.py, that is imported by both the main Monmaster threads\nand by the monmasterUI web application. The mglobals module contains very little code, only enough to set up the\nlogging instance that is used by the Snakelets Monmaster web application. In addition, attributes are written to, updated in,\nand read from mglobals by the main Monmaster thread as well as by the monmasterUI code.\n\n!!MonmasterUI components\n!!!Python modules\n>__init__.py\n>> This module is required for a Snakelets web application. In addition to defining certain attributes required by Snakelets, it sets up the shared access to the mglobals object, log instances, and defines a method for performing authentication for access to many Monmaster UI functions.\n>restart.py\n>> Used to perform relativley long running functions, specifically, stop, start, and recover, for the external applications that Monmaster can control. Uses threading so that the monmasterUI request can return a response to the browser immediately.\n\n!!!Snakelets\nMonmasterUI uses no snakelets.\n\n!!!Ypages\nThe index.y and showlog.y pages are the only monamasterUI pages that do not require authentication.\n\nindex.y\n> This is the default page for monmasterUI, and displays the overall Monmaster status as well as links to other pages and monmasterUI functions.\n\nlogin.y\n> This page is displayed when a MonmasterUI user who does not have an active, authenticated session attempts to access a function that requires authentication. It calls the authentication function (which must be configured or replaced for each installation) defined in the __init__.py module.\nlogout.y\n> This page removes the user's session when the logout link is selected.\nmaincontrol.y\n> This page turns the main Monmaster testing cycle on or off as requested from index.y\nserverlist.y\n> For each application that is defined, the status of the server is shown along with links that allow the authenticated user to stop, start or recover (start and stop) the application.\nshowlog.y\n> Ths page shows either the full contents of the current Monmaster log, or the last 30 lines, as requested from the index.y page link.\ntemplate.y\n> This defines the standard look and feel for the monmasterUI web app. It wraps all other pages. It, and related components such as stylesheets and graphics, can be customized as desired.\ntoggle.y\n> This page enables/disables the "site is currently unavailable" page that may need to be posted to the public web site to prevent users from connecting to the external web applications during site maintenence. This function is provided as a convenience and is not otherwise connected to other Monmaster functionality.\ntoggleapp.y\n> This page allows individual external application to be started or stopped from the monmasterUI.\n\n!!!!Ypages that support parameter file updates\naddblackout.y\n> Allows a new blackout period to be added.\naddsearchstring.y\n> Allows a new search string to be added to a page parameter element.\ndeleteblackout.y\n> Backend function to delete a specific blackout period.\neditblackout.y\n> Allows a blackout period parameter to be edited.\neditblackoutglobal.y\n> Lists the blackout periods (notification and restart) that are global to Monmaster, and allows updates.\neditpage.y\n> Allows viewing of the search strings (**good_strings** and **error_strings**) for a page as well as the raw HTML returned for prior page requests for that page (if any exist). Note that a page may have been requested from one or more logical servers, so there may be multiple pages displayed.\neditparams.y\n> The main page for parameter edits, providing links to specific editing functions.\neditstring.y\n> Allows editing of a search string.\npagelist.y\n> Lists all defined application pages and provides links to view and edit page parameters.\n\n!!Customizing MonmasterUI\nMonmaster UI uses a stylesheet (manage.css) and a template (template.y) to define the standard look for monmasterUI pages. These files can be modified as desired. In addition, the three image files can be replaced as necessary.
<<timeline>>
Describe the server that is running Monmaster here...\n\nSee: [[Access to Server]]\n MonitMonitorsMonmaster