Ticket #756: bakedoptions2.patch
| File bakedoptions2.patch, 9.5 KB (added by FND, 3 years ago) |
|---|
-
shadows/split.recipe
5 5 shadow: StyleSheetLayout.tiddler 6 6 shadow: StyleSheetLocale.tiddler 7 7 shadow: StyleSheetPrint.tiddler 8 shadow: SystemSettings.tiddler 8 9 shadow: PageTemplate.tiddler 9 10 shadow: ViewTemplate.tiddler 10 11 shadow: EditTemplate.tiddler -
shadows/SystemSettings.tiddler
1 <div title="SystemSettings"> 2 <pre>|''chkAnimate_cookie:''|false| 3 |''chkAutoSave:''|false| 4 |''chkBackstage_cookie:''|false| 5 |''chkCaseSensitiveSearch:''|false| 6 |''chkConfirmDelete:''|true| 7 |''chkDisplayInstrumentation:''|false| 8 |''chkForceMinorUpdate:''|false| 9 |''chkGenerateAnRssFeed:''|false| 10 |''chkHttpReadOnly:''|true| 11 |''chkIncrementalSearch:''|true| 12 |''chkInsertTabs:''|false| 13 |''chkOpenInNewWindow:''|true| 14 |''chkRegExpSearch:''|false| 15 |''chkSaveBackups:''|true| 16 |''chkSaveEmptyTemplate:''|false| 17 |''chkSideBarTabs_cookie:''|false| 18 |''chkSliderOptionsPanel_cookie:''|false| 19 |''chkToggleLinks:''|false| 20 |''chkUsePreForStorage:''|true| 21 |''txtBackupFolder:''|| 22 |''txtEditorFocus:''|text| 23 |''txtFileSystemCharSet:''|UTF-8| 24 |''txtMainTab_cookie:''|More| 25 |''txtMaxEditRows:''|30| 26 |''txtMoreTab_cookie:''|Missing| 27 |''txtTheme:''|| 28 |''txtUserName:''|YourName|</pre> 29 </div> 30 No newline at end of file -
js/TiddlyWiki.js
151 151 return textOut.join(""); 152 152 }; 153 153 154 TiddlyWiki.prototype.slicesRE = /(?:^([\'\/]{0,2})~?([\.\w]+)\:\1 \s*([^\n]+)\s*$)|(?:^\|([\'\/]{0,2})~?([\.\w]+)\:?\4\|\s*([^\|\n]+)\s*\|$)/gm;154 TiddlyWiki.prototype.slicesRE = /(?:^([\'\/]{0,2})~?([\.\w]+)\:\1[\t\x20]*([^\n]*)[\t\x20]*$)|(?:^\|([\'\/]{0,2})~?([\.\w]+)\:?\4\|[\t\x20]*([^\|\n]*)[\t\x20]*\|$)/gm; 155 155 156 156 // @internal 157 157 TiddlyWiki.prototype.calcAllSlices = function(title) -
js/main.js
33 33 story = new Story("tiddlerDisplay","tiddler"); 34 34 addEvent(document,"click",Popup.onDocumentClick); 35 35 saveTest(); 36 loadOptionsCookie();37 36 for(var s=0; s<config.notifyTiddlers.length; s++) 38 37 store.addNotification(config.notifyTiddlers[s].name,config.notifyTiddlers[s].notify); 39 38 t1 = new Date(); 40 39 loadShadowTiddlers(); 41 40 t2 = new Date(); 42 41 store.loadFromDiv("storeArea","store",true); 42 loadOptionsCookie(); 43 43 t3 = new Date(); 44 44 invokeParamifier(params,"onload"); 45 45 t4 = new Date(); -
js/Options.js
4 4 5 5 config.optionHandlers = { 6 6 'txt': { 7 get: function(name) {return encodeCookie(config.options[name].toString());},8 set: function(name,value) {config.options[name] = decodeCookie(value);}7 get: function(name) {return config.options[name].toString();}, 8 set: function(name,value) {config.options[name] = value;} 9 9 }, 10 10 'chk': { 11 11 get: function(name) {return config.options[name] ? "true" : "false";}, … … 13 13 } 14 14 }; 15 15 16 function loadOptionsCookie()16 function setOption(name,value) 17 17 { 18 var optType = name.substr(0,3); 19 if(config.optionHandlers[optType] && config.optionHandlers[optType].set) 20 config.optionHandlers[optType].set(name,value); 21 } 22 23 // Gets the value of an option as a string. Most code should just read from config.options.* directly 24 function getOption(name) 25 { 26 var optType = name.substr(0,3); 27 if(config.optionHandlers[optType] && config.optionHandlers[optType].get) 28 return config.optionHandlers[optType].get(name); 29 else 30 return null; 31 } 32 33 //# Loads up config.options from cookies and SystemSettings 34 function initialiseOptions() 35 { 18 36 if(safeMode) 19 37 return; 38 loadSystemSettings(); 39 loadCookies(); 40 } 41 // Deprecated name for backwards compatibility 42 var loadOptionsCookie = initialiseOptions; 43 44 function loadCookies() 45 { 46 var cookies = {}; 20 47 var cookies = document.cookie.split(";"); 21 48 for(var c=0; c<cookies.length; c++) { 22 49 var p = cookies[c].indexOf("="); 23 50 if(p != -1) { 24 51 var name = cookies[c].substr(0,p).trim(); 25 52 var value = cookies[c].substr(p+1).trim(); 26 var optType = name.substr(0,3); 27 if(config.optionHandlers[optType] && config.optionHandlers[optType].set) 28 config.optionHandlers[optType].set(name,value); 53 if(config.optionSource[name] == 'cookie') 54 setOption(name,decodeCookie(value)); 29 55 } 30 56 } 31 57 } 32 58 33 function saveOptionCookie(name)59 function loadSystemSettings() 34 60 { 61 var settings = store.calcAllSlices("SystemSettings"); 62 for(var key in settings) { 63 var splitPos = key.indexOf('_'); 64 var name = key; 65 var source = "setting"; 66 if(splitPos !== -1) { 67 source = key.substr(splitPos+1); 68 name = key.substr(0,splitPos); 69 } 70 setOption(name,settings[key]); 71 config.optionSource[name] = source; 72 } 73 } 74 75 function onSystemSettingsChange() 76 { 77 if(!startingUp) { 78 loadSystemSettings(); 79 } 80 } 81 82 // Saves the named option in a cookie or SystemSettings as appropriate 83 function saveOption(name) 84 { 35 85 if(safeMode) 36 86 return; 37 var c = name + "="; 38 var optType = name.substr(0,3); 39 if(config.optionHandlers[optType] && config.optionHandlers[optType].get) 40 c += config.optionHandlers[optType].get(name); 87 if(config.optionSource[name] == 'cookie') { 88 if(store.getTiddlerSlice("SystemSettings",name + "_cookie") == getOption(name)) { 89 removeCookie(name); 90 } else { 91 saveCookie(name); 92 } 93 } else { 94 saveSystemSetting(name); 95 } 96 } 97 // Deprecated names for backwards compatibility 98 var saveOptionCookie = saveOption; 99 100 function saveCookie(name) 101 { 102 var c = name + "=" + encodeCookie(getOption(name)); 41 103 c += "; expires=Fri, 1 Jan 2038 12:00:00 UTC; path=/"; 42 104 document.cookie = c; 43 105 } 44 106 107 function removeCookie(name) 108 { 109 document.cookie = name + "=; expires=Thu, 01-Jan-1970 00:00:01 UTC; path=/;"; 110 } 111 112 function saveSystemSetting(name) 113 { 114 var settings = store.calcAllSlices("SystemSettings"); 115 var key; 116 for(key in config.options) { 117 if(config.optionSource[key] == "setting") { 118 var value = getOption(key); 119 value = value == null ? "" : value; 120 if(settings[key] !== value) 121 settings[key] = value; 122 } 123 } 124 var text = []; 125 for(key in settings) { 126 text.push("|''%0:''|%1|".format([key,settings[key]])); 127 } 128 text.sort(); 129 store.saveTiddler("SystemSettings","SystemSettings",text.join("\n"),"System",new Date()); 130 autoSaveChanges(); 131 } 132 133 //# Flatten cookies to ANSI character set by substituting html character entities for non-ANSI characters 45 134 function encodeCookie(s) 46 135 { 47 136 return escape(convertUnicodeToHtmlEntities(s)); 48 137 } 49 138 139 //# Decode any html character entities to their unicode equivalent 50 140 function decodeCookie(s) 51 141 { 52 142 s = unescape(s); … … 54 144 return s.replace(re,function($0) {return String.fromCharCode(eval($0.replace(/[&#;]/g,"")));}); 55 145 } 56 146 57 58 147 config.macros.option.genericCreate = function(place,type,opt,className,desc) 59 148 { 60 149 var typeInfo = config.macros.option.types[type]; -
js/Config.js
63 63 }; 64 64 config.optionsDesc = {}; 65 65 66 //# config.optionSource["chkAnimate"] can be: 67 //# cookie: the option gets stored in a cookie, with the default value coming from SystemSettings 68 //# volatile: the option isn't persisted at all, and reverts to the default specified in SystemSettings when the document is reloaded 69 //# setting: the option is stored in the SystemSettings tiddler 70 //# The default is "setting" 71 config.optionSource = {}; 72 66 73 // Default tiddler templates 67 74 var DEFAULT_VIEW_TEMPLATE = 1; 68 75 var DEFAULT_EDIT_TEMPLATE = 2; -
js/Lingo.js
462 462 StyleSheetLayout: "This shadow tiddler contains CSS definitions related to the layout of page elements. ''DO NOT EDIT THIS TIDDLER'', instead make your changes in the StyleSheet shadow tiddler", 463 463 StyleSheetLocale: "This shadow tiddler contains CSS definitions related to the translation locale", 464 464 StyleSheetPrint: "This shadow tiddler contains CSS definitions for printing", 465 SystemSettings: "This tiddler is used to store configuration options for this TiddlyWiki document", 465 466 TabAll: "This shadow tiddler contains the contents of the 'All' tab in the right-hand sidebar", 466 467 TabMore: "This shadow tiddler contains the contents of the 'More' tab in the right-hand sidebar", 467 468 TabMoreMissing: "This shadow tiddler contains the contents of the 'Missing' tab in the right-hand sidebar", … … 472 473 ToolbarCommands: "This shadow tiddler determines which commands are shown in tiddler toolbars", 473 474 ViewTemplate: "The HTML template in this shadow tiddler determines how tiddlers look" 474 475 }); 475 -
js/Refresh.js
4 4 5 5 //# List of notification functions to be called when certain tiddlers are changed or deleted 6 6 config.notifyTiddlers = [ 7 {name: "SystemSettings", notify: onSystemSettingsChange}, 7 8 {name: "StyleSheetLayout", notify: refreshStyles}, 8 9 {name: "StyleSheetColors", notify: refreshStyles}, 9 10 {name: "StyleSheet", notify: refreshStyles},
