13248 lines
522 KiB
HTML
13248 lines
522 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
<head>
|
|
<script type="text/javascript">
|
|
//<![CDATA[
|
|
var version = {title: "TiddlyWiki", major: 2, minor: 2, revision: 3, date: new Date("Jun 17, 2007"), extensions: {}};
|
|
//]]>
|
|
</script>
|
|
<!--
|
|
TiddlyWiki created by Jeremy Ruston, (jeremy [at] osmosoft [dot] com)
|
|
|
|
Copyright (c) UnaMesa Association 2004-2007
|
|
|
|
Redistribution and use in source and binary forms, with or without modification,
|
|
are permitted provided that the following conditions are met:
|
|
|
|
Redistributions of source code must retain the above copyright notice, this
|
|
list of conditions and the following disclaimer.
|
|
|
|
Redistributions in binary form must reproduce the above copyright notice, this
|
|
list of conditions and the following disclaimer in the documentation and/or other
|
|
materials provided with the distribution.
|
|
|
|
Neither the name of the UnaMesa Association nor the names of its contributors may be
|
|
used to endorse or promote products derived from this software without specific
|
|
prior written permission.
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
|
SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
|
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
|
DAMAGE.
|
|
-->
|
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
|
<!--PRE-HEAD-START-->
|
|
<!--{{{-->
|
|
<link rel='alternate' type='application/rss+xml' title='RSS' href='index.xml'/>
|
|
<!--}}}-->
|
|
|
|
<style type="text/css">#contentWrapper {display:none;}</style><div id="SplashScreen" style="border: 3px solid #ccc; display: block; text-align: center; width: 320px; margin: 100px auto; padding: 50px; color:#000; font-size: 28px; font-family:Tahoma; background-color:#eee;"><b>Lumiera TiddlyWiki</b> is loading<blink> ...</blink><br><br><span style="font-size: 14px; color:red;">Requires Javascript.</span></div>
|
|
<!--PRE-HEAD-END-->
|
|
<title> Lumiera - Distributed Developer Wiki </title>
|
|
<style type="text/css">
|
|
#saveTest {display:none;}
|
|
#messageArea {display:none;}
|
|
#copyright {display:none;}
|
|
#storeArea {display:none;}
|
|
#storeArea div {padding:0.5em; margin:1em 0em 0em 0em; border-color:#fff #666 #444 #ddd; border-style:solid; border-width:2px; overflow:auto;}
|
|
#shadowArea {display:none;}
|
|
#javascriptWarning {width:100%; text-align:center; font-weight:bold; background-color:#dd1100; color:#fff; padding:1em 0em;}
|
|
</style>
|
|
<!--POST-HEAD-START-->
|
|
|
|
<!--POST-HEAD-END-->
|
|
</head>
|
|
<body onload="main();" onunload="if(window.checkUnsavedChanges) checkUnsavedChanges(); if(window.scrubNodes) scrubNodes(document.body);">
|
|
<!--PRE-BODY-START-->
|
|
|
|
<!--PRE-BODY-END-->
|
|
<div id="copyright">
|
|
Welcome to TiddlyWiki created by Jeremy Ruston, Copyright © 2007 UnaMesa Association
|
|
</div>
|
|
<noscript>
|
|
<div id="javascriptWarning">This page requires JavaScript to function properly.<br /><br />If you are using Microsoft Internet Explorer you may need to click on the yellow bar above and select 'Allow Blocked Content'. You must then click 'Yes' on the following security warning.</div>
|
|
</noscript>
|
|
<div id="saveTest"></div>
|
|
<div id="backstageCloak"></div>
|
|
<div id="backstageButton"></div>
|
|
<div id="backstageArea"><div id="backstageToolbar"></div></div>
|
|
<div id="backstage">
|
|
<div id="backstagePanel"></div>
|
|
</div>
|
|
<div id="contentWrapper"></div>
|
|
<div id="contentStash"></div>
|
|
<div id="shadowArea">
|
|
<div title="ColorPalette">
|
|
<pre>Background: #fff
|
|
Foreground: #000
|
|
PrimaryPale: #8cf
|
|
PrimaryLight: #18f
|
|
PrimaryMid: #04b
|
|
PrimaryDark: #014
|
|
SecondaryPale: #ffc
|
|
SecondaryLight: #fe8
|
|
SecondaryMid: #db4
|
|
SecondaryDark: #841
|
|
TertiaryPale: #eee
|
|
TertiaryLight: #ccc
|
|
TertiaryMid: #999
|
|
TertiaryDark: #666
|
|
Error: #f88</pre>
|
|
</div>
|
|
<div title="StyleSheetColors">
|
|
<pre>/*{{{*/
|
|
body {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
|
|
|
|
a {color:[[ColorPalette::PrimaryMid]];}
|
|
a:hover {background-color:[[ColorPalette::PrimaryMid]]; color:[[ColorPalette::Background]];}
|
|
a img {border:0;}
|
|
|
|
h1,h2,h3,h4,h5,h6 {color:[[ColorPalette::SecondaryDark]]; background:transparent;}
|
|
h1 {border-bottom:2px solid [[ColorPalette::TertiaryLight]];}
|
|
h2,h3 {border-bottom:1px solid [[ColorPalette::TertiaryLight]];}
|
|
|
|
.button {color:[[ColorPalette::PrimaryDark]]; border:1px solid [[ColorPalette::Background]];}
|
|
.button:hover {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::SecondaryLight]]; border-color:[[ColorPalette::SecondaryMid]];}
|
|
.button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::SecondaryDark]];}
|
|
|
|
.header {background:[[ColorPalette::PrimaryMid]];}
|
|
.headerShadow {color:[[ColorPalette::Foreground]];}
|
|
.headerShadow a {font-weight:normal; color:[[ColorPalette::Foreground]];}
|
|
.headerForeground {color:[[ColorPalette::Background]];}
|
|
.headerForeground a {font-weight:normal; color:[[ColorPalette::PrimaryPale]];}
|
|
|
|
.tabSelected{color:[[ColorPalette::PrimaryDark]];
|
|
background:[[ColorPalette::TertiaryPale]];
|
|
border-left:1px solid [[ColorPalette::TertiaryLight]];
|
|
border-top:1px solid [[ColorPalette::TertiaryLight]];
|
|
border-right:1px solid [[ColorPalette::TertiaryLight]];
|
|
}
|
|
.tabUnselected {color:[[ColorPalette::Background]]; background:[[ColorPalette::TertiaryMid]];}
|
|
.tabContents {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::TertiaryPale]]; border:1px solid [[ColorPalette::TertiaryLight]];}
|
|
.tabContents .button {border:0;}
|
|
|
|
#sidebar {}
|
|
#sidebarOptions input {border:1px solid [[ColorPalette::PrimaryMid]];}
|
|
#sidebarOptions .sliderPanel {background:[[ColorPalette::PrimaryPale]];}
|
|
#sidebarOptions .sliderPanel a {border:none;color:[[ColorPalette::PrimaryMid]];}
|
|
#sidebarOptions .sliderPanel a:hover {color:[[ColorPalette::Background]]; background:[[ColorPalette::PrimaryMid]];}
|
|
#sidebarOptions .sliderPanel a:active {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::Background]];}
|
|
|
|
.wizard {background:[[ColorPalette::PrimaryPale]]; border:1px solid [[ColorPalette::PrimaryMid]];}
|
|
.wizard h1 {color:[[ColorPalette::PrimaryDark]]; border:none;}
|
|
.wizard h2 {color:[[ColorPalette::Foreground]]; border:none;}
|
|
.wizardStep {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];
|
|
border:1px solid [[ColorPalette::PrimaryMid]];}
|
|
.wizardStep.wizardStepDone {background::[[ColorPalette::TertiaryLight]];}
|
|
.wizardFooter {background:[[ColorPalette::PrimaryPale]];}
|
|
.wizardFooter .status {background:[[ColorPalette::PrimaryDark]]; color:[[ColorPalette::Background]];}
|
|
.wizard .button {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryLight]]; border: 1px solid;
|
|
border-color:[[ColorPalette::SecondaryPale]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryDark]] [[ColorPalette::SecondaryPale]];}
|
|
.wizard .button:hover {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Background]];}
|
|
.wizard .button:active {color:[[ColorPalette::Background]]; background:[[ColorPalette::Foreground]]; border: 1px solid;
|
|
border-color:[[ColorPalette::PrimaryDark]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryPale]] [[ColorPalette::PrimaryDark]];}
|
|
|
|
#messageArea {border:1px solid [[ColorPalette::SecondaryMid]]; background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]];}
|
|
#messageArea .button {color:[[ColorPalette::PrimaryMid]]; background:[[ColorPalette::SecondaryPale]]; border:none;}
|
|
|
|
.popupTiddler {background:[[ColorPalette::TertiaryPale]]; border:2px solid [[ColorPalette::TertiaryMid]];}
|
|
|
|
.popup {background:[[ColorPalette::TertiaryPale]]; color:[[ColorPalette::TertiaryDark]]; border-left:1px solid [[ColorPalette::TertiaryMid]]; border-top:1px solid [[ColorPalette::TertiaryMid]]; border-right:2px solid [[ColorPalette::TertiaryDark]]; border-bottom:2px solid [[ColorPalette::TertiaryDark]];}
|
|
.popup hr {color:[[ColorPalette::PrimaryDark]]; background:[[ColorPalette::PrimaryDark]]; border-bottom:1px;}
|
|
.popup li.disabled {color:[[ColorPalette::TertiaryMid]];}
|
|
.popup li a, .popup li a:visited {color:[[ColorPalette::Foreground]]; border: none;}
|
|
.popup li a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border: none;}
|
|
.popup li a:active {background:[[ColorPalette::SecondaryPale]]; color:[[ColorPalette::Foreground]]; border: none;}
|
|
.popupHighlight {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
|
|
.listBreak div {border-bottom:1px solid [[ColorPalette::TertiaryDark]];}
|
|
|
|
.tiddler .defaultCommand {font-weight:bold;}
|
|
|
|
.shadow .title {color:[[ColorPalette::TertiaryDark]];}
|
|
|
|
.title {color:[[ColorPalette::SecondaryDark]];}
|
|
.subtitle {color:[[ColorPalette::TertiaryDark]];}
|
|
|
|
.toolbar {color:[[ColorPalette::PrimaryMid]];}
|
|
.toolbar a {color:[[ColorPalette::TertiaryLight]];}
|
|
.selected .toolbar a {color:[[ColorPalette::TertiaryMid]];}
|
|
.selected .toolbar a:hover {color:[[ColorPalette::Foreground]];}
|
|
|
|
.tagging, .tagged {border:1px solid [[ColorPalette::TertiaryPale]]; background-color:[[ColorPalette::TertiaryPale]];}
|
|
.selected .tagging, .selected .tagged {background-color:[[ColorPalette::TertiaryLight]]; border:1px solid [[ColorPalette::TertiaryMid]];}
|
|
.tagging .listTitle, .tagged .listTitle {color:[[ColorPalette::PrimaryDark]];}
|
|
.tagging .button, .tagged .button {border:none;}
|
|
|
|
.footer {color:[[ColorPalette::TertiaryLight]];}
|
|
.selected .footer {color:[[ColorPalette::TertiaryMid]];}
|
|
|
|
.sparkline {background:[[ColorPalette::PrimaryPale]]; border:0;}
|
|
.sparktick {background:[[ColorPalette::PrimaryDark]];}
|
|
|
|
.error, .errorButton {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::Error]];}
|
|
.warning {color:[[ColorPalette::Foreground]]; background:[[ColorPalette::SecondaryPale]];}
|
|
.lowlight {background:[[ColorPalette::TertiaryLight]];}
|
|
|
|
.zoomer {background:none; color:[[ColorPalette::TertiaryMid]]; border:3px solid [[ColorPalette::TertiaryMid]];}
|
|
|
|
.imageLink, #displayArea .imageLink {background:transparent;}
|
|
|
|
.annotation {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; border:2px solid [[ColorPalette::SecondaryMid]];}
|
|
|
|
.viewer .listTitle {list-style-type:none; margin-left:-2em;}
|
|
.viewer .button {border:1px solid [[ColorPalette::SecondaryMid]];}
|
|
.viewer blockquote {border-left:3px solid [[ColorPalette::TertiaryDark]];}
|
|
|
|
.viewer table, table.twtable {border:2px solid [[ColorPalette::TertiaryDark]];}
|
|
.viewer th, .viewer thead td, .twtable th, .twtable thead td {background:[[ColorPalette::SecondaryMid]]; border:1px solid [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::Background]];}
|
|
.viewer td, .viewer tr, .twtable td, .twtable tr {border:1px solid [[ColorPalette::TertiaryDark]];}
|
|
|
|
.viewer pre {border:1px solid [[ColorPalette::SecondaryLight]]; background:[[ColorPalette::SecondaryPale]];}
|
|
.viewer code {color:[[ColorPalette::SecondaryDark]];}
|
|
.viewer hr {border:0; border-top:dashed 1px [[ColorPalette::TertiaryDark]]; color:[[ColorPalette::TertiaryDark]];}
|
|
|
|
.highlight, .marked {background:[[ColorPalette::SecondaryLight]];}
|
|
|
|
.editor input {border:1px solid [[ColorPalette::PrimaryMid]];}
|
|
.editor textarea {border:1px solid [[ColorPalette::PrimaryMid]]; width:100%;}
|
|
.editorFooter {color:[[ColorPalette::TertiaryMid]];}
|
|
|
|
#backstageArea {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::TertiaryMid]];}
|
|
#backstageArea a {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
|
|
#backstageArea a:hover {background:[[ColorPalette::SecondaryLight]]; color:[[ColorPalette::Foreground]]; }
|
|
#backstageArea a.backstageSelTab {background:[[ColorPalette::Background]]; color:[[ColorPalette::Foreground]];}
|
|
#backstageButton a {background:none; color:[[ColorPalette::Background]]; border:none;}
|
|
#backstageButton a:hover {background:[[ColorPalette::Foreground]]; color:[[ColorPalette::Background]]; border:none;}
|
|
#backstagePanel {background:[[ColorPalette::Background]]; border-color: [[ColorPalette::Background]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]] [[ColorPalette::TertiaryDark]];}
|
|
.backstagePanelFooter .button {border:none; color:[[ColorPalette::Background]];}
|
|
.backstagePanelFooter .button:hover {color:[[ColorPalette::Foreground]];}
|
|
#backstageCloak {background:[[ColorPalette::Foreground]]; opacity:0.6; filter:'alpha(opacity:60)';}
|
|
/*}}}*/</pre>
|
|
</div>
|
|
<div title="StyleSheetLayout">
|
|
<pre>/*{{{*/
|
|
* html .tiddler {height:1%;}
|
|
|
|
body {font-size:.75em; font-family:arial,helvetica; margin:0; padding:0;}
|
|
|
|
h1,h2,h3,h4,h5,h6 {font-weight:bold; text-decoration:none;}
|
|
h1,h2,h3 {padding-bottom:1px; margin-top:1.2em;margin-bottom:0.3em;}
|
|
h4,h5,h6 {margin-top:1em;}
|
|
h1 {font-size:1.35em;}
|
|
h2 {font-size:1.25em;}
|
|
h3 {font-size:1.1em;}
|
|
h4 {font-size:1em;}
|
|
h5 {font-size:.9em;}
|
|
|
|
hr {height:1px;}
|
|
|
|
a {text-decoration:none;}
|
|
|
|
dt {font-weight:bold;}
|
|
|
|
ol {list-style-type:decimal;}
|
|
ol ol {list-style-type:lower-alpha;}
|
|
ol ol ol {list-style-type:lower-roman;}
|
|
ol ol ol ol {list-style-type:decimal;}
|
|
ol ol ol ol ol {list-style-type:lower-alpha;}
|
|
ol ol ol ol ol ol {list-style-type:lower-roman;}
|
|
ol ol ol ol ol ol ol {list-style-type:decimal;}
|
|
|
|
.txtOptionInput {width:11em;}
|
|
|
|
#contentWrapper .chkOptionInput {border:0;}
|
|
|
|
.externalLink {text-decoration:underline;}
|
|
|
|
.indent {margin-left:3em;}
|
|
.outdent {margin-left:3em; text-indent:-3em;}
|
|
code.escaped {white-space:nowrap;}
|
|
|
|
.tiddlyLinkExisting {font-weight:bold;}
|
|
.tiddlyLinkNonExisting {font-style:italic;}
|
|
|
|
/* the 'a' is required for IE, otherwise it renders the whole tiddler in bold */
|
|
a.tiddlyLinkNonExisting.shadow {font-weight:bold;}
|
|
|
|
#mainMenu .tiddlyLinkExisting,
|
|
#mainMenu .tiddlyLinkNonExisting,
|
|
#sidebarTabs .tiddlyLinkNonExisting {font-weight:normal; font-style:normal;}
|
|
#sidebarTabs .tiddlyLinkExisting {font-weight:bold; font-style:normal;}
|
|
|
|
.header {position:relative;}
|
|
.header a:hover {background:transparent;}
|
|
.headerShadow {position:relative; padding:4.5em 0em 1em 1em; left:-1px; top:-1px;}
|
|
.headerForeground {position:absolute; padding:4.5em 0em 1em 1em; left:0px; top:0px;}
|
|
|
|
.siteTitle {font-size:3em;}
|
|
.siteSubtitle {font-size:1.2em;}
|
|
|
|
#mainMenu {position:absolute; left:0; width:10em; text-align:right; line-height:1.6em; padding:1.5em 0.5em 0.5em 0.5em; font-size:1.1em;}
|
|
|
|
#sidebar {position:absolute; right:3px; width:16em; font-size:.9em;}
|
|
#sidebarOptions {padding-top:0.3em;}
|
|
#sidebarOptions a {margin:0em 0.2em; padding:0.2em 0.3em; display:block;}
|
|
#sidebarOptions input {margin:0.4em 0.5em;}
|
|
#sidebarOptions .sliderPanel {margin-left:1em; padding:0.5em; font-size:.85em;}
|
|
#sidebarOptions .sliderPanel a {font-weight:bold; display:inline; padding:0;}
|
|
#sidebarOptions .sliderPanel input {margin:0 0 .3em 0;}
|
|
#sidebarTabs .tabContents {width:15em; overflow:hidden;}
|
|
|
|
.wizard {padding:0.1em 1em 0em 2em;}
|
|
.wizard h1 {font-size:2em; font-weight:bold; background:none; padding:0em 0em 0em 0em; margin:0.4em 0em 0.2em 0em;}
|
|
.wizard h2 {font-size:1.2em; font-weight:bold; background:none; padding:0em 0em 0em 0em; margin:0.4em 0em 0.2em 0em;}
|
|
.wizardStep {padding:1em 1em 1em 1em;}
|
|
.wizard .button {margin:0.5em 0em 0em 0em; font-size:1.2em;}
|
|
.wizardFooter {padding:0.8em 0.4em 0.8em 0em;}
|
|
.wizardFooter .status {padding:0em 0.4em 0em 0.4em; margin-left:1em;}
|
|
.wizard .button {padding:0.1em 0.2em 0.1em 0.2em;}
|
|
|
|
#messageArea {position:fixed; top:2em; right:0em; margin:0.5em; padding:0.5em; z-index:2000; _position:absolute;}
|
|
.messageToolbar {display:block; text-align:right; padding:0.2em 0.2em 0.2em 0.2em;}
|
|
#messageArea a {text-decoration:underline;}
|
|
|
|
.tiddlerPopupButton {padding:0.2em 0.2em 0.2em 0.2em;}
|
|
.popupTiddler {position: absolute; z-index:300; padding:1em 1em 1em 1em; margin:0;}
|
|
|
|
.popup {position:absolute; z-index:300; font-size:.9em; padding:0; list-style:none; margin:0;}
|
|
.popup .popupMessage {padding:0.4em;}
|
|
.popup hr {display:block; height:1px; width:auto; padding:0; margin:0.2em 0em;}
|
|
.popup li.disabled {padding:0.4em;}
|
|
.popup li a {display:block; padding:0.4em; font-weight:normal; cursor:pointer;}
|
|
.listBreak {font-size:1px; line-height:1px;}
|
|
.listBreak div {margin:2px 0;}
|
|
|
|
.tabset {padding:1em 0em 0em 0.5em;}
|
|
.tab {margin:0em 0em 0em 0.25em; padding:2px;}
|
|
.tabContents {padding:0.5em;}
|
|
.tabContents ul, .tabContents ol {margin:0; padding:0;}
|
|
.txtMainTab .tabContents li {list-style:none;}
|
|
.tabContents li.listLink { margin-left:.75em;}
|
|
|
|
#contentWrapper {display:block;}
|
|
#splashScreen {display:none;}
|
|
|
|
#displayArea {margin:1em 17em 0em 14em;}
|
|
|
|
.toolbar {text-align:right; font-size:.9em;}
|
|
|
|
.tiddler {padding:1em 1em 0em 1em;}
|
|
|
|
.missing .viewer,.missing .title {font-style:italic;}
|
|
|
|
.title {font-size:1.6em; font-weight:bold;}
|
|
|
|
.missing .subtitle {display:none;}
|
|
.subtitle {font-size:1.1em;}
|
|
|
|
.tiddler .button {padding:0.2em 0.4em;}
|
|
|
|
.tagging {margin:0.5em 0.5em 0.5em 0; float:left; display:none;}
|
|
.isTag .tagging {display:block;}
|
|
.tagged {margin:0.5em; float:right;}
|
|
.tagging, .tagged {font-size:0.9em; padding:0.25em;}
|
|
.tagging ul, .tagged ul {list-style:none; margin:0.25em; padding:0;}
|
|
.tagClear {clear:both;}
|
|
|
|
.footer {font-size:.9em;}
|
|
.footer li {display:inline;}
|
|
|
|
.annotation {padding:0.5em; margin:0.5em;}
|
|
|
|
* html .viewer pre {width:99%; padding:0 0 1em 0;}
|
|
.viewer {line-height:1.4em; padding-top:0.5em;}
|
|
.viewer .button {margin:0em 0.25em; padding:0em 0.25em;}
|
|
.viewer blockquote {line-height:1.5em; padding-left:0.8em;margin-left:2.5em;}
|
|
.viewer ul, .viewer ol {margin-left:0.5em; padding-left:1.5em;}
|
|
|
|
.viewer table, table.twtable {border-collapse:collapse; margin:0.8em 1.0em;}
|
|
.viewer th, .viewer td, .viewer tr,.viewer caption,.twtable th, .twtable td, .twtable tr,.twtable caption {padding:3px;}
|
|
table.listView {font-size:0.85em; margin:0.8em 1.0em;}
|
|
table.listView th, table.listView td, table.listView tr {padding:0px 3px 0px 3px;}
|
|
|
|
.viewer pre {padding:0.5em; margin-left:0.5em; font-size:1.2em; line-height:1.4em; overflow:auto;}
|
|
.viewer code {font-size:1.2em; line-height:1.4em;}
|
|
|
|
.editor {font-size:1.1em;}
|
|
.editor input, .editor textarea {display:block; width:100%; font:inherit;}
|
|
.editorFooter {padding:0.25em 0em; font-size:.9em;}
|
|
.editorFooter .button {padding-top:0px; padding-bottom:0px;}
|
|
|
|
.fieldsetFix {border:0; padding:0; margin:1px 0px 1px 0px;}
|
|
|
|
.sparkline {line-height:1em;}
|
|
.sparktick {outline:0;}
|
|
|
|
.zoomer {font-size:1.1em; position:absolute; overflow:hidden;}
|
|
.zoomer div {padding:1em;}
|
|
|
|
* html #backstage {width:99%;}
|
|
* html #backstageArea {width:99%;}
|
|
#backstageArea {display:none; position:relative; overflow: hidden; z-index:150; padding:0.3em 0.5em 0.3em 0.5em;}
|
|
#backstageToolbar {position:relative;}
|
|
#backstageArea a {font-weight:bold; margin-left:0.5em; padding:0.3em 0.5em 0.3em 0.5em;}
|
|
#backstageButton {display:none; position:absolute; z-index:175; top:0em; right:0em;}
|
|
#backstageButton a {padding:0.1em 0.4em 0.1em 0.4em; margin:0.1em 0.1em 0.1em 0.1em;}
|
|
#backstage {position:relative; width:100%; z-index:50;}
|
|
#backstagePanel {display:none; z-index:100; position:absolute; margin:0em 3em 0em 3em; padding:1em 1em 1em 1em;}
|
|
.backstagePanelFooter {padding-top:0.2em; float:right;}
|
|
.backstagePanelFooter a {padding:0.2em 0.4em 0.2em 0.4em;}
|
|
#backstageCloak {display:none; z-index:20; position:absolute; width:100%; height:100px;}
|
|
|
|
.whenBackstage {display:none;}
|
|
.backstageVisible .whenBackstage {display:block;}
|
|
/*}}}*/</pre>
|
|
</div>
|
|
<div title="StyleSheetLocale">
|
|
<pre>/***
|
|
StyleSheet for use when a translation requires any css style changes.
|
|
This StyleSheet can be used directly by languages such as Chinese, Japanese and Korean which use a logographic writing system and need larger font sizes.
|
|
***/
|
|
|
|
/*{{{*/
|
|
body {font-size:0.8em;}
|
|
|
|
#sidebarOptions {font-size:1.05em;}
|
|
#sidebarOptions a {font-style:normal;}
|
|
#sidebarOptions .sliderPanel {font-size:0.95em;}
|
|
|
|
.subtitle {font-size:0.8em;}
|
|
|
|
.viewer table.listView {font-size:0.95em;}
|
|
|
|
.htmlarea .toolbarHA table {border:1px solid ButtonFace; margin:0em 0em;}
|
|
/*}}}*/</pre>
|
|
</div>
|
|
<div title="StyleSheetPrint">
|
|
<pre>/*{{{*/
|
|
@media print {
|
|
#mainMenu, #sidebar, #messageArea, .toolbar, #backstageButton {display: none ! important;}
|
|
#displayArea {margin: 1em 1em 0em 1em;}
|
|
/* Fixes a feature in Firefox 1.5.0.2 where print preview displays the noscript content */
|
|
noscript {display:none;}
|
|
}
|
|
/*}}}*/</pre>
|
|
</div>
|
|
<div title="PageTemplate">
|
|
<pre><!--{{{-->
|
|
<div class='header' macro='gradient vert [[ColorPalette::PrimaryLight]] [[ColorPalette::PrimaryMid]]'>
|
|
<div class='headerShadow'>
|
|
<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;
|
|
<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>
|
|
</div>
|
|
<div class='headerForeground'>
|
|
<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;
|
|
<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>
|
|
</div>
|
|
</div>
|
|
<div id='mainMenu' refresh='content' tiddler='MainMenu'></div>
|
|
<div id='sidebar'>
|
|
<div id='sidebarOptions' refresh='content' tiddler='SideBarOptions'></div>
|
|
<div id='sidebarTabs' refresh='content' force='true' tiddler='SideBarTabs'></div>
|
|
</div>
|
|
<div id='displayArea'>
|
|
<div id='messageArea'></div>
|
|
<div id='tiddlerDisplay'></div>
|
|
</div>
|
|
<!--}}}--></pre>
|
|
</div>
|
|
<div title="ViewTemplate">
|
|
<pre><!--{{{-->
|
|
<div class='toolbar' macro='toolbar closeTiddler closeOthers +editTiddler > fields syncing permalink references jump'></div>
|
|
<div class='title' macro='view title'></div>
|
|
<div class='subtitle'><span macro='view modifier link'></span>, <span macro='view modified date'></span> (<span macro='message views.wikified.createdPrompt'></span> <span macro='view created date'></span>)</div>
|
|
<div class='tagging' macro='tagging'></div>
|
|
<div class='tagged' macro='tags'></div>
|
|
<div class='viewer' macro='view text wikified'></div>
|
|
<div class='tagClear'></div>
|
|
<!--}}}--></pre>
|
|
</div>
|
|
<div title="EditTemplate">
|
|
<pre><!--{{{-->
|
|
<div class='toolbar' macro='toolbar +saveTiddler -cancelTiddler deleteTiddler'></div>
|
|
<div class='title' macro='view title'></div>
|
|
<div class='editor' macro='edit title'></div>
|
|
<div macro='annotations'></div>
|
|
<div class='editor' macro='edit text'></div>
|
|
<div class='editor' macro='edit tags'></div><div class='editorFooter'><span macro='message views.editor.tagPrompt'></span><span macro='tagChooser'></span></div>
|
|
<!--}}}--></pre>
|
|
</div>
|
|
<div title="GettingStarted">
|
|
<pre>To get started with this blank TiddlyWiki, you'll need to modify the following tiddlers:
|
|
* SiteTitle & SiteSubtitle: The title and subtitle of the site, as shown above (after saving, they will also appear in the browser title bar)
|
|
* MainMenu: The menu (usually on the left)
|
|
* DefaultTiddlers: Contains the names of the tiddlers that you want to appear when the TiddlyWiki is opened
|
|
You'll also need to enter your username for signing your edits: <<option txtUserName>></pre>
|
|
</div>
|
|
<div title="OptionsPanel">
|
|
<pre>These InterfaceOptions for customising TiddlyWiki are saved in your browser
|
|
|
|
Your username for signing your edits. Write it as a WikiWord (eg JoeBloggs)
|
|
|
|
<<option txtUserName>>
|
|
<<option chkSaveBackups>> SaveBackups
|
|
<<option chkAutoSave>> AutoSave
|
|
<<option chkRegExpSearch>> RegExpSearch
|
|
<<option chkCaseSensitiveSearch>> CaseSensitiveSearch
|
|
<<option chkAnimate>> EnableAnimations
|
|
|
|
----
|
|
Also see AdvancedOptions</pre>
|
|
</div>
|
|
</div>
|
|
<!--POST-SHADOWAREA-->
|
|
<div id="storeArea">
|
|
<div title="1. The basics of the task macro" modifier="CehTeh" modified="200706100740" created="200604082224" tags="TaskMacroTutorial" server.type="file" server.host="file:///home/ct/.homepage/home.html" server.page.revision="200706100740">
|
|
<pre>A task has a description, an estimate of how long it will take, and a record of how much time you have spent on it so far. Here's an example, which shows a task estimated at 3 hours, with 1 hour spent on it, and ''2'' hours remaining:
|
|
<<<
|
|
<<task 3 3 1>> Add a double-click handler to the description cell that opens the editor and selects the text
|
|
<<<
|
|
If you hover the mouse over any part of the task -- the bullet, the description, or any of the numeric cells -- a tip will appear explaining it.
|
|
|
|
Try modifying the time spent. Suppose you've just spent one more hour and want to record it. Just click on the second yellow cell, and enter "+1" (sans the quote marks, of course) in the popup window. Watch the time remaining go down to 1 hour.
|
|
|
|
In reality, I originally estimated this task at a half-hour, but it ended up taking 3.5 hours. The macro also tracks your original estimate, if it is different from the current estimate, in a fourth cell like this:
|
|
<<<
|
|
<<task 0.5 2 1>> Add a double-click handler to the description cell that opens the editor and selects the text
|
|
<<<
|
|
You can adjust the current estimate in the same way as you adjusted the time spent. Click on the current estimate cell (the first yellow cell), and change it to 2.5 hours by typing "2.5" or "+.5".
|
|
|
|
You can also adjust the time remaining, which will modify either the estimate (if the time remaining increases) or the time spent (if it decreases). Click on the time remaining and add an hour by typing "+1".
|
|
|
|
When the time remaining goes to zero, the task is considered complete:
|
|
<<<
|
|
<<task 0.5 3.5 3.5>> Add a double-click handler to the description cell that opens the editor and selects the text
|
|
<<<
|
|
If you haven't already done so, try double-clicking the description. Yes, it really does open up the editor and select just the text of the description.
|
|
|
|
----
|
|
To continue, click the down-arrow and choose another section: <<tag TaskMacroTutorial>></pre>
|
|
</div>
|
|
<div title="2. More advanced use of the task macro" modifier="LukeBlanshard" modified="200604090319" created="200604082349" tags="TaskMacroTutorial" server.type="file" server.host="file:///home/ct/.homepage/home.html" server.page.revision="200604090319">
|
|
<pre>A task's description is a single wikified line, so it can contain any formatting that can be specified on one line:
|
|
<<<
|
|
<<task 1>> Beef up the time click handlers to allow entry of ''two'' values each: cur&spent, spent&rem. Add click handler to done tasks' spent cells too, to reopen them (like with +0, 1).
|
|
<<task 0.5>> Put tasksum on the ViewTemplate.
|
|
<<<
|
|
You can specify just the description of a task, and leave it unestimated. Click the question mark to enter the estimate:
|
|
<<<
|
|
<<task>> Beef up the time click handlers to allow entry of ''two'' values each: cur&spent, spent&rem. Add click handler to done tasks' spent cells too, to reopen them (like with +0, 1).
|
|
<<<
|
|
As this task implies, you can enter two values in the popup when you click on any of the time cells. Separate them with spaces and/or a comma. Experiment:
|
|
<<<
|
|
<<task 1>> Beef up the time click handlers to allow entry of ''two'' values each: cur&spent, spent&rem. Add click handler to done tasks' spent cells too, to reopen them (like with +0, 1).
|
|
<<<
|
|
Finally, if you haven't already figured this out, you can double-click on a task's bullet to mark it complete, with the current estimate entered as the time spent.
|
|
|
|
----
|
|
To continue, click the down-arrow and choose another section: <<tag TaskMacroTutorial>></pre>
|
|
</div>
|
|
<div title="3. The taskadder macro: add tasks easily" modifier="LukeBlanshard" modified="200605020243" created="200604082241" tags="TaskMacroTutorial" server.type="file" server.host="file:///home/ct/.homepage/home.html" server.page.revision="200605020243">
|
|
<pre>If you've been paying attention, you've noticed that I haven't discussed the actual adding of calls to the task macro within your tiddlers -- it's all been about modifying tasks that were already there. That's because adding tasks via the taskadder macro is much easier and more intuitive than adding them by hand.
|
|
|
|
And setting up a taskadder is simplicity itself. Just add {{{<<taskadder>>}}} to your tiddler. You will see this:
|
|
<<<
|
|
<<taskadder>>
|
|
<<<
|
|
Just type a task description into the first field, and your initial estimate for how long it will take into the second field. Click the "add task" button, or just hit Enter in either of the fields, to add the new task into the tiddler. Notice that you can just start typing a new task as soon as you're done entering the first one.
|
|
|
|
You can have as many taskadders as you like in any tiddler. The last one you used will capture the keyboard focus when it is redisplayed, meaning you can type a series of tasks without using the mouse. Try adding some tasks here and in the above adder:
|
|
<<<
|
|
<<taskadder>>
|
|
<<<
|
|
Notice that the one you just used takes focus when this tiddler is redisplayed.
|
|
|
|
A taskadder by default adds tasks above itself. You can make it add them below by adding a {{{below}}} argument to the macro call:
|
|
<<<
|
|
<<taskadder below>>
|
|
<<<
|
|
|
|
----
|
|
To continue, click the down-arrow and choose another section: <<tag TaskMacroTutorial>></pre>
|
|
</div>
|
|
<div title="4. The tasksum macro: summarize tasks" modifier="LukeBlanshard" modified="200605020248" created="200604082241" tags="TaskMacroTutorial" server.type="file" server.host="file:///home/ct/.homepage/home.html" server.page.revision="200605020248">
|
|
<pre>In this tutorial, we've been looking mostly at individual tasks. In real life, though, you'll typically have a series of them, or even several series of them in the same tiddler. In these cases you want a summary that tells you -- at a minimum -- how much time you still expect to spend on these tasks.
|
|
|
|
To get such a summary, just add {{{<<tasksum start>>}}} before the tasks and {{{<<tasksum end>>}}} after them. Here's an example:
|
|
<<<
|
|
<<tasksum start>>
|
|
<<task 0.25 0.25 0.25>> Add tooltips to the various cells
|
|
<<task 1 0.75 0.75>> Figure out how to add auto-updating click handlers to the time cells
|
|
<<task 2 2 0>> Add simple click handlers to cur, spent, rem: just allow direct setting of values
|
|
<<task 1 3.5 2.5>> Add a double-click handler to the desc cell that opens the editor and selects the text
|
|
<<task 1 1 0>> Beef up the time click handlers to allow entry of two values each: cur&spent, spent&rem. Add click handler to done tasks' spent cells too, to reopen them (like with +0, 1).
|
|
<<task 1 1 0>> Beef up the time click handlers to handle leading + or -
|
|
<<task 1 1 0>> Add a double-click handler to the status cell that functions like typing 0 into the rem cell
|
|
<<tasksum end>>
|
|
<<<
|
|
If you'd rather have the summary at the top, just add {{{here}}} to the start call, ie {{{<<tasksum start here>>}}}.
|
|
<<<
|
|
<<tasksum start here>>
|
|
<<task 0.25 0.25 0.25>> Add tooltips to the various cells
|
|
<<task 1 0.75 0.75>> Figure out how to add auto-updating click handlers to the time cells
|
|
<<task 2 2 0>> Add simple click handlers to cur, spent, rem: just allow direct setting of values
|
|
<<tasksum end>>
|
|
<<<
|
|
You can nest these things if you like, just be sure to match starts and ends:
|
|
<<<
|
|
<<tasksum start here>>
|
|
* Time cell manipulation:<<tasksum start>>
|
|
<<task 1 0.75 0.75>> Figure out how to add auto-updating click handlers to the time cells
|
|
<<task 2 2 0>> Add simple click handlers to cur, spent, rem: just allow direct setting of values
|
|
<<task 1 1 0>> Beef up the time click handlers to allow entry of two values each: cur&spent, spent&rem. Add click handler to done tasks' spent cells too, to reopen them (like with +0, 1).
|
|
<<task 1 1 0>> Beef up the time click handlers to handle leading + or -
|
|
<<tasksum end "Cell manipulation:">>
|
|
<<br>>
|
|
* Double-click handling:<<tasksum start>>
|
|
<<task 1 3.5 2.5>> Add a double-click handler to the desc cell that opens the editor and selects the text
|
|
<<task 1 1 0>> Add a double-click handler to the status cell that functions like typing 0 into the rem cell
|
|
<<tasksum end "Double-clicks:">>
|
|
|
|
<<tasksum end>>
|
|
<<<
|
|
Finally, the simplest way to use tasksum is to add it to your view template. See TaskSummaryViewTemplate for an example template. Note that if no tasks are present between the start and end, nothing is displayed.
|
|
|
|
----
|
|
To continue, click the down-arrow and choose another section: <<tag TaskMacroTutorial>></pre>
|
|
</div>
|
|
<div title="5. Task macro installation issues" modifier="Ichthyostega" modified="200706260504" created="200604082243" tags="TaskMacroTutorial excludeMissing" server.type="file" server.host="file:///home/ct/.homepage/home.html" server.page.revision="200605132015" changecount="1">
|
|
<pre>The TaskMacroPlugin can be installed like any other TiddlyWiki plugin, and used without further effort. However, there are two issues that may affect you. (To get started with a brand new wiki that does not have these issues, consider downloading the [[empty LabWiki|empty_labwiki.html]].)
|
|
# The task macros don't play nicely with the default TiddlyWiki display of tags. In the default view template, a tiddler's list of tags is shown in a little box that floats in the upper right corner of the tiddler. However, this little box may interfere with the tables used by the task macros. In Firefox, the tables are drawn right over the top of the tag box, rendering both of them illegible. In Internet Explorer, the tag box forces the tables to be pushed down below the box, which can waste a lot of space.<<br>><<br>>Thus, I recommend changing your view template to eliminate the little box. If you use Simon Baird's [[TagglyTagging|http://simonbaird.com/mptw/#TagglyTagging]] (as LabWiki does), then my TaskSummaryViewTemplate might be a good alternative. Simply import it into your wiki and rename it to ViewTemplate. This template also demonstrates how to incorporate the tasksum macro into every tiddler so any tiddler with tasks has a summary at the top.<<br>><<br>>
|
|
# Most view templates also add a minus sign ("-") before the "close" command. TiddlyWiki interprets this to mean that you want the close command to be executed if you hit the Escape key from within the tiddler.<<br>><<br>>However, most tiddlers never have focus, and so never give you the opportunity to try it out. But if you have a taskadder in your tiddler, then you suddenly enable this feature -- and you probably don't want it. It means that if you type a nice long task description and then hit Escape, that description will be lost and the tiddler will be closed. So I recommend that you remove the minus sign from the view template's menu altogether, as I have done in LabWiki's own ViewTemplate.
|
|
|
|
----
|
|
This ends the tutorial. To go back to any previous section, click the down-arrow and choose it: <<tag TaskMacroTutorial>></pre>
|
|
</div>
|
|
<div title="Admin" modifier="CehTeh" modified="200706110324" created="200706080535" server.type="file" server.host="file:///home/ct/.homepage/home.html" server.page.revision="200706110324">
|
|
<pre>PageTemplate
|
|
|>|SiteTitle - SiteSubtitle|
|
|
|>|MainMenu|
|
|
|DefaultTiddlers<<br>><<br>><<br>>ViewTemplate<<br>><<br>>EditTemplate|SideBarOptions|
|
|
|~|OptionsPanel|
|
|
|~|SideBarTabs|
|
|
|~|AdvancedOptions|
|
|
|~|<<tiddler Configuration.SideBarTabs>>|
|
|
|
|
''StyleSheet:'' StyleSheetColors - StyleSheetLayout - StyleSheetPrint
|
|
|
|
ColorPalette
|
|
|
|
SiteUrl</pre>
|
|
</div>
|
|
<div title="ArchitectureOverview" modifier="Ichthyostega" modified="200810151608" created="200810151553" changecount="7">
|
|
<pre>This page intends to capture the lage picture regarding Lumiera's Architecture. This may be a moving target...
|
|
|
|
[img[Overview of Lumiera Architecture|draw/Lumi.Architecture-1.png][http://www.lumiera.org/gitweb?p=LUMIERA;f=doc/devel/draw/Lumi.Architecture-1.svg;hb=HEAD]]
|
|
|
|
//this drawing is maintained as SVG in GIT//
|
|
~~(click on the above image...)~~
|
|
|
|
!Description
|
|
* the Application has three Layers: [[Backend|backend.html]], [[Proc-Layer|renderengine.html]] and GUI
|
|
* the Application shall be completely functional without GUI ("headless", script-driven)
|
|
* all IO, media data fetching, processing and bookkeeping falls within the realm of the Backend
|
|
* all media object manipulation, deciding and configuration is the Proc Layer's job
|
|
* extensible by plugins on all levels, highly configurable, but not totally componentized (micro kernel) architecture
|
|
* strong separation between high-level and low-level areas of the Application
|
|
* the user/GUI manipulates a [[high-level model|renderengine.html#HighLevelModel]] whereas rendering is based on a corresponding [[low-level model|renderengine.html#OverviewRenderEngine]]
|
|
* stored Session (state) is comprised of high-level model, a collection of [[Assets|renderengine.html#Asset]] and accompaning configuration
|
|
* (possibly) several storage backends, abstracted out by a common interface
|
|
|
|
</pre>
|
|
</div>
|
|
<div title="AutoTools" modifier="Ichthyostega" modified="200805200610" created="200805200609" changecount="3">
|
|
<pre>* autotools 1.10 (as of 5/2008) &dash; Question: other versions usable too?
|
|
* the usual procedure, in short
|
|
{{{
|
|
autoreconf -i
|
|
automake
|
|
./configure --enable-alpha
|
|
make
|
|
make check
|
|
}}}
|
|
</pre>
|
|
</div>
|
|
<div title="BetterTimelineMacro" modifier="Saq" modified="200701030924" created="200607280926" tags="lewcidExtension systemConfig" server.type="file" server.host="file:///home/ct/.homepage/home.html" server.page.revision="200701030924">
|
|
<pre>/***
|
|
|Name|BetterTimelineMacro|
|
|
|Created by|SaqImtiaz|
|
|
|Location|http://tw.lewcid.org/#BetterTimelineMacro|
|
|
|Version|0.5 beta|
|
|
|Requires|~TW2.x|
|
|
!!!Description:
|
|
A replacement for the core timeline macro that offers more features:
|
|
*list tiddlers with only specfic tag
|
|
*exclude tiddlers with a particular tag
|
|
*limit entries to any number of days, for example one week
|
|
*specify a start date for the timeline, only tiddlers after that date will be listed.
|
|
|
|
!!!Installation:
|
|
Copy the contents of this tiddler to your TW, tag with systemConfig, save and reload your TW.
|
|
Edit the ViewTemplate to add the fullscreen command to the toolbar.
|
|
|
|
!!!Syntax:
|
|
{{{<<timeline better:true>>}}}
|
|
''the param better:true enables the advanced features, without it you will get the old timeline behaviour.''
|
|
|
|
additonal params:
|
|
(use only the ones you want)
|
|
{{{<<timeline better:true onlyTag:Tag1 excludeTag:Tag2 sortBy:modified/created firstDay:YYYYMMDD maxDays:7 maxEntries:30>>}}}
|
|
|
|
''explanation of syntax:''
|
|
onlyTag: only tiddlers with this tag will be listed. Default is to list all tiddlers.
|
|
excludeTag: tiddlers with this tag will not be listed.
|
|
sortBy: sort tiddlers by date modified or date created. Possible values are modified or created.
|
|
firstDay: useful for starting timeline from a specific date. Example: 20060701 for 1st of July, 2006
|
|
maxDays: limits timeline to include only tiddlers from the specified number of days. If you use a value of 7 for example, only tiddlers from the last 7 days will be listed.
|
|
maxEntries: limit the total number of entries in the timeline.
|
|
|
|
|
|
!!!History:
|
|
*28-07-06: ver 0.5 beta, first release
|
|
|
|
!!!Code
|
|
***/
|
|
//{{{
|
|
// Return the tiddlers as a sorted array
|
|
TiddlyWiki.prototype.getTiddlers = function(field,excludeTag,includeTag)
|
|
{
|
|
var results = [];
|
|
this.forEachTiddler(function(title,tiddler)
|
|
{
|
|
if(excludeTag == undefined || tiddler.tags.find(excludeTag) == null)
|
|
if(includeTag == undefined || tiddler.tags.find(includeTag)!=null)
|
|
results.push(tiddler);
|
|
});
|
|
if(field)
|
|
results.sort(function (a,b) {if(a[field] == b[field]) return(0); else return (a[field] < b[field]) ? -1 : +1; });
|
|
return results;
|
|
}
|
|
|
|
|
|
|
|
//this function by Udo
|
|
function getParam(params, name, defaultValue)
|
|
{
|
|
if (!params)
|
|
return defaultValue;
|
|
var p = params[0][name];
|
|
return p ? p[0] : defaultValue;
|
|
}
|
|
|
|
window.old_timeline_handler= config.macros.timeline.handler;
|
|
config.macros.timeline.handler = function(place,macroName,params,wikifier,paramString,tiddler)
|
|
{
|
|
var args = paramString.parseParams("list",null,true);
|
|
var betterMode = getParam(args, "better", "false");
|
|
if (betterMode == 'true')
|
|
{
|
|
var sortBy = getParam(args,"sortBy","modified");
|
|
var excludeTag = getParam(args,"excludeTag",undefined);
|
|
var includeTag = getParam(args,"onlyTag",undefined);
|
|
var tiddlers = store.getTiddlers(sortBy,excludeTag,includeTag);
|
|
var firstDayParam = getParam(args,"firstDay",undefined);
|
|
var firstDay = (firstDayParam!=undefined)? firstDayParam: "00010101";
|
|
var lastDay = "";
|
|
var field= sortBy;
|
|
var maxDaysParam = getParam(args,"maxDays",undefined);
|
|
var maxDays = (maxDaysParam!=undefined)? maxDaysParam*24*60*60*1000: (new Date()).getTime() ;
|
|
var maxEntries = getParam(args,"maxEntries",undefined);
|
|
var last = (maxEntries!=undefined) ? tiddlers.length-Math.min(tiddlers.length,parseInt(maxEntries)) : 0;
|
|
for(var t=tiddlers.length-1; t>=last; t--)
|
|
{
|
|
var tiddler = tiddlers[t];
|
|
var theDay = tiddler[field].convertToLocalYYYYMMDDHHMM().substr(0,8);
|
|
if ((theDay>=firstDay)&& (tiddler[field].getTime()> (new Date()).getTime() - maxDays))
|
|
{
|
|
if(theDay != lastDay)
|
|
{
|
|
var theDateList = document.createElement("ul");
|
|
place.appendChild(theDateList);
|
|
createTiddlyElement(theDateList,"li",null,"listTitle",tiddler[field].formatString(this.dateFormat));
|
|
lastDay = theDay;
|
|
}
|
|
var theDateListItem = createTiddlyElement(theDateList,"li",null,"listLink",null);
|
|
theDateListItem.appendChild(createTiddlyLink(place,tiddler.title,true));
|
|
}
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
window.old_timeline_handler.apply(this,arguments);
|
|
}
|
|
}
|
|
//}}}</pre>
|
|
</div>
|
|
<div title="BuildDependenceis" modifier="Ichthyostega" modified="200904192357" created="200708120103" tags="organization buildsys" changecount="22">
|
|
<pre>for __Building__
|
|
* gcc (4.1), glibc6 (2.3), libstdc++6 (4.1)
|
|
* [[build system|BuildSystem]] dependencies: SCons (0.96.90), Python (2.4), pkg-config
|
|
* [[GAVL|http://gmerlin.sourceforge.net/gavl.html]] (1.0.0)
|
|
* NoBug for Logging, Tracing, Asserting (can be obtained from [[Pipapo.org|http://www.pipapo.org/pipawiki/NoBug]])
|
|
* ~NoBug needs [[valgrind|Valgrind]] (3.2), execinfo.h and libpthread (&rarr; glibc)
|
|
* std::tr1 &mdash; esp. for the former BOOST::shared_ptr (which is now proposed standard)
|
|
* BOOST ~~(listed below are the DEBIAN package names)~~
|
|
** libboost-dev (>=1.34.1-2)
|
|
** libboost-program-options-dev (>=1.34.1-2)
|
|
** libboost-program-options1.34.1 (>=1.34.1-2) ''NOTE: binary dependency''
|
|
** libboost-regex-dev (>=1.34.1-2)
|
|
** libboost-regex1.34.1 (>=1.34.1-2) ''binary..''
|
|
* for the GUI: gtkmm-2.4 gdl-1.0 libglibmm-2.4 cairomm-1.0 xv
|
|
** libgtkmm-2.4-dev (>=2.8)
|
|
** libcairomm-1.0-dev (>=0.6.0)
|
|
** libgdl-lum-dev or libgdl-1-dev (>=2.27.1)
|
|
*** libxml2-dev (>=2.6)
|
|
** libglibmm-2.4-dev (>=2.16), requiring glib2.0 (>=2.16) and gthread-2.0 (>=2.12.4)
|
|
** libxv-dev (>=1.0.2)
|
|
* for rendering the icons: librsvg-2.0
|
|
** librsvg2-dev (>= 2.18)
|
|
//usually, newer versions are OK//
|
|
|
|
boost 1.35 works too.
|
|
|
|
We use the GNOME Docking Library (GDL) within the Lumiera GTK GUI. As we actively participate in GDL development, we depend on a much more recent version, than most distos provide. We maintain a custom debian package (and source tree of GDL) which builds a {{{libgdl-lum.so}}}, in order to avoid side effects on other software. You may grab the tree including the Debian source package structure from [[our git|http://git.lumiera.org/gitweb?p=gdl-package;a=shortlog;h=refs/heads/debLumiera]] and create a binary Debian (or Ubuntu) package. For non-Debian systems, you may use the same build tree just in the standard way (configure, make, make install) to install into {{{/usr/local/lib/libgdl-lum.so}}}. Alternatively you may of course always just use a recent snapshot of GDL and build and install it as usual &mdash; but doing so may cause other software on your system to use this bleeding edge version of GDL too.
|
|
|
|
|
|
for __Running__</pre>
|
|
</div>
|
|
<div title="BuildSystem" modifier="Ichthyostega" modified="200708120101" created="200708051532" tags="organization buildsys" changecount="4">
|
|
<pre>July 2007 we agreed to try out several Build Systems in real world usage, to get a better feel on the maintenance costs of each.
|
|
* SCons
|
|
* AutoTools
|
|
|
|
!Used Functionality
|
|
* (re)building with reliable dependency checks
|
|
* environment checks ("configure")
|
|
* executing self-test suite
|
|
* provide central interface for setting switches and configuration options
|
|
* installing of some or all created artifacts</pre>
|
|
</div>
|
|
<div title="DefaultTiddlers" modifier="CehTeh" modified="200707111115" created="200706172308" changecount="3">
|
|
<pre>LumieraWiki
|
|
ShortCuts</pre>
|
|
</div>
|
|
<div title="DesignDocumentation" modifier="CehTeh" modified="200707030409" created="200706181207" tags="process policy" changecount="6">
|
|
<pre>* There is a [[Manifest]] explaining the vision of the Lumiera project
|
|
* The foundation how we work together is defined in LumieraDesignProcess
|
|
* There is a description how the git repository is set up in RepositorySetup
|
|
* we decided to write code in GNU style, with no tabs (use spaces)
|
|
</pre>
|
|
</div>
|
|
<div title="FullScreenPlugin" modifier="CehTeh" modified="200706110313" created="200607241016" tags="systemConfig lewcidExtension" server.type="file" server.host="file:///home/ct/.homepage/home.html" server.page.revision="200706110313">
|
|
<pre>/***
|
|
|Name|FullScreenPlugin|
|
|
|Created by|SaqImtiaz|
|
|
|Location|http://tw.lewcid.org/#FullScreenPlugin|
|
|
|Version|1.1|
|
|
|Requires|~TW2.x|
|
|
!Description:
|
|
Toggle between viewing tiddlers fullscreen and normally. Very handy for when you need more viewing space.
|
|
|
|
!Demo:
|
|
Click the ↕ button in the toolbar for this tiddler. Click it again to turn off fullscreen.
|
|
|
|
!Installation:
|
|
Copy the contents of this tiddler to your TW, tag with systemConfig, save and reload your TW.
|
|
Edit the ViewTemplate to add the fullscreen command to the toolbar.
|
|
|
|
!History:
|
|
*25-07-06: ver 1.1
|
|
*20-07-06: ver 1.0
|
|
|
|
!Code
|
|
***/
|
|
//{{{
|
|
var lewcidFullScreen = false;
|
|
|
|
config.commands.fullscreen =
|
|
{
|
|
text:" ↕ ",
|
|
tooltip:"Fullscreen mode"
|
|
};
|
|
|
|
config.commands.fullscreen.handler = function (event,src,title)
|
|
{
|
|
if (lewcidFullScreen == false)
|
|
{
|
|
lewcidFullScreen = true;
|
|
setStylesheet('#sidebar, .header, #mainMenu{display:none;} #displayArea{margin:0em 0 0 0 !important;}',"lewcidFullScreenStyle");
|
|
}
|
|
else
|
|
{
|
|
lewcidFullScreen = false;
|
|
setStylesheet(' ',"lewcidFullScreenStyle");
|
|
}
|
|
}
|
|
|
|
config.macros.fullscreen={};
|
|
config.macros.fullscreen.handler = function(place,macroName,params,wikifier,paramString,tiddler)
|
|
{
|
|
var label = params[0]||" ↕ ";
|
|
var tooltip = params[1]||"Fullscreen mode";
|
|
createTiddlyButton(place,label,tooltip,config.commands.fullscreen.handler);
|
|
}
|
|
|
|
var lewcid_fullscreen_closeTiddler = Story.prototype.closeTiddler;
|
|
Story.prototype.closeTiddler =function(title,animate,slowly)
|
|
{
|
|
lewcid_fullscreen_closeTiddler.apply(this,arguments);
|
|
if (story.isEmpty() && lewcidFullScreen == true)
|
|
config.commands.fullscreen.handler();
|
|
}
|
|
|
|
|
|
Slider.prototype.lewcidStop = Slider.prototype.stop;
|
|
Slider.prototype.stop = function()
|
|
{
|
|
this.lewcidStop();
|
|
if (story.isEmpty() && lewcidFullScreen == true)
|
|
config.commands.fullscreen.handler();
|
|
}
|
|
//}}}</pre>
|
|
</div>
|
|
<div title="GitAliases" modifier="MichaelPloujnikov" modified="200706270309" created="200706181050" tags="git organization" changecount="5">
|
|
<pre>to make the admin/git_hooks/post-commit working add following to your .gitconfig:
|
|
{{{
|
|
[alias]
|
|
sign = tag -s -f -m 'automatic generated on last commit'
|
|
publish = push --all public
|
|
}}}
|
|
|
|
these two commands are used by 'admin/git-hooks/post-commit'
|
|
|
|
'git sign' creates a gpg-signed tag after each commit, named '$~BRANCH_signature' overriding an older tag of the same name. Thus the head revision is always gpg signed (it is not perfect, in some cases like some merges and other things the signature can become unsynced and needs to be fixed manually).
|
|
|
|
'git publish' just sends the commit to some repository which has to be registered with 'git remote add public ...', in case you are working offline this will stuck and timeout, you may break it with ctrl-c, someone may fix it.</pre>
|
|
</div>
|
|
<div title="GitBranches" modifier="Ichthyostega" modified="200708120100" created="200706260447" tags="overview git organization" changecount="13">
|
|
<pre>some ''interesting Branches''
|
|
|
|
|![[pipapo.org|PipapoOrg]] |!''mirrored'' |!|!description |
|
|
| ct#master | ichthyo#master | |Lumiera main development line |
|
|
| ichthyo#scons | | |[[SCons]]-based build system, improvements|
|
|
|
|
</pre>
|
|
</div>
|
|
<div title="GitNotes" modifier="MichaelPloujnikov" modified="200706270308" created="200706181049" tags="note git" changecount="4">
|
|
<pre>I use some GitAliases to make signing and publishing easier.
|
|
|
|
the '.git' dir itself is not versioned/distributed since it usually contains site-specific things. Despite this we might want to distribute some maintenance scripts and hooks so I put the default hooks into admin/git_hooks/ and users can symlink from .git/hooks them when needed.
|
|
|
|
For now I hope this approach suffices, maybe we need admin/git_hooks/$HOOKNAME.$USER at some point when it turns out that people want personal hooks.
|
|
|
|
&rarr; see [[Interesting Branches|GitBranches]]
|
|
</pre>
|
|
</div>
|
|
<div title="Howto download the Lumiera sources and deliver changes" modifier="SimAV" modified="200707161757" created="200707152057" changecount="7">
|
|
<pre>This part should explain what you have to do in order to download the sources of Lumiera from pipapo.org. It treats as well how to deliver improvements to cin3 using git. Git is a tool similar to cvs or svn.
|
|
|
|
The cin3 sources are stored in a git repository. Maybe you have never heard of git before, but i can allay your fears: using git isn't that complicated. To download cin3 the very first time you simply have to clone a git-repo from pipapo.org. To do so just type the following in a shell:
|
|
!!!Code
|
|
//{{{
|
|
git clone git://git.pipapo.org/lumiera/ct YOURCOPY'sNAME
|
|
//}}}
|
|
|
|
This will create a directory named YOURCOPY'sNAME which contains the whole data of the lumiera/ct branch of Lumiera. After having downloaded a cin3-git-repository you can update it by simply typing:
|
|
!!!Code
|
|
//{{{
|
|
cd /your/path/YOURCOPY'sNAME
|
|
git pull
|
|
//}}}
|
|
|
|
If everything went well your copy is now up to date. Pulling is faster than cloning it again and causes less traffic at the server.
|
|
|
|
!!!Tips:
|
|
* NEVER delete a git repository without a permission of a pro.
|
|
* Check the url.
|
|
* Install git before calling git
|
|
|
|
Now you could compile the source code or improve Lumiera or the documentation. After having done so (let's say you have written a patch) you can deliver your changes by:
|
|
* at first setting your name and email
|
|
* committing your changes
|
|
* pushing your local git-repo to a public server
|
|
|
|
!!!Code
|
|
//{{{
|
|
git config --global user.name "YOUR REALNAME"
|
|
git config --global user.email ~YOUR-E@MAIL.ADRESS
|
|
git commit -m 'YOUR DESCRIPTION' -- FILE/TO/COMMIT
|
|
git push git://git.pipapo.org/lumiera/mob
|
|
//}}}
|
|
|
|
lumiera/mob is an anonymous account at pipapo.org where everyone can commit changes. </pre>
|
|
</div>
|
|
<div title="IRC-Transcripts" modifier="Ichthyostega" modified="200810151611" created="200708120209" tags="discuss irclog" changecount="12">
|
|
<pre>We keep a protocol or short summary of each important discussion. The summaries of the monthly developer meetings are posted to the Mailinglist and can be found on pipapo.org too
|
|
|
|
* [[10-08 developer meeting 10.Oct.2008|IRC_2008-10-10]]
|
|
* [[07-08 developer meeting 6.Jul.2008|IRC_2008-07-06]]
|
|
* [[06-08 developer meeting 5.Jun.2008|IRC_2008-06-05]]
|
|
* [[05-08 developer meeting 8.May.2008|IRC_2008-05-08]]
|
|
* [[04-08 developer meeting 3.Apr.2008|IRC_2008-04-03]]
|
|
* [[03-08 developer meeting 6.Mar.2008|IRC_2008-03-06]]
|
|
* [[1.official developer meeting 1.Feb.2008|IRC_2008-02-01]]
|
|
* [[informal developer meeting 10.Aug.2007|IRC_2007-08-10]]
|
|
|
|
!talks about specific topics
|
|
* [[buffer allocation for render nodes (6/08)|IRC_log_BufferAllocation_2008-06]]
|
|
</pre>
|
|
</div>
|
|
<div title="IRC_2007-08-10" modifier="Ichthyostega" modified="200810140236" created="200802021815" tags="irclog" changecount="2">
|
|
<pre>!10/11 aug 2007
|
|
* maybe let the render graph builder generate a meta language which then is ''jit compiled'' for each configuration
|
|
* using smart pointers and factories for objects ''and avoid unprotected use of {{{new}}} and {{{delete}}}'', if this wont work because of cycles, we might investigate specialized garbage collectors for specific cases.
|
|
* format for frames would be likely ffmpeg or such first, finally we see what suits best. We have to provide coverter nodes to convert frame formats for accessing different libraries anyway (ffmpeg, v4l, gstreamer, ...)
|
|
* we need a pool of worker threads and associated ~APIs
|
|
* accessing frames has a time (get until..), ''unique frame identifier'' (see below), policies (what to do when out of time, quality required,..) and hints (recursive dependency, must cache, playback speed and direction, ...)
|
|
* for each sequence (configuration) each node has a number (monotonic incrementing), a generation counter (increment on each parameter change), a propagation sum (from parent nodes)
|
|
* frames are identified by their time(frame number) and node number plus generation number and propagation sum. This allows easily to find out when a frame has to be rerendered
|
|
* no difference between compositor and viewer
|
|
** viewer is just a decoder where a display window attaches
|
|
** one can have multiple of such display windows
|
|
** tracks, effects, (things which are nodes in the render graph) can add gui components to the viewer, like masking tools, panning, overlay and other compositor things.
|
|
** in the render graph we have ''attachment points'' i.e. ~ExitNode-instances. Display and other output can only be pulled from such ~ExitNodes. Changing just the display or attaching it to another ~ExitNode doesn't count as change of the render graph, while reordering or reconfiguring the ~ExitNodes themselves of course //is// a reconfiguration.
|
|
* tracks are just containers for other nodes
|
|
** they serve a GUI representation (timeline, patchbay, viewer)
|
|
** they do the mixing of contained things
|
|
** can be recursive, the GUI represents basically a tree
|
|
** we need some 'wiring' abstraction for the GUI to make it a real graph
|
|
* rendering frames, context between frames
|
|
** the proc layer ''only queries frames'' (by identifier and timeout) the backend tries to serve the best it can do (from cache or let them render)
|
|
** each render job carries some ''quality limit'' (as S/N ratio) when previewing or scratching through the project this is used to generate reasonable quality previews
|
|
** individual processing nodes can use additional state for their calculations...
|
|
*** the node objects themselves should stay stateless, i.e. they shouldn't store state internally.
|
|
*** they can use special ''context frames'', which are provided and managed by the backend (as opaque data blocks).
|
|
*** they can depend on previous state, i.e request from the backend a previous context frame, the same way as they can request previous media frames from the bakend, but there is no guarantee that the backend will satisfy this request.
|
|
* on the question who decides what to do after a cache miss, we tend to put the decision into the render node (because this seems to be the simpler approach), but still have to work out the details.
|
|
</pre>
|
|
</div>
|
|
<div title="IRC_2008-02-01" modifier="Ichthyostega" modified="200802031846" created="200802021821" tags="irclog" changecount="28">
|
|
<pre>! 1. feb.2008 on #openvideo
|
|
21:00 -23:30 GMT. __Participants__:
|
|
* hermanr
|
|
* cehteh
|
|
* ichthyo
|
|
* Dasypus
|
|
* gmerlin
|
|
* ~SimAV
|
|
* pippin
|
|
* Plough
|
|
* Plouj
|
|
* Velmont
|
|
|
|
!! Discuss the open points in http://www.pipapo.org/pipawiki/Lumiera/DesignProcess &mdash; do we need this formalism?
|
|
At start of the project last summer, Cehteh made a [[design process proposal|http://www.pipapo.org/pipawiki/Lumiera/DesignProcess]]. We will keeping this up, not for every implementation detail, but for major plans, wishes and design decisions. One point in the agenda of future meetings will be to work through proposals in the queue
|
|
* proposals in the "idea" state are not complete, can be just brainstorming or need further discussion. Comments please to the proposal page.
|
|
* proposals in the "draft" state are ready for conclusive discussion and will be treated in one of the next meetings
|
|
* "final" proposals are either "accepted" or "dropped". We don't differentiate the latter, but should write a short note why it was dropped.
|
|
* if there is need for more or finer grained categories, we'll extend the page and the template as needed or provide different views
|
|
|
|
!! The development model
|
|
We employ a distributed model based on GIT. We want this repository to be as complete as possible, including documentation in embedded ~TiddlyWikis and Bug reports. Each dev has its own GIT repo, devs are pulling from each other, they are free to cherry pick and try to make the combined version work. Point is that everyone can clone the git, negotiate with the others what s(he) wants to do, and hack on. Every dev signs off his branch with an standardized signature. For small changes we provide a "Mob GIT", i.e. anonymously pushable git (which is untrusted of course). Cehteh is currently working on a git web frontend which makes the codebase in the mob-repo web-editable like a wiki.
|
|
Will we need a stable version or an official branch? not yet &mdash; as long as the team is small it will work more painless without. At some point, when the project is more mature, we will define an official branch. Later on we will have automated builds and regression test runs. As we do test-driven development anyways, it's just a question of someone setting up all the infrastructure, then we'll do it.
|
|
Ichthyo proposes a new requirement: All devs should ensure the "master" branch of their respective repositories always passes the compiler and the test suite. ~Work-In-Progress should be done on branches. Rationale: it is sufficient to pull from the master branches, and you can be sure the version you pulled worked for the originator.
|
|
A note on dependencies: it will be hard to target minimal dependencies for such a project, but we shall try not to bloat it unnecessarily. Sometimes it can be sensible to rather re-invent a feature &mdash; esp. when it fits into the core focus of the project &mdash; instead of depending on difficult to build and not sufficiently maintained external projects. But we should avoid reinventing things like GUI toolkits.
|
|
And, pretty much obvious, we try to stick to modern programming standards. Read: modules have interfaces, interfaces need some (minimal) documentation, and it is not allowed to bypass the interfaces and tangle everything in a wild fashion.
|
|
Currently, the project can be separated into three layers, which could evolve into sub-projects: Backend, ~Proc-Layer, GUI. For each part, the dev most deeply involved and most knowledgeable will take on the sometimes necessary leadership and have the last word in case of quarrels. Currently, Cehteh cares for the Backend and Ichthyo headed for the ~Proc-Layer. We have postponed any work on the GUI for now and don't participate in GUI toolkit discussions. If there is a dev willing to care for the GUI, collect proposals, care for usability and the users needs and finally code it up, then he will the one to decide what toolkit to use.
|
|
We plan to make the discussion about GPL v3 a point on the agenda of the next meeting.
|
|
|
|
!! Monthly meetings
|
|
* make it thursday, not friday
|
|
* time for now 21:00 GMT &mdash; if some (potential) participants have problems with this time, please speak up (maybe alternating times?)
|
|
* write a short status report for each mayor part //prior// to the meeting (saves us time). Maybe add an TODO list there
|
|
* go through the open issues for the design process drafts
|
|
* publish a protocol of each meeting on the (~Cinelerra-CV, ~LibOpenvideo) Mailinglists, in the TiddlyWiki and on pipapo.org
|
|
* News, Protocols and the agenda of the next meeting can be found at the [[pipawiki-page|http://www.pipapo.org/pipawiki/Lumiera/MonthlyMeetings]]
|
|
* next meeting on first Thursday in March (6.3.2008)
|
|
|
|
!! Who works on what, what are the short term goals, what tasks are open?
|
|
''Ichthyo'' works on the processing layer. Current goal is to get the core of the builder fleshed out. Next goal is to create a clip object (dummy), add it to the EDL, hand the EDL over to the builder and let the builder make the first (preliminary) render nodes. (note: left many details for later).
|
|
Ichthyo started coding his design draft and things seem to work out as intended. Some Keywords: Have a high-level model and a low level model. The former is comprised of the objects in the Session edited by the user, the latter is a network of completely configured render nodes, employing the same pull model as in Cinelerra-2. In between sits the Builder, translating high-level into low-level. This translation is done on demand (not for every frame).
|
|
Current state in this part is: basic asset manager is done, asset objects (forming a hierarchy) can be created and will be registered automatically, it is possible to create a clip-"~MediaObject" from a media asset (without caring for any details regarding multichannel clips). Some support lib components are written, Session and data holders start up on demand and shutdown cleanly. The test suite is the only interesting executable, and this will remain so for quite some time. Currently writing the first parts of the Builder.
|
|
Further plans/ideas: Ichthyo is rather determined to embed a Prolog interpreter (YAP Prolog) to handle all sorts of configuration queries in a rule-driven fashion. Things Ichthyo can't do in the near future: caring for session loading/saving serialisation plus storage backends, caring for a DB based implementation of the asset manager and integration with production support software, target the scheduler which will receive any edit operations initiated from the GUI.
|
|
|
|
''Cehteh'' is currently working on webgit, which is somewhat related inasmuch it will make small contributions to the mob repository much simpler. Previously he started with some foundation and support facilities. He plans to come back to the Backend implementation in about two weeks. The Backend is intended to handle all media (and even meta-)data as generalized frames. The render nodes network created by the ~Proc-Layer is completely stateless and all data is served from below. While it will be possible to address and access individual data within a frame (e.g. audio samples), frames are the smallest unit for memory and cache management. No plans to use a tiled memory model or to support frames larger than aprox. 20-40% of the available RAM.
|
|
Cehteh's design plan includes a scheduler to organize the access to the raw data, monitor the timings and prefetch data as needed. This scheduler will be configurable via quality preferences ("need realtime", "need perfect quality"). Further, there will be an elaborate caching scheme trying hard to avoid re-rendering any frames already calculated previously. Temporary data will be backed by files and thus swapped out &mdash; this swapout and size of temporary data is to be monitored and adjusted according to the current load &mdash; and all temporary data is kept as most-recent-used cache discipline. Incoming and outgoing footage shall mostly be handled by using mmaped buffers. The rationale is to avoid unnecessary copy from kernel to user space and wasting memory for an additional in-kernel buffer. Writing via a mmapped buffer is little more tricky; there will be a in-place writing which is used for indices and other precalculated data which needs updates, and the processing layer can query write buffers which are actually a small cache/ring and then comited to the file. Basically, mmapping is a clean solution if you can design for it, and it's portable (posix)
|
|
Things to do: object serialisation backend is sometime on Cehteh's schedule, but that's ahead and if someone else helps or takes over it would be OK. Even more true for a DB based backend for the asset manager.
|
|
|
|
''Gmerlin'' plans to implement grayscale support for GAVL, so the upper layers can store arbitrary data in it.
|
|
|
|
__about multithreading__: since the render nodes are stateless they can be driven in multiple threads (but inter frame dependencies need to be resolved/serialized). Mostly the backend manages threads and does that quite conservatively (compared to Cinelerra-2 which massively creates separate threads for small tasks). Any edit operations initiated from GUI go to a scheduler in the middle layer, which enqueues and effectively serializes operations done to the "media objects" in the high-level model. The editing operations themselves are //not threadsafe // by design, they rely on being scheduled correctly. The builder is triggered from this ~Proc-Layer scheduler and starts in one separate thread, and when done, we swap whole parts of the render nodes network and then the backend can re(start) rendering as needed.
|
|
|
|
!!The naming discussion
|
|
The discussion looks healthy so far... People can add new proposals on the [[pipawiki|http://www.pipapo.org/pipawiki/Lumiera/Names]]. intersting names are still coming in, so we should just let the name-choosing game go on for a while. And, btw, we //can// depart from beeing similar to "Cinelerra" ;-)
|
|
Let's say, we need a person volonteering to guide/moderate the selection, going over the list and scratching inammprobiate ones. Criteria for good names being:
|
|
* should not be an existing project
|
|
* should be "googleable"
|
|
* should not be offensive
|
|
* should have one of the free top level domains (.net, .org)
|
|
* should be compatible with educational institutions (sorry, no pr0nedit :)
|
|
* should not obviously collide with trade marks
|
|
</pre>
|
|
</div>
|
|
<div title="IRC_2008-03-06" modifier="Ichthyostega" modified="200804120331" created="200804120326" tags="irclog excludeMissing" changecount="3">
|
|
<pre>! 6. mar.2008 on #openvideo
|
|
21:00 - 23:30 GMT, __Participants__:
|
|
* hermanr
|
|
* cehteh
|
|
* ichthyo
|
|
* Plouj
|
|
* SimAV
|
|
* akirad
|
|
* _MMA_
|
|
* rgareus
|
|
* ddennedy
|
|
* edrz
|
|
* anewcomb
|
|
* gmerlin
|
|
* oracle2025
|
|
* gisle
|
|
|
|
! Boilerplate
|
|
!! Organization of this meeting
|
|
* cehteh writes the protocol
|
|
* hermanr does chairman
|
|
|
|
!! Leftovers from last meeting
|
|
We concluded there are no leftovers
|
|
|
|
! Go through Ideas and Drafts in design process
|
|
|
|
!! Idea: time_handling
|
|
http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/time_handling
|
|
|
|
Point 1 is superseded by using gavl.
|
|
|
|
Points 2 and 3 are still valid.
|
|
|
|
''Ichthyo'' asked gmerlin if there are any problems according gavl for the points 2 (position of frames) and 3 (position for keyframes and automation). Gmerlin acknowledges that he doesnt see any problems.
|
|
|
|
''Oracle2025'' brings interlacing on topic "are you aware that automations and keyframes could/should also apply to fields?". We agree that this must be handled "in interlacing, a frame is a pair of 2 subsequent fields".
|
|
|
|
__Conclusion__:
|
|
Refactor the proposal according to the discussion and work it out, make it draft then. Discuss about it on the next meeting
|
|
|
|
!! Idea: Unit tests in Python
|
|
http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/UnitTests_Python
|
|
|
|
We have a testsuite based on cehtehs 'test.sh' which superseedes this proposal.
|
|
|
|
__Conclusion__:
|
|
Drop it.
|
|
|
|
!! Idea: Todo Lists
|
|
http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/TodoLists
|
|
|
|
This Idea is in a very early state an not yet mature.<br/>
|
|
''Cehteh'' explains: "I want something which doesn't need much human care and i want one big 'milestones' thing and a small 'mini-task' thing". Ichthyo refines this as "Roadmap" and "Near time task list". We agree that this shall not be too strict. There are some ideas floating, like adding this things to the testsuite or use the wiki. Ichthyo shows how he uses the tiddlywiki's task macro ([[renderengine.html#PlanningNodeCreatorTool]]). He likes it but doubts its usefulness when it is used without guessing the hours/days of work.
|
|
|
|
__Conclusion__:
|
|
We use the Tiddlywiki task macro thing for now.
|
|
|
|
!! Draft: CCodingStyleGuide
|
|
http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/CCodingStyleGuide
|
|
|
|
Ichthyo tells that the discussion on the wiki page made this clear now. Cehteh explains that he uses this style with success for diffrent projects. We make clear that this is meant for C, in C++ we use namespaces. Overall we agree that code shall be self-documenting.
|
|
|
|
__Conclusion__:
|
|
Make it final.
|
|
|
|
!! Draft: DevelopmentFramework
|
|
http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/DevelopmentFramework
|
|
|
|
Cehteh explains that he will transfer this propoal to a tiddlywiki covering compatibility guides and dependencies. We conclude that this wiki must reflect the actual practice (NoBug, Doxygen, test.sh) despite the proposal is not concrete yet.
|
|
|
|
A short discussion about build systems came up, we still use autotools and scons in parallel, delaying the decision later. oracle2025 mentioned that scons could be used for development and autotools for release. No decision about that everyone has different opinions. But we agree that it works as is.
|
|
|
|
__Conclusion__:
|
|
Cehteh will make the proposed wiki which shall be maintained to reflect the state and this topic will be finalized by that.
|
|
|
|
!! Draft: Skills Collection
|
|
http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/SkillsCollection
|
|
|
|
This might be only useful if there are more developers working on the project.
|
|
|
|
__Conclusion__:
|
|
Leave in draft state for now.
|
|
|
|
!! Draft: Architecture Overview
|
|
http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/ArchitectureOverview
|
|
|
|
Ichthyo drawn a diagram showing the planned architecture. Cehteh raises concerns about codecs/plugins/effects in backend. After that there was some discussion about details. Cehteh suggests to place plugins in a extra box, gmerlin suggests that 'plugins' don't fit into the diagram, there should be "filters", "sources",..; Followed by some more discussion, showing that we basically agree and understand the design but the drawing needs some refinements.
|
|
|
|
__Conclusion__:
|
|
Good idea, needs some refinements, work in progress.
|
|
|
|
|
|
! Call for Design
|
|
|
|
Ichthyo explains that he wants the overall design a bit more formalized. He put this topic on the agenda to remind that we have to work it out in DesignProcess and already started to make some design proposals.
|
|
|
|
__Conclusion__:
|
|
Things need to be worked out in DesignProcess, take a look and review it.
|
|
|
|
! Naming
|
|
|
|
Raffa, Velmont, goibhniu and others collected and managed proposed names past weeks which finally ended in a community voting. Results are at http://www.cs.cornell.edu/w8/~andru/cgi-perl/civs/results.pl?id=E_9fad0d1d10c23d38
|
|
''Lumiera'' won, Lumiera.org is free and no one of in this meeting has objections against this name. Velmont offers to register and pay for the lumiera.org domain which will be hosted on our own server (see topic below). Hermanr raises concerns if it is ok when the name is registered on another site and by another person than the server, cehteh explains that he like this distribution where doable and no one other objects. Ichthyo asks about a short name for Lumiera which will be used for C++ namespaces and such kinds. After a short discussion we agree that we use the full name and no abbreviation. We now have to rename the source and the wiki. Anyone renames the sourcecode where he is responsible for. Cehteh will go over the pipapo.org wiki and rename things.
|
|
|
|
Finally we express our great thanks to the people who put the efforts into the name selection, thanks raffa, Velmont, goibhniu & co.
|
|
|
|
__Conclusion__:
|
|
''Projectname is Lumiera'', we have a lot things to rename.
|
|
|
|
! Project Server, setup, organization, administration
|
|
Some people gathered together and rented a server at 'hetzner.de' which will host some free project pages and personal sites. Cehteh is the one who signed for the server and officially respobsible for it.
|
|
|
|
The server is split into isolated 'vservers' which are created as needed. Idea is to work cooperatively to get the best out of its resources.
|
|
|
|
For our projects (cinelerra.org and lumiera.org) we now need volunteers who help setting it up and administrating things. Velmont offered to help with lumiera.org, hermanr takes care of cinelerra.org, raffa will help with maintaining the webpages. oracle2025 will care for developer chroots, build and test environments. cehteh will make a page on pipapo.org which reflects the current server setup http://www.pipapo.org/pipawiki/RootServerSetup . There are still a lot jobs to do!
|
|
|
|
Cehteh asked about how to manage emergency root access on the host/root server when he is unreachable. There where several suggestions between one root key for all who pay for the server to shared key schemes. We finally agreed that anyone who payed for the server can send a ssh key to ssh to be registered for emergency access.
|
|
|
|
The concrete server setup will be worked out next days. Ideas are one frontend proxy and a shared nameserver. A shared nameserver, A developer vserver shared between all developers. Maybe a shared mail server.
|
|
|
|
Hermanr asked about how to handle distribution of large media files. There was some discussion about bittorrent vs http. We concluded to work that out as needed.
|
|
|
|
In the forthcoming discussion about cehteh stresses that "it is a public server, if you place confidential information unencrypted on it, its you fault". Ssh keys shall be kept secret by the users but we can't enforce policies on those.
|
|
|
|
Ichthyo asks about how to setup lumiera.org (wiki?), oracle2025 suggests webgit, cehteh explains that webgit isn't ready yet but should be useable in a few days (pipapo.org will use that too). Velmont suggest a 'real' website for the time when non-developers want to use it. Git will be set up on lumiera.org the same way as it is currently set up on pipapo.org.
|
|
|
|
Hermanr asked Velmont about some help moving the bugs.cinelerra.org over, this might be little challenging since it needs an MTA and other things.
|
|
|
|
Ichthyo asks about keeping the Lumiera project pages on pipapo.org until the server is ready, this is ok.
|
|
|
|
__Conclusions__:
|
|
We have our own server which now needs volunteers for maintenance. The projects will slowly move there, until ready Lumiera stays on pipapo.org.
|
|
|
|
|
|
! GPL3 pros cons, license rationale
|
|
|
|
Ichthyo and cehteh would like to investigate a license change to GPLv3, neither of us has experience with problems this
|
|
might raise. Questions are if we lock us out from potential libraries which are GPLv2 only or lock out possible contributors because of unforeseen patent clauses. The others here thinking that "GPLv2 or later" would be most-compatible. Gmerlin tells that he uses some "GPLv2 only" mplayer code in gavl which is itself "GPLv2 or later". Cehteh explains that "GPLv2 only" code is a problem, where "GPLv2 or later" is not. Ichthyo raises concerns that the Support library may need to be LGPL, cehteh mentions that it would likely be enough if we only apply that to the plugin-loader. After all it turns out that there is a lot of confusion, misunderstanding and interpretation used with licenses and no one of us knows for sure. Finally we conclude that the interpretation and license enforcement is ruled by the copyright owner.
|
|
|
|
__Conclusion__:
|
|
Learn more about GPLv3, use GPLv2 or later and propose to switch to GPLv3 when we are ready to do public beta releases when possible.
|
|
|
|
|
|
! Next meeting
|
|
|
|
The next meeting will be at thuesday 3rd april 21:00GMT (if not rescheduled see below).
|
|
|
|
Ichthyo tells that Martin Ellison wrote he couldn't attend because of the time. So again we made a short discussion about changing/alternating timings to allow people in downunder/japan to attend. They have to speak up an make time suggestions.
|
|
|
|
Conclusion:
|
|
Next meeting 3rd april 21:00GMT. But Aussies, please speak up if you want the time changed!
|
|
</pre>
|
|
</div>
|
|
<div title="IRC_2008-04-03" modifier="Ichthyostega" modified="200805200559" created="200804120337" tags="irclog excludeMissing" changecount="2">
|
|
<pre>! 3. apr.2008 on #lumiera
|
|
21:00 - 23:30 GMT. __Participants__:
|
|
* cehteh
|
|
* gmerlin
|
|
* hermanr
|
|
* ichthyo
|
|
* joelholdsworth
|
|
* johncoswell
|
|
* rgareus
|
|
* sakalli
|
|
|
|
! Boilerplate
|
|
!! Organization of this meeting
|
|
* sakalli writes the protocol, ichthyo will help reviewing it
|
|
|
|
!! Recurring Topics
|
|
We concluded there are no leftovers and currently no Drafts from the design process to discuss
|
|
|
|
! Call for volunteers
|
|
(which tasks are to do, how can we interest people...?)
|
|
|
|
There was a sense that there are people willing to help but they might need direction or cannot do actual coding. But there is also a lot of tasks that could be done by beginners and non-programmers. These tasks are important and if someone who is not a programmer is willing to take them on that leaves more time for the programmers. Examples of such tasks:
|
|
* Protocol writing
|
|
* maintaining to do lists and isolating tasks
|
|
* constant code and documentation review
|
|
* unit/functional testing
|
|
* header file "task force" - some fundamentals discussed by the developers on libopenvideo should find their way into basic .h files
|
|
* installing and maintaining project tracking and automated builds/tests on the server
|
|
|
|
See http://www.lumiera.org/wiki/todo.html#Tasks
|
|
|
|
It was also noted that at current phase some basic development is still needed before we can accommodate a large number of coders doing small tasks and for now we need some subsystem owners. For GUI for example.
|
|
|
|
To make it easier for "beginners" to get aquainted with the program it was decided that one ''official Lumiera GIT repository'' should be established.
|
|
|
|
|
|
! Project announcements/registration
|
|
(freshmeat, gnu, etc...) any takers?
|
|
|
|
The discussion was about advertising the project on various sites. There were some concerns raised that it is too early to do too much publicity at the moment. That the right time should be shortly before the first public release. But there is also some value in registering to the project in planning/alpha stage to interest people such as prospective coders. It was noted that the [http://www.linux.com/feature/126441 article on linux.com] resulted in a lot of people contacting ichthyo and cehteh. [http://plot.bek.no/pipermail/piksel/2008-January/003328.html "I believe in Cinelerra"] by Leo Germani also generated a lot of traffic by developers. Some level of presence on mailing lists would be good although not too much just enough to indicate the project is going on.
|
|
|
|
__Conclusion__: volunteer needed to coordinate publicity (not overly urgent, but helpful)
|
|
|
|
|
|
! Informal talk about the GUI
|
|
|
|
Firstly, as SimAV was not able to be present during the meeting a proposal by him was relayed by Ichthyo: GUI and backend should be completely separated and communicate via pipes. It was agreed that the GUI should be detached but some higher level message protocol rather than bare pipes should be used. Some comments:
|
|
* cehteh standalone gui is a nice to have, but implementation details have to be worked out
|
|
* gmerlin Video playback can be separated in a separate X connection
|
|
* cehteh suggests to start with an conventional, attached gui and just keep it in mind to make it detachable later
|
|
* rgareus IMHO you want to share memory for the video-frame buffer beween the player and backend - with pipes you'll go the video-jack way.
|
|
|
|
''joelholdsworth'' is a new developer in the group and had showed interest in developing the GUI. he stated that he is interested in seeing a GUI that uses popular toolkits and that plays by the standards to create a consistent UI with the rest of the free desktop. For this reason he was advocating using GTKmm. There was no direct objections to GTKmm. Generally, there seems some preference for GTK. (Note this doesn't mean GNOME). Cehteh advocates the idea to use Lua-gtk, i.e. writing the GUI in a clean and lightweight scripting language.
|
|
|
|
Cario was suggested to be used for implementing the canvas in the timeline view.
|
|
|
|
|
|
|
|
The gui should provide a skeleton. Timeline and canvas should be controllable and extensible by plugins. Tracks can be nested. Use tiling windows and dockeable views and tools palettes. For example some configuration within session/renderpipeline may cause some pluggable elements to be added to the gui. A fader or a toggle/icon and so forth. Some plugins might render additional output (e.g. in previews). A video track renders thumbnails, automation curves on top.
|
|
|
|
Workflow is another important aspect to take into account in the design. A lot of information needs to come from editors and users in the design process. Different thoughts about the workflow:
|
|
* Should not make a predefined workflow. Just produce a tool that can be adapted to different workflows. It can be predefined, but should not be fixed.
|
|
* We dont have the resources to develop a "workflow" in the formal manner, we will go the "propose and comment" route.
|
|
* We should take the best ideas from popular competing products such as Final Cut Pro, AVID, Premiere plus After Effects.
|
|
|
|
Customisation is deemed important. Some points brought up in the discussion:
|
|
* sakalli: would be great if we could provide a fcp configuration and a avid configuration besides the default configuration as well. That could lure a lot of users quickly. On the other side, too much flexibility can be be a problem as well.
|
|
* cehteh: yes .. but such things are prolly costly to setup .. we need volunteers for anything optional
|
|
* Customization should be possible without recompile, but not too cheap.
|
|
* There should be a working skeleton or some fixed anchor but gui operations should be bound to a scripting language to achieve customization.
|
|
* The whole gui in a script with some performance critical widgets coded in C/C++
|
|
* Some parts should just be customizable, other parts should be kept fixed.
|
|
* cehteh suggested to start out by making a 'high level' description with no language/toolkit in mind .. what widgets do we need etc and after that to work on the skeleton mockup.
|
|
* cehteh / hermanr: Lumiera should allow to choose theme independently from desktop .. because what you have as your desktop-theme doesn't suit for video editing in many cases ... see ardour
|
|
|
|
ichthyo brings up the role of customization for the middle layer and gives an overview of his plans for the new participants. :
|
|
He had good experiences with a rule based aproach in various projects. He wants to embed a Prolog interpreter that can answer to "configuration queries". There is a "builder" component in the middle layer to derive the render nodes graph based on a "high level model", which is visible to the user (in the GUI) and based on these configuration queries.
|
|
|
|
Rationale for using prolog is: The rules are very readable because they rather represent facts and relations, not the way "how dings are done" but the way "how things are related". Example: how to configure some effects when the footage is interlaced. Additionally, we want to have some global swithces, which could control these rules, like "I want maximum quality", or "I want as much as possible set up automatically". The prolog rules are stored in the session and can be editd by advanced users. Of course, there is a set of basic rules. This aspect of customisation isn't exactly a GUI issue but it would have consequences for the GUI.
|
|
|
|
some discussion:
|
|
* joelholdsworth: so we just need a way of exposing properties. This is reasonably straightforward when all you want is value, colour, string etc.
|
|
* rules within the middle layer/session could bind to some properties exposed in the GUI
|
|
* gmerlin joelholdsworth: Agree, but point out that this can become difficult
|
|
* cehteh joelholdsworth: skeleton and plugins who attach into some gui areas, so you can add custom widgets
|
|
* ichthyo: also the ability to attach "tags" to various objects, so the rules can bind on those tags
|
|
* cehteh: maybe a standard set of widgets, not really completely custom ones (gmerlin agrees)
|
|
* joelholdsworth: probably you need to be able to do both well
|
|
* joelholdsworth in many apps the value/colour/string set works perfectly well, but in luminierra the controls will likely need to be much richer
|
|
|
|
Some brainstorming points about usability:
|
|
* We need a realy good bezier widget for all sorts of curves.
|
|
* Faders that can be grabbed everywhere are nice like like ardours and Blender faders. Or others which have no big knob
|
|
* The controls in blender's node view would be a good modal to copy (not advocating GL UI, just using widgets and concepts).
|
|
|
|
One extra point:
|
|
* we have agreed to make all of the big interfaces between the layers as plain C interfaces, because this is the most widely supported common denominator.
|
|
|
|
!!!! GUI CONCLUSION
|
|
* ''joelholdsworth'' is now the official GUI maintainer for Lumiera!
|
|
* sakalli, hermanr, ichthyo announced interest in contributing to discussions about GUI, workflows and usability. gmerlin noted that he knows some gtk secrets and is willing to help out here too.
|
|
|
|
|
|
! Froscon application
|
|
[http://www.froscon.org/ Froscon] is a small nice german open source exhibition that is very very technical oriented. Cehteh will be there as well as Ichthyo. Question is wether we should have a booth, perhaps together with some other interested media projects. Could ask Richard and the ffmpeg/mplayer people. End of call for papers is in june.
|
|
|
|
We made no decision about official presence but most likely there will be a developer meeting if nothing else.
|
|
|
|
|
|
! Timecode metadata discussion
|
|
This Discussion started out on the libopenvideo list: The question was wether we agree on one uniform format solution from decoder up to app level regarding timecode. And what this format would be: arithmetic or struct type. Regarding metadata (including type of timecode) the question is if we should work out a rather fixed data format, or go the route towards rather open description records.
|
|
|
|
__Conclusion__: Gmerlin does it the way it fits best for within the decoder, and Lumiera uses a more uniform time format for representing timecode in the higher app layers. Conversion functions will be concentrated in a library. Regarding metadata we will investigate further.
|
|
|
|
//A (shortended) digest of the timecode and metadata discussion is attached below//
|
|
|
|
! Next meeting
|
|
|
|
The next meeting will be at thursday 8th may 21:00GMT
|
|
|
|
-----------------------------
|
|
|
|
!!!! Timecode discussion
|
|
{{{
|
|
12:51 cehteh gmerlin: did you read my last mail about generalization of metadata?
|
|
12:51 cehteh key/value pairs
|
|
12:51 gmerlin not sure about that
|
|
12:51 cehteh i am pretty sure that i want that in lumiera
|
|
12:52 cehteh if gavl does that for us it would be even better
|
|
12:52 gmerlin first of all 2 different things:
|
|
12:52 gmerlin 1. arithmetic <-> struct
|
|
12:53 gmerlin 2. Generic <-> format specific
|
|
12:53 cehteh arithmetic for sure
|
|
12:53 gmerlin On the decoder API side, I want to export ideally only one type
|
|
12:54 gmerlin No no SMPTEXXX and ISO999908098
|
|
12:54 cehteh will that be attached to the frames in a intrusive way?
|
|
12:54 cehteh i rather leave the attaching up to the application
|
|
12:54 gmerlin intrusive?
|
|
12:55 cehteh struct frame { uint64_t timecode; } vs...
|
|
12:55 cehteh struct frame { struct metadata* something; }
|
|
12:55 cehteh or even vs something done at a api level
|
|
12:56 gmerlin struct lumiera_video_frame { gavl_video_frame_t * f; uint64_t timecode};
|
|
12:56 gmerlin Or add timecodes to gavl_video_frame_t
|
|
12:57 cehteh struct lumiera_video_frame { gavl_video_frame_t * f; struct metadata* timecode_n_stuff; }
|
|
12:57 ichthyo so I support a struct metadata*
|
|
12:58 cehteh ichthyo: timecodes might not be regular .. they should be optional, but anyways they dont cost when using an arithmetic type
|
|
12:58 cehteh i mean thats the purpose of timecodes .. to tag every frame and dont make assumptions that your footage is perfect
|
|
12:58 ichthyo but a struct metadata* would rather mean to keep it out of basic GAVL and have a libmetadata -- which may be integrated with GAVL -- right?
|
|
12:59 cehteh someome may have stolen a frame :P
|
|
12:59 cehteh thats gmerlins decision ...
|
|
12:59 gmerlin I'm against gavl integration of metadata
|
|
12:59 gmerlin gavl has a clear scope: Number crunching
|
|
01:00 cehteh gmerlin: you somehow have to pass it from the decoder to the application
|
|
01:01 cehteh i would prefer to introduce some sidechannel
|
|
01:01 gmerlin Yes, gmerlin_avdecoder will provide a separate function for getting the next timecode
|
|
01:01 gmerlin bgav_get_next_timecode()
|
|
01:01 cehteh gavl_get_frame (gavl_frame* place the frame here, metadata* place metadata there)
|
|
01:01 gmerlin or: bgav_timecode_from_pts()
|
|
01:03 gmerlin Some higher MXF profiles allow changing timecode parameneters in one stream
|
|
01:06 gmerlin It's sometimes impossible to separate demuxers and codecs
|
|
01:06 gmerlin better have them together in one lib
|
|
01:06 cehteh actually i would like to cache gavls internal states into the backend
|
|
01:08 gmerlin Ok, so timecodes are YYYYMMDDHHMMSSFF as int64_t
|
|
01:08 cehteh the indexing is something i prolly have some words about
|
|
01:09 cehteh timecodes are uint64_t as microseconds
|
|
01:09 cehteh well for lumiera :-P
|
|
01:10 cehteh YYYYMMDDHHMMSSFF as int64_t isnt that much better than a struct :P
|
|
01:11 ichthyo now, IMHO its mostly up to gmerlin to decide how it fits into GAVL
|
|
01:11 cehteh ack
|
|
01:11 gmerlin Not gavl
|
|
01:11 ichthyo gmerlin?
|
|
01:11 gmerlin gmerlin avdecoder yes.
|
|
01:11 cehteh in lumiera we will use usecs
|
|
01:11 ichthyo yes
|
|
01:12 ichthyo we will have a conversion function somewhere
|
|
01:12 gmerlin And will it include a calendar date?
|
|
01:12 cehteh doing it only once (avdecoder->usec) makes some sense
|
|
01:12 gmerlin usecs since when?
|
|
01:12 ichthyo either, we get directly usecs from avdecoder, if this fits in for gmerlin,
|
|
01:12 ichthyo or we'll get the format which works best for him and we do the conversion ourselves
|
|
01:12 cehteh defined elsewhere
|
|
01:12 cehteh reel-start or absolute time or whatever
|
|
01:13 ichthyo also, what sort of timecode this was based on (drop frame or not)
|
|
01:13 cehteh gmerlin: thats a important point .. just uint64_t does not suffice
|
|
01:13 cehteh it needs a tag describing what kind of timecode was used
|
|
01:14 cehteh no matter how you encode it
|
|
01:14 cehteh and iirc there are quite some timecodes
|
|
01:14 ichthyo because in this respect richard was right: we need to be able to reprocuce any value 1:1
|
|
01:14 cehteh yep
|
|
01:15 cehteh further i want to be able to convert between any kind of timecode in a fingersnip
|
|
01:15 gmerlin ichthyo: and that's impossible with usecs
|
|
01:15 cehteh gmerlin: its not
|
|
01:15 ichthyo with usecs alone: agreed
|
|
01:16 ichthyo with usecs + metadata it should be possible
|
|
01:16 ichthyo modulo some extreme cases (high speed cams, weeks of footage....)
|
|
01:16 cehteh yes .. you need framerate and other infos depending on the metadata
|
|
01:17 cehteh you need to be careful to do the math right so that inverse functions dont drift
|
|
01:17 gmerlin I'll export something lossless, which repduces MXF, DV and Quicktime timecodes losslessly
|
|
01:17 gmerlin You can then do what you want with them :)
|
|
01:17 cehteh thats why i would like to do it at only *one* place/library .. because its delicate and bugs are easier to spot/fix there
|
|
01:18 ichthyo and then there is some api to get at the additional metadata
|
|
01:18 cehteh yeah
|
|
01:18 ichthyo and beyond that: lets devise a libmetadata
|
|
01:18 cehteh just shove the data over .. YYYYMMDDHHMMSSFF as int64_t would be ok
|
|
01:18 gmerlin Ok.
|
|
01:18 cehteh we make a libmetadata (as part of our support lib)
|
|
01:19 cehteh somewhat independent so that it can be spun out
|
|
}}}
|
|
|
|
!!!! about Metadata
|
|
{{{
|
|
01:19 cehteh gmerlin: well .. how bout other metadata
|
|
01:19 cehteh your decoder needs to pass that too
|
|
01:20 gmerlin like?
|
|
01:20 gmerlin Author, Artist title...
|
|
01:20 cehteh some cameras encode shutter speed, focus, gain control, colour balance
|
|
01:20 cehteh and other things
|
|
01:20 gmerlin Hmmm
|
|
01:20 gmerlin I think MXF exports some of these
|
|
01:21 ichthyo wav files can have additional chunks; whats with flac?
|
|
01:21 gmerlin flac has vorbis metadata
|
|
01:21 ichthyo important for the more modern sound formats
|
|
01:21 cehteh dunno .. just thinkin about pro codecs and raw film metadata
|
|
01:21 ichthyo just wanting to point out: things to come here,
|
|
01:22 ichthyo e.g for sound: what stream is what channel
|
|
01:22 gmerlin Channel locations are handles by gavl
|
|
01:22 gmerlin If you have a multichannel stream
|
|
01:22 cehteh well .. note that there is per-asset metadata you want to pass .. and per frame metadata
|
|
01:22 cehteh maybe even some more undiscovered cases :)
|
|
01:23 cehteh did someone say this is easy??
|
|
01:23 sakalli did any of you watch the video regarding red workflow that i sent to the mailing list? redcode raw holds everyting, asa, wb, etc... hope lumiera will be able to facilitate that as well.
|
|
01:23 ichthyo at some point I want to be able to support ambisonics
|
|
01:24 ichthyo and maybe some day there will be wave field sysnthesis in more broad use
|
|
01:24 cehteh the codec in the back needs to pass us these things else we cantb handle it
|
|
01:24 gmerlin well, the easiest would be to extend bgav_metadata_t
|
|
01:24 ichthyo rationale is: just be open
|
|
01:24 cehteh gmerlin: maybe we need to investigate this things more, nothing needs to be decided now
|
|
01:24 ichthyo ack
|
|
01:25 cehteh see my key/value metadata proposal .. at some point maybe you make a complete sidechannel just for metadata
|
|
01:25 cehteh decoder stuffs that in on demand and it is passed along with its own api like the bgav_timecode_from_pts()
|
|
01:26 cehteh that way you dont need to touch it more than necessary
|
|
01:26 gmerlin shouldn't that key/value stuff be unified with plugin parameters?
|
|
01:27 cehteh for lumiera, maybe, maybe not
|
|
01:27 ichthyo you mean: you have a common api for describing "values" ?
|
|
01:27 cehteh some plugin parameters are determined by math functions
|
|
01:27 gmerlin You have a key, a type and a value
|
|
01:27 cehteh maybe for caching them
|
|
01:27 cehteh the api might be unified .. but the storage not
|
|
01:28 gmerlin why?
|
|
01:28 ichthyo because any block of data could be in the metadata
|
|
01:28 cehteh metadata which belongs to the frame coming from the decoder is const
|
|
01:28 cehteh plugin parameters are volatile
|
|
|
|
01:33 gmerlin One other point (but too late for it now) are audio timecodes. I'll adress that on libopenvideo
|
|
01:33 cehteh we will write a little more sophisticated timecode library
|
|
01:34 cehteh gmerlin: that should be unified :)
|
|
}}}
|
|
|
|
</pre>
|
|
</div>
|
|
<div title="IRC_2008-05-08" modifier="Ichthyostega" modified="200805200604" created="200805200600" tags="irclog excludeMissing" changecount="3">
|
|
<pre>! 8. May.2008 on #lumiera
|
|
__Participants__:
|
|
* cehteh
|
|
* joelholdsworth
|
|
* ichthyo
|
|
* raffa
|
|
* ~WesLappy
|
|
* gmerlin
|
|
|
|
! Boilerplate
|
|
!! Organization of this meeting
|
|
* cehteh writes the protocol
|
|
|
|
! Webpage-Infrastructure, Maintenance
|
|
|
|
Cehteh put this on topic because it's really urgent to bring up some infrastructure to manage the information we produce.
|
|
|
|
The Lumiera pages on pipapo.org were always meant as intermediary solution. Pipapo.org gets much spam on the moinmoin wiki and cehteh expresses that he wants to move pipapo.org to a new infrastructure based on asciidoc and git he created (see http://git.pipapo.org/uWiki.html). This system is barely useable and needs lots of work to be completed. It would be nice to use it for Lumiera too, if the others agree. Maintaining and extending (scripting) needs someone who knows shell scripting and doesn't need to be done by the core devs freeing their resources to work on Lumiera. Cehteh expresses that none of the people who proposed to help before showed up yet. ~WesLappy tells he might help (addendum not this week, because he is busy).
|
|
|
|
Next there was a suggestion by cehteh to convert the tiddlywikis to asciidoc. Ichthyo expresses that he likes the tiddlywikis, Joel mentions that they feel a little odd. Generally we all agree that they have some problems in sense of workflow and merging.
|
|
|
|
Ichthyo makes the suggestion to keep the tiddlywikis as scrapbook and build up 'official' documentation based on their content in whatever-we-use-then (asciidoc) documentation system. All agree on this approach.
|
|
|
|
Back to the new wiki, cehteh suggests to make stricter access rules to prevent spam: "There will be a group of 'Validated' people which following rules: only Validated people can edit general content and 'Validated' people can add new people to 'Validated' themselves". That means that we can have a lightweight self-administrating authentication where new people have to be introduced by someone who is already there.
|
|
|
|
Ichthyo suggests to send a reply to Serge G. who send an introduction to the cinelerra mailing list expressing that he would like to help.
|
|
|
|
Raffa will take care of content/design as much her time/knowledge permits.
|
|
|
|
__Conclusion__:
|
|
* We really need someone to help with the webpage scripting.
|
|
* Documentation needs to be well organized and moved over.
|
|
* Content of the pipapo.org moinmoin wiki should be moved over.
|
|
* The new website should be well organized with a nice looking frontpage
|
|
* All other documentation should be below that
|
|
|
|
-----
|
|
|
|
! Whats pending in DesignProcess
|
|
|
|
!! MistakestoAvoid
|
|
http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/MistakestoAvoid
|
|
|
|
rick_777 wrote a "MistakestoAvoid" page which explains some possible gotchas. We basically agree with most points there while we already decided to address some things differently than he suggested. One noteable difference is that we do not intent to provide a windows version of Lumiera, which was explained in serveral places. Cehteh added some comments to the page explaining some things.
|
|
|
|
|
|
-----
|
|
|
|
nothing more to discuss in 'Ideas', we go over to 'Drafts'
|
|
|
|
!! ArchitectureOverview
|
|
http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/ArchitectureOverview
|
|
|
|
Cehteh suggests to put that drawing under version control, as .fig. Ichthyo explains that it is already a .SVG and that he does not like .fig.
|
|
|
|
Conclusion: We agree to keep it as .SVG, add it to the repository and improve/complete it.
|
|
|
|
!! GitSubmoduleTransistion
|
|
http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/GitSubmoduleTransistion
|
|
|
|
Another suggestion made by cehteh is to make managing of subprojects within the sourcetree easier. Joel and ichthyo oppose that it is not really needed now and needs more understanding of git. Ichthyo suggests that the documentation might be separated into its own git, he further explains that the things are not settled yet and we don't know if we will some rearrangements and movements of files between modules.
|
|
|
|
Conclusion: We transform the documentation to a submodule and see how it works. Other things will be decided much later.
|
|
|
|
|
|
|
|
!! GlobalInitialization
|
|
http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/GlobalInitialization
|
|
|
|
This topic is discussed and agreed on the DesignProcess page already.
|
|
|
|
__Conclusion__: finalize it
|
|
|
|
!! MasterRepositorySetup
|
|
http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/MasterRepositorySetup
|
|
|
|
Setting up an master repository was decided on the last meeting. cehteh now set one up which also does some automatic, but intended fragile merging from subsystem maintainer branches.
|
|
# it updates automatically for the maintainers repo for conflict free fast-forwards
|
|
# it can always be overridden with explicit pushes
|
|
|
|
The others agree on the setup.
|
|
|
|
Ichthyo stresses that maintainers shall watch that their 'master' branch should compile cleanly and pass the testsuite always, test which are not operational should be tagged as PLANNED. We all agree...
|
|
|
|
Then a short discussion about building and synchronizing the docs follows. Problem is that docs build in maintainer branches are different for each branch, rsyncing them up to the server will always change a lot of things. We agree that the 'official' docs shall be build from the LUMIERA/master repository, preferably on the 'devel' vserver which has to be set up.
|
|
|
|
__Conclusions__: Make this final, setup build environment in the devel server and build docs there.
|
|
|
|
|
|
!! NoBugFlags
|
|
http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/NoBugFlags
|
|
|
|
Defining a debugging control hierarchy. This is work in progress and cehteh explains that he works it out and deploys it, this depends on the GlobalInitialization decided earlier.
|
|
|
|
__Conclusion__: accepted, finish and finalize it.
|
|
|
|
|
|
! Further Technical Discussion
|
|
|
|
Ichthyo asks how the GUI will be pulled up. Since he didn't attend IRC discussions recently he has no information yet what's going on. We explain him that we already made some discussions. Integrate the GUI into the build system probably linked as library, nothing finally decided yet. Communication will go over the plugin/interface facility (Plain C API). This things should be worked out and documented in DesignProcess.
|
|
|
|
Cehteh made a small tool {{{./admin/headercheck}}} which will gradually extended to proof that headers are sufficiently selfstanding.
|
|
|
|
|
|
! Progress
|
|
|
|
''Cehteh'' finished low level file handling and working in mmaping and frameprovider next. When thats finished, the finalization of the Plugin loader and interface definition things is the most urgent thing.
|
|
|
|
''Ichthyo'' works on the builder internals and next on some sort of "connection manager".
|
|
|
|
''Joel'' goes on with GUI pro9gramming and integrating it into the source tree next.
|
|
|
|
Gmerlin and cehteh discuss about how to handle the index files which avdecoder uses internally. cehteh would like to manage them in the Lumiera backend to, because filehandles are a precious resource. Gmerlin explains that this index files are just loaded and kept in memory. So this poses no problem for filehandle exhaustion. We will discuss this further via email.
|
|
|
|
Cehteh suggests that we should think about some kind of preferences/registry sometime next to store default configs.
|
|
|
|
Following a discussion about how messages are passed between GUI and core. Generally we will use the interfaces defined by the plugin system. Gmerlin says that he uses message queues in 'gmerlin', Joel requests that a lot of things should be done synchronous and he wants to avoid message queues. Cehteh suggests to use use the scheduler for GUI things too. For the parts where the GUI interacts with the high level proc model ichthyo and joel agree on working something (synchronous) out. Ichthyo stresses that the edit core is not threadsafe by design and relies on the backends scheduler. The underlying builder might sometimes to expensive for synchronous calls (ichthyo plans a rule system there) this needs to be worked out.
|
|
|
|
Ichthyo explains that the builder needs to detect cycles and check if the high level model is translateable into the low level model (in case plugins git removed and so on). Parts in the render graph which are not 'doable' should be flagged as erroneous but not dropped since one doesn't want to loose project information when loading a project on a machine with different installed plugins. In any case it should be possible that the GUI gets immediate synchronous feedback for such things.
|
|
|
|
|
|
! Next Meeting
|
|
|
|
Next meeting is on thursday 5th June 21:00 UTC
|
|
</pre>
|
|
</div>
|
|
<div title="IRC_2008-06-05" modifier="Ichthyostega" modified="200807072133" created="200807072132" tags="irclog excludeMissing" changecount="2">
|
|
<pre>! 5.June 2008 on #lumiera
|
|
21:00 -23:15 UTC. __Participants__:
|
|
* cehteh
|
|
* ichthyo
|
|
* joelholdsworth
|
|
* rcbarnes
|
|
* raffa
|
|
|
|
//Protocol written by ichthyo//
|
|
|
|
|
|
! Left over from the last meeting
|
|
//Nothing left over and no urgent topics.//
|
|
Seemingly, work is proceeding in all parts of the application.
|
|
|
|
! Discuss Ideas and Drafts in design process
|
|
//There are no new design proposals and no proposals that can be finalized.//
|
|
|
|
Ichthyo points out that he's about to work out the details of some of his proposals, which are currently in "idea" state. Following that, most of the meeting is spent on discussing the details of two of these proposals.
|
|
|
|
!!! Idea: Design the Render Nodes interface
|
|
[[Design of the render nodes interface|http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/DesignRenderNodesInterface]]
|
|
|
|
''Cehteh'' points out that, as we are in the pre-alpha phase, interfaces may be growing on-demand. Later on, interface versions will be numbered. If needed, we could add a special "draft" or "experimental" tag, or, alternatively, use the common numbering scheme, where odd major version numbers denote the development line of an interface.
|
|
|
|
''Ichthyo'' agrees, but adds he also meant "interface" in this proposal in a wider sense, like in "what do we need and require from a processing node". Knowing how generally Lumiera will handle the processing nodes while rendering helps him with defining and implementing the builder
|
|
|
|
__Conclusion__: "currently in work". For now, grow interfaces on demand.
|
|
-----
|
|
|
|
!!! Idea: Placement Metaphor used within the high-level view of Proc-Layer
|
|
[[Placement Metaphor in the Proc-Layer|http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/ProcPlacementMetaphor]]
|
|
|
|
In the course of the discussion, ''Ichthyo'' explains the rationale
|
|
* one common mechanism for sticking objects together and putting them into the session
|
|
* either specify the "placement"-parameters (time, output destination, track) directly, link to another object's parameters, or derive some or all of those values from the context (up the tree of tracks)
|
|
* ability to build a system of high-level media objects (clips, effects...) which re-adjust automatically on change
|
|
* extensible to handle or derive some parameters based on conditions and rules, e.g. for semi-automatic wiring of the output destination based on tags
|
|
|
|
''Joelholdsworth'' is concerned that this proposal may go too far and tries to tie things together which aren't really connected. While basically it's no problem having the time position of a clip either absolute, or derived by a link to another object, he can't see a clear benefit of controlling sound pan or video layer order from the placement. Pan, for example, is just an parameter value or interpolated curve, similar to colour correction or gamma adjustment. For the gui, he points out, it's probably better to stick to the object metaphor, so start time, output, layer number or sound pan would be properties of the object.
|
|
|
|
But that's exactly what Ichthyo wants to avoid. Obviously, this would be the standard solution employed by most current editing apps, and works reasonably well in average cases. But he is looking for a solution which covers this standard case, but also doesn't get into the way when dealing with advanced compositing, working with spatial sound systems (Ambisonics, Wave Field Synthesis) or stereoscopic (3D) video.
|
|
|
|
//On the whole, there is no conclusion yet.// Certainly, this proposal needs more discussion, parts need to be defined much more clear (esp. the "Pro" arguments), maybe parts of the functionality should be separated out.
|
|
|
|
While in this discussion, several aspects of the cooperation of GUI and Proc layer are considered.
|
|
* it is not necessary to make all of the Placement proposal visible to the GUI (and the user). Proc layer may as well provide a simplyfied and hard wired API for the most common properties (layer index, pan) and only use this part of the Placement concept for building and wiring the nodes.
|
|
* the adjustment of objects linked together by a placement can be handled as follows:
|
|
*# GUI notifies Proc of a position/parameter change of one object and gets immediate, synchronous feedback (OK or fail)
|
|
*# Proc detects the other linked objects affected by the change and notifies GUI (both synchronous and asynchronous is possible) to update information regarding those objects
|
|
*# GUI pulls the necessary properties by calling Proc on a per object base.
|
|
* as a rule of thumb, GUI <-> Proc is mostly synchronous, while Backend <-> GUI is often asynchronous, but there are exceptions from the rule
|
|
* we have general //parameters//, which are automatible. These are represented as //control data connections between the nodes.// We certainly don't want to represent some things in this way, though. For example, the in/out points of clips are fixed values.
|
|
* in Ichthyo's concept, the Placement doesn't itself provide such parameter values/sources, rather it can be used to //find// or //derive// parameter sources.
|
|
* the node graph is built bottom up, starting at the source, then via the effects attached locally to a clip, further on upwards (directed by the tree of tracks) to be finally connected via global busses to the output ports. Rendering pulls from these output ports.
|
|
* Joelholdsworth, Cehteh, Ichthyo and Rcbarnes agree that the plain //node-editor// approach is problematic in the context of a NLE. It shows too much details and fails to capture the temporal aspect. We strive at having node-like features and flexibility, but rather within the timeline.
|
|
* especially, the topology of the node graph isn't constant over the whole timeline. But it's the job of the builder in the Proc layer to deal with these complexities, the user shouldn't be overwhelmed with all those details.
|
|
-----
|
|
|
|
! Next meeting
|
|
* some people in europe complained that 21:00 UTC is too late, esp. with daylight saving
|
|
* there was the proposal to alternate between the current schedule, and sunday 16:00 UTC
|
|
* but Joel can't attend on sunday afternoon for now
|
|
* so we settle down on thursday, 16:30
|
|
|
|
Next meeting: ''Thursday 3.July 2008 16:30 UTC''
|
|
</pre>
|
|
</div>
|
|
<div title="IRC_2008-07-06" modifier="Ichthyostega" created="200810151616" tags="irclog excludeMissing" changecount="1">
|
|
<pre>! 6.July 2008 on #lumiera
|
|
__Participants__
|
|
* ichthyo
|
|
* cehteh
|
|
* jilt
|
|
* dmj726
|
|
* Teld
|
|
* _nasa_
|
|
* alcarinque_
|
|
* MNO
|
|
* Wescotte
|
|
* weatherhead
|
|
|
|
//Protocol written by Teld//
|
|
|
|
!Boilerplate
|
|
!!Organization of this meeting
|
|
* dmj726 intends to write the protocol
|
|
* ichtyo is chairman
|
|
* there is no agenda, so this is a freeform meeting
|
|
!!Leftovers from last meeting
|
|
//There are no leftovers//
|
|
|
|
!Introduction of Lumiera
|
|
Because there are quite some new participants, an introduction of the project Lumiera is given
|
|
|
|
There are 3 core devs:
|
|
* cehteh: backend serving data (from filesystem and so on), manages threads, using C, Posix System programming, maintains autotools and git
|
|
* ichthyo: proc layer, render graph, in the middle, C++, he maintains scons
|
|
* joelholdsworth: GUI in C++/Gtkm
|
|
Other people involved:
|
|
* rcbarnes: ui designer and HCI expert
|
|
* raffa: web content
|
|
* Simav: gives a hand when and where he can
|
|
* Teld: web infrastructure
|
|
|
|
The foundations of the design are already done but a lot of detail needs to be worked out. cehteh and ichtyo provide a non exhaustive list.
|
|
|
|
cehteh:
|
|
* improvement of the testsuite (simple Bash)
|
|
* start of a worker thread manager (Posix knowledge required)
|
|
* start of the scheduler (some Posix, good C coding)
|
|
* runtime profiler (little but advanced Posix realtime programming job)
|
|
* review of code and documentation
|
|
* system administration
|
|
* setup of a build/test environment on the server
|
|
* setup and maintain postfix/dovecot by a mail administrator
|
|
ichtyo:
|
|
* asset management (keeping track of all media files, captures, clips, scenes)
|
|
* session loading saving and the issues of compound documents
|
|
* session structure related issues to be able to Import/Export/Connect via e.g. OSC (Open Sound Control) or JACK
|
|
* flesh out the more high level "edit operations" and the interface to UNDO
|
|
* Prolog integration after the first integration round has been reached. The Prolog interpreter will do some of the more advanced configuration (example: if effect XYZ is used, then deinterlace beforehand).
|
|
* integration with some sort of production support software (like Celtx)
|
|
cehteh emphasizes that Lumiera is an open project, so anybody can jump in where he sees fit as long as he communicates and acknowledges with the persons involved. ichtyo points out that the plugin structure is very important: anything that is not legally completely clean (proprietary), should be factored out into a sister project and be loaded as plugin.
|
|
|
|
!Issues and questions that come up
|
|
!!handling of config errors.
|
|
When the configuration has a syntax error, in 90% of the cases there will be no possibility to do anything sane. Therefore, the config system will be built to log a warning and the user code does not need to care. The user just gets an alert and the application continues to work.
|
|
|
|
!!scripting language.
|
|
There will be a scripting interface. ichtyo does not want scripts everywhere, only at well defined interfaces. That implies also that scripts cannot just do anything, only that what is permitted in a controlled way. The meeting agrees on that. cehteh wants one default language and proposes Lua: light, simple.
|
|
|
|
Other members suggestions: Python, Ruby, Scheme. However, Python and Ruby are very slow. Scheme has many variants.
|
|
|
|
!!editing on small devices (eeePC)
|
|
Problem: video editors GUIs are some of the most elaborate and complicated GUIs. However, basic functions consist of only a few buttons. Proxy editing could be a solution. It is decided that it is not a primary goal now. First the basics have to be implemented.
|
|
|
|
!!uWiki.
|
|
uWiki is the glue between a markup driver (Asciidoc) and revision control (git). Haserl with Bash is used now. Haserl appears to have problems with conditional includes. Its limits have been reached while prototyping. Lua could very well be a valid replacement. It will be investigated. PHP is rejected because it is not stable and suffers from serious security problems.
|
|
|
|
!!'musical' timeline in bars and beats
|
|
The questions of syncing and linking things together are already on the core agenda: the so-called placement concept. Discussion is still going on, especially with the GUI developer joelholdsworth. See for detailed information: http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/ProcPlacementMetaphor
|
|
|
|
!Next meeting
|
|
The next meeting will be held ''Thursday, 7 August 19:00 UTC''
|
|
</pre>
|
|
</div>
|
|
<div title="IRC_2008-10-10" modifier="Ichthyostega" modified="200810151623" created="200810151617" tags="irclog excludeMissing" changecount="6">
|
|
<pre>!Oct 10, 2008 on #lumiera
|
|
19:00 - 23:15 UTC
|
|
__Participants__
|
|
* cehteh
|
|
* ichthyo
|
|
* joelholdsworth
|
|
* alcarinque
|
|
* ~KenSentMe
|
|
* Plouj
|
|
* raffa
|
|
* thorwil
|
|
* Victor_Sigma
|
|
* wildhostile
|
|
|
|
//Protocol written by Ichthyo//
|
|
|
|
!!!organisational
|
|
Not much of a fixed agenda this time.
|
|
Agreement to start with the Logo discussion, as this is of general interest, followed by the design drafts and similar dev topics.
|
|
|
|
!The Lumiera Logo
|
|
Summary of the situation: discussion regarding a logo for Lumiera is going on sporadically since quite some time. Several people from the community have made proposals. Also, there was discussion about the criteria a logo would have to fulfil. Especially the core devs raised the bar and required quite some professional level of design. On the contrary, several members of the community were concerned that such a demanding attitude will hinder creativity in a domain which is far off from coding. Moreover, many people complained they are really excited about Lumiera and strongly want to participate in some manner, but find it very difficult in the current phase of the project to give any valuable contribution.
|
|
|
|
This summer, one of the proposals by [[Leandro Ribeiro|http://farm4.static.flickr.com/3060/2927333034_ac94be80ea_b.jpg]] gained some popularity and especially was embraced by two of the core devs, while the GUI core dev wasn't convinced and [[explained|http://www.pipapo.org/pipawiki/JoelHoldsworth/LogoThoughts]] his reservation. Prior to this meeting some people joined a brainstorming session and came up with [[another design|http://www.pipapo.org/pipawiki/Lumiera/Logos?action=AttachFile&do=get&target=combo.png]] compiled of several proposals, which could meet the acceptance of the core devs. At the same time, Raffa made an argument for conducting a public contest, similar to the one which gave us the name of Lumiera. The situation for Lumiera is somewhat special. Usually, the community builds when the product is already minimally usable; we can't have users for now, but we have a lot of prospective users.
|
|
|
|
Thus, while basically it would be possible for the core devs to shorten the process by just picking a design which is acceptable for all, maybe after augmenting it a little, several of the arguments articulated this far are in favour of a more formal decision by a contest:
|
|
* it would allow for a lot of people to really participate
|
|
* it could help to shape a general (graphic) style for Lumiera
|
|
* it could underpin the fact Lumiera indeed is a collaborative effort
|
|
* it doesn't mean additional work for the core devs on the whole
|
|
* it helps spreading the word
|
|
|
|
Then, there is some discussion about the requirements. The core devs are concerned to keep up some quality level, because there is the possibility for the community to embrace a design, but when Lumiera enters the area it is intended to do, the standards of comparison will be different. The GIMP logo can be quoted as a negative example here.
|
|
|
|
!!Conclusion
|
|
There will be a Lumiera Logo contest.
|
|
* we should further discuss requirements on the Mailinglist until the end of the next week
|
|
* the ''deadline for submissions'' will be the next meeting (Nov 12 2008)
|
|
* then, after a pre-selection phase, the vote shall be conducted prior to the December meeting.
|
|
|
|
Some minimal technical requirements will be enforced:
|
|
* the basic sign fits a compact rather quadratic bounding box (like 4:3)
|
|
* easy to print on various media (on posters, t-shirts, ..)
|
|
* basically a shape, using only a small number of solid colours (web safe)
|
|
* should work on different backgrounds, esp. not requiring white background
|
|
* the design should scale from microscopic size (favicon) up to big posters
|
|
* vector graphic source is mandatory
|
|
|
|
Besides, we give some artistic guidelines
|
|
* it should be recognisable
|
|
* it should contain something like a sign, not just "Lumiera" in a fancy font
|
|
* it should not rely on transparencies, gradients and subtle shades,
|
|
* it should be viable, possibly work well in different presentation styles, able to be simplified as well as graphically augmented
|
|
|
|
Raffa volunteers to help organizing the contest and the voting.
|
|
----
|
|
|
|
|
|
|
|
|
|
!Recurring Topics: design proposals
|
|
Discussion of open [[design process|http://www.pipapo.org/pipawiki/Lumiera/DesignProcess]] drafts.
|
|
|
|
!!Mistakes to avoid
|
|
[http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/MistakestoAvoid Mistakes to avoid in the Lumiera Design]
|
|
We are carrying this one along since quite some time and we'd like to get rid of it, either by reworking it or by dropping it as-is. Because it contains a mixture of things
|
|
* we fully agree to 80% of the statements made there, but we think those statements are so very basic and self-evident as to be considered off-topic here. We are aware of the recurring problems with open source video editing. That's why we are here.
|
|
* the proposal draws conclusions on two technically substantial points, at which we don't agree. And it fails to provide sufficient (technically sound) arguments to prove these statements.
|
|
|
|
While it is certainly //desirable// to be cross-platform as much as possible and especially ''target Microsoft Windows'', we don't see much possibilities with today's mainstream technology to build an application which is as technologically demanding as a video editor is. We would end up developing two or even three sister applications, or we are forced to sacrifice performance for portability. When put up to face such options, we have a clear preference to concentrate on a really free and open platform.
|
|
|
|
While it is certainly //desirable// to make the application as robust as possible, we don't see how ''using multiple separate processes'' could help us with this goal //without creating major scalability or performance problems// due to the use of shared memory. And, yet more important: we don't share the basic assumption made in the proposal, namely that video processing is inherently dangerous. We think the basic algorithms involved are sufficiently well-known and understandable to implement them in a sound manner.
|
|
|
|
__Conclusion__: drop it
|
|
|
|
!!!!on the question of separate processes
|
|
The only practical solution would be to separate the GUI. Separating backend and proc-layer doesn't make much sense, technically speaking. We re-considered this question. Joelholdsworth (GUI) and Ichthyo (Proc-layer)prefer running the GUI in-process and to avoid the additional hassle with shared memory. Cehteh (backend) doesn't care for know and would like to re-discuss it as an option later on. This is somewhat similar to the possibility of running Lumiera distributed over the network, which is a goal, but not an immediate one.
|
|
|
|
|
|
!!Tag Clouds
|
|
[http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/TagCloudsOnResources Tag clouds on resources]
|
|
Tags are considered very important. Meanwhile, we have a much more advanced proposal, which superseeds this one: [http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/DelectusShotEvaluator "Delectus"]
|
|
|
|
__Conclusion__: drop it
|
|
|
|
|
|
|
|
!!Overview of Lumiera Architecture
|
|
[http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/ArchitectureOverview Architecture Overview]
|
|
The purpose of this drawing to give an first impression what subsystem is where and what the names mean. Since discussed last time, Ichthyo re-arranged the plugins as requested and added some details for the backend. Joelholdsworth points out that it's OK for him to show the GUI just as a single block here (and of course the GUI has much more internal structure). Cehteh adds that maintaining this drawing surely is a moving target, so we better remove the rendered image and just retain the textual description and link to the source (SVG), which is in GIT.
|
|
|
|
__Conclusion__: accept it, change the image to a link
|
|
|
|
|
|
|
|
!!EDLs as Meta-Clips
|
|
[http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/EDLsAreMetaClips EDLs are meta-clips]
|
|
This is just a high-level proposal, which doesn't go into technical details of implementing nested EDLs. It just poses the question "do we want to treat nested EDLs as being meta-clip" -- which we do.
|
|
|
|
__Conclusion__: accepted
|
|
|
|
|
|
|
|
!!The Builder
|
|
[http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/ProcBuilder Builder in the Proc-Layer]
|
|
Similar to the previous one, this is a high-level proposal. It covers the fundamental approach Ichthyo takes within the Proc-Layer. Cehteh adds that he agrees to 98% and the remaining 2% are just matter of favour. Personally, he would have preferred one large graph which gets garbage collected (instead of the segmented graph)
|
|
|
|
__Conclusion__: accepted
|
|
|
|
|
|
|
|
!!High-level Model
|
|
[http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/ProcHighLevelModel Overview of the High-level model within the Proc-Layer]
|
|
Cehteh queries if this shouldn't be better moved over to the documentation? He is fine with the contents, but it seems to be a bit voluminous for a design proposal. Ichthyo asks to leave it there just for now, as he feels it still needs review.
|
|
|
|
__Conclusion__: leave it for now, maybe retract it from the design proposals and file it as documentation?
|
|
|
|
|
|
|
|
!!Lua scripting language
|
|
[http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/ScriptingLanguage use Lua as required scripting language]
|
|
All core devs agree with this decision. Joelholdsworth points out that he is fine with Lua, just he didn't want to write the GUI in it. Ichthyo adds that Lua is probably the best choice from today's mainstream scripting languages, because it is very lightweight. He further points out, that having Lua as //required// scripting language doesn't rule out using other popular languages (Python, Ruby) for scripting. Just they aren't required for running Lumiera. Cehteh will have a look at the details as soon as possible, but has currently other more urgent things in the queue. (Plouj shows interest to help here)
|
|
|
|
__Conclusion__: accepted
|
|
|
|
|
|
|
|
!!Time Handling
|
|
[http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/time_handling time handling]
|
|
A long standing proposal; meanwhile we've decided to build on GAVL, which is now reflected in the text of this proposal too. Ichthyo points out he changed the rounding rule in this proposal from "mathematical" to "floor (x+0.5)". Cehteh asks if we should use a thin library layer on top of gavl, to centralize all the time calculations. There seems to be agreement that this should actually be done //on demand.// Joelholdsworth sais sometimes he'd prefer to have a simple raw type to represent time, because it makes calculations much easier. Ichthyo adds that internally (within the layers, but not on interfaces) one could use a thin C++ wrapper with overloaded operators, which is default-convertible to gavl_time.
|
|
|
|
__Conclusion__: accepted
|
|
|
|
Note: the proposed rigid testsuite for time handling is necessary only when we introduce a wrapper...
|
|
|
|
!!Interface naming convention
|
|
See the design proposal [http://www.pipapo.org/pipawiki/Lumiera/DesignProcess/InterfaceNamespaces Interface Namespaces]. While working on the plugin loader, ''Cehteh'' and ''nasa'' did some brainstorming about a plugin naming scheme and how to get unique interface identifiers. The idea is to use a distinctive prefix, like a condensed organisation domain or email name, or a GPG fingerprint or even a UID, followed by the interface namespace hierarchy. These would be combined into a single identifier (valid C name). The intention is to get non-ambiguous names, yet avoiding the need of a central registry.
|
|
|
|
__Conclusion__: accepted
|
|
|
|
----
|
|
general Topics
|
|
|
|
!Config System
|
|
''cehteh'' landed the first version of this subsystem and asked for review and testing. Currently it's "work with no progress", but it is basically usable (you can get values, you can set values by environment variables, but you can't persist). It should be augmented on demand, e.g. by adding the support for more value types (value types are a hint how to parse, and link the parsed value to a given C type).
|
|
|
|
|
|
!Use of Namespaces
|
|
Currently there is no clear uniform rule regarding namespaces use. ''Joelholdsworth'' places his code within lumiera::gui and below. He points out that external libs like Cairo, GTK, GLib will bring in their hierarchies and all of Lumiera should comply and put anything below a lumiera:: root. On the contrary, ''Ichthyo'' deliberately moved his implementation code away from the central lumiera:: interface hierarchy into shallow namespaces and avoids nesting. He argues that having all code below luimiera:: effectively makes this namespace global or forces it to be void of any function; rather he'd prefer to import every interface explicitly into the implementation namespace. ''Cehteh'' argues that having a global lumiera::, even if empty, would mark a general claim and stand for the uniformity of the project. Generally, there should be some correspondence between folders and namespaces.
|
|
|
|
No conclusion yet, to be discussed further.
|
|
|
|
|
|
!Interface Definition Language
|
|
In his work on the plugin loader, ''Cehteh'' created a first draft how to export an interface, and calls for review. An example can be found in [http://www.lumiera.org/gitweb?p=lumiera/ct;a=blob;f=tests/backend/test-interfaces.c;h=fb1c4d30a34414767a313d24df60e679c96ad2a7;hb=7323114e77348995ccaf03417136aef7ee332776 tests/backend/test-interfaces.c]
|
|
|
|
An interface is a list of "slots" mapping functions. The interface descriptor is itself realised as interface, an thus can be versioned, extended and specialised. By use of some glue code and macros we create a simple Interface Definition Language
|
|
* after exporting a header with the C interface, including the types to be used...
|
|
* LUMIERA_INTERFACE_DECLARE creates an interface description (i.e. the official interface)
|
|
* implementing such an interface can be done in 3 major ways
|
|
* LUMIERA_INTERFACE_INSTANCE creates an instance on-the-fly (e.g. for descriptors)
|
|
* LUMIERA_EXPORT for defining a table of functions/interfaces to export from the core
|
|
* LUMIERA_PLUGIN for defining an interface table for functions located within a dynlib module (plugin)
|
|
* besides, with LUMIERA_INTERFACE_INLINE you can create a function on-the-fly while LUMIERA_INTERFACE_MAP maps onto an existing function directly
|
|
|
|
The plugin loading system cares for mapping the given implementation function to the interface slots. Interfaces from the core need to be registered before they can be used, while for plugins this is done automatically on loading the module. The client code later just calls {{{interface_open()}}} and {{{interface_close()}}} where it doesn't matter anymore if the invoked function is in the core or loaded from an dynlib (plugin); loader, registry and/or plugin-DB shall manage it transparently.
|
|
|
|
Version numbering starts with 1 and uses minor version numbers for compatible changes and major version numbers for everything that breaks existing asumptions. Version number zero is reserved for experimental work and per definition always the most recent version number.
|
|
|
|
The system is designed to be very flexible and extensible, but this foundation really needs thorough review.
|
|
|
|
Joelholdworth expresses some concern regarding the UIDs in octal notation used within the interface description. Cehteh explains they never need to be specified by client code. They are just distinctive IDs and provided for some special case within the plugin loader / serializer. He plans to provide a simple tool which automatically replaces a $LUIDGEN with such a bitstring. The octal notation was chosen, because it is the most compact albeit portable notation possible in C source code.
|
|
|
|
!!Conclusion
|
|
|
|
looks good, agreement by all core devs.
|
|
Should be reviewed and investigated in detail to find any hidden problems.
|
|
|
|
|
|
!Next meeting
|
|
|
|
There were some problems with the meeting schedule. Using the first week of month seems to be problematic. We'll try with second wednesday...
|
|
|
|
The next meeting is scheduled for ''Wednesday Nov 12 2008 19:30 UTC'' at #lumiera
|
|
</pre>
|
|
</div>
|
|
<div title="IRC_log_BufferAllocation_2008-06" modifier="Ichthyostega" created="200806211624" tags="irclog excludeMissing" changecount="1">
|
|
<pre>! 5.June 2008 on #lumiera
|
|
__cehteh__ and __ichthyo__
|
|
{{{
|
|
[2008-06-05 19:21:21] <cehteh> do you need me? .. i am away if not .. i have no much to say for the today meeting either
|
|
[2008-06-05 19:21:57] <ichthyo> I have one topic I want to discuss with you, cehteh
|
|
[2008-06-05 19:22:07] <ichthyo> but it need not be now, or in the meeting
|
|
[2008-06-05 19:22:07] <cehteh> ok
|
|
[2008-06-05 19:22:24] <ichthyo> it's about allocating processing buffers
|
|
[2008-06-05 19:23:20] <cehteh> the backend will provide them as temporary files/cyclic buffers
|
|
[2008-06-05 19:23:52] <cehteh> its not there yet but in my mind
|
|
[2008-06-05 19:24:11] <ichthyo> haha, same for the builder... it's mostly just in my mind
|
|
[2008-06-05 19:24:42] <cehteh> opened almost like a normal file but giving frame properties instead filename
|
|
[2008-06-05 19:24:56] <cehteh> (there will be a distinct api for that)
|
|
[2008-06-05 19:25:01] <ichthyo> ok
|
|
[2008-06-05 19:25:05] <ichthyo> regarding the buffers: my question is more special
|
|
[2008-06-05 19:25:19] <ichthyo> if you want to cache a frame (intermediary result)
|
|
[2008-06-05 19:25:35] <ichthyo> then I thought we could avoid the copy operation
|
|
[2008-06-05 19:25:44] <ichthyo> I could arrange things accordingly
|
|
[2008-06-05 19:25:46] <cehteh> then the backend creates a backing mmaped file for that maybe manages its size (or do you want to tell how much frames you want to cache?)
|
|
[2008-06-05 19:26:06] <cehteh> yes perfect .. thats what i am planning
|
|
[2008-06-05 19:26:26] <ichthyo> you know, many processing nodes will be able to process "in place"
|
|
[2008-06-05 19:26:34] <ichthyo> but ther are some that can't do this
|
|
[2008-06-05 19:27:44] <ichthyo> so basically each processing function will "see" input frame buffer(s) and output frame buffer(s). but when a node is "in-place-capable", actually the in and out buffer may point to the same location
|
|
[2008-06-05 19:26:55] <cehteh> basiically all temporary frames with the same properties are allcoated from the same backing file (well maybe 2 caching levels but not important here)
|
|
[2008-06-05 19:27:06] <cehteh> the index give them meaning
|
|
[2008-06-05 19:27:49] <cehteh> do you can query (and lock) a frame by that
|
|
[2008-06-05 19:28:04] <ichthyo> that sounds good
|
|
[2008-06-05 19:28:24] <cehteh> do some inplace editing and then tell the backend "this is now frame N of node X"
|
|
[2008-06-05 19:28:34] <ichthyo> yeah, exactly
|
|
[2008-06-05 19:28:44] <cehteh> (plus a uuid or preferably genertion number)
|
|
[2008-06-05 19:28:39] <ichthyo> basically my Idea was as follows:
|
|
[2008-06-05 19:29:47] <ichthyo> when I know the result will be cached, I'll let the node process into the location of the cache frame, and any node which will /use/ this frame as an input will be wired such that it isn't allowed to modify this frame (which is supposed to be located in the cache)
|
|
[2008-06-05 19:30:45] <cehteh> yes thats managed in the index
|
|
[2008-06-05 19:30:48] <ichthyo> for this to work, I need to "allocate and lock" a location in the cache, and release it when it contains the final processed result
|
|
[2008-06-05 19:31:17] <cehteh> well i try to make no locks there, you query frames which are uniquely identified
|
|
[2008-06-05 19:31:44] <ichthyo> it doesnt need to be a "lock
|
|
[2008-06-05 19:31:55] <ichthyo> just some way to tell that this frame is "under construction"
|
|
[2008-06-05 19:32:01] <cehteh> yes
|
|
[2008-06-05 19:32:14] <cehteh> we thinking the same :)
|
|
[2008-06-05 19:32:57] <cehteh> well problem is when shortly after that another node queries the source frame which got destructed .. thats something the builder needs to avoid, nothing i can do then
|
|
[2008-06-05 19:33:21] <ichthyo> yes, builder will care for that
|
|
[2008-06-05 19:33:41] <ichthyo> I can even tell in advance the maximum number of temporary buffers I need
|
|
[2008-06-05 19:33:51] <cehteh> and it not only needs a under-construcion
|
|
[2008-06-05 19:34:44] <cehteh> there are 2 indices one for source and one for destination
|
|
[2008-06-05 19:35:11] <cehteh> indices will have a pointer to the 'job' working on it i tihnk
|
|
[2008-06-05 19:35:24] <ichthyo> ok
|
|
[2008-06-05 19:35:48] <cehteh> (actually there is a list planed many jobs can read-share an frame)
|
|
[2008-06-05 19:36:40] <cehteh> i would like if I do not need to do *any* checks in that direction ... means the builder delivers clean jobs which dont step on their own foot
|
|
[2008-06-05 19:36:54] <ichthyo> my understanding too
|
|
[2008-06-05 19:37:07] <ichthyo> also, I want the nodes to be freed of any checks
|
|
[2008-06-05 19:37:33] <ichthyo> so they can assume they get a valid buffer pointer to the right sort of buffer
|
|
[2008-06-05 19:37:54] <cehteh> yes thats guranteed
|
|
[2008-06-05 19:37:41] <cehteh> if it fails then we get some hairy bugs ... but checking job dependencies afterwards is costly
|
|
[2008-06-05 19:38:53] <ichthyo> I mean -- I want to prepare everything as much as possible while building, so that all that needs to be "filled in" when starting the processing are the actual buffer locations
|
|
[2008-06-05 19:38:58] <cehteh> *thinkin* prolly easier than it looks
|
|
[2008-06-05 19:39:10] <cehteh> exaxctly
|
|
[2008-06-05 19:39:50] <ichthyo> we can't prepare everything, because, some nodes may include a variable ammount of source frames
|
|
[2008-06-05 19:40:11] <ichthyo> and this number can depend on automation. Classic example is the "time average" video effect
|
|
[2008-06-05 19:39:53] <cehteh> problem is only when the builder generates one node which takes X and in-place generates Y from it
|
|
[2008-06-05 19:40:10] <cehteh> and you have a 2nd node which takes X too
|
|
[2008-06-05 19:40:23] <cehteh> this needs to be serialized somehow
|
|
[2008-06-05 19:41:12] <ichthyo> regarding the problem you mention: I want to exclude/avoid this situation already when building
|
|
[2008-06-05 19:41:35] <cehteh> yes thats what i was thinking .. thats easiest addressed there
|
|
[2008-06-05 19:41:46] <cehteh> and a very ugly bug when it fails :(
|
|
[2008-06-05 19:41:42] <ichthyo> when a node puts its result into a frame located within the cache
|
|
[2008-06-05 19:41:59] <ichthyo> this frame is treated as if it is read-only
|
|
[2008-06-05 19:42:21] <ichthyo> no node depending on this frame will be wired in a way that allows "in-place"
|
|
[2008-06-05 19:42:33] <cehteh> about the time averaging: i plan to hint some dependencies so you can ask for "maybe" or by some priority depending on quality/whatever
|
|
[2008-06-05 19:43:19] <cehteh> where quality should be runtime adjusted by the profiler
|
|
[2008-06-05 19:43:39] <ichthyo> the problem with time averaging is: we don't know how much frames will be averaged at build time, because that's a automatable effect parameter
|
|
[2008-06-05 19:43:47] <cehteh> thats a case where a dependencie might not be fullfilled .. but only on request
|
|
[2008-06-05 19:44:08] <ichthyo> but the "quality" thing sounds like a good idea
|
|
[2008-06-05 19:44:17] <cehteh> yes then split that rendering into 3 passes?
|
|
[2008-06-05 19:44:27] <cehteh> 1st pass : building the graph
|
|
[2008-06-05 19:44:53] <cehteh> 2nd pass: determine dependencies (by inspecting automation)
|
|
[2008-06-05 19:45:00] <cehteh> 3rd pass: do the render
|
|
[2008-06-05 19:45:10] <ichthyo> maybe?
|
|
[2008-06-05 19:45:17] <ichthyo> 1st pass of course is clear
|
|
[2008-06-05 19:45:25] <cehteh> well do you have a better idea?
|
|
[2008-06-05 19:45:49] <cehteh> so far i thought about 2 pass where the dependency analysis was part of the builder
|
|
[2008-06-05 19:46:02] <ichthyo> agreed
|
|
[2008-06-05 19:46:28] <cehteh> but making it three pass shouldnt be a problem or?
|
|
[2008-06-05 19:46:51] <ichthyo> I also thought after having finished the raw graph, I'll do some configuration calldown, e.g. to determine the maximum number of buffers needed
|
|
[2008-06-05 19:46:59] <cehteh> maybe even adaptive 2/3 pass depending on effects ... but maybe that would complicate it unnecessary
|
|
[2008-06-05 19:47:43] <ichthyo> its not really a problem, just need to be aware and work the details out correctlyy
|
|
[2008-06-05 19:47:49] <cehteh> i dont think you need to count the buffers (not yet, maybe i oversee soemthing)
|
|
[2008-06-05 19:48:08] <cehteh> otherwise the backend should manage that automatically
|
|
[2008-06-05 19:48:18] <ichthyo> yes, I'm fine with that
|
|
[2008-06-05 19:48:46] <ichthyo> just to note, if it helps with the allocation, I /can/ tell the maximum number of buffers needed
|
|
[2008-06-05 19:49:00] <ichthyo> (for a given segment of the graph, of course)
|
|
[2008-06-05 19:49:09] <cehteh> not sure if i overseen something, but i think when needed such a 'configuration calldown' (and optimizing pass) could be added later
|
|
[2008-06-05 19:49:27] <ichthyo> sure
|
|
[2008-06-05 19:49:50] <cehteh> buffers itself doesnt cost .. but if you really need a lot it will cause IO
|
|
[2008-06-05 19:49:57] <cehteh> but that unavoidable anyways
|
|
[2008-06-05 19:50:05] <ichthyo> no no
|
|
[2008-06-05 19:50:19] <cehteh> yes yes
|
|
[2008-06-05 19:50:20] <ichthyo> I'll try to minimize buffer use as much as possible
|
|
[2008-06-05 19:50:24] <cehteh> :)
|
|
[2008-06-05 19:50:30] <cehteh> of course
|
|
[2008-06-05 19:51:00] <cehteh> but there are always some limits on finite machines
|
|
[2008-06-05 19:51:26] <ichthyo> the problematic case are usual rather rare corner cases, but it should handle those flawless, of course
|
|
[2008-06-05 19:51:36] <ichthyo> similar for the size of the buffers
|
|
[2008-06-05 19:51:46] <ichthyo> I dont want Lumiera to clip the image
|
|
[2008-06-05 19:51:49] <ichthyo> as cinelerra does
|
|
[2008-06-05 19:52:04] <ichthyo> e.g. when using the motion tracker
|
|
[2008-06-05 19:52:20] <cehteh> well if you need safe-regions around you need to use biggier frames
|
|
[2008-06-05 19:52:31] <cehteh> but memory requirements grow quadratic!
|
|
[2008-06-05 19:52:46] <ichthyo> the user should NEVER need to set up the processing buffer size, as is necessary in cinelerra
|
|
[2008-06-05 19:52:59] <cehteh> yes agreed
|
|
[2008-06-05 19:53:15] <ichthyo> I don't think we need safe-regions allways,
|
|
[2008-06-05 19:53:31] <ichthyo> but, as e.g. the motion tracking will create automation data in Lumiera
|
|
[2008-06-05 19:53:38] <cehteh> yes only for some effect .. motion tracker doesnt need it
|
|
[2008-06-05 19:53:50] <ichthyo> it means the actual buffer size depends on automation data for a given frame
|
|
[2008-06-05 19:53:56] <cehteh> that just xyr transformation
|
|
[2008-06-05 19:54:35] <cehteh> a blur is something which might require a small safe-region to bleed over the edges
|
|
[2008-06-05 19:54:43] <ichthyo> yes, you are right
|
|
[2008-06-05 19:54:52] <ichthyo> if the motion tracker is wired intelligently
|
|
[2008-06-05 19:55:05] <ichthyo> it doesn't need to move anyting itself
|
|
[2008-06-05 19:55:18] <cehteh> mapping the motion tracker transformation to a destionation might need safe regions
|
|
[2008-06-05 19:55:30] <cehteh> (in case of rotations)
|
|
[2008-06-05 19:55:36] <ichthyo> yes agreed
|
|
[2008-06-05 19:56:16] <cehteh> well temp buffers will be allcocated for frames of the same 'class' i aleready saied that
|
|
[2008-06-05 19:56:50] <cehteh> and i will group these classes so that some similar sizes fall in the same class
|
|
[2008-06-05 19:57:19] <cehteh> that might waste some memory on disk at the end of each frame .. but that doesnt need to be mapped in
|
|
[2008-06-05 19:57:32] <cehteh> the kernel will do that automatically for us
|
|
[2008-06-05 19:57:37] <ichthyo> :)
|
|
[2008-06-05 19:57:59] <cehteh> well mostly .. i need to whip it with the right hints ;)
|
|
[2008-06-05 19:58:10] <ichthyo> :-o
|
|
}}}</pre>
|
|
</div>
|
|
<div title="InlineJavaScript" modifier="Jeremy" created="200603090618" tags="systemConfig" server.type="file" server.host="file:///home/ct/.homepage/home.html" server.page.revision="200603090618">
|
|
<pre>/***
|
|
''InlineJavascriptPlugin for ~TiddlyWiki version 1.2.x and 2.0''
|
|
^^author: Eric Shulman - ELS Design Studios
|
|
source: http://www.TiddlyTools.com/#InlineJavascriptPlugin
|
|
license: [[Creative Commons Attribution-ShareAlike 2.5 License|http://creativecommons.org/licenses/by-sa/2.5/]]^^
|
|
|
|
Insert Javascript executable code directly into your tiddler content. Lets you ''call directly into TW core utility routines, define new functions, calculate values, add dynamically-generated TiddlyWiki-formatted output'' into tiddler content, or perform any other programmatic actions each time the tiddler is rendered.
|
|
!!!!!Usage
|
|
<<<
|
|
When installed, this plugin adds new wiki syntax for surrounding tiddler content with {{{<script>}}} and {{{</script>}}} markers, so that it can be treated as embedded javascript and executed each time the tiddler is rendered.
|
|
|
|
''Deferred execution from an 'onClick' link''
|
|
By including a label="..." parameter in the initial {{{<script>}}} marker, the plugin will create a link to an 'onclick' script that will only be executed when that specific link is clicked, rather than running the script each time the tiddler is rendered.
|
|
|
|
''External script source files:''
|
|
You can also load javascript from an external source URL, by including a src="..." parameter in the initial {{{<script>}}} marker (e.g., {{{<script src="demo.js"></script>}}}). This is particularly useful when incorporating third-party javascript libraries for use in custom extensions and plugins. The 'foreign' javascript code remains isolated in a separate file that can be easily replaced whenever an updated library file becomes available.
|
|
|
|
''Defining javascript functions and libraries:''
|
|
Although the external javascript file is loaded while the tiddler content is being rendered, any functions it defines will not be available for use until //after// the rendering has been completed. Thus, you cannot load a library and //immediately// use it's functions within the same tiddler. However, once that tiddler has been loaded, the library functions can be freely used in any tiddler (even the one in which it was initially loaded).
|
|
|
|
To ensure that your javascript functions are always available when needed, you should load the libraries from a tiddler that will be rendered as soon as your TiddlyWiki document is opened. For example, you could put your {{{<script src="..."></script>}}} syntax into a tiddler called LoadScripts, and then add {{{<<tiddler LoadScripts>>}}} in your MainMenu tiddler.
|
|
|
|
Since the MainMenu is always rendered immediately upon opening your document, the library will always be loaded before any other tiddlers that rely upon the functions it defines. Loading an external javascript library does not produce any direct output in the tiddler, so these definitions should have no impact on the appearance of your MainMenu.
|
|
|
|
''Creating dynamic tiddler content''
|
|
An important difference between this implementation of embedded scripting and conventional embedded javascript techniques for web pages is the method used to produce output that is dynamically inserted into the document:
|
|
* In a typical web document, you use the document.write() function to output text sequences (often containing HTML tags) that are then rendered when the entire document is first loaded into the browser window.
|
|
* However, in a ~TiddlyWiki document, tiddlers (and other DOM elements) are created, deleted, and rendered "on-the-fly", so writing directly to the global 'document' object does not produce the results you want (i.e., replacing the embedded script within the tiddler content), and completely replaces the entire ~TiddlyWiki document in your browser window.
|
|
* To allow these scripts to work unmodified, the plugin automatically converts all occurences of document.write() so that the output is inserted into the tiddler content instead of replacing the entire ~TiddlyWiki document.
|
|
|
|
If your script does not use document.write() to create dynamically embedded content within a tiddler, your javascript can, as an alternative, explicitly return a text value that the plugin can then pass through the wikify() rendering engine to insert into the tiddler display. For example, using {{{return "thistext"}}} will produce the same output as {{{document.write("thistext")}}}.
|
|
|
|
//Note: your script code is automatically 'wrapped' inside a function, {{{_out()}}}, so that any return value you provide can be correctly handled by the plugin and inserted into the tiddler. To avoid unpredictable results (and possibly fatal execution errors), this function should never be redefined or called from ''within'' your script code.//
|
|
|
|
''Accessing the ~TiddlyWiki DOM''
|
|
The plugin provides one pre-defined variable, 'place', that is passed in to your javascript code so that it can have direct access to the containing DOM element into which the tiddler output is currently being rendered.
|
|
|
|
Access to this DOM element allows you to create scripts that can:
|
|
* vary their actions based upon the specific location in which they are embedded
|
|
* access 'tiddler-relative' information (use findContainingTiddler(place))
|
|
* perform direct DOM manipulations (when returning wikified text is not enough)
|
|
<<<
|
|
!!!!!Examples
|
|
<<<
|
|
an "alert" message box:
|
|
{{{
|
|
<script>alert('InlineJavascriptPlugin: this is a demonstration message');</script>
|
|
}}}
|
|
<script>alert('InlineJavascriptPlugin: this is a demonstration message');</script>
|
|
|
|
dynamic output:
|
|
{{{
|
|
<script>return (new Date()).toString();</script>
|
|
}}}
|
|
<script>return (new Date()).toString();</script>
|
|
|
|
wikified dynamic output:
|
|
{{{
|
|
<script>return "link to current user: [["+config.options.txtUserName+"]]";</script>
|
|
}}}
|
|
<script>return "link to current user: [["+config.options.txtUserName+"]]";</script>
|
|
|
|
dynamic output using 'place' to get size information for current tiddler
|
|
{{{
|
|
<script>
|
|
if (!window.story) window.story=window;
|
|
var title=story.findContainingTiddler(place).id.substr(7);
|
|
return title+" is using "+store.getTiddlerText(title).length+" bytes";
|
|
</script>
|
|
}}}
|
|
<script>
|
|
if (!window.story) window.story=window;
|
|
var title=story.findContainingTiddler(place).id.substr(7);
|
|
return title+" is using "+store.getTiddlerText(title).length+" bytes";
|
|
</script>
|
|
|
|
creating an 'onclick' button/link that runs a script
|
|
{{{
|
|
<script label="click here">
|
|
if (!window.story) window.story=window;
|
|
alert("Hello World!\nlinktext='"+place.firstChild.data+"'\ntiddler='"+story.findContainingTiddler(place).id.substr(7)+"'");
|
|
</script>
|
|
}}}
|
|
<script label="click here">
|
|
if (!window.story) window.story=window;
|
|
alert("Hello World!\nlinktext='"+place.firstChild.data+"'\ntiddler='"+story.findContainingTiddler(place).id.substr(7)+"'");
|
|
</script>
|
|
|
|
loading a script from a source url
|
|
{{{
|
|
<script src="demo.js">return "loading demo.js..."</script>
|
|
<script label="click to execute demo() function">demo()</script>
|
|
}}}
|
|
where http://www.TiddlyTools.com/demo.js contains:
|
|
>function demo() { alert('this output is from demo(), defined in demo.js') }
|
|
>alert('InlineJavascriptPlugin: demo.js has been loaded');
|
|
<script src="demo.js">return "loading demo.js..."</script>
|
|
<script label="click to execute demo() function">demo()</script>
|
|
<<<
|
|
!!!!!Installation
|
|
<<<
|
|
import (or copy/paste) the following tiddlers into your document:
|
|
''InlineJavascriptPlugin'' (tagged with <<tag systemConfig>>)
|
|
<<<
|
|
!!!!!Revision History
|
|
<<<
|
|
''2006.01.05 [1.4.0]''
|
|
added support 'onclick' scripts. When label="..." param is present, a button/link is created using the indicated label text, and the script is only executed when the button/link is clicked. 'place' value is set to match the clicked button/link element.
|
|
''2005.12.13 [1.3.1]''
|
|
when catching eval error in IE, e.description contains the error text, instead of e.toString(). Fixed error reporting so IE shows the correct response text. Based on a suggestion by UdoBorkowski
|
|
''2005.11.09 [1.3.0]''
|
|
for 'inline' scripts (i.e., not scripts loaded with src="..."), automatically replace calls to 'document.write()' with 'place.innerHTML+=' so script output is directed into tiddler content
|
|
Based on a suggestion by BradleyMeck
|
|
''2005.11.08 [1.2.0]''
|
|
handle loading of javascript from an external URL via src="..." syntax
|
|
''2005.11.08 [1.1.0]''
|
|
pass 'place' param into scripts to provide direct DOM access
|
|
''2005.11.08 [1.0.0]''
|
|
initial release
|
|
<<<
|
|
!!!!!Credits
|
|
<<<
|
|
This feature was developed by EricShulman from [[ELS Design Studios|http:/www.elsdesign.com]]
|
|
<<<
|
|
!!!!!Code
|
|
***/
|
|
//{{{
|
|
version.extensions.inlineJavascript= {major: 1, minor: 4, revision: 0, date: new Date(2006,1,5)};
|
|
|
|
config.formatters.push( {
|
|
name: "inlineJavascript",
|
|
match: "\\<script",
|
|
lookahead: "\\<script(?: src=\\\"((?:.|\\n)*?)\\\")?(?: label=\\\"((?:.|\\n)*?)\\\")?\\>((?:.|\\n)*?)\\</script\\>",
|
|
|
|
handler: function(w) {
|
|
var lookaheadRegExp = new RegExp(this.lookahead,"mg");
|
|
lookaheadRegExp.lastIndex = w.matchStart;
|
|
var lookaheadMatch = lookaheadRegExp.exec(w.source)
|
|
if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
|
|
if (lookaheadMatch[1]) { // load a script library
|
|
// make script tag, set src, add to body to execute, then remove for cleanup
|
|
var script = document.createElement("script"); script.src = lookaheadMatch[1];
|
|
document.body.appendChild(script); document.body.removeChild(script);
|
|
}
|
|
if (lookaheadMatch[2] && lookaheadMatch[3]) { // create a link to an 'onclick' script
|
|
// add a link, define click handler, save code in link (pass 'place'), set link attributes
|
|
var link=createTiddlyElement(w.output,"a",null,"tiddlyLinkExisting",lookaheadMatch[2]);
|
|
link.onclick=function(){try{return(eval(this.code))}catch(e){alert(e.description?e.description:e.toString())}}
|
|
link.code="function _out(place){"+lookaheadMatch[3]+"};_out(this);"
|
|
link.setAttribute("href","javascript:;"); link.setAttribute("title",""); link.style.cursor="pointer";
|
|
}
|
|
else if (lookaheadMatch[3]) { // run inline script code
|
|
var code="function _out(place){"+lookaheadMatch[3]+"};_out(w.output);"
|
|
code=code.replace(/document.write\(/gi,'place.innerHTML+=(');
|
|
try { var out = eval(code); } catch(e) { out = e.description?e.description:e.toString(); }
|
|
if (out && out.length) wikify(out,w.output);
|
|
}
|
|
w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length;
|
|
}
|
|
}
|
|
} )
|
|
//}}}
|
|
</pre>
|
|
</div>
|
|
<div title="InlineJavascriptPlugin" modifier="PauloSoares" modified="200609302108" created="200512130544" tags="plugin excludeLists systemConfig" server.type="file" server.host="file:///home/ct/.homepage/home.html" server.page.revision="200609302108">
|
|
<pre>/***
|
|
|''Name:''|InlineJavascriptPlugin|
|
|
|''Source:''|http://www.TiddlyTools.com/#InlineJavascriptPlugin|
|
|
|''Author:''|Eric Shulman - ELS Design Studios|
|
|
|''License:''|[[Creative Commons Attribution-ShareAlike 2.5 License|http://creativecommons.org/licenses/by-sa/2.5/]]|
|
|
|''~CoreVersion:''|2.0.10|
|
|
|
|
Insert Javascript executable code directly into your tiddler content. Lets you ''call directly into TW core utility routines, define new functions, calculate values, add dynamically-generated TiddlyWiki-formatted output'' into tiddler content, or perform any other programmatic actions each time the tiddler is rendered.
|
|
!!!!!Usage
|
|
<<<
|
|
When installed, this plugin adds new wiki syntax for surrounding tiddler content with {{{<script>}}} and {{{</script>}}} markers, so that it can be treated as embedded javascript and executed each time the tiddler is rendered.
|
|
|
|
''Deferred execution from an 'onClick' link''
|
|
By including a label="..." parameter in the initial {{{<script>}}} marker, the plugin will create a link to an 'onclick' script that will only be executed when that specific link is clicked, rather than running the script each time the tiddler is rendered.
|
|
|
|
''External script source files:''
|
|
You can also load javascript from an external source URL, by including a src="..." parameter in the initial {{{<script>}}} marker (e.g., {{{<script src="demo.js"></script>}}}). This is particularly useful when incorporating third-party javascript libraries for use in custom extensions and plugins. The 'foreign' javascript code remains isolated in a separate file that can be easily replaced whenever an updated library file becomes available.
|
|
|
|
''Display script source in tiddler output''
|
|
By including the keyword parameter "show", in the initial {{{<script>}}} marker, the plugin will include the script source code in the output that it displays in the tiddler.
|
|
|
|
''Defining javascript functions and libraries:''
|
|
Although the external javascript file is loaded while the tiddler content is being rendered, any functions it defines will not be available for use until //after// the rendering has been completed. Thus, you cannot load a library and //immediately// use it's functions within the same tiddler. However, once that tiddler has been loaded, the library functions can be freely used in any tiddler (even the one in which it was initially loaded).
|
|
|
|
To ensure that your javascript functions are always available when needed, you should load the libraries from a tiddler that will be rendered as soon as your TiddlyWiki document is opened. For example, you could put your {{{<script src="..."></script>}}} syntax into a tiddler called LoadScripts, and then add {{{<<tiddler LoadScripts>>}}} in your MainMenu tiddler.
|
|
|
|
Since the MainMenu is always rendered immediately upon opening your document, the library will always be loaded before any other tiddlers that rely upon the functions it defines. Loading an external javascript library does not produce any direct output in the tiddler, so these definitions should have no impact on the appearance of your MainMenu.
|
|
|
|
''Creating dynamic tiddler content''
|
|
An important difference between this implementation of embedded scripting and conventional embedded javascript techniques for web pages is the method used to produce output that is dynamically inserted into the document:
|
|
* In a typical web document, you use the document.write() function to output text sequences (often containing HTML tags) that are then rendered when the entire document is first loaded into the browser window.
|
|
* However, in a ~TiddlyWiki document, tiddlers (and other DOM elements) are created, deleted, and rendered "on-the-fly", so writing directly to the global 'document' object does not produce the results you want (i.e., replacing the embedded script within the tiddler content), and completely replaces the entire ~TiddlyWiki document in your browser window.
|
|
* To allow these scripts to work unmodified, the plugin automatically converts all occurences of document.write() so that the output is inserted into the tiddler content instead of replacing the entire ~TiddlyWiki document.
|
|
|
|
If your script does not use document.write() to create dynamically embedded content within a tiddler, your javascript can, as an alternative, explicitly return a text value that the plugin can then pass through the wikify() rendering engine to insert into the tiddler display. For example, using {{{return "thistext"}}} will produce the same output as {{{document.write("thistext")}}}.
|
|
|
|
//Note: your script code is automatically 'wrapped' inside a function, {{{_out()}}}, so that any return value you provide can be correctly handled by the plugin and inserted into the tiddler. To avoid unpredictable results (and possibly fatal execution errors), this function should never be redefined or called from ''within'' your script code.//
|
|
|
|
''Accessing the ~TiddlyWiki DOM''
|
|
The plugin provides one pre-defined variable, 'place', that is passed in to your javascript code so that it can have direct access to the containing DOM element into which the tiddler output is currently being rendered.
|
|
|
|
Access to this DOM element allows you to create scripts that can:
|
|
* vary their actions based upon the specific location in which they are embedded
|
|
* access 'tiddler-relative' information (use findContainingTiddler(place))
|
|
* perform direct DOM manipulations (when returning wikified text is not enough)
|
|
<<<
|
|
!!!!!Examples
|
|
<<<
|
|
an "alert" message box:
|
|
><script show>
|
|
alert('InlineJavascriptPlugin: this is a demonstration message');
|
|
</script>
|
|
dynamic output:
|
|
><script show>
|
|
return (new Date()).toString();
|
|
</script>
|
|
wikified dynamic output:
|
|
><script show>
|
|
return "link to current user: [["+config.options.txtUserName+"]]";
|
|
</script>
|
|
dynamic output using 'place' to get size information for current tiddler:
|
|
><script show>
|
|
if (!window.story) window.story=window;
|
|
var title=story.findContainingTiddler(place).id.substr(7);
|
|
return title+" is using "+store.getTiddlerText(title).length+" bytes";
|
|
</script>
|
|
creating an 'onclick' button/link that runs a script:
|
|
><script label="click here" show>
|
|
if (!window.story) window.story=window;
|
|
alert("Hello World!\nlinktext='"+place.firstChild.data+"'\ntiddler='"+story.findContainingTiddler(place).id.substr(7)+"'");
|
|
</script>
|
|
loading a script from a source url:
|
|
>http://www.TiddlyTools.com/demo.js contains:
|
|
>>{{{function demo() { alert('this output is from demo(), defined in demo.js') } }}}
|
|
>>{{{alert('InlineJavascriptPlugin: demo.js has been loaded'); }}}
|
|
><script src="demo.js" show>
|
|
return "loading demo.js..."
|
|
</script>
|
|
><script label="click to execute demo() function" show>
|
|
demo()
|
|
</script>
|
|
<<<
|
|
!!!!!Installation
|
|
<<<
|
|
import (or copy/paste) the following tiddlers into your document:
|
|
''InlineJavascriptPlugin'' (tagged with <<tag systemConfig>>)
|
|
<<<
|
|
!!!!!Revision History
|
|
<<<
|
|
''2006.06.01 [1.5.1]'' when calling wikify() on script return value, pass hightlightRegExp and tiddler params so macros that rely on these values can render properly
|
|
''2006.04.19 [1.5.0]'' added 'show' parameter to force display of javascript source code in tiddler output
|
|
''2006.01.05 [1.4.0]'' added support 'onclick' scripts. When label="..." param is present, a button/link is created using the indicated label text, and the script is only executed when the button/link is clicked. 'place' value is set to match the clicked button/link element.
|
|
''2005.12.13 [1.3.1]'' when catching eval error in IE, e.description contains the error text, instead of e.toString(). Fixed error reporting so IE shows the correct response text. Based on a suggestion by UdoBorkowski
|
|
''2005.11.09 [1.3.0]'' for 'inline' scripts (i.e., not scripts loaded with src="..."), automatically replace calls to 'document.write()' with 'place.innerHTML+=' so script output is directed into tiddler content. Based on a suggestion by BradleyMeck
|
|
''2005.11.08 [1.2.0]'' handle loading of javascript from an external URL via src="..." syntax
|
|
''2005.11.08 [1.1.0]'' pass 'place' param into scripts to provide direct DOM access
|
|
''2005.11.08 [1.0.0]'' initial release
|
|
<<<
|
|
!!!!!Credits
|
|
<<<
|
|
This feature was developed by EricShulman from [[ELS Design Studios|http:/www.elsdesign.com]]
|
|
<<<
|
|
!!!!!Code
|
|
***/
|
|
//{{{
|
|
version.extensions.inlineJavascript= {major: 1, minor: 5, revision: 1, date: new Date(2006,6,1)};
|
|
|
|
config.formatters.push( {
|
|
name: "inlineJavascript",
|
|
match: "\\<script",
|
|
lookahead: "\\<script(?: src=\\\"((?:.|\\n)*?)\\\")?(?: label=\\\"((?:.|\\n)*?)\\\")?( show)?\\>((?:.|\\n)*?)\\</script\\>",
|
|
|
|
handler: function(w) {
|
|
var lookaheadRegExp = new RegExp(this.lookahead,"mg");
|
|
lookaheadRegExp.lastIndex = w.matchStart;
|
|
var lookaheadMatch = lookaheadRegExp.exec(w.source)
|
|
if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
|
|
if (lookaheadMatch[1]) { // load a script library
|
|
// make script tag, set src, add to body to execute, then remove for cleanup
|
|
var script = document.createElement("script"); script.src = lookaheadMatch[1];
|
|
document.body.appendChild(script); document.body.removeChild(script);
|
|
}
|
|
if (lookaheadMatch[4]) { // there is script code
|
|
if (lookaheadMatch[3]) // show inline script code in tiddler output
|
|
wikify("{{{\n"+lookaheadMatch[0]+"\n}}}\n",w.output);
|
|
if (lookaheadMatch[2]) { // create a link to an 'onclick' script
|
|
// add a link, define click handler, save code in link (pass 'place'), set link attributes
|
|
var link=createTiddlyElement(w.output,"a",null,"tiddlyLinkExisting",lookaheadMatch[2]);
|
|
link.onclick=function(){try{return(eval(this.code))}catch(e){alert(e.description?e.description:e.toString())}}
|
|
link.code="function _out(place){"+lookaheadMatch[4]+"};_out(this);"
|
|
link.setAttribute("href","javascript:;"); link.setAttribute("title",""); link.style.cursor="pointer";
|
|
}
|
|
else { // run inline script code
|
|
var code="function _out(place){"+lookaheadMatch[4]+"};_out(w.output);"
|
|
code=code.replace(/document.write\(/gi,'place.innerHTML+=(');
|
|
try { var out = eval(code); } catch(e) { out = e.description?e.description:e.toString(); }
|
|
if (out && out.length) wikify(out,w.output,w.highlightRegExp,w.tiddler);
|
|
}
|
|
}
|
|
w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length;
|
|
}
|
|
}
|
|
} )
|
|
//}}}</pre>
|
|
</div>
|
|
<div title="LumieraDesignProcess" modifier="MichaelPloujnikov" modified="200706270317" created="200706181202" tags="process" changecount="5">
|
|
<pre>! Lumiera design process
|
|
A lightweight formalized process how people can add proposals for the Lumiera development.
|
|
|
|
|
|
!! Description
|
|
Use the Wiki at http://www.pipapo.org/pipawiki/Lumiera/DesignProcess to make it easy to add proposals in a well defined manner.
|
|
|
|
I'd like to introduce a slightly formalized process for the ongoing Lumiera planning:
|
|
* Every proposal is instantiated as 'Idea', the author gives other people the opportunity to review and comment on it with extreme prejudice, while still working out details.
|
|
* When the the 'Idea' in a proper form and worked out in most details it becomes a 'Draft'. This 'Draft' need to be carefully reviewed, commented, perhaps corrected and rated by the other Developers.
|
|
* At some point we may decide that a 'Draft' becomes a 'Final' (I leave it open how this decision shall be done for now). 'Final' Documents will be imported into the repository (this wiki, you are reading such a Document right now!).
|
|
|
|
* Sometimes proposals will become dropped for some reason, this is indicated by changing their state to 'Dropped', they still stay in the system for further reference.
|
|
|
|
!!! Pros
|
|
* simple
|
|
* flexible
|
|
* no much rules
|
|
* persistent and at Final stage well documented process
|
|
|
|
!!! Cons
|
|
* could be abused/vandalized (but wiki can use ACL's)
|
|
* depends on my server, this might be unfavorable or unreliable, ymmv.
|
|
* will only work if all or almost all involved people agree on this process
|
|
|
|
!!! Alternatives
|
|
We could use some forum, Trac, Mailinglist or whatever instead.
|
|
|
|
Just for Design documentation I would give [[Bouml|http://bouml.free.fr/]] a try. For myself, I am not very fond of UML Design tools, while Bouml looks quite promising and we could maintain the UML model in git repositories which would be more favorable than this centralized wiki. The backside is that this needs even more agreement between the developers, everyone has to install and use Bouml (and learn its usage) and design is constrained by a external tool.
|
|
|
|
This distributed wiki might be used instead the pipapo.org wiki, investigate that for future.
|
|
|
|
!! Rationale
|
|
Wiki works. It is simple to use and just flexible enough to handle the task. I don't go to install any other software for such tasks on my server. While the design progresses I'd propose to move our work into git repositories and eventually phase this wiki pages out anyways. I'd rather like to start out distributed/git right away .. but git gives us only a fine storage layer, for a design process we need some good presentation layer (later when using git and starting the implementation everyones favorite editor serves for that) I have no better ideas yet to solve the presentation problem other than using this wiki (or maybe Bouml).
|
|
</pre>
|
|
</div>
|
|
<div title="LumieraWiki" modifier="Ichthyostega" modified="200810151550" created="200706172308" tags="portal" changecount="46">
|
|
<pre>[<img[draw/LumiLogo.png]]
|
|
|
|
|
|
|
|
|
|
''Lumiera'' is the emerging professional non linear video editor for Linux
|
|
|
|
|
|
This is the entry point to several [[TiddlyWiki]]-Pages containing the developer and design documentation. The documentation is split in several parts corresponding to the parts of the application. Those TiddlyWiki pages are self modifying HTML pages; we include them into the GIT source tree. For the future we plan to move the contents of these developer doc wikis into a GIT backed uWiki (still under development as of 10/2008)
|
|
* we maintain (semi-) final design docs in DesignDocumentation
|
|
* Things get often worked out on IRC, see IRC-Transcripts for protocols, transcripts and decisions made there
|
|
|
|
----
|
|
!Architecture and Subsystems
|
|
&rarr; see the ArchitectureOverview
|
|
|
|
* Cehteh works on the data backend, see [[this page|backend.html]]
|
|
* Ichthyo focuses mainly on Edit operations and Builder, [[see this separate page|renderengine.html]]
|
|
* Joel builds the Lumiera GUI based on GTK
|
|
* Gmerlin is in charge of [[GAVL|http://gmerlin.sourceforge.net/gavl.html]] for processing of video data
|
|
* Some tools which don't fit somewhere else and are used everywhere are put into a [[Support Library|support_library.html]]
|
|
|
|
!Coding &mdash; Building &mdash; Testing
|
|
how to organize several aspects of the practical coding...
|
|
* what to do in BOUML? &rarr; [[more|whatInBOUML]]
|
|
* how to organize packages, files, includes? &rarr; [[more|SrcTreeStructure]]
|
|
* how to organize the executable to be built?
|
|
* what coding conventions to prefer? &rarr; [[GNU Style|DesignDocumentation]]
|
|
* what [[build system|BuildSystem]] to use?
|
|
* various [[build dependencies|BuildDependenceis]]
|
|
* we embrace __Test Driven Development__. &rarr; Description of [[Test System|TestSh]] and TestSuite
|
|
</pre>
|
|
</div>
|
|
<div title="MainMenu" modifier="CehTeh" modified="200803281345" created="200706172305" changecount="6">
|
|
<pre>GettingStarted
|
|
[[LumieraWiki]]
|
|
[[Compatibility|compatibility.html]]
|
|
[[ToDo|todo.html]]
|
|
[[Backend|backend.html]]
|
|
[[Proc-Layer|renderengine.html]]
|
|
[[Support-Library|support_library.html]]
|
|
[[Admin]]
|
|
<<fullscreen>></pre>
|
|
</div>
|
|
<div title="Manifest" modifier="MichaelPloujnikov" modified="200706270308" created="200706181209" changecount="9">
|
|
<pre>! Manifest
|
|
This Proposal describe the general ideas how the community will work together to create Lumiera.
|
|
|
|
!! Description
|
|
I started with my personal opinions, so far people expressed their commitment with this text.
|
|
|
|
!!! Background
|
|
Cinelerra is quite an old project, there is an original version from heroinewarrior.com and a community fork at cinelerra.org. The original author claims that there was no-one producing usable input despite their proposes while cinelerra was in development, and indeed the cinelerra.org community only feeds back the source released by the original author into their SVN repository and maintains few fixes. There is not much development going on. Some people have created new functionality/features from time to time which have rarely been merged into the main repository and maintained by themselves.
|
|
|
|
The Cinelerra community is a quite loose group of individuals, there is some fluctuation on the developer base and almost all developers have day jobs which restricts their involvement time on the cinelerra project.
|
|
|
|
Some of these things work quite well, there is an overall friendly relation between the involved people. People who know C++ and have the time to edit the source have satisfactory added their own features. The Mailing-list and the IRC channel is also quite helpful and even new users who ask stupid questions are welcome.
|
|
|
|
But there are some bad things too. Notably there is not much progress on the community development. Users don't benefit from new improvements which other people have made. There is a endlessly growing list of bugs and feature requests, when someone sends a patch to the ML he has to invest quite some time to maintain it until it might be merged. Finally we don't know what heroine virtual is working on, until we see his next tarball.
|
|
|
|
!! Solution for "Cinelerra3" / Lumiera
|
|
Cinelerra is heroine's product, this time we should work together with him to make it pleasant and progressing for anyone.
|
|
We are in need of a new development model which is acceptable by all involved people and benefits from the way Cinelerra development worked the years before, without maintaining the bad sides again:
|
|
|
|
# ''Make it easy to contribute''<<br>>Even if it is favorable when we have people which are continuously working on Lumiera / Cinelerra, it's a fact that people show up, send a few patches and then disappear. The development model should be prepared for this by:
|
|
## Good documentation
|
|
## Well defined design and interfaces
|
|
## Establish some coding guidelines to make it easy for others maintain code written by others
|
|
## Prefer known and simple approaches/coding over bleeding edge and highly complex techniques
|
|
# ''Simple access''<<br>>We will use a fully distributed development model using git. I'll open a anonymous pushable repository which anyone can use to publish his changes.
|
|
# ''Freedom to do, or not to do''<<br>>The model allows everyone to do as much as he wants. In a free project there is no way to put demands on people. This is good since it's easy to join and is open for anyone. The community might expect some responsibility for people maintaining their patches, but at worst, things which don't match our expected quality and when there is no one who keeps them up, will be removed. Since we are working in a distributed way with each developer maintaining his own repository and merging from other people, there is no easy way that bad code will leap into the project.
|
|
# ''No Rule is better than a Rule which is not engaged''<<br>>We have to agree on some rules to make teamwork possible. These rules should be kept to a minimum required and accepted by all involved people. It is vital that we can trust each other on simple things, like properly formatted code or that patches one proposes to merge don't break the system etc..
|
|
# ''Legal status must be clear''<<br>>Lumiera is developed under the GPL, every contributor must acknowledge this. Even when we provide anonymous commits, every non trivial patch should be traceable to the person who made it, GPG signatures would be proper here - details need to be worked out.
|
|
# ''All for Lumiera''<<br>>The goal is to make the best Linux video editor to date, nothing less. Everyone puts in their best abilities. This project is not the place to blame people for things where they are not profound, help each other, make things right instead of blaming someone. Everyone should rate himself at what he can do best on the project.
|
|
</pre>
|
|
</div>
|
|
<div title="MarkupPreHead" modifier="Ichthyostega" modified="200708120049" created="200706172303" tags="excludeMissing" changecount="2">
|
|
<pre><!--{{{-->
|
|
<link rel='alternate' type='application/rss+xml' title='RSS' href='index.xml'/>
|
|
<!--}}}-->
|
|
|
|
<style type="text/css">#contentWrapper {display:none;}</style><div id="SplashScreen" style="border: 3px solid #ccc; display: block; text-align: center; width: 320px; margin: 100px auto; padding: 50px; color:#000; font-size: 28px; font-family:Tahoma; background-color:#eee;"><b>Lumiera TiddlyWiki</b> is loading<blink> ...</blink><br><br><span style="font-size: 14px; color:red;">Requires Javascript.</span></div></pre>
|
|
</div>
|
|
<div title="Micro-GPG-HowTo" modifier="CehTeh" modified="200708101901" created="200708101900" changecount="2">
|
|
<pre>I (cehteh) just paste my configs and give very few hints here, refer to the gpg manpage, the gpg documentation, google or ask on IRC for details. Maybe you improve this.
|
|
|
|
First of all you need to install gpg and generate your keypair if you don't have done that already. generating keys is done with {{{gpg --gen-key}}} refer to the manpage for details.
|
|
|
|
Be very careful that your private key has a **GOOD** passphrase and be kept secret.
|
|
|
|
Configuration files are in {{{~/.gnupg}}}
|
|
|
|
Here are the things I have in my {{{~/.gnupg/gpg.conf}}} (there are a lot of comments too, which I leave out here, instead I add some notes as comments)
|
|
{{{
|
|
no-greeting
|
|
|
|
# enter your keyid AC4F4FF4 is mine!
|
|
default-key AC4F4FF4
|
|
|
|
force-v3-sigs
|
|
|
|
compress-algo 1
|
|
|
|
# you can add alternative keyservers
|
|
keyserver hkp://subkeys.pgp.net
|
|
#keyserver blackhole.pca.dfn.de
|
|
|
|
# to let gpg automatically download public keys from the net, makes usage much easier
|
|
keyserver-options auto-key-retrieve
|
|
|
|
# using a gpg agent makes usage easier too, but you should only use it on a personal computer
|
|
use-agent
|
|
}}}
|
|
|
|
|
|
when you want to use the gpg agent you need to add following line to your {{{~/.bash_profile}}} to start the agent on login:
|
|
{{{
|
|
eval $(gpg-agent --daemon)
|
|
}}}
|
|
|
|
|
|
further you need to add following lines to your {{{~/.bash_logout}}} to stop the agent when logging off:
|
|
{{{
|
|
if test "$GPG_AGENT_INFO"; then
|
|
kill -TERM $(echo $GPG_AGENT_INFO | sed -s 's/.*:\(.*\):.*/\1/')
|
|
fi
|
|
}}}
|
|
|
|
further the gpg agent needs some configuration in {{{~/.gnupg/gpg-agent.conf}}}:
|
|
{{{
|
|
pinentry-program /usr/bin/pinentry-gtk-2
|
|
no-grab
|
|
default-cache-ttl 1209600
|
|
max-cache-ttl 1209600
|
|
}}}
|
|
|
|
Note that I am using very long timeouts, refer to the manual about its implications or leave the defaults.
|
|
|
|
</pre>
|
|
</div>
|
|
<div title="PageTemplate" modifier="Ichthyostega" modified="200706260504" created="200701131624" tags="MPTWTheme excludeMissing" server.type="file" server.host="file:///home/ct/.homepage/home.html" server.page.revision="200706110330" changecount="1">
|
|
<pre><!--{{{-->
|
|
<div class='header' macro='gradient vert [[ColorPalette::PrimaryLight]] [[ColorPalette::PrimaryMid]]'>
|
|
<div class='headerShadow'>
|
|
<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;
|
|
<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>
|
|
</div>
|
|
<div class='headerForeground'>
|
|
<span class='siteTitle' refresh='content' tiddler='SiteTitle'></span>&nbsp;
|
|
<span class='siteSubtitle' refresh='content' tiddler='SiteSubtitle'></span>
|
|
</div>
|
|
</div>
|
|
<!-- horizontal MainMenu -->
|
|
<div id='topMenu' refresh='content' tiddler='MainMenu'></div>
|
|
<!-- original MainMenu menu -->
|
|
<!-- <div id='mainMenu' refresh='content' tiddler='MainMenu'></div> -->
|
|
<div id='sidebar'>
|
|
<div id='sidebarOptions' refresh='content' tiddler='SideBarOptions'></div>
|
|
<div id='sidebarTabs' refresh='content' force='true' tiddler='SideBarTabs'></div>
|
|
</div>
|
|
<div id='displayArea'>
|
|
<div id='messageArea'></div>
|
|
<div id='tiddlerDisplay'></div>
|
|
</div>
|
|
<!--}}}-->
|
|
</pre>
|
|
</div>
|
|
<div title="PartTiddlerPlugin" modifier="PauloSoares" modified="200611082325" created="200601251216" tags="excludeLists plugin systemConfig" server.type="file" server.host="file:///home/ct/.homepage/home.html" server.page.revision="200611082325">
|
|
<pre>/***
|
|
|<html><a name="Top"/></html>''Name:''|PartTiddlerPlugin|
|
|
|''Version:''|1.0.6 (2006-11-07)|
|
|
|''Source:''|http://tiddlywiki.abego-software.de/#PartTiddlerPlugin|
|
|
|''Author:''|UdoBorkowski (ub [at] abego-software [dot] de)|
|
|
|''Licence:''|[[BSD open source license]]|
|
|
|''TiddlyWiki:''|2.0|
|
|
|''Browser:''|Firefox 1.0.4+; InternetExplorer 6.0|
|
|
!Table of Content<html><a name="TOC"/></html>
|
|
* <html><a href="javascript:;" onclick="window.scrollAnchorVisible('Description',null, event)">Description, Syntax</a></html>
|
|
* <html><a href="javascript:;" onclick="window.scrollAnchorVisible('Applications',null, event)">Applications</a></html>
|
|
** <html><a href="javascript:;" onclick="window.scrollAnchorVisible('LongTiddler',null, event)">Refering to Paragraphs of a Longer Tiddler</a></html>
|
|
** <html><a href="javascript:;" onclick="window.scrollAnchorVisible('Citation',null, event)">Citation Index</a></html>
|
|
** <html><a href="javascript:;" onclick="window.scrollAnchorVisible('TableCells',null, event)">Creating "multi-line" Table Cells</a></html>
|
|
** <html><a href="javascript:;" onclick="window.scrollAnchorVisible('Tabs',null, event)">Creating Tabs</a></html>
|
|
** <html><a href="javascript:;" onclick="window.scrollAnchorVisible('Sliders',null, event)">Using Sliders</a></html>
|
|
* <html><a href="javascript:;" onclick="window.scrollAnchorVisible('Revisions',null, event)">Revision History</a></html>
|
|
* <html><a href="javascript:;" onclick="window.scrollAnchorVisible('Code',null, event)">Code</a></html>
|
|
!Description<html><a name="Description"/></html>
|
|
With the {{{<part aPartName> ... </part>}}} feature you can structure your tiddler text into separate (named) parts.
|
|
Each part can be referenced as a "normal" tiddler, using the "//tiddlerName//''/''//partName//" syntax (e.g. "About/Features"). E.g. you may create links to the parts, use it in {{{<<tiddler...>>}}} or {{{<<tabs...>>}}} macros etc.
|
|
|
|
''Syntax:''
|
|
|>|''<part'' //partName// [''hidden''] ''>'' //any tiddler content// ''</part>''|
|
|
|//partName//|The name of the part. You may reference a part tiddler with the combined tiddler name "//nameOfContainerTidder//''/''//partName//.|
|
|
|''hidden''|When defined the content of the part is not displayed in the container tiddler. But when the part is explicitly referenced (e.g. in a {{{<<tiddler...>>}}} macro or in a link) the part's content is displayed.|
|
|
|<html><i>any&nbsp;tiddler&nbsp;content</i></html>|<html>The content of the part.<br>A part can have any content that a "normal" tiddler may have, e.g. you may use all the formattings and macros defined.</html>|
|
|
|>|~~Syntax formatting: Keywords in ''bold'', optional parts in [...]. 'or' means that exactly one of the two alternatives must exist.~~|
|
|
<html><sub><a href="javascript:;" onclick="window.scrollAnchorVisible('Top',null, event)">[Top]</sub></a></html>
|
|
|
|
!Applications<html><a name="Applications"/></html>
|
|
!!Refering to Paragraphs of a Longer Tiddler<html><a name="LongTiddler"/></html>
|
|
Assume you have written a long description in a tiddler and now you want to refer to the content of a certain paragraph in that tiddler (e.g. some definition.) Just wrap the text with a ''part'' block, give it a nice name, create a "pretty link" (like {{{[[Discussion Groups|Introduction/DiscussionGroups]]}}}) and you are done.
|
|
|
|
Notice this complements the approach to first writing a lot of small tiddlers and combine these tiddlers to one larger tiddler in a second step (e.g. using the {{{<<tiddler...>>}}} macro). Using the ''part'' feature you can first write a "classic" (longer) text that can be read "from top to bottom" and later "reuse" parts of this text for some more "non-linear" reading.
|
|
|
|
<html><sub><a href="javascript:;" onclick="window.scrollAnchorVisible('Top',null, event)">[Top]</sub></a></html>
|
|
|
|
!!Citation Index<html><a name="Citation"/></html>
|
|
Create a tiddler "Citations" that contains your "citations".
|
|
Wrap every citation with a part and a proper name.
|
|
|
|
''Example''
|
|
{{{
|
|
<part BAX98>Baxter, Ira D. et al: //Clone Detection Using Abstract Syntax Trees.//
|
|
in //Proc. ICSM//, 1998.</part>
|
|
|
|
<part BEL02>Bellon, Stefan: //Vergleich von Techniken zur Erkennung duplizierten Quellcodes.//
|
|
Thesis, Uni Stuttgart, 2002.</part>
|
|
|
|
<part DUC99>Ducasse, Stéfane et al: //A Language Independent Approach for Detecting Duplicated Code.//
|
|
in //Proc. ICSM//, 1999.</part>
|
|
}}}
|
|
|
|
You may now "cite" them just by using a pretty link like {{{[[Citations/BAX98]]}}} or even more pretty, like this {{{[[BAX98|Citations/BAX98]]}}}.
|
|
|
|
<html><sub><a href="javascript:;" onclick="window.scrollAnchorVisible('Top',null, event)">[Top]</sub></a></html>
|
|
|
|
!!Creating "multi-line" Table Cells<html><a name="TableCells"/></html>
|
|
You may have noticed that it is hard to create table cells with "multi-line" content. E.g. if you want to create a bullet list inside a table cell you cannot just write the bullet list
|
|
{{{
|
|
* Item 1
|
|
* Item 2
|
|
* Item 3
|
|
}}}
|
|
into a table cell (i.e. between the | ... | bars) because every bullet item must start in a new line but all cells of a table row must be in one line.
|
|
|
|
Using the ''part'' feature this problem can be solved. Just create a hidden part that contains the cells content and use a {{{<<tiddler >>}}} macro to include its content in the table's cell.
|
|
|
|
''Example''
|
|
{{{
|
|
|!Subject|!Items|
|
|
|subject1|<<tiddler ./Cell1>>|
|
|
|subject2|<<tiddler ./Cell2>>|
|
|
|
|
<part Cell1 hidden>
|
|
* Item 1
|
|
* Item 2
|
|
* Item 3
|
|
</part>
|
|
...
|
|
}}}
|
|
|
|
Notice that inside the {{{<<tiddler ...>>}}} macro you may refer to the "current tiddler" using the ".".
|
|
|
|
BTW: The same approach can be used to create bullet lists with items that contain more than one line.
|
|
|
|
<html><sub><a href="javascript:;" onclick="window.scrollAnchorVisible('Top',null, event)">[Top]</sub></a></html>
|
|
|
|
!!Creating Tabs<html><a name="Tabs"/></html>
|
|
The build-in {{{<<tabs ...>>}}} macro requires that you defined an additional tiddler for every tab it displays. When you want to have "nested" tabs you need to define a tiddler for the "main tab" and one for every tab it contains. I.e. the definition of a set of tabs that is visually displayed at one place is distributed across multiple tiddlers.
|
|
|
|
With the ''part'' feature you can put the complete definition in one tiddler, making it easier to keep an overview and maintain the tab sets.
|
|
|
|
''Example''
|
|
The standard tabs at the sidebar are defined by the following eight tiddlers:
|
|
* SideBarTabs
|
|
* TabAll
|
|
* TabMore
|
|
* TabMoreMissing
|
|
* TabMoreOrphans
|
|
* TabMoreShadowed
|
|
* TabTags
|
|
* TabTimeline
|
|
|
|
Instead of these eight tiddlers one could define the following SideBarTabs tiddler that uses the ''part'' feature:
|
|
{{{
|
|
<<tabs txtMainTab
|
|
Timeline Timeline SideBarTabs/Timeline
|
|
All 'All tiddlers' SideBarTabs/All
|
|
Tags 'All tags' SideBarTabs/Tags
|
|
More 'More lists' SideBarTabs/More>>
|
|
<part Timeline hidden><<timeline>></part>
|
|
<part All hidden><<list all>></part>
|
|
<part Tags hidden><<allTags>></part>
|
|
<part More hidden><<tabs txtMoreTab
|
|
Missing 'Missing tiddlers' SideBarTabs/Missing
|
|
Orphans 'Orphaned tiddlers' SideBarTabs/Orphans
|
|
Shadowed 'Shadowed tiddlers' SideBarTabs/Shadowed>></part>
|
|
<part Missing hidden><<list missing>></part>
|
|
<part Orphans hidden><<list orphans>></part>
|
|
<part Shadowed hidden><<list shadowed>></part>
|
|
}}}
|
|
|
|
Notice that you can easily "overwrite" individual parts in separate tiddlers that have the full name of the part.
|
|
|
|
E.g. if you don't like the classic timeline tab but only want to see the 100 most recent tiddlers you could create a tiddler "~SideBarTabs/Timeline" with the following content:
|
|
{{{
|
|
<<forEachTiddler
|
|
sortBy 'tiddler.modified' descending
|
|
write '(index < 100) ? "* [["+tiddler.title+"]]\n":""'>>
|
|
}}}
|
|
<html><sub><a href="javascript:;" onclick="window.scrollAnchorVisible('Top',null, event)">[Top]</sub></a></html>
|
|
|
|
!!Using Sliders<html><a name="Sliders"/></html>
|
|
Very similar to the build-in {{{<<tabs ...>>}}} macro (see above) the {{{<<slider ...>>}}} macro requires that you defined an additional tiddler that holds the content "to be slid". You can avoid creating this extra tiddler by using the ''part'' feature
|
|
|
|
''Example''
|
|
In a tiddler "About" we may use the slider to show some details that are documented in the tiddler's "Details" part.
|
|
{{{
|
|
...
|
|
<<slider chkAboutDetails About/Details details "Click here to see more details">>
|
|
<part Details hidden>
|
|
To give you a better overview ...
|
|
</part>
|
|
...
|
|
}}}
|
|
|
|
Notice that putting the content of the slider into the slider's tiddler also has an extra benefit: When you decide you need to edit the content of the slider you can just doubleclick the content, the tiddler opens for editing and you can directly start editing the content (in the part section). In the "old" approach you would doubleclick the tiddler, see that the slider is using tiddler X, have to look for the tiddler X and can finally open it for editing. So using the ''part'' approach results in a much short workflow.
|
|
|
|
<html><sub><a href="javascript:;" onclick="window.scrollAnchorVisible('Top',null, event)">[Top]</sub></a></html>
|
|
|
|
!Revision history<html><a name="Revisions"/></html>
|
|
* v1.0.6 (2006-11-07)
|
|
** Bugfix: cannot edit tiddler when UploadPlugin by Bidix is installed. Thanks to José Luis González Castro for reporting the bug.
|
|
* v1.0.5 (2006-03-02)
|
|
** Bugfix: Example with multi-line table cells does not work in IE6. Thanks to Paulo Soares for reporting the bug.
|
|
* v1.0.4 (2006-02-28)
|
|
** Bugfix: Shadow tiddlers cannot be edited (in TW 2.0.6). Thanks to Torsten Vanek for reporting the bug.
|
|
* v1.0.3 (2006-02-26)
|
|
** Adapt code to newly introduced Tiddler.prototype.isReadOnly() function (in TW 2.0.6). Thanks to Paulo Soares for reporting the problem.
|
|
* v1.0.2 (2006-02-05)
|
|
** Also allow other macros than the "tiddler" macro use the "." in the part reference (to refer to "this" tiddler)
|
|
* v1.0.1 (2006-01-27)
|
|
** Added Table of Content for plugin documentation. Thanks to RichCarrillo for suggesting.
|
|
** Bugfix: newReminder plugin does not work when PartTiddler is installed. Thanks to PauloSoares for reporting.
|
|
* v1.0.0 (2006-01-25)
|
|
** initial version
|
|
<html><sub><a href="javascript:;" onclick="window.scrollAnchorVisible('Top',null, event)">[Top]</sub></a></html>
|
|
|
|
!Code<html><a name="Code"/></html>
|
|
<html><sub><a href="javascript:;" onclick="window.scrollAnchorVisible('Top',null, event)">[Top]</sub></a></html>
|
|
***/
|
|
//{{{
|
|
//============================================================================
|
|
// PartTiddlerPlugin
|
|
|
|
// Ensure that the PartTiddler Plugin is only installed once.
|
|
//
|
|
if (!version.extensions.PartTiddlerPlugin) {
|
|
|
|
|
|
|
|
version.extensions.PartTiddlerPlugin = {
|
|
major: 1, minor: 0, revision: 6,
|
|
date: new Date(2006, 10, 7),
|
|
type: 'plugin',
|
|
source: "http://tiddlywiki.abego-software.de/#PartTiddlerPlugin"
|
|
};
|
|
|
|
if (!window.abego) window.abego = {};
|
|
if (version.major < 2) alertAndThrow("PartTiddlerPlugin requires TiddlyWiki 2.0 or newer.");
|
|
|
|
//============================================================================
|
|
// Common Helpers
|
|
|
|
// Looks for the next newline, starting at the index-th char of text.
|
|
//
|
|
// If there are only whitespaces between index and the newline
|
|
// the index behind the newline is returned,
|
|
// otherwise (or when no newline is found) index is returned.
|
|
//
|
|
var skipEmptyEndOfLine = function(text, index) {
|
|
var re = /(\n|[^\s])/g;
|
|
re.lastIndex = index;
|
|
var result = re.exec(text);
|
|
return (result && text.charAt(result.index) == '\n')
|
|
? result.index+1
|
|
: index;
|
|
}
|
|
|
|
|
|
//============================================================================
|
|
// Constants
|
|
|
|
var partEndOrStartTagRE = /(<\/part>)|(<part(?:\s+)((?:[^>])+)>)/mg;
|
|
var partEndTagREString = "<\\/part>";
|
|
var partEndTagString = "</part>";
|
|
|
|
//============================================================================
|
|
// Plugin Specific Helpers
|
|
|
|
// Parse the parameters inside a <part ...> tag and return the result.
|
|
//
|
|
// @return [may be null] {partName: ..., isHidden: ...}
|
|
//
|
|
var parseStartTagParams = function(paramText) {
|
|
var params = paramText.readMacroParams();
|
|
if (params.length == 0 || params[0].length == 0) return null;
|
|
|
|
var name = params[0];
|
|
var paramsIndex = 1;
|
|
var hidden = false;
|
|
if (paramsIndex < params.length) {
|
|
hidden = params[paramsIndex] == "hidden";
|
|
paramsIndex++;
|
|
}
|
|
|
|
return {
|
|
partName: name,
|
|
isHidden: hidden
|
|
};
|
|
}
|
|
|
|
// Returns the match to the next (end or start) part tag in the text,
|
|
// starting the search at startIndex.
|
|
//
|
|
// When no such tag is found null is returned, otherwise a "Match" is returned:
|
|
// [0]: full match
|
|
// [1]: matched "end" tag (or null when no end tag match)
|
|
// [2]: matched "start" tag (or null when no start tag match)
|
|
// [3]: content of start tag (or null if no start tag match)
|
|
//
|
|
var findNextPartEndOrStartTagMatch = function(text, startIndex) {
|
|
var re = new RegExp(partEndOrStartTagRE);
|
|
re.lastIndex = startIndex;
|
|
var match = re.exec(text);
|
|
return match;
|
|
}
|
|
|
|
//============================================================================
|
|
// Formatter
|
|
|
|
// Process the <part ...> ... </part> starting at (w.source, w.matchStart) for formatting.
|
|
//
|
|
// @return true if a complete part section (including the end tag) could be processed, false otherwise.
|
|
//
|
|
var handlePartSection = function(w) {
|
|
var tagMatch = findNextPartEndOrStartTagMatch(w.source, w.matchStart);
|
|
if (!tagMatch) return false;
|
|
if (tagMatch.index != w.matchStart || !tagMatch[2]) return false;
|
|
|
|
// Parse the start tag parameters
|
|
var arguments = parseStartTagParams(tagMatch[3]);
|
|
if (!arguments) return false;
|
|
|
|
// Continue processing
|
|
var startTagEndIndex = skipEmptyEndOfLine(w.source, tagMatch.index + tagMatch[0].length);
|
|
var endMatch = findNextPartEndOrStartTagMatch(w.source, startTagEndIndex);
|
|
if (endMatch && endMatch[1]) {
|
|
if (!arguments.isHidden) {
|
|
w.nextMatch = startTagEndIndex;
|
|
w.subWikify(w.output,partEndTagREString);
|
|
}
|
|
w.nextMatch = skipEmptyEndOfLine(w.source, endMatch.index + endMatch[0].length);
|
|
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
config.formatters.push( {
|
|
name: "part",
|
|
match: "<part\\s+[^>]+>",
|
|
|
|
handler: function(w) {
|
|
if (!handlePartSection(w)) {
|
|
w.outputText(w.output,w.matchStart,w.matchStart+w.matchLength);
|
|
}
|
|
}
|
|
} )
|
|
|
|
//============================================================================
|
|
// Extend "fetchTiddler" functionality to also recognize "part"s of tiddlers
|
|
// as tiddlers.
|
|
|
|
var currentParent = null; // used for the "." parent (e.g. in the "tiddler" macro)
|
|
|
|
// Return the match to the first <part ...> tag of the text that has the
|
|
// requrest partName.
|
|
//
|
|
// @return [may be null]
|
|
//
|
|
var findPartStartTagByName = function(text, partName) {
|
|
var i = 0;
|
|
|
|
while (true) {
|
|
var tagMatch = findNextPartEndOrStartTagMatch(text, i);
|
|
if (!tagMatch) return null;
|
|
|
|
if (tagMatch[2]) {
|
|
// Is start tag
|
|
|
|
// Check the name
|
|
var arguments = parseStartTagParams(tagMatch[3]);
|
|
if (arguments && arguments.partName == partName) {
|
|
return tagMatch;
|
|
}
|
|
}
|
|
i += tagMatch[0].length;
|
|
}
|
|
}
|
|
|
|
// Return the part "partName" of the given parentTiddler as a "readOnly" Tiddler
|
|
// object, using fullName as the Tiddler's title.
|
|
//
|
|
// All remaining properties of the new Tiddler (tags etc.) are inherited from
|
|
// the parentTiddler.
|
|
//
|
|
// @return [may be null]
|
|
//
|
|
var getPart = function(parentTiddler, partName, fullName) {
|
|
var text = parentTiddler.text;
|
|
var startTag = findPartStartTagByName(text, partName);
|
|
if (!startTag) return null;
|
|
|
|
var endIndexOfStartTag = skipEmptyEndOfLine(text, startTag.index+startTag[0].length);
|
|
var indexOfEndTag = text.indexOf(partEndTagString, endIndexOfStartTag);
|
|
|
|
if (indexOfEndTag >= 0) {
|
|
var partTiddlerText = text.substring(endIndexOfStartTag,indexOfEndTag);
|
|
var partTiddler = new Tiddler();
|
|
partTiddler.set(
|
|
fullName,
|
|
partTiddlerText,
|
|
parentTiddler.modifier,
|
|
parentTiddler.modified,
|
|
parentTiddler.tags,
|
|
parentTiddler.created);
|
|
partTiddler.abegoIsPartTiddler = true;
|
|
return partTiddler;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
// Hijack the store.fetchTiddler to recognize the "part" addresses.
|
|
//
|
|
|
|
var oldFetchTiddler = store.fetchTiddler ;
|
|
store.fetchTiddler = function(title) {
|
|
var result = oldFetchTiddler.apply(this, arguments);
|
|
if (!result && title) {
|
|
var i = title.lastIndexOf('/');
|
|
if (i > 0) {
|
|
var parentName = title.substring(0, i);
|
|
var partName = title.substring(i+1);
|
|
var parent = (parentName == ".")
|
|
? currentParent
|
|
: oldFetchTiddler.apply(this, [parentName]);
|
|
if (parent) {
|
|
return getPart(parent, partName, parent.title+"/"+partName);
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
};
|
|
|
|
|
|
// The user must not edit a readOnly/partTiddler
|
|
//
|
|
|
|
config.commands.editTiddler.oldIsReadOnlyFunction = Tiddler.prototype.isReadOnly;
|
|
|
|
Tiddler.prototype.isReadOnly = function() {
|
|
// Tiddler.isReadOnly was introduced with TW 2.0.6.
|
|
// For older version we explicitly check the global readOnly flag
|
|
if (config.commands.editTiddler.oldIsReadOnlyFunction) {
|
|
if (config.commands.editTiddler.oldIsReadOnlyFunction.apply(this, arguments)) return true;
|
|
} else {
|
|
if (readOnly) return true;
|
|
}
|
|
|
|
return this.abegoIsPartTiddler;
|
|
}
|
|
|
|
config.commands.editTiddler.handler = function(event,src,title)
|
|
{
|
|
var t = store.getTiddler(title);
|
|
// Edit the tiddler if it either is not a tiddler (but a shadowTiddler)
|
|
// or the tiddler is not readOnly
|
|
if(!t || !t.abegoIsPartTiddler)
|
|
{
|
|
clearMessage();
|
|
story.displayTiddler(null,title,DEFAULT_EDIT_TEMPLATE);
|
|
story.focusTiddler(title,"text");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// To allow the "./partName" syntax in macros we need to hijack
|
|
// the invokeMacro to define the "currentParent" while it is running.
|
|
//
|
|
var oldInvokeMacro = window.invokeMacro;
|
|
function myInvokeMacro(place,macro,params,wikifier,tiddler) {
|
|
var oldCurrentParent = currentParent;
|
|
if (tiddler) currentParent = tiddler;
|
|
try {
|
|
oldInvokeMacro.apply(this, arguments);
|
|
} finally {
|
|
currentParent = oldCurrentParent;
|
|
}
|
|
}
|
|
window.invokeMacro = myInvokeMacro;
|
|
|
|
// Scroll the anchor anchorName in the viewer of the given tiddler visible.
|
|
// When no tiddler is defined use the tiddler of the target given event is used.
|
|
window.scrollAnchorVisible = function(anchorName, tiddler, evt) {
|
|
var tiddlerElem = null;
|
|
if (tiddler) {
|
|
tiddlerElem = document.getElementById(story.idPrefix + tiddler);
|
|
}
|
|
if (!tiddlerElem && evt) {
|
|
var target = resolveTarget(evt);
|
|
tiddlerElem = story.findContainingTiddler(target);
|
|
}
|
|
if (!tiddlerElem) return;
|
|
|
|
var children = tiddlerElem.getElementsByTagName("a");
|
|
for (var i = 0; i < children.length; i++) {
|
|
var child = children[i];
|
|
var name = child.getAttribute("name");
|
|
if (name == anchorName) {
|
|
var y = findPosY(child);
|
|
window.scrollTo(0,y);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
} // of "install only once"
|
|
//}}}
|
|
|
|
/***
|
|
<html><sub><a href="javascript:;" onclick="scrollAnchorVisible('Top',null, event)">[Top]</sub></a></html>
|
|
|
|
!Licence and Copyright
|
|
Copyright (c) abego Software ~GmbH, 2006 ([[www.abego-software.de|http://www.abego-software.de]])
|
|
|
|
Redistribution and use in source and binary forms, with or without modification,
|
|
are permitted provided that the following conditions are met:
|
|
|
|
Redistributions of source code must retain the above copyright notice, this
|
|
list of conditions and the following disclaimer.
|
|
|
|
Redistributions in binary form must reproduce the above copyright notice, this
|
|
list of conditions and the following disclaimer in the documentation and/or other
|
|
materials provided with the distribution.
|
|
|
|
Neither the name of abego Software nor the names of its contributors may be
|
|
used to endorse or promote products derived from this software without specific
|
|
prior written permission.
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
|
SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
|
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
|
DAMAGE.
|
|
|
|
<html><sub><a href="javascript:;" onclick="scrollAnchorVisible('Top',null, event)">[Top]</sub></a></html>
|
|
***/</pre>
|
|
</div>
|
|
<div title="RSSReaderPlugin" modifier="BidiX" modified="200704220833" created="200704132044" tags="systemConfig" server.type="file" server.host="file:///home/ct/.homepage/home.html" server.page.revision="200704220833">
|
|
<pre>/***
|
|
|''Name:''|RSSReaderPlugin|
|
|
|''Description:''|This plugin provides a RSSReader for TiddlyWiki|
|
|
|''Version:''|1.1.1|
|
|
|''Date:''|Apr 21, 2007|
|
|
|''Source:''|http://tiddlywiki.bidix.info/#RSSReaderPlugin|
|
|
|''Documentation:''|http://tiddlywiki.bidix.info/#RSSReaderPluginDoc|
|
|
|''Author:''|BidiX (BidiX (at) bidix (dot) info)|
|
|
|''Credit:''|BramChen for RssNewsMacro|
|
|
|''License:''|[[BSD open source license|http://tiddlywiki.bidix.info/#%5B%5BBSD%20open%20source%20license%5D%5D ]]|
|
|
|''~CoreVersion:''|2.2.0|
|
|
|''OptionalRequires:''|http://www.tiddlytools.com/#NestedSlidersPlugin|
|
|
***/
|
|
//{{{
|
|
version.extensions.RSSReaderPlugin = {
|
|
major: 1, minor: 1, revision: 1,
|
|
date: new Date("Apr 21, 2007"),
|
|
source: "http://TiddlyWiki.bidix.info/#RSSReaderPlugin",
|
|
author: "BidiX",
|
|
coreVersion: '2.2.0'
|
|
};
|
|
|
|
config.macros.rssReader = {
|
|
dateFormat: "DDD, DD MMM YYYY",
|
|
itemStyle: "display: block;border: 1px solid black;padding: 5px;margin: 5px;", //useed '@@'+itemStyle+itemText+'@@'
|
|
msg:{
|
|
permissionDenied: "Permission to read preferences was denied.",
|
|
noRSSFeed: "No RSS Feed at this address %0",
|
|
urlNotAccessible: " Access to %0 is not allowed"
|
|
},
|
|
cache: [], // url => XMLHttpRequest.responseXML
|
|
desc: "noDesc",
|
|
|
|
handler: function(place,macroName,params,wikifier,paramString,tiddler) {
|
|
var desc = params[0];
|
|
var feedURL = params[1];
|
|
var toFilter = (params[2] ? true : false);
|
|
var filterString = (toFilter?(params[2].substr(0,1) == ' '? tiddler.title:params[2]):'');
|
|
var place = createTiddlyElement(place, "div", "RSSReader");
|
|
wikify("^^<<rssFeedUpdate "+feedURL+" [[" + tiddler.title + "]]>>^^\n",place);
|
|
if (this.cache[feedURL]) {
|
|
this.displayRssFeed(this.cache[feedURL], feedURL, place, desc, toFilter, filterString);
|
|
}
|
|
else {
|
|
var r = loadRemoteFile(feedURL,config.macros.rssReader.processResponse, [place, desc, toFilter, filterString]);
|
|
if (typeof r == "string")
|
|
displayMessage(r);
|
|
}
|
|
|
|
},
|
|
|
|
// callback for loadRemoteFile
|
|
// params : [place, desc, toFilter, filterString]
|
|
processResponse: function(status, params, responseText, url, xhr) { // feedURL, place, desc, toFilter, filterString) {
|
|
if (window.netscape){
|
|
try {
|
|
if (document.location.protocol.indexOf("http") == -1) {
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
|
|
}
|
|
}
|
|
catch (e) { displayMessage(e.description?e.description:e.toString()); }
|
|
}
|
|
if (xhr.status == httpStatus.NotFound)
|
|
{
|
|
displayMessage(config.macros.rssReader.noRSSFeed.format([url]));
|
|
return;
|
|
}
|
|
if (!status)
|
|
{
|
|
displayMessage(config.macros.rssReader.noRSSFeed.format([url]));
|
|
return;
|
|
}
|
|
if (xhr.responseXML) {
|
|
// response is interpreted as XML
|
|
config.macros.rssReader.cache[url] = xhr.responseXML;
|
|
config.macros.rssReader.displayRssFeed(xhr.responseXML, params[0], url, params[1], params[2], params[3]);
|
|
}
|
|
else {
|
|
if (responseText.substr(0,5) == "<?xml") {
|
|
// response exists but not return as XML -> try to parse it
|
|
var dom = (new DOMParser()).parseFromString(responseText, "text/xml");
|
|
if (dom) {
|
|
// parsing successful so use it
|
|
config.macros.rssReader.cache[url] = dom;
|
|
config.macros.rssReader.displayRssFeed(dom, params[0], url, params[1], params[2], params[3]);
|
|
return;
|
|
}
|
|
}
|
|
// no XML display as html
|
|
wikify("<html>" + responseText + "</html>", params[0]);
|
|
displayMessage(config.macros.rssReader.msg.noRSSFeed.format([url]));
|
|
}
|
|
},
|
|
|
|
// explore down the DOM tree
|
|
displayRssFeed: function(xml, place, feedURL, desc, toFilter, filterString){
|
|
// Channel
|
|
var chanelNode = xml.getElementsByTagName('channel').item(0);
|
|
var chanelTitleElement = (chanelNode ? chanelNode.getElementsByTagName('title').item(0) : null);
|
|
var chanelTitle = "";
|
|
if ((chanelTitleElement) && (chanelTitleElement.firstChild))
|
|
chanelTitle = chanelTitleElement.firstChild.nodeValue;
|
|
var chanelLinkElement = (chanelNode ? chanelNode.getElementsByTagName('link').item(0) : null);
|
|
var chanelLink = "";
|
|
if (chanelLinkElement)
|
|
chanelLink = chanelLinkElement.firstChild.nodeValue;
|
|
var titleTxt = "!![["+chanelTitle+"|"+chanelLink+"]]\n";
|
|
var title = createTiddlyElement(place,"div",null,"ChanelTitle",null);
|
|
wikify(titleTxt,title);
|
|
// ItemList
|
|
var itemList = xml.getElementsByTagName('item');
|
|
var article = createTiddlyElement(place,"ul",null,null,null);
|
|
var lastDate;
|
|
var re;
|
|
if (toFilter)
|
|
re = new RegExp(filterString.escapeRegExp());
|
|
for (var i=0; i<itemList.length; i++){
|
|
var titleElm = itemList[i].getElementsByTagName('title').item(0);
|
|
var titleText = (titleElm ? titleElm.firstChild.nodeValue : '');
|
|
if (toFilter && ! titleText.match(re)) {
|
|
continue;
|
|
}
|
|
var descText = '';
|
|
descElem = itemList[i].getElementsByTagName('description').item(0);
|
|
if (descElem){
|
|
try{
|
|
for (var ii=0; ii<descElem.childNodes.length; ii++) {
|
|
descText += descElem.childNodes[ii].nodeValue;
|
|
}
|
|
}
|
|
catch(e){}
|
|
descText = descText.replace(/<br \/>/g,'\n');
|
|
if (desc == "asHtml")
|
|
descText = "<html>"+descText+"</html>";
|
|
}
|
|
var linkElm = itemList[i].getElementsByTagName("link").item(0);
|
|
var linkURL = linkElm.firstChild.nodeValue;
|
|
var pubElm = itemList[i].getElementsByTagName('pubDate').item(0);
|
|
var pubDate;
|
|
if (!pubElm) {
|
|
pubElm = itemList[i].getElementsByTagName('date').item(0); // for del.icio.us
|
|
if (pubElm) {
|
|
pubDate = pubElm.firstChild.nodeValue;
|
|
pubDate = this.formatDateString(this.dateFormat, pubDate);
|
|
}
|
|
else {
|
|
pubDate = '0';
|
|
}
|
|
}
|
|
else {
|
|
pubDate = (pubElm ? pubElm.firstChild.nodeValue : 0);
|
|
pubDate = this.formatDate(this.dateFormat, pubDate);
|
|
}
|
|
titleText = titleText.replace(/\[|\]/g,'');
|
|
var rssText = '*'+'[[' + titleText + '|' + linkURL + ']]' + '' ;
|
|
if ((desc != "noDesc") && descText){
|
|
rssText = rssText.replace(/\n/g,' ');
|
|
descText = '@@'+this.itemStyle+descText + '@@\n';
|
|
if (version.extensions.nestedSliders){
|
|
descText = '+++[...]' + descText + '===';
|
|
}
|
|
rssText = rssText + descText;
|
|
}
|
|
var story;
|
|
if ((lastDate != pubDate) && ( pubDate != '0')) {
|
|
story = createTiddlyElement(article,"li",null,"RSSItem",pubDate);
|
|
lastDate = pubDate;
|
|
}
|
|
else {
|
|
lastDate = pubDate;
|
|
}
|
|
story = createTiddlyElement(article,"div",null,"RSSItem",null);
|
|
wikify(rssText,story);
|
|
}
|
|
},
|
|
|
|
formatDate: function(template, date){
|
|
var dateString = new Date(date);
|
|
// template = template.replace(/hh|mm|ss/g,'');
|
|
return dateString.formatString(template);
|
|
},
|
|
|
|
formatDateString: function(template, date){
|
|
var dateString = new Date(date.substr(0,4), date.substr(5,2) - 1, date.substr(8,2)
|
|
);
|
|
return dateString.formatString(template);
|
|
}
|
|
|
|
};
|
|
|
|
config.macros.rssFeedUpdate = {
|
|
label: "Update",
|
|
prompt: "Clear the cache and redisplay this RssFeed",
|
|
handler: function(place,macroName,params) {
|
|
var feedURL = params[0];
|
|
var tiddlerTitle = params[1];
|
|
createTiddlyButton(place, this.label, this.prompt,
|
|
function () {
|
|
if (config.macros.rssReader.cache[feedURL]) {
|
|
config.macros.rssReader.cache[feedURL] = null;
|
|
}
|
|
story.refreshTiddler(tiddlerTitle,null, true);
|
|
return false;});
|
|
}
|
|
};
|
|
|
|
//}}}
|
|
</pre>
|
|
</div>
|
|
<div title="RSSReaderPluginDoc" modifier="Ichthyostega" modified="200706260503" created="200704132051" tags="Doc RSSReader excludeMissing" server.type="file" server.host="file:///home/ct/.homepage/home.html" server.page.revision="200704220857" changecount="1">
|
|
<pre>//last update: RSSReaderPlugin v 1.1.1//
|
|
|
|
!Description
|
|
This plugin provides a RSSReader for TiddlyWiki
|
|
* It accesses asynchronously an RSSFeed
|
|
*Depending on the chanel item format, each item could be written as :
|
|
**simple text wikified
|
|
**html
|
|
|
|
!Usage
|
|
{{{
|
|
<<rssReader noDesc|asHtml|asText rssUrl ['filtering string']>>
|
|
noDesc: only title of item is printed
|
|
|
|
asHtml: if you know that description contain html (links, img ...),
|
|
the text is enclosed with <html> </html> tags
|
|
|
|
asText: if the description should not be interpreted as html the
|
|
description is wikified
|
|
|
|
rssUrl: the rssFeed url that could be accessed.
|
|
|
|
'filtering string': if present, the rssfeed item title must contained
|
|
this string to be displayed.
|
|
If 'filering string' contained space characters only, the tiddler
|
|
title is used for filtering.
|
|
|
|
}}}
|
|
|
|
For security reasons, if the TiddlyWiki is accessed from http, a ProxyService should be used to access an rssFeed from an other site.
|
|
|
|
!examples
|
|
| !reader | !RSSFeed type | !working from |
|
|
| BidiXTWRSS | Description asHtml | file: or tiddlywiki.bidix.info |
|
|
| [[Le Monde]] | Description asText | file: or tiddlywiki.bidix.info using proxy |
|
|
| YahooNewsSport | Description asHtml | file: or tiddlywiki.bidix.info using proxy |
|
|
| TiddlyWikiRSS | Description asHtml | file: or tiddlywiki.bidix.info using proxy |
|
|
| [[Libération]] | noDesc | file: or tiddlywiki.bidix.info using proxy |
|
|
| [[TestComment]] | asText and filters | file: or tiddlywiki.bidix.info using proxy |
|
|
see : <<tag RSSFeed>> for the full list.
|
|
|
|
!Revision history
|
|
* V1.1.0 (2207/04/13)
|
|
**No more import functions
|
|
* V1.0.0 (2006/11/11)
|
|
**refactoring using core loadRemoteFile function
|
|
**import using new tiddlywiki:tiddler element
|
|
**import and presentation preserved without EricShulman's NestedSliderPlugin
|
|
**better display of items
|
|
* v0.3.0 (24/08/2006)
|
|
** Filter on RSS item title
|
|
** Place to display redefined for asynchronous processing
|
|
* v0.2.2 (22/08/2006)
|
|
**Haloscan feed has no pubDate.
|
|
* v0.2.1 (08/05/2006)
|
|
* v0.2.0 (01/05/2006)
|
|
**Small adapations for del.icio.us feed
|
|
* v0.1.1 (28/04/2006)
|
|
**Bug : Channel without title
|
|
* v0.1.0 (24/04/2006)
|
|
** initial release
|
|
|
|
|
|
</pre>
|
|
</div>
|
|
<div title="RepositorySetup" modifier="Ichthyostega" modified="200707022305" created="200706280015" tags="process excludeMissing" changecount="3">
|
|
<pre>||'''State'''||''Final''||
|
|
||'''Date'''||[[Date(2007-06-09T00:48:02Z)]]||
|
|
||'''Proposed by'''||["ct"]||
|
|
|
|
! Repository Setup
|
|
Here we describe the Directory hierarchy and how the git repository are set up.
|
|
|
|
!! Description
|
|
Use "./admin/treeinfo.sh" to produce a annotated directory tree like this:
|
|
{{{
|
|
. : The root dir for the Lumiera project
|
|
./admin : administrative scripts
|
|
./admin/git_hooks : git hook scripts
|
|
./build : build dir
|
|
./doc : documentation
|
|
./doc/devel : developer documentation, extra sources, doxygen
|
|
./doc/devel/uml : Bouml generated HTML doc
|
|
./doc/user : user documentation in texinfo
|
|
./oldsrc : Cinelerra2 sources, added per case when needed
|
|
./src : every components source in a own subdir here
|
|
./tests : test suite
|
|
./tests/bugs : tests against reported bugs
|
|
./uml : uml models, created with bouml
|
|
./uml/lumiera : Lumiera UML model
|
|
./wiki : tiddlywiki for semi-persistent documentation
|
|
}}}
|
|
|
|
!! New Directories:
|
|
|
|
When you need to add a new mariginally important directory please provides a file named DIR_INFO within this directory. It's first line should note the purpose of the directory in a few words (less than 40 characters). The following lines are free form description about the details.
|
|
|
|
!! Submodules:
|
|
|
|
We want to use the new GIT feature of "Superprojects and Submodules" when it is ready for general use.
|
|
Then we will transform several subtrees into separate GIT repos which will be linked to from the main
|
|
Project (then called the "Superproject") as submodules.
|
|
|
|
!!! Pros
|
|
* because its a text-like structure, it is partially self-documenting
|
|
* GIT is flexible and with the planned submodules it can be separated in chunks of manageable size if necessary
|
|
|
|
!!! Cons
|
|
* can get large and confusing
|
|
* has no real "portal" or entrance point for people wanting to join
|
|
|
|
!!Rationale
|
|
Every important document, draft, text and code (including) prototypes should be checked into
|
|
one SCM (or a set of related SCMs). This repo should be "almost everything" you need for the
|
|
project. Because we try to use a distributed development model, every dev can/should have
|
|
his own copy and fed his changes back.
|
|
|
|
This ''Repository approach'' avoids the problems of a central infrastructure and helps cut down
|
|
project management time. Basically, every dev is responsible himself for getting every important
|
|
piece of information added into "the general view of matters" in a consistent way.
|
|
|
|
|
|
! Conclusion
|
|
## When approbate (this proposal becomes a Final) write some conclusions about its process:
|
|
|
|
|
|
|
|
! Comments
|
|
Basically the structure is just fine.
|
|
* maybe add a "pastebin" somewhere in the dev-documentation area?
|
|
* i would add the source tree roots at level 2, so we can have several submodules here:
|
|
** oldsrc
|
|
** cin3
|
|
** prototype
|
|
-- ["Ichthyostega"] [[DateTime(2007-06-16T23:10:01Z)]]
|
|
|
|
Draft now.
|
|
|
|
Yes I left source dirs out but this sounds fine, note that with git, there is no problem to reorganize the repo (in contrast to CVS) later. We can fix things afterward when we find better ways.
|
|
-- ["ct"] [[DateTime(2007-06-17T17:36:46Z)]]
|
|
|
|
Whats prototype for? won't that be better a branch?
|
|
-- ["ct"] [[DateTime(2007-06-17T22:04:39Z)]]
|
|
|
|
I just wanted to show there could be additional things beside the main tree (later to be separate submodules). The example was meant as a classical
|
|
throwaway prototype. But I agree, in our case we just start hacking at the new tree and make feature/tryout/prototype branches...
|
|
|
|
The point I wanted to make is: every directory 2 levels deep in the source tree, e.g. /src/cinelerra3 or /src/oldsrource should be a completely
|
|
self-contained tree which can be built without needing anything of the rest of the repo. Thats an prerequisite for moving to Submodules IMHO.
|
|
But you seem rather to put the sourcetree-roots 1 level deep. As we have just two trees at the moment (and can easily reorganize), I have no
|
|
objections against this. The only point I really care is to try to keep the source tree self-contained without any dependencies to the rest
|
|
of the "design GIT" (because of this Superprojects-Submodules thing...)
|
|
-- ["Ichthyostega"] [[DateTime(2007-06-17T23:45:06Z)]]
|
|
|
|
we could make the trees deeper than one level, I didn't intended 1-level depth. but also be careful with that not to make it too complex. While I am not sure if we want a complete oldsrc, that just adds weight and confusion for now (lets see). Neither I am fully decided about the hierarchy in /src (want /libs /plugins or /src/libs /src/plugins or /src/render/plugins? name it rather 'effects' than 'plugins'?). While I am quite sure that I want to separate /oldssrc and /src quite much (in /src should only be new stuff or stuff which is carefully reviewed, with know license and author).
|
|
-- ["ct"] [[DateTime(2007-06-18T08:38:43Z)]]
|
|
|
|
I made this proposal 'final' now further details are likely better worked out in the git repository (and we already started to define things there) see ./admin/treeinfo.sh
|
|
-- ["ct"] [[DateTime(2007-06-27T16:01:52Z)]]
|
|
</pre>
|
|
</div>
|
|
<div title="SCons" modifier="Ichthyostega" modified="200708180224" created="200708180211" tags="organization buildsys" changecount="3">
|
|
<pre>[SCons|http://www.scons.org/] is an //alternate build system// written in Python and using specific python-scripts for defining the buildprocess. These build scripts, called {{{SConstruct}}} and {{{SConsscript}}} are indeed //definitions//, not scripts for //doing// the build. If you are new to SCons (and familiar with make), you should really read the [Introduction of the users guide|http://www.scons.org/doc/0.97/HTML/scons-user/book1.html], because SCons is quite a different beast then make and the autotools.
|
|
|
|
To learn how to use SCons and to get a better feeling of its strenghtes and weaknesses, Ichthyo started a SCons based build system for Lumiera in July 2007 and will maintain it for some time parallel to the automake system (maintained by Cehteh). Every build system looks good in theory and has some big advantages, but only in real use one can see how much effort is needed to keep up with the demands of a given project.
|
|
|
|
!some Notes
|
|
* we build always in the top level directory
|
|
* at the moment, we use no separate build directory, rather we place the object files alongside with the sources
|
|
* but we place the created executables and shared libraries into one $BINDIR (configurable in the top level {{{SConstruct}}})
|
|
* note: for SCons, each file (which is buildable) and each directory (containing buildable files) is on itself a Target.
|
|
* additionally, we provide some //aliasses//
|
|
** build == $BINDIR
|
|
** install places some of the created artifacts into $DESTDIR
|
|
** testcode is an alias for all the executables comprising the testsuite
|
|
** check == directory {{{tests}}} and runs the testsuite
|
|
* run scons -h to get additional explanations.
|
|
|
|
Typically, one would just write the necessary definitions as they come into one global scope. But because the buildscripts are actually Python scripts, ichthyo found it preferable to use some more structuring and break down the code into several python functions and pass all necessary variables as parameters. This may seem overkill at first look, but the Lumiera project is expected to become a large project.
|
|
|
|
Moreover, one could simply list all needed files or break everything down into a hierarchical build. But instead, we use for most objects a helper function (located in {{{admin/scons/Buildhelper.py}}}) called {{{srcSubtree()}}}, which will scan a directory tree and add all {{{'*.c','*.cpp','*.cc'}}} - files as Object nodes to the build process. Besides that, we use the //hierarchical aproach rather reluctant//: at the moment, only the subtree for separate tools and the tests-directory have a separate buildscript. Probably, the subtree for plugins will get one as well at some point in the future.
|
|
</pre>
|
|
</div>
|
|
<div title="ShortCuts" modifier="Ichthyostega" modified="200810151609" created="200706260438" tags="portal" changecount="8">
|
|
<pre>~~This small Tiddler contains usefull Shortcuts, Info, Links~~
|
|
|
|
*[[Wiki-Markup|http://tiddlywiki.org/wiki/TiddlyWiki_Markup]]
|
|
*[[Design-Process|http://www.pipapo.org/pipawiki/Lumiera/DesignProcess]]
|
|
*
|
|
----
|
|
</pre>
|
|
</div>
|
|
<div title="SideBarOptions" modifier="CehTeh" created="200706182001" changecount="1">
|
|
<pre><<search>><<closeAll>><<permaview>><<newTiddler>><<saveChanges>><<slider chkSliderOptionsPanel OptionsPanel "options »" "Change TiddlyWiki advanced options">></pre>
|
|
</div>
|
|
<div title="SiteSubtitle" modifier="CehTeh" created="200706181110" changecount="1">
|
|
<pre>Distributed Developer Wiki</pre>
|
|
</div>
|
|
<div title="SiteTitle" modifier="CehTeh" created="200706181110" changecount="1">
|
|
<pre>Lumiera</pre>
|
|
</div>
|
|
<div title="SplashScreenPlugin" modifier="Saq" modified="200607202048" created="200607191631" tags="lewcidExtension systemConfig" server.type="file" server.host="file:///home/ct/.homepage/home.html" server.page.revision="200607202048">
|
|
<pre>/***
|
|
|
|
''Inspired by [[TiddlyPom|http://www.warwick.ac.uk/~tuspam/tiddlypom.html]]''
|
|
|
|
|Name|SplashScreenPlugin|
|
|
|Created by|SaqImtiaz|
|
|
|Location|http://tw.lewcid.org/#SplashScreenPlugin|
|
|
|Version|0.21 |
|
|
|Requires|~TW2.08+|
|
|
!Description:
|
|
Provides a simple splash screen that is visible while the TW is loading.
|
|
|
|
!Installation
|
|
Copy the source text of this tiddler to your TW in a new tiddler, tag it with systemConfig and save and reload. The SplashScreen will now be installed and will be visible the next time you reload your TW.
|
|
|
|
!Customizing
|
|
Once the SplashScreen has been installed and you have reloaded your TW, the splash screen html will be present in the MarkupPreHead tiddler. You can edit it and customize to your needs.
|
|
|
|
!History
|
|
* 20-07-06 : version 0.21, modified to hide contentWrapper while SplashScreen is displayed.
|
|
* 26-06-06 : version 0.2, first release
|
|
|
|
!Code
|
|
***/
|
|
//{{{
|
|
var old_lewcid_splash_restart=restart;
|
|
|
|
restart = function()
|
|
{ if (document.getElementById("SplashScreen"))
|
|
document.getElementById("SplashScreen").style.display = "none";
|
|
if (document.getElementById("contentWrapper"))
|
|
document.getElementById("contentWrapper").style.display = "block";
|
|
|
|
old_lewcid_splash_restart();
|
|
|
|
if (splashScreenInstall)
|
|
{if(config.options.chkAutoSave)
|
|
{saveChanges();}
|
|
displayMessage("TW SplashScreen has been installed, please save and refresh your TW.");
|
|
}
|
|
}
|
|
|
|
|
|
var oldText = store.getTiddlerText("MarkupPreHead");
|
|
if (oldText.indexOf("SplashScreen")==-1)
|
|
{var siteTitle = store.getTiddlerText("SiteTitle");
|
|
var splasher='\n\n<style type="text/css">#contentWrapper {display:none;}</style><div id="SplashScreen" style="border: 3px solid #ccc; display: block; text-align: center; width: 320px; margin: 100px auto; padding: 50px; color:#000; font-size: 28px; font-family:Tahoma; background-color:#eee;"><b>'+siteTitle +'</b> is loading<blink> ...</blink><br><br><span style="font-size: 14px; color:red;">Requires Javascript.</span></div>';
|
|
if (! store.tiddlerExists("MarkupPreHead"))
|
|
{var myTiddler = store.createTiddler("MarkupPreHead");}
|
|
else
|
|
{var myTiddler = store.getTiddler("MarkupPreHead");}
|
|
myTiddler.set(myTiddler.title,oldText+splasher,config.options.txtUserName,null,null);
|
|
store.setDirty(true);
|
|
var splashScreenInstall = true;
|
|
}
|
|
//}}}</pre>
|
|
</div>
|
|
<div title="SrcTreeStructure" modifier="CehTeh" modified="200706270059" created="200706262157" tags="organization" changecount="2">
|
|
<pre>* add a ''~DIR_INFO'' file to each marginally important directory. The first line should give a short abstract about this dir (40 characters, not more), following lines can give more precise information. There is a 'admin/treeinfo.sh' script which generates a texual overview of the directory tree.
|
|
</pre>
|
|
</div>
|
|
<div title="StyleSheet" modifier="Ichthyostega" modified="200706260503" created="200701131624" tags="MPTWTheme excludeMissing" server.type="file" server.host="file:///home/ct/.homepage/home.html" server.page.revision="200706090017" changecount="1">
|
|
<pre>/*{{{*/
|
|
/* a contrasting background so I can see where one tiddler ends and the other begins */
|
|
body {
|
|
background: [[ColorPalette::TertiaryLight]];
|
|
}
|
|
|
|
/* sexy colours and font for the header */
|
|
.headerForeground {
|
|
color: [[ColorPalette::PrimaryPale]];
|
|
}
|
|
.headerShadow, .headerShadow a {
|
|
color: [[ColorPalette::PrimaryMid]];
|
|
}
|
|
.headerForeground, .headerShadow {
|
|
padding: 1em 1em 0;
|
|
font-family: 'Trebuchet MS' sans-serif;
|
|
font-weight:bold;
|
|
}
|
|
.headerForeground .siteSubtitle {
|
|
color: [[ColorPalette::PrimaryLight]];
|
|
}
|
|
.headerShadow .siteSubtitle {
|
|
color: [[ColorPalette::PrimaryMid]];
|
|
}
|
|
|
|
/* make shadow go and down right instead of up and left */
|
|
.headerShadow {
|
|
left: 2px;
|
|
top: 3px;
|
|
}
|
|
|
|
/* prefer monospace for editing */
|
|
.editor textarea {
|
|
font-family: 'Consolas' monospace;
|
|
}
|
|
|
|
/* sexy tiddler titles */
|
|
.title {
|
|
font-size: 250%;
|
|
color: [[ColorPalette::PrimaryLight]];
|
|
font-family: 'Trebuchet MS' sans-serif;
|
|
}
|
|
|
|
/* more subtle tiddler subtitle */
|
|
.subtitle {
|
|
padding:0px;
|
|
margin:0px;
|
|
padding-left:0.5em;
|
|
font-size: 90%;
|
|
color: [[ColorPalette::TertiaryMid]];
|
|
}
|
|
.subtitle .tiddlyLink {
|
|
color: [[ColorPalette::TertiaryMid]];
|
|
}
|
|
|
|
/* a little bit of extra whitespace */
|
|
.viewer {
|
|
padding-bottom:3px;
|
|
}
|
|
|
|
/* don't want any background color for headings */
|
|
h1,h2,h3,h4,h5,h6 {
|
|
background: [[ColorPalette::Background]];
|
|
color: [[ColorPalette::Foreground]];
|
|
}
|
|
|
|
/* give tiddlers 3d style border and explicit background */
|
|
.tiddler {
|
|
background: [[ColorPalette::Background]];
|
|
border-right: 2px [[ColorPalette::TertiaryMid]] solid;
|
|
border-bottom: 2px [[ColorPalette::TertiaryMid]] solid;
|
|
margin-bottom: 1em;
|
|
padding-bottom: 2em;
|
|
}
|
|
|
|
/* make options slider look nicer */
|
|
#sidebarOptions .sliderPanel {
|
|
border:solid 1px [[ColorPalette::PrimaryLight]];
|
|
}
|
|
|
|
|
|
/* the borders look wrong with the body background */
|
|
#sidebar .button {
|
|
border-style: none;
|
|
}
|
|
|
|
/* displays the list of a tiddler's tags horizontally. used in ViewTemplate */
|
|
.tagglyTagged li.listTitle {
|
|
display:none
|
|
}
|
|
.tagglyTagged li {
|
|
display: inline; font-size:90%;
|
|
}
|
|
.tagglyTagged ul {
|
|
margin:0px; padding:0px;
|
|
}
|
|
|
|
/* this means you can put line breaks in SidebarOptions for readability */
|
|
#sidebarOptions br {
|
|
display:none;
|
|
}
|
|
/* undo the above in OptionsPanel */
|
|
#sidebarOptions .sliderPanel br {
|
|
display:inline;
|
|
}
|
|
|
|
/* horizontal main menu stuff */
|
|
#displayArea {
|
|
margin: 1em 15.7em 0em 1em; /* use the freed up space */
|
|
}
|
|
#topMenu br {
|
|
display: none;
|
|
}
|
|
#topMenu {
|
|
background: [[ColorPalette::PrimaryMid]];
|
|
color:[[ColorPalette::PrimaryPale]];
|
|
}
|
|
#topMenu {
|
|
padding:2px;
|
|
}
|
|
#topMenu .button, #topMenu .tiddlyLink, #topMenu a {
|
|
margin-left: 0.5em;
|
|
margin-right: 0.5em;
|
|
padding-left: 3px;
|
|
padding-right: 3px;
|
|
color: [[ColorPalette::PrimaryPale]];
|
|
font-size: 115%;
|
|
}
|
|
#topMenu .button:hover, #topMenu .tiddlyLink:hover {
|
|
background: [[ColorPalette::PrimaryDark]];
|
|
}
|
|
|
|
/* make it print a little cleaner */
|
|
@media print {
|
|
#topMenu {
|
|
display: none ! important;
|
|
}
|
|
/* not sure if we need all the importants */
|
|
.tiddler {
|
|
border-style: none ! important;
|
|
margin:0px ! important;
|
|
padding:0px ! important;
|
|
padding-bottom:2em ! important;
|
|
}
|
|
.tagglyTagging .button, .tagglyTagging .hidebutton {
|
|
display: none ! important;
|
|
}
|
|
.headerShadow {
|
|
visibility: hidden ! important;
|
|
}
|
|
.tagglyTagged .quickopentag, .tagged .quickopentag {
|
|
border-style: none ! important;
|
|
}
|
|
.quickopentag a.button, .miniTag {
|
|
display: none ! important;
|
|
}
|
|
}
|
|
/*}}}*/
|
|
</pre>
|
|
</div>
|
|
<div title="TabTimeline" modifier="CehTeh" created="200706182004" changecount="1">
|
|
<pre><<timeline better:true maxDays:14 maxEntries:20>></pre>
|
|
</div>
|
|
<div title="TaskMacroPlugin" modifier="LukeBlanshard" modified="200605131931" created="200510261917" tags="systemConfig TaskMacro" server.type="file" server.host="file:///home/ct/.homepage/home.html" server.page.revision="200605131931">
|
|
<pre>/***
|
|
|Name|TaskMacroPlugin|
|
|
|Author|<<extension TaskMacroPlugin author>>|
|
|
|Location|<<extension TaskMacroPlugin source>>|
|
|
|License|<<extension TaskMacroPlugin license>>|
|
|
|Version|<<extension TaskMacroPlugin versionAndDate>>|
|
|
!Description
|
|
A set of macros to help you keep track of time estimates for tasks.
|
|
|
|
Macros defined:
|
|
* {{{task}}}: Displays a task description and makes it easy to estimate and track the time spent on the task.
|
|
* {{{taskadder}}}: Displays text entry field to simplify the adding of tasks.
|
|
* {{{tasksum}}}: Displays a summary of tasks sandwiched between two calls to this macro.
|
|
* {{{extension}}}: A simple little macro that displays information about a TiddlyWiki plugin, and that will hopefully someday migrate to the TW core in some form.
|
|
Core overrides:
|
|
* {{{wikify}}}: when wikifying a tiddler's complete text, adds refresh information so the tiddler will be refreshed when it changes
|
|
* {{{config.refreshers}}}: have the built-in refreshers return true; also, add a new refresher ("fullContent") that redisplays a full tiddler whenever it or any nested tiddlers it shows are changed
|
|
* {{{refreshElements}}}: now checks the return value from the refresher and only short-circuits the recursion if the refresher returns true
|
|
!Plugin Information
|
|
***/
|
|
//{{{
|
|
version.extensions.TaskMacroPlugin = {
|
|
major: 1, minor: 1, revision: 0,
|
|
date: new Date(2006,5-1,13),
|
|
author: "LukeBlanshard",
|
|
source: "http://labwiki.sourceforge.net/#TaskMacroPlugin",
|
|
license: "http://labwiki.sourceforge.net/#CopyrightAndLicense"
|
|
}
|
|
//}}}
|
|
/***
|
|
A little macro for pulling out extension info. Use like {{{<<extension PluginName datum>>}}}, where {{{PluginName}}} is the name you used for {{{version.extensions}}} and {{{datum}}} is either {{{versionAndDate}}} or a property of the extension description object, such as {{{source}}}.
|
|
***/
|
|
//{{{
|
|
config.macros.extension = {
|
|
handler: function( place, macroName, params, wikifier, paramString, tiddler ) {
|
|
var info = version.extensions[params[0]]
|
|
var datum = params[1]
|
|
switch (params[1]) {
|
|
case 'versionAndDate':
|
|
createTiddlyElement( place, "span", null, null,
|
|
info.major+'.'+info.minor+'.'+info.revision+', '+info.date.formatString('DD MMM YYYY') )
|
|
break;
|
|
default:
|
|
wikify( info[datum], place )
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
//}}}
|
|
/***
|
|
!Core Overrides
|
|
***/
|
|
//{{{
|
|
window.wikify_orig_TaskMacroPlugin = window.wikify
|
|
window.wikify = function(source,output,highlightRegExp,tiddler)
|
|
{
|
|
if ( tiddler && tiddler.text === source )
|
|
addDisplayDependency( output, tiddler.title )
|
|
wikify_orig_TaskMacroPlugin.apply( this, arguments )
|
|
}
|
|
config.refreshers_orig_TaskMacroPlugin = config.refreshers
|
|
config.refreshers = {
|
|
link: function() {
|
|
config.refreshers_orig_TaskMacroPlugin.link.apply( this, arguments )
|
|
return true
|
|
},
|
|
content: function() {
|
|
config.refreshers_orig_TaskMacroPlugin.content.apply( this, arguments )
|
|
return true
|
|
},
|
|
fullContent: function( e, changeList ) {
|
|
var tiddlers = e.refreshTiddlers
|
|
if ( changeList == null || tiddlers == null )
|
|
return false
|
|
for ( var i=0; i < tiddlers.length; ++i )
|
|
if ( changeList.find(tiddlers[i]) != null ) {
|
|
var title = tiddlers[0]
|
|
story.refreshTiddler( title, null, true )
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
}
|
|
function refreshElements(root,changeList)
|
|
{
|
|
var nodes = root.childNodes;
|
|
for(var c=0; c<nodes.length; c++)
|
|
{
|
|
var e = nodes[c],type;
|
|
if(e.getAttribute)
|
|
type = e.getAttribute("refresh");
|
|
else
|
|
type = null;
|
|
var refresher = config.refreshers[type];
|
|
if ( ! refresher || ! refresher(e, changeList) )
|
|
{
|
|
if(e.hasChildNodes())
|
|
refreshElements(e,changeList);
|
|
}
|
|
}
|
|
}
|
|
//}}}
|
|
/***
|
|
!Global Functions
|
|
***/
|
|
//{{{
|
|
// Add the tiddler whose title is given to the list of tiddlers whose
|
|
// changing will cause a refresh of the tiddler containing the given element.
|
|
function addDisplayDependency( element, title ) {
|
|
while ( element && element.getAttribute ) {
|
|
var idAttr = element.getAttribute("id"), tiddlerAttr = element.getAttribute("tiddler")
|
|
if ( idAttr && tiddlerAttr && idAttr == story.idPrefix+tiddlerAttr ) {
|
|
var list = element.refreshTiddlers
|
|
if ( list == null ) {
|
|
list = [tiddlerAttr]
|
|
element.refreshTiddlers = list
|
|
element.setAttribute( "refresh", "fullContent" )
|
|
}
|
|
list.pushUnique( title )
|
|
return
|
|
}
|
|
element = element.parentNode
|
|
}
|
|
}
|
|
|
|
// Lifted from Story.prototype.focusTiddler: just return the field instead of focusing it.
|
|
Story.prototype.findEditField = function( title, field )
|
|
{
|
|
var tiddler = document.getElementById(this.idPrefix + title);
|
|
if(tiddler != null)
|
|
{
|
|
var children = tiddler.getElementsByTagName("*")
|
|
var e = null;
|
|
for (var t=0; t<children.length; t++)
|
|
{
|
|
var c = children[t];
|
|
if(c.tagName.toLowerCase() == "input" || c.tagName.toLowerCase() == "textarea")
|
|
{
|
|
if(!e)
|
|
e = c;
|
|
if(c.getAttribute("edit") == field)
|
|
e = c;
|
|
}
|
|
}
|
|
return e
|
|
}
|
|
}
|
|
|
|
// Wraps the given event function in another function that handles the
|
|
// event in a standard way.
|
|
function wrapEventHandler( otherHandler ) {
|
|
return function(e) {
|
|
if (!e) var e = window.event
|
|
e.cancelBubble = true
|
|
if (e.stopPropagation) e.stopPropagation()
|
|
return otherHandler( e )
|
|
}
|
|
}
|
|
//}}}
|
|
/***
|
|
!Task Macro
|
|
Usage:
|
|
> {{{<<task orig cur spent>>description}}}
|
|
All of orig, cur, and spent are optional numbers of hours. The description goes through the end of the line, and is wikified.
|
|
***/
|
|
//{{{
|
|
config.macros.task = {
|
|
NASCENT: 0, // Task not yet estimated
|
|
LIVE: 1, // Estimated but with time remaining
|
|
DONE: 2, // Completed: no time remaining
|
|
bullets: ["\u25cb", // nascent (open circle)
|
|
"\u25ba", // live (right arrow)
|
|
"\u25a0"],// done (black square)
|
|
styles: ["nascent", "live", "done"],
|
|
|
|
// Translatable text:
|
|
lingo: {
|
|
spentTooBig: "Spent time %0 can't exceed current estimate %1",
|
|
noNegative: "Times may not be negative numbers",
|
|
statusTips: ["Not yet estimated", "To do", "Done"], // Array indexed by state (NASCENT/LIVE/DONE)
|
|
descClickTip: " -- Double-click to edit task description",
|
|
statusClickTip: " -- Double-click to mark task complete",
|
|
statusDoneTip: " -- Double-click to adjust the time spent, to revive the task",
|
|
origTip: "Original estimate in hours",
|
|
curTip: "Current estimate in hours",
|
|
curTip2: "Estimate in hours", // For when orig == cur
|
|
clickTip: " -- Click to adjust",
|
|
spentTip: "Hours spent on this task",
|
|
remTip: "Hours remaining",
|
|
curPrompt: "Estimate this task in hours, or adjust the current estimate by starting with + or -.\n\nYou may optionally also set or adjust the time spent by putting a second number after the first.",
|
|
spentPrompt: "Enter the number of hours you've spent on this task, or adjust the current number by starting with + or -.\n\nYou may optionally also set or adjust the time remaining by putting a second number after the first.",
|
|
remPrompt: "Enter the number of hours it will take to finish this task, or adjust the current estimate by starting with + or -.\n\nYou may optionally also set or adjust the time spent by putting a second number after the first.",
|
|
numbersOnly: "Enter numbers only, please",
|
|
notCurrent: "The tiddler has been modified since it was displayed, please redisplay it before doing this."
|
|
},
|
|
|
|
// The macro handler
|
|
handler: function( place, macroName, params, wikifier, paramString, tiddler )
|
|
{
|
|
var start = wikifier.matchStart, end = wikifier.nextMatch
|
|
|
|
var origStr = params.length > 0? params.shift() : "?"
|
|
var orig = +origStr // as a number
|
|
var cur = params.length > 1? +params.shift() : orig
|
|
var spent = params.length > 0? +params.shift() : 0
|
|
if ( spent > cur )
|
|
throw Error( this.lingo.spentTooBig.format([spent, cur]) )
|
|
if ( orig < 0 || cur < 0 || spent < 0 )
|
|
throw Error( this.lingo.noNegative )
|
|
var rem = cur - spent
|
|
var state = isNaN(orig+rem)? this.NASCENT : rem > 0? this.LIVE : this.DONE
|
|
var table = createTiddlyElement( place, "table", null, "task "+this.styles[state] )
|
|
var tbody = createTiddlyElement( table, "tbody" )
|
|
var row = createTiddlyElement( tbody, "tr" )
|
|
var statusCell = createTiddlyElement( row, "td", null, "status", this.bullets[state] )
|
|
var descCell = createTiddlyElement( row, "td", null, "description" )
|
|
|
|
var origCell = state==this.NASCENT || orig==cur? null
|
|
: createTiddlyElement( row, "td", null, "numeric original" )
|
|
var curCell = createTiddlyElement( row, "td", null, "numeric current" )
|
|
var spentCell = createTiddlyElement( row, "td", null, "numeric spent" )
|
|
var remCell = createTiddlyElement( row, "td", null, "numeric remaining" )
|
|
|
|
var sums = config.macros.tasksum.tasksums
|
|
if ( sums && sums.length ) {
|
|
var summary = [(state == this.NASCENT? NaN : orig), cur, spent]
|
|
summary.owner = tiddler
|
|
sums[0].push( summary )
|
|
}
|
|
|
|
// The description goes to the end of the line
|
|
wikifier.subWikify( descCell, "$\\n?" )
|
|
var descEnd = wikifier.nextMatch
|
|
|
|
statusCell.setAttribute( "title", this.lingo.statusTips[state] )
|
|
descCell.setAttribute( "title", this.lingo.statusTips[state]+this.lingo.descClickTip )
|
|
if (origCell) {
|
|
createTiddlyElement( origCell, "div", null, null, orig )
|
|
origCell.setAttribute( "title", this.lingo.origTip )
|
|
curCell.setAttribute( "title", this.lingo.curTip )
|
|
}
|
|
else {
|
|
curCell.setAttribute( "title", this.lingo.curTip2 )
|
|
}
|
|
var curDivContents = (state==this.NASCENT)? "?" : cur
|
|
var curDiv = createTiddlyElement( curCell, "div", null, null, curDivContents )
|
|
spentCell.setAttribute( "title", this.lingo.spentTip )
|
|
var spentDiv = createTiddlyElement( spentCell, "div", null, null, spent )
|
|
remCell.setAttribute( "title", this.lingo.remTip )
|
|
var remDiv = createTiddlyElement( remCell, "div", null, null, rem )
|
|
|
|
// Handle double-click on the description by going
|
|
// into edit mode and selecting the description
|
|
descCell.ondblclick = this.editDescription( tiddler, end, descEnd )
|
|
|
|
function appTitle( el, suffix ) {
|
|
el.setAttribute( "title", el.getAttribute("title")+suffix )
|
|
}
|
|
|
|
// For incomplete tasks, handle double-click on the bullet by marking the task complete
|
|
if ( state != this.DONE ) {
|
|
appTitle( statusCell, this.lingo.statusClickTip )
|
|
statusCell.ondblclick = this.markTaskComplete( tiddler, start, end, macroName, orig, cur, state )
|
|
}
|
|
// For complete ones, handle double-click on the bullet by letting you adjust the time spent
|
|
else {
|
|
appTitle( statusCell, this.lingo.statusDoneTip )
|
|
statusCell.ondblclick = this.adjustTimeSpent( tiddler, start, end, macroName, orig, cur, spent )
|
|
}
|
|
|
|
// Add click handlers for the numeric cells.
|
|
if ( state != this.DONE ) {
|
|
appTitle( curCell, this.lingo.clickTip )
|
|
curDiv.className = "adjustable"
|
|
curDiv.onclick = this.adjustCurrentEstimate( tiddler, start, end, macroName,
|
|
orig, cur, spent, curDivContents )
|
|
}
|
|
appTitle( spentCell, this.lingo.clickTip )
|
|
spentDiv.className = "adjustable"
|
|
spentDiv.onclick = this.adjustTimeSpent( tiddler, start, end, macroName, orig, cur, spent )
|
|
if ( state == this.LIVE ) {
|
|
appTitle( remCell, this.lingo.clickTip )
|
|
remDiv.className = "adjustable"
|
|
remDiv.onclick = this.adjustTimeRemaining( tiddler, start, end, macroName, orig, cur, spent )
|
|
}
|
|
},
|
|
|
|
// Puts the tiddler into edit mode, and selects the range of characters
|
|
// defined by start and end. Separated for leak prevention in IE.
|
|
editDescription: function( tiddler, start, end ) {
|
|
return wrapEventHandler( function(e) {
|
|
story.displayTiddler( null, tiddler.title, DEFAULT_EDIT_TEMPLATE )
|
|
var tiddlerElement = document.getElementById( story.idPrefix + tiddler.title )
|
|
window.scrollTo( 0, ensureVisible(tiddlerElement) )
|
|
var element = story.findEditField( tiddler.title, "text" )
|
|
if ( element && element.tagName.toLowerCase() == "textarea" ) {
|
|
// Back up one char if the last char's a newline
|
|
if ( tiddler.text[end-1] == '\n' )
|
|
--end
|
|
element.focus()
|
|
if ( element.setSelectionRange != undefined ) { // Mozilla
|
|
element.setSelectionRange( start, end )
|
|
// Damn mozilla doesn't scroll to visible. Approximate.
|
|
var max = 0.0 + element.scrollHeight
|
|
var len = element.textLength
|
|
var top = max*start/len, bot = max*end/len
|
|
element.scrollTop = Math.min( top, (bot+top-element.clientHeight)/2 )
|
|
}
|
|
else if ( element.createTextRange != undefined ) { // IE
|
|
var range = element.createTextRange()
|
|
range.collapse()
|
|
range.moveEnd("character", end)
|
|
range.moveStart("character", start)
|
|
range.select()
|
|
}
|
|
else // Other? Too bad, just select the whole thing.
|
|
element.select()
|
|
return false
|
|
}
|
|
else
|
|
return true
|
|
} )
|
|
},
|
|
|
|
// Modifies a task macro call such that the task appears complete.
|
|
markTaskComplete: function( tiddler, start, end, macroName, orig, cur, state ) {
|
|
var macro = this, text = tiddler.text
|
|
return wrapEventHandler( function(e) {
|
|
if ( text !== tiddler.text ) {
|
|
alert( macro.lingo.notCurrent )
|
|
return false
|
|
}
|
|
if ( state == macro.NASCENT )
|
|
orig = cur = 0
|
|
// The second "cur" in the call below bumps up the time spent
|
|
// to match the current estimate.
|
|
macro.replaceMacroCall( tiddler, start, end, macroName, orig, cur, cur )
|
|
return false
|
|
} )
|
|
},
|
|
|
|
// Asks the user for an adjustment to the current estimate, modifies the macro call accordingly.
|
|
adjustCurrentEstimate: function( tiddler, start, end, macroName, orig, cur, spent, curDivContents ) {
|
|
var macro = this, text = tiddler.text
|
|
return wrapEventHandler( function(e) {
|
|
if ( text !== tiddler.text ) {
|
|
alert( macro.lingo.notCurrent )
|
|
return false
|
|
}
|
|
var txt = prompt( macro.lingo.curPrompt, curDivContents )
|
|
if ( txt != null ) {
|
|
var a = macro.breakInput( txt )
|
|
cur = macro.offset( cur, a[0] )
|
|
if ( a.length > 1 )
|
|
spent = macro.offset( spent, a[1] )
|
|
macro.replaceMacroCall( tiddler, start, end, macroName, orig, cur, spent )
|
|
}
|
|
return false
|
|
} )
|
|
},
|
|
|
|
// Asks the user for an adjustment to the time spent, modifies the macro call accordingly.
|
|
adjustTimeSpent: function( tiddler, start, end, macroName, orig, cur, spent ) {
|
|
var macro = this, text = tiddler.text
|
|
return wrapEventHandler( function(e) {
|
|
if ( text !== tiddler.text ) {
|
|
alert( macro.lingo.notCurrent )
|
|
return false
|
|
}
|
|
var txt = prompt( macro.lingo.spentPrompt, spent )
|
|
if ( txt != null ) {
|
|
var a = macro.breakInput( txt )
|
|
spent = macro.offset( spent, a[0] )
|
|
var rem = cur - spent
|
|
if ( a.length > 1 ) {
|
|
rem = macro.offset( rem, a[1] )
|
|
cur = spent + rem
|
|
}
|
|
macro.replaceMacroCall( tiddler, start, end, macroName, orig, cur, spent )
|
|
}
|
|
return false
|
|
} )
|
|
},
|
|
|
|
// Asks the user for an adjustment to the time remaining, modifies the macro call accordingly.
|
|
adjustTimeRemaining: function( tiddler, start, end, macroName, orig, cur, spent ) {
|
|
var macro = this
|
|
var text = tiddler.text
|
|
var rem = cur - spent
|
|
return wrapEventHandler( function(e) {
|
|
if ( text !== tiddler.text ) {
|
|
alert( macro.lingo.notCurrent )
|
|
return false
|
|
}
|
|
var txt = prompt( macro.lingo.remPrompt, rem )
|
|
if ( txt != null ) {
|
|
var a = macro.breakInput( txt )
|
|
var newRem = macro.offset( rem, a[0] )
|
|
if ( newRem > rem || a.length > 1 )
|
|
cur += (newRem - rem)
|
|
else
|
|
spent += (rem - newRem)
|
|
if ( a.length > 1 )
|
|
spent = macro.offset( spent, a[1] )
|
|
macro.replaceMacroCall( tiddler, start, end, macroName, orig, cur, spent )
|
|
}
|
|
return false
|
|
} )
|
|
},
|
|
|
|
// Breaks input at spaces & commas, returns array
|
|
breakInput: function( txt ) {
|
|
var a = txt.trim().split( /[\s,]+/ )
|
|
if ( a.length == 0 )
|
|
a = [NaN]
|
|
return a
|
|
},
|
|
|
|
// Adds to, subtracts from, or replaces a numeric value
|
|
offset: function( num, txt ) {
|
|
if ( txt == "" || typeof(txt) != "string" )
|
|
return NaN
|
|
if ( txt.match(/^[+-]/) )
|
|
return num + (+txt)
|
|
return +txt
|
|
},
|
|
|
|
// Does some error checking, then replaces the indicated macro
|
|
// call within the text of the given tiddler.
|
|
replaceMacroCall: function( tiddler, start, end, macroName, orig, cur, spent )
|
|
{
|
|
if ( isNaN(cur+spent) ) {
|
|
alert( this.lingo.numbersOnly )
|
|
return
|
|
}
|
|
if ( spent < 0 || cur < 0 ) {
|
|
alert( this.lingo.noNegative )
|
|
return
|
|
}
|
|
if ( isNaN(orig) )
|
|
orig = cur
|
|
if ( spent > cur )
|
|
cur = spent
|
|
var text = tiddler.text.substring(0,start) + "<<" + macroName + " " +
|
|
orig + " " + cur + " " + spent + ">>" + tiddler.text.substring(end)
|
|
var title = tiddler.title
|
|
store.saveTiddler( title, title, text, config.options.txtUserName, new Date(), undefined )
|
|
//story.refreshTiddler( title, null, true )
|
|
if ( config.options.chkAutoSave )
|
|
saveChanges()
|
|
}
|
|
}
|
|
//}}}
|
|
/***
|
|
!Tasksum Macro
|
|
Usage:
|
|
> {{{<<tasksum "start" ["here" [intro]]>>}}}
|
|
or:
|
|
> {{{<<tasksum "end" [intro]>>}}}
|
|
Put one of the {{{<<tasksum start>>}}} lines before the tasks you want to summarize, and an {{{end}}} line after them. By default, the summary goes at the end; if you include {{{here}}} in the start line, the summary will go at the top. The intro argument, if supplied, replaces the default text introducing the summary.
|
|
***/
|
|
//{{{
|
|
config.macros.tasksum = {
|
|
|
|
// Translatable text:
|
|
lingo: {
|
|
unrecVerb: "<<%0>> requires 'start' or 'end' as its first argument",
|
|
mustMatch: "<<%0 end>> must match a preceding <<%0 start>>",
|
|
defIntro: "Task summary:",
|
|
nascentSum: "''%0 not estimated''",
|
|
doneSum: "%0 complete (in %1 hours)",
|
|
liveSum: "%0 ongoing (%1 hours so far, ''%2 hours remaining'')",
|
|
overSum: "Total overestimate: %0%.",
|
|
underSum: "Total underestimate: %0%.",
|
|
descPattern: "%0 %1. %2",
|
|
origTip: "Total original estimates in hours",
|
|
curTip: "Total current estimates in hours",
|
|
spentTip: "Total hours spent on tasks",
|
|
remTip: "Total hours remaining"
|
|
},
|
|
|
|
// The macro handler
|
|
handler: function( place, macroName, params, wikifier, paramString, tiddler )
|
|
{
|
|
var sums = this.tasksums
|
|
if ( params[0] == "start" ) {
|
|
sums.unshift([])
|
|
if ( params[1] == "here" ) {
|
|
sums[0].intro = params[2] || this.lingo.defIntro
|
|
sums[0].place = place
|
|
sums[0].placement = place.childNodes.length
|
|
}
|
|
}
|
|
else if ( params[0] == "end" ) {
|
|
if ( ! sums.length )
|
|
throw Error( this.lingo.mustMatch.format([macroName]) )
|
|
var list = sums.shift()
|
|
var intro = list.intro || params[1] || this.lingo.defIntro
|
|
var nNascent=0, nLive=0, nDone=0, nMine=0
|
|
var totLiveSpent=0, totDoneSpent=0
|
|
var totOrig=0, totCur=0, totSpent=0
|
|
for ( var i=0; i < list.length; ++i ) {
|
|
var a = list[i]
|
|
if ( a.length > 3 ) {
|
|
nNascent += a[0]
|
|
nLive += a[1]
|
|
nDone += a[2]
|
|
totLiveSpent += a[3]
|
|
totDoneSpent += a[4]
|
|
totOrig += a[5]
|
|
totCur += a[6]
|
|
totSpent += a[7]
|
|
if ( a.owner == tiddler )
|
|
nMine += a[8]
|
|
}
|
|
else {
|
|
if ( a.owner == tiddler )
|
|
++nMine
|
|
if ( isNaN(a[0]) ) {
|
|
++nNascent
|
|
}
|
|
else {
|
|
if ( a[1] > a[2] ) {
|
|
++nLive
|
|
totLiveSpent += a[2]
|
|
}
|
|
else {
|
|
++nDone
|
|
totDoneSpent += a[2]
|
|
}
|
|
totOrig += a[0]
|
|
totCur += a[1]
|
|
totSpent += a[2]
|
|
}
|
|
}
|
|
}
|
|
|
|
// If we're nested, push a summary outward
|
|
if ( sums.length ) {
|
|
var summary = [nNascent, nLive, nDone, totLiveSpent, totDoneSpent,
|
|
totOrig, totCur, totSpent, nMine]
|
|
summary.owner = tiddler
|
|
sums[0].push( summary )
|
|
}
|
|
|
|
var descs = [], styles = []
|
|
if ( nNascent > 0 ) {
|
|
descs.push( this.lingo.nascentSum.format([nNascent]) )
|
|
styles.push( "nascent" )
|
|
}
|
|
if ( nDone > 0 )
|
|
descs.push( this.lingo.doneSum.format([nDone, totDoneSpent]) )
|
|
if ( nLive > 0 ) {
|
|
descs.push( this.lingo.liveSum.format([nLive, totLiveSpent, totCur-totSpent]) )
|
|
styles.push( "live" )
|
|
}
|
|
else
|
|
styles.push( "done" )
|
|
var off = ""
|
|
if ( totOrig > totCur )
|
|
off = this.lingo.overSum.format( [Math.round(100.0*(totOrig-totCur)/totCur)] )
|
|
else if ( totCur > totOrig )
|
|
off = this.lingo.underSum.format( [Math.round(100.0*(totCur-totOrig)/totOrig)] )
|
|
|
|
var top = (list.intro != undefined)
|
|
var table = createTiddlyElement( null, "table", null, "tasksum "+(top?"top":"bottom") )
|
|
var tbody = createTiddlyElement( table, "tbody" )
|
|
var row = createTiddlyElement( tbody, "tr", null, styles.join(" ") )
|
|
var descCell = createTiddlyElement( row, "td", null, "description" )
|
|
|
|
var description = this.lingo.descPattern.format( [intro, descs.join(", "), off] )
|
|
wikify( description, descCell, null, tiddler )
|
|
|
|
var origCell = totOrig == totCur? null
|
|
: createTiddlyElement( row, "td", null, "numeric original", totOrig )
|
|
var curCell = createTiddlyElement( row, "td", null, "numeric current", totCur )
|
|
var spentCell = createTiddlyElement( row, "td", null, "numeric spent", totSpent )
|
|
var remCell = createTiddlyElement( row, "td", null, "numeric remaining", totCur-totSpent )
|
|
|
|
if ( origCell )
|
|
origCell.setAttribute( "title", this.lingo.origTip )
|
|
curCell .setAttribute( "title", this.lingo.curTip )
|
|
spentCell.setAttribute( "title", this.lingo.spentTip )
|
|
remCell .setAttribute( "title", this.lingo.remTip )
|
|
|
|
// Discard the table if there are no tasks
|
|
if ( list.length > 0 ) {
|
|
var place = top? list.place : place
|
|
var placement = top? list.placement : place.childNodes.length
|
|
if ( placement >= place.childNodes.length )
|
|
place.appendChild( table )
|
|
else
|
|
place.insertBefore( table, place.childNodes[placement] )
|
|
}
|
|
}
|
|
else
|
|
throw Error( this.lingo.unrecVerb.format([macroName]) )
|
|
|
|
// If we're wikifying, and are followed by end-of-line, swallow the newline.
|
|
if ( wikifier && wikifier.source.charAt(wikifier.nextMatch) == "\n" )
|
|
++wikifier.nextMatch
|
|
},
|
|
|
|
// This is the stack of pending summaries
|
|
tasksums: []
|
|
}
|
|
//}}}
|
|
/***
|
|
!Taskadder Macro
|
|
Usage:
|
|
> {{{<<taskadder ["above"|"below"|"focus"|"nofocus"]...>>}}}
|
|
Creates a line with text entry fields for a description and an estimate. By default, puts focus in the description field and adds tasks above the entry fields. Use {{{nofocus}}} to not put focus in the description field. Use {{{below}}} to add tasks below the entry fields.
|
|
***/
|
|
//{{{
|
|
config.macros.taskadder = {
|
|
|
|
// Translatable text:
|
|
lingo: {
|
|
unrecParam: "<<%0>> doesn't recognize '%1' as a parameter",
|
|
descTip: "Describe a new task",
|
|
curTip: "Estimate how long in hours the task will take",
|
|
buttonText: "add task",
|
|
buttonTip: "Add a new task with the description and estimate as entered",
|
|
notCurrent: "The tiddler has been modified since it was displayed, please redisplay it before adding a task this way.",
|
|
|
|
eol: "eol"
|
|
},
|
|
|
|
// The macro handler
|
|
handler: function( place, macroName, params, wikifier, paramString, tiddler )
|
|
{
|
|
var above = true
|
|
var focus = false
|
|
|
|
while ( params.length > 0 ) {
|
|
var p = params.shift()
|
|
switch (p) {
|
|
case "above": above = true; break
|
|
case "below": above = false; break
|
|
case "focus": focus = true; break
|
|
case "nofocus": focus = false; break
|
|
default: throw Error( this.lingo.unrecParam.format([macroName, p]) )
|
|
}
|
|
}
|
|
|
|
// If we're followed by end-of-line, swallow the newline.
|
|
if ( wikifier.source.charAt(wikifier.nextMatch) == "\n" )
|
|
++wikifier.nextMatch
|
|
|
|
var where = above? wikifier.matchStart : wikifier.nextMatch
|
|
|
|
var table = createTiddlyElement( place, "table", null, "task" )
|
|
var tbody = createTiddlyElement( table, "tbody" )
|
|
var row = createTiddlyElement( tbody, "tr" )
|
|
var statusCell = createTiddlyElement( row, "td", null, "status" )
|
|
var descCell = createTiddlyElement( row, "td", null, "description" )
|
|
var curCell = createTiddlyElement( row, "td", null, "numeric" )
|
|
var addCell = createTiddlyElement( row, "td", null, "addtask" )
|
|
|
|
var descId = this.generateId()
|
|
var curId = this.generateId()
|
|
var descInput = createTiddlyElement( descCell, "input", descId )
|
|
var curInput = createTiddlyElement( curCell, "input", curId )
|
|
|
|
descInput.setAttribute( "type", "text" )
|
|
curInput .setAttribute( "type", "text" )
|
|
descInput.setAttribute( "size", "40")
|
|
curInput .setAttribute( "size", "6" )
|
|
descInput.setAttribute( "autocomplete", "off" );
|
|
curInput .setAttribute( "autocomplete", "off" );
|
|
descInput.setAttribute( "title", this.lingo.descTip );
|
|
curInput .setAttribute( "title", this.lingo.curTip );
|
|
|
|
var addAction = this.addTask( tiddler, where, descId, curId, above )
|
|
var addButton = createTiddlyButton( addCell, this.lingo.buttonText, this.lingo.buttonTip, addAction )
|
|
|
|
descInput.onkeypress = this.handleEnter(addAction)
|
|
curInput .onkeypress = descInput.onkeypress
|
|
addButton.onkeypress = this.handleSpace(addAction)
|
|
if ( focus || tiddler.taskadderLocation == where ) {
|
|
descInput.focus()
|
|
descInput.select()
|
|
}
|
|
},
|
|
|
|
// Returns a function that inserts a new task macro into the tiddler.
|
|
addTask: function( tiddler, where, descId, curId, above ) {
|
|
var macro = this, oldText = tiddler.text
|
|
return wrapEventHandler( function(e) {
|
|
if ( oldText !== tiddler.text ) {
|
|
alert( macro.lingo.notCurrent )
|
|
return false
|
|
}
|
|
var desc = document.getElementById(descId).value
|
|
var cur = document.getElementById(curId) .value
|
|
var init = tiddler.text.substring(0,where) + "<<task " + cur + ">> " + desc + "\n"
|
|
var text = init + tiddler.text.substring(where)
|
|
var title = tiddler.title
|
|
tiddler.taskadderLocation = (above? init.length : where)
|
|
try {
|
|
store.saveTiddler( title, title, text, config.options.txtUserName, new Date(), undefined )
|
|
//story.refreshTiddler( title, null, true )
|
|
}
|
|
finally {
|
|
delete tiddler.taskadderLocation
|
|
}
|
|
if ( config.options.chkAutoSave )
|
|
saveChanges()
|
|
} )
|
|
},
|
|
|
|
// Returns an event handler that delegates to two other functions: "matches" to decide
|
|
// whether to consume the event, and "addTask" to actually perform the work.
|
|
handleGeneric: function( addTask, matches ) {
|
|
return function(e) {
|
|
if (!e) var e = window.event
|
|
var consume = false
|
|
if ( matches(e) ) {
|
|
consume = true
|
|
addTask( e )
|
|
}
|
|
e.cancelBubble = consume;
|
|
if ( consume && e.stopPropagation ) e.stopPropagation();
|
|
return !consume;
|
|
}
|
|
},
|
|
|
|
// Returns an event handler that handles enter keys by calling another event handler
|
|
handleEnter: function( addTask ) {
|
|
return this.handleGeneric( addTask, function(e){return e.keyCode == 13 || e.keyCode == 10} ) // Different codes for Enter
|
|
},
|
|
|
|
// Returns an event handler that handles the space key by calling another event handler
|
|
handleSpace: function( addTask ) {
|
|
return this.handleGeneric( addTask, function(e){return (e.charCode||e.keyCode) == 32} )
|
|
},
|
|
|
|
counter: 0,
|
|
generateId: function() {
|
|
return "taskadder:" + String(this.counter++)
|
|
}
|
|
}
|
|
//}}}
|
|
/***
|
|
!Stylesheet
|
|
***/
|
|
//{{{
|
|
var stylesheet = '\
|
|
.viewer table.task, table.tasksum {\
|
|
width: 100%;\
|
|
padding: 0;\
|
|
border-collapse: collapse;\
|
|
}\
|
|
.viewer table.task {\
|
|
border: none;\
|
|
margin: 0;\
|
|
}\
|
|
table.tasksum, .viewer table.tasksum {\
|
|
border: solid 2px #999;\
|
|
margin: 3px 0;\
|
|
}\
|
|
table.tasksum td {\
|
|
text-align: center;\
|
|
border: 1px solid #ddd;\
|
|
background-color: #ffc;\
|
|
vertical-align: middle;\
|
|
margin: 0;\
|
|
padding: 0;\
|
|
}\
|
|
.viewer table.task tr {\
|
|
border: none;\
|
|
}\
|
|
.viewer table.task td {\
|
|
text-align: center;\
|
|
vertical-align: baseline;\
|
|
border: 1px solid #fff;\
|
|
background-color: inherit;\
|
|
margin: 0;\
|
|
padding: 0;\
|
|
}\
|
|
td.numeric {\
|
|
width: 3em;\
|
|
}\
|
|
table.task td.numeric div {\
|
|
border: 1px solid #ddd;\
|
|
background-color: #ffc;\
|
|
margin: 1px 0;\
|
|
padding: 0;\
|
|
}\
|
|
table.task td.original div {\
|
|
background-color: #fdd;\
|
|
}\
|
|
table.tasksum td.original {\
|
|
background-color: #fdd;\
|
|
}\
|
|
table.tasksum td.description {\
|
|
background-color: #e8e8e8;\
|
|
}\
|
|
table.task td.status {\
|
|
width: 1.5em;\
|
|
cursor: default;\
|
|
}\
|
|
table.task td.description, table.tasksum td.description {\
|
|
width: auto;\
|
|
text-align: left;\
|
|
padding: 0 3px;\
|
|
}\
|
|
table.task.done td.status,table.task.done td.description {\
|
|
color: #ccc;\
|
|
}\
|
|
table.task.done td.current, table.task.done td.remaining {\
|
|
visibility: hidden;\
|
|
}\
|
|
table.task.done td.spent div, table.tasksum tr.done td.current,\
|
|
table.tasksum tr.done td.spent, table.tasksum tr.done td.remaining {\
|
|
background-color: #eee;\
|
|
color: #aaa;\
|
|
}\
|
|
table.task.nascent td.description {\
|
|
color: #844;\
|
|
}\
|
|
table.task.nascent td.current div, table.tasksum tr.nascent td.numeric.current {\
|
|
font-weight: bold;\
|
|
color: #c00;\
|
|
background-color: #def;\
|
|
}\
|
|
table.task.nascent td.spent, table.task.nascent td.remaining {\
|
|
visibility: hidden;\
|
|
}\
|
|
td.remaining {\
|
|
font-weight: bold;\
|
|
}\
|
|
.adjustable {\
|
|
cursor: pointer; \
|
|
}\
|
|
table.task input {\
|
|
display: block;\
|
|
width: 100%;\
|
|
font: inherit;\
|
|
margin: 2px 0;\
|
|
padding: 0;\
|
|
border: 1px inset #999;\
|
|
}\
|
|
table.task td.numeric input {\
|
|
background-color: #ffc;\
|
|
text-align: center;\
|
|
}\
|
|
table.task td.addtask {\
|
|
width: 6em;\
|
|
border-left: 2px solid white;\
|
|
vertical-align: middle;\
|
|
}\
|
|
'
|
|
setStylesheet( stylesheet, "TaskMacroPluginStylesheet" )
|
|
//}}}
|
|
</pre>
|
|
</div>
|
|
<div title="TaskMacroReleaseNotes" modifier="LukeBlanshard" modified="200605102059" created="200605020308" tags="TaskMacro" server.type="file" server.host="file:///home/ct/.homepage/home.html" server.page.revision="200605102059">
|
|
<pre>!!Changes in 1.1.0
|
|
* Made the macros work in nested tiddlers (ie when one tiddler includes another using {{{<<tiddler>>}}} or something similar):
|
|
** Task summaries in the outer tiddler include the tasks from the inner one
|
|
** Using the editing shortcuts on the tasks as displayed in the outer tiddler correctly changes the inner tiddler and also redisplays the outer one
|
|
** Added sanity checks to the editing shortcuts so they will refuse to work if the tiddler has been modified behind their backs
|
|
* Made some small usability fixes:
|
|
** The "add task" button now responds to the Space key (hat tip: Daniel Baird)
|
|
** Double-clicking on a completed task's bullet now does the same thing as clicking on the elapsed time: it lets you adjust the time spent, giving you the option of resurrecting the task (hat tip: ~JackF)
|
|
** Reworked the focus handling of the taskadder macro so it works more intuitively, by refocusing on the same adder you just used
|
|
</pre>
|
|
</div>
|
|
<div title="TaskMacroTutorial" modifier="LukeBlanshard" modified="200605102059" created="200604082009" tags="TaskMacro" server.type="file" server.host="file:///home/ct/.homepage/home.html" server.page.revision="200605102059">
|
|
<pre>The task macro provided by the TaskMacroPlugin is for planning, estimating, and tracking detailed tasks such as those required for writing software. It is inspired by [[Joel Spolsky|http://www.joelonsoftware.com/articles/fog0000000245.html]]'s method for scheduling software development, also popularized by [[Voo2do|http://voo2do.com]] and [[XPlanner|http://xplanner.org]].
|
|
|
|
For changes since the previous version, see the TaskMacroReleaseNotes.
|
|
|
|
This tutorial leads you through the use of the task macro itself, and supporting macros that summarize lists of tasks and simplify the adding of tasks to a list. Follow along by clicking the links below. Or click the little down-arrow next to this tiddler's title, above, and choose "Open all" to have all the tutorial sections displayed at once.
|
|
|
|
</pre>
|
|
</div>
|
|
<div title="TaskSummaryViewTemplate" modifier="LukeBlanshard" modified="200604091859" created="200604082012" server.type="file" server.host="file:///home/ct/.homepage/home.html" server.page.revision="200604091859">
|
|
<pre><!---
|
|
Includes portions of [[TagglyTaggingViewTemplate|http://simonbaird.com/mptw/#TagglyTaggingViewTemplate]], v1.2 (16-Jan-2006).
|
|
Also adds a pair of tasksum macros around the tiddler, to summarize any contained tasks at the top. Removes the "-" in front of closeTiddler, which can easily bite you if you have a focusable element in a tiddler, such as a taskadder entry field.
|
|
Portions written by Luke Blanshard are hereby released into the public domain.
|
|
--->
|
|
<!--{{{-->
|
|
<div class="toolbar" macro="toolbar closeTiddler closeOthers +editTiddler permalink references jump newHere"></div>
|
|
<div class="tagglyTagged" macro="tags"></div>
|
|
<div><span class="title" macro="view title"></span><span class="miniTag" macro="miniTag"></span></div>
|
|
<div macro="tasksum start here"></div>
|
|
<div class="viewer" macro="view text wikified"></div>
|
|
<div macro="tasksum end"></div>
|
|
<div class="tagglyTagging" macro="tagglyListWithSort"></div>
|
|
<!--}}}-->
|
|
</pre>
|
|
</div>
|
|
<div title="TestSh" modifier="CehTeh" modified="200708182045" created="200708131509" tags="buildsys organization testsuite" changecount="12">
|
|
<pre>! The Test Script
|
|
To drive the various tests, we use the script {{{tests/test.sh}}}. All tests are run under valgrind control if available unless {{{VALGRINDFLAGS=DISABLE}}} is defined.
|
|
* The SCons buildsystem will build and run the testcode when executing the target {{{scons tests}}}.
|
|
* This test script is integrated in the automake build and will be used when {{{make check}}} is called.
|
|
|
|
! Options for running the Test Suite
|
|
One may define {{{TESTMODE}}} containing any one of the following strings:
|
|
* {{{FAST}}} only run tests which failed recently
|
|
* {{{FIRSTFAIL}}} abort the tests at the first failure
|
|
|
|
The variable {{{TESTSUITES}}} may contain a list of string which are used to select which tests are run. If not given, all available tests are run.
|
|
|
|
putting this together a very fast check (when using automake) while hacking on the source would look like:
|
|
{{{
|
|
VALGRINDFLAGS=DISABLE TESTMODE=FAST+FIRSTFAIL make check
|
|
}}}
|
|
This doesn't catch all errors, notably not regressions, but is useful to do coarse checks.
|
|
|
|
Running the testsuite with everything enabled is just:
|
|
{{{
|
|
make check
|
|
}}}
|
|
|
|
! Writing Tests
|
|
~Test-Definitons are written in files named {{{NNname.tests}}} in the {{{tests}}} dir, where NN is a number defining the order of the various test files, 'name' should be a descriptive name about whats going to be tested.
|
|
|
|
In a .tests file one has to define following:
|
|
* {{{TESTING <description> <binary>}}} set the program binary to be tested to <binary>, <description> should be a string which is displayed as header before running following tests
|
|
* {{{TEST <description> [optargs] <<END}}} run the previously set binary with [optargs], <description> is displayed when running this test. A detailed test spec must follow this command and be terminated with {{{END}}} on a single line. Test specs can contain following statements:
|
|
** {{{in: <line>}}} send <line> to stdin of the test program
|
|
** {{{out: <line>}}} expect <line> at the stdout of the test program
|
|
** {{{err: <line>}}} expect <line> at the stderr of the test program
|
|
** {{{return: <status>}}} expect <status> as exit status of the program
|
|
|
|
If no {{{out:}}} or {{{err:}}} is given, stdout and stderr are not considered as part of the test. If no {{{return:}}} is given, then 0 is expected.
|
|
|
|
!! Numbering Tests
|
|
It needs to be ensured that simpler tests come before more complex ones and that dependant tests come after their dependencies.
|
|
|
|
Here is the order suggested:
|
|
|00|The test system itself|
|
|
|01..|Infrastructure, package consistency etc.|
|
|
|10..|Basic support library functionality|
|
|
|20..|Higher level support library services|
|
|
|30..|Backend Unit tests|
|
|
|40..|Proc Layer Unit tests|
|
|
|50..|User interface Unit tests (Gui, Scripting)|
|
|
|60..|Unit interaction tests (Backend, Proc, UI, ...)|
|
|
|70..|Functionality tests on the complete program|
|
|
|80..|Reported bugs which can be expressed in a test case|
|
|
|90..|Optional tests, example code etc.|
|
|
|
|
</pre>
|
|
</div>
|
|
<div title="TestSuite" modifier="Ichthyostega" modified="200708231706" created="200708120254" tags="buildsys organization testsuite" changecount="16">
|
|
<pre>For running the automatic Tests, we use Cehteh's simple [[test.sh|TestSh]].
|
|
|
|
This page is a proposal (by Ichthyo) how the various tests could be organized.
|
|
* individual ''Testcases'' are classes, doing whatsoever and however they see fit.
|
|
* it is up to the individual test classes to take care / handle / isolate themself form any ''dependencies'' (similar to the [[philosophy of TestNG|http://www.beust.com/weblog/archives/000082.html]])
|
|
* Testcases are ''grouped'' together into thematic (Sub)-Testsuites. Each Testcase has an unique ID and can be tagged with several groupIDs
|
|
* for running a ''Testsuite'' (=distinct collection of tests) we build an executable linked against the test class objects.
|
|
* moreover, for ''simple Tests'', we can build separate stelf-contained executables or even use other scripts.
|
|
* the Testsuite executable provides some command line magic to select individual tests.
|
|
* Top-level Testsuites or ''~Test-Collections'' for [[test.sh|TestSh]] contain calls to the different (sub)-Suites, together with the expected results/output
|
|
|
|
!internal Testsuite runner
|
|
The class {{{test::Suite}}} (common/test/suite.hpp) helps building an executable which will run all //registered// test case objects, or some group of such testcases. Each test case implements a simple interface and thus provides a {{{run (args)}}} function, moreover, it registers itself immediately alongside with his definition; this works by the usual trick of defining a static class object and calling some registration function from the constructor of this static var. See the following __hello-world-Example__:
|
|
{{{
|
|
#include <iostream>
|
|
#include "common/test/run.hpp"
|
|
|
|
class HelloWorld_test : public Test
|
|
{
|
|
virtual void run(Arg arg)
|
|
{
|
|
greeting();
|
|
}
|
|
|
|
void greeting()
|
|
{
|
|
std::cout << "This is how the world ends...\n";
|
|
}
|
|
};
|
|
|
|
/** Register this test class to be invoked in some test groups (suites) */
|
|
LAUNCHER (HelloWorld_test, "unit function common");
|
|
}}}
|
|
Notes:
|
|
* type Arg is {{{typedef std::vector<string> & Arg;}}}
|
|
* this vector may be {{{size()==0}}}, which means no comandline args available.
|
|
* otherwise arg[0] is always the ID (normally the classname) of the test
|
|
* the following args may contain further arguments passed from system commandline.
|
|
* the test can/should produce output that can be checked with Cehteh's [[./test.sh|TestSh]].
|
|
* the macro "LAUNCHER" expands to {{{Launch<HelloWorld_test> run_HelloWorld_test("HelloWorld_test","unit function common");}}}
|
|
* note the second parameter to the macro (or the Laucher-ctor) is a space-delimited list of group names
|
|
* thus any test can declare itself as belonging to some groups, and we can create a {{{test::Suite}}} for each group if we want.
|
|
|
|
!!!invoking the testrunner
|
|
The class {{{test::TestOption}}} predefines a boost-commandlineparser to support the following optons:
|
|
|
|
|>|!{{{./test-components --group <groupID> [testID [arguments...]]}}}|
|
|
|{{{--help}}}| options summary|
|
|
|{{{--group|-g <groupID>}}}| build a Testsuite out of all tests from this group. If missing, ALL tests will be included |
|
|
|{{{[testID]}}}| (optional) one single testcase. If missing, all testcases of the group will be invoked |
|
|
|{{{--describe}}}| print all registered tests to stdout in a format suited for use with test.sh |
|
|
Further commandline arguments are deliverd to a single testcase only if you specify a {{{testID}}}. Otherwise, all commandline arguments remaining after options parsing will be discarded and all tests of the suite will be run with an commandline vector of size()==0
|
|
|
|
|
|
!conventions for the Buildsystem
|
|
to help with automating the build, ichthyo would appreciate to have the following conventions.
|
|
* in the {{{tests}}} directory are
|
|
** the testdefinitions together with {{{test.sh}}}
|
|
** the test-executables, which should named according to the pattern {{{test-XXX}}}
|
|
* below are the source directories for each of the aforementioned test-executables. When such a source directory is named "XXX", the corresponding executable is "test-XXX"
|
|
* each of the source directories, which actually could be source trees, will be compiled and linked together with the Lumiera core classes and files. Thus, it needs to contain exactly //one// main(), but by using commandline parameters, one executable can drive a lot of different tests.
|
|
|
|
-------
|
|
//as of 18.8.2007, ichthyo has implemented this scheme for the SCons build//
|
|
</pre>
|
|
</div>
|
|
<div title="TextAreaPlugin" modifier="Jeremy" created="200601261745" tags="systemConfig" server.type="file" server.host="file:///home/ct/.homepage/home.html" server.page.revision="200601261745">
|
|
<pre>/***
|
|
''TextAreaPlugin for TiddlyWiki version 2.0''
|
|
^^author: Eric Shulman - ELS Design Studios
|
|
source: http://www.elsdesign.com/tiddlywiki/#TextAreaPlugin
|
|
license: [[Creative Commons Attribution-ShareAlike 2.5 License|http://creativecommons.org/licenses/by-sa/2.5/]]^^
|
|
|
|
This plugin 'hijacks' the TW core function, ''Story.prototype.focusTiddler()'', so it can add special 'keyDown' handlers to adjust several behaviors associated with the textarea control used in the tiddler editor. Specifically, it:
|
|
* Adds text search INSIDE of edit fields.^^
|
|
Use ~CTRL-F for "Find" (prompts for search text), and ~CTRL-G for "Find Next" (uses previous search text)^^
|
|
* Enables TAB characters to be entered into field content^^
|
|
(instead of moving to next field)^^
|
|
* Option to set cursor at top of edit field instead of auto-selecting contents^^
|
|
(see configuration section for checkbox)^^
|
|
!!!!!Configuration
|
|
<<<
|
|
<<option chkDisableAutoSelect>> place cursor at start of textarea instead of pre-selecting content
|
|
<<option chkTextAreaExtensions>> add control-f (find), control-g (find again) and allow TABs as input in textarea
|
|
<<<
|
|
!!!!!Installation
|
|
<<<
|
|
Import (or copy/paste) the following tiddlers into your document:
|
|
''TextAreaPlugin'' (tagged with <<tag systemConfig>>)
|
|
<<<
|
|
!!!!!Revision History
|
|
<<<
|
|
''2006.01.22 [1.0.1]''
|
|
only add extra key processing for TEXTAREA elements (not other edit fields).
|
|
added option to enable/disable textarea keydown extensions (default is "standard keys" only)
|
|
''2006.01.22 [1.0.0]''
|
|
Moved from temporary "System Tweaks" tiddler into 'real' TextAreaPlugin tiddler.
|
|
<<<
|
|
!!!!!Code
|
|
***/
|
|
//{{{
|
|
version.extensions.textAreaPlugin= {major: 1, minor: 0, revision: 1, date: new Date(2006,1,23)};
|
|
//}}}
|
|
|
|
//{{{
|
|
if (!config.options.chkDisableAutoSelect) config.options.chkDisableAutoSelect=false; // default to standard action
|
|
if (!config.options.chkTextAreaExtensions) config.options.chkTextAreaExtensions=false; // default to standard action
|
|
|
|
// Focus a specified tiddler. Attempts to focus the specified field, otherwise the first edit field it finds
|
|
Story.prototype.focusTiddler = function(title,field)
|
|
{
|
|
var tiddler = document.getElementById(this.idPrefix + title);
|
|
if(tiddler != null)
|
|
{
|
|
var children = tiddler.getElementsByTagName("*")
|
|
var e = null;
|
|
for (var t=0; t<children.length; t++)
|
|
{
|
|
var c = children[t];
|
|
if(c.tagName.toLowerCase() == "input" || c.tagName.toLowerCase() == "textarea")
|
|
{
|
|
if(!e)
|
|
e = c;
|
|
if(c.getAttribute("edit") == field)
|
|
e = c;
|
|
}
|
|
}
|
|
if(e)
|
|
{
|
|
e.focus();
|
|
e.select(); // select entire contents
|
|
|
|
// TWEAK: add TAB and "find" key handlers
|
|
if (config.options.chkTextAreaExtensions) // add extra key handlers
|
|
addKeyDownHandlers(e);
|
|
|
|
// TWEAK: option to NOT autoselect contents
|
|
if (config.options.chkDisableAutoSelect) // set cursor to start of field content
|
|
if (e.setSelectionRange) e.setSelectionRange(0,0); // for FF
|
|
else if (e.createTextRange) { var r=e.createTextRange(); r.collapse(true); r.select(); } // for IE
|
|
|
|
}
|
|
}
|
|
}
|
|
//}}}
|
|
|
|
//{{{
|
|
function addKeyDownHandlers(e)
|
|
{
|
|
// exit if not textarea or element doesn't allow selections
|
|
if (e.tagName.toLowerCase()!="textarea" || !e.setSelectionRange) return;
|
|
|
|
// utility function: exits keydown handler and prevents browser from processing the keystroke
|
|
var processed=function(ev) { ev.cancelBubble=true; if (ev.stopPropagation) ev.stopPropagation(); return false; }
|
|
|
|
// capture keypress in edit field
|
|
e.onkeydown = function(ev) { if (!ev) var ev=window.event;
|
|
|
|
// process TAB
|
|
if (!ev.shiftKey && ev.keyCode==9) {
|
|
// replace current selection with a TAB character
|
|
var start=e.selectionStart; var end=e.selectionEnd;
|
|
e.value=e.value.substr(0,start)+String.fromCharCode(9)+e.value.substr(end);
|
|
// update insertion point, scroll it into view
|
|
e.setSelectionRange(start+1,start+1);
|
|
var linecount=e.value.split('\n').length;
|
|
var thisline=e.value.substr(0,e.selectionStart).split('\n').length-1;
|
|
e.scrollTop=Math.floor((thisline-e.rows/2)*e.scrollHeight/linecount);
|
|
return processed(ev);
|
|
}
|
|
|
|
// process CTRL-F (find matching text) or CTRL-G (find next match)
|
|
if (ev.ctrlKey && (ev.keyCode==70||ev.keyCode==71)) {
|
|
// if ctrl-f or no previous search, prompt for search text (default to previous text or current selection)... if no search text, exit
|
|
if (ev.keyCode==70||!e.find||!e.find.length)
|
|
{ var f=prompt("find:",e.find?e.find:e.value.substring(e.selectionStart,e.selectionEnd)); e.focus(); e.find=f?f:e.find; }
|
|
if (!e.find||!e.find.length) return processed(ev);
|
|
// do case-insensitive match with 'wraparound'... if not found, alert and exit
|
|
var newstart=e.value.toLowerCase().indexOf(e.find.toLowerCase(),e.selectionStart+1);
|
|
if (newstart==-1) newstart=e.value.toLowerCase().indexOf(e.find.toLowerCase());
|
|
if (newstart==-1) { alert("'"+e.find+"' not found"); e.focus(); return processed(ev); }
|
|
// set new selection, scroll it into view, and report line position in status bar
|
|
e.setSelectionRange(newstart,newstart+e.find.length);
|
|
var linecount=e.value.split('\n').length;
|
|
var thisline=e.value.substr(0,e.selectionStart).split('\n').length;
|
|
e.scrollTop=Math.floor((thisline-1-e.rows/2)*e.scrollHeight/linecount);
|
|
window.status="line: "+thisline+"/"+linecount;
|
|
return processed(ev);
|
|
}
|
|
}
|
|
}
|
|
//}}}</pre>
|
|
</div>
|
|
<div title="TiddlyWiki" modifier="Ichthyostega" modified="200810151552" created="200706260506" tags="excludeMissing" changecount="5">
|
|
<pre>The Name of the Software driving this Wiki. Is is written completely in ~JavaScript and contained in one single HTML page.
|
|
Thus no server and no network connection is needed. Simply open the file in your browser and save changes locally. As the wiki HTML is located in the Lumiera source tree, all changes will be managed and distributed via [[GIT|GitNotes]]. While doing so, you sometimes will have to merge conflicing changes manually in the HTML source. There is a 'empty.html' in the same folder serving as template for generating new wikis. Please refrain from editing it.
|
|
* see GettingStarted
|
|
* see [[Homepage|http://tiddlywiki.com]], [[Wiki-Markup|http://tiddlywiki.org/wiki/TiddlyWiki_Markup]]
|
|
</pre>
|
|
</div>
|
|
<div title="whatInBOUML" modifier="Ichthyostega" modified="200708051535" created="200706260559" tags="discuss policy" changecount="3">
|
|
<pre>The question to find out about is: how much of the coding to do with the help of BOUML. Basically, BOUML is capable to permanently support the coding; you can define all entities, fields and methods in the UML model an just develop the method bodies //conventionally// with a text editor.
|
|
|
|
__Ichthyo__ tends to be sceptical about this approach. While it probably will work, it is questionable if it will result in &raquo;good code&laquo; the fear is, that this rigid hierarchical structure distracts from the more complex semantical concerns.
|
|
|
|
Another approach could be to use BOUML just to create the basic structures and from this point on rather utilizing it for technical documentation.
|
|
|
|
!!After some use
|
|
After having used BOUML now (August 07) to some extent, Ichthyo notes down his observation:
|
|
# __Assessment__
|
|
#* it is fast, rock stable and complete up to a medium requirement level.
|
|
#* the drawing functions are just basic and insufficient for corporate level demands, just enough for creating design drafts
|
|
#* I miss real world round trip capabilities. Basically, it works fine as long as BOUML is the primary programming environment
|
|
# __Benefits__: setting up new Entities together with all relations and the most important operations is very fast and convienient with bouml. You can get a fairly complete and consistent skeleton of some subsystem much more rapidly than when creating classes from templates in a normal IDE
|
|
# __Drawbacks__: For fleshing out more implementation centric parts, it is seriousely lacking expressiveness, as far as C++ is concerned. This is partially due to the nature of UML. As a warning example, look at the source code of BOUML together with it's "plugouts". It has about 250kLOC, several thousand source files, most of this caused by duplicating whole class hierarchies, set up in a classificatory manner (which is a big no-no for most modern object oriented programming styles).
|
|
|
|
!!!conclusion
|
|
I want to try out the following aproach
|
|
*use it for reasoning about structure
|
|
*use it for setting up all new major entities
|
|
*don't use it for //real programming//</pre>
|
|
</div>
|
|
</div>
|
|
<!--POST-STOREAREA-->
|
|
<!--POST-BODY-START-->
|
|
<!--POST-BODY-END-->
|
|
<script type="text/javascript">
|
|
//<![CDATA[
|
|
//
|
|
// Please note:
|
|
//
|
|
// * This code is designed to be readable but for compactness it only includes brief comments. You can see fuller comments
|
|
// in the project Subversion repository at http://svn.tiddlywiki.org/Trunk/core/
|
|
//
|
|
// * You should never need to modify this source code directly. TiddlyWiki is carefully designed to allow deep customisation
|
|
// without changing the core code. Please consult the development group at http://groups.google.com/group/TiddlyWikiDev
|
|
//
|
|
|
|
//--
|
|
//-- Configuration repository
|
|
//--
|
|
|
|
// Miscellaneous options
|
|
var config = {
|
|
numRssItems: 20, // Number of items in the RSS feed
|
|
animDuration: 400, // Duration of UI animations in milliseconds
|
|
cascadeFast: 20, // Speed for cascade animations (higher == slower)
|
|
cascadeSlow: 60, // Speed for EasterEgg cascade animations
|
|
cascadeDepth: 5 // Depth of cascade animation
|
|
};
|
|
|
|
// Adaptors
|
|
config.adaptors = {};
|
|
|
|
// Backstage tasks
|
|
config.tasks = {};
|
|
|
|
// Annotations
|
|
config.annotations = {};
|
|
|
|
// Custom fields to be automatically added to new tiddlers
|
|
config.defaultCustomFields = {};
|
|
|
|
// Messages
|
|
config.messages = {
|
|
messageClose: {},
|
|
dates: {},
|
|
tiddlerPopup: {}
|
|
};
|
|
|
|
// Options that can be set in the options panel and/or cookies
|
|
config.options = {
|
|
chkRegExpSearch: false,
|
|
chkCaseSensitiveSearch: false,
|
|
chkAnimate: true,
|
|
chkSaveBackups: true,
|
|
chkAutoSave: false,
|
|
chkGenerateAnRssFeed: false,
|
|
chkSaveEmptyTemplate: false,
|
|
chkOpenInNewWindow: true,
|
|
chkToggleLinks: false,
|
|
chkHttpReadOnly: true,
|
|
chkForceMinorUpdate: false,
|
|
chkConfirmDelete: true,
|
|
chkInsertTabs: false,
|
|
chkUsePreForStorage: true, // Whether to use <pre> format for storage
|
|
chkDisplayStartupTime: false,
|
|
txtBackupFolder: "",
|
|
txtMainTab: "tabTimeline",
|
|
txtMoreTab: "moreTabAll",
|
|
txtMaxEditRows: "30",
|
|
txtFileSystemCharSet: "UTF-8"
|
|
};
|
|
config.optionsDesc = {};
|
|
|
|
// List of notification functions to be called when certain tiddlers are changed or deleted
|
|
config.notifyTiddlers = [
|
|
{name: "StyleSheetLayout", notify: refreshStyles},
|
|
{name: "StyleSheetColors", notify: refreshStyles},
|
|
{name: "StyleSheet", notify: refreshStyles},
|
|
{name: "StyleSheetPrint", notify: refreshStyles},
|
|
{name: "PageTemplate", notify: refreshPageTemplate},
|
|
{name: "SiteTitle", notify: refreshPageTitle},
|
|
{name: "SiteSubtitle", notify: refreshPageTitle},
|
|
{name: "ColorPalette", notify: refreshColorPalette},
|
|
{name: null, notify: refreshDisplay}
|
|
];
|
|
|
|
// Default tiddler templates
|
|
var DEFAULT_VIEW_TEMPLATE = 1;
|
|
var DEFAULT_EDIT_TEMPLATE = 2;
|
|
config.tiddlerTemplates = {
|
|
1: "ViewTemplate",
|
|
2: "EditTemplate"
|
|
};
|
|
|
|
// More messages (rather a legacy layout that shouldn't really be like this)
|
|
config.views = {
|
|
wikified: {
|
|
tag: {}
|
|
},
|
|
editor: {
|
|
tagChooser: {}
|
|
}
|
|
};
|
|
|
|
// Backstage tasks
|
|
config.backstageTasks = ["save","sync","importTask","tweak","plugins"];
|
|
|
|
// Macros; each has a 'handler' member that is inserted later
|
|
config.macros = {
|
|
today: {},
|
|
version: {},
|
|
search: {sizeTextbox: 15},
|
|
tiddler: {},
|
|
tag: {},
|
|
tags: {},
|
|
tagging: {},
|
|
timeline: {},
|
|
allTags: {},
|
|
list: {
|
|
all: {},
|
|
missing: {},
|
|
orphans: {},
|
|
shadowed: {},
|
|
touched: {}
|
|
},
|
|
closeAll: {},
|
|
permaview: {},
|
|
saveChanges: {},
|
|
slider: {},
|
|
option: {},
|
|
options: {},
|
|
newTiddler: {},
|
|
newJournal: {},
|
|
sparkline: {},
|
|
tabs: {},
|
|
gradient: {},
|
|
message: {},
|
|
view: {},
|
|
edit: {},
|
|
tagChooser: {},
|
|
toolbar: {},
|
|
br: {},
|
|
plugins: {},
|
|
refreshDisplay: {},
|
|
importTiddlers: {},
|
|
sync: {},
|
|
annotations: {}
|
|
};
|
|
|
|
// Commands supported by the toolbar macro
|
|
config.commands = {
|
|
closeTiddler: {},
|
|
closeOthers: {},
|
|
editTiddler: {},
|
|
saveTiddler: {hideReadOnly: true},
|
|
cancelTiddler: {},
|
|
deleteTiddler: {hideReadOnly: true},
|
|
permalink: {},
|
|
references: {type: "popup"},
|
|
jump: {type: "popup"},
|
|
syncing: {type: "popup"},
|
|
fields: {type: "popup"}
|
|
};
|
|
|
|
// Browser detection... In a very few places, there's nothing else for it but to know what browser we're using.
|
|
config.userAgent = navigator.userAgent.toLowerCase();
|
|
config.browser = {
|
|
isIE: config.userAgent.indexOf("msie") != -1 && config.userAgent.indexOf("opera") == -1,
|
|
isGecko: config.userAgent.indexOf("gecko") != -1,
|
|
ieVersion: /MSIE (\d.\d)/i.exec(config.userAgent), // config.browser.ieVersion[1], if it exists, will be the IE version string, eg "6.0"
|
|
isSafari: config.userAgent.indexOf("applewebkit") != -1,
|
|
isBadSafari: !((new RegExp("[\u0150\u0170]","g")).test("\u0150")),
|
|
firefoxDate: /gecko\/(\d{8})/i.exec(config.userAgent), // config.browser.firefoxDate[1], if it exists, will be Firefox release date as "YYYYMMDD"
|
|
isOpera: config.userAgent.indexOf("opera") != -1,
|
|
isLinux: config.userAgent.indexOf("linux") != -1,
|
|
isUnix: config.userAgent.indexOf("x11") != -1,
|
|
isMac: config.userAgent.indexOf("mac") != -1,
|
|
isWindows: config.userAgent.indexOf("win") != -1
|
|
};
|
|
|
|
// Basic regular expressions
|
|
config.textPrimitives = {
|
|
upperLetter: "[A-Z\u00c0-\u00de\u0150\u0170]",
|
|
lowerLetter: "[a-z0-9_\\-\u00df-\u00ff\u0151\u0171]",
|
|
anyLetter: "[A-Za-z0-9_\\-\u00c0-\u00de\u00df-\u00ff\u0150\u0170\u0151\u0171]",
|
|
anyLetterStrict: "[A-Za-z0-9\u00c0-\u00de\u00df-\u00ff\u0150\u0170\u0151\u0171]"
|
|
};
|
|
if(config.browser.isBadSafari) {
|
|
config.textPrimitives = {
|
|
upperLetter: "[A-Z\u00c0-\u00de]",
|
|
lowerLetter: "[a-z0-9_\\-\u00df-\u00ff]",
|
|
anyLetter: "[A-Za-z0-9_\\-\u00c0-\u00de\u00df-\u00ff]",
|
|
anyLetterStrict: "[A-Za-z0-9\u00c0-\u00de\u00df-\u00ff]"
|
|
};
|
|
}
|
|
config.textPrimitives.sliceSeparator = "::";
|
|
config.textPrimitives.urlPattern = "[a-z]{3,8}:[^\\s:'\"][^\\s'\"]*(?:/|\\b)";
|
|
config.textPrimitives.unWikiLink = "~";
|
|
config.textPrimitives.wikiLink = "(?:(?:" + config.textPrimitives.upperLetter + "+" +
|
|
config.textPrimitives.lowerLetter + "+" +
|
|
config.textPrimitives.upperLetter +
|
|
config.textPrimitives.anyLetter + "*)|(?:" +
|
|
config.textPrimitives.upperLetter + "{2,}" +
|
|
config.textPrimitives.lowerLetter + "+))";
|
|
|
|
config.textPrimitives.cssLookahead = "(?:(" + config.textPrimitives.anyLetter + "+)\\(([^\\)\\|\\n]+)(?:\\):))|(?:(" + config.textPrimitives.anyLetter + "+):([^;\\|\\n]+);)";
|
|
config.textPrimitives.cssLookaheadRegExp = new RegExp(config.textPrimitives.cssLookahead,"mg");
|
|
|
|
config.textPrimitives.brackettedLink = "\\[\\[([^\\]]+)\\]\\]";
|
|
config.textPrimitives.titledBrackettedLink = "\\[\\[([^\\[\\]\\|]+)\\|([^\\[\\]\\|]+)\\]\\]";
|
|
config.textPrimitives.tiddlerForcedLinkRegExp = new RegExp("(?:" + config.textPrimitives.titledBrackettedLink + ")|(?:" +
|
|
config.textPrimitives.brackettedLink + ")|(?:" +
|
|
config.textPrimitives.urlPattern + ")","mg");
|
|
config.textPrimitives.tiddlerAnyLinkRegExp = new RegExp("("+ config.textPrimitives.wikiLink + ")|(?:" +
|
|
config.textPrimitives.titledBrackettedLink + ")|(?:" +
|
|
config.textPrimitives.brackettedLink + ")|(?:" +
|
|
config.textPrimitives.urlPattern + ")","mg");
|
|
|
|
config.glyphs = {
|
|
browsers: [
|
|
function() {return config.browser.isIE;},
|
|
function() {return true}
|
|
],
|
|
currBrowser: null,
|
|
codes: {
|
|
downTriangle: ["\u25BC","\u25BE"],
|
|
downArrow: ["\u2193","\u2193"],
|
|
bentArrowLeft: ["\u2190","\u21A9"],
|
|
bentArrowRight: ["\u2192","\u21AA"]
|
|
}
|
|
};
|
|
|
|
//--
|
|
//-- Shadow tiddlers
|
|
//--
|
|
|
|
config.shadowTiddlers = {
|
|
StyleSheet: "",
|
|
MarkupPreHead: "<!--{{{-->\n<link rel='alternate' type='application/rss+xml' title='RSS' href='index.xml'/>\n<!--}}}-->",
|
|
MarkupPostHead: "",
|
|
MarkupPreBody: "",
|
|
MarkupPostBody: "",
|
|
TabTimeline: '<<timeline>>',
|
|
TabAll: '<<list all>>',
|
|
TabTags: '<<allTags excludeLists>>',
|
|
TabMoreMissing: '<<list missing>>',
|
|
TabMoreOrphans: '<<list orphans>>',
|
|
TabMoreShadowed: '<<list shadowed>>',
|
|
AdvancedOptions: '<<options>>',
|
|
PluginManager: '<<plugins>>',
|
|
ImportTiddlers: '<<importTiddlers>>'
|
|
};
|
|
|
|
//--
|
|
//-- Translateable strings
|
|
//--
|
|
|
|
// Strings in "double quotes" should be translated; strings in 'single quotes' should be left alone
|
|
|
|
merge(config.options,{
|
|
txtUserName: "YourName"});
|
|
|
|
merge(config.tasks,{
|
|
save: {text: "save", tooltip: "Save your changes to this TiddlyWiki", action: saveChanges},
|
|
sync: {text: "sync", tooltip: "Synchronise changes with other TiddlyWiki files and servers", content: '<<sync>>'},
|
|
importTask: {text: "import", tooltip: "Import tiddlers and plugins from other TiddlyWiki files and servers", content: '<<importTiddlers>>'},
|
|
tweak: {text: "tweak", tooltip: "Tweak the appearance and behaviour of TiddlyWiki", content: '<<options>>'},
|
|
plugins: {text: "plugins", tooltip: "Manage installed plugins", content: '<<plugins>>'}
|
|
});
|
|
|
|
// Options that can be set in the options panel and/or cookies
|
|
merge(config.optionsDesc,{
|
|
txtUserName: "Username for signing your edits",
|
|
chkRegExpSearch: "Enable regular expressions for searches",
|
|
chkCaseSensitiveSearch: "Case-sensitive searching",
|
|
chkAnimate: "Enable animations",
|
|
chkSaveBackups: "Keep backup file when saving changes",
|
|
chkAutoSave: "Automatically save changes",
|
|
chkGenerateAnRssFeed: "Generate an RSS feed when saving changes",
|
|
chkSaveEmptyTemplate: "Generate an empty template when saving changes",
|
|
chkOpenInNewWindow: "Open external links in a new window",
|
|
chkToggleLinks: "Clicking on links to open tiddlers causes them to close",
|
|
chkHttpReadOnly: "Hide editing features when viewed over HTTP",
|
|
chkForceMinorUpdate: "Don't update modifier username and date when editing tiddlers",
|
|
chkConfirmDelete: "Require confirmation before deleting tiddlers",
|
|
chkInsertTabs: "Use the tab key to insert tab characters instead of moving between fields",
|
|
txtBackupFolder: "Name of folder to use for backups",
|
|
txtMaxEditRows: "Maximum number of rows in edit boxes",
|
|
txtFileSystemCharSet: "Default character set for saving changes (Firefox/Mozilla only)"});
|
|
|
|
merge(config.messages,{
|
|
customConfigError: "Problems were encountered loading plugins. See PluginManager for details",
|
|
pluginError: "Error: %0",
|
|
pluginDisabled: "Not executed because disabled via 'systemConfigDisable' tag",
|
|
pluginForced: "Executed because forced via 'systemConfigForce' tag",
|
|
pluginVersionError: "Not executed because this plugin needs a newer version of TiddlyWiki",
|
|
nothingSelected: "Nothing is selected. You must select one or more items first",
|
|
savedSnapshotError: "It appears that this TiddlyWiki has been incorrectly saved. Please see http://www.tiddlywiki.com/#DownloadSoftware for details",
|
|
subtitleUnknown: "(unknown)",
|
|
undefinedTiddlerToolTip: "The tiddler '%0' doesn't yet exist",
|
|
shadowedTiddlerToolTip: "The tiddler '%0' doesn't yet exist, but has a pre-defined shadow value",
|
|
tiddlerLinkTooltip: "%0 - %1, %2",
|
|
externalLinkTooltip: "External link to %0",
|
|
noTags: "There are no tagged tiddlers",
|
|
notFileUrlError: "You need to save this TiddlyWiki to a file before you can save changes",
|
|
cantSaveError: "It's not possible to save changes. Possible reasons include:\n- your browser doesn't support saving (Firefox, Internet Explorer, Safari and Opera all work if properly configured)\n- the pathname to your TiddlyWiki file contains illegal characters\n- the TiddlyWiki HTML file has been moved or renamed",
|
|
invalidFileError: "The original file '%0' does not appear to be a valid TiddlyWiki",
|
|
backupSaved: "Backup saved",
|
|
backupFailed: "Failed to save backup file",
|
|
rssSaved: "RSS feed saved",
|
|
rssFailed: "Failed to save RSS feed file",
|
|
emptySaved: "Empty template saved",
|
|
emptyFailed: "Failed to save empty template file",
|
|
mainSaved: "Main TiddlyWiki file saved",
|
|
mainFailed: "Failed to save main TiddlyWiki file. Your changes have not been saved",
|
|
macroError: "Error in macro <<\%0>>",
|
|
macroErrorDetails: "Error while executing macro <<\%0>>:\n%1",
|
|
missingMacro: "No such macro",
|
|
overwriteWarning: "A tiddler named '%0' already exists. Choose OK to overwrite it",
|
|
unsavedChangesWarning: "WARNING! There are unsaved changes in TiddlyWiki\n\nChoose OK to save\nChoose CANCEL to discard",
|
|
confirmExit: "--------------------------------\n\nThere are unsaved changes in TiddlyWiki. If you continue you will lose those changes\n\n--------------------------------",
|
|
saveInstructions: "SaveChanges",
|
|
unsupportedTWFormat: "Unsupported TiddlyWiki format '%0'",
|
|
tiddlerSaveError: "Error when saving tiddler '%0'",
|
|
tiddlerLoadError: "Error when loading tiddler '%0'",
|
|
wrongSaveFormat: "Cannot save with storage format '%0'. Using standard format for save.",
|
|
invalidFieldName: "Invalid field name %0",
|
|
fieldCannotBeChanged: "Field '%0' cannot be changed",
|
|
loadingMissingTiddler: "Attempting to retrieve the tiddler '%0' from the '%1' server at:\n\n'%2' in the workspace '%3'"});
|
|
|
|
merge(config.messages.messageClose,{
|
|
text: "close",
|
|
tooltip: "close this message area"});
|
|
|
|
config.messages.backstage = {
|
|
open: {text: "backstage", tooltip: "Open the backstage area to perform authoring and editing tasks"},
|
|
close: {text: "close", tooltip: "Close the backstage area"},
|
|
prompt: "backstage: ",
|
|
decal: {
|
|
edit: {text: "edit", tooltip: "Edit the tiddler '%0'"}
|
|
}
|
|
};
|
|
|
|
config.messages.listView = {
|
|
tiddlerTooltip: "Click for the full text of this tiddler",
|
|
previewUnavailable: "(preview not available)"
|
|
};
|
|
|
|
config.messages.dates.months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November","December"];
|
|
config.messages.dates.days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
|
config.messages.dates.shortMonths = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
config.messages.dates.shortDays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
// suffixes for dates, eg "1st","2nd","3rd"..."30th","31st"
|
|
config.messages.dates.daySuffixes = ["st","nd","rd","th","th","th","th","th","th","th",
|
|
"th","th","th","th","th","th","th","th","th","th",
|
|
"st","nd","rd","th","th","th","th","th","th","th",
|
|
"st"];
|
|
config.messages.dates.am = "am";
|
|
config.messages.dates.pm = "pm";
|
|
|
|
merge(config.messages.tiddlerPopup,{
|
|
});
|
|
|
|
merge(config.views.wikified.tag,{
|
|
labelNoTags: "no tags",
|
|
labelTags: "tags: ",
|
|
openTag: "Open tag '%0'",
|
|
tooltip: "Show tiddlers tagged with '%0'",
|
|
openAllText: "Open all",
|
|
openAllTooltip: "Open all of these tiddlers",
|
|
popupNone: "No other tiddlers tagged with '%0'"});
|
|
|
|
merge(config.views.wikified,{
|
|
defaultText: "The tiddler '%0' doesn't yet exist. Double-click to create it",
|
|
defaultModifier: "(missing)",
|
|
shadowModifier: "(built-in shadow tiddler)",
|
|
dateFormat: "DD MMM YYYY",
|
|
createdPrompt: "created"});
|
|
|
|
merge(config.views.editor,{
|
|
tagPrompt: "Type tags separated with spaces, [[use double square brackets]] if necessary, or add existing",
|
|
defaultText: "Type the text for '%0'"});
|
|
|
|
merge(config.views.editor.tagChooser,{
|
|
text: "tags",
|
|
tooltip: "Choose existing tags to add to this tiddler",
|
|
popupNone: "There are no tags defined",
|
|
tagTooltip: "Add the tag '%0'"});
|
|
|
|
merge(config.messages,{
|
|
sizeTemplates:
|
|
[
|
|
{unit: 1024*1024*1024, template: "%0\u00a0GB"},
|
|
{unit: 1024*1024, template: "%0\u00a0MB"},
|
|
{unit: 1024, template: "%0\u00a0KB"},
|
|
{unit: 1, template: "%0\u00a0B"}
|
|
]});
|
|
|
|
merge(config.macros.search,{
|
|
label: "search",
|
|
prompt: "Search this TiddlyWiki",
|
|
accessKey: "F",
|
|
successMsg: "%0 tiddlers found matching %1",
|
|
failureMsg: "No tiddlers found matching %0"});
|
|
|
|
merge(config.macros.tagging,{
|
|
label: "tagging: ",
|
|
labelNotTag: "not tagging",
|
|
tooltip: "List of tiddlers tagged with '%0'"});
|
|
|
|
merge(config.macros.timeline,{
|
|
dateFormat: "DD MMM YYYY"});
|
|
|
|
merge(config.macros.allTags,{
|
|
tooltip: "Show tiddlers tagged with '%0'",
|
|
noTags: "There are no tagged tiddlers"});
|
|
|
|
config.macros.list.all.prompt = "All tiddlers in alphabetical order";
|
|
config.macros.list.missing.prompt = "Tiddlers that have links to them but are not defined";
|
|
config.macros.list.orphans.prompt = "Tiddlers that are not linked to from any other tiddlers";
|
|
config.macros.list.shadowed.prompt = "Tiddlers shadowed with default contents";
|
|
config.macros.list.touched.prompt = "Tiddlers that have been modified locally";
|
|
|
|
merge(config.macros.closeAll,{
|
|
label: "close all",
|
|
prompt: "Close all displayed tiddlers (except any that are being edited)"});
|
|
|
|
merge(config.macros.permaview,{
|
|
label: "permaview",
|
|
prompt: "Link to an URL that retrieves all the currently displayed tiddlers"});
|
|
|
|
merge(config.macros.saveChanges,{
|
|
label: "save changes",
|
|
prompt: "Save all tiddlers to create a new TiddlyWiki",
|
|
accessKey: "S"});
|
|
|
|
merge(config.macros.newTiddler,{
|
|
label: "new tiddler",
|
|
prompt: "Create a new tiddler",
|
|
title: "New Tiddler",
|
|
accessKey: "N"});
|
|
|
|
merge(config.macros.newJournal,{
|
|
label: "new journal",
|
|
prompt: "Create a new tiddler from the current date and time",
|
|
accessKey: "J"});
|
|
|
|
merge(config.macros.options,{
|
|
wizardTitle: "Tweak advanced options",
|
|
step1Title: "These options are saved in cookies in your browser",
|
|
step1Html: "<input type='hidden' name='markList'></input><br><input type='checkbox' checked='false' name='chkUnknown'>Show unknown options</input>",
|
|
unknownDescription: "//(unknown)//",
|
|
listViewTemplate: {
|
|
columns: [
|
|
{name: 'Option', field: 'option', title: "Option", type: 'String'},
|
|
{name: 'Description', field: 'description', title: "Description", type: 'WikiText'},
|
|
{name: 'Name', field: 'name', title: "Name", type: 'String'}
|
|
],
|
|
rowClasses: [
|
|
{className: 'lowlight', field: 'lowlight'}
|
|
]}
|
|
});
|
|
|
|
merge(config.macros.plugins,{
|
|
wizardTitle: "Manage plugins",
|
|
step1Title: "Currently loaded plugins",
|
|
step1Html: "<input type='hidden' name='markList'></input>", // DO NOT TRANSLATE
|
|
skippedText: "(This plugin has not been executed because it was added since startup)",
|
|
noPluginText: "There are no plugins installed",
|
|
confirmDeleteText: "Are you sure you want to delete these plugins:\n\n%0",
|
|
removeLabel: "remove systemConfig tag",
|
|
removePrompt: "Remove systemConfig tag",
|
|
deleteLabel: "delete",
|
|
deletePrompt: "Delete these tiddlers forever",
|
|
listViewTemplate: {
|
|
columns: [
|
|
{name: 'Selected', field: 'Selected', rowName: 'title', type: 'Selector'},
|
|
{name: 'Tiddler', field: 'tiddler', title: "Tiddler", type: 'Tiddler'},
|
|
{name: 'Size', field: 'size', tiddlerLink: 'size', title: "Size", type: 'Size'},
|
|
{name: 'Forced', field: 'forced', title: "Forced", tag: 'systemConfigForce', type: 'TagCheckbox'},
|
|
{name: 'Disabled', field: 'disabled', title: "Disabled", tag: 'systemConfigDisable', type: 'TagCheckbox'},
|
|
{name: 'Executed', field: 'executed', title: "Loaded", type: 'Boolean', trueText: "Yes", falseText: "No"},
|
|
{name: 'Startup Time', field: 'startupTime', title: "Startup Time", type: 'String'},
|
|
{name: 'Error', field: 'error', title: "Status", type: 'Boolean', trueText: "Error", falseText: "OK"},
|
|
{name: 'Log', field: 'log', title: "Log", type: 'StringList'}
|
|
],
|
|
rowClasses: [
|
|
{className: 'error', field: 'error'},
|
|
{className: 'warning', field: 'warning'}
|
|
]}
|
|
});
|
|
|
|
merge(config.macros.toolbar,{
|
|
moreLabel: "more",
|
|
morePrompt: "Reveal further commands"
|
|
});
|
|
|
|
merge(config.macros.refreshDisplay,{
|
|
label: "refresh",
|
|
prompt: "Redraw the entire TiddlyWiki display"
|
|
});
|
|
|
|
merge(config.macros.importTiddlers,{
|
|
readOnlyWarning: "You cannot import into a read-only TiddlyWiki file. Try opening it from a file:// URL",
|
|
wizardTitle: "Import tiddlers from another file or server",
|
|
step1Title: "Step 1: Locate the server or TiddlyWiki file",
|
|
step1Html: "Specify the type of the server: <select name='selTypes'><option value=''>Choose...</option></select><br>Enter the URL or pathname here: <input type='text' size=50 name='txtPath'><br>...or browse for a file: <input type='file' size=50 name='txtBrowse'><br><hr>...or select a pre-defined feed: <select name='selFeeds'><option value=''>Choose...</option></select>",
|
|
openLabel: "open",
|
|
openPrompt: "Open the connection to this file or server",
|
|
openError: "There were problems fetching the tiddlywiki file",
|
|
statusOpenHost: "Opening the host",
|
|
statusGetWorkspaceList: "Getting the list of available workspaces",
|
|
step2Title: "Step 2: Choose the workspace",
|
|
step2Html: "Enter a workspace name: <input type='text' size=50 name='txtWorkspace'><br>...or select a workspace: <select name='selWorkspace'><option value=''>Choose...</option></select>",
|
|
cancelLabel: "cancel",
|
|
cancelPrompt: "Cancel this import",
|
|
statusOpenWorkspace: "Opening the workspace",
|
|
statusGetTiddlerList: "Getting the list of available tiddlers",
|
|
step3Title: "Step 3: Choose the tiddlers to import",
|
|
step3Html: "<input type='hidden' name='markList'></input><br><input type='checkbox' checked='true' name='chkSync'>Keep these tiddlers linked to this server so that you can synchronise subsequent changes</input><br><input type='checkbox' name='chkSave'>Save the details of this server in a 'systemServer' tiddler called:</input> <input type='text' size=25 name='txtSaveTiddler'>",
|
|
importLabel: "import",
|
|
importPrompt: "Import these tiddlers",
|
|
confirmOverwriteText: "Are you sure you want to overwrite these tiddlers:\n\n%0",
|
|
step4Title: "Step 4: Importing %0 tiddler(s)",
|
|
step4Html: "<input type='hidden' name='markReport'></input>", // DO NOT TRANSLATE
|
|
doneLabel: "done",
|
|
donePrompt: "Close this wizard",
|
|
statusDoingImport: "Importing tiddlers",
|
|
statusDoneImport: "All tiddlers imported",
|
|
systemServerNamePattern: "%2 on %1",
|
|
systemServerNamePatternNoWorkspace: "%1",
|
|
confirmOverwriteSaveTiddler: "The tiddler '%0' already exists. Click 'OK' to overwrite it with the details of this server, or 'Cancel' to leave it unchanged",
|
|
serverSaveTemplate: "|''Type:''|%0|\n|''URL:''|%1|\n|''Workspace:''|%2|\n\nThis tiddler was automatically created to record the details of this server",
|
|
serverSaveModifier: "(System)",
|
|
listViewTemplate: {
|
|
columns: [
|
|
{name: 'Selected', field: 'Selected', rowName: 'title', type: 'Selector'},
|
|
{name: 'Tiddler', field: 'tiddler', title: "Tiddler", type: 'Tiddler'},
|
|
{name: 'Size', field: 'size', tiddlerLink: 'size', title: "Size", type: 'Size'},
|
|
{name: 'Tags', field: 'tags', title: "Tags", type: 'Tags'}
|
|
],
|
|
rowClasses: [
|
|
]}
|
|
});
|
|
|
|
merge(config.macros.sync,{
|
|
listViewTemplate: {
|
|
columns: [
|
|
{name: 'Selected', field: 'selected', rowName: 'title', type: 'Selector'},
|
|
{name: 'Tiddler', field: 'tiddler', title: "Tiddler", type: 'Tiddler'},
|
|
{name: 'Server Type', field: 'serverType', title: "Server type", type: 'String'},
|
|
{name: 'Server Host', field: 'serverHost', title: "Server host", type: 'String'},
|
|
{name: 'Server Workspace', field: 'serverWorkspace', title: "Server workspace", type: 'String'},
|
|
{name: 'Status', field: 'status', title: "Synchronisation status", type: 'String'},
|
|
{name: 'Server URL', field: 'serverUrl', title: "Server URL", text: "View", type: 'Link'}
|
|
],
|
|
rowClasses: [
|
|
],
|
|
buttons: [
|
|
{caption: "Sync these tiddlers", name: 'sync'}
|
|
]},
|
|
wizardTitle: "Synchronize with external servers and files",
|
|
step1Title: "Choose the tiddlers you want to synchronize",
|
|
step1Html: "<input type='hidden' name='markList'></input>", // DO NOT TRANSLATE
|
|
syncLabel: "sync",
|
|
syncPrompt: "Sync these tiddlers",
|
|
hasChanged: "Changed while unplugged",
|
|
hasNotChanged: "Unchanged while unplugged",
|
|
syncStatusList: {
|
|
none: {text: "...", color: "none"},
|
|
changedServer: {text: "Changed on server", color: '#80ff80'},
|
|
changedLocally: {text: "Changed while unplugged", color: '#80ff80'},
|
|
changedBoth: {text: "Changed while unplugged and on server", color: '#ff8080'},
|
|
notFound: {text: "Not found on server", color: '#ffff80'},
|
|
putToServer: {text: "Saved update on server", color: '#ff80ff'},
|
|
gotFromServer: {text: "Retrieved update from server", color: '#80ffff'}
|
|
}
|
|
});
|
|
|
|
merge(config.macros.annotations,{
|
|
});
|
|
|
|
merge(config.commands.closeTiddler,{
|
|
text: "close",
|
|
tooltip: "Close this tiddler"});
|
|
|
|
merge(config.commands.closeOthers,{
|
|
text: "close others",
|
|
tooltip: "Close all other tiddlers"});
|
|
|
|
merge(config.commands.editTiddler,{
|
|
text: "edit",
|
|
tooltip: "Edit this tiddler",
|
|
readOnlyText: "view",
|
|
readOnlyTooltip: "View the source of this tiddler"});
|
|
|
|
merge(config.commands.saveTiddler,{
|
|
text: "done",
|
|
tooltip: "Save changes to this tiddler"});
|
|
|
|
merge(config.commands.cancelTiddler,{
|
|
text: "cancel",
|
|
tooltip: "Undo changes to this tiddler",
|
|
warning: "Are you sure you want to abandon your changes to '%0'?",
|
|
readOnlyText: "done",
|
|
readOnlyTooltip: "View this tiddler normally"});
|
|
|
|
merge(config.commands.deleteTiddler,{
|
|
text: "delete",
|
|
tooltip: "Delete this tiddler",
|
|
warning: "Are you sure you want to delete '%0'?"});
|
|
|
|
merge(config.commands.permalink,{
|
|
text: "permalink",
|
|
tooltip: "Permalink for this tiddler"});
|
|
|
|
merge(config.commands.references,{
|
|
text: "references",
|
|
tooltip: "Show tiddlers that link to this one",
|
|
popupNone: "No references"});
|
|
|
|
merge(config.commands.jump,{
|
|
text: "jump",
|
|
tooltip: "Jump to another open tiddler"});
|
|
|
|
merge(config.commands.syncing,{
|
|
text: "syncing",
|
|
tooltip: "Control synchronisation of this tiddler with a server or external file",
|
|
currentlySyncing: "<div>Currently syncing via <span class='popupHighlight'>'%0'</span> to:</"+"div><div>host: <span class='popupHighlight'>%1</span></"+"div><div>workspace: <span class='popupHighlight'>%2</span></"+"div>", // Note escaping of closing <div> tag
|
|
notCurrentlySyncing: "Not currently syncing",
|
|
captionUnSync: "Stop synchronising this tiddler",
|
|
chooseServer: "Synchronise this tiddler with another server:",
|
|
currServerMarker: "\u25cf ",
|
|
notCurrServerMarker: " "});
|
|
|
|
merge(config.commands.fields,{
|
|
text: "fields",
|
|
tooltip: "Show the extended fields of this tiddler",
|
|
emptyText: "There are no extended fields for this tiddler",
|
|
listViewTemplate: {
|
|
columns: [
|
|
{name: 'Field', field: 'field', title: "Field", type: 'String'},
|
|
{name: 'Value', field: 'value', title: "Value", type: 'String'}
|
|
],
|
|
rowClasses: [
|
|
],
|
|
buttons: [
|
|
]}});
|
|
|
|
merge(config.shadowTiddlers,{
|
|
DefaultTiddlers: "GettingStarted",
|
|
MainMenu: "GettingStarted",
|
|
SiteTitle: "My TiddlyWiki",
|
|
SiteSubtitle: "a reusable non-linear personal web notebook",
|
|
SiteUrl: "http://www.tiddlywiki.com/",
|
|
SideBarOptions: '<<search>><<closeAll>><<permaview>><<newTiddler>><<newJournal "DD MMM YYYY">><<saveChanges>><<slider chkSliderOptionsPanel OptionsPanel "options »" "Change TiddlyWiki advanced options">>',
|
|
SideBarTabs: '<<tabs txtMainTab "Timeline" "Timeline" TabTimeline "All" "All tiddlers" TabAll "Tags" "All tags" TabTags "More" "More lists" TabMore>>',
|
|
TabMore: '<<tabs txtMoreTab "Missing" "Missing tiddlers" TabMoreMissing "Orphans" "Orphaned tiddlers" TabMoreOrphans "Shadowed" "Shadowed tiddlers" TabMoreShadowed>>'});
|
|
|
|
merge(config.annotations,{
|
|
AdvancedOptions: "This shadow tiddler provides access to several advanced options",
|
|
ColorPalette: "These values in this shadow tiddler determine the colour scheme of the ~TiddlyWiki user interface",
|
|
DefaultTiddlers: "The tiddlers listed in this shadow tiddler will be automatically displayed when ~TiddlyWiki starts up",
|
|
EditTemplate: "The HTML template in this shadow tiddler determines how tiddlers look while they are being edited",
|
|
GettingStarted: "This shadow tiddler provides basic usage instructions",
|
|
ImportTiddlers: "This shadow tiddler provides access to importing tiddlers",
|
|
MainMenu: "This shadow tiddler is used as the contents of the main menu in the left-hand column of the screen",
|
|
MarkupPreHead: "This tiddler is inserted at the top of the <head> section of the TiddlyWiki HTML file",
|
|
MarkupPostHead: "This tiddler is inserted at the bottom of the <head> section of the TiddlyWiki HTML file",
|
|
MarkupPreBody: "This tiddler is inserted at the top of the <body> section of the TiddlyWiki HTML file",
|
|
MarkupPostBody: "This tiddler is inserted at the end of the <body> section of the TiddlyWiki HTML file immediately before the script block",
|
|
OptionsPanel: "This shadow tiddler is used as the contents of the options panel slider in the right-hand sidebar",
|
|
PageTemplate: "The HTML template in this shadow tiddler determines the overall ~TiddlyWiki layout",
|
|
PluginManager: "This shadow tiddler provides access to the plugin manager",
|
|
SideBarOptions: "This shadow tiddler is used as the contents of the option panel in the right-hand sidebar",
|
|
SideBarTabs: "This shadow tiddler is used as the contents of the tabs panel in the right-hand sidebar",
|
|
SiteSubtitle: "This shadow tiddler is used as the second part of the page title",
|
|
SiteTitle: "This shadow tiddler is used as the first part of the page title",
|
|
SiteUrl: "This shadow tiddler should be set to the full target URL for publication",
|
|
StyleSheetColours: "This shadow tiddler contains CSS definitions related to the color of page elements",
|
|
StyleSheet: "This tiddler can contain custom CSS definitions",
|
|
StyleSheetLayout: "This shadow tiddler contains CSS definitions related to the layout of page elements",
|
|
StyleSheetLocale: "This shadow tiddler contains CSS definitions related to the translation locale",
|
|
StyleSheetPrint: "This shadow tiddler contains CSS definitions for printing",
|
|
TabAll: "This shadow tiddler contains the contents of the 'All' tab in the right-hand sidebar",
|
|
TabMore: "This shadow tiddler contains the contents of the 'More' tab in the right-hand sidebar",
|
|
TabMoreMissing: "This shadow tiddler contains the contents of the 'Missing' tab in the right-hand sidebar",
|
|
TabMoreOrphans: "This shadow tiddler contains the contents of the 'Orphans' tab in the right-hand sidebar",
|
|
TabMoreShadowed: "This shadow tiddler contains the contents of the 'Shadowed' tab in the right-hand sidebar",
|
|
TabTags: "This shadow tiddler contains the contents of the 'Tags' tab in the right-hand sidebar",
|
|
TabTimeline: "This shadow tiddler contains the contents of the 'Timeline' tab in the right-hand sidebar",
|
|
ViewTemplate: "The HTML template in this shadow tiddler determines how tiddlers look"
|
|
});
|
|
|
|
//--
|
|
//-- Main
|
|
//--
|
|
|
|
var params = null; // Command line parameters
|
|
var store = null; // TiddlyWiki storage
|
|
var story = null; // Main story
|
|
var formatter = null; // Default formatters for the wikifier
|
|
config.parsers = {}; // Hashmap of alternative parsers for the wikifier
|
|
var anim = new Animator(); // Animation engine
|
|
var readOnly = false; // Whether we're in readonly mode
|
|
var highlightHack = null; // Embarrassing hack department...
|
|
var hadConfirmExit = false; // Don't warn more than once
|
|
var safeMode = false; // Disable all plugins and cookies
|
|
var installedPlugins = []; // Information filled in when plugins are executed
|
|
var startingUp = false; // Whether we're in the process of starting up
|
|
var pluginInfo,tiddler; // Used to pass information to plugins in loadPlugins()
|
|
|
|
// Whether to use the JavaSaver applet
|
|
var useJavaSaver = config.browser.isSafari || config.browser.isOpera;
|
|
|
|
// Starting up
|
|
function main()
|
|
{
|
|
var t9,t8,t7,t6,t5,t4,t3,t2,t1,t0 = new Date();
|
|
startingUp = true;
|
|
window.onbeforeunload = function(e) {if(window.confirmExit) return confirmExit();};
|
|
params = getParameters();
|
|
if(params)
|
|
params = params.parseParams("open",null,false);
|
|
store = new TiddlyWiki();
|
|
invokeParamifier(params,"oninit");
|
|
story = new Story("tiddlerDisplay","tiddler");
|
|
addEvent(document,"click",Popup.onDocumentClick);
|
|
saveTest();
|
|
loadOptionsCookie();
|
|
for(var s=0; s<config.notifyTiddlers.length; s++)
|
|
store.addNotification(config.notifyTiddlers[s].name,config.notifyTiddlers[s].notify);
|
|
t1 = new Date();
|
|
store.loadFromDiv("storeArea","store",true);
|
|
t2 = new Date();
|
|
loadShadowTiddlers();
|
|
t3 = new Date();
|
|
invokeParamifier(params,"onload");
|
|
t4 = new Date();
|
|
readOnly = (window.location.protocol == "file:") ? false : config.options.chkHttpReadOnly;
|
|
var pluginProblem = loadPlugins();
|
|
t5 = new Date();
|
|
formatter = new Formatter(config.formatters);
|
|
invokeParamifier(params,"onconfig");
|
|
t6 = new Date();
|
|
store.notifyAll();
|
|
t7 = new Date();
|
|
restart();
|
|
t8 = new Date();
|
|
if(pluginProblem) {
|
|
story.displayTiddler(null,"PluginManager");
|
|
displayMessage(config.messages.customConfigError);
|
|
}
|
|
for(var m in config.macros) {
|
|
if(config.macros[m].init)
|
|
config.macros[m].init();
|
|
}
|
|
if(!readOnly)
|
|
backstage.init();
|
|
t9 = new Date();
|
|
if(config.options.chkDisplayStartupTime) {
|
|
displayMessage("Load in " + (t2-t1) + " ms");
|
|
displayMessage("Loadshadows in " + (t3-t2) + " ms");
|
|
displayMessage("Loadplugins in " + (t5-t4) + " ms");
|
|
displayMessage("Notify in " + (t7-t6) + " ms");
|
|
displayMessage("Restart in " + (t8-t7) + " ms");
|
|
displayMessage("Total startup in " + (t9-t0) + " ms");
|
|
}
|
|
startingUp = false;
|
|
}
|
|
|
|
// Restarting
|
|
function restart()
|
|
{
|
|
invokeParamifier(params,"onstart");
|
|
if(story.isEmpty()) {
|
|
var defaultParams = store.getTiddlerText("DefaultTiddlers").parseParams("open",null,false);
|
|
invokeParamifier(defaultParams,"onstart");
|
|
}
|
|
window.scrollTo(0,0);
|
|
}
|
|
|
|
function saveTest()
|
|
{
|
|
var s = document.getElementById("saveTest");
|
|
if(s.hasChildNodes())
|
|
alert(config.messages.savedSnapshotError);
|
|
s.appendChild(document.createTextNode("savetest"));
|
|
}
|
|
|
|
function loadShadowTiddlers()
|
|
{
|
|
var shadows = new TiddlyWiki();
|
|
shadows.loadFromDiv("shadowArea","shadows",true);
|
|
shadows.forEachTiddler(function(title,tiddler){config.shadowTiddlers[title] = tiddler.text;});
|
|
delete shadows;
|
|
}
|
|
|
|
function loadPlugins()
|
|
{
|
|
if(safeMode)
|
|
return false;
|
|
var tiddlers = store.getTaggedTiddlers("systemConfig");
|
|
var toLoad = [];
|
|
var nLoaded = 0;
|
|
var map = {};
|
|
var nPlugins = tiddlers.length;
|
|
installedPlugins = [];
|
|
for(var i=0; i<nPlugins; i++) {
|
|
var p = getPluginInfo(tiddlers[i]);
|
|
installedPlugins[i] = p;
|
|
var n = p.Name;
|
|
if(n)
|
|
map[n] = p;
|
|
if(n = p.Source)
|
|
map[n] = p;
|
|
}
|
|
var visit = function(p) {
|
|
if(!p || p.done)
|
|
return;
|
|
p.done = 1;
|
|
var reqs = p.Requires;
|
|
if(reqs) {
|
|
reqs = reqs.readBracketedList();
|
|
for(var i=0; i<reqs.length; i++)
|
|
visit(map[reqs[i]]);
|
|
}
|
|
toLoad.push(p);
|
|
};
|
|
for(i=0; i<nPlugins; i++)
|
|
visit(installedPlugins[i]);
|
|
for(i=0; i<toLoad.length; i++) {
|
|
p = toLoad[i];
|
|
pluginInfo = p;
|
|
tiddler = p.tiddler;
|
|
if(isPluginExecutable(p)) {
|
|
if(isPluginEnabled(p)) {
|
|
p.executed = true;
|
|
var startTime = new Date();
|
|
try {
|
|
if(tiddler.text)
|
|
window.eval(tiddler.text);
|
|
nLoaded++;
|
|
} catch(ex) {
|
|
p.log.push(config.messages.pluginError.format([exceptionText(ex)]));
|
|
p.error = true;
|
|
}
|
|
pluginInfo.startupTime = String((new Date()) - startTime) + "ms";
|
|
} else {
|
|
nPlugins--;
|
|
}
|
|
} else {
|
|
p.warning = true;
|
|
}
|
|
}
|
|
return nLoaded != nPlugins;
|
|
}
|
|
|
|
function getPluginInfo(tiddler)
|
|
{
|
|
var p = store.getTiddlerSlices(tiddler.title,["Name","Description","Version","Requires","CoreVersion","Date","Source","Author","License","Browsers"]);
|
|
p.tiddler = tiddler;
|
|
p.title = tiddler.title;
|
|
p.log = [];
|
|
return p;
|
|
}
|
|
|
|
// Check that a particular plugin is valid for execution
|
|
function isPluginExecutable(plugin)
|
|
{
|
|
if(plugin.tiddler.isTagged("systemConfigForce"))
|
|
return verifyTail(plugin,true,config.messages.pluginForced);
|
|
if(plugin["CoreVersion"]) {
|
|
var coreVersion = plugin["CoreVersion"].split(".");
|
|
var w = parseInt(coreVersion[0]) - version.major;
|
|
if(w == 0 && coreVersion[1])
|
|
w = parseInt(coreVersion[1]) - version.minor;
|
|
if(w == 0 && coreVersion[2])
|
|
w = parseInt(coreVersion[2]) - version.revision;
|
|
if(w > 0)
|
|
return verifyTail(plugin,false,config.messages.pluginVersionError);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
function isPluginEnabled(plugin)
|
|
{
|
|
if(plugin.tiddler.isTagged("systemConfigDisable"))
|
|
return verifyTail(plugin,false,config.messages.pluginDisabled);
|
|
return true;
|
|
}
|
|
|
|
function verifyTail(plugin,result,message)
|
|
{
|
|
plugin.log.push(message);
|
|
return result;
|
|
}
|
|
|
|
function invokeMacro(place,macro,params,wikifier,tiddler)
|
|
{
|
|
try {
|
|
var m = config.macros[macro];
|
|
if(m && m.handler)
|
|
m.handler(place,macro,params.readMacroParams(),wikifier,params,tiddler);
|
|
else
|
|
createTiddlyError(place,config.messages.macroError.format([macro]),config.messages.macroErrorDetails.format([macro,config.messages.missingMacro]));
|
|
} catch(ex) {
|
|
createTiddlyError(place,config.messages.macroError.format([macro]),config.messages.macroErrorDetails.format([macro,ex.toString()]));
|
|
}
|
|
}
|
|
|
|
//--
|
|
//-- Paramifiers
|
|
//--
|
|
|
|
function getParameters()
|
|
{
|
|
var p = null;
|
|
if(window.location.hash) {
|
|
p = decodeURI(window.location.hash.substr(1));
|
|
if(config.browser.firefoxDate != null && config.browser.firefoxDate[1] < "20051111")
|
|
p = convertUTF8ToUnicode(p);
|
|
}
|
|
return p;
|
|
}
|
|
|
|
function invokeParamifier(params,handler)
|
|
{
|
|
if(!params || params.length == undefined || params.length <= 1)
|
|
return;
|
|
for(var t=1; t<params.length; t++) {
|
|
var p = config.paramifiers[params[t].name];
|
|
if(p && p[handler] instanceof Function)
|
|
p[handler](params[t].value);
|
|
}
|
|
}
|
|
|
|
config.paramifiers = {};
|
|
|
|
config.paramifiers.start = {
|
|
oninit: function(v) {
|
|
safeMode = v.toLowerCase() == "safe";
|
|
}
|
|
};
|
|
|
|
config.paramifiers.open = {
|
|
onstart: function(v) {
|
|
story.displayTiddler("bottom",v,null,false,null);
|
|
}
|
|
};
|
|
|
|
config.paramifiers.story = {
|
|
onstart: function(v) {
|
|
var list = store.getTiddlerText(v,"").parseParams("open",null,false);
|
|
invokeParamifier(list,"onstart");
|
|
}
|
|
};
|
|
|
|
config.paramifiers.search = {
|
|
onstart: function(v) {
|
|
story.search(v,false,false);
|
|
}
|
|
};
|
|
|
|
config.paramifiers.searchRegExp = {
|
|
onstart: function(v) {
|
|
story.prototype.search(v,false,true);
|
|
}
|
|
};
|
|
|
|
config.paramifiers.tag = {
|
|
onstart: function(v) {
|
|
var tagged = store.getTaggedTiddlers(v,"title");
|
|
for(var t=0; t<tagged.length; t++)
|
|
story.displayTiddler("bottom",tagged[t].title,null,false,null);
|
|
}
|
|
};
|
|
|
|
config.paramifiers.newTiddler = {
|
|
onstart: function(v) {
|
|
if(!readOnly) {
|
|
story.displayTiddler(null,v,DEFAULT_EDIT_TEMPLATE);
|
|
story.focusTiddler(v,"text");
|
|
}
|
|
}
|
|
};
|
|
|
|
config.paramifiers.newJournal = {
|
|
onstart: function(v) {
|
|
if(!readOnly) {
|
|
var now = new Date();
|
|
var title = now.formatString(v.trim());
|
|
story.displayTiddler(null,title,DEFAULT_EDIT_TEMPLATE);
|
|
story.focusTiddler(title,"text");
|
|
}
|
|
}
|
|
};
|
|
|
|
config.paramifiers.readOnly = {
|
|
onconfig: function(v) {
|
|
var p = v.toLowerCase();
|
|
readOnly = p == "yes" ? true : (p == "no" ? false : readOnly);
|
|
}
|
|
};
|
|
|
|
//--
|
|
//-- Formatter helpers
|
|
//--
|
|
|
|
function Formatter(formatters)
|
|
{
|
|
this.formatters = [];
|
|
var pattern = [];
|
|
for(var n=0; n<formatters.length; n++) {
|
|
pattern.push("(" + formatters[n].match + ")");
|
|
this.formatters.push(formatters[n]);
|
|
}
|
|
this.formatterRegExp = new RegExp(pattern.join("|"),"mg");
|
|
}
|
|
|
|
config.formatterHelpers = {
|
|
|
|
createElementAndWikify: function(w)
|
|
{
|
|
w.subWikifyTerm(createTiddlyElement(w.output,this.element),this.termRegExp);
|
|
},
|
|
|
|
inlineCssHelper: function(w)
|
|
{
|
|
var styles = [];
|
|
config.textPrimitives.cssLookaheadRegExp.lastIndex = w.nextMatch;
|
|
var lookaheadMatch = config.textPrimitives.cssLookaheadRegExp.exec(w.source);
|
|
while(lookaheadMatch && lookaheadMatch.index == w.nextMatch) {
|
|
var s,v;
|
|
if(lookaheadMatch[1]) {
|
|
s = lookaheadMatch[1].unDash();
|
|
v = lookaheadMatch[2];
|
|
} else {
|
|
s = lookaheadMatch[3].unDash();
|
|
v = lookaheadMatch[4];
|
|
}
|
|
if (s=="bgcolor")
|
|
s = "backgroundColor";
|
|
styles.push({style: s, value: v});
|
|
w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length;
|
|
config.textPrimitives.cssLookaheadRegExp.lastIndex = w.nextMatch;
|
|
lookaheadMatch = config.textPrimitives.cssLookaheadRegExp.exec(w.source);
|
|
}
|
|
return styles;
|
|
},
|
|
|
|
applyCssHelper: function(e,styles)
|
|
{
|
|
for(var t=0; t< styles.length; t++) {
|
|
try {
|
|
e.style[styles[t].style] = styles[t].value;
|
|
} catch (ex) {
|
|
}
|
|
}
|
|
},
|
|
|
|
enclosedTextHelper: function(w)
|
|
{
|
|
this.lookaheadRegExp.lastIndex = w.matchStart;
|
|
var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
|
|
if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
|
|
var text = lookaheadMatch[1];
|
|
if(config.browser.isIE)
|
|
text = text.replace(/\n/g,"\r");
|
|
createTiddlyElement(w.output,this.element,null,null,text);
|
|
w.nextMatch = lookaheadMatch.index + lookaheadMatch[0].length;
|
|
}
|
|
},
|
|
|
|
isExternalLink: function(link)
|
|
{
|
|
if(store.tiddlerExists(link) || store.isShadowTiddler(link)) {
|
|
return false;
|
|
}
|
|
var urlRegExp = new RegExp(config.textPrimitives.urlPattern,"mg");
|
|
if(urlRegExp.exec(link)) {
|
|
return true;
|
|
}
|
|
if (link.indexOf(".")!=-1 || link.indexOf("\\")!=-1 || link.indexOf("/")!=-1){
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
};
|
|
|
|
//--
|
|
//-- Standard formatters
|
|
//--
|
|
|
|
config.formatters = [
|
|
{
|
|
name: "table",
|
|
match: "^\\|(?:[^\\n]*)\\|(?:[fhck]?)$",
|
|
lookaheadRegExp: /^\|([^\n]*)\|([fhck]?)$/mg,
|
|
rowTermRegExp: /(\|(?:[fhck]?)$\n?)/mg,
|
|
cellRegExp: /(?:\|([^\n\|]*)\|)|(\|[fhck]?$\n?)/mg,
|
|
cellTermRegExp: /((?:\x20*)\|)/mg,
|
|
rowTypes: {"c":"caption", "h":"thead", "":"tbody", "f":"tfoot"},
|
|
|
|
handler: function(w)
|
|
{
|
|
var table = createTiddlyElement(w.output,"table",null,"twtable");
|
|
var prevColumns = [];
|
|
var currRowType = null;
|
|
var rowContainer;
|
|
var rowCount = 0;
|
|
w.nextMatch = w.matchStart;
|
|
this.lookaheadRegExp.lastIndex = w.nextMatch;
|
|
var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
|
|
while(lookaheadMatch && lookaheadMatch.index == w.nextMatch) {
|
|
var nextRowType = lookaheadMatch[2];
|
|
if(nextRowType == "k") {
|
|
table.className = lookaheadMatch[1];
|
|
w.nextMatch += lookaheadMatch[0].length+1;
|
|
} else {
|
|
if(nextRowType != currRowType) {
|
|
rowContainer = createTiddlyElement(table,this.rowTypes[nextRowType]);
|
|
currRowType = nextRowType;
|
|
}
|
|
if(currRowType == "c") {
|
|
// Caption
|
|
w.nextMatch++;
|
|
if(rowContainer != table.firstChild)
|
|
table.insertBefore(rowContainer,table.firstChild);
|
|
rowContainer.setAttribute("align",rowCount == 0?"top":"bottom");
|
|
w.subWikifyTerm(rowContainer,this.rowTermRegExp);
|
|
} else {
|
|
this.rowHandler(w,createTiddlyElement(rowContainer,"tr",null,(rowCount&1)?"oddRow":"evenRow"),prevColumns);
|
|
rowCount++;
|
|
}
|
|
}
|
|
this.lookaheadRegExp.lastIndex = w.nextMatch;
|
|
lookaheadMatch = this.lookaheadRegExp.exec(w.source);
|
|
}
|
|
},
|
|
rowHandler: function(w,e,prevColumns)
|
|
{
|
|
var col = 0;
|
|
var colSpanCount = 1;
|
|
var prevCell = null;
|
|
this.cellRegExp.lastIndex = w.nextMatch;
|
|
var cellMatch = this.cellRegExp.exec(w.source);
|
|
while(cellMatch && cellMatch.index == w.nextMatch) {
|
|
if(cellMatch[1] == "~") {
|
|
// Rowspan
|
|
var last = prevColumns[col];
|
|
if(last) {
|
|
last.rowSpanCount++;
|
|
last.element.setAttribute("rowspan",last.rowSpanCount);
|
|
last.element.setAttribute("rowSpan",last.rowSpanCount); // Needed for IE
|
|
last.element.valign = "center";
|
|
}
|
|
w.nextMatch = this.cellRegExp.lastIndex-1;
|
|
} else if(cellMatch[1] == ">") {
|
|
// Colspan
|
|
colSpanCount++;
|
|
w.nextMatch = this.cellRegExp.lastIndex-1;
|
|
} else if(cellMatch[2]) {
|
|
// End of row
|
|
if(prevCell && colSpanCount > 1) {
|
|
prevCell.setAttribute("colspan",colSpanCount);
|
|
prevCell.setAttribute("colSpan",colSpanCount); // Needed for IE
|
|
}
|
|
w.nextMatch = this.cellRegExp.lastIndex;
|
|
break;
|
|
} else {
|
|
// Cell
|
|
w.nextMatch++;
|
|
var styles = config.formatterHelpers.inlineCssHelper(w);
|
|
var spaceLeft = false;
|
|
var chr = w.source.substr(w.nextMatch,1);
|
|
while(chr == " ") {
|
|
spaceLeft = true;
|
|
w.nextMatch++;
|
|
chr = w.source.substr(w.nextMatch,1);
|
|
}
|
|
var cell;
|
|
if(chr == "!") {
|
|
cell = createTiddlyElement(e,"th");
|
|
w.nextMatch++;
|
|
} else {
|
|
cell = createTiddlyElement(e,"td");
|
|
}
|
|
prevCell = cell;
|
|
prevColumns[col] = {rowSpanCount:1,element:cell};
|
|
if(colSpanCount > 1) {
|
|
cell.setAttribute("colspan",colSpanCount);
|
|
cell.setAttribute("colSpan",colSpanCount); // Needed for IE
|
|
colSpanCount = 1;
|
|
}
|
|
config.formatterHelpers.applyCssHelper(cell,styles);
|
|
w.subWikifyTerm(cell,this.cellTermRegExp);
|
|
if(w.matchText.substr(w.matchText.length-2,1) == " ") // spaceRight
|
|
cell.align = spaceLeft ? "center" : "left";
|
|
else if(spaceLeft)
|
|
cell.align = "right";
|
|
w.nextMatch--;
|
|
}
|
|
col++;
|
|
this.cellRegExp.lastIndex = w.nextMatch;
|
|
cellMatch = this.cellRegExp.exec(w.source);
|
|
}
|
|
}
|
|
},
|
|
|
|
{
|
|
name: "heading",
|
|
match: "^!{1,6}",
|
|
termRegExp: /(\n)/mg,
|
|
handler: function(w)
|
|
{
|
|
w.subWikifyTerm(createTiddlyElement(w.output,"h" + w.matchLength),this.termRegExp);
|
|
}
|
|
},
|
|
|
|
{
|
|
name: "list",
|
|
match: "^(?:[\\*#;:]+)",
|
|
lookaheadRegExp: /^(?:(?:(\*)|(#)|(;)|(:))+)/mg,
|
|
termRegExp: /(\n)/mg,
|
|
handler: function(w)
|
|
{
|
|
var stack = [w.output];
|
|
var currLevel = 0, currType = null;
|
|
var listLevel, listType, itemType;
|
|
w.nextMatch = w.matchStart;
|
|
this.lookaheadRegExp.lastIndex = w.nextMatch;
|
|
var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
|
|
while(lookaheadMatch && lookaheadMatch.index == w.nextMatch) {
|
|
if(lookaheadMatch[1]) {
|
|
listType = "ul";
|
|
itemType = "li";
|
|
} else if(lookaheadMatch[2]) {
|
|
listType = "ol";
|
|
itemType = "li";
|
|
} else if(lookaheadMatch[3]) {
|
|
listType = "dl";
|
|
itemType = "dt";
|
|
} else if(lookaheadMatch[4]) {
|
|
listType = "dl";
|
|
itemType = "dd";
|
|
}
|
|
listLevel = lookaheadMatch[0].length;
|
|
w.nextMatch += lookaheadMatch[0].length;
|
|
var t;
|
|
if(listLevel > currLevel) {
|
|
for(t=currLevel; t<listLevel; t++) {
|
|
var target = (currLevel == 0) ? stack[stack.length-1] : stack[stack.length-1].lastChild;
|
|
stack.push(createTiddlyElement(target,listType));
|
|
}
|
|
} else if(listLevel < currLevel) {
|
|
for(t=currLevel; t>listLevel; t--)
|
|
stack.pop();
|
|
} else if(listLevel == currLevel && listType != currType) {
|
|
stack.pop();
|
|
stack.push(createTiddlyElement(stack[stack.length-1].lastChild,listType));
|
|
}
|
|
currLevel = listLevel;
|
|
currType = listType;
|
|
var e = createTiddlyElement(stack[stack.length-1],itemType);
|
|
w.subWikifyTerm(e,this.termRegExp);
|
|
this.lookaheadRegExp.lastIndex = w.nextMatch;
|
|
lookaheadMatch = this.lookaheadRegExp.exec(w.source);
|
|
}
|
|
}
|
|
},
|
|
|
|
{
|
|
name: "quoteByBlock",
|
|
match: "^<<<\\n",
|
|
termRegExp: /(^<<<(\n|$))/mg,
|
|
element: "blockquote",
|
|
handler: config.formatterHelpers.createElementAndWikify
|
|
},
|
|
|
|
{
|
|
name: "quoteByLine",
|
|
match: "^>+",
|
|
lookaheadRegExp: /^>+/mg,
|
|
termRegExp: /(\n)/mg,
|
|
element: "blockquote",
|
|
handler: function(w)
|
|
{
|
|
var stack = [w.output];
|
|
var currLevel = 0;
|
|
var newLevel = w.matchLength;
|
|
var t;
|
|
do {
|
|
if(newLevel > currLevel) {
|
|
for(t=currLevel; t<newLevel; t++)
|
|
stack.push(createTiddlyElement(stack[stack.length-1],this.element));
|
|
} else if(newLevel < currLevel) {
|
|
for(t=currLevel; t>newLevel; t--)
|
|
stack.pop();
|
|
}
|
|
currLevel = newLevel;
|
|
w.subWikifyTerm(stack[stack.length-1],this.termRegExp);
|
|
createTiddlyElement(stack[stack.length-1],"br");
|
|
this.lookaheadRegExp.lastIndex = w.nextMatch;
|
|
var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
|
|
var matched = lookaheadMatch && lookaheadMatch.index == w.nextMatch;
|
|
if(matched) {
|
|
newLevel = lookaheadMatch[0].length;
|
|
w.nextMatch += lookaheadMatch[0].length;
|
|
}
|
|
} while(matched);
|
|
}
|
|
},
|
|
|
|
{
|
|
name: "rule",
|
|
match: "^----+$\\n?",
|
|
handler: function(w)
|
|
{
|
|
createTiddlyElement(w.output,"hr");
|
|
}
|
|
},
|
|
|
|
{
|
|
name: "monospacedByLine",
|
|
match: "^\\{\\{\\{\\n",
|
|
lookaheadRegExp: /^\{\{\{\n((?:^[^\n]*\n)+?)(^\}\}\}$\n?)/mg,
|
|
element: "pre",
|
|
handler: config.formatterHelpers.enclosedTextHelper
|
|
},
|
|
|
|
{
|
|
name: "monospacedByLineForCSS",
|
|
match: "^/\\*\\{\\{\\{\\*/\\n",
|
|
lookaheadRegExp: /\/\*\{\{\{\*\/\n*((?:^[^\n]*\n)+?)(\n*^\/\*\}\}\}\*\/$\n?)/mg,
|
|
element: "pre",
|
|
handler: config.formatterHelpers.enclosedTextHelper
|
|
},
|
|
|
|
{
|
|
name: "monospacedByLineForPlugin",
|
|
match: "^//\\{\\{\\{\\n",
|
|
lookaheadRegExp: /^\/\/\{\{\{\n\n*((?:^[^\n]*\n)+?)(\n*^\/\/\}\}\}$\n?)/mg,
|
|
element: "pre",
|
|
handler: config.formatterHelpers.enclosedTextHelper
|
|
},
|
|
|
|
{
|
|
name: "monospacedByLineForTemplate",
|
|
match: "^<!--\\{\\{\\{-->\\n",
|
|
lookaheadRegExp: /<!--\{\{\{-->\n*((?:^[^\n]*\n)+?)(\n*^<!--\}\}\}-->$\n?)/mg,
|
|
element: "pre",
|
|
handler: config.formatterHelpers.enclosedTextHelper
|
|
},
|
|
|
|
{
|
|
name: "wikifyCommentForPlugin",
|
|
match: "^/\\*\\*\\*\\n",
|
|
termRegExp: /(^\*\*\*\/\n)/mg,
|
|
handler: function(w)
|
|
{
|
|
w.subWikifyTerm(w.output,this.termRegExp);
|
|
}
|
|
},
|
|
|
|
{
|
|
name: "wikifyCommentForTemplate",
|
|
match: "^<!---\\n",
|
|
termRegExp: /(^--->\n)/mg,
|
|
handler: function(w)
|
|
{
|
|
w.subWikifyTerm(w.output,this.termRegExp);
|
|
}
|
|
},
|
|
|
|
{
|
|
name: "macro",
|
|
match: "<<",
|
|
lookaheadRegExp: /<<([^>\s]+)(?:\s*)((?:[^>]|(?:>(?!>)))*)>>/mg,
|
|
handler: function(w)
|
|
{
|
|
this.lookaheadRegExp.lastIndex = w.matchStart;
|
|
var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
|
|
if(lookaheadMatch && lookaheadMatch.index == w.matchStart && lookaheadMatch[1]) {
|
|
w.nextMatch = this.lookaheadRegExp.lastIndex;
|
|
invokeMacro(w.output,lookaheadMatch[1],lookaheadMatch[2],w,w.tiddler);
|
|
}
|
|
}
|
|
},
|
|
|
|
{
|
|
name: "prettyLink",
|
|
match: "\\[\\[",
|
|
lookaheadRegExp: /\[\[(.*?)(?:\|(~)?(.*?))?\]\]/mg,
|
|
handler: function(w)
|
|
{
|
|
this.lookaheadRegExp.lastIndex = w.matchStart;
|
|
var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
|
|
if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
|
|
var e;
|
|
var text = lookaheadMatch[1];
|
|
if(lookaheadMatch[3]) {
|
|
// Pretty bracketted link
|
|
var link = lookaheadMatch[3];
|
|
e = (!lookaheadMatch[2] && config.formatterHelpers.isExternalLink(link)) ?
|
|
createExternalLink(w.output,link) : createTiddlyLink(w.output,link,false,null,w.isStatic,w.tiddler);
|
|
} else {
|
|
// Simple bracketted link
|
|
e = createTiddlyLink(w.output,text,false,null,w.isStatic,w.tiddler);
|
|
}
|
|
createTiddlyText(e,text);
|
|
w.nextMatch = this.lookaheadRegExp.lastIndex;
|
|
}
|
|
}
|
|
},
|
|
|
|
{
|
|
name: "unWikiLink",
|
|
match: config.textPrimitives.unWikiLink+config.textPrimitives.wikiLink,
|
|
handler: function(w)
|
|
{
|
|
w.outputText(w.output,w.matchStart+1,w.nextMatch);
|
|
}
|
|
},
|
|
|
|
{
|
|
name: "wikiLink",
|
|
match: config.textPrimitives.wikiLink,
|
|
handler: function(w)
|
|
{
|
|
if(w.matchStart > 0) {
|
|
var preRegExp = new RegExp(config.textPrimitives.anyLetterStrict,"mg");
|
|
preRegExp.lastIndex = w.matchStart-1;
|
|
var preMatch = preRegExp.exec(w.source);
|
|
if(preMatch.index == w.matchStart-1) {
|
|
w.outputText(w.output,w.matchStart,w.nextMatch);
|
|
return;
|
|
}
|
|
}
|
|
if(w.autoLinkWikiWords == true || store.isShadowTiddler(w.matchText)) {
|
|
var link = createTiddlyLink(w.output,w.matchText,false,null,w.isStatic,w.tiddler);
|
|
w.outputText(link,w.matchStart,w.nextMatch);
|
|
} else {
|
|
w.outputText(w.output,w.matchStart,w.nextMatch);
|
|
}
|
|
}
|
|
},
|
|
|
|
{
|
|
name: "urlLink",
|
|
match: config.textPrimitives.urlPattern,
|
|
handler: function(w)
|
|
{
|
|
w.outputText(createExternalLink(w.output,w.matchText),w.matchStart,w.nextMatch);
|
|
}
|
|
},
|
|
|
|
{
|
|
name: "image",
|
|
match: "\\[[<>]?[Ii][Mm][Gg]\\[",
|
|
lookaheadRegExp: /\[([<]?)(>?)[Ii][Mm][Gg]\[(?:([^\|\]]+)\|)?([^\[\]\|]+)\](?:\[([^\]]*)\])?\]/mg,
|
|
handler: function(w)
|
|
{
|
|
this.lookaheadRegExp.lastIndex = w.matchStart;
|
|
var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
|
|
if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
|
|
var e = w.output;
|
|
if(lookaheadMatch[5]) {
|
|
var link = lookaheadMatch[5];
|
|
e = config.formatterHelpers.isExternalLink(link) ? createExternalLink(w.output,link) : createTiddlyLink(w.output,link,false,null,w.isStatic,w.tiddler);
|
|
addClass(e,"imageLink");
|
|
}
|
|
var img = createTiddlyElement(e,"img");
|
|
if(lookaheadMatch[1])
|
|
img.align = "left";
|
|
else if(lookaheadMatch[2])
|
|
img.align = "right";
|
|
if(lookaheadMatch[3])
|
|
img.title = lookaheadMatch[3];
|
|
img.src = lookaheadMatch[4];
|
|
w.nextMatch = this.lookaheadRegExp.lastIndex;
|
|
}
|
|
}
|
|
},
|
|
|
|
{
|
|
name: "html",
|
|
match: "<[Hh][Tt][Mm][Ll]>",
|
|
lookaheadRegExp: /<[Hh][Tt][Mm][Ll]>((?:.|\n)*?)<\/[Hh][Tt][Mm][Ll]>/mg,
|
|
handler: function(w)
|
|
{
|
|
this.lookaheadRegExp.lastIndex = w.matchStart;
|
|
var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
|
|
if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
|
|
createTiddlyElement(w.output,"span").innerHTML = lookaheadMatch[1];
|
|
w.nextMatch = this.lookaheadRegExp.lastIndex;
|
|
}
|
|
}
|
|
},
|
|
|
|
{
|
|
name: "commentByBlock",
|
|
match: "/%",
|
|
lookaheadRegExp: /\/%((?:.|\n)*?)%\//mg,
|
|
handler: function(w)
|
|
{
|
|
this.lookaheadRegExp.lastIndex = w.matchStart;
|
|
var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
|
|
if(lookaheadMatch && lookaheadMatch.index == w.matchStart)
|
|
w.nextMatch = this.lookaheadRegExp.lastIndex;
|
|
}
|
|
},
|
|
|
|
{
|
|
name: "boldByChar",
|
|
match: "''",
|
|
termRegExp: /('')/mg,
|
|
element: "strong",
|
|
handler: config.formatterHelpers.createElementAndWikify
|
|
},
|
|
|
|
{
|
|
name: "italicByChar",
|
|
match: "//",
|
|
termRegExp: /(\/\/)/mg,
|
|
element: "em",
|
|
handler: config.formatterHelpers.createElementAndWikify
|
|
},
|
|
|
|
{
|
|
name: "underlineByChar",
|
|
match: "__",
|
|
termRegExp: /(__)/mg,
|
|
element: "u",
|
|
handler: config.formatterHelpers.createElementAndWikify
|
|
},
|
|
|
|
{
|
|
name: "strikeByChar",
|
|
match: "--(?!\\s|$)",
|
|
termRegExp: /((?!\s)--|(?=\n\n))/mg,
|
|
element: "strike",
|
|
handler: config.formatterHelpers.createElementAndWikify
|
|
},
|
|
|
|
{
|
|
name: "superscriptByChar",
|
|
match: "\\^\\^",
|
|
termRegExp: /(\^\^)/mg,
|
|
element: "sup",
|
|
handler: config.formatterHelpers.createElementAndWikify
|
|
},
|
|
|
|
{
|
|
name: "subscriptByChar",
|
|
match: "~~",
|
|
termRegExp: /(~~)/mg,
|
|
element: "sub",
|
|
handler: config.formatterHelpers.createElementAndWikify
|
|
},
|
|
|
|
{
|
|
name: "monospacedByChar",
|
|
match: "\\{\\{\\{",
|
|
lookaheadRegExp: /\{\{\{((?:.|\n)*?)\}\}\}/mg,
|
|
handler: function(w)
|
|
{
|
|
this.lookaheadRegExp.lastIndex = w.matchStart;
|
|
var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
|
|
if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
|
|
createTiddlyElement(w.output,"code",null,null,lookaheadMatch[1]);
|
|
w.nextMatch = this.lookaheadRegExp.lastIndex;
|
|
}
|
|
}
|
|
},
|
|
|
|
{
|
|
name: "styleByChar",
|
|
match: "@@",
|
|
termRegExp: /(@@)/mg,
|
|
handler: function(w)
|
|
{
|
|
var e = createTiddlyElement(w.output,"span");
|
|
var styles = config.formatterHelpers.inlineCssHelper(w);
|
|
if(styles.length == 0)
|
|
e.className = "marked";
|
|
else
|
|
config.formatterHelpers.applyCssHelper(e,styles);
|
|
w.subWikifyTerm(e,this.termRegExp);
|
|
}
|
|
},
|
|
|
|
{
|
|
name: "lineBreak",
|
|
match: "\\n|<br ?/?>",
|
|
handler: function(w)
|
|
{
|
|
createTiddlyElement(w.output,"br");
|
|
}
|
|
},
|
|
|
|
{
|
|
name: "rawText",
|
|
match: "\\\"{3}|<nowiki>",
|
|
lookaheadRegExp: /(?:\"{3}|<nowiki>)((?:.|\n)*?)(?:\"{3}|<\/nowiki>)/mg,
|
|
handler: function(w)
|
|
{
|
|
this.lookaheadRegExp.lastIndex = w.matchStart;
|
|
var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
|
|
if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
|
|
createTiddlyElement(w.output,"span",null,null,lookaheadMatch[1]);
|
|
w.nextMatch = this.lookaheadRegExp.lastIndex;
|
|
}
|
|
}
|
|
},
|
|
|
|
{
|
|
name: "mdash",
|
|
match: "--",
|
|
handler: function(w)
|
|
{
|
|
createTiddlyElement(w.output,"span").innerHTML = "—";
|
|
}
|
|
},
|
|
|
|
{
|
|
name: "htmlEntitiesEncoding",
|
|
match: "(?:(?:&#?[a-zA-Z0-9]{2,8};|.)(?:&#?(?:x0*(?:3[0-6][0-9a-fA-F]|1D[c-fC-F][0-9a-fA-F]|20[d-fD-F][0-9a-fA-F]|FE2[0-9a-fA-F])|0*(?:76[89]|7[7-9][0-9]|8[0-7][0-9]|761[6-9]|76[2-7][0-9]|84[0-3][0-9]|844[0-7]|6505[6-9]|6506[0-9]|6507[0-1]));)+|&#?[a-zA-Z0-9]{2,8};)",
|
|
handler: function(w)
|
|
{
|
|
createTiddlyElement(w.output,"span").innerHTML = w.matchText;
|
|
}
|
|
},
|
|
|
|
{
|
|
name: "customClasses",
|
|
match: "\\{\\{",
|
|
termRegExp: /(\}\}\})/mg,
|
|
lookaheadRegExp: /\{\{[\s]*([\w]+[\s\w]*)[\s]*\{(\n?)/mg,
|
|
handler: function(w)
|
|
{
|
|
this.lookaheadRegExp.lastIndex = w.matchStart;
|
|
var lookaheadMatch = this.lookaheadRegExp.exec(w.source);
|
|
if(lookaheadMatch) {
|
|
var e = createTiddlyElement(w.output,lookaheadMatch[2] == "\n" ? "div" : "span",null,lookaheadMatch[1]);
|
|
w.nextMatch = this.lookaheadRegExp.lastIndex;
|
|
w.subWikifyTerm(e,this.termRegExp);
|
|
}
|
|
}
|
|
}
|
|
|
|
];
|
|
|
|
//--
|
|
//-- Wikifier
|
|
//--
|
|
|
|
function getParser(tiddler,format)
|
|
{
|
|
if(tiddler) {
|
|
if(!format)
|
|
format = tiddler.fields["wikiformat"];
|
|
if(format) {
|
|
for(var i in config.parsers) {
|
|
if(format == config.parsers[i].format)
|
|
return config.parsers[i];
|
|
}
|
|
} else {
|
|
for(var i in config.parsers) {
|
|
if(tiddler.isTagged(config.parsers[i].formatTag))
|
|
return config.parsers[i];
|
|
}
|
|
}
|
|
}
|
|
return formatter;
|
|
}
|
|
|
|
function wikify(source,output,highlightRegExp,tiddler)
|
|
{
|
|
if(source && source != "") {
|
|
var wikifier = new Wikifier(source,getParser(tiddler),highlightRegExp,tiddler);
|
|
wikifier.subWikifyUnterm(output);
|
|
}
|
|
}
|
|
|
|
function wikifyStatic(source,highlightRegExp,tiddler,format)
|
|
{
|
|
var e = createTiddlyElement(document.body,"div");
|
|
e.style.display = "none";
|
|
var html = "";
|
|
if(source && source != "") {
|
|
var wikifier = new Wikifier(source,getParser(tiddler,format),highlightRegExp,tiddler);
|
|
wikifier.isStatic = true;
|
|
wikifier.subWikifyUnterm(e);
|
|
html = e.innerHTML;
|
|
removeNode(e);
|
|
}
|
|
return html;
|
|
}
|
|
|
|
function wikifyPlain(title,theStore,limit)
|
|
{
|
|
if(!theStore)
|
|
theStore = store;
|
|
if(theStore.tiddlerExists(title) || theStore.isShadowTiddler(title)) {
|
|
return wikifyPlainText(theStore.getTiddlerText(title),limit,tiddler);
|
|
} else {
|
|
return "";
|
|
}
|
|
}
|
|
|
|
function wikifyPlainText(text,limit,tiddler)
|
|
{
|
|
if(limit > 0)
|
|
text = text.substr(0,limit);
|
|
var wikifier = new Wikifier(text,formatter,null,tiddler);
|
|
return wikifier.wikifyPlain();
|
|
}
|
|
|
|
function highlightify(source,output,highlightRegExp,tiddler)
|
|
{
|
|
if(source && source != "") {
|
|
var wikifier = new Wikifier(source,formatter,highlightRegExp,tiddler);
|
|
wikifier.outputText(output,0,source.length);
|
|
}
|
|
}
|
|
|
|
function Wikifier(source,formatter,highlightRegExp,tiddler)
|
|
{
|
|
this.source = source;
|
|
this.output = null;
|
|
this.formatter = formatter;
|
|
this.nextMatch = 0;
|
|
this.autoLinkWikiWords = tiddler && tiddler.autoLinkWikiWords() == false ? false : true;
|
|
this.highlightRegExp = highlightRegExp;
|
|
this.highlightMatch = null;
|
|
this.isStatic = false;
|
|
if(highlightRegExp) {
|
|
highlightRegExp.lastIndex = 0;
|
|
this.highlightMatch = highlightRegExp.exec(source);
|
|
}
|
|
this.tiddler = tiddler;
|
|
}
|
|
|
|
Wikifier.prototype.wikifyPlain = function()
|
|
{
|
|
var e = createTiddlyElement(document.body,"div");
|
|
this.subWikify(e);
|
|
var text = getPlainText(e);
|
|
removeNode(e);
|
|
return text;
|
|
};
|
|
|
|
Wikifier.prototype.subWikify = function(output,terminator)
|
|
{
|
|
if(terminator)
|
|
this.subWikifyTerm(output,new RegExp("(" + terminator + ")","mg"));
|
|
else
|
|
this.subWikifyUnterm(output);
|
|
};
|
|
|
|
Wikifier.prototype.subWikifyUnterm = function(output)
|
|
{
|
|
// subWikify() can be indirectly recursive, so we need to save the old output pointer
|
|
var oldOutput = this.output;
|
|
this.output = output;
|
|
this.formatter.formatterRegExp.lastIndex = this.nextMatch;
|
|
var formatterMatch = this.formatter.formatterRegExp.exec(this.source);
|
|
while(formatterMatch) {
|
|
// Output any text before the match
|
|
if(formatterMatch.index > this.nextMatch)
|
|
this.outputText(this.output,this.nextMatch,formatterMatch.index);
|
|
// Set the match parameters for the handler
|
|
this.matchStart = formatterMatch.index;
|
|
this.matchLength = formatterMatch[0].length;
|
|
this.matchText = formatterMatch[0];
|
|
this.nextMatch = this.formatter.formatterRegExp.lastIndex;
|
|
for(var t=1; t<formatterMatch.length; t++) {
|
|
if(formatterMatch[t]) {
|
|
this.formatter.formatters[t-1].handler(this);
|
|
this.formatter.formatterRegExp.lastIndex = this.nextMatch;
|
|
break;
|
|
}
|
|
}
|
|
formatterMatch = this.formatter.formatterRegExp.exec(this.source);
|
|
}
|
|
if(this.nextMatch < this.source.length) {
|
|
this.outputText(this.output,this.nextMatch,this.source.length);
|
|
this.nextMatch = this.source.length;
|
|
}
|
|
this.output = oldOutput;
|
|
};
|
|
|
|
Wikifier.prototype.subWikifyTerm = function(output,terminatorRegExp)
|
|
{
|
|
// subWikify() can be indirectly recursive, so we need to save the old output pointer
|
|
var oldOutput = this.output;
|
|
this.output = output;
|
|
// Get the first matches for the formatter and terminator RegExps
|
|
terminatorRegExp.lastIndex = this.nextMatch;
|
|
var terminatorMatch = terminatorRegExp.exec(this.source);
|
|
this.formatter.formatterRegExp.lastIndex = this.nextMatch;
|
|
var formatterMatch = this.formatter.formatterRegExp.exec(terminatorMatch ? this.source.substr(0,terminatorMatch.index) : this.source);
|
|
while(terminatorMatch || formatterMatch) {
|
|
if(terminatorMatch && (!formatterMatch || terminatorMatch.index <= formatterMatch.index)) {
|
|
if(terminatorMatch.index > this.nextMatch)
|
|
this.outputText(this.output,this.nextMatch,terminatorMatch.index);
|
|
this.matchText = terminatorMatch[1];
|
|
this.matchLength = terminatorMatch[1].length;
|
|
this.matchStart = terminatorMatch.index;
|
|
this.nextMatch = this.matchStart + this.matchLength;
|
|
this.output = oldOutput;
|
|
return;
|
|
}
|
|
if(formatterMatch.index > this.nextMatch)
|
|
this.outputText(this.output,this.nextMatch,formatterMatch.index);
|
|
this.matchStart = formatterMatch.index;
|
|
this.matchLength = formatterMatch[0].length;
|
|
this.matchText = formatterMatch[0];
|
|
this.nextMatch = this.formatter.formatterRegExp.lastIndex;
|
|
for(var t=1; t<formatterMatch.length; t++) {
|
|
if(formatterMatch[t]) {
|
|
this.formatter.formatters[t-1].handler(this);
|
|
this.formatter.formatterRegExp.lastIndex = this.nextMatch;
|
|
break;
|
|
}
|
|
}
|
|
terminatorRegExp.lastIndex = this.nextMatch;
|
|
terminatorMatch = terminatorRegExp.exec(this.source);
|
|
formatterMatch = this.formatter.formatterRegExp.exec(terminatorMatch ? this.source.substr(0,terminatorMatch.index) : this.source);
|
|
}
|
|
if(this.nextMatch < this.source.length) {
|
|
this.outputText(this.output,this.nextMatch,this.source.length);
|
|
this.nextMatch = this.source.length;
|
|
}
|
|
this.output = oldOutput;
|
|
};
|
|
|
|
Wikifier.prototype.outputText = function(place,startPos,endPos)
|
|
{
|
|
while(this.highlightMatch && (this.highlightRegExp.lastIndex > startPos) && (this.highlightMatch.index < endPos) && (startPos < endPos)) {
|
|
if(this.highlightMatch.index > startPos) {
|
|
createTiddlyText(place,this.source.substring(startPos,this.highlightMatch.index));
|
|
startPos = this.highlightMatch.index;
|
|
}
|
|
var highlightEnd = Math.min(this.highlightRegExp.lastIndex,endPos);
|
|
var theHighlight = createTiddlyElement(place,"span",null,"highlight",this.source.substring(startPos,highlightEnd));
|
|
startPos = highlightEnd;
|
|
if(startPos >= this.highlightRegExp.lastIndex)
|
|
this.highlightMatch = this.highlightRegExp.exec(this.source);
|
|
}
|
|
if(startPos < endPos) {
|
|
createTiddlyText(place,this.source.substring(startPos,endPos));
|
|
}
|
|
};
|
|
|
|
//--
|
|
//-- Macro definitions
|
|
//--
|
|
|
|
config.macros.today.handler = function(place,macroName,params)
|
|
{
|
|
var now = new Date();
|
|
var text;
|
|
if(params[0])
|
|
text = now.formatString(params[0].trim());
|
|
else
|
|
text = now.toLocaleString();
|
|
createTiddlyElement(place,"span",null,null,text);
|
|
};
|
|
|
|
config.macros.version.handler = function(place)
|
|
{
|
|
createTiddlyElement(place,"span",null,null,version.major + "." + version.minor + "." + version.revision + (version.beta ? " (beta " + version.beta + ")" : ""));
|
|
};
|
|
|
|
config.macros.list.handler = function(place,macroName,params)
|
|
{
|
|
var type = params[0] ? params[0] : "all";
|
|
var list = document.createElement("ul");
|
|
place.appendChild(list);
|
|
if(this[type].prompt)
|
|
createTiddlyElement(list,"li",null,"listTitle",this[type].prompt);
|
|
var results;
|
|
if(this[type].handler)
|
|
results = this[type].handler(params);
|
|
for(var t = 0; t < results.length; t++) {
|
|
var li = document.createElement("li");
|
|
list.appendChild(li);
|
|
createTiddlyLink(li,typeof results[t] == "string" ? results[t] : results[t].title,true);
|
|
}
|
|
};
|
|
|
|
config.macros.list.all.handler = function(params)
|
|
{
|
|
return store.reverseLookup("tags","excludeLists",false,"title");
|
|
};
|
|
|
|
config.macros.list.missing.handler = function(params)
|
|
{
|
|
return store.getMissingLinks();
|
|
};
|
|
|
|
config.macros.list.orphans.handler = function(params)
|
|
{
|
|
return store.getOrphans();
|
|
};
|
|
|
|
config.macros.list.shadowed.handler = function(params)
|
|
{
|
|
return store.getShadowed();
|
|
};
|
|
|
|
config.macros.list.touched.handler = function(params)
|
|
{
|
|
return store.getTouched();
|
|
};
|
|
|
|
config.macros.allTags.handler = function(place,macroName,params)
|
|
{
|
|
var tags = store.getTags(params[0]);
|
|
var ul = createTiddlyElement(place,"ul");
|
|
if(tags.length == 0)
|
|
createTiddlyElement(ul,"li",null,"listTitle",this.noTags);
|
|
for(var t=0; t<tags.length; t++) {
|
|
var title = tags[t][0];
|
|
var info = getTiddlyLinkInfo(title);
|
|
var li =createTiddlyElement(ul,"li");
|
|
var btn = createTiddlyButton(li,title + " (" + tags[t][1] + ")",this.tooltip.format([title]),onClickTag,info.classes);
|
|
btn.setAttribute("tag",title);
|
|
btn.setAttribute("refresh","link");
|
|
btn.setAttribute("tiddlyLink",title);
|
|
}
|
|
};
|
|
|
|
config.macros.timeline.handler = function(place,macroName,params)
|
|
{
|
|
var field = params[0] ? params[0] : "modified";
|
|
var tiddlers = store.reverseLookup("tags","excludeLists",false,field);
|
|
var lastDay = "";
|
|
var last = params[1] ? tiddlers.length-Math.min(tiddlers.length,parseInt(params[1])) : 0;
|
|
for(var t=tiddlers.length-1; t>=last; t--) {
|
|
var tiddler = tiddlers[t];
|
|
var theDay = tiddler[field].convertToLocalYYYYMMDDHHMM().substr(0,8);
|
|
if(theDay != lastDay) {
|
|
var theDateList = document.createElement("ul");
|
|
place.appendChild(theDateList);
|
|
createTiddlyElement(theDateList,"li",null,"listTitle",tiddler[field].formatString(this.dateFormat));
|
|
lastDay = theDay;
|
|
}
|
|
var theDateListItem = createTiddlyElement(theDateList,"li",null,"listLink");
|
|
theDateListItem.appendChild(createTiddlyLink(place,tiddler.title,true));
|
|
}
|
|
};
|
|
|
|
config.macros.search.handler = function(place,macroName,params)
|
|
{
|
|
var searchTimeout = null;
|
|
var btn = createTiddlyButton(place,this.label,this.prompt,this.onClick);
|
|
var txt = createTiddlyElement(place,"input",null,"txtOptionInput");
|
|
if(params[0])
|
|
txt.value = params[0];
|
|
txt.onkeyup = this.onKeyPress;
|
|
txt.onfocus = this.onFocus;
|
|
txt.setAttribute("size",this.sizeTextbox);
|
|
txt.setAttribute("accessKey",this.accessKey);
|
|
txt.setAttribute("autocomplete","off");
|
|
txt.setAttribute("lastSearchText","");
|
|
if(config.browser.isSafari) {
|
|
txt.setAttribute("type","search");
|
|
txt.setAttribute("results","5");
|
|
} else {
|
|
txt.setAttribute("type","text");
|
|
}
|
|
};
|
|
|
|
// Global because there's only ever one outstanding incremental search timer
|
|
config.macros.search.timeout = null;
|
|
|
|
config.macros.search.doSearch = function(txt)
|
|
{
|
|
if(txt.value.length > 0) {
|
|
story.search(txt.value,config.options.chkCaseSensitiveSearch,config.options.chkRegExpSearch);
|
|
txt.setAttribute("lastSearchText",txt.value);
|
|
}
|
|
};
|
|
|
|
config.macros.search.onClick = function(e)
|
|
{
|
|
config.macros.search.doSearch(this.nextSibling);
|
|
return false;
|
|
};
|
|
|
|
config.macros.search.onKeyPress = function(e)
|
|
{
|
|
if(!e) var e = window.event;
|
|
switch(e.keyCode) {
|
|
case 13: // Ctrl-Enter
|
|
case 10: // Ctrl-Enter on IE PC
|
|
config.macros.search.doSearch(this);
|
|
break;
|
|
case 27: // Escape
|
|
this.value = "";
|
|
clearMessage();
|
|
break;
|
|
}
|
|
if(this.value.length > 2) {
|
|
if(this.value != this.getAttribute("lastSearchText")) {
|
|
if(config.macros.search.timeout)
|
|
clearTimeout(config.macros.search.timeout);
|
|
var txt = this;
|
|
config.macros.search.timeout = setTimeout(function() {config.macros.search.doSearch(txt);},500);
|
|
}
|
|
} else {
|
|
if(config.macros.search.timeout)
|
|
clearTimeout(config.macros.search.timeout);
|
|
}
|
|
};
|
|
|
|
config.macros.search.onFocus = function(e)
|
|
{
|
|
this.select();
|
|
};
|
|
|
|
config.macros.tiddler.handler = function(place,macroName,params,wikifier,paramString,tiddler)
|
|
{
|
|
params = paramString.parseParams("name",null,true,false,true);
|
|
var names = params[0]["name"];
|
|
var tiddlerName = names[0];
|
|
var className = names[1] ? names[1] : null;
|
|
var args = params[0]["with"];
|
|
var wrapper = createTiddlyElement(place,"span",null,className);
|
|
if(!args) {
|
|
wrapper.setAttribute("refresh","content");
|
|
wrapper.setAttribute("tiddler",tiddlerName);
|
|
}
|
|
var text = store.getTiddlerText(tiddlerName);
|
|
if(text) {
|
|
var stack = config.macros.tiddler.tiddlerStack;
|
|
if(stack.indexOf(tiddlerName) !== -1)
|
|
return;
|
|
stack.push(tiddlerName);
|
|
try {
|
|
var n = args ? Math.min(args.length,9) : 0;
|
|
for(var i=0; i<n; i++) {
|
|
var placeholderRE = new RegExp("\\$" + (i + 1),"mg");
|
|
text = text.replace(placeholderRE,args[i]);
|
|
}
|
|
config.macros.tiddler.renderText(wrapper,text,tiddlerName,params);
|
|
} finally {
|
|
stack.pop();
|
|
}
|
|
}
|
|
};
|
|
|
|
config.macros.tiddler.renderText = function(place,text,tiddlerName,params)
|
|
{
|
|
wikify(text,place,null,store.getTiddler(tiddlerName));
|
|
};
|
|
|
|
config.macros.tiddler.tiddlerStack = [];
|
|
|
|
config.macros.tag.handler = function(place,macroName,params)
|
|
{
|
|
createTagButton(place,params[0]);
|
|
};
|
|
|
|
config.macros.tags.handler = function(place,macroName,params,wikifier,paramString,tiddler)
|
|
{
|
|
params = paramString.parseParams("anon",null,true,false,false);
|
|
var theList = createTiddlyElement(place,"ul");
|
|
var title = getParam(params,"anon","");
|
|
if(title && store.tiddlerExists(title))
|
|
tiddler = store.getTiddler(title);
|
|
var sep = getParam(params,"sep"," ");
|
|
var lingo = config.views.wikified.tag;
|
|
var prompt = tiddler.tags.length == 0 ? lingo.labelNoTags : lingo.labelTags;
|
|
createTiddlyElement(theList,"li",null,"listTitle",prompt.format([tiddler.title]));
|
|
for(var t=0; t<tiddler.tags.length; t++) {
|
|
createTagButton(createTiddlyElement(theList,"li"),tiddler.tags[t],tiddler.title);
|
|
if(t<tiddler.tags.length-1)
|
|
createTiddlyText(theList,sep);
|
|
}
|
|
};
|
|
|
|
config.macros.tagging.handler = function(place,macroName,params,wikifier,paramString,tiddler)
|
|
{
|
|
params = paramString.parseParams("anon",null,true,false,false);
|
|
var theList = createTiddlyElement(place,"ul");
|
|
var title = getParam(params,"anon","");
|
|
if(title == "" && tiddler instanceof Tiddler)
|
|
title = tiddler.title;
|
|
var sep = getParam(params,"sep"," ");
|
|
theList.setAttribute("title",this.tooltip.format([title]));
|
|
var tagged = store.getTaggedTiddlers(title);
|
|
var prompt = tagged.length == 0 ? this.labelNotTag : this.label;
|
|
createTiddlyElement(theList,"li",null,"listTitle",prompt.format([title,tagged.length]));
|
|
for(var t=0; t<tagged.length; t++) {
|
|
createTiddlyLink(createTiddlyElement(theList,"li"),tagged[t].title,true);
|
|
if(t<tagged.length-1)
|
|
createTiddlyText(theList,sep);
|
|
}
|
|
};
|
|
|
|
config.macros.closeAll.handler = function(place)
|
|
{
|
|
createTiddlyButton(place,this.label,this.prompt,this.onClick);
|
|
};
|
|
|
|
config.macros.closeAll.onClick = function(e)
|
|
{
|
|
story.closeAllTiddlers();
|
|
return false;
|
|
};
|
|
|
|
config.macros.permaview.handler = function(place)
|
|
{
|
|
createTiddlyButton(place,this.label,this.prompt,this.onClick);
|
|
};
|
|
|
|
config.macros.permaview.onClick = function(e)
|
|
{
|
|
story.permaView();
|
|
return false;
|
|
};
|
|
|
|
config.macros.saveChanges.handler = function(place)
|
|
{
|
|
if(!readOnly)
|
|
createTiddlyButton(place,this.label,this.prompt,this.onClick,null,null,this.accessKey);
|
|
};
|
|
|
|
config.macros.saveChanges.onClick = function(e)
|
|
{
|
|
saveChanges();
|
|
return false;
|
|
};
|
|
|
|
config.macros.slider.onClickSlider = function(e)
|
|
{
|
|
if(!e) var e = window.event;
|
|
var n = this.nextSibling;
|
|
var cookie = n.getAttribute("cookie");
|
|
var isOpen = n.style.display != "none";
|
|
if(config.options.chkAnimate && anim && typeof Slider == "function")
|
|
anim.startAnimating(new Slider(n,!isOpen,null,"none"));
|
|
else
|
|
n.style.display = isOpen ? "none" : "block";
|
|
config.options[cookie] = !isOpen;
|
|
saveOptionCookie(cookie);
|
|
return false;
|
|
};
|
|
|
|
config.macros.slider.createSlider = function(place,cookie,title,tooltip)
|
|
{
|
|
var cookie = cookie ? cookie : "";
|
|
var btn = createTiddlyButton(place,title,tooltip,this.onClickSlider);
|
|
var panel = createTiddlyElement(null,"div",null,"sliderPanel");
|
|
panel.setAttribute("cookie",cookie);
|
|
panel.style.display = config.options[cookie] ? "block" : "none";
|
|
place.appendChild(panel);
|
|
return panel;
|
|
};
|
|
|
|
config.macros.slider.handler = function(place,macroName,params)
|
|
{
|
|
var panel = this.createSlider(place,params[0],params[2],params[3]);
|
|
var text = store.getTiddlerText(params[1]);
|
|
panel.setAttribute("refresh","content");
|
|
panel.setAttribute("tiddler",params[1]);
|
|
if(text)
|
|
wikify(text,panel,null,store.getTiddler(params[1]));
|
|
};
|
|
|
|
config.macros.option.genericCreate = function(place,type,opt,className,desc)
|
|
{
|
|
var typeInfo = config.macros.option.types[type];
|
|
var c = document.createElement(typeInfo.elementType);
|
|
if(typeInfo.typeValue)
|
|
c.setAttribute("type",typeInfo.typeValue);
|
|
c[typeInfo.eventName] = typeInfo.onChange;
|
|
c.setAttribute("option",opt);
|
|
if(className)
|
|
c.className = className;
|
|
else
|
|
c.className = typeInfo.className;
|
|
if(config.optionsDesc[opt])
|
|
c.setAttribute("title",config.optionsDesc[opt]);
|
|
place.appendChild(c);
|
|
if(desc != "no")
|
|
createTiddlyText(place,config.optionsDesc[opt] ? config.optionsDesc[opt] : opt);
|
|
c[typeInfo.valueField] = config.options[opt];
|
|
return c;
|
|
};
|
|
|
|
config.macros.option.genericOnChange = function(e)
|
|
{
|
|
var opt = this.getAttribute("option");
|
|
if(opt) {
|
|
var optType = opt.substr(0,3);
|
|
var handler = config.macros.option.types[optType];
|
|
if (handler.elementType && handler.valueField)
|
|
config.macros.option.propagateOption(opt,handler.valueField,this[handler.valueField],handler.elementType);
|
|
}
|
|
return true;
|
|
};
|
|
|
|
config.macros.option.types = {
|
|
'txt': {
|
|
elementType: "input",
|
|
valueField: "value",
|
|
eventName: "onkeyup",
|
|
className: "txtOptionInput",
|
|
create: config.macros.option.genericCreate,
|
|
onChange: config.macros.option.genericOnChange
|
|
},
|
|
'chk': {
|
|
elementType: "input",
|
|
valueField: "checked",
|
|
eventName: "onclick",
|
|
className: "chkOptionInput",
|
|
typeValue: "checkbox",
|
|
create: config.macros.option.genericCreate,
|
|
onChange: config.macros.option.genericOnChange
|
|
}
|
|
};
|
|
|
|
config.macros.option.propagateOption = function(opt,valueField,value,elementType)
|
|
{
|
|
config.options[opt] = value;
|
|
saveOptionCookie(opt);
|
|
var nodes = document.getElementsByTagName(elementType);
|
|
for(var t=0; t<nodes.length; t++) {
|
|
var optNode = nodes[t].getAttribute("option");
|
|
if(opt == optNode)
|
|
nodes[t][valueField] = value;
|
|
}
|
|
};
|
|
|
|
config.macros.option.handler = function(place,macroName,params,wikifier,paramString,tiddler)
|
|
{
|
|
params = paramString.parseParams("anon",null,true,false,false);
|
|
var opt = (params[1] && params[1].name == "anon") ? params[1].value : getParam(params,"name",null);
|
|
var className = (params[2] && params[2].name == "anon") ? params[2].value : getParam(params,"class",null);
|
|
var desc = getParam(params,"desc","no");
|
|
var type = opt.substr(0,3);
|
|
var h = config.macros.option.types[type];
|
|
if (h && h.create)
|
|
h.create(place,type,opt,className,desc);
|
|
};
|
|
|
|
config.macros.options.handler = function(place,macroName,params,wikifier,paramString,tiddler)
|
|
{
|
|
params = paramString.parseParams("anon",null,true,false,false);
|
|
var showUnknown = getParam(params,"showUnknown","no");
|
|
var wizard = new Wizard();
|
|
wizard.createWizard(place,this.wizardTitle);
|
|
wizard.addStep(this.step1Title,this.step1Html);
|
|
var markList = wizard.getElement("markList");
|
|
var chkUnknown = wizard.getElement("chkUnknown");
|
|
chkUnknown.checked = showUnknown == "yes";
|
|
chkUnknown.onchange = this.onChangeUnknown;
|
|
var listWrapper = document.createElement("div");
|
|
markList.parentNode.insertBefore(listWrapper,markList);
|
|
wizard.setValue("listWrapper",listWrapper);
|
|
this.refreshOptions(listWrapper,showUnknown == "yes");
|
|
};
|
|
|
|
config.macros.options.refreshOptions = function(listWrapper,showUnknown)
|
|
{
|
|
var opts = [];
|
|
for(var n in config.options) {
|
|
var opt = {};
|
|
opt.option = "";
|
|
opt.name = n;
|
|
opt.lowlight = !config.optionsDesc[n];
|
|
opt.description = opt.lowlight ? this.unknownDescription : config.optionsDesc[n];
|
|
if(!opt.lowlight || showUnknown)
|
|
opts.push(opt);
|
|
}
|
|
opts.sort(function(a,b) {return a.name.substr(3) < b.name.substr(3) ? -1 : (a.name.substr(3) == b.name.substr(3) ? 0 : +1);});
|
|
var listview = ListView.create(listWrapper,opts,this.listViewTemplate);
|
|
for(n=0; n<opts.length; n++) {
|
|
var type = opts[n].name.substr(0,3);
|
|
var h = config.macros.option.types[type];
|
|
if (h && h.create) {
|
|
h.create(opts[n].colElements['option'],type,opts[n].name,null,"no");
|
|
}
|
|
}
|
|
};
|
|
|
|
config.macros.options.onChangeUnknown = function(e)
|
|
{
|
|
var wizard = new Wizard(this);
|
|
var listWrapper = wizard.getValue("listWrapper");
|
|
removeChildren(listWrapper);
|
|
config.macros.options.refreshOptions(listWrapper,this.checked);
|
|
return false;
|
|
};
|
|
|
|
config.macros.newTiddler.createNewTiddlerButton = function(place,title,params,label,prompt,accessKey,newFocus,isJournal)
|
|
{
|
|
var tags = [];
|
|
for(var t=1; t<params.length; t++) {
|
|
if((params[t].name == "anon" && t != 1) || (params[t].name == "tag"))
|
|
tags.push(params[t].value);
|
|
}
|
|
label = getParam(params,"label",label);
|
|
prompt = getParam(params,"prompt",prompt);
|
|
accessKey = getParam(params,"accessKey",accessKey);
|
|
newFocus = getParam(params,"focus",newFocus);
|
|
var customFields = getParam(params,"fields","");
|
|
if(!customFields && !store.isShadowTiddler(title))
|
|
customFields = String.encodeHashMap(config.defaultCustomFields);
|
|
var btn = createTiddlyButton(place,label,prompt,this.onClickNewTiddler,null,null,accessKey);
|
|
btn.setAttribute("newTitle",title);
|
|
btn.setAttribute("isJournal",isJournal ? "true" : "false");
|
|
if(tags.length > 0)
|
|
btn.setAttribute("params",tags.join("|"));
|
|
btn.setAttribute("newFocus",newFocus);
|
|
btn.setAttribute("newTemplate",getParam(params,"template",DEFAULT_EDIT_TEMPLATE));
|
|
if(customFields !== "")
|
|
btn.setAttribute("customFields",customFields);
|
|
var text = getParam(params,"text");
|
|
if(text !== undefined)
|
|
btn.setAttribute("newText",text);
|
|
return btn;
|
|
};
|
|
|
|
config.macros.newTiddler.onClickNewTiddler = function()
|
|
{
|
|
var title = this.getAttribute("newTitle");
|
|
if(this.getAttribute("isJournal") == "true") {
|
|
var now = new Date();
|
|
title = now.formatString(title.trim());
|
|
}
|
|
var params = this.getAttribute("params");
|
|
var tags = params ? params.split("|") : [];
|
|
var focus = this.getAttribute("newFocus");
|
|
var template = this.getAttribute("newTemplate");
|
|
var customFields = this.getAttribute("customFields");
|
|
story.displayTiddler(null,title,template,false,null,null);
|
|
var tiddlerElem = document.getElementById(story.idPrefix + title);
|
|
story.addCustomFields(tiddlerElem,customFields);
|
|
var text = this.getAttribute("newText");
|
|
if(typeof text == "string")
|
|
story.getTiddlerField(title,"text").value = text.format([title]);
|
|
for(var t=0;t<tags.length;t++)
|
|
story.setTiddlerTag(title,tags[t],+1);
|
|
story.focusTiddler(title,focus);
|
|
return false;
|
|
};
|
|
|
|
config.macros.newTiddler.handler = function(place,macroName,params,wikifier,paramString,tiddler)
|
|
{
|
|
if(!readOnly) {
|
|
params = paramString.parseParams("anon",null,true,false,false);
|
|
var title = params[1] && params[1].name == "anon" ? params[1].value : this.title;
|
|
title = getParam(params,"title",title);
|
|
this.createNewTiddlerButton(place,title,params,this.label,this.prompt,this.accessKey,"title",false);
|
|
}
|
|
};
|
|
|
|
config.macros.newJournal.handler = function(place,macroName,params,wikifier,paramString,tiddler)
|
|
{
|
|
if(!readOnly) {
|
|
params = paramString.parseParams("anon",null,true,false,false);
|
|
var title = params[1] && params[1].name == "anon" ? params[1].value : "";
|
|
title = getParam(params,"title",title);
|
|
config.macros.newTiddler.createNewTiddlerButton(place,title,params,this.label,this.prompt,this.accessKey,"text",true);
|
|
}
|
|
};
|
|
|
|
config.macros.sparkline.handler = function(place,macroName,params)
|
|
{
|
|
var data = [];
|
|
var min = 0;
|
|
var max = 0;
|
|
for(var t=0; t<params.length; t++) {
|
|
var v = parseInt(params[t]);
|
|
if(v < min)
|
|
min = v;
|
|
if(v > max)
|
|
max = v;
|
|
data.push(v);
|
|
}
|
|
if(data.length < 1)
|
|
return;
|
|
var box = createTiddlyElement(place,"span",null,"sparkline",String.fromCharCode(160));
|
|
box.title = data.join(",");
|
|
var w = box.offsetWidth;
|
|
var h = box.offsetHeight;
|
|
box.style.paddingRight = (data.length * 2 - w) + "px";
|
|
box.style.position = "relative";
|
|
for(var d=0; d<data.length; d++) {
|
|
var tick = document.createElement("img");
|
|
tick.border = 0;
|
|
tick.className = "sparktick";
|
|
tick.style.position = "absolute";
|
|
tick.src = "data:image/gif,GIF89a%01%00%01%00%91%FF%00%FF%FF%FF%00%00%00%C0%C0%C0%00%00%00!%F9%04%01%00%00%02%00%2C%00%00%00%00%01%00%01%00%40%02%02T%01%00%3B";
|
|
tick.style.left = d*2 + "px";
|
|
tick.style.width = "2px";
|
|
var v = Math.floor(((data[d] - min)/(max-min)) * h);
|
|
tick.style.top = (h-v) + "px";
|
|
tick.style.height = v + "px";
|
|
box.appendChild(tick);
|
|
}
|
|
};
|
|
|
|
config.macros.tabs.handler = function(place,macroName,params)
|
|
{
|
|
var cookie = params[0];
|
|
var numTabs = (params.length-1)/3;
|
|
var wrapper = createTiddlyElement(null,"div",null,cookie);
|
|
var tabset = createTiddlyElement(wrapper,"div",null,"tabset");
|
|
tabset.setAttribute("cookie",cookie);
|
|
var validTab = false;
|
|
for(var t=0; t<numTabs; t++) {
|
|
var label = params[t*3+1];
|
|
var prompt = params[t*3+2];
|
|
var content = params[t*3+3];
|
|
var tab = createTiddlyButton(tabset,label,prompt,this.onClickTab,"tab tabUnselected");
|
|
tab.setAttribute("tab",label);
|
|
tab.setAttribute("content",content);
|
|
tab.title = prompt;
|
|
if(config.options[cookie] == label)
|
|
validTab = true;
|
|
}
|
|
if(!validTab)
|
|
config.options[cookie] = params[1];
|
|
place.appendChild(wrapper);
|
|
this.switchTab(tabset,config.options[cookie]);
|
|
};
|
|
|
|
config.macros.tabs.onClickTab = function(e)
|
|
{
|
|
config.macros.tabs.switchTab(this.parentNode,this.getAttribute("tab"));
|
|
return false;
|
|
};
|
|
|
|
config.macros.tabs.switchTab = function(tabset,tab)
|
|
{
|
|
var cookie = tabset.getAttribute("cookie");
|
|
var theTab = null;
|
|
var nodes = tabset.childNodes;
|
|
for(var t=0; t<nodes.length; t++) {
|
|
if(nodes[t].getAttribute && nodes[t].getAttribute("tab") == tab) {
|
|
theTab = nodes[t];
|
|
theTab.className = "tab tabSelected";
|
|
} else {
|
|
nodes[t].className = "tab tabUnselected";
|
|
}
|
|
}
|
|
if(theTab) {
|
|
if(tabset.nextSibling && tabset.nextSibling.className == "tabContents")
|
|
removeNode(tabset.nextSibling);
|
|
var tabContent = createTiddlyElement(null,"div",null,"tabContents");
|
|
tabset.parentNode.insertBefore(tabContent,tabset.nextSibling);
|
|
var contentTitle = theTab.getAttribute("content");
|
|
wikify(store.getTiddlerText(contentTitle),tabContent,null,store.getTiddler(contentTitle));
|
|
if(cookie) {
|
|
config.options[cookie] = tab;
|
|
saveOptionCookie(cookie);
|
|
}
|
|
}
|
|
};
|
|
|
|
// <<gradient [[tiddler name]] vert|horiz rgb rgb rgb rgb... >>
|
|
config.macros.gradient.handler = function(place,macroName,params,wikifier)
|
|
{
|
|
var terminator = ">>";
|
|
var panel;
|
|
if(wikifier)
|
|
panel = createTiddlyElement(place,"div",null,"gradient");
|
|
else
|
|
panel = place;
|
|
panel.style.position = "relative";
|
|
panel.style.overflow = "hidden";
|
|
panel.style.zIndex = "0";
|
|
var t;
|
|
if(wikifier) {
|
|
var styles = config.formatterHelpers.inlineCssHelper(wikifier);
|
|
config.formatterHelpers.applyCssHelper(panel,styles);
|
|
}
|
|
var colours = [];
|
|
for(t=1; t<params.length; t++) {
|
|
var c = new RGB(params[t]);
|
|
if(c)
|
|
colours.push(c);
|
|
}
|
|
drawGradient(panel,params[0] != "vert",colours);
|
|
if(wikifier)
|
|
wikifier.subWikify(panel,terminator);
|
|
if(document.all) {
|
|
panel.style.height = "100%";
|
|
panel.style.width = "100%";
|
|
}
|
|
};
|
|
|
|
config.macros.message.handler = function(place,macroName,params)
|
|
{
|
|
if(params[0]) {
|
|
var m = config;
|
|
var p = params[0].split(".");
|
|
for(var t=0; t<p.length; t++) {
|
|
if(p[t] in m)
|
|
m = m[p[t]];
|
|
else
|
|
break;
|
|
}
|
|
createTiddlyText(place,m.toString().format(params.splice(1)));
|
|
}
|
|
};
|
|
|
|
config.macros.view.handler = function(place,macroName,params,wikifier,paramString,tiddler)
|
|
{
|
|
if((tiddler instanceof Tiddler) && params[0]) {
|
|
var value = store.getValue(tiddler,params[0]);
|
|
if(value != undefined) {
|
|
switch(params[1]) {
|
|
case undefined:
|
|
highlightify(value,place,highlightHack,tiddler);
|
|
break;
|
|
case "link":
|
|
createTiddlyLink(place,value,true);
|
|
break;
|
|
case "wikified":
|
|
wikify(value,place,highlightHack,tiddler);
|
|
break;
|
|
case "date":
|
|
value = Date.convertFromYYYYMMDDHHMM(value);
|
|
createTiddlyText(place,value.formatString(params[2] ? params[2] : config.views.wikified.dateFormat));
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
config.macros.edit.handler = function(place,macroName,params,wikifier,paramString,tiddler)
|
|
{
|
|
var field = params[0];
|
|
var rows = params[1];
|
|
if((tiddler instanceof Tiddler) && field) {
|
|
story.setDirty(tiddler.title,true);
|
|
if(field != "text" && !rows) {
|
|
var e = createTiddlyElement(null,"input");
|
|
if(tiddler.isReadOnly())
|
|
e.setAttribute("readOnly","readOnly");
|
|
e.setAttribute("edit",field);
|
|
e.setAttribute("type","text");
|
|
var v = store.getValue(tiddler,field);
|
|
if(!v)
|
|
v = "";
|
|
e.value = v;
|
|
e.setAttribute("size","40");
|
|
e.setAttribute("autocomplete","off");
|
|
place.appendChild(e);
|
|
} else {
|
|
var wrapper1 = createTiddlyElement(null,"fieldset",null,"fieldsetFix");
|
|
var wrapper2 = createTiddlyElement(wrapper1,"div");
|
|
var e = createTiddlyElement(wrapper2,"textarea");
|
|
if(tiddler.isReadOnly())
|
|
e.setAttribute("readOnly","readOnly");
|
|
var v = store.getValue(tiddler,field);
|
|
if(!v)
|
|
v = "";
|
|
e.value = v;
|
|
var rows = rows ? rows : 10;
|
|
var lines = v.match(/\n/mg);
|
|
var maxLines = Math.max(parseInt(config.options.txtMaxEditRows),5);
|
|
if(lines != null && lines.length > rows)
|
|
rows = lines.length + 5;
|
|
rows = Math.min(rows,maxLines);
|
|
e.setAttribute("rows",rows);
|
|
e.setAttribute("edit",field);
|
|
place.appendChild(wrapper1);
|
|
}
|
|
}
|
|
};
|
|
|
|
config.macros.tagChooser.onClick = function(e)
|
|
{
|
|
if(!e) var e = window.event;
|
|
var lingo = config.views.editor.tagChooser;
|
|
var popup = Popup.create(this);
|
|
var tags = store.getTags();
|
|
if(tags.length == 0)
|
|
createTiddlyText(createTiddlyElement(popup,"li"),lingo.popupNone);
|
|
for(var t=0; t<tags.length; t++) {
|
|
var theTag = createTiddlyButton(createTiddlyElement(popup,"li"),tags[t][0],lingo.tagTooltip.format([tags[t][0]]),config.macros.tagChooser.onTagClick);
|
|
theTag.setAttribute("tag",tags[t][0]);
|
|
theTag.setAttribute("tiddler",this.getAttribute("tiddler"));
|
|
}
|
|
Popup.show();
|
|
e.cancelBubble = true;
|
|
if(e.stopPropagation) e.stopPropagation();
|
|
return false;
|
|
};
|
|
|
|
config.macros.tagChooser.onTagClick = function(e)
|
|
{
|
|
if(!e) var e = window.event;
|
|
var tag = this.getAttribute("tag");
|
|
var title = this.getAttribute("tiddler");
|
|
if(!readOnly)
|
|
story.setTiddlerTag(title,tag,0);
|
|
return false;
|
|
};
|
|
|
|
config.macros.tagChooser.handler = function(place,macroName,params,wikifier,paramString,tiddler)
|
|
{
|
|
if(tiddler instanceof Tiddler) {
|
|
var title = tiddler.title;
|
|
var lingo = config.views.editor.tagChooser;
|
|
var btn = createTiddlyButton(place,lingo.text,lingo.tooltip,this.onClick);
|
|
btn.setAttribute("tiddler",title);
|
|
}
|
|
};
|
|
|
|
// Create a toolbar command button
|
|
config.macros.toolbar.createCommand = function(place,commandName,tiddler,theClass)
|
|
{
|
|
if(typeof commandName != "string") {
|
|
var c = null;
|
|
for(var t in config.commands) {
|
|
if(config.commands[t] == commandName)
|
|
c = t;
|
|
}
|
|
commandName = c;
|
|
}
|
|
if((tiddler instanceof Tiddler) && (typeof commandName == "string")) {
|
|
var command = config.commands[commandName];
|
|
if(command.isEnabled ? command.isEnabled(tiddler) : this.isCommandEnabled(command,tiddler)) {
|
|
var text = command.getText ? command.getText(tiddler) : this.getCommandText(command,tiddler);
|
|
var tooltip = command.getTooltip ? command.getTooltip(tiddler) : this.getCommandTooltip(command,tiddler);
|
|
var cmd;
|
|
switch(command.type) {
|
|
case "popup":
|
|
cmd = this.onClickPopup;
|
|
break;
|
|
case "command":
|
|
default:
|
|
cmd = this.onClickCommand;
|
|
break;
|
|
}
|
|
var btn = createTiddlyButton(null,text,tooltip,cmd);
|
|
btn.setAttribute("commandName",commandName);
|
|
btn.setAttribute("tiddler",tiddler.title);
|
|
if(theClass)
|
|
addClass(btn,theClass);
|
|
place.appendChild(btn);
|
|
}
|
|
}
|
|
};
|
|
|
|
config.macros.toolbar.isCommandEnabled = function(command,tiddler)
|
|
{
|
|
var title = tiddler.title;
|
|
var ro = tiddler.isReadOnly();
|
|
var shadow = store.isShadowTiddler(title) && !store.tiddlerExists(title);
|
|
return (!ro || (ro && !command.hideReadOnly)) && !(shadow && command.hideShadow);
|
|
};
|
|
|
|
config.macros.toolbar.getCommandText = function(command,tiddler)
|
|
{
|
|
return tiddler.isReadOnly() && command.readOnlyText ? command.readOnlyText : command.text;
|
|
};
|
|
|
|
config.macros.toolbar.getCommandTooltip = function(command,tiddler)
|
|
{
|
|
return tiddler.isReadOnly() && command.readOnlyTooltip ? command.readOnlyTooltip : command.tooltip;
|
|
};
|
|
|
|
config.macros.toolbar.onClickCommand = function(e)
|
|
{
|
|
if(!e) var e = window.event;
|
|
e.cancelBubble = true;
|
|
if (e.stopPropagation) e.stopPropagation();
|
|
var command = config.commands[this.getAttribute("commandName")];
|
|
return command.handler(e,this,this.getAttribute("tiddler"));
|
|
};
|
|
|
|
config.macros.toolbar.onClickPopup = function(e)
|
|
{
|
|
if(!e) var e = window.event;
|
|
e.cancelBubble = true;
|
|
if (e.stopPropagation) e.stopPropagation();
|
|
var popup = Popup.create(this);
|
|
var command = config.commands[this.getAttribute("commandName")];
|
|
var title = this.getAttribute("tiddler");
|
|
var tiddler = store.fetchTiddler(title);
|
|
popup.setAttribute("tiddler",title);
|
|
command.handlePopup(popup,title);
|
|
Popup.show();
|
|
return false;
|
|
};
|
|
|
|
// Invoke the first command encountered from a given place that is tagged with a specified class
|
|
config.macros.toolbar.invokeCommand = function(place,theClass,event)
|
|
{
|
|
var children = place.getElementsByTagName("a");
|
|
for(var t=0; t<children.length; t++) {
|
|
var c = children[t];
|
|
if(hasClass(c,theClass) && c.getAttribute && c.getAttribute("commandName")) {
|
|
if(c.onclick instanceof Function)
|
|
c.onclick.call(c,event);
|
|
break;
|
|
}
|
|
}
|
|
};
|
|
|
|
config.macros.toolbar.onClickMore = function(e)
|
|
{
|
|
var e = this.nextSibling;
|
|
e.style.display = "inline";
|
|
removeNode(this);
|
|
return false;
|
|
};
|
|
|
|
config.macros.toolbar.handler = function(place,macroName,params,wikifier,paramString,tiddler)
|
|
{
|
|
for(var t=0; t<params.length; t++) {
|
|
var c = params[t];
|
|
switch(c) {
|
|
case '>':
|
|
var btn = createTiddlyButton(place,this.moreLabel,this.morePrompt,config.macros.toolbar.onClickMore);
|
|
addClass(btn,"moreCommand");
|
|
var e = createTiddlyElement(place,"span",null,"moreCommand");
|
|
e.style.display = "none";
|
|
place = e;
|
|
break;
|
|
default:
|
|
var theClass = "";
|
|
switch(c.substr(0,1)) {
|
|
case "+":
|
|
theClass = "defaultCommand";
|
|
c = c.substr(1);
|
|
break;
|
|
case "-":
|
|
theClass = "cancelCommand";
|
|
c = c.substr(1);
|
|
break;
|
|
}
|
|
if(c in config.commands)
|
|
this.createCommand(place,c,tiddler,theClass);
|
|
break;
|
|
}
|
|
}
|
|
};
|
|
|
|
config.macros.refreshDisplay.handler = function(place)
|
|
{
|
|
createTiddlyButton(place,this.label,this.prompt,this.onClick);
|
|
};
|
|
|
|
config.macros.refreshDisplay.onClick = function(e)
|
|
{
|
|
refreshAll();
|
|
return false;
|
|
};
|
|
|
|
config.macros.annotations.handler = function(place,macroName,params,wikifier,paramString,tiddler)
|
|
{
|
|
var title = tiddler ? tiddler.title : null;
|
|
var a = title ? config.annotations[title] : null;
|
|
if(!tiddler || !title || !a)
|
|
return;
|
|
var text = a.format([title]);
|
|
wikify(text,createTiddlyElement(place,"div",null,"annotation"),null,tiddler);
|
|
};
|
|
|
|
//--
|
|
//-- Menu and toolbar commands
|
|
//--
|
|
|
|
config.commands.closeTiddler.handler = function(event,src,title)
|
|
{
|
|
story.closeTiddler(title,true);
|
|
return false;
|
|
};
|
|
|
|
config.commands.closeOthers.handler = function(event,src,title)
|
|
{
|
|
story.closeAllTiddlers(title);
|
|
return false;
|
|
};
|
|
|
|
config.commands.editTiddler.handler = function(event,src,title)
|
|
{
|
|
clearMessage();
|
|
var tiddlerElem = document.getElementById(story.idPrefix + title);
|
|
var fields = tiddlerElem.getAttribute("tiddlyFields");
|
|
story.displayTiddler(null,title,DEFAULT_EDIT_TEMPLATE,false,null,fields);
|
|
story.focusTiddler(title,"text");
|
|
return false;
|
|
};
|
|
|
|
config.commands.saveTiddler.handler = function(event,src,title)
|
|
{
|
|
var newTitle = story.saveTiddler(title,event.shiftKey);
|
|
if(newTitle)
|
|
story.displayTiddler(null,newTitle);
|
|
return false;
|
|
};
|
|
|
|
config.commands.cancelTiddler.handler = function(event,src,title)
|
|
{
|
|
if(story.hasChanges(title) && !readOnly) {
|
|
if(!confirm(this.warning.format([title])))
|
|
return false;
|
|
}
|
|
story.setDirty(title,false);
|
|
story.displayTiddler(null,title);
|
|
return false;
|
|
};
|
|
|
|
config.commands.deleteTiddler.handler = function(event,src,title)
|
|
{
|
|
var deleteIt = true;
|
|
if (config.options.chkConfirmDelete)
|
|
deleteIt = confirm(this.warning.format([title]));
|
|
if (deleteIt) {
|
|
store.removeTiddler(title);
|
|
story.closeTiddler(title,true);
|
|
autoSaveChanges();
|
|
}
|
|
return false;
|
|
};
|
|
|
|
config.commands.permalink.handler = function(event,src,title)
|
|
{
|
|
var t = encodeURIComponent(String.encodeTiddlyLink(title));
|
|
if(window.location.hash != t)
|
|
window.location.hash = t;
|
|
return false;
|
|
};
|
|
|
|
config.commands.references.handlePopup = function(popup,title)
|
|
{
|
|
var references = store.getReferringTiddlers(title);
|
|
var c = false;
|
|
for(var r=0; r<references.length; r++) {
|
|
if(references[r].title != title && !references[r].isTagged("excludeLists")) {
|
|
createTiddlyLink(createTiddlyElement(popup,"li"),references[r].title,true);
|
|
c = true;
|
|
}
|
|
}
|
|
if(!c)
|
|
createTiddlyText(createTiddlyElement(popup,"li",null,"disabled"),this.popupNone);
|
|
};
|
|
|
|
config.commands.jump.handlePopup = function(popup,title)
|
|
{
|
|
story.forEachTiddler(function(title,element) {
|
|
createTiddlyLink(createTiddlyElement(popup,"li"),title,true,null,false,null,true);
|
|
});
|
|
};
|
|
|
|
config.commands.syncing.handlePopup = function(popup,title)
|
|
{
|
|
var tiddler = store.fetchTiddler(title);
|
|
if(!tiddler)
|
|
return;
|
|
var serverType = tiddler.getServerType();
|
|
var serverHost = tiddler.fields['server.host'];
|
|
var serverWorkspace = tiddler.fields['server.workspace'];
|
|
if(!serverWorkspace)
|
|
serverWorkspace = "";
|
|
if(serverType) {
|
|
var e = createTiddlyElement(popup,"li",null,"popupMessage");
|
|
e.innerHTML = config.commands.syncing.currentlySyncing.format([serverType,serverHost,serverWorkspace]);
|
|
} else {
|
|
createTiddlyElement(popup,"li",null,"popupMessage",config.commands.syncing.notCurrentlySyncing);
|
|
}
|
|
if(serverType) {
|
|
createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div");
|
|
var btn = createTiddlyButton(createTiddlyElement(popup,"li"),this.captionUnSync,null,config.commands.syncing.onChooseServer);
|
|
btn.setAttribute("tiddler",title);
|
|
btn.setAttribute("server.type","");
|
|
}
|
|
createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div");
|
|
createTiddlyElement(popup,"li",null,"popupMessage",config.commands.syncing.chooseServer);
|
|
var feeds = store.getTaggedTiddlers("systemServer","title");
|
|
for(var t=0; t<feeds.length; t++) {
|
|
var f = feeds[t];
|
|
var feedServerType = store.getTiddlerSlice(f.title,"Type");
|
|
if(!feedServerType)
|
|
feedServerType = "file";
|
|
var feedServerHost = store.getTiddlerSlice(f.title,"URL");
|
|
if(!feedServerHost)
|
|
feedServerHost = "";
|
|
var feedServerWorkspace = store.getTiddlerSlice(f.title,"Workspace");
|
|
if(!feedServerWorkspace)
|
|
feedServerWorkspace = "";
|
|
var caption = f.title;
|
|
if(serverType == feedServerType && serverHost == feedServerHost && serverWorkspace == feedServerWorkspace) {
|
|
caption = config.commands.syncing.currServerMarker + caption;
|
|
} else {
|
|
caption = config.commands.syncing.notCurrServerMarker + caption;
|
|
}
|
|
btn = createTiddlyButton(createTiddlyElement(popup,"li"),caption,null,config.commands.syncing.onChooseServer);
|
|
btn.setAttribute("tiddler",title);
|
|
btn.setAttribute("server.type",feedServerType);
|
|
btn.setAttribute("server.host",feedServerHost);
|
|
btn.setAttribute("server.workspace",feedServerWorkspace);
|
|
}
|
|
};
|
|
|
|
config.commands.syncing.onChooseServer = function(e)
|
|
{
|
|
var tiddler = this.getAttribute("tiddler");
|
|
var serverType = this.getAttribute("server.type");
|
|
if(serverType) {
|
|
store.addTiddlerFields(tiddler,{
|
|
'server.type': serverType,
|
|
'server.host': this.getAttribute("server.host"),
|
|
'server.workspace': this.getAttribute("server.workspace")
|
|
});
|
|
} else {
|
|
store.setValue(tiddler,'server',null);
|
|
}
|
|
return false;
|
|
};
|
|
|
|
config.commands.fields.handlePopup = function(popup,title)
|
|
{
|
|
var tiddler = store.fetchTiddler(title);
|
|
if(!tiddler)
|
|
return;
|
|
var fields = {};
|
|
store.forEachField(tiddler,function(tiddler,fieldName,value) {fields[fieldName] = value;},true);
|
|
var items = [];
|
|
for(var t in fields) {
|
|
items.push({field: t,value: fields[t]});
|
|
}
|
|
items.sort(function(a,b) {return a.field < b.field ? -1 : (a.field == b.field ? 0 : +1);});
|
|
if(items.length > 0)
|
|
ListView.create(popup,items,this.listViewTemplate);
|
|
else
|
|
createTiddlyElement(popup,"div",null,null,this.emptyText);
|
|
};
|
|
|
|
//--
|
|
//-- Tiddler() object
|
|
//--
|
|
|
|
function Tiddler(title)
|
|
{
|
|
this.title = title;
|
|
this.text = null;
|
|
this.modifier = null;
|
|
this.modified = new Date();
|
|
this.created = new Date();
|
|
this.links = [];
|
|
this.linksUpdated = false;
|
|
this.tags = [];
|
|
this.fields = {};
|
|
return this;
|
|
}
|
|
|
|
Tiddler.prototype.getLinks = function()
|
|
{
|
|
if(this.linksUpdated==false)
|
|
this.changed();
|
|
return this.links;
|
|
};
|
|
|
|
// Returns the fields that are inherited in string field:"value" field2:"value2" format
|
|
Tiddler.prototype.getInheritedFields = function()
|
|
{
|
|
var f = {};
|
|
for(i in this.fields) {
|
|
if(i=="server.host" || i=="server.workspace" || i=="wikiformat"|| i=="server.type") {
|
|
f[i] = this.fields[i];
|
|
}
|
|
}
|
|
return String.encodeHashMap(f);
|
|
};
|
|
|
|
// Increment the changeCount of a tiddler
|
|
Tiddler.prototype.incChangeCount = function()
|
|
{
|
|
var c = this.fields['changecount'];
|
|
c = c ? parseInt(c) : 0;
|
|
this.fields['changecount'] = String(c+1);
|
|
};
|
|
|
|
// Clear the changeCount of a tiddler
|
|
Tiddler.prototype.clearChangeCount = function()
|
|
{
|
|
if(this.fields['changecount']) {
|
|
delete this.fields['changecount'];
|
|
}
|
|
};
|
|
|
|
// Returns true if the tiddler has been updated since the tiddler was created or downloaded
|
|
Tiddler.prototype.isTouched = function()
|
|
{
|
|
var changeCount = this.fields['changecount'];
|
|
if(changeCount === undefined)
|
|
changeCount = 0;
|
|
return changeCount > 0;
|
|
};
|
|
|
|
// Format the text for storage in an RSS item
|
|
Tiddler.prototype.saveToRss = function(url)
|
|
{
|
|
var s = [];
|
|
s.push("<item>");
|
|
s.push("<title" + ">" + this.title.htmlEncode() + "</title" + ">");
|
|
s.push("<description>" + wikifyStatic(this.text,null,this).htmlEncode() + "</description>");
|
|
for(var t=0; t<this.tags.length; t++)
|
|
s.push("<category>" + this.tags[t] + "</category>");
|
|
s.push("<link>" + url + "#" + encodeURIComponent(String.encodeTiddlyLink(this.title)) + "</link>");
|
|
s.push("<pubDate>" + this.modified.toGMTString() + "</pubDate>");
|
|
s.push("</item>");
|
|
return s.join("\n");
|
|
};
|
|
|
|
// Change the text and other attributes of a tiddler
|
|
Tiddler.prototype.set = function(title,text,modifier,modified,tags,created,fields)
|
|
{
|
|
this.assign(title,text,modifier,modified,tags,created,fields);
|
|
this.changed();
|
|
return this;
|
|
};
|
|
|
|
// Change the text and other attributes of a tiddler without triggered a tiddler.changed() call
|
|
Tiddler.prototype.assign = function(title,text,modifier,modified,tags,created,fields)
|
|
{
|
|
if(title != undefined)
|
|
this.title = title;
|
|
if(text != undefined)
|
|
this.text = text;
|
|
if(modifier != undefined)
|
|
this.modifier = modifier;
|
|
if(modified != undefined)
|
|
this.modified = modified;
|
|
if(created != undefined)
|
|
this.created = created;
|
|
if(fields != undefined)
|
|
this.fields = fields;
|
|
if(tags != undefined)
|
|
this.tags = (typeof tags == "string") ? tags.readBracketedList() : tags;
|
|
else if(this.tags == undefined)
|
|
this.tags = [];
|
|
return this;
|
|
};
|
|
|
|
// Get the tags for a tiddler as a string (space delimited, using [[brackets]] for tags containing spaces)
|
|
Tiddler.prototype.getTags = function()
|
|
{
|
|
return String.encodeTiddlyLinkList(this.tags);
|
|
};
|
|
|
|
// Test if a tiddler carries a tag
|
|
Tiddler.prototype.isTagged = function(tag)
|
|
{
|
|
return this.tags.indexOf(tag) != -1;
|
|
};
|
|
|
|
// Static method to convert "\n" to newlines, "\s" to "\"
|
|
Tiddler.unescapeLineBreaks = function(text)
|
|
{
|
|
return text ? text.unescapeLineBreaks() : "";
|
|
};
|
|
|
|
// Convert newlines to "\n", "\" to "\s"
|
|
Tiddler.prototype.escapeLineBreaks = function()
|
|
{
|
|
return this.text.escapeLineBreaks();
|
|
};
|
|
|
|
// Updates the secondary information (like links[] array) after a change to a tiddler
|
|
Tiddler.prototype.changed = function()
|
|
{
|
|
this.links = [];
|
|
var t = this.autoLinkWikiWords() ? 0 : 1;
|
|
var tiddlerLinkRegExp = t==0 ? config.textPrimitives.tiddlerAnyLinkRegExp : config.textPrimitives.tiddlerForcedLinkRegExp;
|
|
tiddlerLinkRegExp.lastIndex = 0;
|
|
var formatMatch = tiddlerLinkRegExp.exec(this.text);
|
|
while(formatMatch) {
|
|
var lastIndex = tiddlerLinkRegExp.lastIndex;
|
|
if(t==0 && formatMatch[1] && formatMatch[1] != this.title) {
|
|
// wikiWordLink
|
|
if(formatMatch.index > 0) {
|
|
var preRegExp = new RegExp(config.textPrimitives.unWikiLink+"|"+config.textPrimitives.anyLetter,"mg");
|
|
preRegExp.lastIndex = formatMatch.index-1;
|
|
var preMatch = preRegExp.exec(this.text);
|
|
if(preMatch.index != formatMatch.index-1)
|
|
this.links.pushUnique(formatMatch[1]);
|
|
} else {
|
|
this.links.pushUnique(formatMatch[1]);
|
|
}
|
|
}
|
|
else if(formatMatch[2-t] && !config.formatterHelpers.isExternalLink(formatMatch[3-t])) // titledBrackettedLink
|
|
this.links.pushUnique(formatMatch[3-t]);
|
|
else if(formatMatch[4-t] && formatMatch[4-t] != this.title) // brackettedLink
|
|
this.links.pushUnique(formatMatch[4-t]);
|
|
tiddlerLinkRegExp.lastIndex = lastIndex;
|
|
formatMatch = tiddlerLinkRegExp.exec(this.text);
|
|
}
|
|
this.linksUpdated = true;
|
|
};
|
|
|
|
Tiddler.prototype.getSubtitle = function()
|
|
{
|
|
var theModifier = this.modifier;
|
|
if(!theModifier)
|
|
theModifier = config.messages.subtitleUnknown;
|
|
var theModified = this.modified;
|
|
if(theModified)
|
|
theModified = theModified.toLocaleString();
|
|
else
|
|
theModified = config.messages.subtitleUnknown;
|
|
return config.messages.tiddlerLinkTooltip.format([this.title,theModifier,theModified]);
|
|
};
|
|
|
|
Tiddler.prototype.isReadOnly = function()
|
|
{
|
|
return readOnly;
|
|
};
|
|
|
|
Tiddler.prototype.autoLinkWikiWords = function()
|
|
{
|
|
return !(this.isTagged("systemConfig") || this.isTagged("excludeMissing"));
|
|
};
|
|
|
|
Tiddler.prototype.generateFingerprint = function()
|
|
{
|
|
return "0x" + Crypto.hexSha1Str(this.text);
|
|
};
|
|
|
|
Tiddler.prototype.getServerType = function()
|
|
{
|
|
var serverType = null;
|
|
if(this.fields && this.fields['server.type'])
|
|
serverType = this.fields['server.type'];
|
|
if(!serverType)
|
|
serverType = this.fields['wikiformat'];
|
|
if(serverType && !config.adaptors[serverType])
|
|
serverType = null;
|
|
return serverType;
|
|
};
|
|
|
|
Tiddler.prototype.getAdaptor = function()
|
|
{
|
|
var serverType = this.getServerType();
|
|
if(serverType)
|
|
return new config.adaptors[serverType];
|
|
else
|
|
return null;
|
|
};
|
|
|
|
//--
|
|
//-- TiddlyWiki() object contains Tiddler()s
|
|
//--
|
|
|
|
function TiddlyWiki()
|
|
{
|
|
var tiddlers = {}; // Hashmap by name of tiddlers
|
|
this.tiddlersUpdated = false;
|
|
this.namedNotifications = []; // Array of {name:,notify:} of notification functions
|
|
this.notificationLevel = 0;
|
|
this.slices = {}; // map tiddlerName->(map sliceName->sliceValue). Lazy.
|
|
this.clear = function() {
|
|
tiddlers = {};
|
|
this.setDirty(false);
|
|
};
|
|
this.fetchTiddler = function(title) {
|
|
return tiddlers[title];
|
|
};
|
|
this.deleteTiddler = function(title) {
|
|
delete this.slices[title];
|
|
delete tiddlers[title];
|
|
};
|
|
this.addTiddler = function(tiddler) {
|
|
delete this.slices[tiddler.title];
|
|
tiddlers[tiddler.title] = tiddler;
|
|
};
|
|
this.forEachTiddler = function(callback) {
|
|
for(var t in tiddlers) {
|
|
var tiddler = tiddlers[t];
|
|
if(tiddler instanceof Tiddler)
|
|
callback.call(this,t,tiddler);
|
|
}
|
|
};
|
|
}
|
|
|
|
TiddlyWiki.prototype.setDirty = function(dirty)
|
|
{
|
|
this.dirty = dirty;
|
|
};
|
|
|
|
TiddlyWiki.prototype.isDirty = function()
|
|
{
|
|
return this.dirty;
|
|
};
|
|
|
|
TiddlyWiki.prototype.suspendNotifications = function()
|
|
{
|
|
this.notificationLevel--;
|
|
};
|
|
|
|
TiddlyWiki.prototype.resumeNotifications = function()
|
|
{
|
|
this.notificationLevel++;
|
|
};
|
|
|
|
// Invoke the notification handlers for a particular tiddler
|
|
TiddlyWiki.prototype.notify = function(title,doBlanket)
|
|
{
|
|
if(!this.notificationLevel) {
|
|
for(var t=0; t<this.namedNotifications.length; t++) {
|
|
var n = this.namedNotifications[t];
|
|
if((n.name == null && doBlanket) || (n.name == title))
|
|
n.notify(title);
|
|
}
|
|
}
|
|
};
|
|
|
|
// Invoke the notification handlers for all tiddlers
|
|
TiddlyWiki.prototype.notifyAll = function()
|
|
{
|
|
if(!this.notificationLevel) {
|
|
for(var t=0; t<this.namedNotifications.length; t++) {
|
|
var n = this.namedNotifications[t];
|
|
if(n.name)
|
|
n.notify(n.name);
|
|
}
|
|
}
|
|
};
|
|
|
|
// Add a notification handler to a tiddler
|
|
TiddlyWiki.prototype.addNotification = function(title,fn)
|
|
{
|
|
for(var i=0; i<this.namedNotifications.length; i++) {
|
|
if((this.namedNotifications[i].name == title) && (this.namedNotifications[i].notify == fn))
|
|
return this;
|
|
}
|
|
this.namedNotifications.push({name: title, notify: fn});
|
|
return this;
|
|
};
|
|
|
|
TiddlyWiki.prototype.removeTiddler = function(title)
|
|
{
|
|
var tiddler = this.fetchTiddler(title);
|
|
if(tiddler) {
|
|
this.deleteTiddler(title);
|
|
this.notify(title,true);
|
|
this.setDirty(true);
|
|
}
|
|
};
|
|
|
|
TiddlyWiki.prototype.tiddlerExists = function(title)
|
|
{
|
|
var t = this.fetchTiddler(title);
|
|
return t != undefined;
|
|
};
|
|
|
|
TiddlyWiki.prototype.isShadowTiddler = function(title)
|
|
{
|
|
return typeof config.shadowTiddlers[title] == "string";
|
|
};
|
|
|
|
TiddlyWiki.prototype.getTiddler = function(title)
|
|
{
|
|
var t = this.fetchTiddler(title);
|
|
if(t != undefined)
|
|
return t;
|
|
else
|
|
return null;
|
|
};
|
|
|
|
TiddlyWiki.prototype.getTiddlerText = function(title,defaultText)
|
|
{
|
|
var tiddler = this.fetchTiddler(title);
|
|
if(tiddler)
|
|
return tiddler.text;
|
|
if(!title)
|
|
return defaultText;
|
|
var pos = title.indexOf(config.textPrimitives.sliceSeparator);
|
|
if(pos != -1) {
|
|
var slice = this.getTiddlerSlice(title.substr(0,pos),title.substr(pos + config.textPrimitives.sliceSeparator.length));
|
|
if(slice)
|
|
return slice;
|
|
}
|
|
if(this.isShadowTiddler(title))
|
|
return config.shadowTiddlers[title];
|
|
if(defaultText != undefined)
|
|
return defaultText;
|
|
return null;
|
|
};
|
|
|
|
TiddlyWiki.prototype.slicesRE = /(?:[\'\/]*~?([\.\w]+)[\'\/]*\:[\'\/]*\s*(.*?)\s*$)|(?:\|[\'\/]*~?([\.\w]+)\:?[\'\/]*\|\s*(.*?)\s*\|)/gm;
|
|
|
|
// @internal
|
|
TiddlyWiki.prototype.calcAllSlices = function(title)
|
|
{
|
|
var slices = {};
|
|
var text = this.getTiddlerText(title,"");
|
|
this.slicesRE.lastIndex = 0;
|
|
do {
|
|
var m = this.slicesRE.exec(text);
|
|
if(m) {
|
|
if(m[1])
|
|
slices[m[1]] = m[2];
|
|
else
|
|
slices[m[3]] = m[4];
|
|
}
|
|
} while(m);
|
|
return slices;
|
|
};
|
|
|
|
// Returns the slice of text of the given name
|
|
TiddlyWiki.prototype.getTiddlerSlice = function(title,sliceName)
|
|
{
|
|
var slices = this.slices[title];
|
|
if(!slices) {
|
|
slices = this.calcAllSlices(title);
|
|
this.slices[title] = slices;
|
|
}
|
|
return slices[sliceName];
|
|
};
|
|
|
|
// Build an hashmap of the specified named slices of a tiddler
|
|
TiddlyWiki.prototype.getTiddlerSlices = function(title,sliceNames)
|
|
{
|
|
var r = {};
|
|
for(var t=0; t<sliceNames.length; t++) {
|
|
var slice = this.getTiddlerSlice(title,sliceNames[t]);
|
|
if(slice)
|
|
r[sliceNames[t]] = slice;
|
|
}
|
|
return r;
|
|
};
|
|
|
|
TiddlyWiki.prototype.getRecursiveTiddlerText = function(title,defaultText,depth)
|
|
{
|
|
var bracketRegExp = new RegExp("(?:\\[\\[([^\\]]+)\\]\\])","mg");
|
|
var text = this.getTiddlerText(title,null);
|
|
if(text == null)
|
|
return defaultText;
|
|
var textOut = [];
|
|
var lastPos = 0;
|
|
do {
|
|
var match = bracketRegExp.exec(text);
|
|
if(match) {
|
|
textOut.push(text.substr(lastPos,match.index-lastPos));
|
|
if(match[1]) {
|
|
if(depth <= 0)
|
|
textOut.push(match[1]);
|
|
else
|
|
textOut.push(this.getRecursiveTiddlerText(match[1],"[[" + match[1] + "]]",depth-1));
|
|
}
|
|
lastPos = match.index + match[0].length;
|
|
} else {
|
|
textOut.push(text.substr(lastPos));
|
|
}
|
|
} while(match);
|
|
return textOut.join("");
|
|
};
|
|
|
|
TiddlyWiki.prototype.setTiddlerTag = function(title,status,tag)
|
|
{
|
|
var tiddler = this.fetchTiddler(title);
|
|
if(tiddler) {
|
|
var t = tiddler.tags.indexOf(tag);
|
|
if(t != -1)
|
|
tiddler.tags.splice(t,1);
|
|
if(status)
|
|
tiddler.tags.push(tag);
|
|
tiddler.changed();
|
|
this.incChangeCount(title);
|
|
this.notify(title,true);
|
|
this.setDirty(true);
|
|
}
|
|
};
|
|
|
|
TiddlyWiki.prototype.addTiddlerFields = function(title,fields)
|
|
{
|
|
var tiddler = this.fetchTiddler(title);
|
|
if(!tiddler)
|
|
return;
|
|
merge(tiddler.fields,fields);
|
|
tiddler.changed();
|
|
this.incChangeCount(title);
|
|
this.notify(title,true);
|
|
this.setDirty(true);
|
|
};
|
|
|
|
TiddlyWiki.prototype.saveTiddler = function(title,newTitle,newBody,modifier,modified,tags,fields,clearChangeCount,created)
|
|
{
|
|
var tiddler = this.fetchTiddler(title);
|
|
if(tiddler) {
|
|
created = created ? created : tiddler.created; // Preserve created date
|
|
this.deleteTiddler(title);
|
|
} else {
|
|
created = created ? created : modified;
|
|
tiddler = new Tiddler();
|
|
}
|
|
tiddler.set(newTitle,newBody,modifier,modified,tags,created,fields);
|
|
this.addTiddler(tiddler);
|
|
if(clearChangeCount)
|
|
tiddler.clearChangeCount();
|
|
else
|
|
tiddler.incChangeCount();
|
|
if(title != newTitle)
|
|
this.notify(title,true);
|
|
this.notify(newTitle,true);
|
|
this.setDirty(true);
|
|
return tiddler;
|
|
};
|
|
|
|
// Reset the sync status of a freshly synced tiddler
|
|
TiddlyWiki.prototype.resetTiddler = function(title)
|
|
{
|
|
var tiddler = this.fetchTiddler(title);
|
|
if(tiddler) {
|
|
tiddler.clearChangeCount();
|
|
this.notify(title,true);
|
|
this.setDirty(true);
|
|
}
|
|
};
|
|
|
|
TiddlyWiki.prototype.incChangeCount = function(title)
|
|
{
|
|
var tiddler = this.fetchTiddler(title);
|
|
if(tiddler)
|
|
tiddler.incChangeCount();
|
|
};
|
|
|
|
TiddlyWiki.prototype.createTiddler = function(title)
|
|
{
|
|
var tiddler = this.fetchTiddler(title);
|
|
if(!tiddler) {
|
|
tiddler = new Tiddler();
|
|
tiddler.title = title;
|
|
this.addTiddler(tiddler);
|
|
this.setDirty(true);
|
|
}
|
|
return tiddler;
|
|
};
|
|
|
|
// Load contents of a TiddlyWiki from an HTML DIV
|
|
TiddlyWiki.prototype.loadFromDiv = function(src,idPrefix,noUpdate)
|
|
{
|
|
this.idPrefix = idPrefix;
|
|
var storeElem = (typeof src == "string") ? document.getElementById(src) : src;
|
|
if(!storeElem)
|
|
return;
|
|
var tiddlers = this.getLoader().loadTiddlers(this,storeElem.childNodes);
|
|
this.setDirty(false);
|
|
if(!noUpdate) {
|
|
for(var i = 0;i<tiddlers.length; i++)
|
|
tiddlers[i].changed();
|
|
}
|
|
};
|
|
|
|
// Load contents of a TiddlyWiki from a string
|
|
// Returns null if there's an error
|
|
TiddlyWiki.prototype.importTiddlyWiki = function(text)
|
|
{
|
|
var posDiv = locateStoreArea(text);
|
|
if(!posDiv)
|
|
return null;
|
|
var content = "<" + "html><" + "body>" + text.substring(posDiv[0],posDiv[1] + endSaveArea.length) + "<" + "/body><" + "/html>";
|
|
// Create the iframe
|
|
var iframe = document.createElement("iframe");
|
|
iframe.style.display = "none";
|
|
document.body.appendChild(iframe);
|
|
var doc = iframe.document;
|
|
if(iframe.contentDocument)
|
|
doc = iframe.contentDocument; // For NS6
|
|
else if(iframe.contentWindow)
|
|
doc = iframe.contentWindow.document; // For IE5.5 and IE6
|
|
// Put the content in the iframe
|
|
doc.open();
|
|
doc.writeln(content);
|
|
doc.close();
|
|
// Load the content into a TiddlyWiki() object
|
|
var storeArea = doc.getElementById("storeArea");
|
|
this.loadFromDiv(storeArea,"store");
|
|
// Get rid of the iframe
|
|
iframe.parentNode.removeChild(iframe);
|
|
return this;
|
|
};
|
|
|
|
TiddlyWiki.prototype.updateTiddlers = function()
|
|
{
|
|
this.tiddlersUpdated = true;
|
|
this.forEachTiddler(function(title,tiddler) {
|
|
tiddler.changed();
|
|
});
|
|
};
|
|
|
|
// Return all tiddlers formatted as an HTML string
|
|
TiddlyWiki.prototype.allTiddlersAsHtml = function()
|
|
{
|
|
return store.getSaver().externalize(store);
|
|
};
|
|
|
|
// Return an array of tiddlers matching a search regular expression
|
|
TiddlyWiki.prototype.search = function(searchRegExp,sortField,excludeTag)
|
|
{
|
|
var candidates = this.reverseLookup("tags",excludeTag,false);
|
|
var results = [];
|
|
for(var t=0; t<candidates.length; t++) {
|
|
if((candidates[t].title.search(searchRegExp) != -1) || (candidates[t].text.search(searchRegExp) != -1))
|
|
results.push(candidates[t]);
|
|
}
|
|
if(!sortField)
|
|
sortField = "title";
|
|
results.sort(function(a,b) {return a[sortField] < b[sortField] ? -1 : (a[sortField] == b[sortField] ? 0 : +1);});
|
|
return results;
|
|
};
|
|
|
|
// Return an array of all the tags in use. Each member of the array is another array where [0] is the name of the tag and [1] is the number of occurances
|
|
TiddlyWiki.prototype.getTags = function(excludeTag)
|
|
{
|
|
var results = [];
|
|
this.forEachTiddler(function(title,tiddler) {
|
|
for(var g=0; g<tiddler.tags.length; g++) {
|
|
var tag = tiddler.tags[g];
|
|
if(excludeTag) {
|
|
var t = store.fetchTiddler(tag);
|
|
if(t && t.isTagged(excludeTag))
|
|
return false;
|
|
}
|
|
var f = false;
|
|
for(var c=0; c<results.length; c++) {
|
|
if(results[c][0] == tag) {
|
|
f = true;
|
|
results[c][1]++;
|
|
}
|
|
}
|
|
if(!f)
|
|
results.push([tag,1]);
|
|
}
|
|
});
|
|
results.sort(function(a,b) {return a[0].toLowerCase() < b[0].toLowerCase() ? -1 : (a[0].toLowerCase() == b[0].toLowerCase() ? 0 : +1);});
|
|
return results;
|
|
};
|
|
|
|
// Return an array of the tiddlers that are tagged with a given tag
|
|
TiddlyWiki.prototype.getTaggedTiddlers = function(tag,sortField)
|
|
{
|
|
return this.reverseLookup("tags",tag,true,sortField);
|
|
};
|
|
|
|
// Return an array of the tiddlers that link to a given tiddler
|
|
TiddlyWiki.prototype.getReferringTiddlers = function(title,unusedParameter,sortField)
|
|
{
|
|
if(!this.tiddlersUpdated)
|
|
this.updateTiddlers();
|
|
return this.reverseLookup("links",title,true,sortField);
|
|
};
|
|
|
|
// Return an array of the tiddlers that do or do not have a specified entry in the specified storage array (ie, "links" or "tags")
|
|
// lookupMatch == true to match tiddlers, false to exclude tiddlers
|
|
TiddlyWiki.prototype.reverseLookup = function(lookupField,lookupValue,lookupMatch,sortField)
|
|
{
|
|
var results = [];
|
|
this.forEachTiddler(function(title,tiddler) {
|
|
var f = !lookupMatch;
|
|
for(var lookup=0; lookup<tiddler[lookupField].length; lookup++) {
|
|
if(tiddler[lookupField][lookup] == lookupValue)
|
|
f = lookupMatch;
|
|
}
|
|
if(f)
|
|
results.push(tiddler);
|
|
});
|
|
if(!sortField)
|
|
sortField = "title";
|
|
results.sort(function(a,b) {return a[sortField] < b[sortField] ? -1 : (a[sortField] == b[sortField] ? 0 : +1);});
|
|
return results;
|
|
};
|
|
|
|
// Return the tiddlers as a sorted array
|
|
TiddlyWiki.prototype.getTiddlers = function(field,excludeTag)
|
|
{
|
|
var results = [];
|
|
this.forEachTiddler(function(title,tiddler) {
|
|
if(excludeTag == undefined || !tiddler.isTagged(excludeTag))
|
|
results.push(tiddler);
|
|
});
|
|
if(field)
|
|
results.sort(function(a,b) {return a[field] < b[field] ? -1 : (a[field] == b[field] ? 0 : +1);});
|
|
return results;
|
|
};
|
|
|
|
// Return array of names of tiddlers that are referred to but not defined
|
|
TiddlyWiki.prototype.getMissingLinks = function(sortField)
|
|
{
|
|
if(!this.tiddlersUpdated)
|
|
this.updateTiddlers();
|
|
var results = [];
|
|
this.forEachTiddler(function (title,tiddler) {
|
|
if(tiddler.isTagged("excludeMissing") || tiddler.isTagged("systemConfig"))
|
|
return;
|
|
for(var n=0; n<tiddler.links.length;n++) {
|
|
var link = tiddler.links[n];
|
|
if(this.fetchTiddler(link) == null && !this.isShadowTiddler(link))
|
|
results.pushUnique(link);
|
|
}
|
|
});
|
|
results.sort();
|
|
return results;
|
|
};
|
|
|
|
// Return an array of names of tiddlers that are defined but not referred to
|
|
TiddlyWiki.prototype.getOrphans = function()
|
|
{
|
|
var results = [];
|
|
this.forEachTiddler(function (title,tiddler) {
|
|
if(this.getReferringTiddlers(title).length == 0 && !tiddler.isTagged("excludeLists"))
|
|
results.push(title);
|
|
});
|
|
results.sort();
|
|
return results;
|
|
};
|
|
|
|
// Return an array of names of all the shadow tiddlers
|
|
TiddlyWiki.prototype.getShadowed = function()
|
|
{
|
|
var results = [];
|
|
for(var t in config.shadowTiddlers) {
|
|
if(typeof config.shadowTiddlers[t] == "string")
|
|
results.push(t);
|
|
}
|
|
results.sort();
|
|
return results;
|
|
};
|
|
|
|
// Return an array of tiddlers that have been touched since they were downloaded or created
|
|
TiddlyWiki.prototype.getTouched = function()
|
|
{
|
|
var results = [];
|
|
this.forEachTiddler(function(title,tiddler) {
|
|
if(tiddler.isTouched())
|
|
results.push(tiddler);
|
|
});
|
|
results.sort();
|
|
return results;
|
|
};
|
|
|
|
// Resolves a Tiddler reference or tiddler title into a Tiddler object, or null if it doesn't exist
|
|
TiddlyWiki.prototype.resolveTiddler = function(tiddler)
|
|
{
|
|
var t = (typeof tiddler == 'string') ? this.getTiddler(tiddler) : tiddler;
|
|
return t instanceof Tiddler ? t : null;
|
|
};
|
|
|
|
TiddlyWiki.prototype.getLoader = function()
|
|
{
|
|
if(!this.loader)
|
|
this.loader = new TW21Loader();
|
|
return this.loader;
|
|
};
|
|
|
|
TiddlyWiki.prototype.getSaver = function()
|
|
{
|
|
if(!this.saver)
|
|
this.saver = new TW21Saver();
|
|
return this.saver;
|
|
};
|
|
|
|
// Returns true if path is a valid field name (path),
|
|
// i.e. a sequence of identifiers, separated by '.'
|
|
TiddlyWiki.isValidFieldName = function(name)
|
|
{
|
|
var match = /[a-zA-Z_]\w*(\.[a-zA-Z_]\w*)*/.exec(name);
|
|
return match && (match[0] == name);
|
|
};
|
|
|
|
// Throws an exception when name is not a valid field name.
|
|
TiddlyWiki.checkFieldName = function(name)
|
|
{
|
|
if(!TiddlyWiki.isValidFieldName(name))
|
|
throw config.messages.invalidFieldName.format([name]);
|
|
};
|
|
|
|
function StringFieldAccess(n,readOnly)
|
|
{
|
|
this.set = readOnly ?
|
|
function(t,v) {if(v != t[n]) throw config.messages.fieldCannotBeChanged.format([n]);} :
|
|
function(t,v) {if(v != t[n]) {t[n] = v; return true;}};
|
|
this.get = function(t) {return t[n];};
|
|
}
|
|
|
|
function DateFieldAccess(n)
|
|
{
|
|
this.set = function(t,v) {
|
|
var d = v instanceof Date ? v : Date.convertFromYYYYMMDDHHMM(v);
|
|
if(d != t[n]) {
|
|
t[n] = d; return true;
|
|
}
|
|
};
|
|
this.get = function(t) {return t[n].convertToYYYYMMDDHHMM();};
|
|
}
|
|
|
|
function LinksFieldAccess(n)
|
|
{
|
|
this.set = function(t,v) {
|
|
var s = (typeof v == "string") ? v.readBracketedList() : v;
|
|
if(s.toString() != t[n].toString()) {
|
|
t[n] = s; return true;
|
|
}
|
|
};
|
|
this.get = function(t) {return String.encodeTiddlyLinkList(t[n]);};
|
|
}
|
|
|
|
TiddlyWiki.standardFieldAccess = {
|
|
// The set functions return true when setting the data has changed the value.
|
|
"title": new StringFieldAccess("title",true),
|
|
// Handle the "tiddler" field name as the title
|
|
"tiddler": new StringFieldAccess("title",true),
|
|
"text": new StringFieldAccess("text"),
|
|
"modifier": new StringFieldAccess("modifier"),
|
|
"modified": new DateFieldAccess("modified"),
|
|
"created": new DateFieldAccess("created"),
|
|
"tags": new LinksFieldAccess("tags")
|
|
};
|
|
|
|
TiddlyWiki.isStandardField = function(name)
|
|
{
|
|
return TiddlyWiki.standardFieldAccess[name] != undefined;
|
|
};
|
|
|
|
// Sets the value of the given field of the tiddler to the value.
|
|
// Setting an ExtendedField's value to null or undefined removes the field.
|
|
// Setting a namespace to undefined removes all fields of that namespace.
|
|
// The fieldName is case-insensitive.
|
|
// All values will be converted to a string value.
|
|
TiddlyWiki.prototype.setValue = function(tiddler,fieldName,value)
|
|
{
|
|
TiddlyWiki.checkFieldName(fieldName);
|
|
var t = this.resolveTiddler(tiddler);
|
|
if(!t)
|
|
return;
|
|
fieldName = fieldName.toLowerCase();
|
|
var isRemove = (value === undefined) || (value === null);
|
|
var accessor = TiddlyWiki.standardFieldAccess[fieldName];
|
|
if(accessor) {
|
|
if(isRemove)
|
|
// don't remove StandardFields
|
|
return;
|
|
var h = TiddlyWiki.standardFieldAccess[fieldName];
|
|
if(!h.set(t,value))
|
|
return;
|
|
} else {
|
|
var oldValue = t.fields[fieldName];
|
|
if(isRemove) {
|
|
if(oldValue !== undefined) {
|
|
// deletes a single field
|
|
delete t.fields[fieldName];
|
|
} else {
|
|
// no concrete value is defined for the fieldName
|
|
// so we guess this is a namespace path.
|
|
// delete all fields in a namespace
|
|
var re = new RegExp('^'+fieldName+'\\.');
|
|
var dirty = false;
|
|
for(var n in t.fields) {
|
|
if(n.match(re)) {
|
|
delete t.fields[n];
|
|
dirty = true;
|
|
}
|
|
}
|
|
if(!dirty)
|
|
return;
|
|
}
|
|
} else {
|
|
// the "normal" set case. value is defined (not null/undefined)
|
|
// For convenience provide a nicer conversion Date->String
|
|
value = value instanceof Date ? value.convertToYYYYMMDDHHMMSSMMM() : String(value);
|
|
if(oldValue == value)
|
|
return;
|
|
t.fields[fieldName] = value;
|
|
}
|
|
}
|
|
// When we are here the tiddler/store really was changed.
|
|
this.notify(t.title,true);
|
|
if(!fieldName.match(/^temp\./))
|
|
this.setDirty(true);
|
|
};
|
|
|
|
// Returns the value of the given field of the tiddler.
|
|
// The fieldName is case-insensitive.
|
|
// Will only return String values (or undefined).
|
|
TiddlyWiki.prototype.getValue = function(tiddler,fieldName)
|
|
{
|
|
var t = this.resolveTiddler(tiddler);
|
|
if(!t)
|
|
return undefined;
|
|
fieldName = fieldName.toLowerCase();
|
|
var accessor = TiddlyWiki.standardFieldAccess[fieldName];
|
|
if(accessor) {
|
|
return accessor.get(t);
|
|
}
|
|
return t.fields[fieldName];
|
|
};
|
|
|
|
// Calls the callback function for every field in the tiddler.
|
|
// When callback function returns a non-false value the iteration stops
|
|
// and that value is returned.
|
|
// The order of the fields is not defined.
|
|
// @param callback a function(tiddler,fieldName,value).
|
|
TiddlyWiki.prototype.forEachField = function(tiddler,callback,onlyExtendedFields)
|
|
{
|
|
var t = this.resolveTiddler(tiddler);
|
|
if(!t)
|
|
return undefined;
|
|
for(var n in t.fields) {
|
|
var result = callback(t,n,t.fields[n]);
|
|
if(result)
|
|
return result;
|
|
}
|
|
if(onlyExtendedFields)
|
|
return undefined;
|
|
for(var n in TiddlyWiki.standardFieldAccess) {
|
|
if(n == "tiddler")
|
|
// even though the "title" field can also be referenced through the name "tiddler"
|
|
// we only visit this field once.
|
|
continue;
|
|
var result = callback(t,n,TiddlyWiki.standardFieldAccess[n].get(t));
|
|
if(result)
|
|
return result;
|
|
}
|
|
return undefined;
|
|
};
|
|
|
|
//--
|
|
//-- Story functions
|
|
//--
|
|
|
|
function Story(container,idPrefix)
|
|
{
|
|
this.container = container;
|
|
this.idPrefix = idPrefix;
|
|
this.highlightRegExp = null;
|
|
}
|
|
|
|
Story.prototype.forEachTiddler = function(fn)
|
|
{
|
|
var place = document.getElementById(this.container);
|
|
if(!place)
|
|
return;
|
|
var e = place.firstChild;
|
|
while(e) {
|
|
var n = e.nextSibling;
|
|
var title = e.getAttribute("tiddler");
|
|
fn.call(this,title,e);
|
|
e = n;
|
|
}
|
|
};
|
|
|
|
Story.prototype.displayTiddlers = function(srcElement,titles,template,animate,unused,customFields,toggle)
|
|
{
|
|
for(var t = titles.length-1;t>=0;t--)
|
|
this.displayTiddler(srcElement,titles[t],template,animate,unused,customFields);
|
|
};
|
|
|
|
Story.prototype.displayTiddler = function(srcElement,title,template,animate,unused,customFields,toggle)
|
|
{
|
|
var place = document.getElementById(this.container);
|
|
var tiddlerElem = document.getElementById(this.idPrefix + title);
|
|
if(tiddlerElem) {
|
|
if(toggle)
|
|
this.closeTiddler(title,true);
|
|
else
|
|
this.refreshTiddler(title,template,false,customFields);
|
|
} else {
|
|
var before = this.positionTiddler(srcElement);
|
|
tiddlerElem = this.createTiddler(place,before,title,template,customFields);
|
|
}
|
|
if(srcElement && typeof srcElement !== "string") {
|
|
if(config.options.chkAnimate && (animate == undefined || animate == true) && anim && typeof Zoomer == "function" && typeof Scroller == "function")
|
|
anim.startAnimating(new Zoomer(title,srcElement,tiddlerElem),new Scroller(tiddlerElem));
|
|
else
|
|
window.scrollTo(0,ensureVisible(tiddlerElem));
|
|
}
|
|
};
|
|
|
|
Story.prototype.positionTiddler = function(srcElement)
|
|
{
|
|
var place = document.getElementById(this.container);
|
|
var before = null;
|
|
if(typeof srcElement == "string") {
|
|
switch(srcElement) {
|
|
case "top":
|
|
before = place.firstChild;
|
|
break;
|
|
case "bottom":
|
|
before = null;
|
|
break;
|
|
}
|
|
} else {
|
|
var after = this.findContainingTiddler(srcElement);
|
|
if(after == null) {
|
|
before = place.firstChild;
|
|
} else if(after.nextSibling) {
|
|
before = after.nextSibling;
|
|
if(before.nodeType != 1)
|
|
before = null;
|
|
}
|
|
}
|
|
return before;
|
|
};
|
|
|
|
Story.prototype.createTiddler = function(place,before,title,template,customFields)
|
|
{
|
|
var tiddlerElem = createTiddlyElement(null,"div",this.idPrefix + title,"tiddler");
|
|
tiddlerElem.setAttribute("refresh","tiddler");
|
|
if(customFields)
|
|
tiddlerElem.setAttribute("tiddlyFields",customFields);
|
|
place.insertBefore(tiddlerElem,before);
|
|
var defaultText = null;
|
|
if(!store.tiddlerExists(title) && !store.isShadowTiddler(title))
|
|
defaultText = this.loadMissingTiddler(title,customFields,tiddlerElem);
|
|
this.refreshTiddler(title,template,false,customFields,defaultText);
|
|
return tiddlerElem;
|
|
};
|
|
|
|
Story.prototype.loadMissingTiddler = function(title,fields,tiddlerElem)
|
|
{
|
|
var tiddler = new Tiddler(title);
|
|
tiddler.fields = typeof fields == "string" ? fields.decodeHashMap() : (fields ? fields : {});
|
|
var serverType = tiddler.getServerType();
|
|
var host = tiddler.fields['server.host'];
|
|
var workspace = tiddler.fields['server.workspace'];
|
|
if(!serverType | !host)
|
|
return null;
|
|
var sm = new SyncMachine(serverType,{
|
|
start: function() {
|
|
return this.openHost(host,"openWorkspace");
|
|
},
|
|
openWorkspace: function() {
|
|
return this.openWorkspace(workspace,"getTiddler");
|
|
},
|
|
getTiddler: function() {
|
|
return this.getTiddler(title,"gotTiddler");
|
|
},
|
|
gotTiddler: function(tiddler) {
|
|
if(tiddler && tiddler.text) {
|
|
var downloaded = new Date();
|
|
if(!tiddler.created)
|
|
tiddler.created = downloaded;
|
|
if(!tiddler.modified)
|
|
tiddler.modified = tiddler.created;
|
|
store.saveTiddler(tiddler.title,tiddler.title,tiddler.text,tiddler.modifier,tiddler.modified,tiddler.tags,tiddler.fields,true,tiddler.created);
|
|
autoSaveChanges();
|
|
}
|
|
delete this;
|
|
return true;
|
|
},
|
|
error: function(message) {
|
|
displayMessage("Error loading missing tiddler from %0: %1".format([host,message]));
|
|
}
|
|
});
|
|
sm.go();
|
|
return config.messages.loadingMissingTiddler.format([title,serverType,host,workspace]);
|
|
};
|
|
|
|
Story.prototype.chooseTemplateForTiddler = function(title,template)
|
|
{
|
|
if(!template)
|
|
template = DEFAULT_VIEW_TEMPLATE;
|
|
if(template == DEFAULT_VIEW_TEMPLATE || template == DEFAULT_EDIT_TEMPLATE)
|
|
template = config.tiddlerTemplates[template];
|
|
return template;
|
|
};
|
|
|
|
Story.prototype.getTemplateForTiddler = function(title,template,tiddler)
|
|
{
|
|
return store.getRecursiveTiddlerText(template,null,10);
|
|
};
|
|
|
|
Story.prototype.refreshTiddler = function(title,template,force,customFields,defaultText)
|
|
{
|
|
var tiddlerElem = document.getElementById(this.idPrefix + title);
|
|
if(tiddlerElem) {
|
|
if(tiddlerElem.getAttribute("dirty") == "true" && !force)
|
|
return tiddlerElem;
|
|
template = this.chooseTemplateForTiddler(title,template);
|
|
var currTemplate = tiddlerElem.getAttribute("template");
|
|
if((template != currTemplate) || force) {
|
|
var tiddler = store.getTiddler(title);
|
|
if(!tiddler) {
|
|
tiddler = new Tiddler();
|
|
if(store.isShadowTiddler(title)) {
|
|
tiddler.set(title,store.getTiddlerText(title),config.views.wikified.shadowModifier,version.date,[],version.date);
|
|
} else {
|
|
var text = template=="EditTemplate" ?
|
|
config.views.editor.defaultText.format([title]) :
|
|
config.views.wikified.defaultText.format([title]);
|
|
text = defaultText ? defaultText : text;
|
|
var fields = customFields ? customFields.decodeHashMap() : null;
|
|
tiddler.set(title,text,config.views.wikified.defaultModifier,version.date,[],version.date,fields);
|
|
}
|
|
}
|
|
tiddlerElem.setAttribute("tags",tiddler.tags.join(" "));
|
|
tiddlerElem.setAttribute("tiddler",title);
|
|
tiddlerElem.setAttribute("template",template);
|
|
var me = this;
|
|
tiddlerElem.onmouseover = this.onTiddlerMouseOver;
|
|
tiddlerElem.onmouseout = this.onTiddlerMouseOut;
|
|
tiddlerElem.ondblclick = this.onTiddlerDblClick;
|
|
tiddlerElem[window.event?"onkeydown":"onkeypress"] = this.onTiddlerKeyPress;
|
|
var html = this.getTemplateForTiddler(title,template,tiddler);
|
|
tiddlerElem.innerHTML = html;
|
|
applyHtmlMacros(tiddlerElem,tiddler);
|
|
if(store.getTaggedTiddlers(title).length > 0)
|
|
addClass(tiddlerElem,"isTag");
|
|
else
|
|
removeClass(tiddlerElem,"isTag");
|
|
if(!store.tiddlerExists(title)) {
|
|
if(store.isShadowTiddler(title))
|
|
addClass(tiddlerElem,"shadow");
|
|
else
|
|
addClass(tiddlerElem,"missing");
|
|
} else {
|
|
removeClass(tiddlerElem,"shadow");
|
|
removeClass(tiddlerElem,"missing");
|
|
}
|
|
if(customFields)
|
|
this.addCustomFields(tiddlerElem,customFields);
|
|
forceReflow();
|
|
}
|
|
}
|
|
return tiddlerElem;
|
|
};
|
|
|
|
Story.prototype.addCustomFields = function(place,customFields)
|
|
{
|
|
var fields = customFields.decodeHashMap();
|
|
var w = document.createElement("div");
|
|
w.style.display = "none";
|
|
place.appendChild(w);
|
|
for(var t in fields) {
|
|
var e = document.createElement("input");
|
|
e.setAttribute("type","text");
|
|
e.setAttribute("value",fields[t]);
|
|
w.appendChild(e);
|
|
e.setAttribute("edit",t);
|
|
}
|
|
};
|
|
|
|
Story.prototype.refreshAllTiddlers = function()
|
|
{
|
|
var place = document.getElementById(this.container);
|
|
var e = place.firstChild;
|
|
if(!e)
|
|
return;
|
|
this.refreshTiddler(e.getAttribute("tiddler"),e.getAttribute("template"),true);
|
|
while((e = e.nextSibling) != null)
|
|
this.refreshTiddler(e.getAttribute("tiddler"),e.getAttribute("template"),true);
|
|
};
|
|
|
|
Story.prototype.onTiddlerMouseOver = function(e)
|
|
{
|
|
if(window.addClass instanceof Function)
|
|
addClass(this,"selected");
|
|
};
|
|
|
|
Story.prototype.onTiddlerMouseOut = function(e)
|
|
{
|
|
if(window.removeClass instanceof Function)
|
|
removeClass(this,"selected");
|
|
};
|
|
|
|
Story.prototype.onTiddlerDblClick = function(e)
|
|
{
|
|
if(!e) var e = window.event;
|
|
var theTarget = resolveTarget(e);
|
|
if(theTarget && theTarget.nodeName.toLowerCase() != "input" && theTarget.nodeName.toLowerCase() != "textarea") {
|
|
if(document.selection && document.selection.empty)
|
|
document.selection.empty();
|
|
config.macros.toolbar.invokeCommand(this,"defaultCommand",e);
|
|
e.cancelBubble = true;
|
|
if(e.stopPropagation) e.stopPropagation();
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
};
|
|
|
|
Story.prototype.onTiddlerKeyPress = function(e)
|
|
{
|
|
if(!e) var e = window.event;
|
|
clearMessage();
|
|
var consume = false;
|
|
var title = this.getAttribute("tiddler");
|
|
var target = resolveTarget(e);
|
|
switch(e.keyCode) {
|
|
case 9: // Tab
|
|
if(config.options.chkInsertTabs && target.tagName.toLowerCase() == "textarea") {
|
|
replaceSelection(target,String.fromCharCode(9));
|
|
consume = true;
|
|
}
|
|
if(config.isOpera) {
|
|
target.onblur = function() {
|
|
this.focus();
|
|
this.onblur = null;
|
|
};
|
|
}
|
|
break;
|
|
case 13: // Ctrl-Enter
|
|
case 10: // Ctrl-Enter on IE PC
|
|
case 77: // Ctrl-Enter is "M" on some platforms
|
|
if(e.ctrlKey) {
|
|
blurElement(this);
|
|
config.macros.toolbar.invokeCommand(this,"defaultCommand",e);
|
|
consume = true;
|
|
}
|
|
break;
|
|
case 27: // Escape
|
|
blurElement(this);
|
|
config.macros.toolbar.invokeCommand(this,"cancelCommand",e);
|
|
consume = true;
|
|
break;
|
|
}
|
|
e.cancelBubble = consume;
|
|
if(consume) {
|
|
if(e.stopPropagation) e.stopPropagation(); // Stop Propagation
|
|
e.returnValue = true; // Cancel The Event in IE
|
|
if(e.preventDefault ) e.preventDefault(); // Cancel The Event in Moz
|
|
}
|
|
return !consume;
|
|
};
|
|
|
|
Story.prototype.getTiddlerField = function(title,field)
|
|
{
|
|
var tiddlerElem = document.getElementById(this.idPrefix + title);
|
|
var e = null;
|
|
if(tiddlerElem != null) {
|
|
var children = tiddlerElem.getElementsByTagName("*");
|
|
for(var t=0; t<children.length; t++) {
|
|
var c = children[t];
|
|
if(c.tagName.toLowerCase() == "input" || c.tagName.toLowerCase() == "textarea") {
|
|
if(!e)
|
|
e = c;
|
|
if(c.getAttribute("edit") == field)
|
|
e = c;
|
|
}
|
|
}
|
|
}
|
|
return e;
|
|
};
|
|
|
|
Story.prototype.focusTiddler = function(title,field)
|
|
{
|
|
var e = this.getTiddlerField(title,field);
|
|
if(e) {
|
|
e.focus();
|
|
e.select();
|
|
}
|
|
};
|
|
|
|
Story.prototype.blurTiddler = function(title)
|
|
{
|
|
var tiddlerElem = document.getElementById(this.idPrefix + title);
|
|
if(tiddlerElem != null && tiddlerElem.focus && tiddlerElem.blur) {
|
|
tiddlerElem.focus();
|
|
tiddlerElem.blur();
|
|
}
|
|
};
|
|
|
|
Story.prototype.setTiddlerField = function(title,tag,mode,field)
|
|
{
|
|
var c = story.getTiddlerField(title,field);
|
|
|
|
var tags = c.value.readBracketedList();
|
|
tags.setItem(tag,mode);
|
|
c.value = String.encodeTiddlyLinkList(tags);
|
|
};
|
|
|
|
Story.prototype.setTiddlerTag = function(title,tag,mode)
|
|
{
|
|
Story.prototype.setTiddlerField(title,tag,mode,"tags");
|
|
};
|
|
|
|
Story.prototype.closeTiddler = function(title,animate,unused)
|
|
{
|
|
var tiddlerElem = document.getElementById(this.idPrefix + title);
|
|
if(tiddlerElem != null) {
|
|
clearMessage();
|
|
this.scrubTiddler(tiddlerElem);
|
|
if(config.options.chkAnimate && animate && anim && typeof Slider == "function")
|
|
anim.startAnimating(new Slider(tiddlerElem,false,null,"all"));
|
|
else {
|
|
removeNode(tiddlerElem);
|
|
forceReflow();
|
|
}
|
|
}
|
|
};
|
|
|
|
Story.prototype.scrubTiddler = function(tiddlerElem)
|
|
{
|
|
tiddlerElem.id = null;
|
|
};
|
|
|
|
Story.prototype.setDirty = function(title,dirty)
|
|
{
|
|
var tiddlerElem = document.getElementById(this.idPrefix + title);
|
|
if(tiddlerElem != null)
|
|
tiddlerElem.setAttribute("dirty",dirty ? "true" : "false");
|
|
};
|
|
|
|
Story.prototype.isDirty = function(title)
|
|
{
|
|
var tiddlerElem = document.getElementById(this.idPrefix + title);
|
|
if(tiddlerElem != null)
|
|
return tiddlerElem.getAttribute("dirty") == "true";
|
|
return null;
|
|
};
|
|
|
|
Story.prototype.areAnyDirty = function()
|
|
{
|
|
var r = false;
|
|
this.forEachTiddler(function(title,element) {
|
|
if(this.isDirty(title))
|
|
r = true;
|
|
});
|
|
return r;
|
|
};
|
|
|
|
Story.prototype.closeAllTiddlers = function(exclude)
|
|
{
|
|
clearMessage();
|
|
this.forEachTiddler(function(title,element) {
|
|
if((title != exclude) && element.getAttribute("dirty") != "true")
|
|
this.closeTiddler(title);
|
|
});
|
|
window.scrollTo(0,ensureVisible(this.container));
|
|
};
|
|
|
|
Story.prototype.isEmpty = function()
|
|
{
|
|
var place = document.getElementById(this.container);
|
|
return place && place.firstChild == null;
|
|
};
|
|
|
|
Story.prototype.search = function(text,useCaseSensitive,useRegExp)
|
|
{
|
|
this.closeAllTiddlers();
|
|
highlightHack = new RegExp(useRegExp ? text : text.escapeRegExp(),useCaseSensitive ? "mg" : "img");
|
|
var matches = store.search(highlightHack,"title","excludeSearch");
|
|
var titles = [];
|
|
for(var t=0;t<matches.length;t++)
|
|
titles.push(matches[t].title);
|
|
this.displayTiddlers(null,titles);
|
|
highlightHack = null;
|
|
var q = useRegExp ? "/" : "'";
|
|
if(matches.length > 0)
|
|
displayMessage(config.macros.search.successMsg.format([titles.length.toString(),q + text + q]));
|
|
else
|
|
displayMessage(config.macros.search.failureMsg.format([q + text + q]));
|
|
};
|
|
|
|
Story.prototype.findContainingTiddler = function(e)
|
|
{
|
|
while(e && !hasClass(e,"tiddler"))
|
|
e = e.parentNode;
|
|
return e;
|
|
};
|
|
|
|
Story.prototype.gatherSaveFields = function(e,fields)
|
|
{
|
|
if(e && e.getAttribute) {
|
|
var f = e.getAttribute("edit");
|
|
if(f)
|
|
fields[f] = e.value.replace(/\r/mg,"");
|
|
if(e.hasChildNodes()) {
|
|
var c = e.childNodes;
|
|
for(var t=0; t<c.length; t++)
|
|
this.gatherSaveFields(c[t],fields);
|
|
}
|
|
}
|
|
};
|
|
|
|
Story.prototype.hasChanges = function(title)
|
|
{
|
|
var e = document.getElementById(this.idPrefix + title);
|
|
if(e != null) {
|
|
var fields = {};
|
|
this.gatherSaveFields(e,fields);
|
|
var tiddler = store.fetchTiddler(title);
|
|
if(!tiddler)
|
|
return false;
|
|
for(var n in fields) {
|
|
if(store.getValue(title,n) != fields[n])
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
|
|
Story.prototype.saveTiddler = function(title,minorUpdate)
|
|
{
|
|
var tiddlerElem = document.getElementById(this.idPrefix + title);
|
|
if(tiddlerElem != null) {
|
|
var fields = {};
|
|
this.gatherSaveFields(tiddlerElem,fields);
|
|
var newTitle = fields.title ? fields.title : title;
|
|
if(store.tiddlerExists(newTitle) && newTitle != title) {
|
|
if(!confirm(config.messages.overwriteWarning.format([newTitle.toString()])))
|
|
return null;
|
|
}
|
|
if(newTitle != title)
|
|
this.closeTiddler(newTitle,false);
|
|
tiddlerElem.id = this.idPrefix + newTitle;
|
|
tiddlerElem.setAttribute("tiddler",newTitle);
|
|
tiddlerElem.setAttribute("template",DEFAULT_VIEW_TEMPLATE);
|
|
tiddlerElem.setAttribute("dirty","false");
|
|
if(config.options.chkForceMinorUpdate)
|
|
minorUpdate = !minorUpdate;
|
|
if(!store.tiddlerExists(newTitle))
|
|
minorUpdate = false;
|
|
var newDate = new Date();
|
|
var extendedFields = store.tiddlerExists(newTitle) ? store.fetchTiddler(newTitle).fields : {};
|
|
for(var n in fields) {
|
|
if(!TiddlyWiki.isStandardField(n))
|
|
extendedFields[n] = fields[n];
|
|
}
|
|
var tiddler = store.saveTiddler(title,newTitle,fields.text,minorUpdate ? undefined : config.options.txtUserName,minorUpdate ? undefined : newDate,fields.tags,extendedFields);
|
|
autoSaveChanges(null,[tiddler]);
|
|
return newTitle;
|
|
}
|
|
return null;
|
|
};
|
|
|
|
Story.prototype.permaView = function()
|
|
{
|
|
var links = [];
|
|
this.forEachTiddler(function(title,element) {
|
|
links.push(String.encodeTiddlyLink(title));
|
|
});
|
|
var t = encodeURIComponent(links.join(" "));
|
|
if(t == "")
|
|
t = "#";
|
|
if(window.location.hash != t)
|
|
window.location.hash = t;
|
|
};
|
|
|
|
//--
|
|
//-- Backstage
|
|
//--
|
|
|
|
var backstage = {
|
|
area: null,
|
|
toolbar: null,
|
|
button: null,
|
|
showButton: null,
|
|
hideButton: null,
|
|
cloak: null,
|
|
panel: null,
|
|
panelBody: null,
|
|
panelFooter: null,
|
|
currTabName: null,
|
|
currTabElem: null,
|
|
content: null,
|
|
|
|
init: function() {
|
|
var cmb = config.messages.backstage;
|
|
this.area = document.getElementById("backstageArea");
|
|
this.toolbar = document.getElementById("backstageToolbar");
|
|
this.button = document.getElementById("backstageButton");
|
|
this.button.style.display = "block";
|
|
var t = cmb.open.text + " " + glyph("bentArrowLeft");
|
|
this.showButton = createTiddlyButton(this.button,t,cmb.open.tooltip,
|
|
function (e) {backstage.show(); return false;},null,"backstageShow");
|
|
t = glyph("bentArrowRight") + " " + cmb.close.text;
|
|
this.hideButton = createTiddlyButton(this.button,t,cmb.close.tooltip,
|
|
function (e) {backstage.hide(); return false;},null,"backstageHide");
|
|
this.cloak = document.getElementById("backstageCloak");
|
|
this.panel = document.getElementById("backstagePanel");
|
|
this.panelFooter = createTiddlyElement(this.panel,"div",null,"backstagePanelFooter");
|
|
this.panelBody = createTiddlyElement(this.panel,"div",null,"backstagePanelBody");
|
|
this.cloak.onmousedown = function(e) {
|
|
backstage.switchTab(null);
|
|
};
|
|
createTiddlyText(this.toolbar,cmb.prompt);
|
|
for(t=0; t<config.backstageTasks.length; t++) {
|
|
var taskName = config.backstageTasks[t];
|
|
var task = config.tasks[taskName];
|
|
var handler = task.action ? this.onClickCommand : this.onClickTab;
|
|
var text = task.text + (task.action ? "" : glyph("downTriangle"));
|
|
var btn = createTiddlyButton(this.toolbar,text,task.tooltip,handler,"backstageTab");
|
|
btn.setAttribute("task",taskName);
|
|
addClass(btn,task.action ? "backstageAction" : "backstageTask");
|
|
}
|
|
this.content = document.getElementById("contentWrapper");
|
|
if(config.options.chkBackstage)
|
|
this.show();
|
|
else
|
|
this.hide();
|
|
},
|
|
|
|
isVisible: function () {
|
|
return this.area ? this.area.style.display == "block" : false;
|
|
},
|
|
|
|
show: function() {
|
|
this.area.style.display = "block";
|
|
if(anim && config.options.chkAnimate) {
|
|
backstage.toolbar.style.left = findWindowWidth() + "px";
|
|
var p = [
|
|
{style: "left", start: findWindowWidth(), end: 0, template: "%0px"}
|
|
];
|
|
anim.startAnimating(new Morpher(backstage.toolbar,config.animDuration,p));
|
|
} else {
|
|
backstage.area.style.left = "0px";
|
|
}
|
|
this.showButton.style.display = "none";
|
|
this.hideButton.style.display = "block";
|
|
config.options.chkBackstage = true;
|
|
saveOptionCookie("chkBackstage");
|
|
addClass(this.content,"backstageVisible");
|
|
},
|
|
|
|
hide: function() {
|
|
if(this.currTabElem) {
|
|
this.switchTab(null);
|
|
} else {
|
|
backstage.toolbar.style.left = "0px";
|
|
if(anim && config.options.chkAnimate) {
|
|
var p = [
|
|
{style: "left", start: 0, end: findWindowWidth(), template: "%0px"}
|
|
];
|
|
var c = function(element,properties) {backstage.area.style.display = "none";};
|
|
anim.startAnimating(new Morpher(backstage.toolbar,config.animDuration,p,c));
|
|
} else {
|
|
this.area.style.display = "none";
|
|
}
|
|
this.showButton.style.display = "block";
|
|
this.hideButton.style.display = "none";
|
|
config.options.chkBackstage = false;
|
|
saveOptionCookie("chkBackstage");
|
|
removeClass(this.content,"backstageVisible");
|
|
}
|
|
},
|
|
|
|
onClickCommand: function(e) {
|
|
var task = config.tasks[this.getAttribute("task")];
|
|
displayMessage(task);
|
|
if(task.action) {
|
|
backstage.switchTab(null);
|
|
task.action();
|
|
}
|
|
return false;
|
|
},
|
|
|
|
onClickTab: function(e) {
|
|
backstage.switchTab(this.getAttribute("task"));
|
|
return false;
|
|
},
|
|
|
|
// Switch to a given tab, or none if null is passed
|
|
switchTab: function(tabName) {
|
|
var tabElem = null;
|
|
var e = this.toolbar.firstChild;
|
|
while(e)
|
|
{
|
|
if(e.getAttribute && e.getAttribute("task") == tabName)
|
|
tabElem = e;
|
|
e = e.nextSibling;
|
|
}
|
|
if(tabName == backstage.currTabName)
|
|
return;
|
|
if(backstage.currTabElem) {
|
|
removeClass(this.currTabElem,"backstageSelTab");
|
|
}
|
|
if(tabElem && tabName) {
|
|
backstage.preparePanel();
|
|
addClass(tabElem,"backstageSelTab");
|
|
var task = config.tasks[tabName];
|
|
wikify(task.content,backstage.panelBody,null,null);
|
|
backstage.showPanel();
|
|
} else if(backstage.currTabElem) {
|
|
backstage.hidePanel();
|
|
}
|
|
backstage.currTabName = tabName;
|
|
backstage.currTabElem = tabElem;
|
|
},
|
|
|
|
isPanelVisible: function() {
|
|
return backstage.panel ? backstage.panel.style.display == "block" : false;
|
|
},
|
|
|
|
preparePanel: function() {
|
|
backstage.cloak.style.height = findWindowHeight() + "px";
|
|
backstage.cloak.style.display = "block";
|
|
removeChildren(backstage.panelBody);
|
|
return backstage.panelBody;
|
|
},
|
|
|
|
showPanel: function() {
|
|
backstage.panel.style.display = "block";
|
|
if(anim && config.options.chkAnimate) {
|
|
backstage.panel.style.top = (-backstage.panel.offsetHeight) + "px";
|
|
var p = [
|
|
{style: "top", start: -backstage.panel.offsetHeight, end: 0, template: "%0px"}
|
|
];
|
|
anim.startAnimating(new Morpher(backstage.panel,config.animDuration,p),new Scroller(backstage.panel,false));
|
|
} else {
|
|
backstage.panel.style.top = "0px";
|
|
}
|
|
return backstage.panelBody;
|
|
},
|
|
|
|
hidePanel: function() {
|
|
backstage.currTabName = null;
|
|
backstage.currTabElem = null;
|
|
if(anim && config.options.chkAnimate) {
|
|
var p = [
|
|
{style: "top", start: 0, end: -(backstage.panel.offsetHeight), template: "%0px"},
|
|
{style: "display", atEnd: "none"}
|
|
];
|
|
var c = function(element,properties) {backstage.cloak.style.display = "none";};
|
|
anim.startAnimating(new Morpher(backstage.panel,config.animDuration,p,c));
|
|
} else {
|
|
backstage.panel.style.display = "none";
|
|
backstage.cloak.style.display = "none";
|
|
}
|
|
}
|
|
};
|
|
|
|
config.macros.backstage = {};
|
|
|
|
config.macros.backstage.handler = function(place,macroName,params,wikifier,paramString,tiddler)
|
|
{
|
|
var backstageTask = config.tasks[params[0]];
|
|
if(backstageTask)
|
|
createTiddlyButton(place,backstageTask.text,backstageTask.tooltip,function(e) {backstage.switchTab(params[0]); return false;});
|
|
};
|
|
|
|
//--
|
|
//-- ImportTiddlers macro
|
|
//--
|
|
|
|
config.macros.importTiddlers.handler = function(place,macroName,params,wikifier,paramString,tiddler)
|
|
{
|
|
if(readOnly) {
|
|
createTiddlyElement(place,"div",null,"marked",this.readOnlyWarning);
|
|
return;
|
|
}
|
|
var w = new Wizard();
|
|
w.createWizard(place,this.wizardTitle);
|
|
this.restart(w);
|
|
};
|
|
|
|
config.macros.importTiddlers.onCancel = function(e)
|
|
{
|
|
var wizard = new Wizard(this);
|
|
var place = wizard.clear();
|
|
config.macros.importTiddlers.restart(wizard);
|
|
return false;
|
|
};
|
|
|
|
config.macros.importTiddlers.restart = function(wizard)
|
|
{
|
|
wizard.addStep(this.step1Title,this.step1Html);
|
|
var s = wizard.getElement("selTypes");
|
|
for(var t in config.adaptors) {
|
|
var e = createTiddlyElement(s,"option",null,null,t);
|
|
e.value = t;
|
|
}
|
|
s = wizard.getElement("selFeeds");
|
|
var feeds = this.getFeeds();
|
|
for(t in feeds) {
|
|
e = createTiddlyElement(s,"option",null,null,t);
|
|
e.value = t;
|
|
}
|
|
wizard.setValue("feeds",feeds);
|
|
s.onchange = config.macros.importTiddlers.onFeedChange;
|
|
var fileInput = wizard.getElement("txtBrowse");
|
|
fileInput.onchange = config.macros.importTiddlers.onBrowseChange;
|
|
fileInput.onkeyup = config.macros.importTiddlers.onBrowseChange;
|
|
wizard.setButtons([{caption: this.openLabel, tooltip: this.openPrompt, onClick: config.macros.importTiddlers.onOpen}]);
|
|
};
|
|
|
|
config.macros.importTiddlers.getFeeds = function()
|
|
{
|
|
var feeds = {};
|
|
var tagged = store.getTaggedTiddlers("systemServer","title");
|
|
for(var t=0; t<tagged.length; t++) {
|
|
var title = tagged[t].title;
|
|
var serverType = store.getTiddlerSlice(title,"Type");
|
|
if(!serverType)
|
|
serverType = "file";
|
|
feeds[title] = {title: title,
|
|
url: store.getTiddlerSlice(title,"URL"),
|
|
workspace: store.getTiddlerSlice(title,"Workspace"),
|
|
workspaceList: store.getTiddlerSlice(title,"WorkspaceList"),
|
|
tiddlerFilter: store.getTiddlerSlice(title,"TiddlerFilter"),
|
|
serverType: serverType,
|
|
description: store.getTiddlerSlice(title,"Description")};
|
|
}
|
|
return feeds;
|
|
};
|
|
|
|
config.macros.importTiddlers.onFeedChange = function(e)
|
|
{
|
|
var wizard = new Wizard(this);
|
|
var selTypes = wizard.getElement("selTypes");
|
|
var fileInput = wizard.getElement("txtPath");
|
|
var feeds = wizard.getValue("feeds");
|
|
var f = feeds[this.value];
|
|
if(f) {
|
|
selTypes.value = f.serverType;
|
|
fileInput.value = f.url;
|
|
this.selectedIndex = 0;
|
|
wizard.setValue("feedName",f.serverType);
|
|
wizard.setValue("feedHost",f.url);
|
|
wizard.setValue("feedWorkspace",f.workspace);
|
|
wizard.setValue("feedWorkspaceList",f.workspaceList);
|
|
wizard.setValue("feedTiddlerFilter",f.tiddlerFilter);
|
|
}
|
|
return false;
|
|
};
|
|
|
|
config.macros.importTiddlers.onBrowseChange = function(e)
|
|
{
|
|
var wizard = new Wizard(this);
|
|
var fileInput = wizard.getElement("txtPath");
|
|
fileInput.value = "file://" + this.value;
|
|
var serverType = wizard.getElement("selTypes");
|
|
serverType.value = "file";
|
|
return false;
|
|
};
|
|
|
|
config.macros.importTiddlers.onOpen = function(e)
|
|
{
|
|
var wizard = new Wizard(this);
|
|
var fileInput = wizard.getElement("txtPath");
|
|
var url = fileInput.value;
|
|
var serverType = wizard.getElement("selTypes").value;
|
|
var adaptor = new config.adaptors[serverType];
|
|
wizard.setValue("adaptor",adaptor);
|
|
wizard.setValue("serverType",serverType);
|
|
wizard.setValue("host",url);
|
|
var context = {};
|
|
var ret = adaptor.openHost(url,context,wizard,config.macros.importTiddlers.onOpenHost);
|
|
if(ret !== true)
|
|
displayMessage(ret);
|
|
wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.statusOpenHost);
|
|
return false;
|
|
};
|
|
|
|
config.macros.importTiddlers.onOpenHost = function(context,wizard)
|
|
{
|
|
var adaptor = wizard.getValue("adaptor");
|
|
if(context.status !== true)
|
|
displayMessage("Error in importTiddlers.onOpenHost: " + context.statusText);
|
|
var ret = adaptor.getWorkspaceList(context,wizard,config.macros.importTiddlers.onGetWorkspaceList);
|
|
if(ret !== true)
|
|
displayMessage(ret);
|
|
wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.statusGetWorkspaceList);
|
|
};
|
|
|
|
config.macros.importTiddlers.onGetWorkspaceList = function(context,wizard)
|
|
{
|
|
if(context.status !== true)
|
|
displayMessage("Error in importTiddlers.onGetWorkspaceList: " + context.statusText);
|
|
wizard.addStep(config.macros.importTiddlers.step2Title,config.macros.importTiddlers.step2Html);
|
|
var s = wizard.getElement("selWorkspace");
|
|
s.onchange = config.macros.importTiddlers.onWorkspaceChange;
|
|
for(var t=0; t<context.workspaces.length; t++) {
|
|
var e = createTiddlyElement(s,"option",null,null,context.workspaces[t].title);
|
|
e.value = context.workspaces[t].title;
|
|
}
|
|
var workspaceList = wizard.getValue("feedWorkspaceList");
|
|
if(workspaceList) {
|
|
var list = workspaceList.parseParams("workspace",null,false,true);
|
|
for(var n=1; n<list.length; n++) {
|
|
if(context.workspaces.findByField("title",list[n].value) == null) {
|
|
e = createTiddlyElement(s,"option",null,null,list[n].value);
|
|
e.value = list[n].value;
|
|
}
|
|
}
|
|
}
|
|
var workspace = wizard.getValue("feedWorkspace");
|
|
if(workspace) {
|
|
t = wizard.getElement("txtWorkspace");
|
|
t.value = workspace;
|
|
}
|
|
wizard.setButtons([{caption: config.macros.importTiddlers.openLabel, tooltip: config.macros.importTiddlers.openPrompt, onClick: config.macros.importTiddlers.onChooseWorkspace}]);
|
|
};
|
|
|
|
config.macros.importTiddlers.onWorkspaceChange = function(e)
|
|
{
|
|
var wizard = new Wizard(this);
|
|
var t = wizard.getElement("txtWorkspace");
|
|
t.value = this.value;
|
|
this.selectedIndex = 0;
|
|
return false;
|
|
};
|
|
|
|
config.macros.importTiddlers.onChooseWorkspace = function(e)
|
|
{
|
|
var wizard = new Wizard(this);
|
|
var adaptor = wizard.getValue("adaptor");
|
|
var workspace = wizard.getElement("txtWorkspace").value;
|
|
wizard.setValue("workspace",workspace);
|
|
var context = {};
|
|
var ret = adaptor.openWorkspace(workspace,context,wizard,config.macros.importTiddlers.onOpenWorkspace);
|
|
if(ret !== true)
|
|
displayMessage(ret);
|
|
wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.statusOpenWorkspace);
|
|
return false;
|
|
};
|
|
|
|
config.macros.importTiddlers.onOpenWorkspace = function(context,wizard)
|
|
{
|
|
if(context.status !== true)
|
|
displayMessage("Error in importTiddlers.onOpenWorkspace: " + context.statusText);
|
|
var adaptor = wizard.getValue("adaptor");
|
|
var ret = adaptor.getTiddlerList(context,wizard,config.macros.importTiddlers.onGetTiddlerList,wizard.getValue("feedTiddlerFilter"));
|
|
if(ret !== true)
|
|
displayMessage(ret);
|
|
wizard.setButtons([{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}],config.macros.importTiddlers.statusGetTiddlerList);
|
|
};
|
|
|
|
config.macros.importTiddlers.onGetTiddlerList = function(context,wizard)
|
|
{
|
|
if(context.status !== true)
|
|
displayMessage("Error in importTiddlers.onGetTiddlerList: " + context.statusText);
|
|
// Extract data for the listview
|
|
var listedTiddlers = [];
|
|
if(context.tiddlers) {
|
|
for(var n=0; n<context.tiddlers.length; n++) {
|
|
var tiddler = context.tiddlers[n];
|
|
listedTiddlers.push({
|
|
title: tiddler.title,
|
|
modified: tiddler.modified,
|
|
modifier: tiddler.modifier,
|
|
text: tiddler.text ? wikifyPlainText(tiddler.text,100) : "",
|
|
tags: tiddler.tags,
|
|
size: tiddler.text ? tiddler.text.length : 0,
|
|
tiddler: tiddler
|
|
});
|
|
}
|
|
}
|
|
listedTiddlers.sort(function(a,b) {return a.title < b.title ? -1 : (a.title == b.title ? 0 : +1);});
|
|
// Display the listview
|
|
wizard.addStep(config.macros.importTiddlers.step3Title,config.macros.importTiddlers.step3Html);
|
|
var markList = wizard.getElement("markList");
|
|
var listWrapper = document.createElement("div");
|
|
markList.parentNode.insertBefore(listWrapper,markList);
|
|
var listView = ListView.create(listWrapper,listedTiddlers,config.macros.importTiddlers.listViewTemplate);
|
|
wizard.setValue("listView",listView);
|
|
var txtSaveTiddler = wizard.getElement("txtSaveTiddler");
|
|
txtSaveTiddler.value = config.macros.importTiddlers.generateSystemServerName(wizard);
|
|
wizard.setButtons([
|
|
{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel},
|
|
{caption: config.macros.importTiddlers.importLabel, tooltip: config.macros.importTiddlers.importPrompt, onClick: config.macros.importTiddlers.doImport}
|
|
]);
|
|
};
|
|
|
|
config.macros.importTiddlers.generateSystemServerName = function(wizard)
|
|
{
|
|
var serverType = wizard.getValue("serverType");
|
|
var host = wizard.getValue("host");
|
|
var workspace = wizard.getValue("workspace");
|
|
var pattern = config.macros.importTiddlers[workspace ? "systemServerNamePattern" : "systemServerNamePatternNoWorkspace"];
|
|
return pattern.format([serverType,host,workspace]);
|
|
};
|
|
|
|
config.macros.importTiddlers.saveServerTiddler = function(wizard)
|
|
{
|
|
var txtSaveTiddler = wizard.getElement("txtSaveTiddler").value;
|
|
if(store.tiddlerExists(txtSaveTiddler)) {
|
|
if(!confirm(config.macros.importTiddlers.confirmOverwriteSaveTiddler.format([txtSaveTiddler])))
|
|
return;
|
|
store.suspendNotifications();
|
|
store.removeTiddler(txtSaveTiddler);
|
|
store.resumeNotifications();
|
|
}
|
|
var serverType = wizard.getValue("serverType");
|
|
var host = wizard.getValue("host");
|
|
var workspace = wizard.getValue("workspace");
|
|
var text = config.macros.importTiddlers.serverSaveTemplate.format([serverType,host,workspace]);
|
|
store.saveTiddler(txtSaveTiddler,txtSaveTiddler,text,config.macros.importTiddlers.serverSaveModifier,new Date(),["systemServer"]);
|
|
};
|
|
|
|
config.macros.importTiddlers.doImport = function(e)
|
|
{
|
|
var wizard = new Wizard(this);
|
|
if(wizard.getElement("chkSave").checked)
|
|
config.macros.importTiddlers.saveServerTiddler(wizard);
|
|
var chkSync = wizard.getElement("chkSync").checked;
|
|
wizard.setValue("sync",chkSync);
|
|
var listView = wizard.getValue("listView");
|
|
var rowNames = ListView.getSelectedRows(listView);
|
|
var adaptor = wizard.getValue("adaptor");
|
|
var overwrite = new Array();
|
|
var t;
|
|
for(t=0; t<rowNames.length; t++) {
|
|
if(store.tiddlerExists(rowNames[t]))
|
|
overwrite.push(rowNames[t]);
|
|
}
|
|
if(overwrite.length > 0) {
|
|
if(!confirm(config.macros.importTiddlers.confirmOverwriteText.format([overwrite.join(", ")])))
|
|
return false;
|
|
}
|
|
wizard.addStep(config.macros.importTiddlers.step4Title.format([rowNames.length]),config.macros.importTiddlers.step4Html);
|
|
for(t=0; t<rowNames.length; t++) {
|
|
var link = document.createElement("div");
|
|
createTiddlyLink(link,rowNames[t],true);
|
|
var place = wizard.getElement("markReport");
|
|
place.parentNode.insertBefore(link,place);
|
|
}
|
|
wizard.setValue("remainingImports",rowNames.length);
|
|
wizard.setButtons([
|
|
{caption: config.macros.importTiddlers.cancelLabel, tooltip: config.macros.importTiddlers.cancelPrompt, onClick: config.macros.importTiddlers.onCancel}
|
|
],config.macros.importTiddlers.statusDoingImport);
|
|
for(t=0; t<rowNames.length; t++) {
|
|
var context = {};
|
|
context.allowSynchronous = true;
|
|
var inbound = adaptor.getTiddler(rowNames[t],context,wizard,config.macros.importTiddlers.onGetTiddler);
|
|
}
|
|
return false;
|
|
};
|
|
|
|
config.macros.importTiddlers.onGetTiddler = function(context,wizard)
|
|
{
|
|
if(!context.status)
|
|
displayMessage("Error in importTiddlers.onGetTiddler: " + context.statusText);
|
|
var tiddler = context.tiddler;
|
|
store.suspendNotifications();
|
|
store.saveTiddler(tiddler.title, tiddler.title, tiddler.text, tiddler.modifier, tiddler.modified, tiddler.tags, tiddler.fields, true, tiddler.created);
|
|
if(!wizard.getValue("sync")) {
|
|
store.setValue(tiddler.title,'server',null);
|
|
}
|
|
store.resumeNotifications();
|
|
if(!context.isSynchronous)
|
|
store.notify(tiddler.title,true);
|
|
var remainingImports = wizard.getValue("remainingImports")-1;
|
|
wizard.setValue("remainingImports",remainingImports);
|
|
if(remainingImports == 0) {
|
|
if(context.isSynchronous) {
|
|
store.notifyAll();
|
|
refreshDisplay();
|
|
}
|
|
wizard.setButtons([
|
|
{caption: config.macros.importTiddlers.doneLabel, tooltip: config.macros.importTiddlers.donePrompt, onClick: config.macros.importTiddlers.onCancel}
|
|
],config.macros.importTiddlers.statusDoneImport);
|
|
autoSaveChanges();
|
|
}
|
|
};
|
|
|
|
//--
|
|
//-- Sync macro
|
|
//--
|
|
|
|
// Synchronisation handlers
|
|
config.syncers = {};
|
|
|
|
// Sync state.
|
|
var currSync = null;
|
|
|
|
// sync macro
|
|
config.macros.sync.handler = function(place,macroName,params,wikifier,paramString,tiddler)
|
|
{
|
|
if(!wikifier.isStatic)
|
|
this.startSync(place);
|
|
};
|
|
|
|
config.macros.sync.startSync = function(place)
|
|
{
|
|
if(currSync)
|
|
config.macros.sync.cancelSync();
|
|
currSync = {};
|
|
currSync.syncList = this.getSyncableTiddlers();
|
|
this.createSyncTasks();
|
|
this.preProcessSyncableTiddlers();
|
|
var wizard = new Wizard();
|
|
currSync.wizard = wizard;
|
|
wizard.createWizard(place,this.wizardTitle);
|
|
wizard.addStep(this.step1Title,this.step1Html);
|
|
var markList = wizard.getElement("markList");
|
|
var listWrapper = document.createElement("div");
|
|
markList.parentNode.insertBefore(listWrapper,markList);
|
|
currSync.listView = ListView.create(listWrapper,currSync.syncList,this.listViewTemplate);
|
|
this.processSyncableTiddlers();
|
|
wizard.setButtons([
|
|
{caption: this.syncLabel, tooltip: this.syncPrompt, onClick: this.doSync}
|
|
]);
|
|
};
|
|
|
|
config.macros.sync.getSyncableTiddlers = function ()
|
|
{
|
|
var list = [];
|
|
store.forEachTiddler(function(title,tiddler) {
|
|
var syncItem = {};
|
|
syncItem.serverType = tiddler.getServerType();
|
|
syncItem.serverHost = tiddler.fields['server.host'];
|
|
syncItem.serverWorkspace = tiddler.fields['server.workspace'];
|
|
syncItem.tiddler = tiddler;
|
|
syncItem.title = tiddler.title;
|
|
syncItem.isTouched = tiddler.isTouched();
|
|
syncItem.selected = syncItem.isTouched;
|
|
syncItem.syncStatus = config.macros.sync.syncStatusList[syncItem.isTouched ? "changedLocally" : "none"];
|
|
syncItem.status = syncItem.syncStatus.text;
|
|
if(syncItem.serverType && syncItem.serverHost)
|
|
list.push(syncItem);
|
|
});
|
|
list.sort(function(a,b) {return a.title < b.title ? -1 : (a.title == b.title ? 0 : +1);});
|
|
return list;
|
|
};
|
|
|
|
config.macros.sync.preProcessSyncableTiddlers = function()
|
|
{
|
|
for(var t=0; t<currSync.syncList.length; t++) {
|
|
si = currSync.syncList[t];
|
|
var ti = si.syncTask.syncMachine.generateTiddlerInfo(si.tiddler);
|
|
si.serverUrl = ti.uri;
|
|
}
|
|
};
|
|
|
|
config.macros.sync.processSyncableTiddlers = function()
|
|
{
|
|
for(var t=0; t<currSync.syncList.length; t++) {
|
|
si = currSync.syncList[t];
|
|
si.rowElement.style.backgroundColor = si.syncStatus.color;
|
|
}
|
|
};
|
|
|
|
config.macros.sync.createSyncTasks = function()
|
|
{
|
|
currSync.syncTasks = [];
|
|
for(var t=0; t<currSync.syncList.length; t++) {
|
|
var si = currSync.syncList[t];
|
|
var r = null;
|
|
for(var st=0; st<currSync.syncTasks.length; st++) {
|
|
var cst = currSync.syncTasks[st];
|
|
if(si.serverType == cst.serverType && si.serverHost == cst.serverHost && si.serverWorkspace == cst.serverWorkspace)
|
|
r = cst;
|
|
}
|
|
if(r == null) {
|
|
si.syncTask = this.createSyncTask(si);
|
|
currSync.syncTasks.push(si.syncTask);
|
|
} else {
|
|
si.syncTask = r;
|
|
r.syncItems.push(si);
|
|
}
|
|
}
|
|
};
|
|
|
|
config.macros.sync.createSyncTask = function(syncItem)
|
|
{
|
|
var st = {};
|
|
st.serverType = syncItem.serverType;
|
|
st.serverHost = syncItem.serverHost;
|
|
st.serverWorkspace = syncItem.serverWorkspace;
|
|
st.syncItems = [syncItem];
|
|
st.syncMachine = new SyncMachine(st.serverType,{
|
|
start: function() {
|
|
return this.openHost(st.serverHost,"openWorkspace");
|
|
},
|
|
openWorkspace: function() {
|
|
return this.openWorkspace(st.serverWorkspace,"getTiddlerList");
|
|
},
|
|
getTiddlerList: function() {
|
|
return this.getTiddlerList("gotTiddlerList");
|
|
},
|
|
gotTiddlerList: function(tiddlers) {
|
|
for(var t=0; t<st.syncItems.length; t++) {
|
|
var si = st.syncItems[t];
|
|
var f = tiddlers.findByField("title",si.title);
|
|
if(f !== null) {
|
|
if(tiddlers[f].fields['server.page.revision'] > si.tiddler.fields['server.page.revision']) {
|
|
si.syncStatus = config.macros.sync.syncStatusList[si.isTouched ? 'changedBoth' : 'changedServer'];
|
|
}
|
|
} else {
|
|
si.syncStatus = config.macros.sync.syncStatusList.notFound;
|
|
}
|
|
config.macros.sync.updateSyncStatus(si);
|
|
}
|
|
},
|
|
getTiddler: function(title) {
|
|
return this.getTiddler(title,"onGetTiddler");
|
|
},
|
|
onGetTiddler: function(tiddler) {
|
|
var syncItem = st.syncItems.findByField("title",tiddler.title);
|
|
if(syncItem !== null) {
|
|
syncItem = st.syncItems[syncItem];
|
|
store.saveTiddler(tiddler.title, tiddler.title, tiddler.text, tiddler.modifier, tiddler.modified, tiddler.tags, tiddler.fields, true, tiddler.created);
|
|
syncItem.syncStatus = config.macros.sync.syncStatusList.gotFromServer;
|
|
config.macros.sync.updateSyncStatus(syncItem);
|
|
}
|
|
},
|
|
putTiddler: function(tiddler) {
|
|
return this.putTiddler(tiddler,"onPutTiddler");
|
|
},
|
|
onPutTiddler: function(tiddler) {
|
|
var syncItem = st.syncItems.findByField("title",tiddler.title);
|
|
if(syncItem !== null) {
|
|
syncItem = st.syncItems[syncItem];
|
|
store.resetTiddler(tiddler.title);
|
|
syncItem.syncStatus = config.macros.sync.syncStatusList.putToServer;
|
|
config.macros.sync.updateSyncStatus(syncItem);
|
|
}
|
|
}
|
|
});
|
|
st.syncMachine.go();
|
|
return st;
|
|
};
|
|
|
|
config.macros.sync.updateSyncStatus = function(syncItem)
|
|
{
|
|
var e = syncItem.colElements["status"];
|
|
removeChildren(e);
|
|
createTiddlyText(e,syncItem.syncStatus.text);
|
|
syncItem.rowElement.style.backgroundColor = syncItem.syncStatus.color;
|
|
};
|
|
|
|
config.macros.sync.doSync = function(e)
|
|
{
|
|
var rowNames = ListView.getSelectedRows(currSync.listView);
|
|
for(var t=0; t<currSync.syncList.length; t++) {
|
|
var si = currSync.syncList[t];
|
|
if(rowNames.indexOf(si.title) != -1) {
|
|
config.macros.sync.doSyncItem(si);
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
|
|
config.macros.sync.doSyncItem = function(syncItem)
|
|
{
|
|
var r = true;
|
|
var sl = config.macros.sync.syncStatusList;
|
|
switch(syncItem.syncStatus) {
|
|
case sl.changedServer:
|
|
r = syncItem.syncTask.syncMachine.go("getTiddler",syncItem.title);
|
|
break;
|
|
case sl.notFound:
|
|
case sl.changedLocally:
|
|
case sl.changedBoth:
|
|
r = syncItem.syncTask.syncMachine.go("putTiddler",syncItem.tiddler);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
if(r !== true)
|
|
displayMessage("Error in doSyncItem: " + r);
|
|
};
|
|
|
|
config.macros.sync.cancelSync = function()
|
|
{
|
|
currSync = null;
|
|
};
|
|
|
|
function SyncMachine(serverType,steps)
|
|
{
|
|
this.serverType = serverType;
|
|
this.adaptor = new config.adaptors[serverType];
|
|
this.steps = steps;
|
|
}
|
|
|
|
SyncMachine.prototype.go = function(step,varargs)
|
|
{
|
|
if(!step)
|
|
step = "start";
|
|
var h = this.steps[step];
|
|
if(!h)
|
|
return null;
|
|
var a = [];
|
|
for(var t=1; t<arguments.length; t++)
|
|
a.push(arguments[t]);
|
|
var r = h.apply(this,a);
|
|
if(typeof r == "string")
|
|
this.invokeError(r);
|
|
return r;
|
|
};
|
|
|
|
SyncMachine.prototype.invokeError = function(message)
|
|
{
|
|
if(this.steps.error)
|
|
this.steps.error(message);
|
|
};
|
|
|
|
SyncMachine.prototype.openHost = function(host,nextStep)
|
|
{
|
|
var me = this;
|
|
return me.adaptor.openHost(host,null,null,function(context) {
|
|
if(typeof context.status == "string")
|
|
me.invokeError(context.status);
|
|
else
|
|
me.go(nextStep);
|
|
});
|
|
};
|
|
|
|
SyncMachine.prototype.getWorkspaceList = function(nextStep)
|
|
{
|
|
var me = this;
|
|
return me.adaptor.getWorkspaceList(null,null,function(context) {
|
|
if(typeof context.status == "string")
|
|
me.invokeError(context.status);
|
|
else
|
|
me.go(nextStep,context.workspaces);
|
|
});
|
|
};
|
|
|
|
SyncMachine.prototype.openWorkspace = function(workspace,nextStep)
|
|
{
|
|
var me = this;
|
|
return me.adaptor.openWorkspace(workspace,null,null,function(context) {
|
|
if(typeof context.status == "string")
|
|
me.invokeError(context.status);
|
|
else
|
|
me.go(nextStep);
|
|
});
|
|
};
|
|
|
|
SyncMachine.prototype.getTiddlerList = function(nextStep)
|
|
{
|
|
var me = this;
|
|
return me.adaptor.getTiddlerList(null,null,function(context) {
|
|
if(typeof context.status == "string")
|
|
me.invokeError(context.status);
|
|
else
|
|
me.go(nextStep,context.tiddlers);
|
|
});
|
|
};
|
|
|
|
SyncMachine.prototype.generateTiddlerInfo = function(tiddler)
|
|
{
|
|
return this.adaptor.generateTiddlerInfo(tiddler);
|
|
};
|
|
|
|
SyncMachine.prototype.getTiddler = function(title,nextStep)
|
|
{
|
|
var me = this;
|
|
return me.adaptor.getTiddler(title,null,null,function(context) {
|
|
if(typeof context.status == "string")
|
|
me.invokeError(context.status);
|
|
else
|
|
me.go(nextStep,context.tiddler);
|
|
});
|
|
};
|
|
|
|
SyncMachine.prototype.putTiddler = function(tiddler,nextStep)
|
|
{
|
|
var me = this;
|
|
return me.adaptor.putTiddler(tiddler,null,null,function(context) {
|
|
if(typeof context.status == "string")
|
|
me.invokeError(context.status);
|
|
else
|
|
me.go(nextStep,tiddler);
|
|
});
|
|
};
|
|
|
|
//--
|
|
//-- Manager UI for groups of tiddlers
|
|
//--
|
|
|
|
config.macros.plugins.handler = function(place,macroName,params,wikifier,paramString,tiddler)
|
|
{
|
|
var wizard = new Wizard();
|
|
wizard.createWizard(place,this.wizardTitle);
|
|
wizard.addStep(this.step1Title,this.step1Html);
|
|
var markList = wizard.getElement("markList");
|
|
var listWrapper = document.createElement("div");
|
|
markList.parentNode.insertBefore(listWrapper,markList);
|
|
listWrapper.setAttribute("refresh","macro");
|
|
listWrapper.setAttribute("macroName","plugins");
|
|
listWrapper.setAttribute("params",paramString);
|
|
this.refresh(listWrapper,paramString);
|
|
};
|
|
|
|
config.macros.plugins.refresh = function(listWrapper,params)
|
|
{
|
|
var wizard = new Wizard(listWrapper);
|
|
var selectedRows = [];
|
|
ListView.forEachSelector(listWrapper,function(e,rowName) {
|
|
if(e.checked)
|
|
selectedRows.push(e.getAttribute("rowName"));
|
|
});
|
|
removeChildren(listWrapper);
|
|
params = params.parseParams("anon");
|
|
var plugins = installedPlugins.slice(0);
|
|
var t,tiddler,p;
|
|
var configTiddlers = store.getTaggedTiddlers("systemConfig");
|
|
for(t=0; t<configTiddlers.length; t++) {
|
|
tiddler = configTiddlers[t];
|
|
if(plugins.findByField("title",tiddler.title) == null) {
|
|
p = getPluginInfo(tiddler);
|
|
p.executed = false;
|
|
p.log.splice(0,0,this.skippedText);
|
|
plugins.push(p);
|
|
}
|
|
}
|
|
for(t=0; t<plugins.length; t++) {
|
|
p = plugins[t];
|
|
p.size = p.tiddler.text ? p.tiddler.text.length : 0;
|
|
p.forced = p.tiddler.isTagged("systemConfigForce");
|
|
p.disabled = p.tiddler.isTagged("systemConfigDisable");
|
|
p.Selected = selectedRows.indexOf(plugins[t].title) != -1;
|
|
}
|
|
if(plugins.length == 0) {
|
|
createTiddlyElement(listWrapper,"em",null,null,this.noPluginText);
|
|
wizard.setButtons([]);
|
|
} else {
|
|
var listView = ListView.create(listWrapper,plugins,this.listViewTemplate,this.onSelectCommand);
|
|
wizard.setValue("listView",listView);
|
|
wizard.setButtons([
|
|
{caption: config.macros.plugins.removeLabel, tooltip: config.macros.plugins.removePrompt, onClick: config.macros.plugins.doRemoveTag},
|
|
{caption: config.macros.plugins.deleteLabel, tooltip: config.macros.plugins.deletePrompt, onClick: config.macros.plugins.doDelete}
|
|
]);
|
|
}
|
|
};
|
|
|
|
config.macros.plugins.doRemoveTag = function(e)
|
|
{
|
|
var wizard = new Wizard(this);
|
|
var listView = wizard.getValue("listView");
|
|
var rowNames = ListView.getSelectedRows(listView);
|
|
if(rowNames.length == 0) {
|
|
alert(config.messages.nothingSelected);
|
|
} else {
|
|
for(var t=0; t<rowNames.length; t++)
|
|
store.setTiddlerTag(rowNames[t],false,"systemConfig");
|
|
}
|
|
};
|
|
|
|
config.macros.plugins.doDelete = function(e)
|
|
{
|
|
var wizard = new Wizard(this);
|
|
var listView = wizard.getValue("listView");
|
|
var rowNames = ListView.getSelectedRows(listView);
|
|
if(rowNames.length == 0) {
|
|
alert(config.messages.nothingSelected);
|
|
} else {
|
|
if(confirm(config.macros.plugins.confirmDeleteText.format([rowNames.join(", ")]))) {
|
|
for(t=0; t<rowNames.length; t++) {
|
|
store.removeTiddler(rowNames[t]);
|
|
story.closeTiddler(rowNames[t],true);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
//--
|
|
//-- Message area
|
|
//--
|
|
|
|
function getMessageDiv()
|
|
{
|
|
var msgArea = document.getElementById("messageArea");
|
|
if(!msgArea)
|
|
return null;
|
|
if(!msgArea.hasChildNodes())
|
|
createTiddlyButton(createTiddlyElement(msgArea,"div",null,"messageToolbar"),
|
|
config.messages.messageClose.text,
|
|
config.messages.messageClose.tooltip,
|
|
clearMessage);
|
|
msgArea.style.display = "block";
|
|
return createTiddlyElement(msgArea,"div");
|
|
}
|
|
|
|
function displayMessage(text,linkText)
|
|
{
|
|
var e = getMessageDiv();
|
|
if(!e) {
|
|
alert(text);
|
|
return;
|
|
}
|
|
if(linkText) {
|
|
var link = createTiddlyElement(e,"a",null,null,text);
|
|
link.href = linkText;
|
|
link.target = "_blank";
|
|
} else {
|
|
e.appendChild(document.createTextNode(text));
|
|
}
|
|
}
|
|
|
|
function clearMessage()
|
|
{
|
|
var msgArea = document.getElementById("messageArea");
|
|
if(msgArea) {
|
|
removeChildren(msgArea);
|
|
msgArea.style.display = "none";
|
|
}
|
|
return false;
|
|
}
|
|
|
|
//--
|
|
//-- Refresh mechanism
|
|
//--
|
|
|
|
config.refreshers = {
|
|
link: function(e,changeList)
|
|
{
|
|
var title = e.getAttribute("tiddlyLink");
|
|
refreshTiddlyLink(e,title);
|
|
return true;
|
|
},
|
|
|
|
tiddler: function(e,changeList)
|
|
{
|
|
var title = e.getAttribute("tiddler");
|
|
var template = e.getAttribute("template");
|
|
if(changeList && changeList.indexOf(title) != -1 && !story.isDirty(title))
|
|
story.refreshTiddler(title,template,true);
|
|
else
|
|
refreshElements(e,changeList);
|
|
return true;
|
|
},
|
|
|
|
content: function(e,changeList)
|
|
{
|
|
var title = e.getAttribute("tiddler");
|
|
var force = e.getAttribute("force");
|
|
if(force != null || changeList == null || changeList.indexOf(title) != -1) {
|
|
removeChildren(e);
|
|
wikify(store.getTiddlerText(title,title),e,null);
|
|
return true;
|
|
} else
|
|
return false;
|
|
},
|
|
|
|
macro: function(e,changeList)
|
|
{
|
|
var macro = e.getAttribute("macroName");
|
|
var params = e.getAttribute("params");
|
|
if(macro)
|
|
macro = config.macros[macro];
|
|
if(macro && macro.refresh)
|
|
macro.refresh(e,params);
|
|
return true;
|
|
}
|
|
};
|
|
|
|
function refreshElements(root,changeList)
|
|
{
|
|
var nodes = root.childNodes;
|
|
for(var c=0; c<nodes.length; c++) {
|
|
var e = nodes[c], type = null;
|
|
if(e.getAttribute && (e.tagName ? e.tagName != "IFRAME" : true))
|
|
type = e.getAttribute("refresh");
|
|
var refresher = config.refreshers[type];
|
|
var refreshed = false;
|
|
if(refresher != undefined)
|
|
refreshed = refresher(e,changeList);
|
|
if(e.hasChildNodes() && !refreshed)
|
|
refreshElements(e,changeList);
|
|
}
|
|
}
|
|
|
|
function applyHtmlMacros(root,tiddler)
|
|
{
|
|
var e = root.firstChild;
|
|
while(e) {
|
|
var nextChild = e.nextSibling;
|
|
if(e.getAttribute) {
|
|
var macro = e.getAttribute("macro");
|
|
if(macro) {
|
|
var params = "";
|
|
var p = macro.indexOf(" ");
|
|
if(p != -1) {
|
|
params = macro.substr(p+1);
|
|
macro = macro.substr(0,p);
|
|
}
|
|
invokeMacro(e,macro,params,null,tiddler);
|
|
}
|
|
}
|
|
if(e.hasChildNodes())
|
|
applyHtmlMacros(e,tiddler);
|
|
e = nextChild;
|
|
}
|
|
}
|
|
|
|
function refreshPageTemplate(title)
|
|
{
|
|
var stash = createTiddlyElement(document.body,"div");
|
|
stash.style.display = "none";
|
|
var display = document.getElementById("tiddlerDisplay");
|
|
var nodes,t;
|
|
if(display) {
|
|
nodes = display.childNodes;
|
|
for(t=nodes.length-1; t>=0; t--)
|
|
stash.appendChild(nodes[t]);
|
|
}
|
|
var wrapper = document.getElementById("contentWrapper");
|
|
if(!title)
|
|
title = "PageTemplate";
|
|
var html = store.getRecursiveTiddlerText(title,null,10);
|
|
wrapper.innerHTML = html;
|
|
applyHtmlMacros(wrapper);
|
|
refreshElements(wrapper);
|
|
display = document.getElementById("tiddlerDisplay");
|
|
removeChildren(display);
|
|
if(!display)
|
|
display = createTiddlyElement(wrapper,"div","tiddlerDisplay");
|
|
nodes = stash.childNodes;
|
|
for(t=nodes.length-1; t>=0; t--)
|
|
display.appendChild(nodes[t]);
|
|
removeNode(stash);
|
|
}
|
|
|
|
function refreshDisplay(hint)
|
|
{
|
|
if(typeof hint == "string")
|
|
hint = [hint];
|
|
var e = document.getElementById("contentWrapper");
|
|
refreshElements(e,hint);
|
|
if(backstage.isPanelVisible()) {
|
|
e = document.getElementById("backstage");
|
|
refreshElements(e,hint);
|
|
}
|
|
}
|
|
|
|
function refreshPageTitle()
|
|
{
|
|
document.title = getPageTitle();
|
|
}
|
|
|
|
function getPageTitle()
|
|
{
|
|
var st = wikifyPlain("SiteTitle");
|
|
var ss = wikifyPlain("SiteSubtitle");
|
|
return st + ((st == "" || ss == "") ? "" : " - ") + ss;
|
|
}
|
|
|
|
function refreshStyles(title,doc)
|
|
{
|
|
if(!doc)
|
|
doc = document;
|
|
setStylesheet(title == null ? "" : store.getRecursiveTiddlerText(title,"",10),title,doc);
|
|
}
|
|
|
|
function refreshColorPalette(title)
|
|
{
|
|
if(!startingUp)
|
|
refreshAll();
|
|
}
|
|
|
|
function refreshAll()
|
|
{
|
|
refreshPageTemplate();
|
|
refreshDisplay();
|
|
refreshStyles("StyleSheetLayout");
|
|
refreshStyles("StyleSheetColors");
|
|
refreshStyles("StyleSheet");
|
|
refreshStyles("StyleSheetPrint");
|
|
}
|
|
|
|
//--
|
|
//-- Options cookie stuff
|
|
//--
|
|
|
|
config.optionHandlers = {
|
|
'txt': {
|
|
get: function(name) {return encodeCookie(config.options[name].toString());},
|
|
set: function(name,value) {config.options[name] = decodeCookie(value);}
|
|
},
|
|
'chk': {
|
|
get: function(name) {return config.options[name] ? "true" : "false";},
|
|
set: function(name,value) {config.options[name] = value == "true";}
|
|
}
|
|
};
|
|
|
|
function loadOptionsCookie()
|
|
{
|
|
if(safeMode)
|
|
return;
|
|
var cookies = document.cookie.split(";");
|
|
for(var c=0; c<cookies.length; c++) {
|
|
var p = cookies[c].indexOf("=");
|
|
if(p != -1) {
|
|
var name = cookies[c].substr(0,p).trim();
|
|
var value = cookies[c].substr(p+1).trim();
|
|
var optType = name.substr(0,3);
|
|
if(config.optionHandlers[optType] && config.optionHandlers[optType].set)
|
|
config.optionHandlers[optType].set(name,value);
|
|
}
|
|
}
|
|
}
|
|
|
|
function saveOptionCookie(name)
|
|
{
|
|
if(safeMode)
|
|
return;
|
|
var c = name + "=";
|
|
var optType = name.substr(0,3);
|
|
if(config.optionHandlers[optType] && config.optionHandlers[optType].get)
|
|
c += config.optionHandlers[optType].get(name);
|
|
c += "; expires=Fri, 1 Jan 2038 12:00:00 UTC; path=/";
|
|
document.cookie = c;
|
|
}
|
|
|
|
function encodeCookie(s)
|
|
{
|
|
return escape(manualConvertUnicodeToUTF8(s));
|
|
}
|
|
|
|
function decodeCookie(s)
|
|
{
|
|
s = unescape(s);
|
|
var re = /&#[0-9]{1,5};/g;
|
|
return s.replace(re,function($0) {return String.fromCharCode(eval($0.replace(/[&#;]/g,"")));});
|
|
}
|
|
|
|
//--
|
|
//-- Saving
|
|
//--
|
|
|
|
var saveUsingSafari = false;
|
|
|
|
var startSaveArea = '<div id="' + 'storeArea">'; // Split up into two so that indexOf() of this source doesn't find it
|
|
var endSaveArea = '</d' + 'iv>';
|
|
|
|
// If there are unsaved changes, force the user to confirm before exitting
|
|
function confirmExit()
|
|
{
|
|
hadConfirmExit = true;
|
|
if((store && store.isDirty && store.isDirty()) || (story && story.areAnyDirty && story.areAnyDirty()))
|
|
return config.messages.confirmExit;
|
|
}
|
|
|
|
// Give the user a chance to save changes before exitting
|
|
function checkUnsavedChanges()
|
|
{
|
|
if(store && store.isDirty && store.isDirty() && window.hadConfirmExit === false) {
|
|
if(confirm(config.messages.unsavedChangesWarning))
|
|
saveChanges();
|
|
}
|
|
}
|
|
|
|
function updateLanguageAttribute(s)
|
|
{
|
|
if(config.locale) {
|
|
var mRE = /(<html(?:.*?)?)(?: xml:lang\="([a-z]+)")?(?: lang\="([a-z]+)")?>/;
|
|
var m = mRE.exec(s);
|
|
if(m) {
|
|
var t = m[1];
|
|
if(m[2])
|
|
t += ' xml:lang="' + config.locale + '"';
|
|
if(m[3])
|
|
t += ' lang="' + config.locale + '"';
|
|
t += ">";
|
|
s = s.substr(0,m.index) + t + s.substr(m.index+m[0].length);
|
|
}
|
|
}
|
|
return s;
|
|
}
|
|
|
|
function updateMarkupBlock(s,blockName,tiddlerName)
|
|
{
|
|
return s.replaceChunk(
|
|
"<!--%0-START-->".format([blockName]),
|
|
"<!--%0-END-->".format([blockName]),
|
|
"\n" + store.getRecursiveTiddlerText(tiddlerName,"") + "\n");
|
|
}
|
|
|
|
function updateOriginal(original,posDiv)
|
|
{
|
|
if(!posDiv)
|
|
posDiv = locateStoreArea(original);
|
|
if(!posDiv) {
|
|
alert(config.messages.invalidFileError.format([localPath]));
|
|
return null;
|
|
}
|
|
var revised = original.substr(0,posDiv[0] + startSaveArea.length) + "\n" +
|
|
convertUnicodeToUTF8(store.allTiddlersAsHtml()) + "\n" +
|
|
original.substr(posDiv[1]);
|
|
var newSiteTitle = convertUnicodeToUTF8(getPageTitle()).htmlEncode();
|
|
revised = revised.replaceChunk("<title"+">","</title"+">"," " + newSiteTitle + " ");
|
|
revised = updateLanguageAttribute(revised);
|
|
revised = updateMarkupBlock(revised,"PRE-HEAD","MarkupPreHead");
|
|
revised = updateMarkupBlock(revised,"POST-HEAD","MarkupPostHead");
|
|
revised = updateMarkupBlock(revised,"PRE-BODY","MarkupPreBody");
|
|
revised = updateMarkupBlock(revised,"POST-SCRIPT","MarkupPostBody");
|
|
return revised;
|
|
}
|
|
|
|
function locateStoreArea(original)
|
|
{
|
|
// Locate the storeArea div's
|
|
var posOpeningDiv = original.indexOf(startSaveArea);
|
|
var limitClosingDiv = original.indexOf("<"+"!--POST-STOREAREA--"+">");
|
|
if(limitClosingDiv == -1)
|
|
limitClosingDiv = original.indexOf("<"+"!--POST-BODY-START--"+">");
|
|
var posClosingDiv = original.lastIndexOf(endSaveArea,limitClosingDiv == -1 ? original.length : limitClosingDiv);
|
|
return (posOpeningDiv != -1 && posClosingDiv != -1) ? [posOpeningDiv,posClosingDiv] : null;
|
|
}
|
|
|
|
function autoSaveChanges(onlyIfDirty,tiddlers)
|
|
{
|
|
if(config.options.chkAutoSave)
|
|
saveChanges(onlyIfDirty,tiddlers);
|
|
}
|
|
|
|
// Save this tiddlywiki with the pending changes
|
|
function saveChanges(onlyIfDirty,tiddlers)
|
|
{
|
|
if(onlyIfDirty && !store.isDirty())
|
|
return;
|
|
clearMessage();
|
|
// Get the URL of the document
|
|
var originalPath = document.location.toString();
|
|
// Check we were loaded from a file URL
|
|
if(originalPath.substr(0,5) != "file:") {
|
|
alert(config.messages.notFileUrlError);
|
|
if(store.tiddlerExists(config.messages.saveInstructions))
|
|
story.displayTiddler(null,config.messages.saveInstructions);
|
|
return;
|
|
}
|
|
var localPath = getLocalPath(originalPath);
|
|
// Load the original file
|
|
var original = loadFile(localPath);
|
|
if(original == null) {
|
|
alert(config.messages.cantSaveError);
|
|
if(store.tiddlerExists(config.messages.saveInstructions))
|
|
story.displayTiddler(null,config.messages.saveInstructions);
|
|
return;
|
|
}
|
|
// Locate the storeArea div's
|
|
var posDiv = locateStoreArea(original);
|
|
if(!posDiv) {
|
|
alert(config.messages.invalidFileError.format([localPath]));
|
|
return;
|
|
}
|
|
saveBackup(localPath,original);
|
|
saveRss(localPath);
|
|
saveEmpty(localPath,original,posDiv);
|
|
saveMain(localPath,original,posDiv);
|
|
}
|
|
|
|
function saveBackup(localPath,original)
|
|
{
|
|
// Save the backup
|
|
if(config.options.chkSaveBackups) {
|
|
var backupPath = getBackupPath(localPath);
|
|
var backup = config.browser.isIE ? ieCopyFile(backupPath,localPath) : saveFile(backupPath,original);
|
|
if(backup)
|
|
displayMessage(config.messages.backupSaved,"file://" + backupPath);
|
|
else
|
|
alert(config.messages.backupFailed);
|
|
}
|
|
}
|
|
|
|
function saveRss(localPath)
|
|
{
|
|
if(config.options.chkGenerateAnRssFeed) {
|
|
var rssPath = localPath.substr(0,localPath.lastIndexOf(".")) + ".xml";
|
|
var rssSave = saveFile(rssPath,convertUnicodeToUTF8(generateRss()));
|
|
if(rssSave)
|
|
displayMessage(config.messages.rssSaved,"file://" + rssPath);
|
|
else
|
|
alert(config.messages.rssFailed);
|
|
}
|
|
}
|
|
|
|
function saveEmpty(localPath,original,posDiv)
|
|
{
|
|
if(config.options.chkSaveEmptyTemplate) {
|
|
var emptyPath,p;
|
|
if((p = localPath.lastIndexOf("/")) != -1)
|
|
emptyPath = localPath.substr(0,p) + "/empty.html";
|
|
else if((p = localPath.lastIndexOf("\\")) != -1)
|
|
emptyPath = localPath.substr(0,p) + "\\empty.html";
|
|
else
|
|
emptyPath = localPath + ".empty.html";
|
|
var empty = original.substr(0,posDiv[0] + startSaveArea.length) + original.substr(posDiv[1]);
|
|
var emptySave = saveFile(emptyPath,empty);
|
|
if(emptySave)
|
|
displayMessage(config.messages.emptySaved,"file://" + emptyPath);
|
|
else
|
|
alert(config.messages.emptyFailed);
|
|
}
|
|
}
|
|
|
|
function saveMain(localPath,original,posDiv)
|
|
{
|
|
var save;
|
|
try {
|
|
var revised = updateOriginal(original,posDiv);
|
|
save = saveFile(localPath,revised);
|
|
} catch (ex) {
|
|
showException(ex);
|
|
}
|
|
if(save) {
|
|
displayMessage(config.messages.mainSaved,"file://" + localPath);
|
|
store.setDirty(false);
|
|
} else {
|
|
alert(config.messages.mainFailed);
|
|
}
|
|
}
|
|
|
|
function getLocalPath(origPath)
|
|
{
|
|
var originalPath = convertUriToUTF8(origPath,config.options.txtFileSystemCharSet);
|
|
// Remove any location or query part of the URL
|
|
var argPos = originalPath.indexOf("?");
|
|
if(argPos != -1)
|
|
originalPath = originalPath.substr(0,argPos);
|
|
var hashPos = originalPath.indexOf("#");
|
|
if(hashPos != -1)
|
|
originalPath = originalPath.substr(0,hashPos);
|
|
// Convert file://localhost/ to file:///
|
|
if(originalPath.indexOf("file://localhost/") == 0)
|
|
originalPath = "file://" + originalPath.substr(16);
|
|
// Convert to a native file format
|
|
var localPath;
|
|
if(originalPath.charAt(9) == ":") // pc local file
|
|
localPath = unescape(originalPath.substr(8)).replace(new RegExp("/","g"),"\\");
|
|
else if(originalPath.indexOf("file://///") == 0) // FireFox pc network file
|
|
localPath = "\\\\" + unescape(originalPath.substr(10)).replace(new RegExp("/","g"),"\\");
|
|
else if(originalPath.indexOf("file:///") == 0) // mac/unix local file
|
|
localPath = unescape(originalPath.substr(7));
|
|
else if(originalPath.indexOf("file:/") == 0) // mac/unix local file
|
|
localPath = unescape(originalPath.substr(5));
|
|
else // pc network file
|
|
localPath = "\\\\" + unescape(originalPath.substr(7)).replace(new RegExp("/","g"),"\\");
|
|
return localPath;
|
|
}
|
|
|
|
function getBackupPath(localPath)
|
|
{
|
|
var backSlash = true;
|
|
var dirPathPos = localPath.lastIndexOf("\\");
|
|
if(dirPathPos == -1) {
|
|
dirPathPos = localPath.lastIndexOf("/");
|
|
backSlash = false;
|
|
}
|
|
var backupFolder = config.options.txtBackupFolder;
|
|
if(!backupFolder || backupFolder == "")
|
|
backupFolder = ".";
|
|
var backupPath = localPath.substr(0,dirPathPos) + (backSlash ? "\\" : "/") + backupFolder + localPath.substr(dirPathPos);
|
|
backupPath = backupPath.substr(0,backupPath.lastIndexOf(".")) + "." + (new Date()).convertToYYYYMMDDHHMMSSMMM() + ".html";
|
|
return backupPath;
|
|
}
|
|
|
|
function generateRss()
|
|
{
|
|
var s = [];
|
|
var d = new Date();
|
|
var u = store.getTiddlerText("SiteUrl");
|
|
// Assemble the header
|
|
s.push("<" + "?xml version=\"1.0\"?" + ">");
|
|
s.push("<rss version=\"2.0\">");
|
|
s.push("<channel>");
|
|
s.push("<title" + ">" + wikifyPlain("SiteTitle").htmlEncode() + "</title" + ">");
|
|
if(u)
|
|
s.push("<link>" + u.htmlEncode() + "</link>");
|
|
s.push("<description>" + wikifyPlain("SiteSubtitle").htmlEncode() + "</description>");
|
|
s.push("<language>en-us</language>");
|
|
s.push("<copyright>Copyright " + d.getFullYear() + " " + config.options.txtUserName.htmlEncode() + "</copyright>");
|
|
s.push("<pubDate>" + d.toGMTString() + "</pubDate>");
|
|
s.push("<lastBuildDate>" + d.toGMTString() + "</lastBuildDate>");
|
|
s.push("<docs>http://blogs.law.harvard.edu/tech/rss</docs>");
|
|
s.push("<generator>TiddlyWiki " + version.major + "." + version.minor + "." + version.revision + "</generator>");
|
|
// The body
|
|
var tiddlers = store.getTiddlers("modified","excludeLists");
|
|
var n = config.numRssItems > tiddlers.length ? 0 : tiddlers.length-config.numRssItems;
|
|
for (var t=tiddlers.length-1; t>=n; t--)
|
|
s.push(tiddlers[t].saveToRss(u));
|
|
// And footer
|
|
s.push("</channel>");
|
|
s.push("</rss>");
|
|
// Save it all
|
|
return s.join("\n");
|
|
}
|
|
|
|
//--
|
|
//-- Filesystem code
|
|
//--
|
|
|
|
function convertUTF8ToUnicode(u)
|
|
{
|
|
if(window.netscape == undefined)
|
|
return manualConvertUTF8ToUnicode(u);
|
|
else
|
|
return mozConvertUTF8ToUnicode(u);
|
|
}
|
|
|
|
function manualConvertUTF8ToUnicode(utf)
|
|
{
|
|
var uni = utf;
|
|
var src = 0;
|
|
var dst = 0;
|
|
var b1, b2, b3;
|
|
var c;
|
|
while(src < utf.length) {
|
|
b1 = utf.charCodeAt(src++);
|
|
if(b1 < 0x80) {
|
|
dst++;
|
|
} else if(b1 < 0xE0) {
|
|
b2 = utf.charCodeAt(src++);
|
|
c = String.fromCharCode(((b1 & 0x1F) << 6) | (b2 & 0x3F));
|
|
uni = uni.substring(0,dst++).concat(c,utf.substr(src));
|
|
} else {
|
|
b2 = utf.charCodeAt(src++);
|
|
b3 = utf.charCodeAt(src++);
|
|
c = String.fromCharCode(((b1 & 0xF) << 12) | ((b2 & 0x3F) << 6) | (b3 & 0x3F));
|
|
uni = uni.substring(0,dst++).concat(c,utf.substr(src));
|
|
}
|
|
}
|
|
return uni;
|
|
}
|
|
|
|
function mozConvertUTF8ToUnicode(u)
|
|
{
|
|
try {
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
|
|
converter.charset = "UTF-8";
|
|
} catch(ex) {
|
|
return manualConvertUTF8ToUnicode(u);
|
|
} // fallback
|
|
var s = converter.ConvertToUnicode(u);
|
|
var fin = converter.Finish();
|
|
return (fin.length > 0) ? s+fin : s;
|
|
}
|
|
|
|
function convertUnicodeToUTF8(s)
|
|
{
|
|
if(window.netscape == undefined)
|
|
return manualConvertUnicodeToUTF8(s);
|
|
else
|
|
return mozConvertUnicodeToUTF8(s);
|
|
}
|
|
|
|
function manualConvertUnicodeToUTF8(s)
|
|
{
|
|
var re = /[^\u0000-\u007F]/g ;
|
|
return s.replace(re,function($0) {return "&#" + $0.charCodeAt(0).toString() + ";";});
|
|
}
|
|
|
|
function mozConvertUnicodeToUTF8(s)
|
|
{
|
|
try {
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
|
|
converter.charset = "UTF-8";
|
|
} catch(ex) {
|
|
return manualConvertUnicodeToUTF8(s);
|
|
} // fallback
|
|
var u = converter.ConvertFromUnicode(s);
|
|
var fin = converter.Finish();
|
|
if(fin.length > 0)
|
|
return u + fin;
|
|
else
|
|
return u;
|
|
}
|
|
|
|
function convertUriToUTF8(uri,charSet)
|
|
{
|
|
if(window.netscape == undefined || charSet == undefined || charSet == "")
|
|
return uri;
|
|
try {
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
var converter = Components.classes["@mozilla.org/intl/utf8converterservice;1"].getService(Components.interfaces.nsIUTF8ConverterService);
|
|
} catch(ex) {
|
|
return uri;
|
|
}
|
|
return converter.convertURISpecToUTF8(uri,charSet);
|
|
}
|
|
|
|
function saveFile(fileUrl,content)
|
|
{
|
|
var r = null;
|
|
if(!r)
|
|
r = mozillaSaveFile(fileUrl,content);
|
|
if(!r)
|
|
r = ieSaveFile(fileUrl,content);
|
|
if(!r)
|
|
r = javaSaveFile(fileUrl,content);
|
|
return r;
|
|
}
|
|
|
|
function loadFile(fileUrl)
|
|
{
|
|
var r = null;
|
|
if((r == null) || (r == false))
|
|
r = mozillaLoadFile(fileUrl);
|
|
if((r == null) || (r == false))
|
|
r = ieLoadFile(fileUrl);
|
|
if((r == null) || (r == false))
|
|
r = javaLoadFile(fileUrl);
|
|
return r;
|
|
}
|
|
|
|
// Returns null if it can't do it, false if there's an error, true if it saved OK
|
|
function ieSaveFile(filePath,content)
|
|
{
|
|
try {
|
|
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
|
} catch(ex) {
|
|
return null;
|
|
}
|
|
var file = fso.OpenTextFile(filePath,2,-1,0);
|
|
file.Write(content);
|
|
file.Close();
|
|
return true;
|
|
}
|
|
|
|
// Returns null if it can't do it, false if there's an error, or a string of the content if successful
|
|
function ieLoadFile(filePath)
|
|
{
|
|
try {
|
|
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
|
var file = fso.OpenTextFile(filePath,1);
|
|
var content = file.ReadAll();
|
|
file.Close();
|
|
} catch(ex) {
|
|
return null;
|
|
}
|
|
return content;
|
|
}
|
|
|
|
function ieCopyFile(dest,source)
|
|
{
|
|
try {
|
|
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
|
fso.GetFile(source).Copy(dest);
|
|
} catch(ex) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
// Returns null if it can't do it, false if there's an error, true if it saved OK
|
|
function mozillaSaveFile(filePath,content)
|
|
{
|
|
if(window.Components) {
|
|
try {
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
|
|
file.initWithPath(filePath);
|
|
if(!file.exists())
|
|
file.create(0,0664);
|
|
var out = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
|
|
out.init(file,0x20|0x02,00004,null);
|
|
out.write(content,content.length);
|
|
out.flush();
|
|
out.close();
|
|
return true;
|
|
} catch(ex) {
|
|
return false;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
// Returns null if it can't do it, false if there's an error, or a string of the content if successful
|
|
function mozillaLoadFile(filePath)
|
|
{
|
|
if(window.Components) {
|
|
try {
|
|
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
|
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
|
|
file.initWithPath(filePath);
|
|
if(!file.exists())
|
|
return null;
|
|
var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream);
|
|
inputStream.init(file,0x01,00004,null);
|
|
var sInputStream = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(Components.interfaces.nsIScriptableInputStream);
|
|
sInputStream.init(inputStream);
|
|
return sInputStream.read(sInputStream.available());
|
|
} catch(ex) {
|
|
return false;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function javaUrlToFilename(url)
|
|
{
|
|
var f = "//localhost";
|
|
if(url.indexOf(f) == 0)
|
|
return url.substring(f.length);
|
|
var i = url.indexOf(":");
|
|
if(i > 0)
|
|
return url.substring(i-1);
|
|
return url;
|
|
}
|
|
|
|
function javaSaveFile(filePath,content)
|
|
{
|
|
try {
|
|
if(document.applets["TiddlySaver"])
|
|
return document.applets["TiddlySaver"].saveFile(javaUrlToFilename(filePath),"UTF-8",content);
|
|
} catch(ex) {
|
|
}
|
|
try {
|
|
var s = new java.io.PrintStream(new java.io.FileOutputStream(javaUrlToFilename(filePath)));
|
|
s.print(content);
|
|
s.close();
|
|
} catch(ex) {
|
|
return null;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
function javaLoadFile(filePath)
|
|
{
|
|
try {
|
|
if(document.applets["TiddlySaver"])
|
|
return String(document.applets["TiddlySaver"].loadFile(javaUrlToFilename(filePath),"UTF-8"));
|
|
} catch(ex) {
|
|
}
|
|
var content = [];
|
|
try {
|
|
var r = new java.io.BufferedReader(new java.io.FileReader(javaUrlToFilename(filePath)));
|
|
var line;
|
|
while((line = r.readLine()) != null)
|
|
content.push(new String(line));
|
|
r.close();
|
|
} catch(ex) {
|
|
return null;
|
|
}
|
|
return content.join("\n");
|
|
}
|
|
|
|
//--
|
|
//-- Server adaptor for talking to static files
|
|
//--
|
|
|
|
function FileAdaptor()
|
|
{
|
|
this.host = null;
|
|
this.store = null;
|
|
return this;
|
|
}
|
|
|
|
FileAdaptor.NotLoadedError = "TiddlyWiki file has not been loaded";
|
|
FileAdaptor.serverType = 'file';
|
|
|
|
// Open the specified host/server
|
|
FileAdaptor.prototype.openHost = function(host,context,userParams,callback)
|
|
{
|
|
this.host = host;
|
|
if(!context)
|
|
context = {};
|
|
context.adaptor = this;
|
|
context.callback = callback;
|
|
context.userParams = userParams;
|
|
var ret = loadRemoteFile(host,FileAdaptor.openHostCallback,context);
|
|
return typeof(ret) == "string" ? ret : true;
|
|
};
|
|
|
|
FileAdaptor.openHostCallback = function(status,context,responseText,url,xhr)
|
|
{
|
|
var adaptor = context.adaptor;
|
|
context.status = status;
|
|
if(!status) {
|
|
context.statusText = "Error reading file: " + xhr.statusText;
|
|
} else {
|
|
// Load the content into a TiddlyWiki() object
|
|
adaptor.store = new TiddlyWiki();
|
|
if(!adaptor.store.importTiddlyWiki(responseText))
|
|
context.statusText = config.messages.invalidFileError.format([url]);
|
|
}
|
|
context.callback(context,context.userParams);
|
|
};
|
|
|
|
// Gets the list of workspaces on a given server
|
|
FileAdaptor.prototype.getWorkspaceList = function(context,userParams,callback)
|
|
{
|
|
if(!context)
|
|
context = {};
|
|
context.workspaces = [{title:"(default)"}];
|
|
context.status = true;
|
|
window.setTimeout(function() {callback(context,userParams);},10);
|
|
return true;
|
|
};
|
|
|
|
// Open the specified workspace
|
|
FileAdaptor.prototype.openWorkspace = function(workspace,context,userParams,callback)
|
|
{
|
|
if(!context)
|
|
context = {};
|
|
context.status = true;
|
|
window.setTimeout(function() {callback(context,userParams);},10);
|
|
return true;
|
|
};
|
|
|
|
// Gets the list of tiddlers within a given workspace
|
|
FileAdaptor.prototype.getTiddlerList = function(context,userParams,callback)
|
|
{
|
|
if(!this.store)
|
|
return FileAdaptor.NotLoadedError;
|
|
if(!context)
|
|
context = {};
|
|
context.tiddlers = [];
|
|
this.store.forEachTiddler(function(title,tiddler)
|
|
{
|
|
var t = new Tiddler(title);
|
|
t.text = tiddler.text;
|
|
t.modified = tiddler.modified;
|
|
t.modifier = tiddler.modifier;
|
|
t.fields['server.page.revision'] = tiddler.modified.convertToYYYYMMDDHHMM();
|
|
t.tags = tiddler.tags;
|
|
context.tiddlers.push(t);
|
|
});
|
|
context.status = true;
|
|
window.setTimeout(function() {callback(context,userParams);},10);
|
|
return true;
|
|
};
|
|
|
|
FileAdaptor.prototype.generateTiddlerInfo = function(tiddler)
|
|
{
|
|
var info = {};
|
|
info.uri = tiddler.fields['server.host'] + "#" + tiddler.title;
|
|
return info;
|
|
};
|
|
|
|
// Retrieves a tiddler from a given workspace on a given server
|
|
FileAdaptor.prototype.getTiddler = function(title,context,userParams,callback)
|
|
{
|
|
if(!this.store)
|
|
return FileAdaptor.NotLoadedError;
|
|
if(!context)
|
|
context = {};
|
|
context.tiddler = this.store.fetchTiddler(title);
|
|
if(context.tiddler) {
|
|
context.tiddler.fields['server.type'] = FileAdaptor.serverType;
|
|
context.tiddler.fields['server.host'] = this.host;
|
|
context.tiddler.fields['server.page.revision'] = context.tiddler.modified.convertToYYYYMMDDHHMM();
|
|
}
|
|
context.status = true;
|
|
if(context.allowSynchronous) {
|
|
context.isSynchronous = true;
|
|
callback(context,userParams);
|
|
} else {
|
|
window.setTimeout(function() {callback(context,userParams);},10);
|
|
}
|
|
return true;
|
|
};
|
|
|
|
FileAdaptor.prototype.close = function()
|
|
{
|
|
delete this.store;
|
|
this.store = null;
|
|
};
|
|
|
|
config.adaptors[FileAdaptor.serverType] = FileAdaptor;
|
|
|
|
//--
|
|
//-- Remote HTTP requests
|
|
//--
|
|
|
|
function loadRemoteFile(url,callback,params)
|
|
{
|
|
return doHttp("GET",url,null,null,null,null,callback,params,null);
|
|
}
|
|
|
|
// HTTP status codes
|
|
var httpStatus = {
|
|
OK: 200,
|
|
ContentCreated: 201,
|
|
NoContent: 204,
|
|
Unauthorized: 401,
|
|
Forbidden: 403,
|
|
NotFound: 404,
|
|
MethodNotAllowed: 405
|
|
};
|
|
|
|
function doHttp(type,url,data,contentType,username,password,callback,params,headers)
|
|
{
|
|
// Get an xhr object
|
|
var x = getXMLHttpRequest();
|
|
if(!x)
|
|
return "Can't create XMLHttpRequest object";
|
|
// Install callback
|
|
x.onreadystatechange = function() {
|
|
if (x.readyState == 4 && callback && (x.status !== undefined)) {
|
|
if([0, httpStatus.OK, httpStatus.ContentCreated, httpStatus.NoContent].contains(x.status))
|
|
callback(true,params,x.responseText,url,x);
|
|
else
|
|
callback(false,params,null,url,x);
|
|
x.onreadystatechange = function(){};
|
|
x = null;
|
|
}
|
|
};
|
|
// Send request
|
|
if(window.Components && window.netscape && window.netscape.security && document.location.protocol.indexOf("http") == -1)
|
|
window.netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
|
|
try {
|
|
url = url + (url.indexOf("?") < 0 ? "?" : "&") + "nocache=" + Math.random();
|
|
x.open(type,url,true,username,password);
|
|
if (data)
|
|
x.setRequestHeader("Content-Type", contentType ? contentType : "application/x-www-form-urlencoded");
|
|
if (x.overrideMimeType)
|
|
x.setRequestHeader("Connection", "close");
|
|
if(headers) {
|
|
for(n in headers)
|
|
x.setRequestHeader(n,headers[n]);
|
|
}
|
|
x.setRequestHeader("X-Requested-With", "TiddlyWiki " + version.major + "." + version.minor + "." + version.revision + (version.beta ? " (beta " + version.beta + ")" : ""));
|
|
x.send(data);
|
|
} catch (ex) {
|
|
return exceptionText(ex);
|
|
}
|
|
return x;
|
|
}
|
|
|
|
function getXMLHttpRequest()
|
|
{
|
|
try {
|
|
var x = new XMLHttpRequest(); // Modern
|
|
} catch(ex) {
|
|
try {
|
|
x = new ActiveXObject("Msxml2.XMLHTTP"); // IE 6
|
|
} catch (ex2) {
|
|
return null;
|
|
}
|
|
}
|
|
return x;
|
|
}
|
|
|
|
//--
|
|
//-- TiddlyWiki-specific utility functions
|
|
//--
|
|
|
|
function createTiddlyButton(theParent,theText,theTooltip,theAction,theClass,theId,theAccessKey)
|
|
{
|
|
var theButton = document.createElement("a");
|
|
if(theAction) {
|
|
theButton.onclick = theAction;
|
|
theButton.setAttribute("href","javascript:;");
|
|
}
|
|
if(theTooltip)
|
|
theButton.setAttribute("title",theTooltip);
|
|
if(theText)
|
|
theButton.appendChild(document.createTextNode(theText));
|
|
if(theClass)
|
|
theButton.className = theClass;
|
|
else
|
|
theButton.className = "button";
|
|
if(theId)
|
|
theButton.id = theId;
|
|
if(theParent)
|
|
theParent.appendChild(theButton);
|
|
if(theAccessKey)
|
|
theButton.setAttribute("accessKey",theAccessKey);
|
|
return theButton;
|
|
}
|
|
|
|
function createTiddlyLink(place,title,includeText,theClass,isStatic,linkedFromTiddler,noToggle)
|
|
{
|
|
var text = includeText ? title : null;
|
|
var i = getTiddlyLinkInfo(title,theClass);
|
|
var btn = isStatic ? createExternalLink(place,store.getTiddlerText("SiteUrl",null) + "#" + title) : createTiddlyButton(place,text,i.subTitle,onClickTiddlerLink,i.classes);
|
|
btn.setAttribute("refresh","link");
|
|
btn.setAttribute("tiddlyLink",title);
|
|
if(noToggle)
|
|
btn.setAttribute("noToggle","true");
|
|
if(linkedFromTiddler) {
|
|
var fields = linkedFromTiddler.getInheritedFields();
|
|
if(fields)
|
|
btn.setAttribute("tiddlyFields",fields);
|
|
}
|
|
return btn;
|
|
}
|
|
|
|
function refreshTiddlyLink(e,title)
|
|
{
|
|
var i = getTiddlyLinkInfo(title,e.className);
|
|
e.className = i.classes;
|
|
e.title = i.subTitle;
|
|
}
|
|
|
|
function getTiddlyLinkInfo(title,currClasses)
|
|
{
|
|
var classes = currClasses ? currClasses.split(" ") : [];
|
|
classes.pushUnique("tiddlyLink");
|
|
var tiddler = store.fetchTiddler(title);
|
|
var subTitle;
|
|
if(tiddler) {
|
|
subTitle = tiddler.getSubtitle();
|
|
classes.pushUnique("tiddlyLinkExisting");
|
|
classes.remove("tiddlyLinkNonExisting");
|
|
classes.remove("shadow");
|
|
} else {
|
|
classes.remove("tiddlyLinkExisting");
|
|
classes.pushUnique("tiddlyLinkNonExisting");
|
|
if(store.isShadowTiddler(title)) {
|
|
subTitle = config.messages.shadowedTiddlerToolTip.format([title]);
|
|
classes.pushUnique("shadow");
|
|
} else {
|
|
subTitle = config.messages.undefinedTiddlerToolTip.format([title]);
|
|
classes.remove("shadow");
|
|
}
|
|
}
|
|
if(config.annotations[title])
|
|
subTitle = config.annotations[title];
|
|
return {classes: classes.join(" "),subTitle: subTitle};
|
|
}
|
|
|
|
function createExternalLink(place,url)
|
|
{
|
|
var theLink = document.createElement("a");
|
|
theLink.className = "externalLink";
|
|
theLink.href = url;
|
|
theLink.title = config.messages.externalLinkTooltip.format([url]);
|
|
if(config.options.chkOpenInNewWindow)
|
|
theLink.target = "_blank";
|
|
place.appendChild(theLink);
|
|
return theLink;
|
|
}
|
|
|
|
// Event handler for clicking on a tiddly link
|
|
function onClickTiddlerLink(e)
|
|
{
|
|
if(!e) e = window.event;
|
|
var theTarget = resolveTarget(e);
|
|
var theLink = theTarget;
|
|
var title = null;
|
|
var fields = null;
|
|
var noToggle = null;
|
|
do {
|
|
title = theLink.getAttribute("tiddlyLink");
|
|
fields = theLink.getAttribute("tiddlyFields");
|
|
noToggle = theLink.getAttribute("noToggle");
|
|
theLink = theLink.parentNode;
|
|
} while(title == null && theLink != null);
|
|
if(!fields && !store.isShadowTiddler(title))
|
|
fields = String.encodeHashMap(config.defaultCustomFields);
|
|
if(title) {
|
|
var toggling = e.metaKey || e.ctrlKey;
|
|
if(config.options.chkToggleLinks)
|
|
toggling = !toggling;
|
|
if(noToggle)
|
|
toggling = false;
|
|
story.displayTiddler(theTarget,title,null,true,null,fields,toggling);
|
|
}
|
|
clearMessage();
|
|
return false;
|
|
}
|
|
|
|
// Create a button for a tag with a popup listing all the tiddlers that it tags
|
|
function createTagButton(place,tag,excludeTiddler)
|
|
{
|
|
var theTag = createTiddlyButton(place,tag,config.views.wikified.tag.tooltip.format([tag]),onClickTag);
|
|
theTag.setAttribute("tag",tag);
|
|
if(excludeTiddler)
|
|
theTag.setAttribute("tiddler",excludeTiddler);
|
|
return theTag;
|
|
}
|
|
|
|
// Event handler for clicking on a tiddler tag
|
|
function onClickTag(e)
|
|
{
|
|
if(!e) var e = window.event;
|
|
var theTarget = resolveTarget(e);
|
|
var popup = Popup.create(this);
|
|
var tag = this.getAttribute("tag");
|
|
var title = this.getAttribute("tiddler");
|
|
if(popup && tag) {
|
|
var tagged = store.getTaggedTiddlers(tag);
|
|
var titles = [];
|
|
var li,r;
|
|
for(r=0;r<tagged.length;r++) {
|
|
if(tagged[r].title != title)
|
|
titles.push(tagged[r].title);
|
|
}
|
|
var lingo = config.views.wikified.tag;
|
|
if(titles.length > 0) {
|
|
var openAll = createTiddlyButton(createTiddlyElement(popup,"li"),lingo.openAllText.format([tag]),lingo.openAllTooltip,onClickTagOpenAll);
|
|
openAll.setAttribute("tag",tag);
|
|
createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div");
|
|
for(r=0; r<titles.length; r++) {
|
|
createTiddlyLink(createTiddlyElement(popup,"li"),titles[r],true);
|
|
}
|
|
} else {
|
|
createTiddlyText(createTiddlyElement(popup,"li",null,"disabled"),lingo.popupNone.format([tag]));
|
|
}
|
|
createTiddlyElement(createTiddlyElement(popup,"li",null,"listBreak"),"div");
|
|
var h = createTiddlyLink(createTiddlyElement(popup,"li"),tag,false);
|
|
createTiddlyText(h,lingo.openTag.format([tag]));
|
|
}
|
|
Popup.show();
|
|
e.cancelBubble = true;
|
|
if(e.stopPropagation) e.stopPropagation();
|
|
return false;
|
|
}
|
|
|
|
// Event handler for 'open all' on a tiddler popup
|
|
function onClickTagOpenAll(e)
|
|
{
|
|
if(!e) var e = window.event;
|
|
var tag = this.getAttribute("tag");
|
|
var tagged = store.getTaggedTiddlers(tag);
|
|
var titles = [];
|
|
for(var t=0; t<tagged.length; t++)
|
|
titles.push(tagged[t].title);
|
|
story.displayTiddlers(this,titles);
|
|
return false;
|
|
}
|
|
|
|
function onClickError(e)
|
|
{
|
|
if(!e) var e = window.event;
|
|
var popup = Popup.create(this);
|
|
var lines = this.getAttribute("errorText").split("\n");
|
|
for(var t=0; t<lines.length; t++)
|
|
createTiddlyElement(popup,"li",null,null,lines[t]);
|
|
Popup.show();
|
|
e.cancelBubble = true;
|
|
if(e.stopPropagation) e.stopPropagation();
|
|
return false;
|
|
}
|
|
|
|
function createTiddlyDropDown(place,onchange,options,defaultValue)
|
|
{
|
|
var sel = createTiddlyElement(place,"select");
|
|
sel.onchange = onchange;
|
|
for(var t=0; t<options.length; t++) {
|
|
var e = createTiddlyElement(sel,"option",null,null,options[t].caption);
|
|
e.value = options[t].name;
|
|
if(options[t].name == defaultValue)
|
|
e.selected = true;
|
|
}
|
|
return sel;
|
|
}
|
|
|
|
function createTiddlyPopup(place,caption,tooltip,tiddler)
|
|
{
|
|
if(tiddler.text) {
|
|
createTiddlyLink(place,caption,true);
|
|
var btn = createTiddlyButton(place,glyph("downArrow"),tooltip,onClickTiddlyPopup,"tiddlerPopupButton");
|
|
btn.tiddler = tiddler;
|
|
} else {
|
|
createTiddlyText(place,caption);
|
|
}
|
|
}
|
|
|
|
function onClickTiddlyPopup(e)
|
|
{
|
|
if(!e) var e = window.event;
|
|
var tiddler = this.tiddler;
|
|
if(tiddler.text) {
|
|
var popup = Popup.create(this,"div","popupTiddler");
|
|
wikify(tiddler.text,popup,null,tiddler);
|
|
Popup.show();
|
|
}
|
|
if(e) e.cancelBubble = true;
|
|
if(e && e.stopPropagation) e.stopPropagation();
|
|
return false;
|
|
}
|
|
|
|
function createTiddlyError(place,title,text)
|
|
{
|
|
var btn = createTiddlyButton(place,title,null,onClickError,"errorButton");
|
|
if(text) btn.setAttribute("errorText",text);
|
|
}
|
|
|
|
function merge(dst,src,preserveExisting)
|
|
{
|
|
for(p in src) {
|
|
if(!preserveExisting || dst[p] === undefined)
|
|
dst[p] = src[p];
|
|
}
|
|
return dst;
|
|
}
|
|
|
|
// Returns a string containing the description of an exception, optionally prepended by a message
|
|
function exceptionText(e,message)
|
|
{
|
|
var s = e.description ? e.description : e.toString();
|
|
return message ? "%0:\n%1".format([message,s]) : s;
|
|
}
|
|
|
|
// Displays an alert of an exception description with optional message
|
|
function showException(e,message)
|
|
{
|
|
alert(exceptionText(e,message));
|
|
}
|
|
|
|
function alertAndThrow(m)
|
|
{
|
|
alert(m);
|
|
throw(m);
|
|
}
|
|
|
|
function glyph(name)
|
|
{
|
|
var g = config.glyphs;
|
|
var b = g.currBrowser;
|
|
if(b == null) {
|
|
b = 0;
|
|
while(!g.browsers[b]() && b < g.browsers.length-1)
|
|
b++;
|
|
g.currBrowser = b;
|
|
}
|
|
if(!g.codes[name])
|
|
return "";
|
|
return g.codes[name][b];
|
|
}
|
|
//-
|
|
//- Animation engine
|
|
//-
|
|
|
|
function Animator()
|
|
{
|
|
this.running = 0; // Incremented at start of each animation, decremented afterwards. If zero, the interval timer is disabled
|
|
this.timerID = 0; // ID of the timer used for animating
|
|
this.animations = []; // List of animations in progress
|
|
return this;
|
|
}
|
|
|
|
// Start animation engine
|
|
Animator.prototype.startAnimating = function() // Variable number of arguments
|
|
{
|
|
for(var t=0; t<arguments.length; t++)
|
|
this.animations.push(arguments[t]);
|
|
if(this.running == 0) {
|
|
var me = this;
|
|
this.timerID = window.setInterval(function() {me.doAnimate(me);},10);
|
|
}
|
|
this.running += arguments.length;
|
|
};
|
|
|
|
// Perform an animation engine tick, calling each of the known animation modules
|
|
Animator.prototype.doAnimate = function(me)
|
|
{
|
|
var a = 0;
|
|
while(a < me.animations.length) {
|
|
var animation = me.animations[a];
|
|
if(animation.tick()) {
|
|
a++;
|
|
} else {
|
|
me.animations.splice(a,1);
|
|
if(--me.running == 0)
|
|
window.clearInterval(me.timerID);
|
|
}
|
|
}
|
|
};
|
|
|
|
// Map a 0..1 value to 0..1, but slow down at the start and end
|
|
Animator.slowInSlowOut = function(progress)
|
|
{
|
|
return(1-((Math.cos(progress * Math.PI)+1)/2));
|
|
};
|
|
|
|
//--
|
|
//-- Morpher animation
|
|
//--
|
|
|
|
// Animate a set of properties of an element
|
|
function Morpher(element,duration,properties,callback)
|
|
{
|
|
this.element = element;
|
|
this.duration = duration;
|
|
this.properties = properties;
|
|
this.startTime = new Date();
|
|
this.endTime = Number(this.startTime) + duration;
|
|
this.callback = callback;
|
|
this.tick();
|
|
return this;
|
|
}
|
|
|
|
Morpher.prototype.assignStyle = function(element,style,value)
|
|
{
|
|
switch(style) {
|
|
case "-tw-vertScroll":
|
|
window.scrollTo(findScrollX(),value);
|
|
break;
|
|
case "-tw-horizScroll":
|
|
window.scrollTo(value,findScrollY());
|
|
break;
|
|
default:
|
|
element.style[style] = value;
|
|
break;
|
|
}
|
|
};
|
|
|
|
Morpher.prototype.stop = function()
|
|
{
|
|
for(var t=0; t<this.properties.length; t++) {
|
|
var p = this.properties[t];
|
|
if(p.atEnd !== undefined) {
|
|
this.assignStyle(this.element,p.style,p.atEnd);
|
|
}
|
|
}
|
|
if(this.callback)
|
|
this.callback(this.element,this.properties);
|
|
};
|
|
|
|
Morpher.prototype.tick = function()
|
|
{
|
|
var currTime = Number(new Date());
|
|
progress = Animator.slowInSlowOut(Math.min(1,(currTime-this.startTime)/this.duration));
|
|
for(var t=0; t<this.properties.length; t++) {
|
|
var p = this.properties[t];
|
|
if(p.start !== undefined && p.end !== undefined) {
|
|
var template = p.template ? p.template : "%0";
|
|
switch(p.format) {
|
|
case undefined:
|
|
case "style":
|
|
var v = p.start + (p.end-p.start) * progress;
|
|
this.assignStyle(this.element,p.style,template.format([v]));
|
|
break;
|
|
case "color":
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if(currTime >= this.endTime) {
|
|
this.stop();
|
|
return false;
|
|
}
|
|
return true;
|
|
};
|
|
|
|
//--
|
|
//-- Zoomer animation
|
|
//--
|
|
|
|
function Zoomer(text,startElement,targetElement,unused)
|
|
{
|
|
var e = createTiddlyElement(document.body,"div",null,"zoomer");
|
|
createTiddlyElement(e,"div",null,null,text);
|
|
var winWidth = findWindowWidth();
|
|
var winHeight = findWindowHeight();
|
|
var p = [
|
|
{style: 'left', start: findPosX(startElement), end: findPosX(targetElement), template: '%0px'},
|
|
{style: 'top', start: findPosY(startElement), end: findPosY(targetElement), template: '%0px'},
|
|
{style: 'width', start: Math.min(startElement.scrollWidth,winWidth), end: Math.min(targetElement.scrollWidth,winWidth), template: '%0px', atEnd: 'auto'},
|
|
{style: 'height', start: Math.min(startElement.scrollHeight,winHeight), end: Math.min(targetElement.scrollHeight,winHeight), template: '%0px', atEnd: 'auto'},
|
|
{style: 'fontSize', start: 8, end: 24, template: '%0pt'}
|
|
];
|
|
var c = function(element,properties) {removeNode(element);};
|
|
return new Morpher(e,config.animDuration,p,c);
|
|
}
|
|
|
|
//--
|
|
//-- Scroller animation
|
|
//--
|
|
|
|
function Scroller(targetElement,unused)
|
|
{
|
|
var p = [
|
|
{style: '-tw-vertScroll', start: findScrollY(), end: ensureVisible(targetElement)}
|
|
];
|
|
return new Morpher(targetElement,config.animDuration,p);
|
|
}
|
|
|
|
//--
|
|
//-- Slider animation
|
|
//--
|
|
|
|
// deleteMode - "none", "all" [delete target element and it's children], [only] "children" [but not the target element]
|
|
function Slider(element,opening,unused,deleteMode)
|
|
{
|
|
element.style.overflow = 'hidden';
|
|
if(opening)
|
|
element.style.height = '0px'; // Resolves a Firefox flashing bug
|
|
element.style.display = 'block';
|
|
var left = findPosX(element);
|
|
var width = element.scrollWidth;
|
|
var height = element.scrollHeight;
|
|
var winWidth = findWindowWidth();
|
|
var p = [];
|
|
var c = null;
|
|
if(opening) {
|
|
p.push({style: 'height', start: 0, end: height, template: '%0px', atEnd: 'auto'});
|
|
p.push({style: 'opacity', start: 0, end: 1, template: '%0'});
|
|
p.push({style: 'filter', start: 0, end: 100, template: 'alpha(opacity:%0)'});
|
|
} else {
|
|
p.push({style: 'height', start: height, end: 0, template: '%0px'});
|
|
p.push({style: 'display', atEnd: 'none'});
|
|
p.push({style: 'opacity', start: 1, end: 0, template: '%0'});
|
|
p.push({style: 'filter', start: 100, end: 0, template: 'alpha(opacity:%0)'});
|
|
switch(deleteMode) {
|
|
case "all":
|
|
c = function(element,properties) {removeNode(element);};
|
|
break;
|
|
case "children":
|
|
c = function(element,properties) {removeChildren(element);};
|
|
break;
|
|
}
|
|
}
|
|
return new Morpher(element,config.animDuration,p,c);
|
|
}
|
|
|
|
//--
|
|
//-- Popup menu
|
|
//--
|
|
|
|
var Popup = {
|
|
stack: [] // Array of objects with members root: and popup:
|
|
};
|
|
|
|
Popup.create = function(root,elem,theClass)
|
|
{
|
|
Popup.remove();
|
|
var popup = createTiddlyElement(document.body,elem ? elem : "ol","popup",theClass ? theClass : "popup");
|
|
Popup.stack.push({root: root, popup: popup});
|
|
return popup;
|
|
};
|
|
|
|
Popup.onDocumentClick = function(e)
|
|
{
|
|
if (!e) var e = window.event;
|
|
var target = resolveTarget(e);
|
|
if(e.eventPhase == undefined)
|
|
Popup.remove();
|
|
else if(e.eventPhase == Event.BUBBLING_PHASE || e.eventPhase == Event.AT_TARGET)
|
|
Popup.remove();
|
|
return true;
|
|
};
|
|
|
|
Popup.show = function(unused1,unused2)
|
|
{
|
|
var curr = Popup.stack[Popup.stack.length-1];
|
|
this.place(curr.root,curr.popup);
|
|
addClass(curr.root,"highlight");
|
|
if(config.options.chkAnimate && anim && typeof Scroller == "function")
|
|
anim.startAnimating(new Scroller(curr.popup));
|
|
else
|
|
window.scrollTo(0,ensureVisible(curr.popup));
|
|
};
|
|
|
|
Popup.place = function(root,popup,offset)
|
|
{
|
|
if(!offset) var offset = {x:0, y:0};
|
|
var rootLeft = findPosX(root);
|
|
var rootTop = findPosY(root);
|
|
var rootHeight = root.offsetHeight;
|
|
var popupLeft = rootLeft + offset.x;
|
|
var popupTop = rootTop + rootHeight + offset.y;
|
|
var winWidth = findWindowWidth();
|
|
if(popup.offsetWidth > winWidth*0.75)
|
|
popup.style.width = winWidth*0.75 + "px";
|
|
var popupWidth = popup.offsetWidth;
|
|
if(popupLeft + popupWidth > winWidth)
|
|
popupLeft = winWidth - popupWidth;
|
|
popup.style.left = popupLeft + "px";
|
|
popup.style.top = popupTop + "px";
|
|
popup.style.display = "block";
|
|
}
|
|
|
|
Popup.remove = function()
|
|
{
|
|
if(Popup.stack.length > 0) {
|
|
Popup.removeFrom(0);
|
|
}
|
|
};
|
|
|
|
Popup.removeFrom = function(from)
|
|
{
|
|
for(var t=Popup.stack.length-1; t>=from; t--) {
|
|
var p = Popup.stack[t];
|
|
removeClass(p.root,"highlight");
|
|
removeNode(p.popup);
|
|
}
|
|
Popup.stack = Popup.stack.slice(0,from);
|
|
};
|
|
|
|
//--
|
|
//-- Wizard support
|
|
//--
|
|
|
|
function Wizard(elem)
|
|
{
|
|
if(elem) {
|
|
this.formElem = findRelated(elem,"wizard","className");
|
|
this.bodyElem = findRelated(this.formElem.firstChild,"wizardBody","className","nextSibling");
|
|
this.footElem = findRelated(this.formElem.firstChild,"wizardFooter","className","nextSibling");
|
|
} else {
|
|
this.formElem = null;
|
|
this.bodyElem = null;
|
|
this.footElem = null;
|
|
}
|
|
}
|
|
|
|
Wizard.prototype.setValue = function(name,value)
|
|
{
|
|
if(this.formElem)
|
|
this.formElem[name] = value;
|
|
};
|
|
|
|
Wizard.prototype.getValue = function(name)
|
|
{
|
|
return this.formElem ? this.formElem[name] : null;
|
|
};
|
|
|
|
Wizard.prototype.createWizard = function(place,title)
|
|
{
|
|
this.formElem = createTiddlyElement(place,"form",null,"wizard");
|
|
createTiddlyElement(this.formElem,"h1",null,null,title);
|
|
this.bodyElem = createTiddlyElement(this.formElem,"div",null,"wizardBody");
|
|
this.footElem = createTiddlyElement(this.formElem,"div",null,"wizardFooter");
|
|
};
|
|
|
|
Wizard.prototype.clear = function()
|
|
{
|
|
removeChildren(this.bodyElem);
|
|
};
|
|
|
|
Wizard.prototype.setButtons = function(buttonInfo,status)
|
|
{
|
|
removeChildren(this.footElem);
|
|
for(var t=0; t<buttonInfo.length; t++) {
|
|
createTiddlyButton(this.footElem,buttonInfo[t].caption,buttonInfo[t].tooltip,buttonInfo[t].onClick);
|
|
insertSpacer(this.footElem);
|
|
}
|
|
if(typeof status == "string") {
|
|
createTiddlyElement(this.footElem,"span",null,"status",status);
|
|
}
|
|
};
|
|
|
|
Wizard.prototype.addStep = function(stepTitle,html)
|
|
{
|
|
removeChildren(this.bodyElem);
|
|
var w = createTiddlyElement(this.bodyElem,"div");
|
|
createTiddlyElement(w,"h2",null,null,stepTitle);
|
|
var step = createTiddlyElement(w,"div",null,"wizardStep");
|
|
step.innerHTML = html;
|
|
applyHtmlMacros(step,tiddler);
|
|
};
|
|
|
|
Wizard.prototype.getElement = function(name)
|
|
{
|
|
return this.formElem.elements[name];
|
|
};
|
|
|
|
//--
|
|
//-- ListView gadget
|
|
//--
|
|
|
|
var ListView = {};
|
|
|
|
// Create a listview
|
|
ListView.create = function(place,listObject,listTemplate,callback,className)
|
|
{
|
|
var table = createTiddlyElement(place,"table",null,className ? className : "listView twtable");
|
|
var thead = createTiddlyElement(table,"thead");
|
|
var r = createTiddlyElement(thead,"tr");
|
|
for(var t=0; t<listTemplate.columns.length; t++) {
|
|
var columnTemplate = listTemplate.columns[t];
|
|
var c = createTiddlyElement(r,"th");
|
|
var colType = ListView.columnTypes[columnTemplate.type];
|
|
if(colType && colType.createHeader)
|
|
colType.createHeader(c,columnTemplate,t);
|
|
}
|
|
var tbody = createTiddlyElement(table,"tbody");
|
|
for(var rc=0; rc<listObject.length; rc++) {
|
|
rowObject = listObject[rc];
|
|
r = createTiddlyElement(tbody,"tr");
|
|
for(c=0; c<listTemplate.rowClasses.length; c++) {
|
|
if(rowObject[listTemplate.rowClasses[c].field])
|
|
addClass(r,listTemplate.rowClasses[c].className);
|
|
}
|
|
rowObject.rowElement = r;
|
|
rowObject.colElements = {};
|
|
for(var cc=0; cc<listTemplate.columns.length; cc++) {
|
|
c = createTiddlyElement(r,"td");
|
|
columnTemplate = listTemplate.columns[cc];
|
|
var field = columnTemplate.field;
|
|
colType = ListView.columnTypes[columnTemplate.type];
|
|
if(colType && colType.createItem)
|
|
colType.createItem(c,rowObject,field,columnTemplate,cc,rc);
|
|
rowObject.colElements[field] = c;
|
|
}
|
|
}
|
|
if(callback && listTemplate.actions)
|
|
createTiddlyDropDown(place,ListView.getCommandHandler(callback),listTemplate.actions);
|
|
if(callback && listTemplate.buttons) {
|
|
for(t=0; t<listTemplate.buttons.length; t++) {
|
|
var a = listTemplate.buttons[t];
|
|
if(a && a.name != "")
|
|
createTiddlyButton(place,a.caption,null,ListView.getCommandHandler(callback,a.name,a.allowEmptySelection));
|
|
}
|
|
}
|
|
return table;
|
|
};
|
|
|
|
ListView.getCommandHandler = function(callback,name,allowEmptySelection)
|
|
{
|
|
return function(e) {
|
|
var view = findRelated(this,"TABLE",null,"previousSibling");
|
|
var tiddlers = [];
|
|
ListView.forEachSelector(view,function(e,rowName) {
|
|
if(e.checked)
|
|
tiddlers.push(rowName);
|
|
});
|
|
if(tiddlers.length == 0 && !allowEmptySelection) {
|
|
alert(config.messages.nothingSelected);
|
|
} else {
|
|
if(this.nodeName.toLowerCase() == "select") {
|
|
callback(view,this.value,tiddlers);
|
|
this.selectedIndex = 0;
|
|
} else {
|
|
callback(view,name,tiddlers);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
// Invoke a callback for each selector checkbox in the listview
|
|
ListView.forEachSelector = function(view,callback)
|
|
{
|
|
var checkboxes = view.getElementsByTagName("input");
|
|
var hadOne = false;
|
|
for(var t=0; t<checkboxes.length; t++) {
|
|
var cb = checkboxes[t];
|
|
if(cb.getAttribute("type") == "checkbox") {
|
|
var rn = cb.getAttribute("rowName");
|
|
if(rn) {
|
|
callback(cb,rn);
|
|
hadOne = true;
|
|
}
|
|
}
|
|
}
|
|
return hadOne;
|
|
};
|
|
|
|
ListView.getSelectedRows = function(view)
|
|
{
|
|
var rowNames = [];
|
|
ListView.forEachSelector(view,function(e,rowName) {
|
|
if(e.checked)
|
|
rowNames.push(rowName);
|
|
});
|
|
return rowNames;
|
|
};
|
|
|
|
ListView.columnTypes = {};
|
|
|
|
ListView.columnTypes.String = {
|
|
createHeader: function(place,columnTemplate,col)
|
|
{
|
|
createTiddlyText(place,columnTemplate.title);
|
|
},
|
|
createItem: function(place,listObject,field,columnTemplate,col,row)
|
|
{
|
|
var v = listObject[field];
|
|
if(v != undefined)
|
|
createTiddlyText(place,v);
|
|
}
|
|
};
|
|
|
|
ListView.columnTypes.WikiText = {
|
|
createHeader: ListView.columnTypes.String.createHeader,
|
|
createItem: function(place,listObject,field,columnTemplate,col,row)
|
|
{
|
|
var v = listObject[field];
|
|
if(v != undefined)
|
|
wikify(v,place,null,null);
|
|
}
|
|
};
|
|
|
|
ListView.columnTypes.Tiddler = {
|
|
createHeader: ListView.columnTypes.String.createHeader,
|
|
createItem: function(place,listObject,field,columnTemplate,col,row)
|
|
{
|
|
var v = listObject[field];
|
|
if(v != undefined && v.title)
|
|
createTiddlyPopup(place,v.title,config.messages.listView.tiddlerTooltip,v);
|
|
}
|
|
};
|
|
|
|
ListView.columnTypes.Size = {
|
|
createHeader: ListView.columnTypes.String.createHeader,
|
|
createItem: function(place,listObject,field,columnTemplate,col,row)
|
|
{
|
|
var v = listObject[field];
|
|
if(v != undefined) {
|
|
var t = 0;
|
|
while(t<config.messages.sizeTemplates.length-1 && v<config.messages.sizeTemplates[t].unit)
|
|
t++;
|
|
createTiddlyText(place,config.messages.sizeTemplates[t].template.format([Math.round(v/config.messages.sizeTemplates[t].unit)]));
|
|
}
|
|
}
|
|
};
|
|
|
|
ListView.columnTypes.Link = {
|
|
createHeader: ListView.columnTypes.String.createHeader,
|
|
createItem: function(place,listObject,field,columnTemplate,col,row)
|
|
{
|
|
var v = listObject[field];
|
|
var c = columnTemplate.text;
|
|
if(v != undefined)
|
|
createTiddlyText(createExternalLink(place,v),c ? c : v);
|
|
}
|
|
};
|
|
|
|
ListView.columnTypes.Date = {
|
|
createHeader: ListView.columnTypes.String.createHeader,
|
|
createItem: function(place,listObject,field,columnTemplate,col,row)
|
|
{
|
|
var v = listObject[field];
|
|
if(v != undefined)
|
|
createTiddlyText(place,v.formatString(columnTemplate.dateFormat));
|
|
}
|
|
};
|
|
|
|
ListView.columnTypes.StringList = {
|
|
createHeader: ListView.columnTypes.String.createHeader,
|
|
createItem: function(place,listObject,field,columnTemplate,col,row)
|
|
{
|
|
var v = listObject[field];
|
|
if(v != undefined) {
|
|
for(var t=0; t<v.length; t++) {
|
|
createTiddlyText(place,v[t]);
|
|
createTiddlyElement(place,"br");
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
ListView.columnTypes.Selector = {
|
|
createHeader: function(place,columnTemplate,col)
|
|
{
|
|
createTiddlyCheckbox(place,null,false,this.onHeaderChange);
|
|
},
|
|
createItem: function(place,listObject,field,columnTemplate,col,row)
|
|
{
|
|
var e = createTiddlyCheckbox(place,null,listObject[field],null);
|
|
e.setAttribute("rowName",listObject[columnTemplate.rowName]);
|
|
},
|
|
onHeaderChange: function(e)
|
|
{
|
|
var state = this.checked;
|
|
var view = findRelated(this,"TABLE");
|
|
if(!view)
|
|
return;
|
|
ListView.forEachSelector(view,function(e,rowName) {
|
|
e.checked = state;
|
|
});
|
|
}
|
|
};
|
|
|
|
ListView.columnTypes.Tags = {
|
|
createHeader: ListView.columnTypes.String.createHeader,
|
|
createItem: function(place,listObject,field,columnTemplate,col,row)
|
|
{
|
|
var tags = listObject[field];
|
|
createTiddlyText(place,String.encodeTiddlyLinkList(tags));
|
|
}
|
|
};
|
|
|
|
ListView.columnTypes.Boolean = {
|
|
createHeader: ListView.columnTypes.String.createHeader,
|
|
createItem: function(place,listObject,field,columnTemplate,col,row)
|
|
{
|
|
if(listObject[field] == true)
|
|
createTiddlyText(place,columnTemplate.trueText);
|
|
if(listObject[field] == false)
|
|
createTiddlyText(place,columnTemplate.falseText);
|
|
}
|
|
};
|
|
|
|
ListView.columnTypes.TagCheckbox = {
|
|
createHeader: ListView.columnTypes.String.createHeader,
|
|
createItem: function(place,listObject,field,columnTemplate,col,row)
|
|
{
|
|
var e = createTiddlyCheckbox(place,null,listObject[field],this.onChange);
|
|
e.setAttribute("tiddler",listObject.title);
|
|
e.setAttribute("tag",columnTemplate.tag);
|
|
},
|
|
onChange : function(e)
|
|
{
|
|
var tag = this.getAttribute("tag");
|
|
var tiddler = this.getAttribute("tiddler");
|
|
store.setTiddlerTag(tiddler,this.checked,tag);
|
|
}
|
|
};
|
|
|
|
ListView.columnTypes.TiddlerLink = {
|
|
createHeader: ListView.columnTypes.String.createHeader,
|
|
createItem: function(place,listObject,field,columnTemplate,col,row)
|
|
{
|
|
var v = listObject[field];
|
|
if(v != undefined) {
|
|
var link = createTiddlyLink(place,listObject[columnTemplate.tiddlerLink],false,null);
|
|
createTiddlyText(link,listObject[field]);
|
|
}
|
|
}
|
|
};
|
|
|
|
//--
|
|
//-- Augmented methods for the JavaScript Number(), Array(), String() and Date() objects
|
|
//--
|
|
|
|
// Clamp a number to a range
|
|
Number.prototype.clamp = function(min,max)
|
|
{
|
|
var c = this;
|
|
if(c < min)
|
|
c = min;
|
|
if(c > max)
|
|
c = max;
|
|
return c;
|
|
};
|
|
|
|
// Add indexOf function if browser does not support it
|
|
if(!Array.indexOf) {
|
|
Array.prototype.indexOf = function(item,from)
|
|
{
|
|
if(!from)
|
|
from = 0;
|
|
for(var i=from; i<this.length; i++) {
|
|
if(this[i] === item)
|
|
return i;
|
|
}
|
|
return -1;
|
|
};}
|
|
|
|
// Find an entry in a given field of the members of an array
|
|
Array.prototype.findByField = function(field,value)
|
|
{
|
|
for(var t=0; t<this.length; t++) {
|
|
if(this[t][field] == value)
|
|
return t;
|
|
}
|
|
return null;
|
|
};
|
|
|
|
// Return whether an entry exists in an array
|
|
Array.prototype.contains = function(item)
|
|
{
|
|
return this.indexOf(item) != -1;
|
|
};
|
|
|
|
// Adds, removes or toggles a particular value within an array
|
|
// value - value to add
|
|
// mode - +1 to add value, -1 to remove value, 0 to toggle it
|
|
Array.prototype.setItem = function(value,mode)
|
|
{
|
|
var p = this.indexOf(value);
|
|
if(mode == 0)
|
|
mode = (p == -1) ? +1 : -1;
|
|
if(mode == +1) {
|
|
if(p == -1)
|
|
this.push(value);
|
|
} else if(mode == -1) {
|
|
if(p != -1)
|
|
this.splice(p,1);
|
|
}
|
|
};
|
|
|
|
// Return whether one of a list of values exists in an array
|
|
Array.prototype.containsAny = function(items)
|
|
{
|
|
for(var i=0; i<items.length; i++) {
|
|
if (this.indexOf(items[i]) != -1)
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
|
|
// Return whether all of a list of values exists in an array
|
|
Array.prototype.containsAll = function(items)
|
|
{
|
|
for (var i = 0; i<items.length; i++) {
|
|
if (this.indexOf(items[i]) == -1)
|
|
return false;
|
|
}
|
|
return true;
|
|
};
|
|
|
|
// Push a new value into an array only if it is not already present in the array. If the optional unique parameter is false, it reverts to a normal push
|
|
Array.prototype.pushUnique = function(item,unique)
|
|
{
|
|
if(unique === false) {
|
|
this.push(item);
|
|
} else {
|
|
if(this.indexOf(item) == -1)
|
|
this.push(item);
|
|
}
|
|
};
|
|
|
|
Array.prototype.remove = function(item)
|
|
{
|
|
var p = this.indexOf(item);
|
|
if(p != -1)
|
|
this.splice(p,1);
|
|
};
|
|
|
|
// Get characters from the right end of a string
|
|
String.prototype.right = function(n)
|
|
{
|
|
return n < this.length ? this.slice(this.length-n) : this;
|
|
};
|
|
|
|
// Trim whitespace from both ends of a string
|
|
String.prototype.trim = function()
|
|
{
|
|
return this.replace(/^\s*|\s*$/g,"");
|
|
};
|
|
|
|
// Convert a string from a CSS style property name to a JavaScript style name ("background-color" -> "backgroundColor")
|
|
String.prototype.unDash = function()
|
|
{
|
|
var s = this.split("-");
|
|
if(s.length > 1) {
|
|
for(var t=1; t<s.length; t++)
|
|
s[t] = s[t].substr(0,1).toUpperCase() + s[t].substr(1);
|
|
}
|
|
return s.join("");
|
|
};
|
|
|
|
// Substitute substrings from an array into a format string that includes '%1'-type specifiers
|
|
String.prototype.format = function(substrings)
|
|
{
|
|
var subRegExp = /(?:%(\d+))/mg;
|
|
var currPos = 0;
|
|
var r = [];
|
|
do {
|
|
var match = subRegExp.exec(this);
|
|
if(match && match[1]) {
|
|
if(match.index > currPos)
|
|
r.push(this.substring(currPos,match.index));
|
|
r.push(substrings[parseInt(match[1])]);
|
|
currPos = subRegExp.lastIndex;
|
|
}
|
|
} while(match);
|
|
if(currPos < this.length)
|
|
r.push(this.substring(currPos,this.length));
|
|
return r.join("");
|
|
};
|
|
|
|
// Escape any special RegExp characters with that character preceded by a backslash
|
|
String.prototype.escapeRegExp = function()
|
|
{
|
|
var s = "\\^$*+?()=!|,{}[].";
|
|
var c = this;
|
|
for(var t=0; t<s.length; t++)
|
|
c = c.replace(new RegExp("\\" + s.substr(t,1),"g"),"\\" + s.substr(t,1));
|
|
return c;
|
|
};
|
|
|
|
// Convert "\" to "\s", newlines to "\n" (and remove carriage returns)
|
|
String.prototype.escapeLineBreaks = function()
|
|
{
|
|
return this.replace(/\\/mg,"\\s").replace(/\n/mg,"\\n").replace(/\r/mg,"");
|
|
};
|
|
|
|
// Convert "\n" to newlines, "\b" to " ", "\s" to "\" (and remove carriage returns)
|
|
String.prototype.unescapeLineBreaks = function()
|
|
{
|
|
return this.replace(/\\n/mg,"\n").replace(/\\b/mg," ").replace(/\\s/mg,"\\").replace(/\r/mg,"");
|
|
};
|
|
|
|
// Convert & to "&", < to "<", > to ">" and " to """
|
|
String.prototype.htmlEncode = function()
|
|
{
|
|
return this.replace(/&/mg,"&").replace(/</mg,"<").replace(/>/mg,">").replace(/\"/mg,""");
|
|
};
|
|
|
|
// Convert "&" to &, "<" to <, ">" to > and """ to "
|
|
String.prototype.htmlDecode = function()
|
|
{
|
|
return this.replace(/</mg,"<").replace(/>/mg,">").replace(/"/mg,"\"").replace(/&/mg,"&");
|
|
};
|
|
|
|
// Convert a string to it's JSON representation by encoding control characters, double quotes and backslash. See json.org
|
|
String.prototype.toJSONString = function()
|
|
{
|
|
var m = {
|
|
'\b': '\\b',
|
|
'\f': '\\f',
|
|
'\n': '\\n',
|
|
'\r': '\\r',
|
|
'\t': '\\t',
|
|
'"' : '\\"',
|
|
'\\': '\\\\'
|
|
};
|
|
var replaceFn = function(a,b) {
|
|
var c = m[b];
|
|
if(c)
|
|
return c;
|
|
c = b.charCodeAt();
|
|
return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
|
|
};
|
|
if(/["\\\x00-\x1f]/.test(this))
|
|
return '"' + this.replace(/([\x00-\x1f\\"])/g,replaceFn) + '"';
|
|
return '"' + this + '"';
|
|
};
|
|
|
|
// Parse a space-separated string of name:value parameters
|
|
// The result is an array of objects:
|
|
// result[0] = object with a member for each parameter name, value of that member being an array of values
|
|
// result[1..n] = one object for each parameter, with 'name' and 'value' members
|
|
String.prototype.parseParams = function(defaultName,defaultValue,allowEval,noNames,cascadeDefaults)
|
|
{
|
|
var parseToken = function(match,p) {
|
|
var n;
|
|
if(match[p]) // Double quoted
|
|
n = match[p];
|
|
else if(match[p+1]) // Single quoted
|
|
n = match[p+1];
|
|
else if(match[p+2]) // Double-square-bracket quoted
|
|
n = match[p+2];
|
|
else if(match[p+3]) // Double-brace quoted
|
|
try {
|
|
n = match[p+3];
|
|
if(allowEval)
|
|
n = window.eval(n);
|
|
} catch(ex) {
|
|
throw "Unable to evaluate {{" + match[p+3] + "}}: " + exceptionText(ex);
|
|
}
|
|
else if(match[p+4]) // Unquoted
|
|
n = match[p+4];
|
|
else if(match[p+5]) // empty quote
|
|
n = "";
|
|
return n;
|
|
};
|
|
var r = [{}];
|
|
var dblQuote = "(?:\"((?:(?:\\\\\")|[^\"])+)\")";
|
|
var sngQuote = "(?:'((?:(?:\\\\\')|[^'])+)')";
|
|
var dblSquare = "(?:\\[\\[((?:\\s|\\S)*?)\\]\\])";
|
|
var dblBrace = "(?:\\{\\{((?:\\s|\\S)*?)\\}\\})";
|
|
var unQuoted = noNames ? "([^\"'\\s]\\S*)" : "([^\"':\\s][^\\s:]*)";
|
|
var emptyQuote = "((?:\"\")|(?:''))";
|
|
var skipSpace = "(?:\\s*)";
|
|
var token = "(?:" + dblQuote + "|" + sngQuote + "|" + dblSquare + "|" + dblBrace + "|" + unQuoted + "|" + emptyQuote + ")";
|
|
var re = noNames ? new RegExp(token,"mg") : new RegExp(skipSpace + token + skipSpace + "(?:(\\:)" + skipSpace + token + ")?","mg");
|
|
var params = [];
|
|
do {
|
|
var match = re.exec(this);
|
|
if(match) {
|
|
var n = parseToken(match,1);
|
|
if(noNames) {
|
|
r.push({name:"",value:n});
|
|
} else {
|
|
var v = parseToken(match,8);
|
|
if(v == null && defaultName) {
|
|
v = n;
|
|
n = defaultName;
|
|
} else if(v == null && defaultValue) {
|
|
v = defaultValue;
|
|
}
|
|
r.push({name:n,value:v});
|
|
if(cascadeDefaults) {
|
|
defaultName = n;
|
|
defaultValue = v;
|
|
}
|
|
}
|
|
}
|
|
} while(match);
|
|
// Summarise parameters into first element
|
|
for(var t=1; t<r.length; t++) {
|
|
if(r[0][r[t].name])
|
|
r[0][r[t].name].push(r[t].value);
|
|
else
|
|
r[0][r[t].name] = [r[t].value];
|
|
}
|
|
return r;
|
|
};
|
|
|
|
// Process a string list of macro parameters into an array. Parameters can be quoted with "", '',
|
|
// [[]], {{ }} or left unquoted (and therefore space-separated). Double-braces {{}} results in
|
|
// an *evaluated* parameter: e.g. {{config.options.txtUserName}} results in the current user's name.
|
|
String.prototype.readMacroParams = function()
|
|
{
|
|
var p = this.parseParams("list",null,true,true);
|
|
var n = [];
|
|
for(var t=1; t<p.length; t++)
|
|
n.push(p[t].value);
|
|
return n;
|
|
};
|
|
|
|
// Process a string list of unique tiddler names into an array. Tiddler names that have spaces in them must be [[bracketed]]
|
|
String.prototype.readBracketedList = function(unique)
|
|
{
|
|
var p = this.parseParams("list",null,false,true);
|
|
var n = [];
|
|
for(var t=1; t<p.length; t++)
|
|
n.pushUnique(p[t].value,unique);
|
|
return n;
|
|
};
|
|
|
|
// Returns array with start and end index of chunk between given start and end marker, or undefined.
|
|
String.prototype.getChunkRange = function(start,end)
|
|
{
|
|
var s = this.indexOf(start);
|
|
if(s != -1) {
|
|
s += start.length;
|
|
var e = this.indexOf(end,s);
|
|
if(e != -1)
|
|
return [s,e];
|
|
}
|
|
};
|
|
|
|
// Replace a chunk of a string given start and end markers
|
|
String.prototype.replaceChunk = function(start,end,sub)
|
|
{
|
|
var r = this.getChunkRange(start,end);
|
|
return r ? this.substring(0,r[0]) + sub + this.substring(r[1]) : this;
|
|
};
|
|
|
|
// Returns a chunk of a string between start and end markers, or undefined
|
|
String.prototype.getChunk = function(start,end)
|
|
{
|
|
var r = this.getChunkRange(start,end);
|
|
if(r)
|
|
return this.substring(r[0],r[1]);
|
|
};
|
|
|
|
|
|
// Static method to bracket a string with double square brackets if it contains a space
|
|
String.encodeTiddlyLink = function(title)
|
|
{
|
|
return title.indexOf(" ") == -1 ? title : "[[" + title + "]]";
|
|
};
|
|
|
|
// Static method to encodeTiddlyLink for every item in an array and join them with spaces
|
|
String.encodeTiddlyLinkList = function(list)
|
|
{
|
|
if(list) {
|
|
var results = [];
|
|
for(var t=0; t<list.length; t++)
|
|
results.push(String.encodeTiddlyLink(list[t]));
|
|
return results.join(" ");
|
|
} else {
|
|
return "";
|
|
}
|
|
};
|
|
|
|
// Convert a string as a sequence of name:"value" pairs into a hashmap
|
|
String.prototype.decodeHashMap = function()
|
|
{
|
|
var fields = this.parseParams("anon","",false);
|
|
var r = {};
|
|
for(var t=1; t<fields.length; t++)
|
|
r[fields[t].name] = fields[t].value;
|
|
return r;
|
|
};
|
|
|
|
// Static method to encode a hashmap into a name:"value"... string
|
|
String.encodeHashMap = function(hashmap)
|
|
{
|
|
var r = [];
|
|
for(var t in hashmap)
|
|
r.push(t + ':"' + hashmap[t] + '"');
|
|
return r.join(" ");
|
|
};
|
|
|
|
// Static method to left-pad a string with 0s to a certain width
|
|
String.zeroPad = function(n,d)
|
|
{
|
|
var s = n.toString();
|
|
if(s.length < d)
|
|
s = "000000000000000000000000000".substr(0,d-s.length) + s;
|
|
return s;
|
|
};
|
|
|
|
String.prototype.startsWith = function(prefix)
|
|
{
|
|
return !prefix || this.substring(0,prefix.length) == prefix;
|
|
};
|
|
|
|
// Returns the first value of the given named parameter.
|
|
function getParam(params,name,defaultValue)
|
|
{
|
|
if(!params)
|
|
return defaultValue;
|
|
var p = params[0][name];
|
|
return p ? p[0] : defaultValue;
|
|
}
|
|
|
|
// Returns the first value of the given boolean named parameter.
|
|
function getFlag(params,name,defaultValue)
|
|
{
|
|
return !!getParam(params,name,defaultValue);
|
|
}
|
|
|
|
// Substitute date components into a string
|
|
Date.prototype.formatString = function(template)
|
|
{
|
|
var t = template.replace(/0hh12/g,String.zeroPad(this.getHours12(),2));
|
|
t = t.replace(/hh12/g,this.getHours12());
|
|
t = t.replace(/0hh/g,String.zeroPad(this.getHours(),2));
|
|
t = t.replace(/hh/g,this.getHours());
|
|
t = t.replace(/mmm/g,config.messages.dates.shortMonths[this.getMonth()]);
|
|
t = t.replace(/0mm/g,String.zeroPad(this.getMinutes(),2));
|
|
t = t.replace(/mm/g,this.getMinutes());
|
|
t = t.replace(/0ss/g,String.zeroPad(this.getSeconds(),2));
|
|
t = t.replace(/ss/g,this.getSeconds());
|
|
t = t.replace(/[ap]m/g,this.getAmPm().toLowerCase());
|
|
t = t.replace(/[AP]M/g,this.getAmPm().toUpperCase());
|
|
t = t.replace(/wYYYY/g,this.getYearForWeekNo());
|
|
t = t.replace(/wYY/g,String.zeroPad(this.getYearForWeekNo()-2000,2));
|
|
t = t.replace(/YYYY/g,this.getFullYear());
|
|
t = t.replace(/YY/g,String.zeroPad(this.getFullYear()-2000,2));
|
|
t = t.replace(/MMM/g,config.messages.dates.months[this.getMonth()]);
|
|
t = t.replace(/0MM/g,String.zeroPad(this.getMonth()+1,2));
|
|
t = t.replace(/MM/g,this.getMonth()+1);
|
|
t = t.replace(/0WW/g,String.zeroPad(this.getWeek(),2));
|
|
t = t.replace(/WW/g,this.getWeek());
|
|
t = t.replace(/DDD/g,config.messages.dates.days[this.getDay()]);
|
|
t = t.replace(/ddd/g,config.messages.dates.shortDays[this.getDay()]);
|
|
t = t.replace(/0DD/g,String.zeroPad(this.getDate(),2));
|
|
t = t.replace(/DDth/g,this.getDate()+this.daySuffix());
|
|
t = t.replace(/DD/g,this.getDate());
|
|
return t;
|
|
};
|
|
|
|
Date.prototype.getWeek = function()
|
|
{
|
|
var dt = new Date(this.getTime());
|
|
var d = dt.getDay();
|
|
if (d==0) d=7;// JavaScript Sun=0, ISO Sun=7
|
|
dt.setTime(dt.getTime()+(4-d)*86400000);// shift day to Thurs of same week to calculate weekNo
|
|
var n = Math.floor((dt.getTime()-new Date(dt.getFullYear(),0,1)+3600000)/86400000);
|
|
return Math.floor(n/7)+1;
|
|
};
|
|
|
|
Date.prototype.getYearForWeekNo = function()
|
|
{
|
|
var dt = new Date(this.getTime());
|
|
var d = dt.getDay();
|
|
if (d==0) d=7;// JavaScript Sun=0, ISO Sun=7
|
|
dt.setTime(dt.getTime()+(4-d)*86400000);// shift day to Thurs of same week
|
|
return dt.getFullYear();
|
|
};
|
|
|
|
Date.prototype.getHours12 = function()
|
|
{
|
|
var h = this.getHours();
|
|
return h > 12 ? h-12 : ( h > 0 ? h : 12 );
|
|
};
|
|
|
|
Date.prototype.getAmPm = function()
|
|
{
|
|
return this.getHours() >= 12 ? config.messages.dates.pm : config.messages.dates.am;
|
|
};
|
|
|
|
Date.prototype.daySuffix = function()
|
|
{
|
|
return config.messages.dates.daySuffixes[this.getDate()-1];
|
|
};
|
|
|
|
// Convert a date to local YYYYMMDDHHMM string format
|
|
Date.prototype.convertToLocalYYYYMMDDHHMM = function()
|
|
{
|
|
return String.zeroPad(this.getFullYear(),4) + String.zeroPad(this.getMonth()+1,2) + String.zeroPad(this.getDate(),2) + String.zeroPad(this.getHours(),2) + String.zeroPad(this.getMinutes(),2);
|
|
};
|
|
|
|
// Convert a date to UTC YYYYMMDDHHMM string format
|
|
Date.prototype.convertToYYYYMMDDHHMM = function()
|
|
{
|
|
return String.zeroPad(this.getUTCFullYear(),4) + String.zeroPad(this.getUTCMonth()+1,2) + String.zeroPad(this.getUTCDate(),2) + String.zeroPad(this.getUTCHours(),2) + String.zeroPad(this.getUTCMinutes(),2);
|
|
};
|
|
|
|
// Convert a date to UTC YYYYMMDD.HHMMSSMMM string format
|
|
Date.prototype.convertToYYYYMMDDHHMMSSMMM = function()
|
|
{
|
|
return String.zeroPad(this.getUTCFullYear(),4) + String.zeroPad(this.getUTCMonth()+1,2) + String.zeroPad(this.getUTCDate(),2) + "." + String.zeroPad(this.getUTCHours(),2) + String.zeroPad(this.getUTCMinutes(),2) + String.zeroPad(this.getUTCSeconds(),2) + String.zeroPad(this.getUTCMilliseconds(),4);
|
|
};
|
|
|
|
// Static method to create a date from a UTC YYYYMMDDHHMM format string
|
|
Date.convertFromYYYYMMDDHHMM = function(d)
|
|
{
|
|
return new Date(Date.UTC(parseInt(d.substr(0,4),10),
|
|
parseInt(d.substr(4,2),10)-1,
|
|
parseInt(d.substr(6,2),10),
|
|
parseInt(d.substr(8,2),10),
|
|
parseInt(d.substr(10,2),10),0,0));
|
|
};
|
|
|
|
//--
|
|
//-- Crypto functions and associated conversion routines
|
|
//--
|
|
|
|
// Crypto "namespace"
|
|
function Crypto() {}
|
|
|
|
// Convert a string to an array of big-endian 32-bit words
|
|
Crypto.strToBe32s = function(str)
|
|
{
|
|
var be = Array();
|
|
var len = Math.floor(str.length/4);
|
|
var i, j;
|
|
for(i=0, j=0; i<len; i++, j+=4) {
|
|
be[i] = ((str.charCodeAt(j)&0xff) << 24)|((str.charCodeAt(j+1)&0xff) << 16)|((str.charCodeAt(j+2)&0xff) << 8)|(str.charCodeAt(j+3)&0xff);
|
|
}
|
|
while (j<str.length) {
|
|
be[j>>2] |= (str.charCodeAt(j)&0xff)<<(24-(j*8)%32);
|
|
j++;
|
|
}
|
|
return be;
|
|
};
|
|
|
|
// Convert an array of big-endian 32-bit words to a string
|
|
Crypto.be32sToStr = function(be)
|
|
{
|
|
var str = "";
|
|
for(var i=0;i<be.length*32;i+=8)
|
|
str += String.fromCharCode((be[i>>5]>>>(24-i%32)) & 0xff);
|
|
return str;
|
|
};
|
|
|
|
// Convert an array of big-endian 32-bit words to a hex string
|
|
Crypto.be32sToHex = function(be)
|
|
{
|
|
var hex = "0123456789ABCDEF";
|
|
var str = "";
|
|
for(var i=0;i<be.length*4;i++)
|
|
str += hex.charAt((be[i>>2]>>((3-i%4)*8+4))&0xF) + hex.charAt((be[i>>2]>>((3-i%4)*8))&0xF);
|
|
return str;
|
|
};
|
|
|
|
// Return, in hex, the SHA-1 hash of a string
|
|
Crypto.hexSha1Str = function(str)
|
|
{
|
|
return Crypto.be32sToHex(Crypto.sha1Str(str));
|
|
};
|
|
|
|
// Return the SHA-1 hash of a string
|
|
Crypto.sha1Str = function(str)
|
|
{
|
|
return Crypto.sha1(Crypto.strToBe32s(str),str.length);
|
|
};
|
|
|
|
// Calculate the SHA-1 hash of an array of blen bytes of big-endian 32-bit words
|
|
Crypto.sha1 = function(x,blen)
|
|
{
|
|
// Add 32-bit integers, wrapping at 32 bits
|
|
add32 = function(a,b)
|
|
{
|
|
var lsw = (a&0xFFFF)+(b&0xFFFF);
|
|
var msw = (a>>16)+(b>>16)+(lsw>>16);
|
|
return (msw<<16)|(lsw&0xFFFF);
|
|
};
|
|
// Add five 32-bit integers, wrapping at 32 bits
|
|
add32x5 = function(a,b,c,d,e)
|
|
{
|
|
var lsw = (a&0xFFFF)+(b&0xFFFF)+(c&0xFFFF)+(d&0xFFFF)+(e&0xFFFF);
|
|
var msw = (a>>16)+(b>>16)+(c>>16)+(d>>16)+(e>>16)+(lsw>>16);
|
|
return (msw<<16)|(lsw&0xFFFF);
|
|
};
|
|
// Bitwise rotate left a 32-bit integer by 1 bit
|
|
rol32 = function(n)
|
|
{
|
|
return (n>>>31)|(n<<1);
|
|
};
|
|
|
|
var len = blen*8;
|
|
// Append padding so length in bits is 448 mod 512
|
|
x[len>>5] |= 0x80 << (24-len%32);
|
|
// Append length
|
|
x[((len+64>>9)<<4)+15] = len;
|
|
var w = Array(80);
|
|
|
|
var k1 = 0x5A827999;
|
|
var k2 = 0x6ED9EBA1;
|
|
var k3 = 0x8F1BBCDC;
|
|
var k4 = 0xCA62C1D6;
|
|
|
|
var h0 = 0x67452301;
|
|
var h1 = 0xEFCDAB89;
|
|
var h2 = 0x98BADCFE;
|
|
var h3 = 0x10325476;
|
|
var h4 = 0xC3D2E1F0;
|
|
|
|
for(var i=0;i<x.length;i+=16) {
|
|
var j,t;
|
|
var a = h0;
|
|
var b = h1;
|
|
var c = h2;
|
|
var d = h3;
|
|
var e = h4;
|
|
for(j = 0;j<16;j++) {
|
|
w[j] = x[i+j];
|
|
t = add32x5(e,(a>>>27)|(a<<5),d^(b&(c^d)),w[j],k1);
|
|
e=d; d=c; c=(b>>>2)|(b<<30); b=a; a = t;
|
|
}
|
|
for(j=16;j<20;j++) {
|
|
w[j] = rol32(w[j-3]^w[j-8]^w[j-14]^w[j-16]);
|
|
t = add32x5(e,(a>>>27)|(a<<5),d^(b&(c^d)),w[j],k1);
|
|
e=d; d=c; c=(b>>>2)|(b<<30); b=a; a = t;
|
|
}
|
|
for(j=20;j<40;j++) {
|
|
w[j] = rol32(w[j-3]^w[j-8]^w[j-14]^w[j-16]);
|
|
t = add32x5(e,(a>>>27)|(a<<5),b^c^d,w[j],k2);
|
|
e=d; d=c; c=(b>>>2)|(b<<30); b=a; a = t;
|
|
}
|
|
for(j=40;j<60;j++) {
|
|
w[j] = rol32(w[j-3]^w[j-8]^w[j-14]^w[j-16]);
|
|
t = add32x5(e,(a>>>27)|(a<<5),(b&c)|(d&(b|c)),w[j],k3);
|
|
e=d; d=c; c=(b>>>2)|(b<<30); b=a; a = t;
|
|
}
|
|
for(j=60;j<80;j++) {
|
|
w[j] = rol32(w[j-3]^w[j-8]^w[j-14]^w[j-16]);
|
|
t = add32x5(e,(a>>>27)|(a<<5),b^c^d,w[j],k4);
|
|
e=d; d=c; c=(b>>>2)|(b<<30); b=a; a = t;
|
|
}
|
|
|
|
h0 = add32(h0,a);
|
|
h1 = add32(h1,b);
|
|
h2 = add32(h2,c);
|
|
h3 = add32(h3,d);
|
|
h4 = add32(h4,e);
|
|
}
|
|
return Array(h0,h1,h2,h3,h4);
|
|
};
|
|
|
|
//--
|
|
//-- RGB colour object
|
|
//--
|
|
|
|
// Construct an RGB colour object from a '#rrggbb', '#rgb' or 'rgb(n,n,n)' string or from separate r,g,b values
|
|
function RGB(r,g,b)
|
|
{
|
|
this.r = 0;
|
|
this.g = 0;
|
|
this.b = 0;
|
|
if(typeof r == "string") {
|
|
if(r.substr(0,1) == "#") {
|
|
if(r.length == 7) {
|
|
this.r = parseInt(r.substr(1,2),16)/255;
|
|
this.g = parseInt(r.substr(3,2),16)/255;
|
|
this.b = parseInt(r.substr(5,2),16)/255;
|
|
} else {
|
|
this.r = parseInt(r.substr(1,1),16)/15;
|
|
this.g = parseInt(r.substr(2,1),16)/15;
|
|
this.b = parseInt(r.substr(3,1),16)/15;
|
|
}
|
|
} else {
|
|
var rgbPattern = /rgb\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/;
|
|
var c = r.match(rgbPattern);
|
|
if(c) {
|
|
this.r = parseInt(c[1],10)/255;
|
|
this.g = parseInt(c[2],10)/255;
|
|
this.b = parseInt(c[3],10)/255;
|
|
}
|
|
}
|
|
} else {
|
|
this.r = r;
|
|
this.g = g;
|
|
this.b = b;
|
|
}
|
|
return this;
|
|
}
|
|
|
|
// Mixes this colour with another in a specified proportion
|
|
// c = other colour to mix
|
|
// f = 0..1 where 0 is this colour and 1 is the new colour
|
|
// Returns an RGB object
|
|
RGB.prototype.mix = function(c,f)
|
|
{
|
|
return new RGB(this.r + (c.r-this.r) * f,this.g + (c.g-this.g) * f,this.b + (c.b-this.b) * f);
|
|
};
|
|
|
|
// Return an rgb colour as a #rrggbb format hex string
|
|
RGB.prototype.toString = function()
|
|
{
|
|
return "#" + ("0" + Math.floor(this.r.clamp(0,1) * 255).toString(16)).right(2) +
|
|
("0" + Math.floor(this.g.clamp(0,1) * 255).toString(16)).right(2) +
|
|
("0" + Math.floor(this.b.clamp(0,1) * 255).toString(16)).right(2);
|
|
};
|
|
|
|
//--
|
|
//-- DOM utilities - many derived from www.quirksmode.org
|
|
//--
|
|
|
|
function drawGradient(place,horiz,colours)
|
|
{
|
|
for(var t=0; t<= 100; t+=2) {
|
|
var bar = document.createElement("div");
|
|
place.appendChild(bar);
|
|
bar.style.position = "absolute";
|
|
bar.style.left = horiz ? t + "%" : 0;
|
|
bar.style.top = horiz ? 0 : t + "%";
|
|
bar.style.width = horiz ? (101-t) + "%" : "100%";
|
|
bar.style.height = horiz ? "100%" : (101-t) + "%";
|
|
bar.style.zIndex = -1;
|
|
var f = t/100;
|
|
var p = f*(colours.length-1);
|
|
bar.style.backgroundColor = colours[Math.floor(p)].mix(colours[Math.ceil(p)],p-Math.floor(p)).toString();
|
|
}
|
|
}
|
|
|
|
function createTiddlyText(theParent,theText)
|
|
{
|
|
return theParent.appendChild(document.createTextNode(theText));
|
|
}
|
|
|
|
function createTiddlyCheckbox(theParent,caption,checked,onChange)
|
|
{
|
|
var cb = document.createElement("input");
|
|
cb.setAttribute("type","checkbox");
|
|
cb.onclick = onChange;
|
|
theParent.appendChild(cb);
|
|
cb.checked = checked;
|
|
cb.className = "chkOptionInput";
|
|
if(caption)
|
|
wikify(caption,theParent);
|
|
return cb;
|
|
}
|
|
|
|
function createTiddlyElement(theParent,theElement,theID,theClass,theText)
|
|
{
|
|
var e = document.createElement(theElement);
|
|
if(theClass != null)
|
|
e.className = theClass;
|
|
if(theID != null)
|
|
e.setAttribute("id",theID);
|
|
if(theText != null)
|
|
e.appendChild(document.createTextNode(theText));
|
|
if(theParent != null)
|
|
theParent.appendChild(e);
|
|
return e;
|
|
}
|
|
|
|
function addEvent(obj,type,fn)
|
|
{
|
|
if(obj.attachEvent) {
|
|
obj['e'+type+fn] = fn;
|
|
obj[type+fn] = function(){obj['e'+type+fn](window.event);};
|
|
obj.attachEvent('on'+type,obj[type+fn]);
|
|
} else {
|
|
obj.addEventListener(type,fn,false);
|
|
}
|
|
}
|
|
|
|
function removeEvent(obj,type,fn)
|
|
{
|
|
if(obj.detachEvent) {
|
|
obj.detachEvent('on'+type,obj[type+fn]);
|
|
obj[type+fn] = null;
|
|
} else {
|
|
obj.removeEventListener(type,fn,false);
|
|
}
|
|
}
|
|
|
|
function addClass(e,theClass)
|
|
{
|
|
var currClass = e.className.split(" ");
|
|
if(currClass.indexOf(theClass) == -1)
|
|
e.className += " " + theClass;
|
|
}
|
|
|
|
function removeClass(e,theClass)
|
|
{
|
|
var currClass = e.className.split(" ");
|
|
var i = currClass.indexOf(theClass);
|
|
while(i != -1) {
|
|
currClass.splice(i,1);
|
|
i = currClass.indexOf(theClass);
|
|
}
|
|
e.className = currClass.join(" ");
|
|
}
|
|
|
|
function hasClass(e,theClass)
|
|
{
|
|
if(e.className) {
|
|
if(e.className.split(" ").indexOf(theClass) != -1)
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// Find the closest relative with a given property value (property defaults to tagName, relative defaults to parentNode)
|
|
function findRelated(e,value,name,relative)
|
|
{
|
|
name = name ? name : "tagName";
|
|
relative = relative ? relative : "parentNode";
|
|
if(name == "className") {
|
|
while(e && !hasClass(e,value)) {
|
|
e = e[relative];
|
|
}
|
|
} else {
|
|
while(e && e[name] != value) {
|
|
e = e[relative];
|
|
}
|
|
}
|
|
return e;
|
|
}
|
|
|
|
// Resolve the target object of an event
|
|
function resolveTarget(e)
|
|
{
|
|
var obj;
|
|
if(e.target)
|
|
obj = e.target;
|
|
else if(e.srcElement)
|
|
obj = e.srcElement;
|
|
if(obj.nodeType == 3) // defeat Safari bug
|
|
obj = obj.parentNode;
|
|
return obj;
|
|
}
|
|
|
|
// Return the content of an element as plain text with no formatting
|
|
function getPlainText(e)
|
|
{
|
|
var text = "";
|
|
if(e.innerText)
|
|
text = e.innerText;
|
|
else if(e.textContent)
|
|
text = e.textContent;
|
|
return text;
|
|
}
|
|
|
|
// Get the scroll position for window.scrollTo necessary to scroll a given element into view
|
|
function ensureVisible(e)
|
|
{
|
|
var posTop = findPosY(e);
|
|
var posBot = posTop + e.offsetHeight;
|
|
var winTop = findScrollY();
|
|
var winHeight = findWindowHeight();
|
|
var winBot = winTop + winHeight;
|
|
if(posTop < winTop) {
|
|
return posTop;
|
|
} else if(posBot > winBot) {
|
|
if(e.offsetHeight < winHeight)
|
|
return posTop - (winHeight - e.offsetHeight);
|
|
else
|
|
return posTop;
|
|
} else {
|
|
return winTop;
|
|
}
|
|
}
|
|
|
|
// Get the current width of the display window
|
|
function findWindowWidth()
|
|
{
|
|
return window.innerWidth ? window.innerWidth : document.documentElement.clientWidth;
|
|
}
|
|
|
|
// Get the current height of the display window
|
|
function findWindowHeight()
|
|
{
|
|
return window.innerHeight ? window.innerHeight : document.documentElement.clientHeight;
|
|
}
|
|
|
|
// Get the current horizontal page scroll position
|
|
function findScrollX()
|
|
{
|
|
return window.scrollX ? window.scrollX : document.documentElement.scrollLeft;
|
|
}
|
|
|
|
// Get the current vertical page scroll position
|
|
function findScrollY()
|
|
{
|
|
return window.scrollY ? window.scrollY : document.documentElement.scrollTop;
|
|
}
|
|
|
|
function findPosX(obj)
|
|
{
|
|
var curleft = 0;
|
|
while(obj.offsetParent) {
|
|
curleft += obj.offsetLeft;
|
|
obj = obj.offsetParent;
|
|
}
|
|
return curleft;
|
|
}
|
|
|
|
function findPosY(obj)
|
|
{
|
|
var curtop = 0;
|
|
while(obj.offsetParent) {
|
|
curtop += obj.offsetTop;
|
|
obj = obj.offsetParent;
|
|
}
|
|
return curtop;
|
|
}
|
|
|
|
// Blur a particular element
|
|
function blurElement(e)
|
|
{
|
|
if(e != null && e.focus && e.blur) {
|
|
e.focus();
|
|
e.blur();
|
|
}
|
|
}
|
|
|
|
// Create a non-breaking space
|
|
function insertSpacer(place)
|
|
{
|
|
var e = document.createTextNode(String.fromCharCode(160));
|
|
if(place)
|
|
place.appendChild(e);
|
|
return e;
|
|
}
|
|
|
|
// Remove all children of a node
|
|
function removeChildren(e)
|
|
{
|
|
while(e && e.hasChildNodes())
|
|
removeNode(e.firstChild);
|
|
}
|
|
|
|
// Remove a node and all it's children
|
|
function removeNode(e)
|
|
{
|
|
scrubNode(e);
|
|
e.parentNode.removeChild(e);
|
|
}
|
|
|
|
// Remove any event handlers or non-primitve custom attributes
|
|
function scrubNode(e)
|
|
{
|
|
var att = e.attributes;
|
|
if(att) {
|
|
for(var t=0; t<att.length; t++) {
|
|
var n = att[t].name;
|
|
if(n !== 'style' && (typeof e[n] === 'function' || (typeof e[n] === 'object' && e[n] != null))) {
|
|
try {
|
|
e[n] = null;
|
|
} catch(ex) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var c = e.firstChild;
|
|
while(c) {
|
|
scrubNode(c);
|
|
c = c.nextSibling;
|
|
}
|
|
}
|
|
|
|
// Add a stylesheet, replacing any previous custom stylesheet
|
|
function setStylesheet(s,id,doc)
|
|
{
|
|
if(!id)
|
|
id = "customStyleSheet";
|
|
if(!doc)
|
|
doc = document;
|
|
var n = doc.getElementById(id);
|
|
if(doc.createStyleSheet) {
|
|
// Test for IE's non-standard createStyleSheet method
|
|
if(n)
|
|
n.parentNode.removeChild(n);
|
|
// This failed without the
|
|
doc.getElementsByTagName("head")[0].insertAdjacentHTML("beforeEnd"," <style id='" + id + "'>" + s + "</style>");
|
|
} else {
|
|
if(n) {
|
|
n.replaceChild(doc.createTextNode(s),n.firstChild);
|
|
} else {
|
|
n = doc.createElement("style");
|
|
n.type = "text/css";
|
|
n.id = id;
|
|
n.appendChild(doc.createTextNode(s));
|
|
doc.getElementsByTagName("head")[0].appendChild(n);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Force the browser to do a document reflow when needed to workaround browser bugs
|
|
function forceReflow()
|
|
{
|
|
if(config.browser.isGecko) {
|
|
setStylesheet("body {top:-1em;margin-top:1em;}");
|
|
setStylesheet("");
|
|
}
|
|
}
|
|
|
|
// Replace the current selection of a textarea or text input and scroll it into view
|
|
function replaceSelection(e,text)
|
|
{
|
|
if(e.setSelectionRange) {
|
|
var oldpos = e.selectionStart;
|
|
var isRange = e.selectionEnd > e.selectionStart;
|
|
e.value = e.value.substr(0,e.selectionStart) + text + e.value.substr(e.selectionEnd);
|
|
e.setSelectionRange(isRange ? oldpos : oldpos + text.length,oldpos + text.length);
|
|
var linecount = e.value.split('\n').length;
|
|
var thisline = e.value.substr(0,e.selectionStart).split('\n').length-1;
|
|
e.scrollTop = Math.floor((thisline - e.rows / 2) * e.scrollHeight / linecount);
|
|
} else if(document.selection) {
|
|
var range = document.selection.createRange();
|
|
if(range.parentElement() == e) {
|
|
var isCollapsed = range.text == "";
|
|
range.text = text;
|
|
if(!isCollapsed) {
|
|
range.moveStart('character', -text.length);
|
|
range.select();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Returns the text of the given (text) node, possibly merging subsequent text nodes
|
|
function getNodeText(e)
|
|
{
|
|
var t = "";
|
|
while(e && e.nodeName == "#text") {
|
|
t += e.nodeValue;
|
|
e = e.nextSibling;
|
|
}
|
|
return t;
|
|
}
|
|
|
|
//--
|
|
//-- LoaderBase and SaverBase
|
|
//--
|
|
|
|
function LoaderBase() {}
|
|
|
|
LoaderBase.prototype.loadTiddler = function(store,node,tiddlers)
|
|
{
|
|
var title = this.getTitle(store,node);
|
|
if(title) {
|
|
var tiddler = store.createTiddler(title);
|
|
this.internalizeTiddler(store,tiddler,title,node);
|
|
tiddlers.push(tiddler);
|
|
}
|
|
};
|
|
|
|
LoaderBase.prototype.loadTiddlers = function(store,nodes)
|
|
{
|
|
var tiddlers = [];
|
|
for(var t = 0; t < nodes.length; t++) {
|
|
try {
|
|
this.loadTiddler(store,nodes[t],tiddlers);
|
|
} catch(ex) {
|
|
showException(ex,config.messages.tiddlerLoadError.format([this.getTitle(store,nodes[t])]));
|
|
}
|
|
}
|
|
return tiddlers;
|
|
};
|
|
|
|
function SaverBase() {}
|
|
|
|
SaverBase.prototype.externalize = function(store)
|
|
{
|
|
var results = [];
|
|
var tiddlers = store.getTiddlers("title");
|
|
for(var t = 0; t < tiddlers.length; t++)
|
|
results.push(this.externalizeTiddler(store,tiddlers[t]));
|
|
return results.join("\n");
|
|
};
|
|
|
|
//--
|
|
//-- TW21Loader (inherits from LoaderBase)
|
|
//--
|
|
|
|
function TW21Loader() {}
|
|
|
|
TW21Loader.prototype = new LoaderBase();
|
|
|
|
TW21Loader.prototype.getTitle = function(store,node)
|
|
{
|
|
var title = null;
|
|
if(node.getAttribute) {
|
|
title = node.getAttribute("title");
|
|
if(!title)
|
|
title = node.getAttribute("tiddler");
|
|
}
|
|
if(!title && node.id) {
|
|
var lenPrefix = store.idPrefix.length;
|
|
if (node.id.substr(0,lenPrefix) == store.idPrefix)
|
|
title = node.id.substr(lenPrefix);
|
|
}
|
|
return title;
|
|
};
|
|
|
|
TW21Loader.prototype.internalizeTiddler = function(store,tiddler,title,node)
|
|
{
|
|
var e = node.firstChild;
|
|
var text = null;
|
|
if(node.getAttribute("tiddler")) {
|
|
text = getNodeText(e).unescapeLineBreaks();
|
|
} else {
|
|
while(e.nodeName!="PRE" && e.nodeName!="pre") {
|
|
e = e.nextSibling;
|
|
}
|
|
text = e.innerHTML.replace(/\r/mg,"").htmlDecode();
|
|
}
|
|
var modifier = node.getAttribute("modifier");
|
|
var c = node.getAttribute("created");
|
|
var m = node.getAttribute("modified");
|
|
var created = c ? Date.convertFromYYYYMMDDHHMM(c) : version.date;
|
|
var modified = m ? Date.convertFromYYYYMMDDHHMM(m) : created;
|
|
var tags = node.getAttribute("tags");
|
|
var fields = {};
|
|
var attrs = node.attributes;
|
|
for(var i = attrs.length-1; i >= 0; i--) {
|
|
var name = attrs[i].name;
|
|
if (attrs[i].specified && !TiddlyWiki.isStandardField(name)) {
|
|
fields[name] = attrs[i].value.unescapeLineBreaks();
|
|
}
|
|
}
|
|
tiddler.assign(title,text,modifier,modified,tags,created,fields);
|
|
return tiddler;
|
|
};
|
|
|
|
//--
|
|
//-- TW21Saver (inherits from SaverBase)
|
|
//--
|
|
|
|
function TW21Saver() {}
|
|
|
|
TW21Saver.prototype = new SaverBase();
|
|
|
|
TW21Saver.prototype.externalizeTiddler = function(store,tiddler)
|
|
{
|
|
try {
|
|
var extendedAttributes = "";
|
|
var usePre = config.options.chkUsePreForStorage;
|
|
store.forEachField(tiddler,
|
|
function(tiddler,fieldName,value) {
|
|
// don't store stuff from the temp namespace
|
|
if(typeof value != "string")
|
|
value = "";
|
|
if (!fieldName.match(/^temp\./))
|
|
extendedAttributes += ' %0="%1"'.format([fieldName,value.escapeLineBreaks().htmlEncode()]);
|
|
},true);
|
|
var created = tiddler.created.convertToYYYYMMDDHHMM();
|
|
var modified = tiddler.modified.convertToYYYYMMDDHHMM();
|
|
var vdate = version.date.convertToYYYYMMDDHHMM();
|
|
var attributes = tiddler.modifier ? ' modifier="' + tiddler.modifier.htmlEncode() + '"' : "";
|
|
attributes += (usePre && modified == created) ? "" : ' modified="' + modified +'"';
|
|
attributes += (usePre && created == vdate) ? "" :' created="' + created + '"';
|
|
var tags = tiddler.getTags();
|
|
if(!usePre || tags)
|
|
attributes += ' tags="' + tags.htmlEncode() + '"';
|
|
return ('<div %0="%1"%2%3>%4</'+'div>').format([
|
|
usePre ? "title" : "tiddler",
|
|
tiddler.title.htmlEncode(),
|
|
attributes,
|
|
extendedAttributes,
|
|
usePre ? "\n<pre>" + tiddler.text.htmlEncode() + "</pre>\n" : tiddler.text.escapeLineBreaks().htmlEncode()
|
|
]);
|
|
} catch (ex) {
|
|
throw exceptionText(ex,config.messages.tiddlerSaveError.format([tiddler.title]));
|
|
}
|
|
};
|
|
|
|
//--
|
|
//-- Deprecated code
|
|
//--
|
|
|
|
// @Deprecated: Use createElementAndWikify and this.termRegExp instead
|
|
config.formatterHelpers.charFormatHelper = function(w)
|
|
{
|
|
w.subWikify(createTiddlyElement(w.output,this.element),this.terminator);
|
|
};
|
|
|
|
// @Deprecated: Use enclosedTextHelper and this.lookaheadRegExp instead
|
|
config.formatterHelpers.monospacedByLineHelper = function(w)
|
|
{
|
|
var lookaheadRegExp = new RegExp(this.lookahead,"mg");
|
|
lookaheadRegExp.lastIndex = w.matchStart;
|
|
var lookaheadMatch = lookaheadRegExp.exec(w.source);
|
|
if(lookaheadMatch && lookaheadMatch.index == w.matchStart) {
|
|
var text = lookaheadMatch[1];
|
|
if(config.browser.isIE)
|
|
text = text.replace(/\n/g,"\r");
|
|
createTiddlyElement(w.output,"pre",null,null,text);
|
|
w.nextMatch = lookaheadRegExp.lastIndex;
|
|
}
|
|
};
|
|
|
|
// @Deprecated: Use <br> or <br /> instead of <<br>>
|
|
config.macros.br.handler = function(place)
|
|
{
|
|
createTiddlyElement(place,"br");
|
|
};
|
|
|
|
// Find an entry in an array. Returns the array index or null
|
|
// @Deprecated: Use indexOf instead
|
|
Array.prototype.find = function(item)
|
|
{
|
|
var i = this.indexOf(item);
|
|
return i == -1 ? null : i;
|
|
};
|
|
|
|
// Load a tiddler from an HTML DIV. The caller should make sure to later call Tiddler.changed()
|
|
// @Deprecated: Use store.getLoader().internalizeTiddler instead
|
|
Tiddler.prototype.loadFromDiv = function(divRef,title)
|
|
{
|
|
return store.getLoader().internalizeTiddler(store,this,title,divRef);
|
|
};
|
|
|
|
// Format the text for storage in an HTML DIV
|
|
// @Deprecated Use store.getSaver().externalizeTiddler instead.
|
|
Tiddler.prototype.saveToDiv = function()
|
|
{
|
|
return store.getSaver().externalizeTiddler(store,this);
|
|
};
|
|
|
|
// @Deprecated: Use store.allTiddlersAsHtml() instead
|
|
function allTiddlersAsHtml()
|
|
{
|
|
return store.allTiddlersAsHtml();
|
|
}
|
|
|
|
// @Deprecated: Use refreshPageTemplate instead
|
|
function applyPageTemplate(title)
|
|
{
|
|
refreshPageTemplate(title);
|
|
}
|
|
|
|
// @Deprecated: Use story.displayTiddlers instead
|
|
function displayTiddlers(srcElement,titles,template,unused1,unused2,animate,unused3)
|
|
{
|
|
story.displayTiddlers(srcElement,titles,template,animate);
|
|
}
|
|
|
|
// @Deprecated: Use story.displayTiddler instead
|
|
function displayTiddler(srcElement,title,template,unused1,unused2,animate,unused3)
|
|
{
|
|
story.displayTiddler(srcElement,title,template,animate);
|
|
}
|
|
|
|
// @Deprecated: Use functions on right hand side directly instead
|
|
var createTiddlerPopup = Popup.create;
|
|
var scrollToTiddlerPopup = Popup.show;
|
|
var hideTiddlerPopup = Popup.remove;
|
|
|
|
// @Deprecated: Use right hand side directly instead
|
|
var regexpBackSlashEn = new RegExp("\\\\n","mg");
|
|
var regexpBackSlash = new RegExp("\\\\","mg");
|
|
var regexpBackSlashEss = new RegExp("\\\\s","mg");
|
|
var regexpNewLine = new RegExp("\n","mg");
|
|
var regexpCarriageReturn = new RegExp("\r","mg");
|
|
//--
|
|
//-- End of scripts
|
|
//--
|
|
//]]>
|
|
</script>
|
|
<script type="text/javascript">
|
|
//<![CDATA[
|
|
if(useJavaSaver)
|
|
document.write("<applet style='position:absolute;left:-1px' name='TiddlySaver' code='TiddlySaver.class' archive='TiddlySaver.jar' width='1' height='1'></applet>");
|
|
//]]>
|
|
</script>
|
|
<!--POST-SCRIPT-START-->
|
|
|
|
<!--POST-SCRIPT-END-->
|
|
</body>
|
|
</html>
|