This commit is contained in:
Aşkın Gedik 2015-12-27 18:03:29 +02:00
commit d063ad3718
37 changed files with 1487 additions and 0 deletions

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
_site
.sass-cache
.jekyll-metadata
.DS_Store

29
_config.yml Normal file
View file

@ -0,0 +1,29 @@
# Site settings
title: Kemal
email: dogruyolserdar@gmail.com
description: 'Lightning Fast, Super Simple web framework for Crystal. Inspired by Sinatra'
baseurl: "" # the subpath of your site, e.g. /blog
url: "http://yourdomain.com" # the base hostname & protocol for your site
twitter_username: sdogruyol
github_username: sdogruyol
# Build settings
markdown: redcarpet
highlighter: pygments
permalink: /blog/:year/:month/:day/:title/
collections:
docs:
output: true
nav_bars:
- title: "Documents"
url: "/docs/getting_started"
- title: "Blog"
url: "/blog"
- title: "Github"
url: "http://github.com/sdogruyol/kemal"
examples:
- title: "How to connect to Database"
url: https://github.com/sdogruyol/kemal-pg-sample

37
_docs/README.md Normal file
View file

@ -0,0 +1,37 @@
---
layout: doc
---
# Kemal Documentation
This README includes documentation of Kemal, the Crystal Web Framework.
## What is Kemal?
Kemal is a micro web framework written in Crystal language. It's strongly inspired from [Sinatra](www.sinatrarb.com).
## What is Crystal?
Crystal is a programming language based on *Ruby* syntax.
## Advantages of using Kemal
- Easy to learn and start to develop.
- Since it's working on LLVM, it's too fast.
- Easy deployment to *Heroku*.
## The Name
Kemal means *Mature, grown up* in Turkish.
## How to start?
- [Getting Started Tutorial](./getting_started.md)
- [Restful Web Services](./rest.md)
- [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)

90
_docs/getting_started.md Normal file
View file

@ -0,0 +1,90 @@
---
layout: doc
title: "Getting Started"
---
# Kemal Tutorial
## 1. Install Crystal
```
brew update
brew install crystal-lang
```
## 2. Installing Kemal
You should create your application first:
```
crystal init app your_app
cd your_app
```
Then add *kemal* to the `shard.yml` file as a dependency.
```
dependencies:
kemal:
github: sdogruyol/kemal
branch: master
```
You should run `shards` to get dependencies:
```
shards install
```
It will output something like that:
```
$ shards install
Updating https://github.com/sdogruyol/kemal.git
Installing kemal (master)
```
## 3. Include Kemal into your project
Open `your_app/src/your_app.cr` and require `kemal` to use Kemal.
```ruby
require 'kemal'
```
## 4. Hack your project
Do some awesome stuff with awesome Kemal.
```ruby
get "/" do
"Hello World!"
end
```
All the code should look like this:
```ruby
require "kemal"
get "/" do
"Hello World!"
end
```
## 5. Run your awesome web project.
```
crystal build --release src/your_app.cr
./your_app
```
You should see some logs like these:
```
[development] Kemal is ready to lead at http://0.0.0.0:3000
2015-12-01 13:47:48 +0200 | 200 | GET / - (666µs)
2015-12-05 13:47:48 +0200 | 404 | GET /favicon.ico - (14µs)
```
Now you can be happy with your new, very fast, readable web project.

44
_docs/http-requests.md Normal file
View file

@ -0,0 +1,44 @@
---
layout: doc
title: HTTP Requests and Responses
---
# 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
# Matches /hello/kemal
get "/hello/:name" do |env|
name = env.params["name"]
"Hello back to #{name}"
end
# Matches /resize?width=200&height=200
get "/resize" do |env|
width = env.params["width"]
height = env.params["height"]
end
# Easily access JSON payload from the params.
# The request content type needs to be application/json
# The payload
# {"name": "Serdar", "likes": ["Ruby", "Crystal"]}
post "/json_params" do |env|
name = env.params["name"] as String
likes = env.params["likes"] as Array
"#{name} likes #{likes.each.join(',')}"
end
# Set the content as application/json and return JSON
get "/user.json" do |env|
kemal = {name: "Kemal", language: "Crystal"}
env.content_type = "application/json"
kemal.to_json
end
# Add headers to your response
get "/headers" do |env|
env.add_header "Accept-Language", "tr"
env.add_header "Authorization", "Token 12345"
end

21
_docs/json.md Normal file
View file

@ -0,0 +1,21 @@
---
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
require "kemal"
require "json"
# You can easily access the context and set content_type like 'application/json'.
# Look how easy to build a JSON serving API.
get "/" do |env|
env.content_type = "application/json"
{name: "Serdar", age: 27}.to_json
end
```

19
_docs/middlewares.md Normal file
View file

@ -0,0 +1,19 @@
---
layout: doc
title: Middlewares
---
# Middlewares
You can create your own middlewares by inheriting from ```HTTP::Handler```
```ruby
class CustomHandler < HTTP::Handler
def call(request)
puts "Doing some custom stuff here"
call_next request
end
end
Kemal.config.add_handler CustomHandler.new
```

30
_docs/rest.md Normal file
View file

@ -0,0 +1,30 @@
---
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.
```
get "/" do
.. show something ..
end
post "/" do
.. create something ..
end
put "/" do
.. replace something ..
end
patch "/" do
.. modify something ..
end
delete "/" do
.. annihilate something ..
end
```

20
_docs/static_files.md Normal file
View file

@ -0,0 +1,20 @@
---
layout: doc
title: Serving Static Files
---
## Static Files
Kemal has built-in support for serving your static files. You need to put your static files under your ```/public``` directory.
E.g: A static file like ```/public/index.html``` will be served with the matching route ```/index.html```.
## Production / Development Mode
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```

36
_docs/statics.md Normal file
View file

@ -0,0 +1,36 @@
---
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
<html>
<head>
<script src="/js/jquery.js"></script>
<script src="/js/your_app.js"></script>
<link rel="stylesheet" href="/css/your_app.css"/>
</head>
<body>
...
</body>
</html>
```

16
_docs/utilities.md Normal file
View file

@ -0,0 +1,16 @@
---
layout: doc
title: Utilities
---
# Browser Redirect
Just like other things in `kemal`, browser redirection is super simple as well. Use `environment` variable in defined route's corresponding block and call `redirect` on it.
```ruby
# Redirect browser
get "/logout" do |env|
# important stuff like clearing session etc.
redirect "/login" # redirect to /login page
end
```
_Make sure to receive `env` as param in defined route's block or you might end-up having compile-time errors._

62
_docs/views.md Normal file
View file

@ -0,0 +1,62 @@
---
layout: doc
title: Using Dynamic Views
---
# Views
You can use ERB-like built-in **ECR** views to render files.
```ruby
get '/:name' do
render "views/hello.ecr"
end
```
And you should have an `hello.ecr` view. It will have the same context as the method.
```erb
Hello <%= env.params["name"] %>
```
## Using Layouts
You can use **layouts** in Kemal. You should pass a second argument.
```ruby
get '/:name' do
render "views/subview.ecr", "views/layouts/layout.ecr"
end
```
And you should use `content` variable (like `yield` in Rails) in layout file.
```erb
<html>
<head>
<title><%= $title %></title>
</head>
<body>
<%= content %>
</body>
</html>
```
## Using Common Paths
Since Crystal does not allow using variables in macro literals, you need to generate
another *helper macro* to make the code easier to read and write.
```ruby
macro my_renderer(filename)
render "my/app/view/base/path/#{{{filename}}}.ecr", "my/app/view/base/path/layouts/layout.ecr"
end
```
And now you can use your new renderer.
```ruby
get '/:name' do
my_renderer "subview"
end
```

41
_docs/websockets.md Normal file
View file

@ -0,0 +1,41 @@
---
layout: doc
title: Websockets
---
# Using Websockets
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.
```ruby
ws "/" do |socket|
end
ws "/route2" do |socket|
end
```
Let's access the socket and create a simple echo server.
```ruby
# Matches "/"
ws "/" do |socket|
# Send welcome message to the client
socket.send "Hello from Kemal!"
# Handle incoming message and echo back to the client
socket.on_message do |message|
socket.send "Echo back from server #{message}"
end
# Executes when the client is disconnected. You can do the cleaning up here.
socket.on_close do
puts "Closing socket"
end
end
```

26
_includes/doc-sidebar.md Normal file
View file

@ -0,0 +1,26 @@
<div class="doc-sidebar">
<h1 class="doc-heading">Guide</h1>
<ul class="doc-list">
{% for post in site.docs %}
<li>
<h2>
<a class="doc-link" href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a>
</h2>
</li>
{% endfor %}
</ul>
<h1 class="doc-heading">Examples</h1>
<ul class="doc-list">
{% for post in site.examples %}
<li>
<h2>
<a class="doc-link" href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a>
</h2>
</li>
{% endfor %}
</ul>
</div>

18
_includes/footer.html Normal file
View file

@ -0,0 +1,18 @@
<footer class="site-footer">
<div class="wrapper">
<div class="footer-col-wrapper">
<div class="footer-col footer-col-1">
<ul class="contact-list">
<a href="https://gitter.im/sdogruyol/kemal">
<img src="https://badges.gitter.im/Join%20Chat.svg"/>
</a>
</ul>
</div>
<div class="footer-develop">
<h4>Kemal is developed and maintained by <a href="http://twitter.com/sdogruyol">Serdar Doğruyol</a></h4>
<h5>Design by <a href="http://twitter.com/askngdk">Aşkın Gedik</a></h5>
</div>
</div>
</div>
</footer>

13
_includes/head.html Normal file
View file

@ -0,0 +1,13 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}</title>
<meta name="description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}">
<link rel="stylesheet" href="{{ "/css/bootstrap.min.css" | prepend: site.baseurl }}">
<link rel="stylesheet" href="{{ "/css/main.css" | prepend: site.baseurl }}">
<link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.baseurl | prepend: site.url }}">
<link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}">
</head>

33
_includes/header.html Normal file
View file

@ -0,0 +1,33 @@
<header class="site-header">
<div class="wrapper">
<a class="site-title" href="{{ site.baseurl }}/"><img src="{{ site.baseurl }}/img/kemal.png">{{ site.title }}</a>
<nav class="site-nav">
<a href="#" class="menu-icon">
<svg viewBox="0 0 18 15">
<path fill="#424242" d="M18,1.484c0,0.82-0.665,1.484-1.484,1.484H1.484C0.665,2.969,0,2.304,0,1.484l0,0C0,0.665,0.665,0,1.484,0 h15.031C17.335,0,18,0.665,18,1.484L18,1.484z"/>
<path fill="#424242" d="M18,7.516C18,8.335,17.335,9,16.516,9H1.484C0.665,9,0,8.335,0,7.516l0,0c0-0.82,0.665-1.484,1.484-1.484 h15.031C17.335,6.031,18,6.696,18,7.516L18,7.516z"/>
<path fill="#424242" d="M18,13.516C18,14.335,17.335,15,16.516,15H1.484C0.665,15,0,14.335,0,13.516l0,0 c0-0.82,0.665-1.484,1.484-1.484h15.031C17.335,12.031,18,12.696,18,13.516L18,13.516z"/>
</svg>
</a>
<div class="trigger">
{% for my_page in site.nav_bars %}
{% if my_page.title %}
<a class="page-link" href="{{ my_page.url | prepend: site.baseurl }}">{{ my_page.title }}</a>
{% endif %}
{% endfor %}
<!-- {% for my_page in site.pages %} -->
<!-- {% if my_page.title %} -->
<!-- <a class="page&#45;link" href="{{ my_page.url | prepend: site.baseurl }}">{{ my_page.title }}</a> -->
<!-- {% endif %} -->
<!-- {% endfor %} -->
</div>
</nav>
</div>
</header>

View file

@ -0,0 +1 @@
<a href="https://github.com/{{ include.username }}"><span class="icon icon--github">{% include icon-github.svg %}</span><span class="username">{{ include.username }}</span></a>

View file

@ -0,0 +1 @@
<svg viewBox="0 0 16 16"><path fill="#828282" d="M7.999,0.431c-4.285,0-7.76,3.474-7.76,7.761 c0,3.428,2.223,6.337,5.307,7.363c0.388,0.071,0.53-0.168,0.53-0.374c0-0.184-0.007-0.672-0.01-1.32 c-2.159,0.469-2.614-1.04-2.614-1.04c-0.353-0.896-0.862-1.135-0.862-1.135c-0.705-0.481,0.053-0.472,0.053-0.472 c0.779,0.055,1.189,0.8,1.189,0.8c0.692,1.186,1.816,0.843,2.258,0.645c0.071-0.502,0.271-0.843,0.493-1.037 C4.86,11.425,3.049,10.76,3.049,7.786c0-0.847,0.302-1.54,0.799-2.082C3.768,5.507,3.501,4.718,3.924,3.65 c0,0,0.652-0.209,2.134,0.796C6.677,4.273,7.34,4.187,8,4.184c0.659,0.003,1.323,0.089,1.943,0.261 c1.482-1.004,2.132-0.796,2.132-0.796c0.423,1.068,0.157,1.857,0.077,2.054c0.497,0.542,0.798,1.235,0.798,2.082 c0,2.981-1.814,3.637-3.543,3.829c0.279,0.24,0.527,0.713,0.527,1.437c0,1.037-0.01,1.874-0.01,2.129 c0,0.208,0.14,0.449,0.534,0.373c3.081-1.028,5.302-3.935,5.302-7.362C15.76,3.906,12.285,0.431,7.999,0.431z"/></svg>

After

Width:  |  Height:  |  Size: 926 B

View file

@ -0,0 +1 @@
<a href="https://twitter.com/{{ include.username }}"><span class="icon icon--twitter">{% include icon-twitter.svg %}</span><span class="username">{{ include.username }}</span></a>

View file

@ -0,0 +1 @@
<svg viewBox="0 0 16 16"><path fill="#828282" d="M15.969,3.058c-0.586,0.26-1.217,0.436-1.878,0.515c0.675-0.405,1.194-1.045,1.438-1.809c-0.632,0.375-1.332,0.647-2.076,0.793c-0.596-0.636-1.446-1.033-2.387-1.033c-1.806,0-3.27,1.464-3.27,3.27 c0,0.256,0.029,0.506,0.085,0.745C5.163,5.404,2.753,4.102,1.14,2.124C0.859,2.607,0.698,3.168,0.698,3.767 c0,1.134,0.577,2.135,1.455,2.722C1.616,6.472,1.112,6.325,0.671,6.08c0,0.014,0,0.027,0,0.041c0,1.584,1.127,2.906,2.623,3.206 C3.02,9.402,2.731,9.442,2.433,9.442c-0.211,0-0.416-0.021-0.615-0.059c0.416,1.299,1.624,2.245,3.055,2.271 c-1.119,0.877-2.529,1.4-4.061,1.4c-0.264,0-0.524-0.015-0.78-0.046c1.447,0.928,3.166,1.469,5.013,1.469 c6.015,0,9.304-4.983,9.304-9.304c0-0.142-0.003-0.283-0.009-0.423C14.976,4.29,15.531,3.714,15.969,3.058z"/></svg>

After

Width:  |  Height:  |  Size: 787 B

20
_layouts/default.html Normal file
View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
{% include head.html %}
<body>
{% include header.html %}
<div class="page-content">
<div class="wrapper">
{{ content }}
</div>
</div>
{% include footer.html %}
</body>
</html>

23
_layouts/doc.html Normal file
View file

@ -0,0 +1,23 @@
---
layout: default
---
<div class="row">
<article class="doc col-md-9">
<header class="doc-header">
<h1 class="doc-title">{{ page.title }}</h1>
</header>
<div class="doc-content">
{{ content }}
</div>
</article>
<div class="col-md-3">
{% include doc-sidebar.md %}
</div>
</div>

18
_layouts/home.html Normal file
View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
{% include head.html %}
<body>
{% include header.html %}
<div>
{{ content }}
</div>
{% include footer.html %}
</body>
</html>

14
_layouts/page.html Normal file
View file

@ -0,0 +1,14 @@
---
layout: default
---
<article class="post">
<header class="post-header">
<h1 class="post-title">{{ page.title }}</h1>
</header>
<div class="post-content">
{{ content }}
</div>
</article>

15
_layouts/post.html Normal file
View file

@ -0,0 +1,15 @@
---
layout: default
---
<article class="post" itemscope itemtype="http://schema.org/BlogPosting">
<header class="post-header">
<h1 class="post-title" itemprop="name headline">{{ page.title }}</h1>
<p class="post-meta"><time datetime="{{ page.date | date_to_xmlschema }}" itemprop="datePublished">{{ page.date | date: "%b %-d, %Y" }}</time>{% if page.author %} • <span itemprop="author" itemscope itemtype="http://schema.org/Person"><span itemprop="name">{{ page.author }}</span></span>{% endif %}</p>
</header>
<div class="post-content" itemprop="articleBody">
{{ content }}
</div>
</article>

View file

@ -0,0 +1,8 @@
---
layout: post
title: Hello World
---
Hello World!
<!-- more -->

207
_sass/_base.scss Normal file
View file

@ -0,0 +1,207 @@
/**
* Reset some basic elements
*/
body, h1, h2, h3, h4, h5, h6,
p, blockquote, pre, hr,
dl, dd, ol, ul, figure {
margin: 0;
padding: 0;
}
/**
* Basic styling
*/
body {
font: $base-font-weight #{$base-font-size}/#{$base-line-height} $base-font-family;
color: $text-color;
background-color: $background-color;
-webkit-text-size-adjust: 100%;
-webkit-font-feature-settings: "kern" 1;
-moz-font-feature-settings: "kern" 1;
-o-font-feature-settings: "kern" 1;
font-feature-settings: "kern" 1;
font-kerning: normal;
}
/**
* Set `margin-bottom` to maintain vertical rhythm
*/
h1, h2, h3, h4, h5, h6,
p, blockquote, pre,
ul, ol, dl, figure,
%vertical-rhythm {
margin-bottom: $spacing-unit / 2;
}
/**
* Images
*/
img {
max-width: 100%;
vertical-align: middle;
}
/**
* Figures
*/
figure > img {
display: block;
}
figcaption {
font-size: $small-font-size;
}
/**
* Lists
*/
ul, ol {
margin-left: $spacing-unit;
}
li {
> ul,
> ol {
margin-bottom: 0;
}
}
/**
* Headings
*/
h1, h2, h3, h4, h5, h6 {
font-weight: $base-font-weight;
}
/**
* Links
*/
a {
color: $brand-color;
text-decoration: none;
&:visited {
color: darken($brand-color, 15%);
}
&:hover {
color: $red-color-light;
text-decoration: underline;
}
}
/**
* Blockquotes
*/
blockquote {
color: $grey-color;
border-left: 4px solid $grey-color-light;
padding-left: $spacing-unit / 2;
font-size: 18px;
letter-spacing: -1px;
font-style: italic;
> :last-child {
margin-bottom: 0;
}
}
/**
* Code formatting
*/
pre,
code {
font-size: 15px;
border: 1px solid $grey-color-light;
border-radius: 3px;
background-color: #f9f9f9;
}
code {
padding: 1px 5px;
}
pre {
padding: 8px 12px;
overflow-x: auto;
> code {
border: 0;
padding-right: 0;
padding-left: 0;
}
}
/**
* Wrapper
*/
.wrapper {
max-width: -webkit-calc(#{$content-width} - (#{$spacing-unit} * 2));
max-width: calc(#{$content-width} - (#{$spacing-unit} * 2));
margin-right: auto;
margin-left: auto;
padding-right: $spacing-unit;
padding-left: $spacing-unit;
@extend %clearfix;
@include media-query($on-laptop) {
max-width: -webkit-calc(#{$content-width} - (#{$spacing-unit}));
max-width: calc(#{$content-width} - (#{$spacing-unit}));
padding-right: $spacing-unit / 2;
padding-left: $spacing-unit / 2;
}
}
/**
* Clearfix
*/
%clearfix {
&:after {
content: "";
display: table;
clear: both;
}
}
/**
* Icons
*/
.icon {
> svg {
display: inline-block;
width: 16px;
height: 16px;
vertical-align: middle;
path {
fill: $grey-color;
}
}
}

348
_sass/_layout.scss Normal file
View file

@ -0,0 +1,348 @@
/**
* Site header
*/
.site-header {
border-top: 7px solid $red-color;
border-bottom: 1px solid $grey-color-light;
min-height: 56px;
// Positioning context for the mobile navigation icon
position: relative;
}
.site-title {
font-size: 26px;
font-weight: 300;
line-height: 90px;
letter-spacing: -1px;
margin-bottom: 0;
float: left;
&,
&:visited {
color: $grey-color-dark;
}
}
.site-title img {
width: 60px;
}
.site-nav {
float: right;
line-height: 90px;
.menu-icon {
display: none;
}
.page-link {
color: $text-color;
line-height: $base-line-height;
// Gaps between nav items, but not on the last one
&:not(:last-child) {
margin-right: 20px;
}
}
@include media-query($on-palm) {
position: absolute;
top: 26px;
right: $spacing-unit / 2;
background-color: $background-color;
border: 1px solid $grey-color-light;
border-radius: 5px;
text-align: right;
.menu-icon {
display: block;
float: right;
width: 36px;
height: 26px;
line-height: 0;
padding-top: 10px;
text-align: center;
> svg {
width: 18px;
height: 15px;
path {
fill: $grey-color-dark;
}
}
}
.trigger {
clear: both;
display: none;
}
&:hover .trigger {
display: block;
padding-bottom: 5px;
}
.page-link {
display: block;
padding: 5px 10px;
&:not(:last-child) {
margin-right: 0;
}
margin-left: 20px;
}
}
}
/**
* Site footer
*/
.site-footer {
border-top: 1px solid $grey-color-light;
margin-top: 40px;
padding: $spacing-unit 0;
}
.footer-heading {
font-size: 18px;
margin-bottom: $spacing-unit / 2;
}
.contact-list,
.social-media-list {
list-style: none;
margin-left: 0;
}
.footer-col-wrapper {
font-size: 15px;
color: $grey-color;
margin-left: -$spacing-unit / 2;
@extend %clearfix;
}
.footer-col {
float: left;
margin-bottom: $spacing-unit / 2;
padding-left: $spacing-unit / 2;
}
.footer-col-1 {
width: -webkit-calc(35% - (#{$spacing-unit} / 2));
width: calc(35% - (#{$spacing-unit} / 2));
}
.footer-col-2 {
width: -webkit-calc(20% - (#{$spacing-unit} / 2));
width: calc(20% - (#{$spacing-unit} / 2));
}
.footer-col-3 {
width: -webkit-calc(45% - (#{$spacing-unit} / 2));
width: calc(45% - (#{$spacing-unit} / 2));
}
@include media-query($on-laptop) {
.footer-col-1,
.footer-col-2 {
width: -webkit-calc(50% - (#{$spacing-unit} / 2));
width: calc(50% - (#{$spacing-unit} / 2));
}
.footer-col-3 {
width: -webkit-calc(100% - (#{$spacing-unit} / 2));
width: calc(100% - (#{$spacing-unit} / 2));
}
}
@include media-query($on-palm) {
.footer-col {
float: none;
width: -webkit-calc(100% - (#{$spacing-unit} / 2));
width: calc(100% - (#{$spacing-unit} / 2));
}
}
/**
* Page content
*/
.page-content {
padding: $spacing-unit 0;
}
.page-heading {
font-size: 20px;
}
.post-list {
margin-left: 0;
list-style: none;
> li {
margin-bottom: $spacing-unit;
}
}
.post-meta {
font-size: $small-font-size;
color: $grey-color;
}
.post-link {
display: block;
font-size: 24px;
}
/**
* Posts
*/
.post-header {
margin-bottom: $spacing-unit;
}
.post-title {
font-size: 42px;
letter-spacing: -1px;
line-height: 1;
@include media-query($on-laptop) {
font-size: 36px;
}
}
.post-content {
margin-bottom: $spacing-unit;
h2 {
font-size: 32px;
@include media-query($on-laptop) {
font-size: 28px;
}
}
h3 {
font-size: 26px;
@include media-query($on-laptop) {
font-size: 22px;
}
}
h4 {
font-size: 20px;
@include media-query($on-laptop) {
font-size: 18px;
}
}
}
/**
* doc content
*/
.doc-sidebar {
background: #f8f8f8;
// padding: $spacing-unit/2;
border-bottom: 1px solid #ccc;
text-shadow: 0 1px 0 #fff;
padding: 20px 24px;
-webkit-box-shadow: 0 0 3px rgba(0,0,0,0.4);
-moz-box-shadow: 0 0 3px rgba(0,0,0,0.4);
box-shadow: 0 0 3px rgba(0,0,0,0.4);
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.doc {
}
.doc-content {
}
.doc-heading {
padding: 0 0 9px;
border-bottom: 1px solid #ccc;
color: #111;
font-size: 20px;
line-height: 20px;
}
.doc-list {
margin-left: 0px;
margin-bottom: 24px;
list-style: none;
> li {
margin: 6px 0;
font-size: 15px;
line-height: 20px
}
}
.doc-meta {
font-size: $small-font-size;
color: $grey-color;
}
.doc-link {
display: block;
font-size: 13px;
}
.hero {
background: #f1f1f1;
text-align: center;
padding: 40px 0;
margin-bottom: 40px;
img {
width: 13%;
}
h1 {
font-size: 55px;
margin: 0px;
}
.button {
display: inline-block;
background: $red-color-light;
color: white;
padding: 8px 20px;
font-size: 16px;
line-height: 20px;
text-decoration: none;
margin: 0 3px 0 0;
font-weight: normal;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
-webkit-box-shadow: 0 2px 0 $red-color-dark;
-moz-box-shadow: 0 2px 0 $red-color-dark;
box-shadow: 0 2px 0 $red-color-dark;
}
}
.footer-develop {
text-align: right;
h4 {
font-size: 13px;
}
h5 {
font-size: 11px;
}
}
.block {
margin-top: 40px;
h1 {
text-align: center;
}
}

View file

@ -0,0 +1,65 @@
.highlight .hll { background-color: #ffc; }
.highlight .c { color: #999; } /* Comment */
.highlight .err { color: #a00; background-color: #faa } /* Error */
.highlight .k { color: #069; } /* Keyword */
.highlight .o { color: #555 } /* Operator */
.highlight .cm { color: #09f; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #099 } /* Comment.Preproc */
.highlight .c1 { color: #999; } /* Comment.Single */
.highlight .cs { color: #999; } /* Comment.Special */
.highlight .gd { background-color: #fcc; border: 1px solid #c00 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #f00 } /* Generic.Error */
.highlight .gh { color: #030; } /* Generic.Heading */
.highlight .gi { background-color: #cfc; border: 1px solid #0c0 } /* Generic.Inserted */
.highlight .go { color: #aaa } /* Generic.Output */
.highlight .gp { color: #009; } /* Generic.Prompt */
.highlight .gs { } /* Generic.Strong */
.highlight .gu { color: #030; } /* Generic.Subheading */
.highlight .gt { color: #9c6 } /* Generic.Traceback */
.highlight .kc { color: #069; } /* Keyword.Constant */
.highlight .kd { color: #069; } /* Keyword.Declaration */
.highlight .kn { color: #069; } /* Keyword.Namespace */
.highlight .kp { color: #069 } /* Keyword.Pseudo */
.highlight .kr { color: #069; } /* Keyword.Reserved */
.highlight .kt { color: #078; } /* Keyword.Type */
.highlight .m { color: #f60 } /* Literal.Number */
.highlight .s { color: #d44950 } /* Literal.String */
.highlight .na { color: #4f9fcf } /* Name.Attribute */
.highlight .nb { color: #366 } /* Name.Builtin */
.highlight .nc { color: #0a8; } /* Name.Class */
.highlight .no { color: #360 } /* Name.Constant */
.highlight .nd { color: #99f } /* Name.Decorator */
.highlight .ni { color: #999; } /* Name.Entity */
.highlight .ne { color: #c00; } /* Name.Exception */
.highlight .nf { color: #c0f } /* Name.Function */
.highlight .nl { color: #99f } /* Name.Label */
.highlight .nn { color: #0cf; } /* Name.Namespace */
.highlight .nt { color: #2f6f9f; } /* Name.Tag */
.highlight .nv { color: #033 } /* Name.Variable */
.highlight .ow { color: #000; } /* Operator.Word */
.highlight .w { color: #bbb } /* Text.Whitespace */
.highlight .mf { color: #f60 } /* Literal.Number.Float */
.highlight .mh { color: #f60 } /* Literal.Number.Hex */
.highlight .mi { color: #f60 } /* Literal.Number.Integer */
.highlight .mo { color: #f60 } /* Literal.Number.Oct */
.highlight .sb { color: #c30 } /* Literal.String.Backtick */
.highlight .sc { color: #c30 } /* Literal.String.Char */
.highlight .sd { color: #c30; font-style: italic } /* Literal.String.Doc */
.highlight .s2 { color: #c30 } /* Literal.String.Double */
.highlight .se { color: #c30; } /* Literal.String.Escape */
.highlight .sh { color: #c30 } /* Literal.String.Heredoc */
.highlight .si { color: #a00 } /* Literal.String.Interpol */
.highlight .sx { color: #c30 } /* Literal.String.Other */
.highlight .sr { color: #3aa } /* Literal.String.Regex */
.highlight .s1 { color: #c30 } /* Literal.String.Single */
.highlight .ss { color: #fc3 } /* Literal.String.Symbol */
.highlight .bp { color: #366 } /* Name.Builtin.Pseudo */
.highlight .vc { color: #033 } /* Name.Variable.Class */
.highlight .vg { color: #033 } /* Name.Variable.Global */
.highlight .vi { color: #033 } /* Name.Variable.Instance */
.highlight .il { color: #f60 } /* Literal.Number.Integer.Long */
.css .o,
.css .o + .nt,
.css .nt + .nt { color: #999; }

20
blog/index.html Normal file
View file

@ -0,0 +1,20 @@
---
layout: default
---
<div class="home">
<h1 class="page-heading">Posts</h1>
<ul class="post-list">
{% for post in site.posts %}
<li>
<span class="post-meta">{{ post.date | date: "%b %-d, %Y" }}</span>
<h2>
<a class="post-link" href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a>
</h2>
</li>
{% endfor %}
</ul>
</div>

14
css/bootstrap.min.css vendored Executable file

File diff suppressed because one or more lines are too long

58
css/main.scss Normal file
View file

@ -0,0 +1,58 @@
---
# Only the main Sass file needs front matter (the dashes are enough)
---
@charset "utf-8";
// Our variables
$base-font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
$base-font-size: 16px;
$base-font-weight: 400;
$small-font-size: $base-font-size * 0.875;
$base-line-height: 1.5;
$spacing-unit: 30px;
$text-color: #525252;
$background-color: #fdfdfd;
$brand-color: #2a7ae2;
$grey-color: #828282;
// $grey-color: #525252;
$grey-color-light: lighten($grey-color, 40%);
$grey-color-dark: darken($grey-color, 25%);
$red-color: #f92727;
$red-color-light: #ff4f4f;
$red-color-dark: darken($red-color, 25%);
// Width of the content area
$content-width: 1024px;
$on-palm: 600px;
$on-laptop: 800px;
// Use media queries like this:
// @include media-query($on-palm) {
// .wrapper {
// padding-right: $spacing-unit / 2;
// padding-left: $spacing-unit / 2;
// }
// }
@mixin media-query($device) {
@media screen and (max-width: $device) {
@content;
}
}
// Import partials from `sass_dir` (defaults to `_sass`)
@import
"base",
"layout",
"syntax-highlighting"
;

19
docs.md Normal file
View file

@ -0,0 +1,19 @@
---
layout: default
---
<div class="doc-sidebar">
<h1 class="doc-heading">Documents</h1>
<ul class="doc-list">
{% for post in site.docs %}
<li>
<h2>
<a class="doc-link" href="{{ post.url | prepend: site.baseurl }}">{{ post.title }}</a>
</h2>
</li>
{% endfor %}
</ul>
</div>

30
feed.xml Normal file
View file

@ -0,0 +1,30 @@
---
layout: null
---
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ site.title | xml_escape }}</title>
<description>{{ site.description | xml_escape }}</description>
<link>{{ site.url }}{{ site.baseurl }}/</link>
<atom:link href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}" rel="self" type="application/rss+xml"/>
<pubDate>{{ site.time | date_to_rfc822 }}</pubDate>
<lastBuildDate>{{ site.time | date_to_rfc822 }}</lastBuildDate>
<generator>Jekyll v{{ jekyll.version }}</generator>
{% for post in site.posts limit:10 %}
<item>
<title>{{ post.title | xml_escape }}</title>
<description>{{ post.content | xml_escape }}</description>
<pubDate>{{ post.date | date_to_rfc822 }}</pubDate>
<link>{{ post.url | prepend: site.baseurl | prepend: site.url }}</link>
<guid isPermaLink="true">{{ post.url | prepend: site.baseurl | prepend: site.url }}</guid>
{% for tag in post.tags %}
<category>{{ tag | xml_escape }}</category>
{% endfor %}
{% for cat in post.categories %}
<category>{{ cat | xml_escape }}</category>
{% endfor %}
</item>
{% endfor %}
</channel>
</rss>

BIN
img/kemal.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

85
index.html Normal file
View file

@ -0,0 +1,85 @@
---
layout: home
---
<div class="hero">
<h1>
<img src="img/kemal.png" alt="kemal"/>
Kemal
</h1>
<h2>
Kemal is a micro web framework written in Crystal language.
<br />
It's strongly inspired from Sinatra.
</h2>
<a href="/docs/getting_started" class="button">Start Now!</a>
</div>
<div class="wrapper block">
<div class="row">
<div class="col-md-6">
<h1>Super Simple</h1>
{% highlight ruby %}
require "kemal"
# Matches GET "http://host:port/"
get "/" do
"Hello World!"
end
# Creates a WebSocket handler.
# Matches "ws://host:port/socket"
ws "/socket" do |socket|
socket.send "Hello from Kemal!"
end
{% endhighlight %}
</div>
<div class="col-md-6">
<h1>Features</h1>
<ul>
<li>Support all REST verbs</li>
<li>Websocket support</li>
<li>Request/Response context, easy parameter handling</li>
<li>Middlewares</li>
<li>Built-in JSON support</li>
<li>Built-in static file serving</li>
<li>Built-in view templating via ecr</li>
</ul>
</div>
</div>
</div>
<div class="wrapper block">
<div class="row">
<div class="col-md-12">
<h1>Benchmarks</h1>
<p>Numbers speak louder than words.</p>
<table class="table"><thead>
<tr>
<th>Framework</th>
<th>Request Per Second</th>
<th>Avg. Response Time</th>
</tr>
</thead><tbody>
<tr>
<td>Kemal (Production)</td>
<td>64986</td>
<td>170μs</td>
</tr>
<tr>
<td>Sinatra (Thin)</td>
<td>2274</td>
<td>43.82ms</td>
</tr>
</tbody></table>
<br />
<p> These results were achieved with <strong>wrk</strong> on a Macbook Pro Late 2013. (<strong>2Ghz i7 8GB Ram OS X Yosemite</strong>) </p>
</div>
</div>
</div>