From c8c09c73cf1fd39c2dfe95653b13d38bf6a9bdc6 Mon Sep 17 00:00:00 2001 From: Freiric Barral Date: Fri, 1 May 2015 21:10:40 +0200 Subject: [PATCH 1/5] deprecated giveUrlRenderer replaced with withUrlRenderer --- src/gitit2.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gitit2.hs b/src/gitit2.hs index a86e02d..101820f 100644 --- a/src/gitit2.hs +++ b/src/gitit2.hs @@ -58,7 +58,7 @@ instance Yesod Master where }); |] contents - giveUrlRenderer [hamlet| + withUrlRenderer [hamlet| $doctype 5 @@ -113,7 +113,7 @@ instance HasGitit Master where getUserR :: Handler Html getUserR = do maid <- maybeAuthId - giveUrlRenderer [hamlet| + withUrlRenderer [hamlet| $maybe aid <- maid

Logout #{aid} $nothing @@ -123,7 +123,7 @@ getUserR = do getMessagesR :: Handler Html getMessagesR = do mmsg <- getMessage - giveUrlRenderer [hamlet| + withUrlRenderer [hamlet| $maybe msg <- mmsg #{msg} |] From c0408b13c9eaa3d48fa73d0c0325d429409910df Mon Sep 17 00:00:00 2001 From: Freiric Barral Date: Wed, 29 Apr 2015 21:44:06 +0200 Subject: [PATCH 2/5] for a page `myPage` in a directory `mySubdirectory` displays the title `myPage` instead of `mySubdirectory/myPage` --- Network/Gitit2/Handler/View.hs | 3 ++- Network/Gitit2/Page.hs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Network/Gitit2/Handler/View.hs b/Network/Gitit2/Handler/View.hs index 33982d1..5f06ea5 100644 --- a/Network/Gitit2/Handler/View.hs +++ b/Network/Gitit2/Handler/View.hs @@ -144,10 +144,11 @@ contentsToWikiPage page contents = do conf <- getConfig plugins' <- getPlugins converter <- wikiLinksConverter (pageToPrefix page) - let title = pageToText page + let title = lastTextFromPage page let defaultFormat = default_format conf foldM applyPlugin (contentToWikiPage' title contents converter defaultFormat) plugins' where + lastTextFromPage (Page ps) = last ps -- | Convert links with no URL to wikilinks. wikiLinksConverter :: Text -> GH master ([Inline] -> String) wikiLinksConverter prefix = do diff --git a/Network/Gitit2/Page.hs b/Network/Gitit2/Page.hs index 5aa9fa4..9a18260 100644 --- a/Network/Gitit2/Page.hs +++ b/Network/Gitit2/Page.hs @@ -35,7 +35,7 @@ textToPage :: Text -> Page textToPage x = Page $ T.splitOn "/" x instance ToMarkup Page where - toMarkup = toMarkup . pageToText + toMarkup (Page ps) = (toMarkup . last) ps instance ToMessage Page where toMessage = pageToText From 9bb8470aeb96d05b8532aef8e3059f165aa6ebd4 Mon Sep 17 00:00:00 2001 From: Freiric Barral Date: Wed, 29 Apr 2015 22:04:35 +0200 Subject: [PATCH 3/5] for wikilink `[directory/bla/blo/mypage]()` display `myPage` instead of `directory/bla/blo/mypage` --- Network/Gitit2/WikiPage.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Network/Gitit2/WikiPage.hs b/Network/Gitit2/WikiPage.hs index 6cad8f4..2b78ed2 100644 --- a/Network/Gitit2/WikiPage.hs +++ b/Network/Gitit2/WikiPage.hs @@ -104,10 +104,13 @@ contentToWikiPage' title contents converter defaultFormat = doc = reader $ toString b Pandoc _ blocks = sanitizePandoc $ addWikiLinks doc convertWikiLinks :: Inline -> Inline - convertWikiLinks (Link ref ("", "")) = Link ref (converter ref, "") + convertWikiLinks (Link ref ("", "")) = Link (linkTitle ref) (converter ref, "") convertWikiLinks (Image ref ("", "")) = Image ref (converter ref, "") convertWikiLinks x = x + linkTitle [Str refStr] = [Str $ T.unpack $ last . T.splitOn "/" $ T.pack refStr] + linkTitle x = x + addWikiLinks :: Pandoc -> Pandoc addWikiLinks = bottomUp (convertWikiLinks) @@ -142,4 +145,3 @@ contentToWikiPage' title contents converter defaultFormat = sanitizeAttr (x,y) = case sanitizeAttribute (T.pack x, T.pack y) of Just (w,z) -> Just (T.unpack w, T.unpack z) Nothing -> Nothing - From 8ab4f672308902d755335106b26cc4c48535d6e9 Mon Sep 17 00:00:00 2001 From: Freiric Barral Date: Fri, 1 May 2015 21:06:07 +0200 Subject: [PATCH 4/5] option to deactivate simple title in wikilinks --- Network/Gitit2/Foundation.hs | 1 + Network/Gitit2/Handler/View.hs | 3 ++- Network/Gitit2/WikiPage.hs | 6 +++--- src/Config.hs | 4 +++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Network/Gitit2/Foundation.hs b/Network/Gitit2/Foundation.hs index 5871df0..64c20ee 100644 --- a/Network/Gitit2/Foundation.hs +++ b/Network/Gitit2/Foundation.hs @@ -64,6 +64,7 @@ data GititConfig = GititConfig{ , front_page :: Text -- ^ Front page of wiki , help_page :: Text -- ^ Help page , latex_engine :: Maybe FilePath -- ^ LaTeX engine to use for PDF export + , simple_title :: Bool -- ^ Hide directory structure for wikilinks? If True `[dir/subdir/mySubpage]()` rendered as mySubpage. } -- | A user. diff --git a/Network/Gitit2/Handler/View.hs b/Network/Gitit2/Handler/View.hs index 5f06ea5..42f93c2 100644 --- a/Network/Gitit2/Handler/View.hs +++ b/Network/Gitit2/Handler/View.hs @@ -146,7 +146,8 @@ contentsToWikiPage page contents = do converter <- wikiLinksConverter (pageToPrefix page) let title = lastTextFromPage page let defaultFormat = default_format conf - foldM applyPlugin (contentToWikiPage' title contents converter defaultFormat) plugins' + simpleTitle = simple_title conf + foldM applyPlugin (contentToWikiPage' title contents converter defaultFormat simpleTitle) plugins' where lastTextFromPage (Page ps) = last ps -- | Convert links with no URL to wikilinks. diff --git a/Network/Gitit2/WikiPage.hs b/Network/Gitit2/WikiPage.hs index 2b78ed2..609e81b 100644 --- a/Network/Gitit2/WikiPage.hs +++ b/Network/Gitit2/WikiPage.hs @@ -62,8 +62,8 @@ readPageFormat s = where (s',rest) = T.break (=='+') s lhs = rest == "+lhs" -contentToWikiPage' :: Text -> ByteString -> ([Inline] -> String) -> PageFormat -> WikiPage -contentToWikiPage' title contents converter defaultFormat = +contentToWikiPage' :: Text -> ByteString -> ([Inline] -> String) -> PageFormat -> Bool -> WikiPage +contentToWikiPage' title contents converter defaultFormat simpleTitle = WikiPage { wpName = title , wpFormat = format @@ -108,7 +108,7 @@ contentToWikiPage' title contents converter defaultFormat = convertWikiLinks (Image ref ("", "")) = Image ref (converter ref, "") convertWikiLinks x = x - linkTitle [Str refStr] = [Str $ T.unpack $ last . T.splitOn "/" $ T.pack refStr] + linkTitle [Str refStr] | simpleTitle = [Str $ T.unpack $ last . T.splitOn "/" $ T.pack refStr] linkTitle x = x addWikiLinks :: Pandoc -> Pandoc diff --git a/src/Config.hs b/src/Config.hs index ee88ca6..246e779 100644 --- a/src/Config.hs +++ b/src/Config.hs @@ -48,6 +48,7 @@ data Conf = Conf { cfg_port :: Int , cfg_help_page :: Text , cfg_max_upload_size :: String , cfg_latex_engine :: Maybe FilePath + , cfg_simple_title :: Bool } data FoundationSettings = FoundationSettings { @@ -88,6 +89,7 @@ parseConfig os = Conf <*> os `parseElem` "help_page" .!= "Help" <*> os `parseElem` "max_upload_size" .!= "1M" <*> os `parseElem` "latex_engine" + <*> os `parseElem` "simple_title" .!= True -- | Ready collection of common mime types. (Copied from -- Happstack.Server.HTTP.FileServe.) @@ -128,7 +130,6 @@ readMimeTypesFile f = catch warn $ "Could not parse mime types file.\n" ++ show e return mimeTypes - gititConfigFromConf :: Conf -> IO GititConfig gititConfigFromConf conf = do mimes <- case cfg_mime_types_file conf of @@ -154,5 +155,6 @@ gititConfigFromConf conf = do , front_page = cfg_front_page conf , help_page = cfg_help_page conf , latex_engine = cfg_latex_engine conf + , simple_title = cfg_simple_title conf } return gconfig From 455be4cff328f2e3aa0424a3cc1fd0a8b3519686 Mon Sep 17 00:00:00 2001 From: Freiric Barral Date: Fri, 1 May 2015 21:47:57 +0200 Subject: [PATCH 5/5] added comments in settings about option simple_title --- settings.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/settings.yaml b/settings.yaml index c7b8df1..53e04d3 100644 --- a/settings.yaml +++ b/settings.yaml @@ -14,3 +14,6 @@ front_page: Front Page help_page: Help max_upload_size: 1M latex_engine: xelatex +# when simple_title is true it displays `myPage` for wikilinks like `[directory/bla/blo/mypage]()` +# defaults to True +# simple_title: False