{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE TypeOperators #-} {-# OPTIONS -fno-warn-orphans #-} module Dixi.Markup where import Control.Lens import Data.Foldable (toList) import Data.Maybe (fromMaybe) import Data.Monoid import Data.Patch (Hunks, HunkStatus(..)) import Data.Proxy import Data.Text (Text) import Servant.API import Servant.HTML.Blaze import Text.Blaze import Text.Cassius import Text.Hamlet (shamlet, Html) import Text.Pandoc.Error import qualified Data.Text as T import Dixi.API import Dixi.Common import Dixi.Config import Dixi.Page import Dixi.Hamlet import Dixi.PatchUtils link :: (IsElem endpoint Dixi, HasLink endpoint) => Proxy endpoint -> MkLink endpoint link = safeLink dixi renderTitle :: Text -> Text renderTitle = T.pack . map (\c -> if c == '_' then ' ' else c) . T.unpack prettyUrl :: Proxy ( Capture "page" Key :> "history" :> Capture "version" Version :> Get '[HTML] PrettyPage ) prettyUrl = Proxy latestUrl :: Proxy (Capture "page" Key :> Get '[HTML] PrettyPage) latestUrl = Proxy rawUrl :: Proxy ( Capture "page" Key :> "history" :> Capture "version" Version :> "raw" :> Get '[HTML] RawPage ) rawUrl = Proxy amendUrl :: Proxy ( Capture "page" Key :> "history" :> Capture "version" Version :> ReqBody '[FormUrlEncoded] NewBody :> Post '[HTML] PrettyPage ) amendUrl = Proxy diffUrl :: Proxy (Capture "page" Key :> "history" :> "diff" :> Get '[HTML] DiffPage) diffUrl = Proxy historyUrl :: Proxy (Capture "page" Key :> "history" :> Get '[HTML] History) historyUrl = Proxy revertUrl :: Proxy (Capture "page" Key :> "history" :> "revert" :> ReqBody '[FormUrlEncoded] RevReq :> Post '[HTML] PrettyPage) revertUrl = Proxy stylesheet :: Css stylesheet = [cassius| div.body margin: 1em table.history border: 0px td border: 0px button width: 100% padding: 4px tr border: 0px .hist-version text-align:right .histh-comment text-align:left .histh-version padding-right:5px .hist-fromto text-align:center body font-family: PT Serif, Palatino, Georgia, Times, serif margin: 0px .toolbar background: #BBBBAA border-top: 1px solid #888877 border-bottom: 1px solid #EEEEDD a:hover background: #F1F1D9 border: 1px outset #F1F1D9 a:active background: #F1F1D9 border: 1px inset #F1F1D9 a background: #DCDCCB border: 1px outset #F1F1D9 text-decoration: none color: black padding: 2px margin-top: 2px margin-bottom: 2px margin-left: 2px .header background: #FFFFDD font-size: 1.5em font-weight: bold padding-left: 0.5em padding-top: 0.5em padding-bottom: 0.5em .subtitle float:right font-size: 0.8em margin-right: 0.5em color: gray position: relative top: -2.5em .addition-sum background: #B5F386 padding: 3px border-radius: 6px 0px 0px 6px margin-top:1px; margin-bottom:1px; .subtraction-sum background: #EC8160 padding: 3px margin-top:1px; margin-bottom:1px; .replacement-sum background: #F3E686 padding: 3px border-radius: 0px 6px 6px 0px margin-top:1px; margin-bottom:1px; .hunk white-space: pre font-family:monospace border-radius: 4px; .hunk-inserted background: #B5F386 .hunk-deleted background: #EC8160 text-decoration: line-through; .hunk-replaced background: #F3E686 .timestamp color: #444444 font-size: small div.timestamp margin-left: 0.5em margin-top: 2em |] undefined outerMatter :: Text -> Html -> Html outerMatter title bod = [shamlet| $doctype 5