1
0
forked from GitHub/gf-core
Commit Graph

54 Commits

Author SHA1 Message Date
hallgren
782bdf3a52 (1) Refactor concurrency, (2) write to .gfo.tmp then rename to .gfo
(1) introduces the module GF.Infra.Concurreny with lifted concurrency
    operators (to reduce uses of liftIO) and some additional concurrency
    utilities, e.g. a function for sequential logging that is used in
    both GF.CompileInParallel and GFServer.
(2) avoids leaving broken .gfo files behind if compilation is aborted.
2014-09-08 15:43:20 +00:00
hallgren
0e87a88f4b src/server: refactoring to isolate dependencies on the cgi/fastcgi packages
* Introducing the module CGI, re-exporting a subset of the cgi package. It
  might complete replace the cgi package in the future.
* Introducing the module CGIUtils, containing functions from FastCGIUtils that
  have nothing to do with fastcgi.

Some low level hackery with unsafePerformIO and global variables was left
in FastCGIUtils, but it is actually not used, neither for gf -server nor
exec/pgf-fcgi.hs.
2014-09-02 12:27:47 +00:00
hallgren
e1644ef319 Add lifted directory operations in GF.System.Directory to eliminate the need for liftIO in various places 2014-08-20 17:47:08 +00:00
hallgren
3c110cbe8d gf -server: include list of loaded PGFs in version info 2014-05-12 13:45:36 +00:00
hallgren
43e61a1e3b PGF web service: add unlexers and enable client side caching
Most PGF web API commands that produce linearizations now accept an
unlexer parameter. Possible values are "text", "code" and "mixed".

The web service now include Date and Last-Modified headers in the HTTP,
responses. This means that browsers can treat responses as static content and
cache them, so it becomes less critical to cache parse results in the server.

Also did some cleanup in PGFService.hs, e.g. removed a couple of functions
that can now be imported from PGF.Lexing instead.
2014-04-09 17:51:25 +00:00
hallgren
6cc8557e6b gf -server: add a command to manually flush the PGF cache
This can be used if the cloud service seems slow, but it would probably
be better to automatically expire unused PGFs from the cache after some time.
2014-03-19 16:15:05 +00:00
hallgren
d99f3e19d7 GFServer.hs: avoid intertwined log messages from parallel requests 2014-02-11 14:22:12 +00:00
hallgren
1d251b2395 gf -server: fix a redirection bug...
...that was introduced with the recent changes to the handling of the
current working directory
2014-01-27 16:30:03 +00:00
hallgren
39a0d9b668 gf -server: allow multiple PGF service requests to be handled in parallel
PGF service requests are stateless and can run in parallel, but some other
requests handled by the server are not and might even change the current
working directory temporarily, and this affects all threads, so it is
important that the PGF service requests access PGF files by absolute paths.
2014-01-24 13:49:02 +00:00
hallgren
b8f3914209 Optionally include C run-time support
If the C run-time library is compiled and installed on your system, you can now
do 'cabal configure -fc-runtime' to get the following extras:
  + The haskell binding to the C run-time library will be included in the
    PGF library (so you can import it in Haskell applications).
    Documentation on the new modules will be included when you run
    'cabal haddock'.
  + The new command 'pgf-shell', implemented on top of haskell binding to
    the C run-time system.
  + Three new commands in the web API: c-parse, c-linearize and
    c-translate. Their interfaces are similar to the corresponding commands
    without the "c-" prefix, but they should be considered preliminary.
2014-01-20 17:06:11 +00:00
hallgren
c8cbd4477f Reduced clutter in monadic code
+ Eliminated vairous ad-hoc coersion functions between specific monads 
  (IO, Err, IOE, Check) in favor of more general lifting functions
  (liftIO, liftErr).
+ Generalized many basic monadic operations from specific monads to
  arbitrary monads in the appropriate class (MonadIO and/or ErrorMonad),
  thereby completely eliminating the need for lifting functions in lots
  of places.

This can be considered a small step forward towards a cleaner
compiler API and more malleable compiler code in general.
2013-11-20 00:45:33 +00:00
hallgren
c959d041a1 gf -server: fix for directory URLs without a trailing slash
When a browser requests a URL that refers to a directory, web server usually
redirect the browser to the same URL with a trailing '/' added, if one was not
already present. This is to prevent relative links in the returned document
from being interpreted relative to the parent directory instead of the current
document. This type of redirection was missing in gf -server.
2013-08-20 15:38:26 +00:00
hallgren
fb61fc4562 Cloud & PGF service: use Content-Type application/json for JSON output
This is in accordance with RFC 4627. http://tools.ietf.org/html/rfc4627
Use application/javascript for JSONP output.
2013-07-29 16:05:54 +00:00
hallgren
eb2b5a65d6 Allow cross origin requests to GF cloud & PGF services
By adding a header

	Access-Control-Allow-Origin: *

to the HTTP responses, web browsers are informed that it is OK to call the
services from web pages hosted on other sites.

This is apparently supported in most modern browsers, so it should no longer
be necessary to resort to JSONP.

See https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS
2013-07-25 16:04:43 +00:00
hallgren
550db69caa Fix UTF-8 decoding problem in gf -server
The package network-2.4.1.1 thoughlessly introduced a backward incompatible
change to the function Network.URI.unEscapeString, see

    f2168b1f89

This also affects the function Network.Shed.Httpd.queryToArguments, which is
used in GFServer.hs.

To remain compatible with older and newer versions of the network package,
we need to stay clear of queryToArguments and unEscapeString. A replacement
function has been added to server/URLEncoding.hs.
2013-06-13 08:23:48 +00:00
hallgren
cd8cbda3d4 Additional changes for GHC 7.4 & 7.6 compatibility 2013-03-11 12:57:09 +00:00
Sergei Trofimovich
05e5895134 ghc-7.6: allow directory-1.2
Get rid of old-time depend (and ClockTime in favour of UTCTime).
time-compat helps to retain backward compatibility with directory-1.1
and lower.
2013-03-09 21:38:43 +00:00
hallgren
d55f5b4e7b gf -server: fix bug in bug fix for current directory 2013-01-13 12:36:58 +00:00
hallgren
f9551337a9 gf -server: small logging improvements 2013-01-12 18:48:23 +00:00
hallgren
cfb72bad8b gf -server: defend against problems with the current directory caused unhandled errors 2013-01-12 17:11:31 +00:00
hallgren
158aafa3af gf -server + gfse: show modification time of public grammars 2012-11-23 23:21:17 +00:00
hallgren
586d7488f2 Add flag --document-root for user with gf --server
This can make it easier to test cloud service updates before installing them.
2012-11-14 13:52:45 +00:00
hallgren
c2b7288411 Eliminate warnings about deprecated use of catch and try
This is also needed for compatibility with GHC 7.6.
2012-11-08 15:53:46 +00:00
hallgren
d441b2c629 gf -server: make it possible to pass arbitrary flags/options to gf when compiling grammars
For example, you can add -optimize-pgf:

  http://localhost:41296/cloud?dir=...&command=remake&-optimize-pgf=&Foods2Eng.gf=&Foods2Swe.gf=
2012-11-06 15:29:38 +00:00
hallgren
87b280fd4f gf -server: introduce command=remake for recompiling previously uploaded grammars
Also remove some old commented out code.
2012-10-23 20:23:01 +00:00
hallgren
3bc65ba527 gf -server: add a GF version info request
GF version info can now be obtained from http://localhost:41926/version
Also removed some unused imports.
2012-09-26 15:23:29 +00:00
hallgren
7c65cd4073 Use the SIO monad in the GF shell
+ The restrictions on arbitrary IO when GF is running in restricted mode is now
  enforced in the types.
+ This hopefully also solves an intermittent problem when accessing the GF
  shell through the web API provided by gf -server. This was visible in the
  Simple Translation Tool and probably caused by some low-level bug in the
  GHC IO libraries.
2012-09-25 19:08:33 +00:00
hallgren
539856de26 GFServer.hs: code improvements
Use a monad in the request handler to make the code a bit more modular and
readable.
2012-09-22 22:10:10 +00:00
hallgren
f79838c299 gf -server: also restrict the paths of uploaded files 2012-09-21 14:53:11 +00:00
hallgren
3d3ee05704 gf -server: improved security checks
+ More restrictive limits on which file paths can be downloaded and removed.
+ Add more extensions to the list of file types that may be removed. In
  particular, allow documents created by simple translation tool to be removed.
2012-09-21 09:00:48 +00:00
hallgren
860a014f2e GFServer.hs: binary files can now be uploaded to the cloud
Karel wants to upload PGF files.
2012-08-01 18:10:00 +00:00
hallgren
70b338de20 translator: documents can now be saved in the cloud
some other small fixes
2012-06-12 15:36:41 +00:00
hallgren
a3a491d8fc GFServer.hs: apply UTF8 encoding when saving uploaded files
This fixes a bug introduced on May 16.
2012-05-28 11:21:30 +00:00
hallgren
25435a6912 gf -server: remove debug output 2012-05-27 11:52:15 +00:00
hallgren
8172cf7d94 GFServer.hs: apply UTF8 decoding to all server input 2012-05-16 14:03:09 +00:00
hallgren
cc2299dde7 PGFService.hs bug fix: pattern match failure in doParse
doParse was missing a branch for PGF.ParseIncomplete.
Also introduced the operator .= to simply the code that builds JSON objects.
2012-02-29 16:21:34 +00:00
hallgren
a68331d287 gf -server mode: JSONP support for grammar lists
Needed by the translation quiz.
2012-02-28 17:20:59 +00:00
hallgren
fc784e92df gfse: text mode editing: accept grammars with printname judgements
But printname judgements are ignored for now.
Also fixed an UTF-8 encoding bug when parsing uploaded grammars in gf -server
mode.
2012-02-24 17:12:38 +00:00
hallgren
b35b48a701 gfse: edit abstract syntax in text mode with instant syntax error reporting
This is an experimental feature. It requires server support for parsing and is
thus not available while offline, unlike most other editing functionality.
2012-02-21 16:58:18 +00:00
hallgren
c4406c146a gfse: added a button to go directly from the editor to the minibar
If there is an error in the grammar, the error message is shown below the
grammar instead.
Also: GFServer.hs now returns compiler output in a JSON structure instead of
as a HTML page.
2012-02-13 15:24:05 +00:00
hallgren
53e5308d74 gfse: stay on the same page when compiling grammars
The link to the minibar (or compiler errors) are now shown below the grammar
on the same page. If you go to the minibar, you only have to press the back
button once to get back to the editor.
Also some output formatting changes in GFServer.hs.
2012-02-10 17:26:02 +00:00
hallgren
a6acb994e8 gfse&minibar: select the right grammar in minibar when invoked from gfse
The grammar that the user is currently working is now the one shown initially
in minibar, instead of the first grammar in alphabetical order.
Also GFServer.hs now removes absolute paths to the grammar files on the server in error messages from GF returned to to gfse.
2012-02-10 15:24:59 +00:00
hallgren
28c2a4ce5e gf -server: better error message for requests with unsupported HTTP methods 2012-02-01 17:34:23 +00:00
hallgren
4c1c115217 gf -server: fix bug that caused '+' to be converted to ' ' in uploaded grammars
Fixed buggy workaround for bug in httpd-shed function queryToArguments.
2012-02-01 17:17:46 +00:00
hallgren
20b4ff07e3 gf -server[=port]
You can now specify which port the HTTP server should run on in server mode.
The default is 41296.
2011-12-14 15:28:27 +00:00
hallgren
9dccff4cf7 gf -server mode improvements
+ Avoid looping if it is not possible to create a new server directory.
+ Work on FastCGI support using the direct-fastcgi package (commented out
  for now because of buggy behavior).
2011-12-14 15:11:13 +00:00
hallgren
5664c0699d gfse: grammar sharing: bug fixes and win32 support
win32 support is untested
2011-11-01 17:45:57 +00:00
hallgren
864d329336 Show version & configuration info when gf -server starts 2011-10-12 19:00:42 +00:00
hallgren
50605036dd Bug fixes for gf -server mode and setup 2011-10-12 18:27:46 +00:00
hallgren
fa4af3d043 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.
2011-10-12 17:03:54 +00:00