From: pho Date: Thu, 10 Jul 2008 10:24:33 +0000 (+0900) Subject: started implementing systemConfig X-Git-Url: https://git.cielonegro.org/gitweb.cgi?a=commitdiff_plain;h=5ab256be8bbbb1f4a012b41ac1cc3f9b29aa7d57;p=Rakka.git started implementing systemConfig darcs-hash:20080710102433-62b54-49252cbcaec31b310f5a8a415e912eb26b5ff69a.gz --- diff --git a/Main.hs b/Main.hs index c4bb048..b6e5d6d 100644 --- a/Main.hs +++ b/Main.hs @@ -15,7 +15,7 @@ import Rakka.Resource.Object import Rakka.Resource.Render import Rakka.Resource.Search import Rakka.Resource.SystemConfig -import Rakka.Resource.TrackBack +-- import Rakka.Resource.TrackBack import Rakka.Storage import Subversion import System.Console.GetOpt @@ -153,7 +153,7 @@ resTree env , (["search.html" ], resSearch env) , (["search.xml" ], resSearch env) , (["systemConfig"], resSystemConfig env) - , (["trackback" ], resTrackBack env) + -- , (["trackback" ], resTrackBack env) ] diff --git a/Rakka/Wiki/Interpreter/Base.hs b/Rakka/Wiki/Interpreter/Base.hs index 2363b9b..2f6aade 100644 --- a/Rakka/Wiki/Interpreter/Base.hs +++ b/Rakka/Wiki/Interpreter/Base.hs @@ -23,6 +23,7 @@ interpreters = [ lineBreakInterp , editPageInterp , loginInterp , searchFieldInterp + , configurationInterp ] @@ -174,3 +175,20 @@ searchFieldInterp in return (Input attrs) } + +-- +configurationInterp :: Interpreter +configurationInterp + = InlineCommandInterpreter { + iciName = "configuration" + , iciInterpret + = \ _ _ -> + let attrs = [ ("type" , "button") + , ("value", "Configuration") + , ("class", "configButton") + ] + in + return (Input attrs) + } diff --git a/defaultPages/SideBar/Left.xml b/defaultPages/SideBar/Left.xml index 25c8760..90361da 100644 --- a/defaultPages/SideBar/Left.xml +++ b/defaultPages/SideBar/Left.xml @@ -9,9 +9,5 @@ * [[MainPage|Main]] * [[Help/Syntax|Syntax Help]] -= Trackbacks = - - - ]]> diff --git a/defaultPages/SideBar/Right.xml b/defaultPages/SideBar/Right.xml index 982e863..7f8e9c8 100644 --- a/defaultPages/SideBar/Right.xml +++ b/defaultPages/SideBar/Right.xml @@ -6,6 +6,7 @@ * * * +* * = In other languages = diff --git a/js/editPage.js b/js/editPage.js index 705f47a..5d782de 100644 --- a/js/editPage.js +++ b/js/editPage.js @@ -11,7 +11,7 @@ var $area = Rakka.switchScreen(); Rakka.displayWaitingMessage("Loading... please wait."); - + // XML 版のページを取得する。 $.ajax({ url : Rakka.baseURI + pageName + ".xml", @@ -42,7 +42,7 @@ : $page.find("textData").text() ; var summary = $page.find("summary").text(); - + displayPageEditor(pageName, oldRevision, defaultType, lang, isLocked, otherLangs, source, summary); } else { @@ -51,7 +51,7 @@ }, error : function (req) { Rakka.hideWaitingMessage(); - + if (req.status == 404) { displayPageEditor(pageName, null, "rakka", null, false, {}, null, ""); } @@ -82,7 +82,7 @@ var makeDirty = function () { isDirty = true; }; - + var fldPageName = $.INPUT({type : "text", value: pageName}); @@ -101,7 +101,7 @@ $.LABEL({}, chkIsLocked, "Disallow anonymous users to edit or delete this page"))); - + var btnTypeRakka = $.INPUT({type : "radio", name : "type", @@ -135,7 +135,7 @@ $.OPTION({value: ""}, "(unspecified)"), (function () { var options = []; - + $.each(Rakka.getSystemConfig().languages, function (tag, name) { options.push( $.OPTION({value: tag}, name)); @@ -181,7 +181,7 @@ var lang = $(selLang).val(); var pageName = $(this).val(); - + if (pageName == "") { delete otherLangs[lang]; } @@ -229,14 +229,14 @@ $(fldRedirect).change(makeDirty); var trContent - = $.TR({}, + = $.TR({}, $.TH({}), $.TD({}) ); var btnPreview = $.INPUT({type: "button", value: "Preview page"}); - + $(btnPreview).click(function () { if (btnTypeRakka.checked) { previewRakkaPage( @@ -252,7 +252,7 @@ var btnSubmit = $.INPUT({type: "button", value: "Submit page"}); - + $(btnSubmit).click(function () { if (btnTypeRakka.checked) { submitTextPage( @@ -303,7 +303,7 @@ var btnDelete = $.INPUT({type: "button", value: "Delete this page"}); - + $(btnDelete).click(function () { if (window.confirm("Do you really want to delete this page?")) { deletePage(pageName); @@ -472,7 +472,7 @@ var previewRakkaPage = function (pageName, source) { Rakka.displayWaitingMessage("Loading... please wait."); - + var url = Rakka.baseURI + "render/" + encodeURI(pageName); $.ajax({ type : "POST", @@ -516,10 +516,10 @@ var showPreview = function (doc) { $previewArea.empty(); - + $previewHeader.show(); $previewArea.show(); - + var root = doc.documentElement; var child = root.firstChild; do { @@ -532,19 +532,19 @@ Rakka.scrollToTopLeft(); }; - var submitTextPage = function (pageName, oldRevision, givenPageName, isLocked, mimeType, lang, otherLangs, summary, text) { - var doc = document.implementation.createDocument( - "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null); - - var page = doc.documentElement; + var submitTextPage + = function (pageName, oldRevision, givenPageName, isLocked, mimeType, lang, otherLangs, summary, text) { + var NS = "http://cielonegro.org/schema/Rakka/Page/1.0"; + var doc = document.implementation.createDocument(NS, "page", null); + var page = doc.documentElement; if (oldRevision != null) { // ページ書換時 - var updateInfo = doc.createElement("updateInfo"); + var updateInfo = doc.createElementNS(NS, "updateInfo"); updateInfo.setAttribute("oldRevision", oldRevision); if (pageName != givenPageName) { - var move = doc.createElement("move"); + var move = doc.createElementNS(NS, "move"); move.setAttribute("from", pageName); updateInfo.appendChild(move); } @@ -560,22 +560,22 @@ } if (summary != null && summary != "") { - var s = doc.createElement("summary"); + var s = doc.createElementNS(NS, "summary"); s.appendChild( doc.createTextNode(summary)); page.appendChild(s); } - var oLang = doc.createElement("otherLang"); + var oLang = doc.createElementNS(NS, "otherLang"); for (var tag in otherLangs) { - var link = doc.createElement("link"); + var link = doc.createElementNS(NS, "link"); link.setAttribute("lang", tag); link.setAttribute("page", otherLangs[tag]); oLang.appendChild(link); } page.appendChild(oLang); - var textData = doc.createElement("textData"); + var textData = doc.createElementNS(NS, "textData"); textData.appendChild( doc.createTextNode(text)); @@ -598,7 +598,7 @@ }, error : function (req) { Rakka.hideWaitingMessage(); - + var $area = Rakka.switchScreen(); $area.text("Error: " + req.status + " " + req.statusText); } @@ -606,18 +606,17 @@ }; var submitBinaryPage = function (pageName, oldRevision, givenPageName, isLocked, lang, otherLangs, summary, path) { - var doc = document.implementation.createDocument( - "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null); - + var NS = "http://cielonegro.org/schema/Rakka/Page/1.0"; + var doc = document.implementation.createDocument(NS, "page", null); var page = doc.documentElement; if (oldRevision != null) { // ページ書換時 - var updateInfo = doc.createElement("updateInfo"); + var updateInfo = doc.createElementNS(NS, "updateInfo"); updateInfo.setAttribute("oldRevision", oldRevision); if (pageName != givenPageName) { - var move = doc.createElement("move"); + var move = doc.createElementNS(NS, "move"); move.setAttribute("from", pageName); updateInfo.appendChild(move); } @@ -633,15 +632,15 @@ } if (summary != null) { - var s = doc.createElement("summary"); + var s = doc.createElementNS(NS, "summary"); s.appendChild( doc.createTextNode(summary)); page.appendChild(s); } - var oLang = doc.createElement("otherLang"); + var oLang = doc.createElementNS(NS, "otherLang"); for (var tag in otherLangs) { - var link = doc.createElement("link"); + var link = doc.createElementNS(NS, "link"); link.setAttribute("lang", tag); link.setAttribute("page", otherLangs[tag]); oLang.appendChild(link); @@ -651,7 +650,7 @@ var bin = Rakka.loadLocalBinaryFile(path); var b64 = Rakka.encodeBase64(bin); - var binaryData = doc.createElement("binaryData"); + var binaryData = doc.createElementNS(NS, "binaryData"); binaryData.appendChild( doc.createTextNode(b64)); @@ -674,7 +673,7 @@ }, error : function (req) { Rakka.hideWaitingMessage(); - + var $area = Rakka.switchScreen(); $area.text("Error: " + req.status + " " + req.statusText); } @@ -682,18 +681,17 @@ }; var submitRedirection = function (pageName, oldRevision, givenPageName, isLocked, destination) { - var doc = document.implementation.createDocument( - "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null); - + var NS = "http://cielonegro.org/schema/Rakka/Page/1.0"; + var doc = document.implementation.createDocument(NS, "page", null); var page = doc.documentElement; if (oldRevision != null) { // ページ書換時 - var updateInfo = doc.createElement("updateInfo"); + var updateInfo = doc.createElementNS(NS, "updateInfo"); updateInfo.setAttribute("oldRevision", oldRevision); if (pageName != givenPageName) { - var move = doc.createElement("move"); + var move = doc.createElementNS(NS, "move"); move.setAttribute("from", pageName); updateInfo.appendChild(move); } @@ -721,7 +719,7 @@ }, error : function (req) { Rakka.hideWaitingMessage(); - + var $area = Rakka.switchScreen(); $area.text("Error: " + req.status + " " + req.statusText); } @@ -741,7 +739,7 @@ }, error : function (req) { Rakka.hideWaitingMessage(); - + var $area = Rakka.switchScreen(); $area.text("Error: " + req.status + " " + req.statusText); } diff --git a/js/login.js b/js/login.js index 291fa29..3223bcf 100644 --- a/js/login.js +++ b/js/login.js @@ -1,5 +1,5 @@ (function () { - + Rakka.showLoginPanel = function () { var $area = Rakka.switchScreen(); @@ -14,9 +14,26 @@ var btnLogin = $.INPUT({type: "button", value: "Login"}); - $(btnLogin).click(function () { - login(fldUserID.value, fldPassword.value); - }); + $(btnLogin) + .click(function () { + login(fldUserID.value, fldPassword.value); + }); + + var fldHandler = function (ev) { + if (ev.keyCode == 27) { // ESC + Rakka.restoreScreen(); + return false; + } + else if (ev.keyCode == 13) { // CR + login(fldUserID.value, fldPassword.value); + return false; + } + else { + return true; + } + }; + $(fldUserID).keypress(fldHandler); + $(fldPassword).keypress(fldHandler); var btnCancel = $.INPUT({type: "button", value: "Cancel"}); @@ -44,6 +61,7 @@ ); $area.append(loginPanel); + $(fldUserID).focus(); }; var login = function (userID, password) { @@ -86,7 +104,7 @@ var updateLoginState = function () { currentUserID = null; currentPassword = null; - + var cookies = document.cookie.split(/;\s*/); $.each(cookies, function () { var m = this.match(/^([^=]*)=(.*)$/); @@ -114,10 +132,14 @@ }); $("input.newButton").attr({disabled: ""}); - + $("input.editButton").attr({ disabled: (Rakka.isSpecialPage ? "disabled" : "") }); + + $("input.configButton").attr({ + disabled: "" + }); } else { /* ログインしてゐない */ @@ -129,10 +151,14 @@ $("input.newButton").attr({ disabled: (Rakka.isGlobalLocked ? "disabled" : "") }); - + $("input.editButton").attr({ disabled: (Rakka.isLocked || Rakka.isGlobalLocked || Rakka.isSpecialPage ? "disabled" : "") }); + + $("input.configButton").attr({ + disabled: "disabled" + }); } }; diff --git a/js/systemConfig.js b/js/systemConfig.js index 9dd7f9c..05a3a56 100644 --- a/js/systemConfig.js +++ b/js/systemConfig.js @@ -7,7 +7,7 @@ var mapDecoder = function (src) { var map = {}; var lines = src.split(/\n/); - + $.each(lines, function () { var m = this.match(/^(\S+)\s+(\S+)$/); @@ -36,10 +36,10 @@ if (cachedConf != null) { return cachedConf; } - + var conf = {}; cachedConf = conf; - + $.ajax({ type : "GET", url : Rakka.baseURI + "systemConfig", @@ -65,4 +65,11 @@ return conf; }; + $(document).ready(function () { + $("input.configButton") + .click(function () { + Rakka.showConfigPanel(); + }); + }); + })(); \ No newline at end of file