Server: add files.

This allows the user to upload auxiliary files to be used in
the conversion.
This commit is contained in:
John MacFarlane 2022-08-14 17:14:59 -07:00
parent 4e04947470
commit 3966b016d1
2 changed files with 25 additions and 13 deletions

View file

@ -802,6 +802,7 @@ executable pandoc-server
containers,
data-default,
bytestring,
skylighting,
base64 >= 0.4,
servant-server,
wai >= 0.3,

View file

@ -26,28 +26,39 @@ import Data.Default
import Data.Set (Set)
import Skylighting (defaultSyntaxMap)
data FileSpec = FileSpec
{ path :: Text
, contents :: Text
, base64 :: Maybe Bool
} deriving (Show)
-- Automatically derive code to convert to/from JSON.
$(deriveJSON defaultOptions ''FileSpec)
-- This is the data to be supplied by the JSON payload
-- of requests. Maybe values may be omitted and will be
-- given default values.
data Params = Params
{ text: :: Text
, from: :: Maybe Text
, to: :: Maybe Text
, wrapText: :: Maybe WrapOption
, columns: :: Maybe Int
, standalone: :: Maybe Bool
, template: :: Maybe Text
, tabStop: :: Maybe Int
, indentedCodeClasses: :: Maybe [Text]
, abbreviations: :: Maybe (Set Text)
, defaultImageExtension: :: Maybe Text
, trackChanges: :: Maybe TrackChanges
, stripComments: :: Maybe Bool
{ text :: Text
, files :: Maybe [FileSpec]
, from :: Maybe Text
, to :: Maybe Text
, wrapText :: Maybe WrapOption
, columns :: Maybe Int
, standalone :: Maybe Bool
, template :: Maybe Text
, tabStop :: Maybe Int
, indentedCodeClasses :: Maybe [Text]
, abbreviations :: Maybe (Set Text)
, defaultImageExtension :: Maybe Text
, trackChanges :: Maybe TrackChanges
, stripComments :: Maybe Bool
} deriving (Show)
instance Default Params where
def = Params
{ text = ""
, files = Nothing
, from = Nothing
, to = Nothing
, wrapText = Nothing