summaryrefslogtreecommitdiff
path: root/src/compiler/GF
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2016-06-15 10:20:30 +0000
committerhallgren <hallgren@chalmers.se>2016-06-15 10:20:30 +0000
commit12d2296991aad74ec0ae5f837aa27119ca062196 (patch)
tree53b881de0b0c62b6a314e687bfdcf11e7f4b436f /src/compiler/GF
parent1465a825d584c087d7b93db73f92fe77847772ce (diff)
GF cloud: more readable formatting of the GF version page
Factor out common CSS from gfse/editor.css into clouds.css.
Diffstat (limited to 'src/compiler/GF')
-rw-r--r--src/compiler/GF/Server.hs31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/compiler/GF/Server.hs b/src/compiler/GF/Server.hs
index d5c84b87c..de0ec6abc 100644
--- a/src/compiler/GF/Server.hs
+++ b/src/compiler/GF/Server.hs
@@ -161,11 +161,7 @@ handle logLn documentroot state0 cache execute1 stateVar
-- "/stop" ->
-- "/start" ->
"/parse" -> parse (decoded qs)
- "/version" -> do (c1,c2) <- PS.listPGFCache cache
- let rel = makeRelative documentroot
- sh1 (path,t) = rel path++" "++show t
- sh = map sh1
- return $ ok200 (unlines (gf_version:"":sh c1++"":sh c2))
+ "/version" -> versionInfo `fmap` PS.listPGFCache cache
"/flush" -> do PS.flushPGFCache cache; return (ok200 "flushed")
'/':rpath ->
-- This code runs without mutual exclusion, so it must *not*
@@ -183,6 +179,27 @@ handle logLn documentroot state0 cache execute1 stateVar
translatePath rpath = root</>rpath -- hmm, check for ".."
+ versionInfo (c1,c2) =
+ html200 . unlines $
+ "<!DOCTYPE html>":
+ "<meta name = \"viewport\" content = \"width = device-width\">":
+ "<link rel=\"stylesheet\" type=\"text/css\" href=\"cloud.css\" title=\"Cloud\">":
+ "":
+ ("<h2>"++hdr++"</h2>"):
+ (zipWith (++) ("<p>":repeat "<br>") buildinfo)++
+ sh "Haskell run-time system" c1++
+ sh "C run-time system" c2
+ where
+ hdr:buildinfo = lines gf_version
+ rel = makeRelative documentroot
+ sh1 (path,t) = "<tr><td>"++rel path++"<td>"++show t
+ sh _ [] = []
+ sh hdr gs =
+ "":("<h3>"++hdr++"</h3>"):
+ "<table class=loaded_grammars><tr><th>Grammar<th>Last modified":
+ map sh1 gs++
+ ["</table>"]
+
wrapCGI cgi = cgiHandler root (handleErrors . handleCGIErrors $ cgi) rq
look field =
@@ -371,7 +388,7 @@ ok200' t = Response 200 [t,xo]
json200 x = json200' id x
json200' f = ok200' jsonUTF8 . encodeString . f . encode
jsonp200' f = ok200' jsonpUTF8 . encodeString . f . encode
---html200 = ok200' htmlUTF8 . encodeString
+html200 = ok200' htmlUTF8 . encodeString
resp204 = Response 204 [xo] "" -- no content
resp301 url = Response 301 [plain,xo,location url] $
"Moved permanently to "++url
@@ -389,7 +406,7 @@ plain = ct "text/plain" ""
plainUTF8 = ct "text/plain" csutf8
jsonUTF8 = ct "application/json" csutf8 -- http://www.ietf.org/rfc/rfc4627.txt
jsonpUTF8 = ct "application/javascript" csutf8
---htmlUTF8 = ct "text/html" csutf8
+htmlUTF8 = ct "text/html" csutf8
ct t cs = ("Content-Type",t++cs)
csutf8 = "; charset=UTF-8"