diff --git a/Makefile b/Makefile index 54862f4de59a18934f16e02e13d2f81230007c97..d7725f13b05de521860faabd3e8439599890dbca 100644 --- a/Makefile +++ b/Makefile @@ -12,10 +12,13 @@ SANDBOX_BIN_DIR = $(SANDBOX_DIR)/bin LOG_FILE = $(LOG_DIR)/production.log PID_FILE = server.pid -INDEXER = $(BIN_DIR)/curryIndexer -SERVER = $(BIN_DIR)/curryServer -SANDBOX_INDEXER = $(SANDBOX_BIN_DIR)/curryIndexer -SANDBOX_SERVER = $(SANDBOX_BIN_DIR)/curryServer +INDEXER_NAME = currygleIndexer +SERVER_NAME = currygleServer + +INDEXER = $(BIN_DIR)/$(INDEXER_NAME) +SERVER = $(BIN_DIR)/$(SERVER_NAME) +SANDBOX_INDEXER = $(SANDBOX_BIN_DIR)/$(INDEXER_NAME) +SANDBOX_SERVER = $(SANDBOX_BIN_DIR)/$(SERVER_NAME) SERVER_ADDRESS = 127.0.0.1 SERVER_PORT = 1337 diff --git a/README.md b/README.md index ec91ad8be308f44c4cfdfd3e563fe6e97f16262e..26a0a0d6cf2cf9bc20b2240580889467b7385e69 100644 --- a/README.md +++ b/README.md @@ -21,45 +21,45 @@ make install ## Usage -The installation process creates two binaries: `curryIndexer` and `curryServer`. The first creates the index for a given directory that contains at least one `.cdoc` file (or one or more subdirectories with at least one `.cdoc` file) and a corresponding URI. The second provides a web server which can be used to search the index. +The installation process creates two binaries: `currygleIndexer` and `currygleServer`. The first creates the index for a given directory that contains at least one `.cdoc` file (or one or more subdirectories with at least one `.cdoc` file) and a corresponding URI. The second provides a web server which can be used to search the index. The `.cdoc` files can be generated with [CurryDoc](https://www-ps.informatik.uni-kiel.de/currywiki/tools/currydoc/) for a given Curry module or package, the URI is the corresponding HTML documentation that also can be generated with CurryDoc. -The `curryIndexer` can either generate a new index or update an existing one. To distinguish between these options, you can use the flag `--n` for generating a new index and `--u` for updating an index. Before using the `curryIndexer` make sure that the `index` directory exists. +The `currygleIndexer` can either generate a new index or update an existing one. To distinguish between these options, you can use the flag `--n` for generating a new index and `--u` for updating an index. Before using the `currygleIndexer` make sure that the `index` directory exists. This package provides an [`examples`](examples/) directory with the documentation of the base Curry modules. So you can generate an index with the provided `.cdoc` files and the [documentation](https://www.informatik.uni-kiel.de/~curry/cpm/DOC/base-1.0.0/). ```shell mkdir -p index -bin/curryIndexer examples/base-1.0.0 https://www.informatik.uni-kiel.de/~curry/cpm/DOC/base-1.0.0/ --n +bin/currygleIndexer examples/base-1.0.0 https://www.informatik.uni-kiel.de/~curry/cpm/DOC/base-1.0.0/ --n ``` -Due to the fact that the `curryIndexer` also recognizes subdirectories, it is possible to simply pass the `examples` directory to the executable. +Due to the fact that the `currygleIndexer` also recognizes subdirectories, it is possible to simply pass the `examples` directory to the executable. ```shell mkdir -p index -bin/curryIndexer examples https://www.informatik.uni-kiel.de/~curry/cpm/DOC/ --n +bin/currygleIndexer examples https://www.informatik.uni-kiel.de/~curry/cpm/DOC/ --n ``` Since it can take a very long time to add modules from a large number of different directories, you can pass a `.txt` file as an argument that consists of pairs of a directory (that contains at least one `.cdoc` file) and a URI to generate the index. The entries must be separated with a semicolon. ```shell mkdir -p index -bin/curryIndexer .txt --n +bin/currygleIndexer .txt --n ``` -The recommended way to use the `curryIndexer` is via the `Makefile` with the targets `index` and `update-index`. If you use another directory for the `.cdoc` files or another URI, then you must change the `CDOC_DIR` and `CDOC_URI` variables. To delete an existing index you can use the target `delete-index`. +The recommended way to use the `currygleIndexer` is via the `Makefile` with the targets `index` and `update-index`. If you use another directory for the `.cdoc` files or another URI, then you must change the `CDOC_DIR` and `CDOC_URI` variables. To delete an existing index you can use the target `delete-index`. -If you have generated an index, you can run the web server on your `localhost` on a given port with the `curryServer` executable. Before using the `curryServer` make sure that the `log` directory exists. +If you have generated an index, you can run the web server on your `localhost` on a given port with the `currygleServer` executable. Before using the `currygleServer` make sure that the `log` directory exists. ```shell mkdir -p log -bin/curryServer -b 127.0.0.1 -p 1337 +bin/currygleServer -b 127.0.0.1 -p 1337 ``` To start the web server you can also run `make start`. If you want to use a custom server address or port, simply change the `SERVER_ADDRESS` and `SERVER_PORT` variables in the `Makefile`. Run `make stop` to stop the web server. -By default, the web server runs in *development* mode. If you want to run the web server in *production* mode you have to change the `SNAP_ENV` variable as described in the `Makefile`. +By default, the web server runs in *development* mode. If you want to run the web server in *production* mode, you have to change the `SNAP_ENV` variable as described in the `Makefile`. ## How to Search @@ -67,6 +67,7 @@ The following listing shows you all available options to restrict a search: * **:module Prelude** (also **:m Prelude**) ⟶ Searches for modules starting with *Prelude*, without a following name, it searches for all modules. * **:inModule Prelude** (also **:in Prelude**) ⟶ Restricts the search to the module *Prelude*, but searches for all contexts. +* **:inPackage base** (also **:ip base**) ⟶ Restricts the search to the package *base*, but searches for all contexts. * **:function map** (also **:f map**) ⟶ Searches for functions starting with *map*, without a following name, it searches for all functions. * **:type Either** (also **:t Either**) ⟶ Searches for types starting with *Either*, without a following name, it searches for all types. * **:class Functor** (also **:c Functor**) ⟶ Searches for type classes starting with *Functor*, without a following name, it searches for all type classes. diff --git a/currygle.cabal b/currygle.cabal index a015139551eda417428f218d75f25d60749f2ac3..d3c75578c8fede973b616c3b3babe88823a8e0e7 100644 --- a/currygle.cabal +++ b/currygle.cabal @@ -24,7 +24,7 @@ source-repository head type: git location: https://git.ps.informatik.uni-kiel.de/apps/currygle.git -executable curryIndexer +executable currygleIndexer main-is: CurryIndexer.hs hs-source-dirs: src other-modules: CurryInfo, FilesAndLoading, Helpers, IndexTypes @@ -45,7 +45,7 @@ executable curryIndexer -fwarn-tabs -funbox-strict-fields -executable curryServer +executable currygleServer main-is: Main.hs hs-source-dirs: src other-modules: Application, CurryInfo, CurrySearch, FilesAndLoading, diff --git a/snaplets/heist/templates/frontpage.tpl b/snaplets/heist/templates/frontpage.tpl index 1167d876258913aab5387a2ba36623775840ecb0..b7045c1447bbbac6c1c21f44c4b2c5aaa702788c 100644 --- a/snaplets/heist/templates/frontpage.tpl +++ b/snaplets/heist/templates/frontpage.tpl @@ -22,7 +22,7 @@
- +
@@ -32,9 +32,9 @@ diff --git a/src/Site.hs b/src/Site.hs index 6d6a5b1e17a68ca0bfd4f1bbfa975d3d55b429a4..6c554b11f8cd5313c596dd229696697d2f85bbb9 100644 --- a/src/Site.hs +++ b/src/Site.hs @@ -75,6 +75,14 @@ app = makeSnaplet "currygle" "An API search engine for Curry" Nothing $ do addRoutes [(contextPath, route (routes staticDir))] return (App h i) +-- | The version of this package. +pkgVersion :: String +pkgVersion = "0.3.0" + +-- | The current year. +pkgYear :: String +pkgYear = "2018" + -- | Defines the routing of the website. It distinguishes between the front- -- and query-page as well as the word completions. routes :: FilePath -> [(ByteString, AppHandler ())] @@ -88,8 +96,10 @@ frontpage :: AppHandler () frontpage = ifTop (heistLocal (bindSplices splices) (render "frontpage")) where splices = mconcat [ "result" ## return optionsList - , "oldquery" ## return [htmlText ""] - , "pagination" ## return [] ] + , "query" ## return [htmlText ""] + , "pagination" ## return [] + , "pkgversion" ## return [htmlText pkgVersion] + , "pkgyear" ## return [htmlText pkgYear] ] -- | Returns the list of word completions for the search text as JSON. completions :: AppHandler () @@ -106,8 +116,10 @@ results = do page <- strToInt 1 <$> getRequestParam "page" query <- getRequestParam "query" let splices = mconcat [ "result" ## resultSplice page docs - , "oldquery" ## return [htmlText query] - , "pagination" ## paginationSplice query page docs] + , "query" ## return [htmlText query] + , "pagination" ## paginationSplice query page docs + , "pkgversion" ## return [htmlText pkgVersion] + , "pkgyear" ## return [htmlText pkgYear] ] heistLocal (bindSplices splices) (render "frontpage") -- | Generates the HTML elements for the search results.