mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 03:32:51 -06:00
fastcgi: replace /categories, /languages and /mylanguage with /info.
This commit is contained in:
@@ -36,9 +36,7 @@ cgiMain pgf =
|
|||||||
"/complete" -> return (doComplete pgf) `ap` getText `ap` getCat `ap` getFrom `ap` getLimit
|
"/complete" -> return (doComplete pgf) `ap` getText `ap` getCat `ap` getFrom `ap` getLimit
|
||||||
"/linearize" -> return (doLinearize pgf) `ap` getTree `ap` getTo
|
"/linearize" -> return (doLinearize pgf) `ap` getTree `ap` getTo
|
||||||
"/translate" -> return (doTranslate pgf) `ap` getText `ap` getCat `ap` getFrom `ap` getTo
|
"/translate" -> return (doTranslate pgf) `ap` getText `ap` getCat `ap` getFrom `ap` getTo
|
||||||
"/categories" -> return $ doCategories pgf
|
"/info" -> return (doInfo pgf) `ap` requestAcceptLanguage
|
||||||
"/languages" -> return $ doLanguages pgf
|
|
||||||
"/mylanguage" -> return (doMyLanguage pgf) `ap` requestAcceptLanguage
|
|
||||||
_ -> throwCGIError 404 "Not Found" ["Resource not found: " ++ path]
|
_ -> throwCGIError 404 "Not Found" ["Resource not found: " ++ path]
|
||||||
outputJSON json
|
outputJSON json
|
||||||
where
|
where
|
||||||
@@ -102,19 +100,18 @@ doLinearize :: PGF -> PGF.Tree -> Maybe PGF.Language -> JSValue
|
|||||||
doLinearize pgf tree mto = showJSON $ map toJSObject
|
doLinearize pgf tree mto = showJSON $ map toJSObject
|
||||||
[[("to",to),("text",text)] | (to,text) <- linearize' pgf mto tree]
|
[[("to",to),("text",text)] | (to,text) <- linearize' pgf mto tree]
|
||||||
|
|
||||||
doLanguages :: PGF -> JSValue
|
doInfo :: PGF -> Maybe (Accept Language) -> JSValue
|
||||||
doLanguages pgf = showJSON $ map toJSObject
|
doInfo pgf macc = showJSON $ toJSObject
|
||||||
[[("name", showJSON l),
|
[("name", showJSON (PGF.abstractName pgf)),
|
||||||
("languageCode", showJSON $ fromMaybe "" (PGF.languageCode pgf l)),
|
("userLanguage", showJSON (selectLanguage pgf macc)),
|
||||||
("canParse", showJSON $ PGF.canParse pgf l)]
|
("categories", showJSON categories),
|
||||||
| l <- PGF.languages pgf]
|
("languages", showJSON languages)]
|
||||||
|
where languages = map toJSObject
|
||||||
doCategories :: PGF -> JSValue
|
[[("name", showJSON l),
|
||||||
doCategories pgf = showJSON $ map toJSObject
|
("languageCode", showJSON $ fromMaybe "" (PGF.languageCode pgf l)),
|
||||||
[[("cat",cat)] | cat <- PGF.categories pgf]
|
("canParse", showJSON $ PGF.canParse pgf l)]
|
||||||
|
| l <- PGF.languages pgf]
|
||||||
doMyLanguage :: PGF -> Maybe (Accept Language) -> JSValue
|
categories = map toJSObject [[("cat", cat)] | cat <- PGF.categories pgf]
|
||||||
doMyLanguage pgf macc = showJSON $ toJSObject [("languageName", selectLanguage pgf macc)]
|
|
||||||
|
|
||||||
-- * PGF utilities
|
-- * PGF utilities
|
||||||
|
|
||||||
|
|||||||
@@ -170,6 +170,10 @@ public class Translate implements EntryPoint {
|
|||||||
}
|
}
|
||||||
toLangBox.addItem(l.getName());
|
toLangBox.addItem(l.getName());
|
||||||
}
|
}
|
||||||
|
gf.mylanguage(new GF.MyLanguageCallback() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
setStatus("Loaded languages.");
|
setStatus("Loaded languages.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user