diff --git a/core/language/en-GB/Misc.multids b/core/language/en-GB/Misc.multids index f2e702333..6d91b8d53 100644 --- a/core/language/en-GB/Misc.multids +++ b/core/language/en-GB/Misc.multids @@ -20,6 +20,7 @@ Encryption/RepeatPassword: Repeat password Encryption/PasswordNoMatch: Passwords do not match Encryption/SetPassword: Set password InvalidFieldName: Illegal characters in field name "<$text text=<>/>". Fields can only contain lowercase letters, digits and the characters underscore (`_`), hyphen (`-`) and period (`.`) +LazyLoadingWarning:

Loading external text from ''<$text text={{!!_canonical_uri}}/>''

If this message doesn't disappear you may be using a browser that doesn't support external text in this configuration. See http://tiddlywiki.com/#ExternalText

MissingTiddler/Hint: Missing tiddler "<$text text=<>/>" - click {{$:/core/images/edit-button}} to create OfficialPluginLibrary: Official ~TiddlyWiki Plugin Library PluginReloadWarning: Please save {{$:/core/ui/Buttons/save-wiki}} and reload {{$:/core/ui/Buttons/refresh}} to allow changes to plugins to take effect diff --git a/core/modules/language.js b/core/modules/language.js index cb7096ef1..5e44d6696 100644 --- a/core/modules/language.js +++ b/core/modules/language.js @@ -22,7 +22,7 @@ function Language(options) { } /* -Return a single translateable string. The title is automatically prefixed with "$:/language/" +Return a wikified translateable string. The title is automatically prefixed with "$:/language/" Options include: variables: optional hashmap of variables to supply to the language wikification */ @@ -32,6 +32,14 @@ Language.prototype.getString = function(title,options) { return this.wiki.renderTiddler("text/plain",title,{variables: options.variables}); }; +/* +Return a raw, unwikified translateable string. The title is automatically prefixed with "$:/language/" +*/ +Language.prototype.getRawString = function(title) { + title = "$:/language/" + title; + return this.wiki.getTiddlerText(title); +}; + exports.Language = Language; })(); diff --git a/core/modules/parsers/wikiparser/wikiparser.js b/core/modules/parsers/wikiparser/wikiparser.js index dd28b2586..736e2dbdf 100644 --- a/core/modules/parsers/wikiparser/wikiparser.js +++ b/core/modules/parsers/wikiparser/wikiparser.js @@ -28,20 +28,9 @@ var WikiParser = function(type,text,options) { this.wiki = options.wiki; var self = this; // Check for an externally linked tiddler - if($tw.browser && options._canonical_uri) { - $tw.utils.httpRequest({ - url: options._canonical_uri, - type: "GET", - callback: function(err,data) { - if(!err) { - var tiddlers = self.wiki.deserializeTiddlers(".tid",data,self.wiki.getCreationFields()) - if(tiddlers) { - self.wiki.addTiddlers(tiddlers); - } - } - } - }); - text = "Loading external text from ''" + options._canonical_uri + "''\n\nIf this message doesn't disappear you may be using a browser that doesn't support external text in this configuration. See http://tiddlywiki.com/#ExternalText"; + if($tw.browser && (text || "") === "" && options._canonical_uri) { + this.loadRemoteTiddler(options._canonical_uri); + text = $tw.language.getRawString("LazyLoadingWarning"); } // Initialise the classes if we don't have them already if(!this.pragmaRuleClasses) { @@ -79,6 +68,27 @@ var WikiParser = function(type,text,options) { // Return the parse tree }; +/* +*/ +WikiParser.prototype.loadRemoteTiddler = function(url) { + var self = this; + $tw.utils.httpRequest({ + url: url, + type: "GET", + callback: function(err,data) { + if(!err) { + var tiddlers = self.wiki.deserializeTiddlers(".tid",data,self.wiki.getCreationFields()); + $tw.utils.each(tiddlers,function(tiddler) { + tiddler["_canonical_uri"] = url; + }); + if(tiddlers) { + self.wiki.addTiddlers(tiddlers); + } + } + } + }); +}; + /* */ WikiParser.prototype.setupRules = function(proto,configPrefix) {