{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE ConstraintKinds #-} {-# 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.Blaze.Renderer.Utf8 (renderMarkup) import Text.Hamlet (shamlet, Html) import Text.Heredoc import Text.Lucius import Text.Pandoc.Error import qualified Data.Text as T import qualified Data.Text.Lazy as L import qualified Data.ByteString.Lazy as B 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, JSON] PrettyPage ) prettyUrl = Proxy latestUrl :: Proxy (Capture "page" Key :> Get '[HTML, JSON] PrettyPage) latestUrl = Proxy rawUrl :: Proxy ( Capture "page" Key :> "history" :> Capture "version" Version :> "raw" :> Get '[HTML, JSON] RawPage ) rawUrl = Proxy amendUrl :: Proxy ( Capture "page" Key :> "history" :> Capture "version" Version :> ReqBody '[FormUrlEncoded, JSON] NewBody :> Post '[HTML, JSON] PrettyPage ) amendUrl = Proxy diffUrl :: Proxy (Capture "page" Key :> "history" :> "diff" :> Get '[HTML, JSON] DiffPage) diffUrl = Proxy historyUrl :: Proxy (Capture "page" Key :> "history" :> Get '[HTML, JSON] History) historyUrl = Proxy revertUrl :: Proxy (Capture "page" Key :> "history" :> "revert" :> ReqBody '[FormUrlEncoded, JSON] RevReq :> Post '[HTML, JSON] PrettyPage) revertUrl = Proxy outerMatter :: Html -> Text -> Html -> Html outerMatter ss title bod = [shamlet| $doctype 5
#{ss}