Add tiddler info dropdown

Including backlinks
This commit is contained in:
Jeremy Ruston 2013-03-19 16:45:07 +00:00
parent 069bb624e5
commit 952f1b3900
11 changed files with 80 additions and 18 deletions

View File

@ -0,0 +1,3 @@
<?xml version="1.0"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xl="http://www.w3.org/1999/xlink" version="1.1" viewBox="294 150 58 58" width="22pt" height="22pt"><g stroke="none" stroke-opacity="1" stroke-dasharray="none" fill="none" fill-opacity="1"><g><path d="M 342.76236 158.98764 C 331.77887 148.0041 313.97113 148.0041 302.98764 158.98764 C 292.0041 169.97113 292.0041 187.77887 302.98764 198.76236 C 313.97113 209.7459 331.77887 209.7459 342.76236 198.76236 C 353.7459 187.77887 353.7459 169.97113 342.76236 158.98764 M 326.5425 157.5 L 326.5425 157.5 C 327.72545 157.5 328.72201 157.91022 329.5337 158.73088 C 330.34465 159.55157 330.75 160.54402 330.75 161.7075 C 330.75 162.87172 330.33979 163.86316 329.51911 164.68385 C 328.69842 165.5045 327.70674 165.91501 326.5425 165.91501 C 325.39801 165.91501 324.4153 165.5045 323.5946 164.68385 C 322.77393 163.86316 322.36372 162.87172 322.36372 161.7075 C 322.36372 160.54402 322.76906 159.55157 323.58 158.73088 C 324.39171 157.91022 325.3793 157.5 326.5425 157.5 Z M 327.80211 190.47259 C 324.91945 195.49132 321.85778 198 318.61462 198 C 317.37452 198 316.38691 197.65158 315.65186 196.9555 C 314.9176 196.25866 314.54943 195.37617 314.54943 194.30782 C 314.54943 193.60202 314.71223 192.70572 315.03629 191.61813 L 319.0151 177.93651 C 319.39685 176.61922 319.58735 175.62754 319.58735 174.95991 C 319.58735 174.53996 319.40582 174.16692 319.04356 173.84286 C 318.68052 173.51905 318.18469 173.35701 317.55527 173.35701 C 317.26861 173.35701 316.92506 173.36677 316.5246 173.38548 L 316.89661 172.2407 L 326.59967 170.66627 L 328.31744 170.66627 L 322.44986 191.01638 C 322.12503 192.18064 321.963 192.94337 321.963 193.30666 C 321.963 193.51588 322.04862 193.71121 322.2204 193.89273 C 322.39218 194.07425 322.5737 194.16554 322.7642 194.16477 C 323.08903 194.16554 323.4131 194.02221 323.73792 193.73559 C 324.59605 193.02976 325.6267 191.75142 326.82838 189.90008 Z" fill="#ccc"/></g></g></svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -0,0 +1,2 @@
title: $:/core/images/info-button.svg
type: image/svg+xml

View File

@ -174,6 +174,22 @@ exports.operators = {
return "subResultsTemp = subResults;\nsubResults = [];for(t=subResultsTemp.length-1; t>=0; t--) {$tw.utils.pushTop(subResults,this.getTiddlersWithTag(subResultsTemp[t]));}";
}
},
"links": { // Return outgoing links on selected tiddlers
selector: function(operator) {
return "for(title in source) {r = this.getTiddlerLinks(title); $tw.utils.pushTop(subResults,r);}";
},
filter: function(operator) {
return "subResultsTemp = subResults;\nsubResults = [];for(t=subResultsTemp.length-1; t>=0; t--) {r = this.getTiddlerLinks(subResultsTemp[t]); $tw.utils.pushTop(subResults,r);}";
}
},
"backlinks": { // Return incoming links on selected tiddlers
selector: function(operator) {
return "for(title in source) {r = this.getTiddlerBacklinks(title); $tw.utils.pushTop(subResults,r);}";
},
filter: function(operator) {
return "subResultsTemp = subResults;\nsubResults = [];for(t=subResultsTemp.length-1; t>=0; t--) {r = this.getTiddlerBacklinks(subResultsTemp[t]); $tw.utils.pushTop(subResults,r);}";
}
},
"has": { // Filter by presence of a particular field
selector: function(operator) {
var op = operator.prefix === "!" ? "=" : "!";

View File

@ -90,17 +90,22 @@ ButtonWidget.prototype.setTiddler = function() {
};
ButtonWidget.prototype.handleClickEvent = function(event) {
var handled = false;
if(this.message) {
this.dispatchMessage(event);
handled = true;
}
if(this.popup) {
this.triggerPopup(event);
handled = true;
}
if(this.set && this.setTo) {
this.setTiddler();
handled = true;
}
event.stopPropagation();
event.preventDefault();
return false;
return handled;
};
ButtonWidget.prototype.handleMouseOverOrOutEvent = function(event) {

View File

@ -288,6 +288,21 @@ exports.getTiddlerLinks = function(title) {
});
};
/*
Return an array of tiddler titles that link to the specified tiddler
*/
exports.getTiddlerBacklinks = function(targetTitle) {
var self = this,
backlinks = [];
this.forEachTiddler(function(title,tiddler) {
var links = self.getTiddlerLinks(title);
if(links.indexOf(targetTitle) !== -1) {
backlinks.push(title);
}
});
return backlinks;
};
/*
Return a hashmap of tiddler titles that are referenced but not defined. Each value is the number of times the missing tiddler is referenced
*/

View File

@ -130,6 +130,7 @@ a.tw-tiddlylink-missing {
}
.tw-tiddler-frame {
position: relative;
padding: 3em;
margin-bottom: 2em;
background-color: {{$:/core/styles/colourmappings##tiddlerbackground}};
@ -235,7 +236,7 @@ a.tw-tiddlylink-missing {
}
.tw-tab-buttons {
font-size: 0.7em;
font-size: 0.85em;
line-height: 100%;
margin-bottom: -1px;
}
@ -261,19 +262,13 @@ a.tw-tiddlylink-missing {
padding: 1em;
}
.config-area {
max-width: 50em;
padding: 1em 3em 3em 3em;
border: 1px solid #aaa;
background: #ddd;
<<box-shadow "inset 1px 1px 4px rgba(0,0,0,0.8)">>
<<border-radius 3px>>
.tw-drop-down .tw-tab-buttons button {
background-color: #ececec;
}
.config-area h1 {
font-size: 1.2em;
text-align: center;
color: #888;
.tw-drop-down .tw-tab-buttons button.tw-tab-selected {
background-color: #fff;
border-bottom: 1px solid #fff;
}
.tw-edit-texteditor input, .tw-edit-texteditor textarea {

View File

@ -1,8 +1,11 @@
title: $:/templates/MoreSideBar
<div class="tw-tab-set">
<div class="tw-tab-buttons"><$button type="set" set="$:/state/moreSideBarTabSet" setTo="missingTab" qualifyTiddlerTitles="yes" selectedClass="tw-tab-selected">Missing</$button><$button type="set" set="$:/state/moreSideBarTabSet" setTo="orphanTab" qualifyTiddlerTitles="yes" selectedClass="tw-tab-selected">Orphans</$button><$button type="set" set="$:/state/moreSideBarTabSet" setTo="systemTab" qualifyTiddlerTitles="yes" selectedClass="tw-tab-selected">System</$button></div>
<div class="tw-tab-buttons"><$button type="set" set="$:/state/moreSideBarTabSet" setTo="tagsTab" qualifyTiddlerTitles="yes" selectedClass="tw-tab-selected">Tags</$button><$button type="set" set="$:/state/moreSideBarTabSet" setTo="missingTab" qualifyTiddlerTitles="yes" selectedClass="tw-tab-selected">Missing</$button><$button type="set" set="$:/state/moreSideBarTabSet" setTo="orphanTab" qualifyTiddlerTitles="yes" selectedClass="tw-tab-selected">Orphans</$button><$button type="set" set="$:/state/moreSideBarTabSet" setTo="systemTab" qualifyTiddlerTitles="yes" selectedClass="tw-tab-selected">System</$button></div>
<div class="tw-tab-contents">
<$reveal type="match" state="$:/state/moreSideBarTabSet" text="tagsTab" qualifyTiddlerTitles="yes">
<$list filter="[tags[]sort[title]]" itemClass="tw-menu-list-item"/>
</$reveal>
<$reveal type="match" state="$:/state/moreSideBarTabSet" text="missingTab" qualifyTiddlerTitles="yes">
<$list filter="[is[missing]sort[title]]" itemClass="tw-menu-list-item"/>
</$reveal>

View File

@ -0,0 +1,16 @@
title: $:/templates/TiddlerDropdown
<div class="tw-tab-set"><div class="tw-tab-buttons"><$button type="set" set="$:/state/moreSideBarTabSet" setTo="refTab" qualifyTiddlerTitles="yes" selectedClass="tw-tab-selected">References</$button><$button type="set" set="$:/state/moreSideBarTabSet" setTo="taggingTab" qualifyTiddlerTitles="yes" selectedClass="tw-tab-selected">Tagging</$button><$button type="set" set="$:/state/moreSideBarTabSet" setTo="fieldsTab" qualifyTiddlerTitles="yes" selectedClass="tw-tab-selected">Fields</$button></div>
<div class="tw-tab-contents">
<$reveal type="match" state="$:/state/moreSideBarTabSet" text="refTab" qualifyTiddlerTitles="yes">
<$list filter="[is[current]backlinks[]sort[title]]" emptyMessage="No tiddlers link to this one">
</$list>
</$reveal>
<$reveal type="match" state="$:/state/moreSideBarTabSet" text="taggingTab" qualifyTiddlerTitles="yes">
<$list filter="[is[current]tagging[]sort[title]]" itemClass="tw-menu-list-item" emptyMessage="No tiddlers are tagged with this one"/>
</$reveal>
<$reveal type="match" state="$:/state/moreSideBarTabSet" text="fieldsTab" qualifyTiddlerTitles="yes">
Fields...
</$reveal>
</div>
</div>

View File

@ -2,12 +2,15 @@ title: $:/templates/ViewTemplate
modifier: JeremyRuston
<span class="tw-tiddler-controls">
<$button popup="tiddlerDropdown" qualifyTiddlerTitles="yes" class="btn-invisible">{{$:/core/images/info-button.svg}}</$button>
<$button message="tw-edit-tiddler" class="btn-invisible">{{$:/core/images/edit-button.svg}}</$button>
<$button message="tw-close-tiddler" class="btn-invisible">{{$:/core/images/close-button.svg}}</$button>
</span>
<span class="title">
<$view field="title"/>
</span>
<span class="title"><$view field="title"/></span>
<$reveal type="popup" state="tiddlerDropdown" qualifyTiddlerTitles="yes">
<div class="tw-drop-down"><$transclude template="$:/templates/TiddlerDropdown"></$transclude></div>
</$reveal>
<div class="small"><$view field="modifier" format="link"/> <$view field="modified" format="date"/></div>

View File

@ -1,3 +1,3 @@
title: $:/state/moreSideBarTabSet-tiddlerTitle:$:/templates/MoreSideBar;templateTitle:$:/templates/MoreSideBar;-tiddlerTitle:$:/templates/SideBar;templateTitle:$:/templates/SideBar;-tiddlerTitle:$:/templates/PageTemplate;-
missingTab
tagsTab

View File

@ -40,6 +40,8 @@ A filter string consists of one or more runs of filter operators that each look
* ''{field}'': tests whether a tiddler field has a specified value (`[modifier[Jeremy]]`) or not (`[!modifier[Jeremy]]`)
* ''tags'': selects the tags on the currently selected tiddlers
* ''tagging'': selects the tiddlers tagged with the currently selected tiddlers
* ''links'': selects the outgoing links on the currently selected tiddlers
* ''backlinks'': selects the tiddlers that link to the currently selected tiddlers
* ''list'': selects the tiddlers listed in a specified tiddler (newline delimited)
An operator can be negated with by preceding it with `!`, for example `[!tag[Tommy]]` selects the tiddlers that are not tagged with `Tommy`.
@ -50,6 +52,8 @@ The operands available with the `is` operator are:
* ''system'': selects all system tiddlers
* ''current'': selects the current ContextTiddler
* ''missing'': selects all missing tiddlers
* ''orphan'': selects all orphan tiddlers
! Runs