Ticket #756: bakedoptions3.patch
| File bakedoptions3.patch, 10.1 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: Timeline 25 txtMaxEditRows: 30 26 txtMoreTab_cookie: Shadow 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; 20 var cookies = document.cookie.split(";"); 21 for(var c=0; c<cookies.length; c++) { 22 var p = cookies[c].indexOf("="); 38 loadSystemSettings(); 39 loadCookies(); 40 } 41 // Deprecated name for backwards compatibility 42 var loadOptionsCookie = initialiseOptions; 43 44 function getCookies() 45 { 46 var cookieList = document.cookie.split(";"); 47 var cookies = {}; 48 for(var c=0; c<cookieList.length; c++) { 49 var p = cookieList[c].indexOf("="); 23 50 if(p != -1) { 24 var name = cookies[c].substr(0,p).trim(); 25 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); 51 var name = cookieList[c].substr(0,p).trim(); 52 var value = cookieList[c].substr(p+1).trim() 53 cookies[name] = decodeCookie(value); 29 54 } 30 55 } 56 return cookies; 31 57 } 32 58 33 function saveOptionCookie(name)59 function loadCookies() 34 60 { 61 var cookies = getCookies(); 62 if(cookies["TiddlyWiki"]) { 63 cookies = cookies["TiddlyWiki"].decodeHashMap(); 64 } 65 for(var n in cookies) { 66 if(config.optionSource[n] == 'cookie') 67 setOption(n,cookies[n]); 68 } 69 } 70 71 function loadSystemSettings() 72 { 73 var settings = store.calcAllSlices("SystemSettings"); 74 for(var key in settings) { 75 var splitPos = key.indexOf('_'); 76 var name = key; 77 var source = "setting"; 78 if(splitPos !== -1) { 79 source = key.substr(splitPos+1); 80 name = key.substr(0,splitPos); 81 } 82 setOption(name,settings[key]); 83 config.optionSource[name] = source; 84 } 85 } 86 87 function onSystemSettingsChange() 88 { 89 if(!startingUp) { 90 loadSystemSettings(); 91 } 92 } 93 94 // Saves the named option in a cookie or SystemSettings as appropriate 95 function saveOption(name) 96 { 35 97 if(safeMode) 36 98 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); 41 c += "; expires=Fri, 1 Jan 2038 12:00:00 UTC; path=/"; 99 if(config.optionSource[name] == 'cookie') { 100 saveCookie(name); 101 } else { 102 saveSystemSetting(name); 103 } 104 } 105 // Deprecated names for backwards compatibility 106 var saveOptionCookie = saveOption; 107 108 function saveCookie(name) 109 { 110 var cookies = {}; 111 for(var key in config.options) { 112 if(config.optionSource[key] == "cookie") { 113 var value = getOption(key); 114 value = value == null ? "" : value; 115 cookies[key] = value; 116 } 117 } 118 var c = "TiddlyWiki=" + encodeCookie(String.encodeHashMap(cookies)) + "; expires=Fri, 1 Jan 2038 12:00:00 UTC; path=/"; 42 119 document.cookie = c; 120 var cookies = getCookies(); 121 for(var c in cookies) { 122 if(c != "TiddlyWiki") 123 removeCookie(c); 124 } 43 125 } 44 126 127 function removeCookie(name) 128 { 129 document.cookie = name + "=; expires=Thu, 01-Jan-1970 00:00:01 UTC; path=/;"; 130 } 131 132 function saveSystemSetting(name) 133 { 134 var settings = store.calcAllSlices("SystemSettings"); 135 var key; 136 for(key in config.options) { 137 if(config.optionSource[key] == undefined || config.optionSource[key] == "setting") { 138 var value = getOption(key); 139 value = value == null ? "" : value; 140 if(settings[key] !== value) 141 settings[key] = value; 142 } 143 } 144 var text = []; 145 for(key in settings) { 146 text.push("%0: %1".format([key,settings[key]])); 147 } 148 text.sort(); 149 store.saveTiddler("SystemSettings","SystemSettings",text.join("\n"),"System",new Date()); 150 autoSaveChanges(); 151 } 152 153 //# Flatten cookies to ANSI character set by substituting html character entities for non-ANSI characters 45 154 function encodeCookie(s) 46 155 { 47 156 return escape(convertUnicodeToHtmlEntities(s)); 48 157 } 49 158 159 //# Decode any html character entities to their unicode equivalent 50 160 function decodeCookie(s) 51 161 { 52 162 s = unescape(s); … … 54 164 return s.replace(re,function($0) {return String.fromCharCode(eval($0.replace(/[&#;]/g,"")));}); 55 165 } 56 166 57 58 167 config.macros.option.genericCreate = function(place,type,opt,className,desc) 59 168 { 60 169 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},
