mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-29 22:42:52 -06:00
the grammars are now recognized by extension i.e. .pgf is grammar just like .php is a PHP script
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user