1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-26 15:23:15 +00:00

Added tags and color macros

Which enables us to do nice colour coded tags. Soon they'll have a drop
down on them too
This commit is contained in:
Jeremy Ruston 2012-06-10 19:47:24 +01:00
parent 2d94e466ae
commit fc49d7dffd
15 changed files with 125 additions and 5 deletions

View File

@ -0,0 +1,41 @@
/*\
title: $:/core/modules/macros/color.js
type: application/javascript
module-type: macro
Color macro.
Applies the specified colour to its content. By default, the colour value is obtained from the `color` field of the current tiddler
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {
name: "color",
params: {
"default": {byName: "default", type: "text"},
}
};
exports.executeMacro = function() {
var tiddler = this.wiki.getTiddler(this.tiddlerTitle),
attributes = {
style: {
"background-color": (tiddler && tiddler.fields.color) || this.params["default"]
}
};
if(this.classes) {
attributes["class"] = this.classes.slice(0);
}
for(var t=0; t<this.content.length; t++) {
this.content[t].execute(this.parents,this.tiddlerTitle);
}
return $tw.Tree.Element("span",attributes,this.content);
};
})();

View File

@ -0,0 +1,45 @@
/*\
title: $:/core/modules/macros/tags.js
type: application/javascript
module-type: macro
Implements the tags macro.
{{{
<<tags template:MyTagTemplate>>
}}}
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.info = {
name: "tags",
dependentOnContextTiddler: true,
params: {
template: {byName: true, type: "tiddler"},
filter: {byName: true, type: "filter"}
}
};
exports.executeMacro = function() {
var tiddler = this.wiki.getTiddler(this.tiddlerTitle),
child = $tw.Tree.Element("div",{"class":"tw-tags-wrapper"},[]);
if(tiddler && tiddler.fields.tags) {
for(var t=0; t<tiddler.fields.tags.length; t++) {
var tag = tiddler.fields.tags[t];
child.children.push($tw.Tree.Macro("tiddler",{
srcParams: {target: tag,template: this.params.template},
wiki: this.wiki,
isBlock: false
}));
}
}
child.execute(this.parents,this.tiddlerTitle);
return child;
};
})();

View File

@ -124,7 +124,7 @@ exports.executeMacro = function() {
attributes["class"].push("tw-tiddler-missing");
}
// Return the children
return $tw.Tree.Element("div",attributes,childrenClone);
return $tw.Tree.Element(this.isBlock ? "div" : "span",attributes,childrenClone);
};
exports.refreshInDom = function(changes) {

View File

@ -0,0 +1,5 @@
title: $:/templates/TagTemplate
{{label{
<<color background:yes default:#888><<<view title>>>>
}}}

View File

@ -5,7 +5,8 @@ modifier: JeremyRuston
<div><span><<view title>></span><<button EditTiddler class:"btn btn-mini"><edit>></div>
}}}
{{small{
<div><<view modifier link>> <<view modified date>> <<view tags>> </div>
<div><<view modifier link>> <<view modified date>></div>
<<tags template:"$:/templates/TagTemplate">>
}}}
{{body{
<<view text wikified>>

View File

@ -55,6 +55,8 @@ tags: docs
* SliderMacro
* ZoomerMacro
* ChooserMacro
* TagsMacro
* ColorMacro
! Commands

View File

@ -0,0 +1,12 @@
title: Improvements
tags: docs introduction
The following features have been improved in TiddlyWiki5:
* TiddlyWiki can now be run under [[node.js|nodejs.org]] as well as in the browser
* TiddlyWiki is structured as a 600-line boot kernel, with everything else implemented as plugins
* Improved WikiText, with much better generation of HTML, including proper `<p>` tags
* Tiddlers containing images are now supported just like WikiText tiddlers, including integrated editing of bitmap and SVG images
* Use of Twitter Bootstrap stylesheet (also enabling the use of Boostrap themes such as http://bootswatch.com)
* Syntax highlighting for JavaScript and JSON tiddlers
* TiddlyWiki5 can directly build both itself and previous (2.6.x) versions of TiddlyWiki from their constituent separate files, without needing external tools

View File

@ -1,5 +1,5 @@
title: TiddlerFilters
tags: feature
tags: docs concepts
TiddlyWiki has a special syntax for expressing filters. They can be used to select tiddlers for an operation, or to filter a set of tiddlers to add or remove members.

View File

@ -1,7 +1,7 @@
title: TiddlyWiki
modifier: JeremyRuston
modified: 20120211110622
tag: docs concepts
tags: docs concepts
TiddlyWiki is a rich, interactive interface for manipulating complex data with structure that doesn't easily fit into conventional tools like spreadsheets or wordprocessors.

View File

@ -1,6 +1,6 @@
title: WikiText
type: text/x-tiddlywiki
tags: concepts
tags: docs concepts
WikiText is a concise, expressive way of typing a wide range of text formatting and hypertext features. Operations like linking become part of the punctuation of your writing.

View File

@ -0,0 +1,3 @@
title: concepts
color: #800

View File

@ -0,0 +1,3 @@
title: docs
color: #008

View File

@ -0,0 +1,3 @@
title: introduction
color: #840

View File

@ -5,6 +5,7 @@ type: application/json
"tiddlers": [
{"title": "HelloThere", "template": "$:/templates/ViewTemplate"},
{"title": "Introduction", "template": "$:/templates/ViewTemplate"},
{"title": "Improvements", "template": "$:/templates/ViewTemplate"},
{"title": "Docs", "template": "$:/templates/ViewTemplate"}
]
}

View File

@ -27,6 +27,10 @@ body {
font-weight: normal;
}
.tw-tags-wrapper .label {
margin-right: 8px;
}
.tw-edit-field {
border: 1px dotted #888;
}