diff --git a/bld.sh b/bld.sh index d9fcdb814..1cedaa1d0 100755 --- a/bld.sh +++ b/bld.sh @@ -12,7 +12,6 @@ node ../../tiddlywiki.js \ --verbose \ --password password \ --savetiddler ReadMe ../../readme.md text/html \ - --newsavetiddler $:/core/templates/new.tiddlywiki5.template.html ../../../jermolene.github.com/new.index.html text/plain \ --savetiddler $:/core/templates/tiddlywiki5.template.html ../../../jermolene.github.com/index.html text/plain \ --savetiddler $:/core/templates/tiddlywiki5.encrypted.template.html ../../../jermolene.github.com/encrypted.html text/plain \ --savetiddler $:/core/templates/static.template.html ../../../jermolene.github.com/static.html text/plain \ diff --git a/core/modules/commands/newsavetiddler.js b/core/modules/commands/newsavetiddler.js deleted file mode 100644 index 003a51a18..000000000 --- a/core/modules/commands/newsavetiddler.js +++ /dev/null @@ -1,44 +0,0 @@ -/*\ -title: $:/core/modules/commands/newsavetiddler.js -type: application/javascript -module-type: command - -Command to save a tiddler to a file - -\*/ -(function(){ - -/*jslint node: true, browser: true */ -/*global $tw: false */ -"use strict"; - -exports.info = { - name: "newsavetiddler", - synchronous: false -}; - -var Command = function(params,commander,callback) { - this.params = params; - this.commander = commander; - this.callback = callback; -}; - -Command.prototype.execute = function() { - if(this.params.length < 2) { - return "Missing filename"; - } - var self = this, - fs = require("fs"), - path = require("path"), - title = this.params[0], - filename = this.params[1], - type = this.params[2] || "text/html"; - fs.writeFile(filename,this.commander.wiki.new_renderTiddler(type,title),"utf8",function(err) { - self.callback(err); - }); - return null; -}; - -exports.Command = Command; - -})(); diff --git a/core/modules/commands/savetiddler.js b/core/modules/commands/savetiddler.js index 7912d0ac6..d58b71b4a 100644 --- a/core/modules/commands/savetiddler.js +++ b/core/modules/commands/savetiddler.js @@ -32,14 +32,8 @@ Command.prototype.execute = function() { path = require("path"), title = this.params[0], filename = this.params[1], - type = this.params[2] || "text/html", - options = {}, - t; - for(t=3; t> - -<> - -<< -<> ->> -}}} - - -\*/ -(function(){ - -/*jslint node: true, browser: true */ -/*global $tw: false */ -"use strict"; - -exports.info = { - name: "checkbox", - params: { - tiddler: {byName: true, type: "tiddler"}, - tag: {byPos: 0, type: "text"}, - "class": {byName: true, type: "text"} - } -}; - -exports.getValue = function() { - var tiddler = this.wiki.getTiddler(this.targetTitle); - return tiddler ? tiddler.hasTag(this.params.tag) : false; -}; - -exports.executeMacro = function() { - // Get the title of the target tiddler - if(this.hasParameter("tiddler")) { - this.targetTitle = this.params.tiddler; - } else { - this.targetTitle = this.tiddlerTitle; - } - // Checkbox attributes - var checkboxAttributes = { - type: "checkbox" - }; - if(this.getValue()) { - checkboxAttributes.checked = "true"; - } - // Label attributes - var labelAttributes = { - "class": [] - }; - if(this.hasParameter("class")) { - $tw.utils.pushTop(labelAttributes["class"],this.params["class"].split(" ")); - } - if(this.classes) { - $tw.utils.pushTop(labelAttributes["class"],this.classes); - } - // Execute content - for(var t=0; t;base64," - var dataURL = this.macroNode.child.domNode.toDataURL(tiddler.fields.type,1.0), - posColon = dataURL.indexOf(":"), - posSemiColon = dataURL.indexOf(";"), - posComma = dataURL.indexOf(","), - type = dataURL.substring(posColon+1,posSemiColon), - text = dataURL.substring(posComma+1); - var update = {type: type, text: text}; - this.macroNode.wiki.addTiddler(new $tw.Tiddler(tiddler,update)); - } -}; - -exports["image/jpg"] = BitmapEditor; -exports["image/jpeg"] = BitmapEditor; -exports["image/png"] = BitmapEditor; -exports["image/gif"] = BitmapEditor; - -})(); diff --git a/core/modules/macros/edit/editors/texteditor.js b/core/modules/macros/edit/editors/texteditor.js deleted file mode 100644 index 5166c684d..000000000 --- a/core/modules/macros/edit/editors/texteditor.js +++ /dev/null @@ -1,151 +0,0 @@ -/*\ -title: $:/core/modules/macros/edit/editors/texteditor.js -type: application/javascript -module-type: editor - -An editor module for editting text - -\*/ -(function(){ - -/*jslint node: true, browser: true */ -/*global $tw: false */ -"use strict"; - -var MIN_TEXT_AREA_HEIGHT = 100; - -function TextEditor(macroNode) { - this.macroNode = macroNode; -} - -/* -Get the tiddler being editted, field name and current value -*/ -TextEditor.prototype.getEditText = function() { - // Get the current tiddler and the field name - var tiddler = this.macroNode.wiki.getTiddler(this.macroNode.editTiddler), - value; - // If we've got a tiddler, the value to display is the field string value - if(tiddler) { - value = tiddler.getFieldString(this.macroNode.editField); - } else { - // Otherwise, we need to construct a default value for the editor - if(this.macroNode.hasParameter("default")) { - value = this.macroNode.params["default"]; - } else { - switch(this.macroNode.editField) { - case "text": - value = "Type the text for the tiddler '" + this.macroNode.editTiddler + "'"; - break; - case "title": - value = this.macroNode.editTiddler; - break; - default: - value = ""; - break; - } - } - } - return {tiddler: tiddler, field: this.macroNode.editField, value: value}; -}; - -TextEditor.prototype.getChild = function() { - var edit = this.getEditText(); - var attributes = { - "class": ["tw-edit-field"] - }, - tagName, - content = []; - if(this.macroNode.classes) { - $tw.utils.pushTop(attributes["class"],this.macroNode.classes); - } - // Figure out what element to use for this editor - var type = this.macroNode.params.type; - if(type === undefined) { - type = edit.field === "text" ? "textarea" : "input"; - } - switch(type) { - case "textarea": - tagName = "textarea"; - content.push($tw.Tree.Text(edit.value)); - break; - case "search": - tagName = "input"; - attributes.type = "search"; - attributes.value = edit.value; - break; - default: // "input" - tagName = "input"; - attributes.type = "text"; - attributes.value = edit.value; - break; - } - // Wrap the editor control in a div - return $tw.Tree.Element(this.macroNode.isBlock ? "div" : "span",{},[$tw.Tree.Element(tagName,attributes,content,{ - events: ["focus","blur","keyup"], - eventHandler: this - })]); -}; - -TextEditor.prototype.handleEvent = function(event) { - // Get the value of the field if it might have changed - if("keyup focus blur".split(" ").indexOf(event.type) !== -1) { - this.saveChanges(); - } - // Fix the height of the textarea if required - if("keyup focus".split(" ").indexOf(event.type) !== -1) { - var self = this; - window.setTimeout(function() { - self.fixHeight(); - },5); - } - return true; -}; - -TextEditor.prototype.saveChanges = function() { - var text = this.macroNode.child.children[0].domNode.value, - tiddler = this.macroNode.wiki.getTiddler(this.macroNode.editTiddler); -// if(this.macroNode.params.requireFocus === "yes" && document.activeElement !== this.macroNode.child.children[0].domNode) { -// text = this.macroNode.params["default"] || ""; -// } - if(!tiddler) { - tiddler = new $tw.Tiddler({title: this.macroNode.editTiddler}); - } - if(text !== tiddler.fields[this.macroNode.editField]) { - var update = {}; - update[this.macroNode.editField] = text; - this.macroNode.wiki.addTiddler(new $tw.Tiddler(tiddler,update)); - } -}; - -TextEditor.prototype.fixHeight = function() { - if(this.macroNode.child && this.macroNode.child.children[0] && this.macroNode.child.children[0].type === "textarea") { - var wrapper = this.macroNode.child.domNode, - textarea = this.macroNode.child.children[0].domNode; - // Set the text area height to 1px temporarily, which allows us to read the true scrollHeight - var prevWrapperHeight = wrapper.style.height; - wrapper.style.height = textarea.style.height + "px"; - textarea.style.overflow = "hidden"; - textarea.style.height = "1px"; - textarea.style.height = Math.max(textarea.scrollHeight,MIN_TEXT_AREA_HEIGHT) + "px"; - wrapper.style.height = prevWrapperHeight; - } -}; - -TextEditor.prototype.postRenderInDom = function() { - this.fixHeight(); -}; - -TextEditor.prototype.refreshInDom = function() { - if(document.activeElement !== this.macroNode.child.children[0].domNode) { - var edit = this.getEditText(); - this.macroNode.child.children[0].domNode.value = edit.value; - } - // Fix the height if needed - this.fixHeight(); -}; - -exports["text/vnd.tiddlywiki"] = TextEditor; -exports["text/plain"] = TextEditor; - -})(); diff --git a/core/modules/macros/fields.js b/core/modules/macros/fields.js deleted file mode 100644 index e1c802999..000000000 --- a/core/modules/macros/fields.js +++ /dev/null @@ -1,66 +0,0 @@ -/*\ -title: $:/core/modules/macros/fields.js -type: application/javascript -module-type: macro - -Fields macro - -\*/ -(function(){ - -/*jslint node: true, browser: true */ -/*global $tw: false */ -"use strict"; - -exports.info = { - name: "fields", - dependentOnContextTiddler: true, - params: { - } -}; - -exports.executeMacro = function() { - // Create the table - var attributes = { - "class": ["tw-fields-table"] - }; - if(this.classes) { - $tw.utils.pushTop(attributes["class"],this.classes); - } - var rows = [ - $tw.Tree.Element("tr",{},[ - $tw.Tree.Element("th",{},[$tw.Tree.Text("Field")]), - $tw.Tree.Element("th",{},[$tw.Tree.Text("Value")]) - ]) - ]; - // Get the value to display - var tiddler = this.wiki.getTiddler(this.tiddlerTitle); - if(tiddler) { - var fields = []; - for(var f in tiddler.fields) { - fields.push(f); - } - fields.sort(); - for(f=0; f> macro are dependent on every tiddler - params: { - type: {byPos: 0, type: "text"}, - filter: {byName: true, type: "filter"}, - history: {byName: true, type: "tiddler"}, - template: {byName: true, type: "tiddler"}, - editTemplate: {byName: true, type: "tiddler"}, - emptyMessage: {byName: true, type: "text"}, - listviewTiddler: {byName: true, type: "tiddler"}, - listview: {byName: true, type: "text"}, - itemClass: {byName: true, type: "text"}, - map: {byName: true, type: "tiddler"}, - block: {ByName: true, type: "text"} // HACK: To be removed... - } -}; - -/* -These types are shorthands for particular filters -*/ -var typeMappings = { - all: "[!is[shadow]sort[title]]", - recent: "[!is[shadow]sort[modified]]", - missing: "[is[missing]sort[title]]", - orphans: "[is[orphan]sort[title]]", - shadowed: "[is[shadow]sort[title]]" -}; - -exports.executeMacro = function() { - this.useBlock = this.isBlock; - if(this.hasParameter("block")) { - this.useBlock = this.params.block === "yes"; - } - // Get the list of tiddlers object - this.getTiddlerList(); - // Create the list frame element - var attributes = {"class": ["tw-list-frame"]}; - if(this.classes) { - $tw.utils.pushTop(attributes["class"],this.classes); - } - this.listFrame = $tw.Tree.Element(this.useBlock ? "div" : "span",attributes,[]); - // Create the list - if(this.list.length === 0) { - // Check for an empty list - this.listFrame.children = [this.getEmptyMessage()]; - } else { - // Create the list - for(var t=0; t 0) { - // Use our content as the template - templateTree = []; - for(var t=0; t=0; t--) { - this.removeListElement(t); - } - // Insert the empty message - this.listFrame.children = [this.getEmptyMessage()]; - this.listFrame.children[0].renderInDom(this.listFrame.domNode,this.listFrame.domNode.childNodes[0]); - return; - } - } else { - // If it is not empty now, but was empty previously, then remove the empty message - if(prevListLength === 0) { - this.removeListElement(0); - } - } - // Step through the list and adjust our child list elements appropriately - for(t=0; t t) { - for(var n=index-1; n>=t; n--) { - this.removeListElement(n); - } - } - // Refresh the node we're reusing - this.listFrame.children[t].refreshInDom(changes); - } - } - // Remove any left over elements - if(this.listFrame.children.length > this.list.length) { - for(t=this.listFrame.children.length-1; t>=this.list.length; t--) { - this.removeListElement(t); - } - } -}; - -/* -Handle any changes to the history list -*/ -exports.handleHistoryChanges = function() { - // Get the history data - var newHistory = this.wiki.getTiddlerData(this.params.history,[]); - // Ignore any entries of the history that match the previous history - var entry = 0; - while(entry < newHistory.length && entry < this.history.length && newHistory[entry].title === this.history[entry].title) { - entry++; - } - // Navigate forwards to each of the new tiddlers - while(entry < newHistory.length) { - if(this.listview && this.listview.navigateTo) { - this.listview.navigateTo(newHistory[entry]); - } - entry++; - } - // Update the history - this.history = newHistory; -}; - -})(); diff --git a/core/modules/macros/list/listviews/cecily.js b/core/modules/macros/list/listviews/cecily.js deleted file mode 100644 index 5cd7d12ad..000000000 --- a/core/modules/macros/list/listviews/cecily.js +++ /dev/null @@ -1,135 +0,0 @@ -/*\ -title: $:/core/modules/macros/list/listviews/cecily.js -type: application/javascript -module-type: listview - -Views the list through a 2D map - -\*/ -(function(){ - -/*jslint node: true, browser: true */ -/*global $tw: false */ -"use strict"; - -function CecilyListView(listMacro) { - // The list macro we're attached to - this.listMacro = listMacro; - // Prepare the list frame - var listFrame = this.listMacro.listFrame, - listFrameDomNode = listFrame.domNode; - // Position the initial list entries on the map - this.loadMap(); - for(var t=0; t 0) { - return text.split("\n"); - } else { - return []; - } -}; - -exports.saveList = function(title,list) { - var storyTiddler = this.wiki.getTiddler(title); - this.wiki.addTiddler(new $tw.Tiddler({ - title: title - },storyTiddler,{text: list.join("\n")})); -}; - -exports.findTitleInStory = function(title,defaultIndex) { - for(var t=0; t