From 39c1546f8e3769c857ec8581e418f19c7e54128d Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Fri, 2 Aug 2024 20:19:03 +0300 Subject: Add documentation for gn-markdown editor --- README.md | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/README.md b/README.md index c7f367b..c229152 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,108 @@ 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 + . .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. + +**Request Example:** + +``` +localhost:8091/edit?file_path=test.md +``` + +**Expected Success Response:** + +```json +{ + "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": "file-error", + "msg": "The file path /home/kabui/test_repo/test.md does not exist" +} +``` + +## Commit (POST) + +This is a POST request to commit changes to a file. + +**Request URL:** + +``` +localhost:8091/commit +``` + +**Request Body Example:** + +```json +{ + "content": "Test for new user\n test 2 for line\n test 3 for new line\n ## real markdown two test\n", + "filename": "test.md", + "username": "genetics", + "email": "genetics@gmail.com", + "commit": "commit by genetics" +} +``` + +**Expected Success Response:** + +```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." +} +``` + # Development ``` -- cgit v1.2.3