From f48701544eda4f79af86b1ad44340e7182bcf024 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Thu, 13 Mar 2014 17:40:53 +0000 Subject: [PATCH] Enhance tiddler title for system tiddlers Now the $:/ part of the name is rendered in grey, making the main part of the title more prominent. @tobibeer suggested this a long time ago; good idea! --- core/language/en-GB/Misc.multids | 1 + core/modules/filters/removeprefix.js | 40 ++++++++++++++++++++++++++++ core/ui/ViewTemplate/title.tid | 29 +++++++++++++++++--- themes/tiddlywiki/vanilla/base.tid | 4 +++ 4 files changed, 70 insertions(+), 4 deletions(-) create mode 100644 core/modules/filters/removeprefix.js diff --git a/core/language/en-GB/Misc.multids b/core/language/en-GB/Misc.multids index caf58de2c..651f0eab7 100644 --- a/core/language/en-GB/Misc.multids +++ b/core/language/en-GB/Misc.multids @@ -3,3 +3,4 @@ title: $:/language/ RecentChanges/DateFormat: DDth MMM YYYY CloseAll/Button: close all MissingTiddler/Hint: Missing tiddler "<$text text=<>/>" - click {{$:/core/images/edit-button}} to create +SystemTiddler/Tooltip: This is a system tiddler \ No newline at end of file diff --git a/core/modules/filters/removeprefix.js b/core/modules/filters/removeprefix.js new file mode 100644 index 000000000..3b62015f5 --- /dev/null +++ b/core/modules/filters/removeprefix.js @@ -0,0 +1,40 @@ +/*\ +title: $:/core/modules/filters/removeprefix.js +type: application/javascript +module-type: filteroperator + +Filter operator for removing a prefix from each title in the list. Titles that do not start with the prefix are removed. + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +/* +Export our filter function +*/ +exports.removeprefix = function(source,operator,options) { + var results = []; + // Function to check an individual title + function checkTiddler(title) { + var match = title.substr(0,operator.operand.length).toLowerCase() === operator.operand.toLowerCase(); + if(match) { + results.push(title.substr(operator.operand.length)); + } + } + // Iterate through the source tiddlers + if($tw.utils.isArray(source)) { + $tw.utils.each(source,function(title) { + checkTiddler(title); + }); + } else { + $tw.utils.each(source,function(element,title) { + checkTiddler(title); + }); + } + return results; +}; + +})(); diff --git a/core/ui/ViewTemplate/title.tid b/core/ui/ViewTemplate/title.tid index 22b25ffbd..11004c90d 100644 --- a/core/ui/ViewTemplate/title.tid +++ b/core/ui/ViewTemplate/title.tid @@ -4,12 +4,33 @@ tags: $:/tags/ViewTemplate \define title-styles() fill:$(foregroundColor)$; \end -
<$list filter="[is[shadow]!has[draft.of]tag[$:/tags/ViewToolbar]] [!is[shadow]!has[draft.of]tag[$:/tags/ViewToolbar]] +[tag[$:/tags/ViewToolbar]]" variable="listItem"><$transclude tiddler=<>/> - -<$set name="foregroundColor" value={{!!color}}>>><$transclude tiddler={{!!icon}}/> <$view field="title"/>
+
+
+ +<$list filter="[is[shadow]!has[draft.of]tag[$:/tags/ViewToolbar]] [!is[shadow]!has[draft.of]tag[$:/tags/ViewToolbar]] +[tag[$:/tags/ViewToolbar]]" variable="listItem"> +<$transclude tiddler=<>/> + + +<$set name="foregroundColor" value={{!!color}}> +>> +<$transclude tiddler={{!!icon}}/> + + +<$list filter="[is[current]removeprefix[$:/]]"> + +$:/<$text text=<>/> + + +<$list filter="[is[current]!prefix[$:/]]"> + +<$view field="title"/> + + +
<$reveal type="nomatch" text="" default="" state=<> class="tw-tiddler-info tw-popup" animate="yes" retain="yes"> <$transclude tiddler="$:/core/ui/TiddlerInfo"/> -
\ No newline at end of file + +
\ No newline at end of file diff --git a/themes/tiddlywiki/vanilla/base.tid b/themes/tiddlywiki/vanilla/base.tid index 405e8cf99..9f245acf8 100644 --- a/themes/tiddlywiki/vanilla/base.tid +++ b/themes/tiddlywiki/vanilla/base.tid @@ -492,6 +492,10 @@ a.tw-tiddlylink-external:hover { color: <>; } +.tw-system-title-prefix { + color: <>; +} + .titlebar img { height: 1em; }