Skip to content

Commit

Permalink
Update API code to support 'custom' code
Browse files Browse the repository at this point in the history
   * When JIDO_API_CUSTOM is set
   * Fix typos
   * Try building with PicoLisp 16.6
   * Update documentation
  • Loading branch information
aw committed Sep 12, 2016
1 parent eaafee7 commit b5165c1
Show file tree
Hide file tree
Showing 17 changed files with 493 additions and 464 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cache: apt

before_script:
- make
- wget http://software-lab.de/picoLisp-3.1.11.tgz -O /tmp/picolisp.tgz
- wget http://software-lab.de/picoLisp-16.6.tgz -O /tmp/picolisp.tgz
- cd /tmp; tar -xf /tmp/picolisp.tgz
- cd /tmp/picoLisp/src64 && make

Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.11.0 (2016-08-29)

* Add 'JIDO_API_CUSTOM' env variable for loading custom API code, docs, html

## 1.10.2 (2016-04-30)

* Update API Documentation to be much more clear and better organized
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ html:
jade -o . -P -E html ui/index.jade

javascript:
coffee --no-header -c -o docs/ ui/ui.coffee
cat ui/license.coffee ui/generic.coffee ui/ui.coffee | coffee --no-header -c -s > docs/ui.js

js: javascript

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ The name of the stunnel binary. On CentOS it's `stunnel`, but on Debian it's `st

The full path to the Admin application. In most cases it refers to `/opt/jidoteki/admin/`, but it may be different depending on the application.

### JIDO_API_CUSTOM

When this is set (ex: `JIDO_API_CUSTOM=yourapp`), the API will load `custom.l` from the `yourapp/api/v1/core/` directory.

# API Endpoints

See the [API Documentation](docs/API.md).
Expand All @@ -80,7 +84,7 @@ If you want to improve this application, please make a pull-request.

## HTML and JavaScript

The HTML and JavaScript files are written in CoffeeScript and Jade, respectively.
The HTML and JavaScript files are written in Jade and CoffeeScript, respectively.

`npm install -g jade coffeescript minify`

Expand Down
5 changes: 3 additions & 2 deletions api/v1/core/api.l
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

(setq
*PR_SET_NAME 15
*JIDO_API_PORT (if (format (sys "JIDO_API_PORT")) @ 8080) )
*JIDO_API_PORT (if (format (sys "JIDO_API_PORT")) @ 8080)
*JIDO_API_FILE (if (sys "JIDO_API_CUSTOM") (pack @ "/index.html") "index.html") )

(mime "md" "text/markdown; charset=UTF-8" 60)

Expand All @@ -29,7 +30,7 @@
(api-stop)
(https-start)
(prinl "HTTP listening on port: " *JIDO_API_PORT)
(server *JIDO_API_PORT "index.html") ]
(server *JIDO_API_PORT *JIDO_API_FILE) ]

(de api-stop ()
(https-stop) )
5 changes: 3 additions & 2 deletions app.l
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright (c) 2015 Alexander Williams, Unscramble <license@unscramble.jp>
# Copyright (c) 2015-2016 Alexander Williams, Unscramble <license@unscramble.jp>

# Jidoteki Admin API

Expand All @@ -16,12 +16,13 @@
(setq
*API_VERSION (if (format (sys "JIDO_API_VERSION")) @ 1)
*API_PATH (pack "api/v" *API_VERSION)
*API_DOC (if (sys "JIDO_API_CUSTOM") (pack @ "/docs/API.md") "docs/API.md")
*Admin_path (if (sys "JIDO_ADMIN_PATH") @ "/opt/jidoteki/admin/")
*Upload_path (pack *Admin_path "home/sftp/uploads/") )

# Load core
(chdir (pack *API_PATH "/core")
(load "allowed.l" "api.l" "auth.l" "helpers.l") )
(load "allowed.l" "api.l" "auth.l" "helpers.l" (when (sys "JIDO_API_CUSTOM") (pack "../../../" @ "/" *API_PATH "/core/custom.l"))) )

(api-start)

Expand Down
2 changes: 1 addition & 1 deletion docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -956,4 +956,4 @@ Content-Type: application/json

----

**Powered by [Jidoteki](https://jidoteki.com) - [Copyright notices](NOTICE) - `v1.10.2`**
**Powered by [Jidoteki](https://jidoteki.com) - [Copyright notices](/docs/NOTICE) - `v1.11.0`**
2 changes: 1 addition & 1 deletion docs/index.l
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
(use Size Date Body
(let (Pre (pack (in "docs/strapdown-prefix.html" (till (eof))))
Suf (pack (in "docs/strapdown-suffix.html" (till (eof))))
Doc (pack (in "docs/API.md" (till (eof)))) )
Doc (pack (in *API_DOC (till (eof)))) )

(json-string (pack Pre "^J" Doc "^J" Suf))
(response-generic 200 Size Date Body '(("Content-Type" . "text/html") ]
Expand Down
Loading

0 comments on commit b5165c1

Please sign in to comment.