mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 03:57:21 +00:00
Merge branch 'master' of https://github.com/Jermolene/TiddlyWiki5
This commit is contained in:
commit
df809bcb87
@ -143,7 +143,7 @@ SimpleServer.prototype.requestHandler = function(request,response) {
|
||||
};
|
||||
|
||||
SimpleServer.prototype.listen = function(port,host) {
|
||||
http.createServer(this.requestHandler.bind(this)).listen(port,host);
|
||||
return http.createServer(this.requestHandler.bind(this)).listen(port,host);
|
||||
};
|
||||
|
||||
var Command = function(params,commander,callback) {
|
||||
@ -302,13 +302,14 @@ Command.prototype.execute = function() {
|
||||
password: password,
|
||||
pathprefix: pathprefix
|
||||
});
|
||||
this.server.listen(port,host);
|
||||
var nodeServer = this.server.listen(port,host);
|
||||
$tw.utils.log("Serving on " + host + ":" + port,"brown/orange");
|
||||
$tw.utils.log("(press ctrl-C to exit)","red");
|
||||
// Warn if required plugins are missing
|
||||
if(!$tw.wiki.getTiddler("$:/plugins/tiddlywiki/tiddlyweb") || !$tw.wiki.getTiddler("$:/plugins/tiddlywiki/filesystem")) {
|
||||
$tw.utils.warning("Warning: Plugins required for client-server operation (\"tiddlywiki/filesystem\" and \"tiddlywiki/tiddlyweb\") are missing from tiddlywiki.info file");
|
||||
}
|
||||
$tw.hooks.invokeHook('th-server-command-post-start', this.server, nodeServer);
|
||||
return null;
|
||||
};
|
||||
|
||||
|
@ -26,16 +26,9 @@ function getIsFilterOperators() {
|
||||
Export our filter function
|
||||
*/
|
||||
exports.is = function(source,operator,options) {
|
||||
// Dispatch to the correct isfilteroperator
|
||||
var isFilterOperators = getIsFilterOperators();
|
||||
if(operator.operand) {
|
||||
var isFilterOperator = isFilterOperators[operator.operand];
|
||||
if(isFilterOperator) {
|
||||
return isFilterOperator(source,operator.prefix,options);
|
||||
} else {
|
||||
return [$tw.language.getString("Error/IsFilterOperator")];
|
||||
}
|
||||
} else {
|
||||
|
||||
|
||||
if( !operator.operand) {
|
||||
// Return all tiddlers if the operand is missing
|
||||
var results = [];
|
||||
source(function(tiddler,title) {
|
||||
@ -43,6 +36,31 @@ exports.is = function(source,operator,options) {
|
||||
});
|
||||
return results;
|
||||
}
|
||||
|
||||
// Get our isfilteroperators
|
||||
var isFilterOperators = getIsFilterOperators(),
|
||||
subops = operator.operand.split("+"),
|
||||
filteredResults = {},
|
||||
results = [];
|
||||
for (var t=0; t<subops.length; t++) {
|
||||
var subop = isFilterOperators[subops[t]];
|
||||
if(subop) {
|
||||
filteredResults[subops[t]] = subop(source,operator.prefix,options);
|
||||
} else {
|
||||
return [$tw.language.getString("Error/IsFilterOperator")];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
source(function(tiddler,title) {
|
||||
for (var t=0; t<subops.length; t++) {
|
||||
if (filteredResults[subops[t]].indexOf(title) != -1){
|
||||
results.push(title);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
})();
|
||||
|
@ -0,0 +1,18 @@
|
||||
created: 20180409142128584
|
||||
modified: 20180409142128584
|
||||
tags: HookMechanism
|
||||
title: Hook: th-server-command-post-start
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
This hook allows plugins to extend the TiddlyWiki server command after it initializes. The two
|
||||
most obvious use cases are adding routes (such as an attachments folder for external files)
|
||||
to the SimpleServer instance and adding a websockets handler to the HTTP server.
|
||||
|
||||
Hook function parameters:
|
||||
|
||||
* SimpleServer instance
|
||||
** Defined in core/modules/commands/server.js
|
||||
* NodeJS HTTP Server instance
|
||||
** See the NodeJS docs at [ext[https://nodejs.org/docs/latest-v8.x/api/http.html#http_class_http_server]]
|
||||
|
||||
Return value is ignored.
|
@ -11,3 +11,4 @@ type: text/vnd.tiddlywiki
|
||||
<<.operator-example 5 "[all[shadows]is[system]tag[$:/tags/Stylesheet]]" "shadow system stylesheets">>
|
||||
<<.operator-example 6 "[is[shadow]]" "overridden shadow tiddlers">>
|
||||
<<.operator-example 7 "[is[missing]]" "empty because its input contains only tiddlers that exist">>
|
||||
<<.operator-example 8 "[all[tiddlers+shadows]is[tiddler+shadow]]" "contains the entire input list">>
|
||||
|
@ -11,7 +11,11 @@ op-parameter-name: C
|
||||
op-output: those input tiddlers that belong to category <<.place C>>
|
||||
op-neg-output: those input tiddlers that do <<.em not>> belong to category <<.place C>>
|
||||
|
||||
The parameter <<.place C>> is one of the following fundamental categories:
|
||||
The parameter <<.place C>> specifies zero or more fundamental categories using the following syntax:
|
||||
|
||||
<$railroad text="""
|
||||
[{: ("current" | "missing" |: "orphans" | "shadows" | "tags" | "tiddlers" ) +"+" }]
|
||||
"""/>
|
||||
|
||||
|!Category |!Matches any tiddler that... |
|
||||
|^`current` |is the [[current tiddler|Current Tiddler]] |
|
||||
|
@ -17,6 +17,10 @@ The components of this plugin include:
|
||||
|
||||
The background task detects when elements with the class `tc-dynaview-set-tiddler-when-visible` scroll into view. The first time that they do, the background task assigns the value in the attribute `data-dynaview-set-value` to the tiddler whose title is in the attribute `data-dynaview-set-tiddler`. This assignment can be tied to a reveal widget to cause content to be displayed when it becomes visible. If the class `tc-dynaview-expand-viewport` is set then the viewport is expanded so that the processing occurs when elements move near the viewport.
|
||||
|
||||
!! Unset tiddler field when set visible before but then scrolled out of view
|
||||
|
||||
The background task detects when elements with the class `tc-dynaview-set-tiddler-when-visible` scroll out view after they have scrolled into view. When scrolling out of view after they have scrolled in, the background task assigns the value in the attribute `data-dynaview-unset-value` to the tiddler whose title is in the attribute `data-dynaview-unset-tiddler`. This assignment can be tied to a reveal widget to cause content to be hidden when it becomes invisible. If the class `tc-dynaview-expand-viewport` is set then the viewport is expanded so that the processing occurs when elements move near the viewport.
|
||||
|
||||
!! Update address bar when scrolling
|
||||
|
||||
The background task detects the tiddler at the top of the viewport and sets the address bar location hash to the title of that tiddler.
|
||||
|
@ -139,6 +139,36 @@ function checkVisibility() {
|
||||
$tw.utils.each(elements,function(element) {
|
||||
// Bail if we've already triggered this element
|
||||
if(element.getAttribute("data-dynaview-has-triggered") === "true") {
|
||||
if(element.getAttribute("data-dynaview-unset-tiddler") !== undefined && element.getAttribute("data-dynaview-unset-value") !== undefined) {
|
||||
// Check if the element is visible
|
||||
var elementRect = element.getBoundingClientRect(),
|
||||
viewportWidth = window.innerWidth || document.documentElement.clientWidth,
|
||||
viewportHeight = window.innerHeight || document.documentElement.clientHeight,
|
||||
viewportRect = {
|
||||
left: 0,
|
||||
right: viewportWidth,
|
||||
top: 0,
|
||||
bottom: viewportHeight
|
||||
};
|
||||
if(element.classList.contains("tc-dynaview-expand-viewport")) {
|
||||
viewportRect.left -= viewportWidth;
|
||||
viewportRect.right += viewportWidth;
|
||||
viewportRect.top -= viewportHeight;
|
||||
viewportRect.bottom += viewportHeight;
|
||||
}
|
||||
if(elementRect.left > viewportRect.right ||
|
||||
elementRect.right < viewportRect.left ||
|
||||
elementRect.top > viewportRect.bottom ||
|
||||
elementRect.bottom < viewportRect.top) {
|
||||
// Set the tiddler value
|
||||
var tiddler = element.getAttribute("data-dynaview-unset-tiddler"),
|
||||
value = element.getAttribute("data-dynaview-unset-value") || "";
|
||||
if(tiddler && $tw.wiki.getTiddlerText(tiddler) !== value) {
|
||||
$tw.wiki.addTiddler(new $tw.Tiddler({title: tiddler, text: value}));
|
||||
}
|
||||
element.setAttribute("data-dynaview-has-triggered","false");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Check if the element is visible
|
||||
@ -167,7 +197,7 @@ function checkVisibility() {
|
||||
if(tiddler && $tw.wiki.getTiddlerText(tiddler) !== value) {
|
||||
$tw.wiki.addTiddler(new $tw.Tiddler({title: tiddler, text: value}));
|
||||
}
|
||||
element.setAttribute("data-dynaview-has-triggered",true);
|
||||
element.setAttribute("data-dynaview-has-triggered","true");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -17,10 +17,37 @@ $index$
|
||||
</div>
|
||||
\end
|
||||
|
||||
\define lorem-ipsum-unset(index)
|
||||
<div class="tc-dynaview-set-tiddler-when-visible" style="min-height: 75px;" data-dynaview-set-tiddler="$:/state/reveal-on-scroll/example$index$" data-dynaview-set-value="yes" data-dynaview-unset-tiddler="$:/state/reveal-on-scroll/example$index$" data-dynaview-unset-value="no">
|
||||
<h1>Heading $index$</h1>
|
||||
<$reveal state="$:/state/reveal-on-scroll/example$index$" type="match" text="yes">
|
||||
(Rendered at <<now "[UTC]YYYY-0MM-0DD 0hh:0mm:0ss.XXX">>) Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
||||
</$reveal>
|
||||
</div>
|
||||
\end
|
||||
|
||||
<$reveal state="$:/state/dynaview-example/reveal-scroll/unset" type="nomatch" text="yes">
|
||||
|
||||
!!!Same example, showing elements when they scroll into view and hiding elements when they scroll out of view:<br>
|
||||
<$button set="$:/state/dynaview-example/reveal-scroll/unset" setTo="yes">Change Example</$button>
|
||||
</$reveal>
|
||||
<$reveal state="$:/state/dynaview-example/reveal-scroll/unset" type="match" text="yes">
|
||||
|
||||
!!!Same example, but only showing elements when they scroll into view:<br>
|
||||
<$button set="$:/state/dynaview-example/reveal-scroll/unset" setTo="no">Change Example</$button>
|
||||
</$reveal>
|
||||
|
||||
Visible: <$list filter="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16">
|
||||
<$macrocall $name="indicator" index=<<currentTiddler>>/>
|
||||
</$list>
|
||||
|
||||
<$reveal state="$:/state/dynaview-example/reveal-scroll/unset" type="nomatch" text="yes">
|
||||
<$list filter="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16">
|
||||
<$macrocall $name="lorem-ipsum" index=<<currentTiddler>>/>
|
||||
</$list>
|
||||
</$reveal>
|
||||
<$reveal state="$:/state/dynaview-example/reveal-scroll/unset" type="match" text="yes">
|
||||
<$list filter="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16">
|
||||
<$macrocall $name="lorem-ipsum-unset" index=<<currentTiddler>>/>
|
||||
</$list>
|
||||
</$reveal>
|
||||
|
Loading…
Reference in New Issue
Block a user