forked from GitHub/gf-core
Merge branch 'master' of https://github.com/GrammaticalFramework/gf-core
This commit is contained in:
28
gf.cabal
28
gf.cabal
@@ -1,5 +1,5 @@
|
||||
name: gf
|
||||
version: 3.9-git
|
||||
version: 3.10
|
||||
|
||||
cabal-version: >= 1.22
|
||||
build-type: Custom
|
||||
@@ -42,7 +42,7 @@ data-files:
|
||||
custom-setup
|
||||
setup-depends:
|
||||
base,
|
||||
Cabal >=1.4.0.0,
|
||||
Cabal >=1.22.0.0,
|
||||
directory,
|
||||
filepath,
|
||||
process >=1.0.1.1
|
||||
@@ -67,11 +67,6 @@ flag network-uri
|
||||
-- Description: Make -new-comp the default
|
||||
-- Default: True
|
||||
|
||||
flag custom-binary
|
||||
Description: Use a customised version of the binary package
|
||||
Default: True
|
||||
Manual: True
|
||||
|
||||
flag c-runtime
|
||||
Description: Include functionality from the C run-time library (which must be installed already)
|
||||
Default: False
|
||||
@@ -89,17 +84,14 @@ Library
|
||||
exceptions
|
||||
hs-source-dirs: src/runtime/haskell
|
||||
|
||||
if flag(custom-binary)
|
||||
other-modules:
|
||||
-- not really part of GF but I have changed the original binary library
|
||||
-- and we have to keep the copy for now.
|
||||
Data.Binary
|
||||
Data.Binary.Put
|
||||
Data.Binary.Get
|
||||
Data.Binary.Builder
|
||||
Data.Binary.IEEE754
|
||||
else
|
||||
build-depends: binary, data-binary-ieee754
|
||||
other-modules:
|
||||
-- not really part of GF but I have changed the original binary library
|
||||
-- and we have to keep the copy for now.
|
||||
Data.Binary
|
||||
Data.Binary.Put
|
||||
Data.Binary.Get
|
||||
Data.Binary.Builder
|
||||
Data.Binary.IEEE754
|
||||
|
||||
--ghc-options: -fwarn-unused-imports
|
||||
--if impl(ghc>=7.8)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: pgf
|
||||
version: 3.9.1-git
|
||||
version: 3.10
|
||||
|
||||
cabal-version: >= 1.20
|
||||
build-type: Simple
|
||||
@@ -12,11 +12,6 @@ bug-reports: https://github.com/GrammaticalFramework/gf-core/issues
|
||||
maintainer: Thomas Hallgren
|
||||
tested-with: GHC==7.6.3, GHC==7.8.3, GHC==7.10.3, GHC==8.0.2
|
||||
|
||||
flag custom-binary
|
||||
Description: Use a customised version of the binary package
|
||||
Default: True
|
||||
Manual: True
|
||||
|
||||
Library
|
||||
default-language: Haskell2010
|
||||
build-depends: base >= 4.6 && <5,
|
||||
@@ -29,17 +24,14 @@ Library
|
||||
mtl,
|
||||
exceptions
|
||||
|
||||
if flag(custom-binary)
|
||||
other-modules:
|
||||
-- not really part of GF but I have changed the original binary library
|
||||
-- and we have to keep the copy for now.
|
||||
Data.Binary
|
||||
Data.Binary.Put
|
||||
Data.Binary.Get
|
||||
Data.Binary.Builder
|
||||
Data.Binary.IEEE754
|
||||
else
|
||||
build-depends: binary, data-binary-ieee754
|
||||
other-modules:
|
||||
-- not really part of GF but I have changed the original binary library
|
||||
-- and we have to keep the copy for now.
|
||||
Data.Binary
|
||||
Data.Binary.Put
|
||||
Data.Binary.Get
|
||||
Data.Binary.Builder
|
||||
Data.Binary.IEEE754
|
||||
|
||||
--ghc-options: -fwarn-unused-imports
|
||||
--if impl(ghc>=7.8)
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
name: gf-server
|
||||
version: 1.0
|
||||
cabal-version: >= 1.8
|
||||
build-type: Custom
|
||||
license: GPL
|
||||
license-file: ../../LICENSE
|
||||
synopsis: FastCGI Server for Grammatical Framework
|
||||
|
||||
flag content
|
||||
Description:
|
||||
Build content service (requires fastcgi and hsql-mysql packages)
|
||||
(In Ubuntu: apt-get install libghc-fastcgi-dev libghc-hsql-mysql-dev)
|
||||
Default: False
|
||||
|
||||
flag http
|
||||
Description: Build pgf-http (deprecated, replaced by gf -server)
|
||||
Default: False
|
||||
|
||||
flag fastcgi
|
||||
Description: Build librar & pgf-service executable with fastcgi support
|
||||
Default: True
|
||||
|
||||
flag c-runtime
|
||||
Description: Include functionality from the C run-time library (which must be installed already)
|
||||
Default: False
|
||||
|
||||
flag network-uri
|
||||
description: Get Network.URI from the network-uri package
|
||||
default: True
|
||||
|
||||
Library
|
||||
exposed-modules: PGFService FastCGIUtils CGIUtils ServeStaticFile RunHTTP Cache
|
||||
other-modules: URLEncoding CGI Fold
|
||||
hs-source-dirs: . transfer
|
||||
|
||||
if flag(fastcgi)
|
||||
build-depends: fastcgi >= 3001.0.2.2
|
||||
-- Install it in Ubuntu with: apt-get install libghc-fastcgi-dev
|
||||
else
|
||||
Buildable: False
|
||||
|
||||
build-depends: base >=4.2 && <5,
|
||||
time, time-compat, old-locale,
|
||||
directory,
|
||||
filepath,
|
||||
containers,
|
||||
process,
|
||||
gf >= 3.6,
|
||||
cgi >= 3001.1.7.3,
|
||||
httpd-shed>=0.4.0.2,
|
||||
mtl,
|
||||
exceptions,
|
||||
json >= 0.3.3,
|
||||
utf8-string >= 0.3.1.1,
|
||||
bytestring,
|
||||
pretty,
|
||||
random
|
||||
|
||||
if flag(network-uri)
|
||||
build-depends: network-uri>=2.6, network>=2.6
|
||||
else
|
||||
build-depends: network>=2.3 && <2.6
|
||||
|
||||
ghc-options: -fwarn-unused-imports
|
||||
if os(windows)
|
||||
ghc-options: -optl-mwindows
|
||||
else
|
||||
build-depends: unix
|
||||
|
||||
if flag(c-runtime)
|
||||
cpp-options: -DC_RUNTIME
|
||||
|
||||
executable pgf-http
|
||||
main-is: pgf-http.hs
|
||||
Hs-source-dirs: exec
|
||||
ghc-options: -threaded
|
||||
if impl(ghc>=7.0)
|
||||
ghc-options: -rtsopts
|
||||
|
||||
if flag(http)
|
||||
buildable: True
|
||||
build-depends: base >=4.2 && <5, gf-server, filepath, directory, cgi
|
||||
else
|
||||
buildable: False
|
||||
|
||||
executable pgf-service
|
||||
main-is: pgf-fcgi.hs
|
||||
Hs-source-dirs: exec
|
||||
ghc-options: -threaded -fwarn-unused-imports
|
||||
if impl(ghc>=7.0)
|
||||
ghc-options: -rtsopts
|
||||
|
||||
if flag(fastcgi)
|
||||
build-depends: fastcgi >= 3001.0.2.2
|
||||
-- Install it in Ubuntu with: apt-get install libghc-fastcgi-dev
|
||||
else
|
||||
Buildable: False
|
||||
|
||||
build-depends: base >=4.2 && <5, gf-server
|
||||
|
||||
if os(windows)
|
||||
ghc-options: -optl-mwindows
|
||||
else
|
||||
build-depends: unix
|
||||
|
||||
executable content-service
|
||||
if flag(content)
|
||||
build-depends: base >=4.2 && <5, old-locale,
|
||||
fastcgi >= 3001.0.2.2,
|
||||
-- In Ubuntu: apt-get install libghc-fastcgi-dev
|
||||
hsql-mysql, hsql
|
||||
-- In Ubuntu: apt-get install libghc-hsql-mysql-dev
|
||||
buildable: True
|
||||
else
|
||||
buildable: False
|
||||
|
||||
main-is: ContentService.hs
|
||||
Hs-source-dirs: exec
|
||||
@@ -1,102 +0,0 @@
|
||||
----------------------------------------------------------------------
|
||||
-- |
|
||||
-- Maintainer : AR
|
||||
-- Stability : (stable)
|
||||
-- Portability : (portable)
|
||||
--
|
||||
-- > CVS $Date: 2005/05/16 17:07:18 $
|
||||
-- > CVS $Author: aarne $
|
||||
-- > CVS $Revision: 1.11 $
|
||||
--
|
||||
-- chop an HTML file into separate files, each linked to the next and previous.
|
||||
-- the names of the files are n-file, with n = 01,02,...
|
||||
-- the chopping is performed at each separator, here defined as @\<!-- NEW --\>@
|
||||
--
|
||||
-- AR 7\/1\/2002 for the Vinnova meeting in Linköping.
|
||||
-- Added table of contents generation in file 00, 16/4/2005
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
module Main (main) where
|
||||
|
||||
import System.Environment(getArgs)
|
||||
import Data.Char
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
file:_ <- getArgs
|
||||
htmls file
|
||||
|
||||
htmls :: FilePath -> IO ()
|
||||
htmls file = do
|
||||
s <- readFile file
|
||||
let ss = allPages file s
|
||||
lg = length ss
|
||||
putStrLn $ show lg ++ " slides"
|
||||
mapM_ (uncurry writeFile . mkFile file lg) ss
|
||||
|
||||
allPages :: FilePath -> String -> [(Int,String)]
|
||||
allPages file s = addIndex $ zip [1..] $ map unlines $ chop lss where
|
||||
chop ls = case span isNoSep ls of
|
||||
(s,_:ss) -> s : chop ss
|
||||
_ -> [ls]
|
||||
isNoSep = (/= separator)
|
||||
addIndex = ((0,mkIndex file lss) :)
|
||||
lss = lines s
|
||||
|
||||
mkFile :: FilePath -> Int -> (Int,String) -> (FilePath,String)
|
||||
mkFile base mx (number,content) =
|
||||
(fileName base number,
|
||||
unlines [
|
||||
begHTML,
|
||||
"<font size=1>",
|
||||
pageNum mx number,
|
||||
link base mx number,
|
||||
"</font>",
|
||||
"<p>",
|
||||
content,
|
||||
endHTML
|
||||
]
|
||||
)
|
||||
|
||||
begHTML, endHTML, separator :: String
|
||||
begHTML = "<html><body bgcolor=\"#FFFFFF\" text=\"#000000\">"
|
||||
endHTML = "</body></html>"
|
||||
separator = "<!-- NEW -->"
|
||||
|
||||
link :: FilePath -> Int -> Int -> String
|
||||
link file mx n =
|
||||
(if n >= mx-1 then "" else (" <a href=\"" ++ file' ++ "\">Next</a>")) ++
|
||||
(if n == 1 then "" else (" <a href=\"" ++ file_ ++ "\">Previous</a>")) ++
|
||||
(" <a href=\"" ++ file0 ++ "\">Contents</a>") ++
|
||||
(" <a href=\"" ++ file ++ "\">Fulltext</a>") ++
|
||||
(" <a href=\"" ++ file1 ++ "\">First</a>") ++
|
||||
(" <a href=\"" ++ file2 ++ "\">Last</a>")
|
||||
where
|
||||
file_ = fileName file (n - 1)
|
||||
file' = fileName file (n + 1)
|
||||
file0 = fileName file 0
|
||||
file1 = fileName file 1
|
||||
file2 = fileName file (mx - 1)
|
||||
|
||||
fileName :: FilePath -> Int -> FilePath
|
||||
fileName file n = (if n < 10 then ('0':) else id) $ show n ++ "-" ++ file
|
||||
|
||||
pageNum mx num = "<p align=right>" ++ show num ++"/" ++ show (mx-1) ++ "</p>"
|
||||
|
||||
mkIndex file = unlines . mkInd 1 where
|
||||
mkInd n ss = case ss of
|
||||
s : rest | (s==separator) -> mkInd (n+1) rest
|
||||
s : rest -> case getHeading s of
|
||||
Just (i,t) -> mkLine n i t : mkInd n rest
|
||||
_ -> mkInd n rest
|
||||
_ -> []
|
||||
getHeading s = case dropWhile isSpace s of
|
||||
'<':h:i:_:t | isDigit i -> return (i,take (length t - 5) t) -- drop final </hi>
|
||||
_ -> Nothing
|
||||
mkLine _ '1' t = t ++ " : Table of Contents<p>" -- heading of whole document
|
||||
mkLine n i t = stars i ++ link n t ++ "<br>"
|
||||
stars i = case i of
|
||||
'3' -> "<li> "
|
||||
'4' -> "<li>* "
|
||||
_ -> ""
|
||||
link n t = "<a href=\"" ++ fileName file n ++ "\">" ++ t ++ "</a>"
|
||||
@@ -6,7 +6,3 @@ cabal-version: >= 1.8
|
||||
Executable gfdoc
|
||||
main-is: GFDoc.hs
|
||||
build-depends: base, directory>=1.2, time>=1.5, process
|
||||
|
||||
Executable htmls
|
||||
main-is: Htmls.hs
|
||||
build-depends: base
|
||||
Reference in New Issue
Block a user