import Rakka.Resource
import Rakka.Storage
import Rakka.SystemConfig
+import Rakka.Utils
import Rakka.Wiki.Engine
import System.FilePath
import Text.XML.HXT.Arrow.Namespace
-> do SiteName siteName <- getSysConfA (envSysConf env) -< ()
BaseURI baseURI <- getSysConfA (envSysConf env) -< ()
StyleSheet styleSheet <- getSysConfA (envSysConf env) -< ()
+ GlobalLock isGLocked <- getSysConfA (envSysConf env) -< ()
- name <- (getXPathTreesInDoc "/page/@name/text()" >>> getText) -< page
+ name <- (getXPathTreesInDoc "/page/@name/text()" >>> getText) -< page
+ isLocked <- (getXPathTreesInDoc "/page/@isLocked/text()" >>> getText >>> parseYesOrNo) -< page
let cssHref = [uriToString id (mkObjectURI baseURI styleSheet) ""]
scriptSrc = [uriToString id (baseURI { uriPath = uriPath baseURI </> "js" }) ""]
)
+= ( eelem "script"
+= sattr "type" "text/javascript"
- += txt ("Rakka.baseURI = \"" ++ uriToString id baseURI "" ++ "\";")
+ += txt ("Rakka.baseURI=\"" ++ uriToString id baseURI "" ++ "\";")
+ += txt ("Rakka.isLocked=" ++ trueOrFalse isLocked ++ ";")
+ += txt ("Rakka.isGlobalLocked=" ++ trueOrFalse isGLocked ++ ";")
)
)
+= ( eelem "body"
-> do SiteName siteName <- getSysConfA (envSysConf env) -< ()
BaseURI baseURI <- getSysConfA (envSysConf env) -< ()
StyleSheet styleSheet <- getSysConfA (envSysConf env) -< ()
+ GlobalLock isGLocked <- getSysConfA (envSysConf env) -< ()
name <- (getXPathTreesInDoc "/pageNotFound/@name/text()" >>> getText) -< pageNotFound
+= ( eelem "script"
+= sattr "type" "text/javascript"
+= txt ("Rakka.baseURI = \"" ++ uriToString id baseURI "" ++ "\";")
+ += txt ("Rakka.isGlobalLocked=" ++ trueOrFalse isGLocked ++ ";")
)
)
+= ( eelem "body"
, DefaultPage(..)
, StyleSheet(..)
, Languages(..)
+ , GlobalLock(..)
, serializeStringPairs
, deserializeStringPairs
, ("pt", "Português")
, ("sv", "Svenska" )
]
+
+
+newtype GlobalLock = GlobalLock Bool deriving (Show, Typeable)
+instance SysConfValue GlobalLock where
+ confPath _ = "globalLock"
+ serialize (GlobalLock isLocked)
+ | isLocked = "*"
+ | otherwise = ""
+ deserialize "*" = Just (GlobalLock True)
+ deserialize "" = Just (GlobalLock False)
+ deserialize _ = Nothing
+ defaultValue _ = GlobalLock False
module Rakka.Utils
( yesOrNo
+ , trueOrFalse
, parseYesOrNo
, maybeA
, deleteIfEmpty
yesOrNo False = "no"
+trueOrFalse :: Bool -> String
+trueOrFalse True = "true"
+trueOrFalse False = "false"
+
+
parseYesOrNo :: ArrowChoice a => a String Bool
parseYesOrNo
= proc str -> do case str of
input[type="button"]:active {
background-color: #999999;
}
+input[type="button"][disabled] {
+ border-color: #e5e5e5;
+ color: #b5b5b5;
+}
+input[type="button"][disabled]:active {
+ background-color: #f5f5f5;
+}
.header, .footer, .sideBar {
background-color: #eeeeee;
/* Namespace Rakka */
var Rakka = {};
-Rakka.baseURI = null;
+Rakka.baseURI = null;
+Rakka.isLocked = false;
+Rakka.isGlobalLocked = false;
$(fldPageName).change(makeDirty);
var chkIsLocked
- = $.INPUT({type : "checkbox",
- checked: (isLocked ? "checked" : "")});
+ = $.INPUT({type : "checkbox",
+ checked : (isLocked ? "checked" : "")});
$(chkIsLocked).change(makeDirty);
$area.append(pageEditor);
+ if (!Rakka.isLoggedIn() || Rakka.isGlobalLocked) {
+ $(trIsLocked).hide();
+ }
+
isDirty = false;
};
var logout = function () {
document.cookie = "rakkaLoginInfo=;max-age=0";
updateLoginState();
+ Rakka.restoreScreen();
};
var currentUserID;
.click(function () {
logout();
});
+
+ $("input.newButton").attr({disabled: ""});
+
+ $("input.editButton").attr({disabled: ""});
}
else {
/* ログインしてゐない */
.val("Login")
.unbind("click")
.click(Rakka.showLoginPanel);
+
+ $("input.newButton").attr({
+ disabled: (Rakka.isGlobalLocked ? "disabled" : "")
+ });
+
+ $("input.editButton").attr({
+ disabled: (Rakka.isLocked || Rakka.isGlobalLocked ? "disabled" : "")
+ });
}
};
Rakka.setAuthorization = function (req) {
- if (currentUserID != null) {
+ if (Rakka.isLoggedIn()) {
req.setRequestHeader(
"Authorization",
"Basic " + Rakka.encodeBase64(currentUserID + ":" + currentPassword));
}
};
+ Rakka.isLoggedIn = function () {
+ return currentUserID != null;
+ };
+
$(document).ready(function () {
updateLoginState();
});
};
Rakka.restoreScreen = function () {
- if (switchedArea == null) {
- throw new Error("Rakka.restoreScreen(): not switched");
- }
+ if (switchedArea != null) {
+ $("div.sideBar div.outline").show();
- $("div.sideBar div.outline").show();
+ $("p.redirection").show();
- $("p.redirection").show();
+ $(switchedArea).remove();
+ switchedArea = null;
- $(switchedArea).remove();
- switchedArea = null;
-
- $("div.body").children().show();
+ $("div.body").children().show();
+ }
return null;
};