Skip to content

Commit 3c4dab7

Browse files
authored
Rewrite index to use scala + angular (#38)
I concluded dynamic typing isn't worth the effort when it comes to prolonged maintenance of a web application. Initially I chose scheme just in case someone else would want to contribute to the project, but that hadn't happened. My chosen previous stack of kawa + my own library wrappers feels unreliable. Kawa maintainer isn't interested in communicating with potential volunteers regarding improving the language. My own wrappers are one person effort. Although scala and angular might be foreign to typical scheme programmer, they are very reliable and future-proof choices. And ultimately, I feel the programming part of this project isn't that important, ultimately I decided it didn't matter much what the index site is written in. Most of the value lies in definition data files in types/*.scm. Writing a service / ui layer against it is relatively easy. Additionally: * remove "parameterized_by" (felt useless in practice) * remove supertypes construct (felt gimmicky and ultimately unclear) * remove "spec-values" (use description instead) * remove "syntax-param-signature" (use value subsignature) * change filtersets to return a list of code + name, not just code
1 parent f5b5428 commit 3c4dab7

File tree

130 files changed

+26719
-5175
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+26719
-5175
lines changed

.circleci/config.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,20 @@ version: 2.1
33
jobs:
44
unittest:
55
docker:
6-
- image: cimg/openjdk:11.0
6+
- image: sbtscala/scala-sbt:eclipse-temurin-jammy-17.0.5_8_1.8.2_3.2.2
77
steps:
88
- checkout
99
- run:
1010
name: Test
1111
command: |
12-
cd kawa-web-collection
13-
git submodule update --init
14-
mvn install -DskipTests=true
15-
cd ..
16-
mvn test
12+
sbt test
1713
1814
build:
1915
machine: true
2016
steps:
2117
- checkout
2218
- run: |
23-
cd kawa-web-collection
24-
git submodule update --init
25-
cd ..
2619
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD
27-
docker build -t scmindex-builder:latest -f docker/base/Dockerfile .
2820
docker build -t arvyy/scheme-index:$CIRCLE_BRANCH -f docker/scheme-index/Dockerfile .
2921
docker build -t arvyy/scheme-index-nginx:$CIRCLE_BRANCH -f docker/nginx/Dockerfile .
3022
- run: |

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "kawa-web-collection"]
2-
path = kawa-web-collection
3-
url = https://github.com/arvyy/kawa-web-collection

README.adoc

Lines changed: 22 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ Selecting multiple tags, will return results that contain *all* of the given tag
4949

5050
Selecting multiple parameter types will return results that match *all* of the given types.
5151

52-
Some types contain logical "parent" / more general types, eg. *number?* is a parent of *integer?*. When searching by parameter type, the procedures that take parent type will be matched. However, the results with more precise "child" type are weight more heavily and should appear at the start of the search.
53-
54-
Some types are defined as a union of other types; for example *list?* is a union of *pair?* and *null?*. If loose parameter filtering is enabled under settings, the composing parts will be treated as parent of union type; ie searching for *list?* you'd be also presented with procedures applicable to *pair?*. On one hand this presents extra results you might be interested, on the other hand those results might not be applicable in general case.
55-
5652
Selecting multiple return types will return results that match *all* of the given types. As and in case filter by parameter type, when filtering by return type the type hierarchy is taken into consideration. Searching by a "parent" return type will also yield procedures returning more precise "child" types.
5753

5854
The text query is parsed by edismax parser (read more about it https://solr.apache.org/guide/6_6/the-dismax-query-parser.html#the-dismax-query-parser), and is used to filter by name and parameter / subsyntax names. This means it supports and interprets common searching syntax, such as using "-" in front of the word to exclude results containing said word. This has its disadvantages; eg. if you tried to search for coercion functions and typed "->string" (without quotes) into the search input field, you wouldn't find anything interesting, because the leading minus was interpreted specially. Instead, you'd have to search using "exact phrase", by putting double quotes around the search.
@@ -62,63 +58,34 @@ The text query is parsed by edismax parser (read more about it https://solr.apac
6258

6359
=== Download
6460

65-
Prebuilt versions are available at https://github.com/arvyy/r7rs-index-site/releases
61+
Select prebuilt versions are available at https://github.com/arvyy/r7rs-index-site/releases
6662

6763
Docker image (always corresponding to latest deployed version) may be pulled from `arvyy/scheme-index:master`.
6864

6965
=== Building native
7066

71-
Build processes requires following tools on path:
72-
73-
* `ant` - Apache Ant build tool
74-
75-
* `mvn` - Apache maven project tool
76-
77-
* `asciidoctor` - Asciidoctor documentation compiler
78-
79-
* `sass` - SCSS compiler
80-
81-
* (optional) `npm` - nodejs / npm tooling to build CLI client application.
82-
83-
You can build scheme index by running `ant` from the root of the source directory. Pass `-DbuildClient=true` to include CLI client application build.
84-
85-
After the build successfully completes, you should find everything scheme index needs in `dist` directory.
67+
Build server by running `sbt clean assembly`. The output will be a jar file in `target/scala-*/scheme-index.jar`
68+
Build frontend by running `npm run build` in subfolder `frontend`. The output will be in `frontend/dist/frontend`
69+
Build documentation using `asciidoctor README.adoc`. The output will be `README.html`
8670

8771
=== Running native
8872

89-
Once you have obtained a built version, you can run it using:
73+
Once built, you'll need a webserver to serve static files and proxy to API.
74+
The webserver should:
9075

91-
```
92-
java -jar scheme-index.jar
93-
```
76+
* proxy to api on `/rest` endpoints
77+
* return static files on direct match
78+
* return index.html for other paths.
79+
80+
To launch API backend, run `java -jar scheme-index.jar`
9481

9582
Note that working directory is important; type files, configuration are resolved relative to the working dir, not relative to jar file.
9683

9784
See <<Configuration>> section for configuring the application behavior.
9885

99-
=== Building docker image
100-
101-
Build a docker image using
102-
103-
```
104-
docker build -t scmindex-builder:latest -f docker/base/Dockerfile .
105-
docker build -t scheme-index -f docker/scheme-index/Dockerfile .
106-
```
107-
108-
The built image has same structure as a native build, under path `/app` inside the image.
109-
11086
=== Running docker image
11187

112-
To run with docker, execute
113-
114-
```
115-
docker run -p 8080:8080 --init scheme-index
116-
```
117-
118-
The application resides in `/app` location. Consult rest of the documentation for details, but in particular you might want to mount a volume
119-
to `/app/logs` to catch log files, or a volume file to `/app/config/configuration.scm` to overwrite index config.
120-
121-
You can build & run locally built images using
88+
Run locally built images using docker-compose
12289

12390
```
12491
cd docker
@@ -135,49 +102,6 @@ mkdir logs
135102
docker-compose up
136103
```
137104

138-
=== Running in development (native)
139-
140-
First, install dependencies under kawa-web-collection submodule (make sure the git submodule is initialized / updated)
141-
142-
```
143-
cd kawa-web-collection
144-
mvn install
145-
```
146-
147-
Afterwards, run the application with
148-
149-
```
150-
mvn kawa:run
151-
```
152-
153-
Launch sass compiler with
154-
155-
```
156-
sass -w src/main/scss/main.scss static/css/scmindex.css
157-
```
158-
159-
Execute unit tests using
160-
161-
```
162-
mvn test
163-
```
164-
165-
=== Running in development (docker)
166-
167-
Make sure kawa-web-collection submodule is initialized
168-
169-
Run with
170-
171-
```
172-
docker-compose -f docker/docker-compose.dev.yml up app sass nginx
173-
```
174-
175-
Execute unit tests using
176-
177-
```
178-
docker-compose -f docker/docker-compose.dev.yml up test
179-
```
180-
181105
== Configuration
182106

183107
=== configuration.scm
@@ -212,33 +136,13 @@ The following is exhaustive list of valid properties
212136
| Which port to use. Relevant only if enable-web is `#t`
213137
| 8080
214138

215-
| cache-templates
216-
| Whether templates should be cached (ie compiled once and remembered). Use `#f` in development, so that you don't need to restart the app to see changes
217-
| #t
218-
219-
| serve-static
220-
| Whether application should serve static resources from ./static folder. Use `#f` if you have some other web server (eg nginx in front) serving the content.
221-
| #t
222-
223139
| spec-index
224140
| Index of definitions to load (see Identifiers definitions section)
225141
| "./types/index.scm"
226142

227143
| filterset-index
228144
| Index of filtersets to load (see Filterset definitions section)
229145
| "filters/index.scm"
230-
231-
| sqlite-data
232-
| File to use for sqlite data
233-
| "sqlitedb"
234-
235-
| enable-user-settings
236-
| Allow user to save certain settings in cookies and show settings page
237-
| #t
238-
239-
| downloads
240-
| Location of downloads config file, listing available CLI app downloads. The file should be a list, where each item is an alist with symbol keys name, checksum, and url and string values. It's not an error if file doesn't exist.
241-
| "config/downloads.scm"
242146
|===
243147

244148
=== Identifiers definitions
@@ -325,16 +229,6 @@ one of as described in `signature` section, as well as additionally:
325229

326230
* `(vector <element>)` - describes an list datastrucutre, where `<element>` has same format as function parameter definition;
327231

328-
| syntax-param-signatures
329-
| Applicable only to syntax type. The value is a list, where each element is itself a 2 element list. First element is a symbol, matching one of the symbols in the signature.
330-
Second argument is parameter type definition, as described under functions. This allows annotating syntax when it expects to receive values of certain types for specific places in the pattern.
331-
332-
| parameterized-by
333-
| List of strings, denoting parameters created by `make-parameter` that influence behavior of this entry
334-
335-
| spec-values
336-
| Sometimes procedures have very limited input set for specific parameter (eg. using symbols as a union). Sometimes procedures handle values with specific logic when it detects specific format in it (eg. printf format specifier). In both cases it's sensible to list these special handlings, and this is what this field is for. The value of spec-values is an alist, where car corresponds to parameter name, and cdr is a list. Each element in said list is also a list - where first element corresponds to specific value (written as a string), and cadr corresponds to the value's description (also a string).
337-
338232
|===
339233

340234
=== Filterset definitions
@@ -366,21 +260,26 @@ Consult logback documentation for details.
366260

367261
== REST API
368262

369-
All of the following endpoints accept `wt` query parameter.
370-
If the parameter's value is `sexpr`, the results are returned as if with `write`, using scheme-json convention
371-
as defined in srfi 180. Otherwise, results are returned as json.
372263

373264
=== `/rest/filterset`
374265

375-
List of filtersets as strings. For all endpoints below, `{filterset name}` must correspond to one of the values returned here.
266+
List of filtersets as strings. For all endpoints below, `{filterset name}` must correspond to one of the code here.
376267

377268
JSON schema
378269
[source,json]
379270
----
380271
{
381272
"type": "array",
382273
"items": {
383-
"type": "string"
274+
"type": "object",
275+
"properties": {
276+
"code": {
277+
"type": "string"
278+
},
279+
"name": {
280+
"type": "string"
281+
}
282+
}
384283
}
385284
}
386285
----
@@ -455,23 +354,6 @@ JSON schema
455354

456355
'''
457356

458-
=== `/rest/filterset/{filterset name}/parameterized`
459-
460-
Dynamic parameters (ie., ones created with `make-parameter`) that affect procedures in the index.
461-
462-
JSON schema
463-
[source,json]
464-
----
465-
{
466-
"type": "array",
467-
"items": {
468-
"type": "string"
469-
}
470-
}
471-
----
472-
473-
'''
474-
475357
=== `/rest/filterset/{filterset name}/search`
476358

477359
Returns found identifiers and faceting meta data.
@@ -498,15 +380,9 @@ Query parameters
498380
| param
499381
| param type filter. Possible values returned in `/rest/params`. The parameter can appear multiple times, and the result will include procedures which contain all given parameter types.
500382

501-
| filter_loose
502-
| whether enable loose filtering as described in <<Filtering logic>>
503-
504383
| return
505384
| return type filter. Possible values returned in `/rest/returns`. The parameter can appear multiple times, and the result will include procedures which contain all given return types.
506385

507-
| parameterized
508-
| return parameterization filter. Possible values returned in `/rest/parameterized`. The parameter can appear multiple times, and the result will include procedures which are parameterized by all values.
509-
510386
| facet
511387
| whether to return facet information of the query. Defaults to "true"
512388
|===

build.sbt

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
ThisBuild / version := "0.0.3"
2+
3+
ThisBuild / scalaVersion := "3.2.1"
4+
5+
libraryDependencies += "org.typelevel" %% "cats-effect" % "3.4.4"
6+
7+
val solrVersion = "8.11.1"
8+
libraryDependencies += ("org.apache.solr" % "solr-solrj" % solrVersion)
9+
.exclude("org.apache.logging.log4j", "log4j-slf4j-impl")
10+
.exclude("org.apache.logging.log4j", "log4j-core")
11+
libraryDependencies += ("org.apache.solr" % "solr-core" % solrVersion)
12+
.exclude("org.apache.logging.log4j", "log4j-slf4j-impl")
13+
.exclude("org.apache.logging.log4j", "log4j-core")
14+
15+
libraryDependencies += "com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.14.1"
16+
17+
val logbackVersion = "1.2.6"
18+
libraryDependencies += "ch.qos.logback" % "logback-core" % logbackVersion
19+
libraryDependencies += "ch.qos.logback" % "logback-classic" % logbackVersion
20+
21+
val http4sVersion = "1.0.0-M37"
22+
libraryDependencies ++= Seq(
23+
"org.http4s" %% "http4s-dsl" % http4sVersion,
24+
"org.http4s" %% "http4s-ember-server" % http4sVersion,
25+
"org.http4s" %% "http4s-circe" % http4sVersion,
26+
)
27+
28+
libraryDependencies += "io.circe" %% "circe-generic" % "0.14.3"
29+
30+
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.15" % "test"
31+
32+
scalacOptions ++= Seq("-Xmax-inlines", "1000")
33+
34+
lazy val root = (project in file("."))
35+
.settings(
36+
name := "scheme-index",
37+
assemblyJarName in assembly := "scheme-index.jar",
38+
assembly / mainClass := Some("scmindex.Main")
39+
)
40+
41+
ThisBuild / assemblyMergeStrategy := {
42+
case PathList("META-INF", "services", xs @ _*) => MergeStrategy.concat
43+
case PathList("META-INF", "services", xs @ _*) => MergeStrategy.concat
44+
case "module-info.class" => MergeStrategy.discard
45+
case s if s.matches("^META-INF/.*\\.SF$") => MergeStrategy.discard
46+
case s if s.matches("^META-INF/.*\\.DSA$") => MergeStrategy.discard
47+
case s if s.matches("^META-INF/.*\\.RSA$") => MergeStrategy.discard
48+
case PathList("META-INF", xs @ _*) =>
49+
(xs map {_.toLowerCase}) match {
50+
case ("manifest.mf" :: Nil) | ("index.list" :: Nil) | ("dependencies" :: Nil) => MergeStrategy.discard
51+
case _ => MergeStrategy.last
52+
}
53+
case _ => MergeStrategy.last
54+
}

0 commit comments

Comments
 (0)