diff options
author | Pjotr Prins | 2024-10-23 15:17:43 -0500 |
---|---|---|
committer | Pjotr Prins | 2024-10-23 15:17:43 -0500 |
commit | a8656fb1890c2e08e22f38de0464ec4252e8180c (patch) | |
tree | 45167548db63ccaca9cf010882942f7ee64f2f6c | |
parent | c9aa9f3d87affcc720260b970b945e228dfc421c (diff) | |
download | gn-guile-a8656fb1890c2e08e22f38de0464ec4252e8180c.tar.gz |
Update documentation
-rw-r--r-- | README.md | 126 | ||||
-rw-r--r-- | doc/git-markdown-editor.md | 117 | ||||
-rw-r--r-- | doc/gn-guile.md | 1 |
3 files changed, 134 insertions, 110 deletions
@@ -2,6 +2,17 @@ This directory provides a Guile web service incl. the new REST API. It is used in conjunction with the Python web services and (very much) WIP. +## Run + +1. **Navigate to the Web Directory and Start the Server** + +Running the web server is documented in [guix script](./web/.guix-shell). + +``` +curl http://127.0.0.1:8091/version +"4.0.0" +``` + # Documentation Start with this file and then the documentation in [doc](./doc/gn-guile.md). @@ -31,117 +42,7 @@ Next fire up emacs with `emacs-geiser-guile` and connect to the running web serv Some tooling and scripts that run independently are stored in `./scripts`. -Here’s the entire markdown content combined into a single, copyable file: - - -# Gn-Markdown - -Gn-Markdown is an API endpoint to edit, parse, and commit markdown files for gn-docs. - -## How to Test the APIs - -1. **Navigate to the Web Directory and Start the Server** - -```sh -cd web -export CURRENT_REPO_PATH=<path-to-git-repo-with-files> -export CGIT_REPO_PATH=<path-to-git-bare-repo> -. .guix-shell -- guile -L .. --listen=1970 -e main ./webserver.scm 8091 -``` - -2. **Test Endpoints** - -The main endpoints provided are `/edit` and `/commit`. More endpoints may be added in the future. - -## Edit (GET) -This is a GET request to retrieve a file's details. Make sure you pass a valid file_path as search_query (the path should be relative to the repo) - -**Request Example:** - -```bash - -curl -G -d "file_path=test.md" localhost:8091/edit - -``` - -**Expected Success Response:** - -```json -{ -"file_path": "test.md", -"content": "Test for new user\n test 2 for line\n test 3 for new line\n ## real markdown two test\n", -"hash": "ecd96f27c45301279150fbda411544687db1aa45" -} -``` - -**Expected Error Response (Status 400):** - -```json -{ -"error": <error_type>, -"msg": <error_reason> -} -``` - -## Commit (POST) - -This is a POST request to commit changes to a file. - -**Request URL:** - -```bash - -curl -X POST http://127.0.0.1:8091/commit \ --H 'Content-Type: application/json' \ --d '{ -"content": "make test commit", -"filename": "test.md", -"email": "test@gmail.com", -"username": "test", -"commit_message": "init commit", -"prev_commit": "7cbfc40d98b49a64e98e7cd562f373053d0325bd" -}' - -``` - - - -**Expected Response for success:** - -```json -{ -"status": "201", -"message": "Committed file successfully", -"content": "Test for new user\n test 2 for line\n test 3 for new line\n ## real markdown two test\n", -"commit_sha": "47df3b7f13a935d50cc8b40e98ca9e513cba104c", -"commit_message": "commit by genetics" -} - -``` - -**If No Changes to File:** - -```json -{ -"status": "200", -"message": "Nothing to commit, working tree clean", -"commit_sha": "ecd96f27c45301279150fbda411544687db1aa45" -} -``` - -**Expected Error Response:** - -```json -{ -"error": "system-error", -"msg": "Commits do not match. Please pull in the latest changes for the current commit *ecd96f27c45301279150fbda411544687db1aa45* and previous commits." -} -``` - -## Notes - -This is meant to be used as api endpoint only to edit any local repo; Clients are expected to handle other service e.g User Interface, authentication # Development @@ -149,6 +50,11 @@ This is meant to be used as api endpoint only to edit any local repo; Clients ar git remote add gn git.genenetwork.org:/home/git/public/gn-guile ``` +# Topics + +* More on [gn-guile](./doc/gn-guile.md) +* Markdown editor with git backend see [markdown](./doc/git-markdown-editor.md). + # LICENSE This software is published by the GeneNetwork team under the AGPL3. See [LICENSE](LICENSE.txt). diff --git a/doc/git-markdown-editor.md b/doc/git-markdown-editor.md new file mode 100644 index 0000000..f286284 --- /dev/null +++ b/doc/git-markdown-editor.md @@ -0,0 +1,117 @@ +# Gn-Markdown + +Gn-Markdown is an API endpoint to edit, parse, and commit markdown files for gn-docs. + +## How to Test the APIs + +1. **Navigate to the Web Directory and Start the Server** + +Running the web server is documented in [guix script](./web/.guix-shell). + +``` +curl http://127.0.0.1:8091/version +"4.0.0" +``` + +```sh +cd web +export CURRENT_REPO_PATH=<path-to-git-repo-with-files> +export CGIT_REPO_PATH=<path-to-git-bare-repo> +. .guix-shell -- guile -L .. --listen=1970 -e main ./webserver.scm 8091 +``` + + + +2. **Test Endpoints** + +The main endpoints provided are `/edit` and `/commit`. More endpoints may be added in the future. + +## Edit (GET) + +This is a GET request to retrieve a file's details. Make sure you pass a valid file_path as search_query (the path should be relative to the repo) + +**Request Example:** + +```bash + +curl -G -d "file_path=test.md" localhost:8091/edit + +``` + +**Expected Success Response:** + +```json +{ +"file_path": "test.md", +"content": "Test for new user\n test 2 for line\n test 3 for new line\n ## real markdown two test\n", +"hash": "ecd96f27c45301279150fbda411544687db1aa45" +} +``` + +**Expected Error Response (Status 400):** + +```json +{ +"error": <error_type>, +"msg": <error_reason> +} +``` + +## Commit (POST) + +This is a POST request to commit changes to a file. + +**Request URL:** + +```bash + +curl -X POST http://127.0.0.1:8091/commit \ +-H 'Content-Type: application/json' \ +-d '{ +"content": "make test commit", +"filename": "test.md", +"email": "test@gmail.com", +"username": "test", +"commit_message": "init commit", +"prev_commit": "7cbfc40d98b49a64e98e7cd562f373053d0325bd" +}' + +``` + + + +**Expected Response for success:** + +```json +{ +"status": "201", +"message": "Committed file successfully", +"content": "Test for new user\n test 2 for line\n test 3 for new line\n ## real markdown two test\n", +"commit_sha": "47df3b7f13a935d50cc8b40e98ca9e513cba104c", +"commit_message": "commit by genetics" +} + +``` + +**If No Changes to File:** + +```json +{ +"status": "200", +"message": "Nothing to commit, working tree clean", +"commit_sha": "ecd96f27c45301279150fbda411544687db1aa45" +} +``` + +**Expected Error Response:** + +```json +{ +"error": "system-error", +"msg": "Commits do not match. Please pull in the latest changes for the current commit *ecd96f27c45301279150fbda411544687db1aa45* and previous commits." +} +``` + +## Notes + +This is meant to be used as api endpoint only to edit any local repo; Clients are expected to handle other service e.g User Interface, authentication diff --git a/doc/gn-guile.md b/doc/gn-guile.md index 7a86c13..9e84e23 100644 --- a/doc/gn-guile.md +++ b/doc/gn-guile.md @@ -4,4 +4,5 @@ The GeneNetwork Guile web server serves an exploratory REST API as well as HTML Topics are: +* [Markdown editor](./git-markdown-editor.md). * [Branding GN](./branding.md) |