From 2c367c5476da70ce9c2b37838febcdf437b9aca4 Mon Sep 17 00:00:00 2001
From: Andreas Abeck
Date: Wed, 18 Mar 2015 18:52:33 +0100
Subject: [PATCH 1/4] added localisation for encryption dialog & de-DE
translation
---
boot/boot.js | 28 ++++++++++++++++++----------
core/language/en-GB/Misc.multids | 6 ++++++
core/modules/startup/password.js | 2 +-
languages/de-DE/Misc.multids | 6 ++++++
4 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/boot/boot.js b/boot/boot.js
index f9f8d16f2..7161da3bd 100644
--- a/boot/boot.js
+++ b/boot/boot.js
@@ -490,20 +490,28 @@ $tw.utils.PasswordPrompt.prototype.createPrompt = function(options) {
children = [dm("h1",{text: options.serviceName})];
if(!options.noUserName) {
children.push(dm("input",{
- attributes: {type: "text", name: "username", placeholder: "Username"}
+ attributes: {type: "text", name: "username", placeholder: $tw.language.getString("Encryption/Username")}
}));
}
children.push(dm("input",{
- attributes: {type: "password", name: "password", placeholder: "Password"}
+ attributes: {
+ type: "password",
+ name: "password",
+ placeholder: ( $tw.language == undefined ? "Password" : $tw.language.getString("Encryption/Password") )
+ }
}));
if(options.repeatPassword) {
children.push(dm("input",{
- attributes: {type: "password", name: "password2", placeholder: "Repeat password"}
+ attributes: {
+ type: "password",
+ name: "password2",
+ placeholder: $tw.language.getString("Encryption/RepeatPassword")
+ }
}));
}
if(options.canCancel) {
children.push(dm("button",{
- text: "Cancel",
+ text: $tw.language.getString("Encryption/Cancel"),
eventListeners: [{
name: "click",
handlerFunction: function(event) {
@@ -537,7 +545,7 @@ $tw.utils.PasswordPrompt.prototype.createPrompt = function(options) {
});
// Check that the passwords match
if(options.repeatPassword && data.password !== data.password2) {
- alert("Passwords do not match");
+ alert($tw.language.getString("Encryption/PasswordNoMatch"));
} else {
// Call the callback
if(options.callback(data)) {
@@ -551,7 +559,7 @@ $tw.utils.PasswordPrompt.prototype.createPrompt = function(options) {
}
});
}
- }
+ }
event.preventDefault();
return false;
},true);
@@ -1925,9 +1933,9 @@ $tw.boot.isStartupTaskEligible = function(taskModule) {
Global Hooks mechanism which allows plugins to modify default functionality
*/
$tw.hooks = $tw.hooks || { names: {}};
-
+
/*
-Add hooks to the hashmap
+Add hooks to the hashmap
*/
$tw.hooks.addHook = function(hookName,definition) {
if($tw.utils.hop($tw.hooks.names,hookName)) {
@@ -1937,9 +1945,9 @@ $tw.hooks.addHook = function(hookName,definition) {
$tw.hooks.names[hookName] = [definition];
}
};
-
+
/*
-Invoke the hook by key
+Invoke the hook by key
*/
$tw.hooks.invokeHook = function(hookName, value) {
if($tw.utils.hop($tw.hooks.names,hookName)) {
diff --git a/core/language/en-GB/Misc.multids b/core/language/en-GB/Misc.multids
index d165ce99d..f56540882 100644
--- a/core/language/en-GB/Misc.multids
+++ b/core/language/en-GB/Misc.multids
@@ -10,8 +10,14 @@ ConfirmOverwriteTiddler: Do you wish to overwrite the tiddler "<$text text=<>/>"?
DefaultNewTiddlerTitle: New Tiddler
DropMessage: Drop here (or use the 'Escape' key to cancel)
+Encryption/Cancel: Cancel
Encryption/ConfirmClearPassword: Do you wish to clear the password? This will remove the encryption applied when saving this wiki
Encryption/PromptSetPassword: Set a new password for this TiddlyWiki
+Encryption/Username: Username
+Encryption/Password: Password
+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 (`.`)
MissingTiddler/Hint: Missing tiddler "<$text text=<>/>" - click {{$:/core/images/edit-button}} to create
OfficialPluginLibrary: Official ~TiddlyWiki Plugin Library
diff --git a/core/modules/startup/password.js b/core/modules/startup/password.js
index 6205b3e7d..5e8bd5352 100644
--- a/core/modules/startup/password.js
+++ b/core/modules/startup/password.js
@@ -23,7 +23,7 @@ exports.startup = function() {
$tw.passwordPrompt.createPrompt({
serviceName: $tw.language.getString("Encryption/PromptSetPassword"),
noUserName: true,
- submitText: "Set password",
+ submitText: $tw.language.getString("Encryption/SetPassword"),
canCancel: true,
repeatPassword: true,
callback: function(data) {
diff --git a/languages/de-DE/Misc.multids b/languages/de-DE/Misc.multids
index 0dd8a6afc..19967cbcb 100644
--- a/languages/de-DE/Misc.multids
+++ b/languages/de-DE/Misc.multids
@@ -10,8 +10,14 @@ ConfirmOverwriteTiddler: Tiddler: "<$text text=<>/>" existiert! OK übers
ConfirmEditShadowTiddler: Sie sind dabei, einen Schatten-Tiddler zu verändern. Zukünftige, automatische Anpassungen werden dadurch unterdrückt. Sie können Ihre Änderungen rückgängig machen, indem Sie diesen Tiddler wieder löschen. Wollen Sie den Tiddler: "<$text text=<>/>" ändern?
DefaultNewTiddlerTitle: Neuer Tiddler
DropMessage: Hierher ziehen (oder Escape um abzubrechen)
+Encryption/Cancel: Abbrechen
Encryption/ConfirmClearPassword: Wollen Sie das Passwort löschen? Damit wird die Verschlüsselung beim nächsten Speichervorgang abgeschalten!
Encryption/PromptSetPassword: Der TiddlyWiki Inhalt wird mit dem nächsten Speichern verschlüsselt!
+Encryption/Username: Benutzername
+Encryption/Password: Passwort
+Encryption/RepeatPassword: Passwort wiederholen
+Encryption/PasswordNoMatch: Passwörter stimmen nicht überein
+Encryption/SetPassword: Passwort setzen
InvalidFieldName: Das Feld: "<$text text=<>/>" enthält illegale Zeichen. Felder müssen klein geschrieben werden. Erlaubte Sonderzeichen sind: Zahlen, Unterstrich (`_`), Minus (`-`) und Punkt (`.`).
MissingTiddler/Hint: Fehlender Tiddler "<$text text=<>/>" - klicken Sie {{$:/core/images/edit-button}} um ihn zu erzeugen.
OfficialPluginLibrary: Offizielles ~TiddlyWiki Plugin Verzeichnis
From 00f35fe41a7e6a030716daede793346356dfd9ae Mon Sep 17 00:00:00 2001
From: Jermolene
Date: Sat, 21 Mar 2015 14:17:42 +0000
Subject: [PATCH 2/4] Don't HTML encode single quotes
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
They don’t get automatically decoded when the browser reads the
resulting HTML. So, instead, we’ll solve
1e9e1a1fdc260bd8a19fa5d244590dabb5dfd7f5 by switching to double quotes
for attribute values.
---
core/modules/utils/fakedom.js | 4 ++--
core/modules/utils/utils.js | 4 ++--
editions/test/tiddlers/tests/test-widget.js | 16 ++++++++--------
editions/test/tiddlers/tests/test-wikitext.js | 2 +-
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/core/modules/utils/fakedom.js b/core/modules/utils/fakedom.js
index 13f162f69..0d6ea6d42 100755
--- a/core/modules/utils/fakedom.js
+++ b/core/modules/utils/fakedom.js
@@ -134,7 +134,7 @@ Object.defineProperty(TW_Element.prototype, "outerHTML", {
for(a=0; a 0) {
- output.push(" style='",style.join(""),"'")
+ output.push(" style=\"",style.join(""),"\"")
}
}
output.push(">");
diff --git a/core/modules/utils/utils.js b/core/modules/utils/utils.js
index 35bc1ff32..eed24a840 100644
--- a/core/modules/utils/utils.js
+++ b/core/modules/utils/utils.js
@@ -363,10 +363,10 @@ exports.getRelativeDate = function(delta) {
};
};
-// Convert & to "&", < to "<", > to ">", " to """ ' to "'"
+// Convert & to "&", < to "<", > to ">", " to """
exports.htmlEncode = function(s) {
if(s) {
- return s.toString().replace(/&/mg,"&").replace(//mg,">").replace(/\"/mg,""").replace(/\'/mg,"'");
+ return s.toString().replace(/&/mg,"&").replace(//mg,">").replace(/\"/mg,""");
} else {
return "";
}
diff --git a/editions/test/tiddlers/tests/test-widget.js b/editions/test/tiddlers/tests/test-widget.js
index 95536fb63..a1ad79823 100755
--- a/editions/test/tiddlers/tests/test-widget.js
+++ b/editions/test/tiddlers/tests/test-widget.js
@@ -69,7 +69,7 @@ describe("Widget module", function() {
var wrapper = renderWidgetNode(widgetNode);
describe("should render", function() {
// Test the rendering
- expect(wrapper.innerHTML).toBe("A text node
and the content of a DIV
and an inner DIV
and back in the outer DIV
");
+ expect(wrapper.innerHTML).toBe("A text node
and the content of a DIV
and an inner DIV
and back in the outer DIV
");
// Test the sequence numbers in the DOM
expect(wrapper.sequenceNumber).toBe(0);
expect(wrapper.children[0].sequenceNumber).toBe(1);
@@ -113,7 +113,7 @@ describe("Widget module", function() {
var wrapper = renderWidgetNode(widgetNode);
describe("should render", function() {
// Test the rendering
- expect(wrapper.innerHTML).toBe("A text node
and the content of a DIV
and an inner DIV
and back in the outer DIVthe quick brown fox
the quick brown fox");
+ expect(wrapper.innerHTML).toBe("A text node
and the content of a DIV
and an inner DIV
and back in the outer DIVthe quick brown fox
the quick brown fox");
// Test the sequence numbers in the DOM
expect(wrapper.sequenceNumber).toBe(0);
expect(wrapper.children[0].sequenceNumber).toBe(1);
@@ -131,7 +131,7 @@ describe("Widget module", function() {
refreshWidgetNode(widgetNode,wrapper,["TiddlerOne"]);
describe("should refresh", function() {
// Test the refreshing
- expect(wrapper.innerHTML).toBe("A text node
and the content of a DIV
and an inner DIV
and back in the outer DIVjumps over the lazy dog
jumps over the lazy dog");
+ expect(wrapper.innerHTML).toBe("A text node
and the content of a DIV
and an inner DIV
and back in the outer DIVjumps over the lazy dog
jumps over the lazy dog");
// Test the sequence numbers in the DOM
expect(wrapper.sequenceNumber).toBe(0);
expect(wrapper.children[0].sequenceNumber).toBe(1);
@@ -163,7 +163,7 @@ describe("Widget module", function() {
var wrapper = renderWidgetNode(widgetNode);
describe("should detect the recursion", function() {
// Test the rendering
- expect(wrapper.innerHTML).toBe("Recursive transclusion error in transclude widget\n");
+ expect(wrapper.innerHTML).toBe("Recursive transclusion error in transclude widget\n");
});
});
@@ -171,12 +171,12 @@ describe("Widget module", function() {
it("should deal with SVG elements", function() {
var wiki = new $tw.Wiki();
// Construct the widget node
- var text = "\n";
+ var text = "\n";
var widgetNode = createWidgetNode(parseText(text,wiki,{parseAsInline:true}),wiki);
// Render the widget node to the DOM
var wrapper = renderWidgetNode(widgetNode);
// Test the rendering
- expect(wrapper.innerHTML).toBe("\n");
+ expect(wrapper.innerHTML).toBe("\n");
expect(wrapper.firstChild.namespaceURI).toBe("http://www.w3.org/2000/svg");
});
@@ -268,7 +268,7 @@ describe("Widget module", function() {
// Render the widget node to the DOM
var wrapper = renderWidgetNode(widgetNode);
// Test the rendering
- expect(wrapper.innerHTML).toBe("
Content
");
+ expect(wrapper.innerHTML).toBe("
Content
");
});
it("should deal with built-in macros", function() {
@@ -283,7 +283,7 @@ describe("Widget module", function() {
// Render the widget node to the DOM
var wrapper = renderWidgetNode(widgetNode);
// Test the rendering
- expect(wrapper.innerHTML).toBe("
-
-» [[transcludes|http://tiddlywiki.com/#Transclusion%20in%20WikiText]] tiddler `Foo`
-» `Foo` with template `Bar`
-» template `Foo` for `CurrentTiddler`
-» field `bar` of `Foo`
-» field `bar` of `CurrentTiddler`
-» `index` of datatiddler `Foo`
-» `index` of `CurrentTiddler` (=data)
-» list of tiddlers tagged `Foo`
-» same using template `Bar`
-