From 44d1a5a9f71b03d9aceeccd760a63fcdc45f8bad Mon Sep 17 00:00:00 2001 From: hallgren Date: Wed, 12 Oct 2011 17:03:54 +0000 Subject: Improvements of "gf -server" mode and related setup "gf -server" mode now contains everything needed to run the minibar and the grammar editor (including example-based grammar writing). The Setup.hs script installs the required files where gf -server can find them. These files have been moved to a new directory: src/www. The separate server program pgf-http is now obsolete. --- WebSetup.hs | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 WebSetup.hs (limited to 'WebSetup.hs') diff --git a/WebSetup.hs b/WebSetup.hs new file mode 100644 index 000000000..c0ac0a66c --- /dev/null +++ b/WebSetup.hs @@ -0,0 +1,62 @@ +module WebSetup(installWeb,copyWeb) where + +import System.Directory(createDirectoryIfMissing,copyFile,removeFile) +import System.FilePath(()) +import System.Cmd(system) +import System.Exit(ExitCode(..)) +import Distribution.Simple.Setup(Flag(..),CopyDest(..),copyDest) +import Distribution.Simple.LocalBuildInfo(datadir,buildDir,absoluteInstallDirs) + +{- + To test the GF web services, the minibar and the grammar editor, use + "cabal install" (or "runhaskell Setup.hs install") to install gf as usual. + Then start the server with the command "gf -server" and + open http://localhost:41296/minibar/minibar.html in your web browser + (Firefox, Safari, Opera or Chrome). The example grammars listed below will + be available in the minibar. +-} + +example_grammars = -- :: [(pgf, tmp, src)] + [("Foods.pgf","foods","contrib""summerschool""foods""Foods???.gf"), + ("Letter.pgf","letter","examples""letter""Letter???.gf")] + + +installWeb args flags pki lbi = setupWeb args dest pki lbi + where + dest = NoCopyDest + +copyWeb args flags pki lbi = setupWeb args dest pki lbi + where + dest = case copyDest flags of + NoFlag -> NoCopyDest + Flag d -> d + +setupWeb args dest pkg lbi = + do putStrLn "setupWeb" + mapM_ (createDirectoryIfMissing True) [grammars_dir,cloud_dir] + mapM_ build_pgf example_grammars + where + grammars_dir = www_dir "grammars" + cloud_dir = www_dir "tmp" -- hmm + www_dir = datadir (absoluteInstallDirs pkg lbi dest) "www" + gfo_dir = buildDir lbi "gfo" + + build_pgf (pgf,tmp,src) = + do createDirectoryIfMissing True tmp_dir + execute cmd + copyFile pgf (grammars_dirpgf) + putStrLn (grammars_dirpgf) + removeFile pgf + where + tmp_dir = gfo_dirtmp + cmd = "gf -make -s -optimize-pgf --gfo-dir="++tmp_dir++ + -- " --output-dir="++grammars_dir++ -- has no effect?! + " "++src + +execute command = + do putStrLn command + e <- system command + case e of + ExitSuccess -> return () + _ -> fail "Command failed" + return () -- cgit v1.2.3