Add support for custom password prompts

This commit is contained in:
Jermolene 2014-10-06 10:02:34 +01:00
parent 67db9d57a2
commit 0c8e538077
3 changed files with 54 additions and 2 deletions

View File

@ -1244,10 +1244,14 @@ Decrypt any tiddlers stored within the element with the ID "encryptedArea". The
$tw.boot.decryptEncryptedTiddlers = function(callback) {
var encryptedArea = document.getElementById("encryptedStoreArea");
if(encryptedArea) {
var encryptedText = encryptedArea.innerHTML;
var encryptedText = encryptedArea.innerHTML,
prompt = "Enter a password to decrypt this TiddlyWiki";
// Prompt for the password
if($tw.utils.hop($tw.boot,"encryptionPrompts")) {
prompt = $tw.boot.encryptionPrompts.decrypt;
}
$tw.passwordPrompt.createPrompt({
serviceName: "Enter a password to decrypt this TiddlyWiki",
serviceName: prompt,
noUserName: true,
submitText: "Decrypt",
callback: function(data) {

View File

@ -0,0 +1,15 @@
title: How to customise the password prompt
tags: howto
created: 20141006085526118
modified: 20141006085526118
You can customise the text and appearance of the password prompt that is displayed when encrypted TiddlyWiki files are first opened.
To do so, create a tiddler tagged {{$:/core/wiki/rawmarkup|$:/core/ui/TagTemplate}} containing:
# A JavaScript `<script>` tag containing code to override the configuration variable `$tw.boot.encryptionPrompts.decrypt`
# CSS `<style>` definitions targeting the `tc-password-wrapper` class to apply styles to the form
Raw markup tiddlers are spliced into the top of the standalone HTML file, and are executed before the boot prefix and boot kernel.
See $:/PathEncryptionPrompt for an example.

View File

@ -0,0 +1,33 @@
title: $:/PatchEncryptionPrompt
tags: $:/core/wiki/rawmarkup
<script>
window.$tw = window.$tw || Object.create(null);
$tw.boot = $tw.boot || Object.create(null);
$tw.boot.encryptionPrompts = {
decrypt: "Decrypt this TiddlyWiki by entering the password"
};
</script>
<style>
body .tc-password-wrapper {
background-color: rgb(183, 197, 235);
border: 8px solid rgb(152, 164, 197);
}
body .tc-password-wrapper form {
text-align: center;
}
body .tc-password-wrapper h1 {
padding-bottom: 8px;
}
body .tc-password-wrapper input {
width: auto;
}
</style>