From: pho Date: Fri, 11 Jul 2008 06:56:40 +0000 (+0900) Subject: configuration X-Git-Url: https://git.cielonegro.org/gitweb.cgi?a=commitdiff_plain;h=619d36dbcf0bc8846da44fcaa5fafc0004adb567;p=Rakka.git configuration darcs-hash:20080711065640-62b54-376f38aa9d63c233cd0fc578b369ad295b954190.gz --- diff --git a/defaultPages/StyleSheet/CieloNegro.xml b/defaultPages/StyleSheet/CieloNegro.xml index 4e0a2ff..ca98846 100644 --- a/defaultPages/StyleSheet/CieloNegro.xml +++ b/defaultPages/StyleSheet/CieloNegro.xml @@ -198,6 +198,9 @@ table.pageEditor { width: 50%; margin-left: 1em; } +.pageEditor textarea { + height: 5em; +} .pageEditor textarea.summary { height: 5em; } diff --git a/defaultPages/StyleSheet/Default.xml b/defaultPages/StyleSheet/Default.xml index f67bf2f..6b5f536 100644 --- a/defaultPages/StyleSheet/Default.xml +++ b/defaultPages/StyleSheet/Default.xml @@ -168,6 +168,10 @@ option { padding: 1px; } +table.configPanel { + width: 100%; +} + table.pageEditor { width: 100%; } @@ -198,6 +202,9 @@ table.pageEditor { width: 50%; margin-left: 1em; } +.pageEditor textarea { + height: 5em; +} .pageEditor textarea.summary { height: 5em; } diff --git a/js/systemConfig.js b/js/systemConfig.js index 05a3a56..e9254e3 100644 --- a/js/systemConfig.js +++ b/js/systemConfig.js @@ -1,36 +1,63 @@ (function () { - var identityDecoder = function (src) { - return src; - }; + var identityDecoder = function (src) { + return src; + }; - var mapDecoder = function (src) { - var map = {}; - var lines = src.split(/\n/); + var identityEncoder = function (src) { + return src; + }; - $.each(lines, function () { - var m = this.match(/^(\S+)\s+(\S+)$/); + var mapDecoder = function (src) { + var map = {}; + var lines = src.split(/\n/); - map[ m[1] ] = m[2]; - }); + $.each(lines, function () { + var m = this.match(/^(\S+)\s+(\S+)$/); - return map; - }; + map[ m[1] ] = m[2]; + }); - var boolDecoder = function (src) { - return src == "*"; - }; + return map; + }; - var decoder_of = { - siteName : identityDecoder, - baseURI : identityDecoder, - defaultPage: identityDecoder, - styleSheet : identityDecoder, - languages : mapDecoder, - globalLock : boolDecoder - }; + var mapEncoder = function (map) { + var lines = []; + + $.each(map, function (key) { + lines.push(key + " " + this); + }); + + return lines.join("\n"); + }; + + var boolDecoder = function (src) { + return src == "*"; + }; + + var boolEncoder = function (bool) { + return bool ? "*" : ""; + }; + + var decoder_of = { + siteName : identityDecoder, + baseURI : identityDecoder, + defaultPage: identityDecoder, + styleSheet : identityDecoder, + languages : mapDecoder, + globalLock : boolDecoder + }; + + var encoder_of = { + siteName : identityEncoder, + baseURI : identityEncoder, + defaultPage: identityEncoder, + styleSheet : identityEncoder, + languages : mapEncoder, + globalLock : boolEncoder + }; - var cachedConf = null; + var cachedConf = null; Rakka.getSystemConfig = function () { if (cachedConf != null) { @@ -65,6 +92,76 @@ return conf; }; + Rakka.showConfigPanel = function () { + var conf = Rakka.getSystemConfig(); + var $area = Rakka.switchScreen(); + + $area.append($.H1({}, "Configuration")); + + var fldSiteName + = $.INPUT({type: "text", value: conf.siteName}); + + var fldBaseURI + = $.INPUT({type: "text", value: conf.baseURI}); + + var fldDefaultPage + = $.INPUT({type: "text", value: conf.defaultPage}); + + var fldStyleSheet + = $.INPUT({type: "text", value: conf.styleSheet}); + + var fldLanguages + = $.TEXTAREA({value: encoder_of.languages(conf.languages)}); + + var chkGlobalLock + = $.INPUT({type: "checkbox", checked: conf.globalLock}); + + var btnSave + = $.INPUT({type: "button", value: "Save"}); + + var btnCancel + = $.INPUT({type: "button", value: "Cancel"}); + + var configPanel + = $.TABLE({className: "pageEditor"}, + $.TBODY({}, + $.TR({}, + $.TH({}, "Site name"), + $.TD({}, fldSiteName) + ), + $.TR({}, + $.TH({}, "Base URI"), + $.TD({}, fldBaseURI) + ), + $.TR({}, + $.TH({}, "Default page"), + $.TD({}, fldDefaultPage) + ), + $.TR({}, + $.TH({}, "Style sheet"), + $.TD({}, fldStyleSheet) + ), + $.TR({}, + $.TH({}, "Languages"), + $.TD({}, fldLanguages) + ), + $.TR({}, + $.TH({}, "Global lock"), + $.TD({}, + $.LABEL({}, + chkGlobalLock, + "Disallow guest users to edit pages.")) + ), + $.TR({}, + $.TH({}), + $.TD({}, btnSave, btnCancel) + ) + ) + ); + + $area.append(configPanel); + }; + $(document).ready(function () { $("input.configButton") .click(function () {