gitit 0.6.4 → 0.6.5
raw patch · 8 files changed
+64/−5 lines, 8 files
Files
- CHANGES +15/−0
- Network/Gitit/Authentication.hs +1/−1
- Network/Gitit/ContentTransformer.hs +4/−2
- Network/Gitit/Interface.hs +5/−0
- Network/Gitit/Page.hs +2/−1
- Network/Gitit/Types.hs +2/−0
- gitit.cabal +4/−1
- plugins/PigLatin.hs +31/−0
CHANGES view
@@ -1,3 +1,18 @@+Version 0.6.5 released 06 Oct 2009++* Added metadata to Page and Context, provided askMeta for plugins.+ This patch gives plugins access to all of the key/value pairs+ in the page metadata block. Thanks to Dan Cook.++* Added PigLatin plugin to demonstrate use of askMeta.++* Display informative message on authentication failure.++Version 0.6.4 released 28 Sep 2009++* Fixed preview javascript so that tex math works properly in+ preview.+ Version 0.6.3 released 27 Sep 2009 * Fixed MathML conversion so it doesn't happen when exporting to
Network/Gitit/Authentication.hs view
@@ -368,7 +368,7 @@ addCookie sessionTime (mkCookie "sid" (show key)) seeOther (encUrl destination) $ toResponse $ p << ("Welcome, " ++ uname) else- loginUserForm+ withMessages ["Invalid username or password."] loginUserForm encUrl :: String -> String encUrl = encString True isAscii
Network/Gitit/ContentTransformer.hs view
@@ -116,7 +116,8 @@ , ctxCacheable = True , ctxTOC = tableOfContents cfg , ctxBirdTracks = showLHSBirdTracks cfg- , ctxCategories = [] }+ , ctxCategories = []+ , ctxMeta = [] } -- | Converts a @ContentTransformer@ into a @GititServerPart@; -- specialized to wiki pages.@@ -318,7 +319,8 @@ pageToPandoc :: Page -> ContentTransformer Pandoc pageToPandoc page' = do modifyContext $ \ctx -> ctx{ ctxTOC = pageTOC page'- , ctxCategories = pageCategories page' }+ , ctxCategories = pageCategories page'+ , ctxMeta = pageMeta page' } return $ readerFor (pageFormat page') (pageLHS page') (pageText page') -- | Converts contents of page file to Page object.
Network/Gitit/Interface.hs view
@@ -115,6 +115,7 @@ , askUser , askRequest , askFileStore+ , askMeta , doNotCache , getContext , modifyContext@@ -151,6 +152,10 @@ -- | Returns the wiki filestore. askFileStore :: PluginM FileStore askFileStore = liftM pluginFileStore ask++-- | Returns the page meta data+askMeta :: PluginM [(String, String)]+askMeta = liftM ctxMeta getContext -- | Indicates that the current page or file is not to be cached. doNotCache :: PluginM ()
Network/Gitit/Page.hs view
@@ -97,7 +97,8 @@ , pageTOC = tableOfContents conf , pageTitle = pagename , pageCategories = []- , pageText = filter (/= '\r') rest }+ , pageText = filter (/= '\r') rest+ , pageMeta = ls } in foldr adjustPage page' ls adjustPage :: (String, String) -> Page -> Page
Network/Gitit/Types.hs view
@@ -138,6 +138,7 @@ , pageTitle :: String , pageCategories :: [String] , pageText :: String+ , pageMeta :: [(String, String)] } deriving (Read, Show) type SessionKey = Integer@@ -191,6 +192,7 @@ , ctxTOC :: Bool , ctxBirdTracks :: Bool , ctxCategories :: [String]+ , ctxMeta :: [(String, String)] } class (Monad m) => HasContext m where
gitit.cabal view
@@ -1,5 +1,5 @@ name: gitit-version: 0.6.4+version: 0.6.5 Cabal-version: >= 1.2 build-type: Simple synopsis: Wiki using happstack, git or darcs, and pandoc.@@ -69,6 +69,7 @@ data/markupHelp/LaTeX, data/markupHelp/LaTeX+LHS, data/markupHelp/HTML, plugins/CapitalizeEmphasis.hs,+ plugins/PigLatin.hs, plugins/Dot.hs, plugins/ImgTex.hs, plugins/Interwiki.hs,@@ -95,6 +96,8 @@ Network.Gitit.Authentication, Network.Gitit.Page, Network.Gitit.Feed if flag(plugins) exposed-modules: Network.Gitit.Interface+ build-depends: ghc, ghc-paths+ cpp-options: -D_PLUGINS build-depends: base >= 3, pandoc >= 1.1, filepath ghc-options: -Wall ghc-prof-options: -auto-all -caf-all
+ plugins/PigLatin.hs view
@@ -0,0 +1,31 @@+module PigLatin (plugin) where++-- This plugin converts a page to pig latin if the 'language' metadata+-- field is set to 'pig latin'. This demonstrates how to get access to+-- metadata in a plugin.++import Network.Gitit.Interface+import Data.Char (toLower, toUpper, isLower, isUpper, isLetter)++plugin :: Plugin+plugin = PageTransform $ \doc -> do+ meta <- askMeta+ case lookup "language" meta of+ Just s | map toLower s == "pig latin" ->+ return $ processWith pigLatinStr doc+ _ -> return doc++pigLatinStr :: Inline -> Inline+pigLatinStr (Str "") = Str ""+pigLatinStr (Str (c:cs)) | isLower c && isConsonant c =+ Str (cs ++ (c : "ay"))+pigLatinStr (Str (c:cs)) | isUpper c && isConsonant c =+ Str (capitalize cs ++ (toLower c : "ay"))+pigLatinStr (Str x@(c:cs)) | isLetter c = Str (x ++ "yay")+pigLatinStr x = x++isConsonant c = c `notElem` "aeiouAEIOU" ++capitalize :: String -> String+capitalize "" = ""+capitalize (c:cs) = toUpper c : cs