mirror of
https://code.sup39.dev/repos/Wqawg
synced 2024-12-27 19:24:52 +09:00
Use path segment in HighlightStyleR, addStylesheet doesn't support query params
This commit is contained in:
parent
e02a0fa4db
commit
eb514b8c3f
5 changed files with 19 additions and 15 deletions
|
@ -20,7 +20,7 @@
|
|||
/favicon.ico FaviconR GET
|
||||
/robots.txt RobotsR GET
|
||||
|
||||
/highlight.css HighlightStyleR GET
|
||||
/highlight/#Text/style.css HighlightStyleR GET
|
||||
|
||||
-- ----------------------------------------------------------------------------
|
||||
-- Federation
|
||||
|
|
|
@ -363,14 +363,9 @@ postRepoDevR shr rp dev = do
|
|||
Just "DELETE" -> deleteRepoDevR shr rp dev
|
||||
_ -> notFound
|
||||
|
||||
getHighlightStyleR :: Handler TypedContent
|
||||
getHighlightStyleR = do
|
||||
styleName <- do
|
||||
ms <- lookupGetParam "style"
|
||||
case ms of
|
||||
Nothing -> getsYesod $ appHighlightStyle . appSettings
|
||||
Just s -> return $ unpack s
|
||||
case lookup styleName highlightingStyles of
|
||||
getHighlightStyleR :: Text -> Handler TypedContent
|
||||
getHighlightStyleR styleName =
|
||||
case lookup (unpack styleName) highlightingStyles of
|
||||
Nothing -> notFound
|
||||
Just style ->
|
||||
return $ TypedContent typeCss $ toContent $ styleToCss style
|
||||
|
|
|
@ -85,8 +85,11 @@ getDarcsRepoSource repository user repo dir = do
|
|||
dirs = zip parent (tail $ inits parent)
|
||||
defaultLayout $ do
|
||||
ms <- lookupGetParam "style"
|
||||
let mparam = ("style",) <$> ms
|
||||
addStylesheetAttrs HighlightStyleR $ maybeToList mparam
|
||||
style <-
|
||||
case ms of
|
||||
Nothing -> getsYesod $ appHighlightStyle . appSettings
|
||||
Just s -> return s
|
||||
addStylesheet $ HighlightStyleR style
|
||||
$(widgetFile "repo/source-darcs")
|
||||
|
||||
getDarcsRepoHeadChanges :: ShrIdent -> RpIdent -> Handler TypedContent
|
||||
|
|
|
@ -95,8 +95,11 @@ getGitRepoSource repository user repo ref dir = do
|
|||
dirs = zip parent (tail $ inits parent)
|
||||
defaultLayout $ do
|
||||
ms <- lookupGetParam "style"
|
||||
let mparam = ("style",) <$> ms
|
||||
addStylesheetAttrs HighlightStyleR $ maybeToList mparam
|
||||
style <-
|
||||
case ms of
|
||||
Nothing -> getsYesod $ appHighlightStyle . appSettings
|
||||
Just s -> return s
|
||||
addStylesheet $ HighlightStyleR style
|
||||
$(widgetFile "repo/source-git")
|
||||
|
||||
getGitRepoHeadChanges :: Repo -> ShrIdent -> RpIdent -> Handler TypedContent
|
||||
|
|
|
@ -43,6 +43,9 @@ import Text.Pandoc.Highlighting
|
|||
import Yesod.Default.Config2 (applyEnvValue, configSettingsYml)
|
||||
import Yesod.Default.Util (WidgetFileSettings, widgetFileNoReload,
|
||||
widgetFileReload)
|
||||
|
||||
import qualified Data.Text as T
|
||||
|
||||
import Yesod.Mail.Send (MailSettings)
|
||||
|
||||
-- | Runtime settings to configure this application. These settings can be
|
||||
|
@ -158,7 +161,7 @@ data AppSettings = AppSettings
|
|||
|
||||
-- | Default color scheme for syntax highlighting of code blocks inside
|
||||
-- documentes rendered with pandoc.
|
||||
, appHighlightStyle :: String
|
||||
, appHighlightStyle :: Text
|
||||
}
|
||||
|
||||
instance FromJSON AppSettings where
|
||||
|
@ -214,7 +217,7 @@ instance FromJSON AppSettings where
|
|||
s <- o .:? "highlight-style" .!= "zenburn"
|
||||
case lookup s highlightingStyles of
|
||||
Nothing -> fail $ "Highlighting style " ++ s ++ " not found"
|
||||
Just _ -> return s
|
||||
Just _ -> return $ T.pack s
|
||||
|
||||
return AppSettings {..}
|
||||
where
|
||||
|
|
Loading…
Reference in a new issue