gitit 0.10.7 → 0.11
raw patch · 16 files changed
+190/−86 lines, 16 filesdep ~pandocPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: pandoc
API changes (from Hackage documentation)
+ Network.Gitit.Framework: isNotDiscussPageFile :: FilePath -> GititServerPart Bool
+ Network.Gitit.Interface: defaultExtension :: Config -> String
+ Network.Gitit.Types: defaultExtension :: Config -> String
- Network.Gitit.Framework: isDiscussPageFile :: FilePath -> Bool
+ Network.Gitit.Framework: isDiscussPageFile :: FilePath -> GititServerPart Bool
- Network.Gitit.Framework: isPageFile :: FilePath -> Bool
+ Network.Gitit.Framework: isPageFile :: FilePath -> GititServerPart Bool
- Network.Gitit.Framework: pathForPage :: String -> FilePath
+ Network.Gitit.Framework: pathForPage :: String -> String -> FilePath
- Network.Gitit.Interface: Config :: FilePath -> FileStoreType -> PageType -> MathMethod -> Bool -> Bool -> (Handler -> Handler) -> AuthenticationLevel -> Handler -> FilePath -> Int -> FilePath -> FilePath -> Priority -> FilePath -> [String] -> Bool -> Integer -> Integer -> String -> Int -> Bool -> String -> [String] -> [String] -> String -> Maybe (String, [String]) -> Bool -> String -> String -> String -> String -> Bool -> Bool -> FilePath -> Map String String -> String -> String -> String -> Bool -> String -> Bool -> String -> Integer -> Integer -> Bool -> Maybe FilePath -> Bool -> Int -> GithubConfig -> Config
+ Network.Gitit.Interface: Config :: FilePath -> FileStoreType -> PageType -> String -> MathMethod -> Bool -> Bool -> (Handler -> Handler) -> AuthenticationLevel -> Handler -> FilePath -> Int -> FilePath -> FilePath -> Priority -> FilePath -> [String] -> Bool -> Integer -> Integer -> String -> Int -> Bool -> String -> [String] -> [String] -> String -> Maybe (String, [String]) -> Bool -> String -> String -> String -> String -> Bool -> Bool -> FilePath -> Map String String -> String -> String -> String -> Bool -> String -> Bool -> String -> Integer -> Integer -> Bool -> Maybe FilePath -> Bool -> Int -> GithubConfig -> Config
- Network.Gitit.Types: Config :: FilePath -> FileStoreType -> PageType -> MathMethod -> Bool -> Bool -> (Handler -> Handler) -> AuthenticationLevel -> Handler -> FilePath -> Int -> FilePath -> FilePath -> Priority -> FilePath -> [String] -> Bool -> Integer -> Integer -> String -> Int -> Bool -> String -> [String] -> [String] -> String -> Maybe (String, [String]) -> Bool -> String -> String -> String -> String -> Bool -> Bool -> FilePath -> Map String String -> String -> String -> String -> Bool -> String -> Bool -> String -> Integer -> Integer -> Bool -> Maybe FilePath -> Bool -> Int -> GithubConfig -> Config
+ Network.Gitit.Types: Config :: FilePath -> FileStoreType -> PageType -> String -> MathMethod -> Bool -> Bool -> (Handler -> Handler) -> AuthenticationLevel -> Handler -> FilePath -> Int -> FilePath -> FilePath -> Priority -> FilePath -> [String] -> Bool -> Integer -> Integer -> String -> Int -> Bool -> String -> [String] -> [String] -> String -> Maybe (String, [String]) -> Bool -> String -> String -> String -> String -> Bool -> Bool -> FilePath -> Map String String -> String -> String -> String -> Bool -> String -> Bool -> String -> Integer -> Integer -> Bool -> Maybe FilePath -> Bool -> Int -> GithubConfig -> Config
Files
- CHANGES +20/−0
- Network/Gitit/Authentication.hs +3/−3
- Network/Gitit/Cache.hs +5/−5
- Network/Gitit/Config.hs +2/−0
- Network/Gitit/ContentTransformer.hs +32/−13
- Network/Gitit/Export.hs +1/−1
- Network/Gitit/Feed.hs +59/−12
- Network/Gitit/Framework.hs +13/−6
- Network/Gitit/Handlers.hs +39/−34
- Network/Gitit/Initialize.hs +3/−3
- Network/Gitit/Plugins.hs +1/−3
- Network/Gitit/Types.hs +2/−0
- data/default.conf +4/−0
- data/static/js/preview.js +1/−1
- data/templates/page.st +2/−2
- gitit.cabal +3/−3
CHANGES view
@@ -1,3 +1,23 @@+Version 0.11 released 02 Jun 2015++ * Allow page extensions to be configurable (not just `.page`)+ (Caleb McDaniel).+ - Added `page-extension` option in config file (Caleb McDaniel).+ - Added new type for `defaultExtension`+ - Changed `isPageFile` to get extension from config+ - New function `isNotDiscussPageFile`+ - `pathForPage` must be passed extension as String+ - `isPageFile` now returns GititServerPart Bool instead of just Bool.+ * Reverted some changes to Plugins that caused excessive memory use.+ * Allow pandoc 1.15.+ * Added missing `<br>` tag in form on registration page (Vaughn Iverson).+ * Show page diffs in feed (Imuli).+ * Display commit messages in feed entry titles (Imuli).+ * Fix preview button for modern jQuery (Imuli).+ * Feed titles reflect site and page names (Imuli).+ * Present feed in canonical order (recent first, Imuli).+ * https support for base-url config option (Imuli).+ Version 0.10.7 released 02 Jun 2015 * Fixes to allow building with pandoc 1.14. `CommonMark` added
Network/Gitit/Authentication.hs view
@@ -249,8 +249,10 @@ , userNameField , label ! [thefor "email"] << "Email (optional, will not be displayed on the Wiki):" , br- , textfield "email" ! [size "20", intAttr "tabindex" 3, value (initField uEmail)], br+ , textfield "email" ! [size "20", intAttr "tabindex" 3, value (initField uEmail)]+ , br ! [theclass "req"] , textfield "full_name_1" ! [size "20", theclass "req"]+ , br , label ! [thefor "password"] << ("Password (at least 6 characters," ++ " including at least one non-letter):")@@ -537,5 +539,3 @@ currentUser = do req <- askRq ok $ toResponse $ maybe "" toString (getHeader "REMOTE_USER" req)--
Network/Gitit/Cache.hs view
@@ -50,11 +50,11 @@ exists <- liftIO $ doesFileExist target when exists $ liftIO $ do liftIO $ removeFile target- expireCachedPDF target+ expireCachedPDF target (defaultExtension cfg) -expireCachedPDF :: String -> IO ()-expireCachedPDF file =- when (takeExtension file == ".page") $ do+expireCachedPDF :: String -> String -> IO ()+expireCachedPDF file ext = + when (takeExtension file == "." ++ ext) $ do let pdfname = file ++ ".export.pdf" exists <- doesFileExist pdfname when exists $ removeFile pdfname@@ -84,4 +84,4 @@ liftIO $ do createDirectoryIfMissing True targetDir B.writeFile target contents- expireCachedPDF target+ expireCachedPDF target (defaultExtension cfg)
Network/Gitit/Config.hs view
@@ -91,6 +91,7 @@ cfRepositoryType <- get cp "DEFAULT" "repository-type" cfRepositoryPath <- get cp "DEFAULT" "repository-path" cfDefaultPageType <- get cp "DEFAULT" "default-page-type"+ cfDefaultExtension <- get cp "DEFAULT" "default-extension" cfMathMethod <- get cp "DEFAULT" "math" cfMathjaxScript <- get cp "DEFAULT" "mathjax-script" cfShowLHSBirdTracks <- get cp "DEFAULT" "show-lhs-bird-tracks"@@ -159,6 +160,7 @@ repositoryPath = cfRepositoryPath , repositoryType = repotype' , defaultPageType = pt+ , defaultExtension = cfDefaultExtension , mathMethod = case map toLower cfMathMethod of "jsmath" -> JsMathScript "mathml" -> MathML
Network/Gitit/ContentTransformer.hs view
@@ -117,14 +117,13 @@ -- ContentTransformer runners -- -runTransformer :: ToMessage a- => (String -> String)- -> ContentTransformer a+runPageTransformer :: ToMessage a+ => ContentTransformer a -> GititServerPart a-runTransformer pathFor xform = withData $ \params -> do+runPageTransformer xform = withData $ \params -> do page <- getPage cfg <- getConfig- evalStateT xform Context{ ctxFile = pathFor page+ evalStateT xform Context{ ctxFile = pathForPage page (defaultExtension cfg) , ctxLayout = defaultPageLayout{ pgPageName = page , pgTitle = page@@ -138,19 +137,39 @@ , ctxCategories = [] , ctxMeta = [] } +runFileTransformer :: ToMessage a+ => ContentTransformer a+ -> GititServerPart a+runFileTransformer xform = withData $ \params -> do+ page <- getPage+ cfg <- getConfig+ evalStateT xform Context{ ctxFile = id page+ , ctxLayout = defaultPageLayout{+ pgPageName = page+ , pgTitle = page+ , pgPrintable = pPrintable params+ , pgMessages = pMessages params+ , pgRevision = pRevision params+ , pgLinkToFeed = useFeed cfg }+ , ctxCacheable = True+ , ctxTOC = tableOfContents cfg+ , ctxBirdTracks = showLHSBirdTracks cfg+ , ctxCategories = []+ , ctxMeta = [] }+ -- | Converts a @ContentTransformer@ into a @GititServerPart@; -- specialized to wiki pages.-runPageTransformer :: ToMessage a- => ContentTransformer a- -> GititServerPart a-runPageTransformer = runTransformer pathForPage+-- runPageTransformer :: ToMessage a+-- => ContentTransformer a+-- -> GititServerPart a+-- runPageTransformer = runTransformer pathForPage -- | Converts a @ContentTransformer@ into a @GititServerPart@; -- specialized to non-pages.-runFileTransformer :: ToMessage a- => ContentTransformer a- -> GititServerPart a-runFileTransformer = runTransformer id+-- runFileTransformer :: ToMessage a+-- => ContentTransformer a+-- -> GititServerPart a+-- runFileTransformer = runTransformer id -- -- Gitit responders
Network/Gitit/Export.hs view
@@ -221,7 +221,7 @@ respondPDF useBeamer page old_pndc = fixURLs page old_pndc >>= \pndc -> do cfg <- getConfig unless (pdfExport cfg) $ error "PDF export disabled"- let cacheName = pathForPage page ++ ".export.pdf"+ let cacheName = pathForPage page (defaultExtension cfg) ++ ".export.pdf" cached <- if useCache cfg then lookupCache cacheName else return Nothing
Network/Gitit/Feed.hs view
@@ -33,13 +33,14 @@ import Data.Ord (comparing) import Network.URI (isUnescapedInURI, escapeURIString) import System.FilePath (dropExtension, takeExtension, (<.>))-import Data.FileStore.Types (history, Author(authorName), Change(..),- FileStore, Revision(..), TimeRange(..))+import Data.FileStore.Generic (Diff(..), diff)+import Data.FileStore.Types (history, retrieve, Author(authorName), Change(..),+ FileStore, Revision(..), TimeRange(..), RevisionId) import Text.Atom.Feed (nullEntry, nullFeed, nullLink, nullPerson, Date, Entry(..), Feed(..), Link(linkRel), Generator(..),- Person(personName), TextContent(TextString))+ Person(personName), EntryContent(..), TextContent(TextString)) import Text.Atom.Feed.Export (xmlFeed)-import Text.XML.Light (ppTopElement)+import Text.XML.Light (ppTopElement, showContent, Content(..), Element(..), blank_element, QName(..), blank_name, CData(..), blank_cdata) import Data.Version (showVersion) import Paths_gitit (version) @@ -64,11 +65,12 @@ generateFeed cfg generator fs mbPath = do now <- getCurrentTime revs <- changeLog (fcFeedDays cfg) fs mbPath now+ diffs <- mapM (getDiffs fs) revs let home = fcBaseUrl cfg ++ "/" -- TODO: 'nub . sort' `persons` - but no Eq or Ord instances! persons = map authorToPerson $ nub $ sortBy (comparing authorName) $ map revAuthor revs basefeed = generateEmptyfeed generator (fcTitle cfg) home mbPath persons (formatFeedTime now)- revisions = map (revisionToEntry home) revs+ revisions = map (revisionToEntry home) (zip revs diffs) return basefeed {feedEntries = revisions} -- | Get the last N days history.@@ -78,8 +80,32 @@ let startTime = addUTCTime (fromIntegral $ -60 * 60 * 24 * days) now' rs <- history a files TimeRange{timeFrom = Just startTime, timeTo = Just now'} (Just 200) -- hard limit of 200 to conserve resources- return $ sortBy (comparing revDateTime) rs+ return $ sortBy (flip $ comparing revDateTime) rs +getDiffs :: FileStore -> Revision -> IO [(FilePath, [Diff [String]])]+getDiffs fs Revision{ revId = to, revDateTime = rd, revChanges = rv } = do+ revPair <- history fs [] (TimeRange Nothing $ Just rd) (Just 2)+ let from = if length revPair >= 2+ then Just $ revId $ revPair !! 1+ else Nothing+ diffs <- mapM (getDiff fs from (Just to)) rv+ return $ map filterPages $ zip (map getFP rv) diffs+ where getFP (Added fp) = fp+ getFP (Modified fp) = fp+ getFP (Deleted fp) = fp+ filterPages (fp, d) = case (reverse fp) of+ 'e':'g':'a':'p':'.':x -> (reverse x, d)+ _ -> (fp, [])++getDiff :: FileStore -> Maybe RevisionId -> Maybe RevisionId -> Change -> IO [Diff [String]]+getDiff fs from _ (Deleted fp) = do+ contents <- retrieve fs fp from+ return [First $ lines contents]+getDiff fs from to (Modified fp) = diff fs fp from to+getDiff fs _ to (Added fp) = do+ contents <- retrieve fs fp to+ return [Second $ lines contents]+ generateEmptyfeed :: Generator -> String ->String ->Maybe String -> [Person] -> Date -> Feed generateEmptyfeed generator title home mbPath authors now = baseNull {feedAuthors = authors,@@ -89,16 +115,37 @@ } where baseNull = nullFeed home (TextString title) now -revisionToEntry :: String -> Revision -> Entry-revisionToEntry home Revision{ revId = rid, revDateTime = rdt,+revisionToEntry :: String -> (Revision, [(FilePath, [Diff [String]])]) -> Entry+revisionToEntry home (Revision{ revId = rid, revDateTime = rdt, revAuthor = ra, revDescription = rd,- revChanges = rv} =- baseEntry{ entrySummary = Just $ TextString rd+ revChanges = rv}, diffs) =+ baseEntry{ entryContent = Just $ HTMLContent $ concat $ map showContent $ map diffFile diffs , entryAuthors = [authorToPerson ra], entryLinks = [ln] }- where baseEntry = nullEntry url (TextString (intercalate ", " $ map show rv))- (formatFeedTime rdt)+ where baseEntry = nullEntry url title (formatFeedTime rdt) url = home ++ escape (extract $ head rv) ++ "?revision=" ++ rid ln = (nullLink url) {linkRel = Just (Left "alternate")}+ title = TextString $ (takeWhile ('\n' /=) rd) ++ " - " ++ (intercalate ", " $ map show rv)++diffFile :: (FilePath, [Diff [String]]) -> Content+diffFile (fp, d) =+ enTag "div" $ header : text+ where+ header = enTag1 "h1" $ enText fp+ text = map (enTag1 "p") $ concat $ map diffLines d++diffLines :: Diff [String] -> [Content]+diffLines (First x) = map (enTag1 "s" . enText) x+diffLines (Second x) = map (enTag1 "b" . enText) x+diffLines (Both x _) = map enText x++enTag :: String -> [Content] -> Content+enTag tag content = Elem blank_element{ elName=blank_name{qName=tag}+ , elContent=content+ }+enTag1 :: String -> Content -> Content+enTag1 tag content = enTag tag [content]+enText :: String -> Content+enText content = Text blank_cdata{cdData=content} -- gitit is set up not to reveal registration emails authorToPerson :: Author -> Person
Network/Gitit/Framework.hs view
@@ -43,6 +43,7 @@ , isPageFile , isDiscussPage , isDiscussPageFile+ , isNotDiscussPageFile , isSourceCode -- * Combinators that change the request locally , withMessages@@ -257,17 +258,23 @@ -- for now, we disallow @*@ and @?@ in page names, because git filestore -- does not deal with them properly, and darcs filestore disallows them. -isPageFile :: FilePath -> Bool-isPageFile f = takeExtension f == ".page"+isPageFile :: FilePath -> GititServerPart Bool+isPageFile f = do+ cfg <- getConfig+ return $ takeExtension f == "." ++ (defaultExtension cfg) isDiscussPage :: String -> Bool isDiscussPage ('@':xs) = isPage xs isDiscussPage _ = False -isDiscussPageFile :: FilePath -> Bool+isDiscussPageFile :: FilePath -> GititServerPart Bool isDiscussPageFile ('@':xs) = isPageFile xs-isDiscussPageFile _ = False+isDiscussPageFile _ = return False +isNotDiscussPageFile :: FilePath -> GititServerPart Bool+isNotDiscussPageFile ('@':_) = return False+isNotDiscussPageFile _ = return True+ isSourceCode :: String -> Bool isSourceCode path' = let langs = languagesByFilename $ takeFileName path'@@ -281,8 +288,8 @@ urlForPage page = '/' : encString False isUnescapedInURI page -- | Returns the filestore path of the file containing the page's source.-pathForPage :: String -> FilePath-pathForPage page = page <.> "page"+pathForPage :: String -> String -> FilePath+pathForPage page ext = page <.> ext -- | Retrieves a mime type based on file extension. getMimeTypeForExtension :: String -> GititServerPart String
Network/Gitit/Handlers.hs view
@@ -111,10 +111,9 @@ randomPage :: Handler randomPage = do fs <- getFileStore- files <- liftIO $ index fs base' <- getWikiBase- let pages = map dropExtension $- filter (\f -> isPageFile f && not (isDiscussPageFile f)) files+ prunedFiles <- liftIO (index fs) >>= filterM isPageFile >>= filterM isNotDiscussPageFile+ let pages = map dropExtension prunedFiles if null pages then error "No pages found!" else do@@ -194,6 +193,7 @@ $ pWikiname params `orIfNull` takeFileName origPath let logMsg = pLogMsg params cfg <- getConfig+ wPF <- isPageFile wikiname mbUser <- getLoggedInUser (user, email) <- case mbUser of Nothing -> return ("Anonymous", "")@@ -218,7 +218,7 @@ , (not overwrite && exists, "A file named '" ++ wikiname ++ "' already exists in the repository: choose a new name " ++ "or check the box to overwrite the existing file.")- , (isPageFile wikiname,+ , (wPF, "This file extension is reserved for wiki pages.") ] if null errors@@ -246,8 +246,8 @@ goToPage = withData $ \(params :: Params) -> do let gotopage = pGotoPage params fs <- getFileStore- allPageNames <- liftM (map dropExtension . filter isPageFile) $- liftIO $ index fs+ pruned_files <- liftIO (index fs) >>= filterM isPageFile+ let allPageNames = map dropExtension pruned_files let findPage f = find f allPageNames let exactMatch f = gotopage == f let insensitiveMatch f = (map toLower gotopage) == (map toLower f)@@ -281,14 +281,14 @@ -- doesn't handle this properly: (\(_ :: FileStoreError) -> return []) let contentMatches = map matchResourceName matchLines- allPages <- liftM (filter isPageFile) $ liftIO $ index fs+ allPages <- liftIO (index fs) >>= filterM isPageFile let slashToSpace = map (\c -> if c == '/' then ' ' else c) let inPageName pageName' x = x `elem` (words $ slashToSpace $ dropExtension pageName') let matchesPatterns pageName' = not (null patterns) && all (inPageName (map toLower pageName')) (map (map toLower) patterns) let pageNameMatches = filter matchesPatterns allPages- let allMatchedFiles = nub $ filter isPageFile contentMatches ++- pageNameMatches+ prunedFiles <- filterM isPageFile (contentMatches ++ pageNameMatches)+ let allMatchedFiles = nub $ prunedFiles let matchesInFile f = mapMaybe (\x -> if matchResourceName x == f then Just (matchLine x) else Nothing) matchLines@@ -324,7 +324,8 @@ showPageHistory :: Handler showPageHistory = withData $ \(params :: Params) -> do page <- getPage- showHistory (pathForPage page) page params+ cfg <- getConfig+ showHistory (pathForPage page $ defaultExtension cfg) page params showFileHistory :: Handler showFileHistory = withData $ \(params :: Params) -> do@@ -403,9 +404,8 @@ let fileFromChange (Added f) = f fileFromChange (Modified f) = f fileFromChange (Deleted f) = f- base' <- getWikiBase- let fileAnchor revis file = if isPageFile file+ let fileAnchor revis file = if takeExtension file == "." ++ (defaultExtension cfg) then anchor ! [href $ base' ++ "/_diff" ++ urlForPage (dropExtension file) ++ "?to=" ++ revis] << dropExtension file else anchor ! [href $ base' ++ urlForPage file ++ "?revision=" ++ revis] << file let filesFor changes revis = intersperse (stringToHtml " ") $@@ -435,7 +435,8 @@ showPageDiff :: Handler showPageDiff = withData $ \(params :: Params) -> do page <- getPage- showDiff (pathForPage page) page params+ cfg <- getConfig+ showDiff (pathForPage page $ defaultExtension cfg) page params showFileDiff :: Handler showFileDiff = withData $ \(params :: Params) -> do@@ -499,13 +500,14 @@ let rev = pRevision params -- if this is set, we're doing a revert fs <- getFileStore page <- getPage+ cfg <- getConfig let getRevisionAndText = E.catch- (do c <- liftIO $ retrieve fs (pathForPage page) rev+ (do c <- liftIO $ retrieve fs (pathForPage page $ defaultExtension cfg) rev -- even if pRevision is set, we return revId of latest -- saved version (because we're doing a revert and -- we don't want gitit to merge the changes with the -- latest version)- r <- liftIO $ latest fs (pathForPage page) >>= revision fs+ r <- liftIO $ latest fs (pathForPage page $ defaultExtension cfg) >>= revision fs return (Just $ revId r, c)) (\e -> if e == NotFound then return (Nothing, "")@@ -528,7 +530,6 @@ strAttr "style" "color: gray"] else [] base' <- getWikiBase- cfg <- getConfig let editForm = gui (base' ++ urlForPage page) ! [identifier "editform"] << [ sha1Box , textarea ! (readonly ++ [cols "80", name "editedText",@@ -570,11 +571,12 @@ confirmDelete = do page <- getPage fs <- getFileStore+ cfg <- getConfig -- determine whether there is a corresponding page, and if not whether there -- is a corresponding file- pageTest <- liftIO $ E.try $ latest fs (pathForPage page)+ pageTest <- liftIO $ E.try $ latest fs (pathForPage page $ defaultExtension cfg) fileToDelete <- case pageTest of- Right _ -> return $ pathForPage page -- a page+ Right _ -> return $ pathForPage page $ defaultExtension cfg -- a page Left NotFound -> do fileTest <- liftIO $ E.try $ latest fs page case fileTest of@@ -599,6 +601,7 @@ deletePage :: Handler deletePage = withData $ \(params :: Params) -> do page <- getPage+ cfg <- getConfig let file = pFileToDelete params mbUser <- getLoggedInUser (user, email) <- case mbUser of@@ -607,7 +610,7 @@ let author = Author user email let descrip = "Deleted using web interface." base' <- getWikiBase- if pConfirm params && (file == page || file == page <.> "page")+ if pConfirm params && (file == page || file == page <.> (defaultExtension cfg)) then do fs <- getFileStore liftIO $ Data.FileStore.delete fs file author descrip@@ -636,12 +639,12 @@ error "Page exceeds maximum size." -- check SHA1 in case page has been modified, merge modifyRes <- if null oldSHA1- then liftIO $ create fs (pathForPage page)+ then liftIO $ create fs (pathForPage page $ defaultExtension cfg) (Author user email) logMsg editedText >> return (Right ()) else do- expireCachedFile (pathForPage page) `mplus` return ()- liftIO $ E.catch (modify fs (pathForPage page)+ expireCachedFile (pathForPage page $ defaultExtension cfg) `mplus` return ()+ liftIO $ E.catch (modify fs (pathForPage page $ defaultExtension cfg) oldSHA1 (Author user email) logMsg editedText) (\e -> if e == Unchanged@@ -665,13 +668,15 @@ indexPage = do path' <- getPath base' <- getWikiBase+ cfg <- getConfig+ let ext = defaultExtension cfg let prefix' = if null path' then "" else path' ++ "/" fs <- getFileStore listing <- liftIO $ directory fs prefix'- let isDiscussionPage (FSFile f) = isDiscussPageFile f- isDiscussionPage (FSDirectory _) = False- let prunedListing = filter (not . isDiscussionPage) listing- let htmlIndex = fileListToHtml base' prefix' prunedListing+ let isNotDiscussionPage (FSFile f) = isNotDiscussPageFile f+ isNotDiscussionPage (FSDirectory _) = return True+ prunedListing <- filterM isNotDiscussionPage listing+ let htmlIndex = fileListToHtml base' prefix' ext prunedListing formattedPage defaultPageLayout{ pgPageName = prefix', pgShowPageTools = False,@@ -679,9 +684,9 @@ pgScripts = [], pgTitle = "Contents"} htmlIndex -fileListToHtml :: String -> String -> [Resource] -> Html-fileListToHtml base' prefix files =- let fileLink (FSFile f) | isPageFile f =+fileListToHtml :: String -> String -> String -> [Resource] -> Html+fileListToHtml base' prefix ext files =+ let fileLink (FSFile f) | takeExtension f == "." ++ ext = li ! [theclass "page" ] << anchor ! [href $ base' ++ urlForPage (prefix ++ dropExtension f)] << dropExtension f@@ -713,8 +718,7 @@ let repoPath = repositoryPath cfg let categoryDescription = "Category: " ++ (intercalate " + " pcategories) fs <- getFileStore- files <- liftIO $ index fs- let pages = filter (\f -> isPageFile f && not (isDiscussPageFile f)) files+ pages <- liftIO (index fs) >>= filterM isPageFile >>= filterM isNotDiscussPageFile matches <- liftM catMaybes $ forM pages $ \f -> do categories <- liftIO $ readCategories $ repoPath </> f@@ -751,8 +755,7 @@ cfg <- getConfig let repoPath = repositoryPath cfg fs <- getFileStore- files <- liftIO $ index fs- let pages = filter (\f -> isPageFile f && not (isDiscussPageFile f)) files+ pages <- liftIO (index fs) >>= filterM isPageFile >>= filterM isNotDiscussPageFile categories <- liftIO $ liftM (nub . sort . concat) $ forM pages $ \f -> readCategories (repoPath </> f) base' <- getWikiBase@@ -769,8 +772,9 @@ expireCache :: Handler expireCache = do page <- getPage+ cfg <- getConfig -- try it as a page first, then as an uploaded file- expireCachedFile (pathForPage page)+ expireCachedFile (pathForPage page $ defaultExtension cfg) expireCachedFile page ok $ toResponse () @@ -786,6 +790,7 @@ Nothing -> error "Could not determine base URL" Just hn -> return $ "http://" ++ hn ++ base' else case baseUrl cfg ++ base' of+ w@('h':'t':'t':'p':'s':':':'/':'/':_) -> return w x@('h':'t':'t':'p':':':'/':'/':_) -> return x y -> return $ "http://" ++ y let fc = FeedConfig{
Network/Gitit/Initialize.hs view
@@ -162,11 +162,11 @@ "\n...\n\n" -- add front page, help page, and user's guide let auth = Author "Gitit" ""- createIfMissing fs (frontPage conf <.> "page") auth "Default front page"+ createIfMissing fs (frontPage conf <.> defaultExtension conf) auth "Default front page" $ header ++ welcomecontents- createIfMissing fs "Help.page" auth "Default help page"+ createIfMissing fs ("Help" <.> defaultExtension conf) auth "Default help page" $ header ++ helpcontents- createIfMissing fs "Gitit User’s Guide.page" auth "User’s guide (README)"+ createIfMissing fs ("Gitit User's Guide" <.> defaultExtension conf) auth "User's guide (README)" $ header ++ usersguidecontents createIfMissing :: FileStore -> FilePath -> Author -> Description -> String -> IO ()
Network/Gitit/Plugins.hs view
@@ -37,9 +37,7 @@ logM "gitit" WARNING ("Loading plugin '" ++ pluginName ++ "'...") runGhc (Just libdir) $ do dflags <- getSessionDynFlags- setSessionDynFlags $ dflags{ hscTarget = HscInterpreted- , ghcLink = LinkInMemory- , ghcMode = CompManager }+ setSessionDynFlags dflags defaultCleanupHandler dflags $ do -- initDynFlags unless ("Network.Gitit.Plugin." `isPrefixOf` pluginName)
Network/Gitit/Types.hs view
@@ -110,6 +110,8 @@ repositoryType :: FileStoreType, -- | Default page markup type for this wiki defaultPageType :: PageType,+ -- | Default file extension for pages in this wiki+ defaultExtension :: String, -- | How to handle LaTeX math in pages? mathMethod :: MathMethod, -- | Treat as literate haskell by default?
data/default.conf view
@@ -55,6 +55,10 @@ # css, and images). If it does not exist, gitit will create it # and populate it with required scripts, stylesheets, and images. +default-extension: page+# files in the repository path must have this extension in order+# to be recognized as Wiki pages+ default-page-type: Markdown # specifies the type of markup used to interpret pages in the wiki. # Possible values are Markdown, CommonMark, RST, LaTeX, HTML, Markdown+LHS,
data/static/js/preview.js view
@@ -3,7 +3,7 @@ var url = location.pathname.replace(/_edit\//,"_preview/"); $.post( url,- {"raw" : $("#editedText").attr("value")},+ {"raw" : $("#editedText").val()}, function(data) { $('#previewpane').html(data); // Process any mathematics if we're using MathML
data/templates/page.st view
@@ -4,8 +4,8 @@ <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> $if(feed)$- <link href="$base$/_feed/" type="application/atom+xml" rel="alternate" title="Sitewide ATOM Feed" />- <link href="$base$/_feed$pageUrl$" type="application/atom+xml" rel="alternate" title="This page's ATOM Feed" />+ <link href="$base$/_feed/" type="application/atom+xml" rel="alternate" title="$wikititle$" />+ <link href="$base$/_feed$pageUrl$" type="application/atom+xml" rel="alternate" title="$wikititle$ - $pagetitle$" /> $endif$ <title>$wikititle$ - $pagetitle$</title> $if(printable)$
gitit.cabal view
@@ -1,5 +1,5 @@ name: gitit-version: 0.10.7+version: 0.11 Cabal-version: >= 1.6 build-type: Simple synopsis: Wiki using happstack, git or darcs, and pandoc.@@ -130,7 +130,7 @@ exposed-modules: Network.Gitit.Interface build-depends: ghc, ghc-paths cpp-options: -D_PLUGINS- build-depends: base >= 3, pandoc >= 1.12.4 && < 1.15,+ build-depends: base >= 3, pandoc >= 1.12.4 && < 1.16, pandoc-types >= 1.12.3 && < 1.13, filepath, safe extensions: CPP if impl(ghc >= 6.12)@@ -147,7 +147,7 @@ pretty, xhtml, containers,- pandoc >= 1.12.4 && < 1.15,+ pandoc >= 1.12.4 && < 1.16, pandoc-types >= 1.12.3 && < 1.13, process, filepath,