From ba97372614698af4f4fd63488352d56b83f8a6c8 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Matthes Date: Mon, 8 Apr 2019 15:06:26 +0200 Subject: [PATCH 1/4] Add the package specifier to the README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ec91ad8..0075e8d 100644 --- a/README.md +++ b/README.md @@ -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. -- GitLab From 11e7e79fd4fe952b48e85822933278496955cd28 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Matthes Date: Mon, 8 Apr 2019 15:11:40 +0200 Subject: [PATCH 2/4] Change the name of the executables from curry... to currygle... --- Makefile | 11 +++++++---- README.md | 20 ++++++++++---------- currygle.cabal | 4 ++-- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 54862f4..d7725f1 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 0075e8d..26a0a0d 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 diff --git a/currygle.cabal b/currygle.cabal index a015139..d3c7557 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, -- GitLab From aff014a23729ecc5481b5407c81eabaec0acd396 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Matthes Date: Mon, 8 Apr 2019 15:16:34 +0200 Subject: [PATCH 3/4] Add template splices for the copyright year and package version --- snaplets/heist/templates/frontpage.tpl | 4 ++-- src/Site.hs | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/snaplets/heist/templates/frontpage.tpl b/snaplets/heist/templates/frontpage.tpl index 1167d87..13b813a 100644 --- a/snaplets/heist/templates/frontpage.tpl +++ b/snaplets/heist/templates/frontpage.tpl @@ -32,9 +32,9 @@ diff --git a/src/Site.hs b/src/Site.hs index 6d6a5b1..151f751 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 ())] @@ -89,7 +97,9 @@ frontpage = ifTop (heistLocal (bindSplices splices) (render "frontpage")) where splices = mconcat [ "result" ## return optionsList , "oldquery" ## return [htmlText ""] - , "pagination" ## return [] ] + , "pagination" ## return [] + , "pkgversion" ## return [htmlText pkgVersion] + , "pkgyear" ## return [htmlText pkgYear] ] -- | Returns the list of word completions for the search text as JSON. completions :: AppHandler () @@ -107,7 +117,9 @@ results = do query <- getRequestParam "query" let splices = mconcat [ "result" ## resultSplice page docs , "oldquery" ## return [htmlText query] - , "pagination" ## paginationSplice query page docs] + , "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. -- GitLab From 7ad545f71f97a225fb5466d48b86c054f8fd8dc5 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Matthes Date: Mon, 8 Apr 2019 15:18:37 +0200 Subject: [PATCH 4/4] Change the name of the query template splice --- snaplets/heist/templates/frontpage.tpl | 2 +- src/Site.hs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/snaplets/heist/templates/frontpage.tpl b/snaplets/heist/templates/frontpage.tpl index 13b813a..b7045c1 100644 --- a/snaplets/heist/templates/frontpage.tpl +++ b/snaplets/heist/templates/frontpage.tpl @@ -22,7 +22,7 @@
- +
diff --git a/src/Site.hs b/src/Site.hs index 151f751..6c554b1 100644 --- a/src/Site.hs +++ b/src/Site.hs @@ -96,7 +96,7 @@ frontpage :: AppHandler () frontpage = ifTop (heistLocal (bindSplices splices) (render "frontpage")) where splices = mconcat [ "result" ## return optionsList - , "oldquery" ## return [htmlText ""] + , "query" ## return [htmlText ""] , "pagination" ## return [] , "pkgversion" ## return [htmlText pkgVersion] , "pkgyear" ## return [htmlText pkgYear] ] @@ -116,7 +116,7 @@ results = do page <- strToInt 1 <$> getRequestParam "page" query <- getRequestParam "query" let splices = mconcat [ "result" ## resultSplice page docs - , "oldquery" ## return [htmlText query] + , "query" ## return [htmlText query] , "pagination" ## paginationSplice query page docs , "pkgversion" ## return [htmlText pkgVersion] , "pkgyear" ## return [htmlText pkgYear] ] -- GitLab