mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-11 09:50:27 +00:00
Expose document location via $:/info/url/*
info tiddlers
This commit is contained in:
parent
8fbcfaa79b
commit
2f590a365e
@ -18,6 +18,21 @@ exports.getInfoTiddlerFields = function() {
|
||||
// Basics
|
||||
infoTiddlerFields.push({title: "$:/info/browser", text: mapBoolean(!!$tw.browser)});
|
||||
infoTiddlerFields.push({title: "$:/info/node", text: mapBoolean(!!$tw.node)});
|
||||
// Document location
|
||||
if($tw.browser) {
|
||||
var setLocationProperty = function(name,value) {
|
||||
infoTiddlerFields.push({title: "$:/info/url/" + name, text: value});
|
||||
},
|
||||
location = document.location;
|
||||
setLocationProperty("full", (location.toString()).split("#")[0]);
|
||||
setLocationProperty("host", location.host);
|
||||
setLocationProperty("hostname", location.hostname);
|
||||
setLocationProperty("protocol", location.protocol);
|
||||
setLocationProperty("port", location.port);
|
||||
setLocationProperty("pathname", location.pathname);
|
||||
setLocationProperty("search", location.search);
|
||||
setLocationProperty("origin", location.origin);
|
||||
}
|
||||
return infoTiddlerFields;
|
||||
};
|
||||
|
||||
|
@ -1,9 +1,13 @@
|
||||
created: 20140720164948099
|
||||
modified: 20140720165248031
|
||||
modified: 20161017122011379
|
||||
tags: Mechanisms
|
||||
title: InfoMechanism
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
\define example(name)
|
||||
<$transclude tiddler="""$:/info/url/$name$""" mode="inline"/>
|
||||
\end
|
||||
|
||||
System tiddlers in the namespace `$:/info/` are used to expose information about the system (including the current browser) so that WikiText applications can adapt themselves to available features.
|
||||
|
||||
! Information Tiddlers
|
||||
@ -11,4 +15,11 @@ System tiddlers in the namespace `$:/info/` are used to expose information about
|
||||
|!Title |!Description |
|
||||
|[[$:/info/browser]] |Running in the browser? ("yes" or "no") |
|
||||
|[[$:/info/node]] |Running under [[Node.js]]? ("yes" or "no") |
|
||||
|
||||
|[[$:/info/url/full]] |<<.from-version "5.1.14">> Full URL of wiki (eg, ''<<example full>>'') |
|
||||
|[[$:/info/url/host]] |<<.from-version "5.1.14">> Host portion of URL of wiki (eg, ''<<example host>>'') |
|
||||
|[[$:/info/url/hostname]] |<<.from-version "5.1.14">> Hostname portion of URL of wiki (eg, ''<<example hostname>>'') |
|
||||
|[[$:/info/url/origin]] |<<.from-version "5.1.14">> Origin portion of URL of wiki (eg, ''<<example origin>>'') |
|
||||
|[[$:/info/url/pathname]] |<<.from-version "5.1.14">> Pathname portion of URL of wiki (eg, ''<<example pathname>>'') |
|
||||
|[[$:/info/url/port]] |<<.from-version "5.1.14">> Port portion of URL of wiki (eg, ''<<example port>>'') |
|
||||
|[[$:/info/url/protocol]] |<<.from-version "5.1.14">> Protocol portion of URL of wiki (eg, ''<<example protocol>>'') |
|
||||
|[[$:/info/url/search]] |<<.from-version "5.1.14">> Search portion of URL of wiki (eg, ''<<example search>>'') |
|
||||
|
Loading…
Reference in New Issue
Block a user