examples: don't depend on pandoc & servant-pandoc, just serve a markdown file

This commit is contained in:
Alp Mestanogullari 2015-05-09 16:27:36 +02:00
parent 616b203792
commit a403eee488
2 changed files with 4 additions and 29 deletions

View file

@ -13,9 +13,6 @@ import Network.HTTP.Types
import Network.Wai import Network.Wai
import Servant import Servant
import Servant.Docs import Servant.Docs
import Servant.Docs.Pandoc (pandoc)
import Text.Pandoc.Options (def, WriterOptions(..))
import Text.Pandoc.Writers.HTML (writeHtmlString)
import qualified GS3 import qualified GS3
type DocsAPI = GS3.API :<|> Raw type DocsAPI = GS3.API :<|> Raw
@ -57,38 +54,18 @@ api = Proxy
docsBS :: ByteString docsBS :: ByteString
docsBS = encodeUtf8 docsBS = encodeUtf8
. pack . pack
. writeHtmlString opts . markdown
. pandoc
$ docsWithIntros [intro] GS3.api $ docsWithIntros [intro] GS3.api
where opts = def { writerHtml5 = True where intro = DocIntro "Welcome" ["This is our super webservice's API.", "Enjoy!"]
, writerTableOfContents = True
, writerHighlight = True
, writerStandalone = True
, writerTemplate =
concat
[ "<!DOCTYPE html><html>"
, "<head>"
, "<meta charset=\"UTF-8\">"
, "<title>API Docs - $title$</title>"
, "</head>"
, "<body>"
, "$toc$"
, "<hr />"
, "$body$"
, "</body>"
, "</html>"
]
}
intro = DocIntro "Welcome" ["This is our super webservice's API.", "Enjoy!"]
server :: Server DocsAPI server :: Server DocsAPI
server = GS3.server :<|> serveDocs server = GS3.server :<|> serveDocs
where serveDocs _ respond = where serveDocs _ respond =
respond $ responseLBS ok200 [html] docsBS respond $ responseLBS ok200 [plain] docsBS
html = ("Content-Type", "text/html") plain = ("Content-Type", "text/plain")
app :: Application app :: Application
app = serve api server app = serve api server

View file

@ -25,13 +25,11 @@ executable getting-started
, http-types , http-types
, js-jquery , js-jquery
, lucid , lucid
, pandoc
, probable , probable
, servant , servant
, servant-docs , servant-docs
, servant-jquery , servant-jquery
, servant-lucid , servant-lucid
, servant-pandoc >= 0.2
, servant-server , servant-server
, text , text
, time , time