From 32ff60315ece9b2a16465187c7707334f984cb80 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Sun, 14 Jan 2024 19:26:31 +0800 Subject: [PATCH] update-docs --- .github/workflows/actions.yml | 2 +- .../1 - Cask: a Scala HTTP micro-framework.md | 11 ++++--- docs/pages/3 - About Cask.md | 2 +- .../app/src/VariableRoutes.scala | 8 ++--- notes.txt | 32 ------------------- 5 files changed, 12 insertions(+), 43 deletions(-) delete mode 100644 notes.txt diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index c660a4f7e8..1445b682f4 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -80,7 +80,7 @@ jobs: generate_docs: - if: github.repository == 'com-lihaoyi/cask' && contains(github.ref, 'refs/tags/') + if: github.repository == 'com-lihaoyi/cask' needs: publish-sonatype runs-on: ubuntu-20.04 env: diff --git a/docs/pages/1 - Cask: a Scala HTTP micro-framework.md b/docs/pages/1 - Cask: a Scala HTTP micro-framework.md index 9832d1b604..778bef1a8c 100644 --- a/docs/pages/1 - Cask: a Scala HTTP micro-framework.md +++ b/docs/pages/1 - Cask: a Scala HTTP micro-framework.md @@ -137,11 +137,12 @@ and pass them all into `cask.Main`. $$$variableRoutes -You can bind path segments to endpoint parameters by declaring them as parameters. these are +You can bind path segments to endpoint parameters by declaring them as parameters. These are either: * A parameter of the same name as the variable path segment of the same name as you - (e.g. `postId` above), + (e.g. `:userName` above). This can be a `String,` or other primitive types like `Int`, + `Boolean`, `Byte`, `Short`, `Long`, `Float`, `Double` * A parameter of type `segments: cask.RemainingPathSegments`, if you want to allow the endpoint to handle arbitrary sub-paths of the given path @@ -424,7 +425,7 @@ $$$todoDb This example demonstrates how to use Cask to write a TodoMVC API server that persists it's state in a database rather than in memory. We use the -[Quill](http://getquill.io/) database access library to write a `@transactional` +[ScalaSql](https://github.com/com-lihaoyi/scalasql/) database access library to write a `@transactional` decorator that automatically opens one transaction per call to an endpoint, ensuring that database queries are properly committed on success or rolled-back on error. Note that because the default database connector propagates its @@ -432,7 +433,7 @@ transaction context in a thread-local, `@transactional` does not need to pass the `ctx` object into each endpoint as an additional parameter list, and so we simply leave it out. -While this example is specific to Quill, you can easily modify the +While this example is specific to ScalaSql, you can easily modify the `@transactional` decorator to make it work with whatever database access library you happen to be using. For libraries which need an implicit transaction, it can be passed into each endpoint function as an additional parameter list as @@ -451,7 +452,7 @@ The following code snippet is the complete code for a full-stack TodoMVC implementation: including HTML generation for the web UI via [Scalatags](https://github.com/lihaoyi/scalatags), Javascript for the interactivity, static file serving, and database integration via -[Quill](https://github.com/getquill/quill). While slightly long, this example +[ScalaSql](https://github.com/com-lihaoyi/scalasql/). While slightly long, this example should give you a tour of all the things you need to know to use Cask. Note that this is a "boring" server-side-rendered webapp with Ajax interactions, diff --git a/docs/pages/3 - About Cask.md b/docs/pages/3 - About Cask.md index 42f01b6111..9bfd122b16 100644 --- a/docs/pages/3 - About Cask.md +++ b/docs/pages/3 - About Cask.md @@ -86,7 +86,7 @@ uses the [Mill](https://github.com/lihaoyi/mill) build tool, comes bundled with the [uPickle](https://github.com/lihaoyi/upickle) JSON library, and makes it trivial to pull in libraries like [Scalatags](https://github.com/lihaoyi/scalatags) to render HTML or -[Quill](https://github.com/getquill/quill) for database access. +[ScalaSql](https://github.com/com-lihaoyi/scalasql/) for database access. Each of these are stable, well-known, well-documented libraries you may already be familiar with, and Cask simply provides the HTTP/routing layer with the hooks diff --git a/example/variableRoutes/app/src/VariableRoutes.scala b/example/variableRoutes/app/src/VariableRoutes.scala index bcd9518cc1..a706f47e37 100644 --- a/example/variableRoutes/app/src/VariableRoutes.scala +++ b/example/variableRoutes/app/src/VariableRoutes.scala @@ -6,13 +6,13 @@ object VariableRoutes extends cask.MainRoutes{ } @cask.get("/path") // GET allowing arbitrary sub-paths, e.g. HOST/path/foo/bar/baz - def getSubpath(remainingPathSegments: cask.RemainingPathSegments) = { - s"Subpath ${remainingPathSegments.value}" + def getSubpath(segments: cask.RemainingPathSegments) = { + s"Subpath ${segments.value}" } @cask.post("/path") // POST allowing arbitrary sub-paths, e.g. HOST/path/foo/bar/baz - def postArticleSubpath(remainingPathSegments: cask.RemainingPathSegments) = { - s"POST Subpath ${remainingPathSegments.value}" + def postArticleSubpath(segments: cask.RemainingPathSegments) = { + s"POST Subpath ${segments.value}" } initialize() diff --git a/notes.txt b/notes.txt deleted file mode 100644 index 797754425f..0000000000 --- a/notes.txt +++ /dev/null @@ -1,32 +0,0 @@ -Web Framework -- Build tool - Y Mill -- Routing - ? Custom - Y Basics - X Composition -- HTML Templating - Y Scalatags - Y Twirl -- JSON - Y uJson -- Filesystem - Y Ammonite -- SQL - Y Quill? -- Migrations - ? -- HTTP Client - Y Requests-Scala -- Modules - X Traits mixed into Main -- Dev Environment - X Custom ---- PUNT --- -Async -Forms -Client-side Support - - Packaging/Resource pipelines can be handled by Mill -Sending Emails -User Management -Sending Emails \ No newline at end of file