diff options
| author | hallgren <hallgren@chalmers.se> | 2013-03-26 14:17:24 +0000 |
|---|---|---|
| committer | hallgren <hallgren@chalmers.se> | 2013-03-26 14:17:24 +0000 |
| commit | 1962574941f8d009578dbc9bb92ea28e86c71afa (patch) | |
| tree | eafb6100153de3883acbe0c3a3429ac2f2f9ca73 /src/server/PGFService.hs | |
| parent | 9faa3407ab22116bfcd0b3a4b1040176e4162bb6 (diff) | |
PGF service: support all parse tree visualziation options in the web API
The new options are
* noleaves, nofun, nocat (booleans, false by default)
* nodefont, leaffont, nodecolor, leafcolor, nodeedgestyle, leafedgestyle
(strings, empty by default)
Diffstat (limited to 'src/server/PGFService.hs')
| -rw-r--r-- | src/server/PGFService.hs | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/server/PGFService.hs b/src/server/PGFService.hs index c537fc0f8..3a43d4589 100644 --- a/src/server/PGFService.hs +++ b/src/server/PGFService.hs @@ -72,7 +72,8 @@ pgfMain command pgf = "alignment" -> outputGraphviz =<< alignment pgf # tree % to "parsetree" -> do t <- tree Just l <- from - outputGraphviz (parseTree pgf l t) + opts <- graphvizOptions + outputGraphviz (parseTree pgf l opts t) "abstrjson" -> out . jsonExpr =<< tree "browse" -> join $ doBrowse pgf # optId % cssClass % href % format "html" % getIncludePrintNames "external" -> do cmd <- getInput "external" @@ -147,6 +148,20 @@ pgfMain command pgf = getIncludePrintNames :: CGI Bool getIncludePrintNames = maybe False (const True) # getInput "printnames" + graphvizOptions = + PGF.GraphvizOptions # bool "noleaves" + % bool "nofun" + % bool "nocat" + % string "nodefont" + % string "leaffont" + % string "nodecolor" + % string "leafcolor" + % string "nodeedgestyle" + % string "leafedgestyle" + where + string name = maybe "" id # getInput name + bool name = maybe False toBool # getInput name + toBool s = s `elem` ["","yes","true","True"] errorMissingId = throwCGIError 400 "Missing identifier" [] @@ -342,9 +357,9 @@ outputGraphviz code = -- ... _ -> "application/binary" -abstrTree pgf tree = PGF.graphvizAbstractTree pgf (True,True) tree -parseTree pgf lang tree = PGF.graphvizParseTree pgf lang PGF.graphvizDefaults tree -alignment pgf tree tos = PGF.graphvizAlignment pgf tos' tree +abstrTree pgf tree = PGF.graphvizAbstractTree pgf (True,True) tree +parseTree pgf lang opts tree = PGF.graphvizParseTree pgf lang opts tree +alignment pgf tree tos = PGF.graphvizAlignment pgf tos' tree where tos' = if null tos then PGF.languages pgf else tos pipeIt2graphviz :: String -> String -> IO BS.ByteString |
