diff --git a/core/modules/info/platform.js b/core/modules/info/platform.js index 9f6097f74..c30f5b83c 100644 --- a/core/modules/info/platform.js +++ b/core/modules/info/platform.js @@ -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; }; diff --git a/editions/tw5.com/tiddlers/mechanisms/InfoMechanism.tid b/editions/tw5.com/tiddlers/mechanisms/InfoMechanism.tid index ab709f1ed..137819bf1 100644 --- a/editions/tw5.com/tiddlers/mechanisms/InfoMechanism.tid +++ b/editions/tw5.com/tiddlers/mechanisms/InfoMechanism.tid @@ -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, ''<>'') | +|[[$:/info/url/host]] |<<.from-version "5.1.14">> Host portion of URL of wiki (eg, ''<>'') | +|[[$:/info/url/hostname]] |<<.from-version "5.1.14">> Hostname portion of URL of wiki (eg, ''<>'') | +|[[$:/info/url/origin]] |<<.from-version "5.1.14">> Origin portion of URL of wiki (eg, ''<>'') | +|[[$:/info/url/pathname]] |<<.from-version "5.1.14">> Pathname portion of URL of wiki (eg, ''<>'') | +|[[$:/info/url/port]] |<<.from-version "5.1.14">> Port portion of URL of wiki (eg, ''<>'') | +|[[$:/info/url/protocol]] |<<.from-version "5.1.14">> Protocol portion of URL of wiki (eg, ''<>'') | +|[[$:/info/url/search]] |<<.from-version "5.1.14">> Search portion of URL of wiki (eg, ''<>'') |