gitit 0.1.0.1 → 0.1.1
raw patch · 5 files changed
+27/−18 lines, 5 files
Files
- Gitit.hs +18/−15
- Gitit/State.hs +2/−0
- README.markdown +4/−1
- data/SampleConfig.hs +1/−0
- gitit.cabal +2/−2
Gitit.hs view
@@ -51,7 +51,7 @@ import System.Exit gititVersion :: String-gititVersion = "0.1.0.1"+gititVersion = "0.1.1" main :: IO () main = do@@ -129,13 +129,16 @@ postupdatecontents <- B.readFile postupdatepath welcomepath <- getDataFileName $ "data" </> "FrontPage.page" welcomecontents <- B.readFile welcomepath+ helppath <- getDataFileName $ "data" </> "Help.page"+ helpcontents <- B.readFile helppath createDirectory repodir oldDir <- getCurrentDirectory setCurrentDirectory repodir runCommand "git init" >>= waitForProcess- -- add welcome page+ -- add front page and help page B.writeFile "Front Page.page" welcomecontents- runCommand "git add 'Front Page.page'; git commit -m 'Initial commit of front page.'" >>= waitForProcess+ B.writeFile "Help.page" helpcontents+ runCommand "git add 'Help.page' 'Front Page.page'; git commit -m 'Initial commit.'" >>= waitForProcess -- set post-update hook so working directory will be updated -- when changes are pushed to the repo let postupdate = ".git" </> "hooks" </> "post-update"@@ -170,7 +173,6 @@ wikiHandlers :: [Handler] wikiHandlers = [ dir "_index" [ handle GET indexPage ] , dir "_activity" [ handle GET showActivity ]- , dir "_help" [ handle GET helpPage ] , dir "_preview" [ handle POST preview ] , dir "_search" [ handle POST searchResults ] , dir "_register" [ handle GET registerUserForm,@@ -182,12 +184,12 @@ handle POST uploadFile ] , handleCommand "showraw" GET showRawPage , handleCommand "history" GET showPageHistory- , handleCommand "edit" GET editPage+ , handleCommand "edit" GET (unlessLocked editPage) , handleCommand "diff" GET showDiff , handleCommand "cancel" POST showPage- , handleCommand "update" POST updatePage- , handleCommand "delete" GET confirmDelete- , handleCommand "delete" POST deletePage+ , handleCommand "update" POST (unlessLocked updatePage)+ , handleCommand "delete" GET (unlessLocked confirmDelete)+ , handleCommand "delete" POST (unlessLocked deletePage) , handle GET showPage ] @@ -285,6 +287,13 @@ [] -> Command Nothing (c:_) -> Command $ Just c +unlessLocked :: (String -> Params -> Web Response) -> (String -> Params -> Web Response)+unlessLocked responder =+ \page params -> do cfg <- query GetConfig+ if page `elem` lockedPages cfg+ then showPage page (params { pMessages = ("Page is locked." : pMessages params) })+ else responder page params+ handle :: Method -> (String -> Params -> Web Response) -> Handler handle meth responder = uriRest $ \uri -> let uriPath = drop 1 $ takeWhile (/='?') uri in if isPage uriPath@@ -321,12 +330,6 @@ then page (intercalate "/" $ rqPaths req) req else noHandle -helpPage :: String -> Params -> Web Response-helpPage _ params = do- helpText <- liftIO $ getDataFileName ("data" </> "Help.page") >>= readFile- helpHtml <- convertToHtml helpText- formattedPage [HidePageControls] ["jsMath/easy/load.js"] "Help" params helpHtml- showRawPage :: String -> Params -> Web Response showRawPage page params = do let revision = pRevision params@@ -683,7 +686,7 @@ , primHtmlChar "bull" , anchor ! [href "/_activity", theclass "nav_link"] << "activity" , primHtmlChar "bull"- , anchor ! [href "/_help", theclass "nav_link"] << "help"+ , anchor ! [href "/Help", theclass "nav_link"] << "help" , primHtmlChar "nbsp" , textfield "patterns" ! [theclass "search_field search_term"] , submit "search" "Search" ]
Gitit/State.hs view
@@ -47,6 +47,7 @@ portNumber :: Int, -- port number to serve content on passwordSalt :: String, -- text to serve as salt in encrypting passwords debugMode :: Bool, -- should debug info be printed to the console?+ lockedPages :: [String], -- pages that cannot be edited through the web interface accessQuestion :: Maybe (String, [String]) -- if Nothing, then anyone can register for an account. -- if Just (prompt, answers), then a user will be given the prompt -- and must give one of the answers in order to register.@@ -64,6 +65,7 @@ portNumber = 5001, passwordSalt = "l91snthoae8eou2340987", debugMode = False,+ lockedPages = ["Help"], accessQuestion = Nothing }
README.markdown view
@@ -94,7 +94,8 @@ maxUploadSize = 100000, portNumber = 5001, passwordSalt = "l91snthoae8eou2340987",- debugMode = True+ debugMode = True,+ lockedPages = ["Help"], accessQuestion = Just ("Enter the access code (to request a code, contact me@foo.bar.com):", ["abcd"]) } @@ -109,6 +110,8 @@ - The `passwordSalt` is used to encrypt passwords and should be changed for every new site. - `debugMode` causes diagnostic information to be printed to the console.+- `lockedPages` is a list of pages that cannot be edited from the web interface.+ (They may still be edited via git, by those with access to the repository.) - The `accessQuestion` is either `Nothing` (in which case anyone will be allowed to register for an account) or `Just (question, [ans1, ans2, ...])` (in which case anyone who registers must first answer the `question` with
data/SampleConfig.hs view
@@ -9,6 +9,7 @@ portNumber = 5001, passwordSalt = "l91snthoae8eou2340987", debugMode = True,+lockedPages = ["Help", "Front Page"], accessQuestion = Just ("Enter the access code (to request an access code, contact me@somewhere.org):", ["abcd"]) }
gitit.cabal view
@@ -1,5 +1,5 @@ name: gitit-version: 0.1.0.1+version: 0.1.1 build-type: Simple synopsis: Wiki using HAppS, git, and pandoc. description: Gitit is a wiki program. HAppS is used for the web@@ -31,7 +31,7 @@ hs-source-dirs: . executable: gitit main-is: Gitit.hs -other-modules: Gitit.State, Gitit.Git+other-modules: Gitit.State, Gitit.Git, Paths_gitit build-depends: base, parsec < 3, pretty, xhtml, containers, pandoc >= 1.1, process, filepath, directory, mtl, cgi, network, old-time, highlighting-kate, bytestring,