From 92bb971ea3e13a69e74c078af7c16f0c95ee0a63 Mon Sep 17 00:00:00 2001 From: krasimir Date: Sun, 25 Jan 2009 22:06:20 +0000 Subject: the grammars are now recognized by extension i.e. .pgf is grammar just like .php is a PHP script --- src/server/PGFService.hs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'src/server/PGFService.hs') 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 -- cgit v1.2.3