-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
23 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"tiddlers":{"$:/config/flibbles/relink-fieldnames/blacklist":{"title":"$:/config/flibbles/relink-fieldnames/blacklist","filter":"[all[shadows+tiddlers]removeprefix[$:/language/Docs/Fields/]]","text":"This tiddler specifies what fields //Relink-fieldname// should refuse to change. Edit its `filter` field if you'd like to change that list.\n"},"$:/plugins/flibbles/relink-fieldnames/readme":{"title":"$:/plugins/flibbles/relink-fieldnames/readme","text":"\\whitespace trim\n\nEnables Relink to relink field names associated with renamed tiddlers. The following fields cannot be interacted with in this way:\n\n<<<\n<$set name=blacklisted filter={{$:/config/flibbles/relink-fieldnames/blacklist!!filter}}>\n''<$list counter=counter filter=\"[enlist<blacklisted>sort[]]\">\n<<currentTiddler>><br>\n</$list>''\n</$set>\n<<<\n\nSee <a href={{$:/plugins/flibbles/relink-fieldnames!!source}} class=\"tc-tiddlylink-external\">the tw5-relink website</a> for more details and examples.\n"},"$:/plugins/flibbles/relink-fieldnames/reference":{"title":"$:/plugins/flibbles/relink-fieldnames/reference","caption":"Field Names","tags":"$:/tags/flibbles/relink/Configuration","text":"\\define label(arrow, setTo) <$reveal type=\"nomatch\" state=<<table-state>> text=\"$setTo$\" default=\"no\"><$button class=\"tc-btn-invisible tc-btn-dropdown\" set=<<table-state>> setTo=\"$setTo$\">{{$arrow$}} ''<$link to=<<field>>/>''</$button> <span class=\"tc-relink-fieldnames-count\">(<$text text={{{ [has<field>count[]] }}} />)</span></$reveal>\n\n\\define entry(field)\n<$set name=\"table-state\" value=<<qualify \"\"\"$:/state/flibbles/relink-fieldnames/table/$field$\"\"\">>>\n<tr class=\"tc-relink-fieldnames-field\">\n<td colspan=\"3\">\n<<label $:/core/images/right-arrow yes>>\n<<label $:/core/images/down-arrow no>>\n</td>\n</tr>\n<$list filter=\"[has<field>]\" >\n<$reveal tag=\"tr\" type=\"match\" state=<<table-state>> text=\"yes\" default=\"no\" class=\"tc-relink-fieldnames-entry\">\n<td class=\"tc-relink-fieldnames-margin\"></td>\n<td class=\"tc-relink-fieldnames-title\"><$link to=<<currentTiddler>> /></td><td><$text text={{{ [all[current]get<field>] }}} /></td>\n</$reveal>\n</$list>\n</$set>\n\\end\n\\whitespace trim\n\nThe following is a table of all tiddlers currently being used as field names.\n\n<$set name=blacklisted filter={{$:/config/flibbles/relink-fieldnames/blacklist!!filter}} >\n<table class=\"tc-relink-fieldnames-table\">\n<tbody>\n<$list variable=\"field\" filter=\"[fields[]is[tiddler]] -[enlist<blacklisted>]\">\n<$macrocall $name=\"entry\" field=<<field>> />\n</$list>\n</tbody>\n</table>\n</$set>\n"},"$:/plugins/flibbles/relink-fieldnames/relinkoperator.js":{"title":"$:/plugins/flibbles/relink-fieldnames/relinkoperator.js","text":"/*\\\ntitle: $:/plugins/flibbles/relink-fieldnames/relinkoperator.js\nmodule-type: relinkoperator\ntype: application/javascript\n\nUpdates the field names if they correspond to the renamed tiddler.\n\n\\*/\n\n/*jslint node: false, browser: true */\n/*global $tw: false */\n\"use strict\";\n\nexports.name = 'field-names';\n\nvar configPrefix = \"$:/config/flibbles/relink/fields/\";\nvar docPrefix = \"$:/language/Docs/Fields/\";\nvar blacklistTiddler = \"$:/config/flibbles/relink-fieldnames/blacklist\";\n\nvar utils = require('$:/plugins/flibbles/relink/js/utils.js');\nutils.getContext('whitelist').hotDirectories.push(docPrefix);\nutils.getContext('whitelist').hotDirectories.push(\"$:/config/flibbles/relink-fieldnames/\");\n\nexports.report = function(tiddler, callback, options) {\n\tvar fields = tiddler.fields;\n\tfor (var field in fields) {\n\t\tif (!isReserved(options.wiki, field)) {\n\t\t\tcallback(field, ': ' + abridge(fields[field], 20), {soft: true});\n\t\t}\n\t}\n};\n\nexports.relink = function(tiddler, fromTitle, toTitle, changes, options) {\n\tif ($tw.utils.hop(tiddler.fields, fromTitle)\n\t&& !isReserved(options.wiki, fromTitle)) {\n\t\tif ($tw.utils.hop(tiddler.fields, toTitle)\n\t\t|| isReserved(options.wiki, toTitle)\n\t\t|| !isValidFieldName(toTitle)) {\n\t\t\t// There is already a [toTitle] field, and we won't clobber it.\n\t\t\t// Or this is an illegal field name\n\t\t\tchanges[fromTitle] = {impossible: true};\n\t\t} else if ($tw.utils.hop(changes, fromTitle)) {\n\t\t\t// If the value changed, we need the changed value, assuming there\n\t\t\t// is one.\n\t\t\tchanges[toTitle] = {\n\t\t\t\toutput: changes[fromTitle].output || tiddler.fields[fromTitle]\n\t\t\t};\n\t\t\t// But we leave the original change in place in case it described\n\t\t\t// an impossible relink or something.\n\t\t\tchanges[fromTitle].output = null;\n\t\t} else {\n\t\t\tchanges[toTitle] = {output: tiddler.fields[fromTitle]};\n\t\t\tchanges[fromTitle] = {output: null};\n\t\t}\n\t}\n\t// If this is a whitelist entry for the fromTitle field, update it.\n\tif (tiddler.fields.title === configPrefix + fromTitle) {\n\t\tvar newTitle = configPrefix + toTitle;\n\t\t// Make sure we wouldn't be deleting an existing whitelist entry.\n\t\tchanges.title = (!options.wiki.tiddlerExists(newTitle)) ?\n\t\t\t{ output: newTitle }:\n\t\t\t{ impossible: true };\n\t}\n};\n\n// Pre v5.2.0, this will be false. But we can't rely on utils.isValidFieldName\n// entirely, because it is forgiving about capitalization when we can't be.\nvar capitalizationAllowed = $tw.utils.isValidFieldName(\"A:\");\n\nfunction isValidFieldName(field) {\n\treturn $tw.utils.isValidFieldName(field)\n\t\t&& (capitalizationAllowed || !/[A-Z]/.test(field));\n};\n\nfunction abridge(string, length) {\n\treturn (string.length > length)? string.substr(0, length) + \"...\" : string;\n};\n\nfunction isReserved(wiki, field) {\n\tvar method = wiki.getGlobalCache('relink-fieldnames-reserved', function() {\n\t\tvar blacklist = wiki.getTiddler(blacklistTiddler);\n\t\tif (blacklist) {\n\t\t\tvar tiddlers = wiki.filterTiddlers(blacklist.fields.filter);\n\t\t\tvar fieldMap = Object.create(null);\n\t\t\tfor (var i = 0; i < tiddlers.length; i++) {\n\t\t\t\tfieldMap[tiddlers[i]] = true;\n\t\t\t}\n\t\t\treturn function(field) {return fieldMap[field] || false;};\n\t\t} else {\n\t\t\t// no blacklist. fieldnames is disabled. Everything is reserved.\n\t\t\treturn function() { return true; };\n\t\t}\n\t});\n\treturn method(field);\n};\n","module-type":"relinkoperator","type":"application/javascript"},"$:/plugins/flibbles/relink-fieldnames/style":{"title":"$:/plugins/flibbles/relink-fieldnames/style","tags":"$:/tags/Stylesheet","text":".tc-relink-fieldnames-table {\n\twidth: 100%;\n\tborder: 0px;\n}\n\n.tc-relink-fieldnames-field a {\n\tfont-weight: bold;\n}\n\n.tc-relink-fieldnames-field td {\n\tborder: 0px;\n}\n\n.tc-relink-fieldnames-count {\n\tcolor: lightgray;\n}\n\n.tc-relink-fieldnames-title {\n\tmargin-left: 3pt;\n\tmin-width: 30%;\n}\n\n.tc-relink-fieldnames-entry td {\n\tborder: 0px;\n\tborder-bottom: 1px solid <<colour table-border>>;\n}\n\n.tc-relink-fieldnames-margin {\n\twidth: 25pt;\n}\n"}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
author: Flibbles | ||
core-version: >=5.1.22 | ||
demo: http://flibbles.github.io/tw5-relink/ | ||
dependents: | ||
description: Renames field names with titles matching Relinked tiddlers | ||
list: readme reference | ||
name: Relink Field Names | ||
parent-plugin: $:/plugins/flibbles/relink | ||
plugin-type: plugin | ||
source: https://github.com/flibbles/tw5-relink | ||
title: $:/plugins/flibbles/relink-fieldnames | ||
type: application/json | ||
version: 2.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters