diff --git a/_config.yml b/_config.yml index c94120d..f3dae58 100644 --- a/_config.yml +++ b/_config.yml @@ -18,12 +18,12 @@ collections: nav_bars: - title: "Documents" - url: "/kemal/docs/getting_started" + url: "/kemal/docs/getting_started.html" - title: "Blog" - url: "/blog" + url: "/blog/" - title: "Github" url: "https://github.com/sdogruyol/kemal" examples: - title: "How to connect to Database" - url: https://github.com/sdogruyol/kemal-pg-sample + url: "https://github.com/sdogruyol/kemal-pg-sample" diff --git a/_docs/README.md b/_docs/README.md index ef9437f..b88a35e 100644 --- a/_docs/README.md +++ b/_docs/README.md @@ -31,7 +31,6 @@ Kemal means *Mature, grown up* in Turkish. - [Websockets](./websockets.md) - [Using Dynamic Views](./views.md) - [HTTP Requests and Responses](./http-requests.md) - - [Serving Static Files](./statics.md) - [Serving JSON API](./json.md) - [Middlewares](./middlewares.md) - [How to connect to Database](https://github.com/sdogruyol/kemal-pg-sample) diff --git a/_docs/getting_started.md b/_docs/getting_started.md index 8addd66..a786502 100644 --- a/_docs/getting_started.md +++ b/_docs/getting_started.md @@ -3,8 +3,6 @@ layout: doc title: "Getting Started" --- -# Kemal Tutorial - ## 1. Install Crystal ``` diff --git a/_docs/http-requests.md b/_docs/http-requests.md index 85f423e..2184f0c 100644 --- a/_docs/http-requests.md +++ b/_docs/http-requests.md @@ -1,10 +1,8 @@ --- layout: doc -title: HTTP Requests and Responses +title: HTTP Request / Response Lifecycle --- -# HTTP Request / Response Lifecycle - Accessing the HTTP request/response environment (query params, body, content_type, headers, status_code) is super easy. You can use the environment returned from the block: ```ruby diff --git a/_docs/json.md b/_docs/json.md index 475869c..14a9072 100644 --- a/_docs/json.md +++ b/_docs/json.md @@ -3,8 +3,6 @@ layout: doc title: Serving JSON API --- -# Serving JSON API - You need to return a ```JSON``` object or need to convert the existing object via `to_json`. ```ruby diff --git a/_docs/middlewares.md b/_docs/middlewares.md index e0e550e..26d1d3b 100644 --- a/_docs/middlewares.md +++ b/_docs/middlewares.md @@ -3,9 +3,29 @@ layout: doc title: Middlewares --- -# Middlewares +## Built-in Middlewares -You can create your own middlewares by inheriting from ```HTTP::Handler``` +Kemal has built-in middlewares for common use cases. + +### HTTP Basic Authorization + +This middleware lets you add HTTP Basic Authorization to your Kemal application. +You can easily use this middleware with `basic_auth` macro like below. + +```ruby +require "kemal" + +basic_auth "username", "password" + +get "/" do + "This won't render without correct username and password." +end + +``` + +## Custom middlewares + +You can create your own middleware by inheriting from ```HTTP::Handler``` ```ruby class CustomHandler < HTTP::Handler diff --git a/_docs/rest.md b/_docs/rest.md index 89812c3..d9868f3 100644 --- a/_docs/rest.md +++ b/_docs/rest.md @@ -3,8 +3,6 @@ layout: doc title: Restful Web Services --- -# Restful Web Services - You can handle HTTP methods as easy as writing method names and the route with a code block. Kemal will handle all the hard work. ``` @@ -26,5 +24,5 @@ You can handle HTTP methods as easy as writing method names and the route with a delete "/" do .. annihilate something .. - end + end ``` diff --git a/_docs/static_files.md b/_docs/static_files.md index 395179d..5a50009 100644 --- a/_docs/static_files.md +++ b/_docs/static_files.md @@ -1,20 +1,36 @@ --- layout: doc -title: Serving Static Files +title: Static Files --- -## Static Files +# Statics -Kemal has built-in support for serving your static files. You need to put your static files under your ```/public``` directory. +Add your files to `public` directory and Kemal will serve these files immediately. -E.g: A static file like ```/public/index.html``` will be served with the matching route ```/index.html```. +``` +app/ + src/ + your_app.cr + public/ + js/ + jquery.js + your_app.js + css/ + your_app.css + index.html +``` -## Production / Development Mode +Open index.html and add -By default Kemal starts in ```development```mode and logs to STDOUT. - -You can use ```production``` mode to redirect the output to a file. By default Kemal logs the output to ```kemal.log```. - -You can start Kemal in production mode by: - -```./your_app -e production``` +```html + + + + + + + + ... + + +``` diff --git a/_docs/statics.md b/_docs/statics.md deleted file mode 100644 index e689fce..0000000 --- a/_docs/statics.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -layout: doc -title: Statics ---- - -# Statics - -Add your files to `public` directory and Kemal will serve these files immediately. - -``` -app/ - src/ - your_app.cr - public/ - js/ - jquery.js - your_app.js - css/ - your_app.css - index.html -``` - -Open index.html and add - -```html - - - - - - - - ... - - -``` diff --git a/_docs/views.md b/_docs/views.md index a48190f..0e1c3a3 100644 --- a/_docs/views.md +++ b/_docs/views.md @@ -3,8 +3,6 @@ layout: doc title: Using Dynamic Views --- -# Views - You can use ERB-like built-in **ECR** views to render files. ```ruby diff --git a/_docs/websockets.md b/_docs/websockets.md index eb180b4..2a8ba0c 100644 --- a/_docs/websockets.md +++ b/_docs/websockets.md @@ -3,9 +3,7 @@ layout: doc title: Websockets --- -# Using Websockets - -Using Websockets is super easy! By nature Websockets are a bit different than standard Http Request/Response lifecycle. +Using Websockets is super easy! By nature Websockets are a bit different than standard Http Request / Response lifecycle. You can easily create a websocket handler which matches the route of `ws://host:port/route. You can create more than 1 websocket handler with different routes. diff --git a/_includes/doc-sidebar.md b/_includes/doc-sidebar.md index 6629996..aaeec92 100644 --- a/_includes/doc-sidebar.md +++ b/_includes/doc-sidebar.md @@ -11,16 +11,4 @@ {% endfor %} - -

Examples

- - diff --git a/index.html b/index.html index 02fbefa..021bc11 100644 --- a/index.html +++ b/index.html @@ -8,7 +8,7 @@ layout: home Kemal

- Kemal is a fast, easy to use micro web framework written in Crystal language. + Lightning Fast, Super Simple micro web framework written in Crystal language.
It's inspired from Sinatra.

@@ -42,7 +42,7 @@ end
  • Support all REST verbs
  • Websocket support
  • Request/Response context, easy parameter handling
  • -
  • Custom and built-in middlewares
  • +
  • Built-in and easily extensible middlewares
  • Built-in JSON support
  • Built-in static file serving
  • Built-in view templating via ecr