summaryrefslogtreecommitdiff
path: root/src/server/PGFService.hs
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2009-01-25 22:06:20 +0000
committerkrasimir <krasimir@chalmers.se>2009-01-25 22:06:20 +0000
commit92bb971ea3e13a69e74c078af7c16f0c95ee0a63 (patch)
tree932b85011a15ee56ec847d8d845defb8a2926e18 /src/server/PGFService.hs
parent7dfc17cd98852250a62040c3b02c526772fdb4bd (diff)
the grammars are now recognized by extension i.e. .pgf is grammar just like .php is a PHP script
Diffstat (limited to 'src/server/PGFService.hs')
-rw-r--r--src/server/PGFService.hs15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/server/PGFService.hs b/src/server/PGFService.hs
index 070f83b49..576ba7a30 100644
--- a/src/server/PGFService.hs
+++ b/src/server/PGFService.hs
@@ -34,19 +34,12 @@ main = do stderrToFile logFile
cgiMain :: Cache PGF -> CGI CGIResult
cgiMain cache =
- do path <- pathInfo
- jsonp <- serveResource cache $ filter (not . null) $ splitBy (=='/') path
+ do path <- getVarWithDefault "SCRIPT_FILENAME" ""
+ pgf <- liftIO $ readCache cache path
+ command <- liftM (maybe "grammar" (urlDecodeUnicode . UTF8.decodeString)) (getInput "command")
+ jsonp <- pgfMain pgf command
outputJSONP jsonp
-serveResource :: Cache PGF -> [String] -> CGI JSValue
-serveResource cache resource =
- case resource of
- [] -> liftIO doListGrammars
- [file] -> serveResource cache [file,"grammar"]
- [file,command] -> do pgf <- liftIO $ readCache cache $ cleanFilePath file
- pgfMain pgf command
- _ -> throwCGIError 400 "Unknown resource" ["Unknown resource: " ++ show resource]
-
pgfMain :: PGF -> String -> CGI JSValue
pgfMain pgf command =
case command of