├── log └── .keep ├── app ├── mailers │ └── .keep ├── models │ ├── .keep │ ├── concerns │ │ └── .keep │ ├── micropost.rb │ └── user.rb ├── assets │ ├── images │ │ └── .keep │ ├── stylesheets │ │ ├── docs.scss │ │ └── application.css │ └── javascripts │ │ ├── docs.coffee │ │ └── application.js ├── controllers │ ├── concerns │ │ └── .keep │ ├── api │ │ ├── v2 │ │ │ └── users_controller.rb │ │ └── v1 │ │ │ ├── microposts_controller.rb │ │ │ ├── sessions_controller.rb │ │ │ ├── users_controller.rb │ │ │ └── base_controller.rb │ ├── application_controller.rb │ └── docs_controller.rb ├── helpers │ ├── docs_helper.rb │ ├── api │ │ ├── v2 │ │ │ └── users_helper.rb │ │ └── v1 │ │ │ ├── sessions_helper.rb │ │ │ └── microposts_helper.rb │ └── application_helper.rb ├── docs │ └── slate │ │ ├── .travis.yml │ │ ├── Rakefile │ │ ├── source │ │ ├── javascripts │ │ │ ├── all.js │ │ │ ├── all_nosearch.js │ │ │ ├── app │ │ │ │ ├── toc.js │ │ │ │ ├── search.js │ │ │ │ └── lang.js │ │ │ └── lib │ │ │ │ ├── jquery.highlight.js │ │ │ │ ├── energize.js │ │ │ │ ├── jquery_ui.js │ │ │ │ └── jquery.tocify.js │ │ ├── images │ │ │ ├── logo.png │ │ │ └── navbar.png │ │ ├── fonts │ │ │ ├── icomoon.eot │ │ │ ├── icomoon.ttf │ │ │ ├── icomoon.woff │ │ │ └── icomoon.svg │ │ ├── index.md │ │ ├── stylesheets │ │ │ ├── _syntax.scss.erb │ │ │ ├── _icon-font.scss │ │ │ ├── print.css.scss │ │ │ ├── _variables.scss │ │ │ ├── _normalize.css │ │ │ └── screen.css.scss │ │ ├── includes │ │ │ └── _errors.md │ │ └── layouts │ │ │ └── layout.erb │ │ ├── .gitignore │ │ ├── Gemfile │ │ ├── Dockerfile │ │ ├── CONTRIBUTING.md │ │ ├── LICENSE │ │ ├── CHANGELOG.md │ │ ├── config.rb │ │ ├── Gemfile.lock │ │ └── README.md ├── views │ ├── api │ │ ├── v1 │ │ │ ├── users │ │ │ │ ├── update.json.jbuilder │ │ │ │ └── show.json.jbuilder │ │ │ ├── sessions │ │ │ │ └── create.json.jbuilder │ │ │ └── microposts │ │ │ │ └── index.json.jbuilder │ │ └── v2 │ │ │ └── users │ │ │ └── show.json.jbuilder │ ├── layouts │ │ └── application.html.erb │ └── docs │ │ └── index.html └── policies │ ├── user_policy.rb │ └── application_policy.rb ├── lib ├── assets │ └── .keep └── tasks │ ├── .keep │ ├── docs.rake │ └── data.rake ├── public ├── favicon.ico ├── robots.txt ├── 500.html ├── 422.html └── 404.html ├── test ├── helpers │ └── .keep ├── mailers │ └── .keep ├── models │ ├── .keep │ ├── user_test.rb │ └── micropost_test.rb ├── controllers │ ├── .keep │ ├── docs_controller_test.rb │ └── api │ │ ├── v2 │ │ └── users_controller_test.rb │ │ └── v1 │ │ ├── sessions_controller_test.rb │ │ └── microposts_controller_test.rb ├── fixtures │ ├── .keep │ ├── users.yml │ └── microposts.yml ├── integration │ └── .keep └── test_helper.rb ├── vendor └── assets │ ├── javascripts │ └── .keep │ └── stylesheets │ └── .keep ├── bin ├── bundle ├── rake ├── rails ├── spring └── setup ├── config ├── boot.rb ├── initializers │ ├── cookies_serializer.rb │ ├── session_store.rb │ ├── mime_types.rb │ ├── filter_parameter_logging.rb │ ├── backtrace_silencers.rb │ ├── assets.rb │ ├── wrap_parameters.rb │ └── inflections.rb ├── environment.rb ├── database.yml ├── locales │ └── en.yml ├── routes.rb ├── secrets.yml ├── application.rb └── environments │ ├── development.rb │ ├── test.rb │ └── production.rb ├── config.ru ├── db ├── migrate │ ├── 20150502134614_add_password_digest_to_users.rb │ ├── 20150502123451_add_authentication_token_to_users.rb │ ├── 20150503131743_create_microposts.rb │ └── 20150502072954_create_users.rb ├── seeds.rb └── schema.rb ├── docs_build.sh ├── Rakefile ├── .gitignore ├── README.rdoc ├── spec ├── controllers │ └── users_controller_spec.rb └── spec_helper.rb ├── Gemfile └── Gemfile.lock /log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/helpers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/fixtures/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/assets/javascripts/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tasks/docs.rake: -------------------------------------------------------------------------------- 1 | namespace :docs do 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/docs_helper.rb: -------------------------------------------------------------------------------- 1 | module DocsHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/docs/slate/.travis.yml: -------------------------------------------------------------------------------- 1 | rvm: 2 | - 1.9.3 3 | - 2.0.0 4 | -------------------------------------------------------------------------------- /app/models/micropost.rb: -------------------------------------------------------------------------------- 1 | class Micropost < ActiveRecord::Base 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/api/v2/users_helper.rb: -------------------------------------------------------------------------------- 1 | module Api::V2::UsersHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/api/v1/sessions_helper.rb: -------------------------------------------------------------------------------- 1 | module Api::V1::SessionsHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/api/v1/microposts_helper.rb: -------------------------------------------------------------------------------- 1 | module Api::V1::MicropostsHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/docs/slate/Rakefile: -------------------------------------------------------------------------------- 1 | require 'middleman-gh-pages' 2 | 3 | task :default => [:build] 4 | -------------------------------------------------------------------------------- /app/docs/slate/source/javascripts/all.js: -------------------------------------------------------------------------------- 1 | //= require_tree ./lib 2 | //= require_tree ./app 3 | -------------------------------------------------------------------------------- /app/views/api/v1/users/update.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.user do 2 | json.(@user, :id, :name) 3 | end 4 | -------------------------------------------------------------------------------- /app/docs/slate/source/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baya/build-an-api-rails-demo/HEAD/app/docs/slate/source/images/logo.png -------------------------------------------------------------------------------- /app/docs/slate/source/fonts/icomoon.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baya/build-an-api-rails-demo/HEAD/app/docs/slate/source/fonts/icomoon.eot -------------------------------------------------------------------------------- /app/docs/slate/source/fonts/icomoon.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baya/build-an-api-rails-demo/HEAD/app/docs/slate/source/fonts/icomoon.ttf -------------------------------------------------------------------------------- /app/docs/slate/source/images/navbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baya/build-an-api-rails-demo/HEAD/app/docs/slate/source/images/navbar.png -------------------------------------------------------------------------------- /app/docs/slate/source/fonts/icomoon.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/baya/build-an-api-rails-demo/HEAD/app/docs/slate/source/fonts/icomoon.woff -------------------------------------------------------------------------------- /app/views/api/v1/users/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.user do 2 | json.(@user, :id, :email, :name, :activated, :admin, :created_at, :updated_at) 3 | end 4 | -------------------------------------------------------------------------------- /app/views/api/v2/users/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.user do 2 | json.(@user, :id, :email, :name, :activated, :admin, :created_at, :updated_at) 3 | end 4 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /app/views/api/v1/sessions/create.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.session do 2 | json.(@user, :id, :name, :admin) 3 | json.token @user.authentication_token 4 | end 5 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /app/docs/slate/source/javascripts/all_nosearch.js: -------------------------------------------------------------------------------- 1 | //= require_tree ./lib 2 | //= require_tree ./app 3 | //= stub ./app/search.js 4 | //= stub ./lib/lunr.js 5 | -------------------------------------------------------------------------------- /test/models/user_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class UserTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Rails.application 5 | -------------------------------------------------------------------------------- /config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.action_dispatch.cookies_serializer = :json 4 | -------------------------------------------------------------------------------- /test/models/micropost_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class MicropostTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /app/controllers/api/v2/users_controller.rb: -------------------------------------------------------------------------------- 1 | class Api::V2::UsersController < Api::V1::UsersController 2 | 3 | def show 4 | @user = User.find(params[:id]) 5 | end 6 | 7 | end 8 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | Rails.application.config.session_store :cookie_store, key: '_build-an-api-rails-demo_session' 4 | -------------------------------------------------------------------------------- /test/controllers/docs_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class DocsControllerTest < ActionController::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | require_relative '../config/boot' 7 | require 'rake' 8 | Rake.application.run 9 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /db/migrate/20150502134614_add_password_digest_to_users.rb: -------------------------------------------------------------------------------- 1 | class AddPasswordDigestToUsers < ActiveRecord::Migration 2 | def change 3 | add_column :users, :password_digest, :string 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /test/controllers/api/v2/users_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class Api::V2::UsersControllerTest < ActionController::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /app/assets/stylesheets/docs.scss: -------------------------------------------------------------------------------- 1 | // Place all the styles related to the docs controller here. 2 | // They will automatically be included in application.css. 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ 4 | -------------------------------------------------------------------------------- /db/migrate/20150502123451_add_authentication_token_to_users.rb: -------------------------------------------------------------------------------- 1 | class AddAuthenticationTokenToUsers < ActiveRecord::Migration 2 | def change 3 | add_column :users, :authentication_token, :string 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /test/controllers/api/v1/sessions_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class Api::V1::SessionsControllerTest < ActionController::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /docs_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | app_dir=`pwd` 4 | cd $app_dir/app/docs/slate 5 | 6 | bundle exec middleman build --clean 7 | 8 | cd $app_dir 9 | 10 | mv $app_dir/public/docs/index.html $app_dir/app/views/docs 11 | -------------------------------------------------------------------------------- /test/controllers/api/v1/microposts_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class Api::V1::MicropostsControllerTest < ActionController::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /app/controllers/api/v1/microposts_controller.rb: -------------------------------------------------------------------------------- 1 | class Api::V1::MicropostsController < Api::V1::BaseController 2 | 3 | def index 4 | user = User.find(params[:user_id]) 5 | @microposts = paginate(user.microposts) 6 | end 7 | 8 | end 9 | -------------------------------------------------------------------------------- /app/assets/javascripts/docs.coffee: -------------------------------------------------------------------------------- 1 | # Place all the behaviors and hooks related to the matching controller here. 2 | # All this logic will automatically be available in application.js. 3 | # You can use CoffeeScript in this file: http://coffeescript.org/ 4 | -------------------------------------------------------------------------------- /config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path("../spring", __FILE__) 4 | rescue LoadError 5 | end 6 | APP_PATH = File.expand_path('../../config/application', __FILE__) 7 | require_relative '../config/boot' 8 | require 'rails/commands' 9 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | # Prevent CSRF attacks by raising an exception. 3 | # For APIs, you may want to use :null_session instead. 4 | protect_from_forgery with: :exception 5 | end 6 | -------------------------------------------------------------------------------- /app/views/api/v1/microposts/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.paginate_meta do 2 | paginate_meta_attributes(json, @microposts) 3 | end 4 | json.microposts do 5 | json.array! @microposts do |micropost| 6 | json.(micropost, :id, :title, :content) 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require File.expand_path('../config/application', __FILE__) 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /lib/tasks/data.rake: -------------------------------------------------------------------------------- 1 | namespace :data do 2 | task :create_microposts => [:environment] do 3 | user = User.find(1) 4 | 100.times do |i| 5 | Micropost.create(user_id: user.id, title: "title-#{i}", content: "content-#{i}") 6 | end 7 | end 8 | end 9 | 10 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | 3 | def paginate_meta_attributes(json, object) 4 | json.(object, 5 | :current_page, 6 | :next_page, 7 | :prev_page, 8 | :total_pages, 9 | :total_count) 10 | end 11 | 12 | end 13 | -------------------------------------------------------------------------------- /db/migrate/20150503131743_create_microposts.rb: -------------------------------------------------------------------------------- 1 | class CreateMicroposts < ActiveRecord::Migration 2 | def change 3 | create_table :microposts do |t| 4 | t.string :title 5 | t.text :content 6 | t.integer :user_id 7 | t.timestamps null: false 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /app/docs/slate/.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | coverage 6 | InstalledFiles 7 | lib/bundler/man 8 | pkg 9 | rdoc 10 | spec/reports 11 | test/tmp 12 | test/version_tmp 13 | tmp 14 | *.DS_STORE 15 | build/ 16 | .cache 17 | 18 | # YARD artifacts 19 | .yardoc 20 | _yardoc 21 | doc/ 22 | .idea/ -------------------------------------------------------------------------------- /app/docs/slate/Gemfile: -------------------------------------------------------------------------------- 1 | source 'http://rubygems.org' 2 | 3 | # Middleman 4 | gem 'middleman', '~>3.3.10' 5 | gem 'middleman-gh-pages', '~> 0.0.3' 6 | gem 'middleman-syntax', '~> 2.0.0' 7 | gem 'rouge', '~> 1.8.0' 8 | gem 'redcarpet', '~> 3.2.2' 9 | 10 | gem 'rake', '~> 10.4.2' 11 | gem 'therubyracer', '~> 0.12.1', platforms: :ruby 12 | -------------------------------------------------------------------------------- /db/migrate/20150502072954_create_users.rb: -------------------------------------------------------------------------------- 1 | class CreateUsers < ActiveRecord::Migration 2 | def change 3 | create_table :users do |t| 4 | t.string :email 5 | t.string :name 6 | t.datetime :activated 7 | t.boolean :admin, default: false 8 | t.timestamps null: false 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV['RAILS_ENV'] ||= 'test' 2 | require File.expand_path('../../config/environment', __FILE__) 3 | require 'rails/test_help' 4 | 5 | class ActiveSupport::TestCase 6 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. 7 | fixtures :all 8 | 9 | # Add more helper methods to be used by all tests here... 10 | end 11 | -------------------------------------------------------------------------------- /app/docs/slate/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:trusty 2 | 3 | RUN apt-get update 4 | RUN apt-get install -yq ruby ruby-dev build-essential git 5 | RUN gem install --no-ri --no-rdoc bundler 6 | ADD Gemfile /app/Gemfile 7 | ADD Gemfile.lock /app/Gemfile.lock 8 | RUN cd /app; bundle install 9 | ADD . /app 10 | EXPOSE 4567 11 | WORKDIR /app 12 | CMD ["bundle", "exec", "middleman", "server"] 13 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |If you are the application owner check the logs for more information.
64 |Maybe you tried to change something you didn't have access to.
63 |If you are the application owner check the logs for more information.
65 |You may have mistyped the address or the page may have moved.
63 |If you are the application owner check the logs for more information.
65 |
26 |
27 |
28 |
43 | API 文档
49 | 50 |GET http://my-site/api/v1/users/<id>
| 参数名 | 63 |是否必需 | 64 |描述 | 65 |
|---|---|---|
| id | 69 |是 | 70 |用户 id | 71 |
76 | {
77 | "user":
78 | {
79 | "id":1,
80 | "email":"test-user-00@mail.com",
81 | "name":"test-user-00",
82 | "activated":"2015-05-02T07:47:14.697Z",
83 | "admin":false,
84 | "created_at":"2015-05-02T07:47:14.708Z",
85 | "updated_at":"2015-05-02T07:47:14.708Z"
86 | }
87 | }
88 |
89 |
90 | The Kittn API uses the following error codes:
95 | 96 || Error Code | 99 |Meaning | 100 |
|---|---|
| 400 | 104 |Bad Request – Your request sucks | 105 |
| 401 | 108 |Unauthorized – Your API key is wrong | 109 |
| 403 | 112 |Forbidden – The kitten requested is hidden for administrators only | 113 |
| 404 | 116 |Not Found – The specified kitten could not be found | 117 |
| 405 | 120 |Method Not Allowed – You tried to access a kitten with an invalid method | 121 |
| 406 | 124 |Not Acceptable – You requested a format that isn’t json | 125 |
| 410 | 128 |Gone – The kitten requested has been removed from our servers | 129 |
| 418 | 132 |I’m a teapot | 133 |
| 429 | 136 |Too Many Requests – You’re requesting too many kittens! Slow down! | 137 |
| 500 | 140 |Internal Server Error – We had a problem with our server. Try again later. | 141 |
| 503 | 144 |Service Unavailable – We’re temporarially offline for maintanance. Please try again later. | 145 |
9 |
10 | *The example above was created with Slate. Check it out at [tripit.github.io/slate](http://tripit.github.io/slate).*
11 |
12 | Features
13 | ------------
14 |
15 | * **Clean, intuitive design** — with Slate, the description of your API is on the left side of your documentation, and all the code examples are on the right side. Inspired by [Stripe's](https://stripe.com/docs/api) and [Paypal's](https://developer.paypal.com/webapps/developer/docs/api/) API docs. Slate is responsive, so it looks great on tablets, phones, and even print.
16 |
17 | * **Everything on a single page** — gone are the days where your users had to search through a million pages to find what they wanted. Slate puts the entire documentation on a single page. We haven't sacrificed linkability, though. As you scroll, your browser's hash will update to the nearest header, so linking to a particular point in the documentation is still natural and easy.
18 |
19 | * **Slate is just Markdown** — when you write docs with Slate, you're just writing Markdown, which makes it simple to edit and understand. Everything is written in Markdown — even the code samples are just Markdown code blocks!
20 |
21 | * **Write code samples in multiple languages** — if your API has bindings in multiple programming languages, you easily put in tabs to switch between them. In your document, you'll distinguish different languages by specifying the language name at the top of each code block, just like with Github Flavored Markdown!
22 |
23 | * **Out-of-the-box syntax highlighting** for [almost 60 languages](http://rouge.jayferd.us/demo), no configuration required.
24 |
25 | * **Automatic, smoothly scrolling table of contents** on the far left of the page. As you scroll, it displays your current position in the document. It's fast, too. We're using Slate at TripIt to build documentation for our new API, where our table of contents has over 180 entries. We've made sure that the performance remains excellent, even for larger documents.
26 |
27 | * **Let your users update your documentation for you** — by default, your Slate-generated documentation is hosted in a public Github repository. Not only does this mean you get free hosting for your docs with Github Pages, but it also makes it's simple for other developers to make pull requests to your docs if they find typos or other problems. Of course, if you don't want to, you're welcome to not use Github and host your docs elsewhere!
28 |
29 | Getting starting with Slate is super easy! Simply fork this repository, and then follow the instructions below. Or, if you'd like to check out what Slate is capable of, take a look at the [sample docs](http://tripit.github.io/slate).
30 |
31 |
32 |
33 | Getting Started with Slate
34 | ------------------------------
35 |
36 | ### Prerequisites
37 |
38 | You're going to need:
39 |
40 | - **Linux or OS X** — Windows may work, but is unsupported.
41 | - **Ruby, version 1.9.3 or newer**
42 | - **Bundler** — If Ruby is already installed, but the `bundle` command doesn't work, just run `gem install bundler` in a terminal.
43 |
44 | ### Getting Set Up
45 |
46 | 1. Fork this repository on Github.
47 | 2. Clone *your forked repository* (not our original one) to your hard drive with `git clone https://github.com/YOURUSERNAME/slate.git`
48 | 3. `cd slate`
49 | 4. Install all dependencies: `bundle install`
50 | 5. Start the test server: `bundle exec middleman server`
51 |
52 | Or use the included Dockerfile! (must install Docker first)
53 |
54 | ```shell
55 | docker build -t slate .
56 | docker run -d -p 4567:4567 slate
57 | ```
58 |
59 | You can now see the docs at