├── lib
└── tasks
│ └── .gitkeep
├── public
├── favicon.ico
├── stylesheets
│ ├── .gitkeep
│ └── style.css
├── images
│ └── rails.png
├── javascripts
│ ├── application.js
│ └── rails.js
├── robots.txt
├── 422.html
├── 404.html
└── 500.html
├── vendor
└── plugins
│ └── .gitkeep
├── app
├── helpers
│ ├── posts_helper.rb
│ ├── api
│ │ ├── v1
│ │ │ └── posts_helper.rb
│ │ └── v2
│ │ │ └── posts_helper.rb
│ └── application_helper.rb
├── views
│ ├── posts
│ │ ├── _post.html.haml
│ │ └── index.html.haml
│ └── layouts
│ │ └── application.html.haml
├── controllers
│ ├── application_controller.rb
│ ├── api
│ │ ├── v1
│ │ │ ├── application_controller.rb
│ │ │ └── posts_controller.rb
│ │ ├── v2
│ │ │ ├── application_controller.rb
│ │ │ └── posts_controller.rb
│ │ └── application_controller.rb
│ └── posts_controller.rb
└── models
│ └── post.rb
├── .gitignore
├── README
├── spec
├── models
│ └── post_spec.rb
├── factories.rb
├── controllers
│ ├── posts_controller_spec.rb
│ └── api
│ │ ├── v2
│ │ └── posts_controller_spec.rb
│ │ └── v1
│ │ └── posts_controller_spec.rb
├── helpers
│ ├── posts_helper_spec.rb
│ └── api
│ │ ├── v1
│ │ └── posts_helper_spec.rb
│ │ └── v2
│ │ └── posts_helper_spec.rb
└── spec_helper.rb
├── config.ru
├── config
├── environment.rb
├── boot.rb
├── initializers
│ ├── mime_types.rb
│ ├── inflections.rb
│ ├── backtrace_silencers.rb
│ ├── session_store.rb
│ └── secret_token.rb
├── locales
│ ├── en.yml
│ └── rails.en.yml
├── database.yml
├── routes.rb
├── environments
│ ├── development.rb
│ ├── test.rb
│ └── production.rb
└── application.rb
├── doc
├── README_FOR_APP
└── app
│ ├── created.rid
│ ├── app
│ ├── models
│ │ └── post_rb.html
│ ├── helpers
│ │ ├── posts_helper_rb.html
│ │ ├── application_helper_rb.html
│ │ └── api
│ │ │ ├── v1
│ │ │ └── posts_helper_rb.html
│ │ │ └── v2
│ │ │ └── posts_helper_rb.html
│ └── controllers
│ │ ├── posts_controller_rb.html
│ │ ├── application_controller_rb.html
│ │ └── api
│ │ ├── application_controller_rb.html
│ │ ├── v1
│ │ ├── posts_controller_rb.html
│ │ └── application_controller_rb.html
│ │ └── v2
│ │ ├── posts_controller_rb.html
│ │ └── application_controller_rb.html
│ ├── doc
│ └── README_FOR_APP.html
│ ├── index.html
│ ├── PostsHelper.html
│ ├── API.html
│ ├── API
│ ├── V1
│ │ ├── PostsHelper.html
│ │ ├── ApplicationController.html
│ │ └── PostsController.html
│ ├── V2
│ │ ├── PostsHelper.html
│ │ ├── ApplicationController.html
│ │ └── PostsController.html
│ ├── V1.html
│ ├── V2.html
│ └── ApplicationController.html
│ ├── ApplicationController.html
│ ├── Post.html
│ ├── ApplicationHelper.html
│ ├── PostsController.html
│ └── rdoc.css
├── Gemfile
├── Rakefile
├── db
├── migrate
│ └── 20110412165030_create_posts.rb
├── seeds.rb
└── schema.rb
├── script
└── rails
└── Gemfile.lock
/lib/tasks/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/vendor/plugins/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/public/stylesheets/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/app/helpers/posts_helper.rb:
--------------------------------------------------------------------------------
1 | module PostsHelper
2 | end
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .bundle
2 | db/*.sqlite3
3 | log/*.log
4 | tmp/
5 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | Demo application for simple RESTful API practices
2 |
--------------------------------------------------------------------------------
/app/views/posts/_post.html.haml:
--------------------------------------------------------------------------------
1 | .post
2 | = post.content
3 |
--------------------------------------------------------------------------------
/app/helpers/api/v1/posts_helper.rb:
--------------------------------------------------------------------------------
1 | module Api::V1::PostsHelper
2 | end
3 |
--------------------------------------------------------------------------------
/app/helpers/api/v2/posts_helper.rb:
--------------------------------------------------------------------------------
1 | module Api::V2::PostsHelper
2 | end
3 |
--------------------------------------------------------------------------------
/spec/models/post_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe Post do
4 |
5 | end
6 |
--------------------------------------------------------------------------------
/spec/factories.rb:
--------------------------------------------------------------------------------
1 | Factory.define(:post) do |f|
2 | f.content "LALALALA"
3 | end
4 |
5 |
6 |
--------------------------------------------------------------------------------
/public/images/rails.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/naru/API-practices-demo/HEAD/public/images/rails.png
--------------------------------------------------------------------------------
/spec/controllers/posts_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe PostsController do
4 |
5 | end
6 |
--------------------------------------------------------------------------------
/app/controllers/application_controller.rb:
--------------------------------------------------------------------------------
1 | class ApplicationController < ActionController::Base
2 | protect_from_forgery
3 | end
4 |
--------------------------------------------------------------------------------
/spec/controllers/api/v2/posts_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe Api::V2::PostsController do
4 |
5 | end
6 |
--------------------------------------------------------------------------------
/app/controllers/api/v1/application_controller.rb:
--------------------------------------------------------------------------------
1 | class API::V1::ApplicationController < API::ApplicationController
2 |
3 | end
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/controllers/api/v2/application_controller.rb:
--------------------------------------------------------------------------------
1 | class API::V2::ApplicationController < API::ApplicationController
2 |
3 | respond_to :json, :xml
4 |
5 | end
6 |
7 |
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 Appi::Application
5 |
--------------------------------------------------------------------------------
/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the rails application
2 | require File.expand_path('../application', __FILE__)
3 |
4 | # Initialize the rails application
5 | Appi::Application.initialize!
6 |
--------------------------------------------------------------------------------
/public/javascripts/application.js:
--------------------------------------------------------------------------------
1 | // Place your application-specific JavaScript functions and classes here
2 | // This file is automatically included by javascript_include_tag :defaults
3 |
--------------------------------------------------------------------------------
/app/views/layouts/application.html.haml:
--------------------------------------------------------------------------------
1 | !!! 5
2 | %html
3 | %head
4 | %Title Appi
5 | = stylesheet_link_tag 'style'
6 | = csrf_meta_tag
7 | %body
8 | #content
9 | = yield
10 |
11 |
--------------------------------------------------------------------------------
/app/controllers/api/v2/posts_controller.rb:
--------------------------------------------------------------------------------
1 | class Api::V2::PostsController < API::V2::ApplicationController
2 |
3 | def index
4 | @posts = Post.all
5 |
6 | respond_with @posts
7 | end
8 |
9 | end
10 |
--------------------------------------------------------------------------------
/config/boot.rb:
--------------------------------------------------------------------------------
1 | require 'rubygems'
2 |
3 | # Set up gems listed in the Gemfile.
4 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
5 |
6 | require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
7 |
--------------------------------------------------------------------------------
/doc/README_FOR_APP:
--------------------------------------------------------------------------------
1 | Use this README file to introduce your application and point to useful places in the API for learning more.
2 | Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.
3 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # See http://www.robotstxt.org/wc/norobots.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/views/posts/index.html.haml:
--------------------------------------------------------------------------------
1 | .centerized
2 | .post_form
3 | = form_for @post do |f|
4 |
5 | - error_messages @post
6 |
7 | = f.text_field :content
8 | = f.submit 'Post'
9 |
10 | = render partial: @posts
11 |
--------------------------------------------------------------------------------
/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 | # Mime::Type.register_alias "text/html", :iphone
6 |
--------------------------------------------------------------------------------
/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | # Sample localization file for English. Add more files in this directory for other locales.
2 | # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3 |
4 | en:
5 | hello: "Hello world"
6 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'http://rubygems.org'
2 |
3 | gem 'rails', '3.0.6'
4 |
5 | gem 'unicorn'
6 | gem 'mysql2'
7 | gem 'haml'
8 |
9 | group :test, :development do
10 | gem 'rspec-rails', '>= 2.0.0.beta.22'
11 | gem 'factory_girl_rails', '1.0'
12 | end
13 |
--------------------------------------------------------------------------------
/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 | require 'rake'
6 |
7 | Appi::Application.load_tasks
8 |
--------------------------------------------------------------------------------
/db/migrate/20110412165030_create_posts.rb:
--------------------------------------------------------------------------------
1 | class CreatePosts < ActiveRecord::Migration
2 | def self.up
3 | create_table :posts do |t|
4 | t.string :content
5 |
6 | t.timestamps
7 | end
8 | end
9 |
10 | def self.down
11 | drop_table :posts
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/script/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3 |
4 | APP_PATH = File.expand_path('../../config/application', __FILE__)
5 | require File.expand_path('../../config/boot', __FILE__)
6 | require 'rails/commands'
7 |
--------------------------------------------------------------------------------
/db/seeds.rb:
--------------------------------------------------------------------------------
1 | # This file should contain all the record creation needed to seed the database with its default values.
2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3 | #
4 | # Examples:
5 | #
6 | # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
7 | # Mayor.create(:name => 'Daley', :city => cities.first)
8 |
--------------------------------------------------------------------------------
/app/controllers/api/application_controller.rb:
--------------------------------------------------------------------------------
1 | class API::ApplicationController < ApplicationController
2 |
3 | rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
4 |
5 | respond_to :json
6 |
7 | def parse_body_json
8 | @attributes = JSON.parse(request.body.read)
9 | end
10 |
11 | def record_not_found
12 | head :not_found
13 | end
14 |
15 | end
16 |
17 |
--------------------------------------------------------------------------------
/spec/helpers/posts_helper_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | # Specs in this file have access to a helper object that includes
4 | # the PostsHelper. For example:
5 | #
6 | # describe PostsHelper do
7 | # describe "string concat" do
8 | # it "concats two strings with spaces" do
9 | # helper.concat_strings("this","that").should == "this that"
10 | # end
11 | # end
12 | # end
13 | describe PostsHelper do
14 | end
15 |
--------------------------------------------------------------------------------
/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Add new inflection rules using the following format
4 | # (all these examples are active by default):
5 | # ActiveSupport::Inflector.inflections do |inflect|
6 | # inflect.plural /^(ox)$/i, '\1en'
7 | # inflect.singular /^(ox)en/i, '\1'
8 | # inflect.irregular 'person', 'people'
9 | # inflect.uncountable %w( fish sheep )
10 | # end
11 |
--------------------------------------------------------------------------------
/config/initializers/backtrace_silencers.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5 |
6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7 | # Rails.backtrace_cleaner.remove_silencers!
8 |
--------------------------------------------------------------------------------
/config/initializers/session_store.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | Appi::Application.config.session_store :cookie_store, :key => '_appi_session'
4 |
5 | # Use the database for sessions instead of the cookie-based default,
6 | # which shouldn't be used to store highly confidential information
7 | # (create the session table with "rails generate session_migration")
8 | # Appi::Application.config.session_store :active_record_store
9 |
--------------------------------------------------------------------------------
/app/models/post.rb:
--------------------------------------------------------------------------------
1 | class Post < ActiveRecord::Base
2 |
3 | validates :content, presence: true, length: { maximum: 141 }
4 |
5 | def self.new_through_api(attrs)
6 | allowed_attributes = ['content']
7 | attrs.reject! {|k,v| !allowed_attributes.include?(k)}
8 |
9 | new attrs
10 | end
11 |
12 | def as_json(options = {})
13 | {
14 | id: id,
15 | content: content,
16 | updated_at: updated_at
17 | }
18 | end
19 |
20 | end
21 |
--------------------------------------------------------------------------------
/spec/helpers/api/v1/posts_helper_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | # Specs in this file have access to a helper object that includes
4 | # the Api::V1::PostsHelper. For example:
5 | #
6 | # describe Api::V1::PostsHelper do
7 | # describe "string concat" do
8 | # it "concats two strings with spaces" do
9 | # helper.concat_strings("this","that").should == "this that"
10 | # end
11 | # end
12 | # end
13 | describe Api::V1::PostsHelper do
14 | end
15 |
--------------------------------------------------------------------------------
/app/controllers/api/v1/posts_controller.rb:
--------------------------------------------------------------------------------
1 | class Api::V1::PostsController < API::V1::ApplicationController
2 |
3 | before_filter :parse_body_json, only: :create
4 |
5 | def index
6 | @posts = Post.all
7 |
8 | respond_with @posts
9 | end
10 |
11 | def show
12 | @post = Post.find(params[:id])
13 |
14 | respond_with @post
15 | end
16 |
17 | def create
18 | @post = Post.new_through_api(@attributes['post'])
19 | @post.save
20 |
21 | respond_with @post
22 | end
23 |
24 | end
25 |
--------------------------------------------------------------------------------
/app/controllers/posts_controller.rb:
--------------------------------------------------------------------------------
1 | class PostsController < ApplicationController
2 |
3 | before_filter :load_posts, only: :index
4 |
5 | def index
6 | @post = Post.new
7 | end
8 |
9 | def create
10 | @post = Post.new params[:post]
11 |
12 | if @post.save
13 | redirect_to :back
14 | else
15 | load_posts
16 | render 'index'
17 | end
18 | end
19 |
20 | private
21 |
22 | def load_posts
23 | @posts = Post.all(order: 'created_at desc')
24 | end
25 |
26 | end
27 |
--------------------------------------------------------------------------------
/config/database.yml:
--------------------------------------------------------------------------------
1 | development:
2 | adapter: mysql2
3 | database: api_demo_dev
4 | pool: 5
5 | timeout: 5000
6 |
7 | # Warning: The database defined as "test" will be erased and
8 | # re-generated from your development database when you run "rake".
9 | # Do not set this db to the same as development or production.
10 | test:
11 | adapter: mysql2
12 | database: api_demo_test
13 | pool: 5
14 | timeout: 5000
15 |
16 | production:
17 | adapter: mysql2
18 | database: api_demo
19 | pool: 5
20 | timeout: 5000
21 |
--------------------------------------------------------------------------------
/spec/helpers/api/v2/posts_helper_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | # Specs in this file have access to a helper object that includes
4 | # the Api::V2::PostsHelper. For example:
5 | #
6 | # describe Api::V2::PostsHelper do
7 | # describe "string concat" do
8 | # it "concats two strings with spaces" do
9 | # helper.concat_strings("this","that").should == "this that"
10 | # end
11 | # end
12 | # end
13 | describe Api::V2::PostsHelper do
14 | pending "add some examples to (or delete) #{__FILE__}"
15 | end
16 |
--------------------------------------------------------------------------------
/config/initializers/secret_token.rb:
--------------------------------------------------------------------------------
1 | # Be sure to restart your server when you modify this file.
2 |
3 | # Your secret key for verifying the integrity of signed cookies.
4 | # If you change this key, all old signed cookies will become invalid!
5 | # Make sure the secret is at least 30 characters and all random,
6 | # no regular words or you'll be exposed to dictionary attacks.
7 | Appi::Application.config.secret_token = 'a6ddb2a4e960e2ef61e091cf26ceeac7957ed17615e7bdff99a667f512d6c6b3dab8f80dbfa5661aaaf1fe0f677233ca18c5301a56a61051a4fbb35ac2b31952'
8 |
--------------------------------------------------------------------------------
/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | # This file is copied to spec/ when you run 'rails generate rspec:install'
2 | ENV["RAILS_ENV"] ||= 'test'
3 | require File.expand_path("../../config/environment", __FILE__)
4 | require 'rspec/rails'
5 |
6 | # Requires supporting ruby files with custom matchers and macros, etc,
7 | # in spec/support/ and its subdirectories.
8 | Dir[Rails.root.join("spec/support/**/*.rb").to_s].each {|f| require f}
9 |
10 | RSpec.configure do |config|
11 |
12 |
13 | config.mock_with :rspec
14 |
15 | config.use_transactional_fixtures = true
16 | end
17 |
18 |
--------------------------------------------------------------------------------
/app/helpers/application_helper.rb:
--------------------------------------------------------------------------------
1 | module ApplicationHelper
2 |
3 | def error_messages(record)
4 | if record.errors.any?
5 | class_name = record.class.name.underscore
6 |
7 | concat tag(:div, { class: 'errorExplanation' }, true)
8 |
9 | concat content_tag(:h2, t('errors.template.header', model: t("activerecord.models.#{class_name}")))
10 | concat content_tag(:p, t('errors.template.body'))
11 |
12 | concat tag(:ul, nil, true)
13 |
14 | record.errors.each do |e, message|
15 | name = t("activerecord.attributes.#{class_name}.#{e}")
16 | concat content_tag(:li, "#{message}")
17 | end
18 |
19 | concat ''.html_safe
20 |
21 | concat ''.html_safe
22 | end
23 | end
24 |
25 | end
26 |
--------------------------------------------------------------------------------
/public/422.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 | scope 'api' do
18 |
19 | scope 'v2' do
20 | match 'posts.:format' => 'api/v2/posts#index', via: :get
21 | end
22 |
23 | ['v1', 'v2'].each do |version|
24 | scope version do
25 | match 'posts.:format' => 'api/v1/posts#index', via: :get
26 | match 'post.:format' => 'api/v1/posts#show', via: :get
27 | match 'post.:format' => 'api/v1/posts#create', via: :post
28 | end
29 | end
30 |
31 | end
32 |
33 | root :to => "posts#index"
34 |
35 | end
36 |
--------------------------------------------------------------------------------
/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The page you were looking for doesn't exist (404)
5 |
17 |
18 |
19 |
20 |
21 |
22 |
The page you were looking for doesn't exist.
23 |
You may have mistyped the address or the page may have moved.
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/public/500.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | We're sorry, but something went wrong (500)
5 |
17 |
18 |
19 |
20 |
21 |
22 |
We're sorry, but something went wrong.
23 |
We've been notified about this issue and we'll take a look at it shortly.
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/doc/app/created.rid:
--------------------------------------------------------------------------------
1 | Sat, 16 Apr 2011 09:39:43 +0200
2 | doc/README_FOR_APP Mon, 11 Apr 2011 22:59:12 +0200
3 | app/controllers/api/application_controller.rb Thu, 14 Apr 2011 17:02:18 +0200
4 | app/controllers/api/v1/application_controller.rb Thu, 14 Apr 2011 13:41:56 +0200
5 | app/controllers/api/v1/posts_controller.rb Thu, 14 Apr 2011 13:49:13 +0200
6 | app/controllers/api/v2/application_controller.rb Thu, 14 Apr 2011 17:58:51 +0200
7 | app/controllers/api/v2/posts_controller.rb Thu, 14 Apr 2011 17:57:21 +0200
8 | app/controllers/application_controller.rb Wed, 13 Apr 2011 22:17:23 +0200
9 | app/controllers/posts_controller.rb Thu, 14 Apr 2011 00:15:30 +0200
10 | app/helpers/api/v1/posts_helper.rb Thu, 14 Apr 2011 09:29:00 +0200
11 | app/helpers/api/v2/posts_helper.rb Thu, 14 Apr 2011 17:56:13 +0200
12 | app/helpers/application_helper.rb Thu, 14 Apr 2011 09:12:47 +0200
13 | app/helpers/posts_helper.rb Tue, 12 Apr 2011 19:08:29 +0200
14 | app/models/post.rb Thu, 14 Apr 2011 13:28:52 +0200
15 |
--------------------------------------------------------------------------------
/db/schema.rb:
--------------------------------------------------------------------------------
1 | # This file is auto-generated from the current state of the database. Instead
2 | # of editing this file, please use the migrations feature of Active Record to
3 | # incrementally modify your database, and then regenerate this schema definition.
4 | #
5 | # Note that this schema.rb definition is the authoritative source for your
6 | # database schema. If you need to create the application database on another
7 | # system, you should be using db:schema:load, not running all the migrations
8 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9 | # you'll amass, the slower it'll run and the greater likelihood for issues).
10 | #
11 | # It's strongly recommended to check this file into your version control system.
12 |
13 | ActiveRecord::Schema.define(:version => 20110412165030) do
14 |
15 | create_table "posts", :force => true do |t|
16 | t.string "content"
17 | t.datetime "created_at"
18 | t.datetime "updated_at"
19 | end
20 |
21 | end
22 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | Appi::Application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb
3 |
4 | # In the development environment your application's code is reloaded on
5 | # every request. This slows down response time but is perfect for development
6 | # since you don't have to restart the webserver when you make code changes.
7 | config.cache_classes = false
8 |
9 | # Log error messages when you accidentally call methods on nil.
10 | config.whiny_nils = true
11 |
12 | # Show full error reports and disable caching
13 | config.consider_all_requests_local = true
14 | config.action_view.debug_rjs = true
15 | config.action_controller.perform_caching = false
16 |
17 | # Don't care if the mailer can't send
18 | config.action_mailer.raise_delivery_errors = false
19 |
20 | # Print deprecation notices to the Rails logger
21 | config.active_support.deprecation = :log
22 |
23 | # Only use best-standards-support built into browsers
24 | config.action_dispatch.best_standards_support = :builtin
25 | end
26 |
27 |
--------------------------------------------------------------------------------
/public/stylesheets/style.css:
--------------------------------------------------------------------------------
1 | * {
2 | outline: none;
3 | font-family: Helvetica, Arial;
4 | }
5 |
6 | body {
7 | background: #a0b9c1;
8 | }
9 |
10 | .centerized {
11 | width: 780px;
12 | margin: 30px auto;
13 | background: #fff;
14 | border-radius: 10px;
15 | }
16 |
17 | .post_form input[type=text] {
18 | width: 600px;
19 | height: 40px;
20 | margin-right: 15px;
21 | border: 1px solid #999;
22 | border-radius: 10px;
23 | font-size: 16px;
24 | padding: 0 5px;
25 | }
26 |
27 | .post_form input[type=submit] {
28 | width: 80px;
29 | height: 40px;
30 | border: none;
31 | border-radius: 5px;
32 | font-size: 16px;
33 | background: #fff;
34 | background: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#aaa));
35 | color: #444;
36 | text-align: center;
37 | text-decoration: none;
38 | }
39 |
40 | .post_form {
41 | border-bottom: 1px solid #bbb;
42 | padding: 20px;
43 | }
44 |
45 | .post {
46 | font-size: 22px;
47 | color: #666;
48 | padding: 15px 20px;
49 | border-bottom: 1px solid #bbb;
50 | }
51 |
52 | .errorExplanation {
53 | margin: 20px 0;
54 | padding: 0 20px;
55 | background: #fdf4f8;
56 | border: 1px dashed #ea87b8;
57 | }
58 |
59 | .errorExplanation p {
60 | border: 0;
61 | }
62 |
63 | .field_with_errors {
64 | float: left;
65 | }
66 |
--------------------------------------------------------------------------------
/doc/app/app/models/post_rb.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 | File: post.rb [Rails Application Documentation]
10 |
11 |
12 |
13 |
15 |
17 |
19 |
21 |
22 |
23 |
24 |
41 |
42 |
43 |
44 |
45 |
Description
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/doc/app/app/helpers/posts_helper_rb.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 | File: posts_helper.rb [Rails Application Documentation]
10 |
11 |
12 |
13 |
15 |
17 |
19 |
21 |
22 |
23 |
24 |
41 |
42 |
43 |
44 |
45 |
Description
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/doc/app/app/controllers/posts_controller_rb.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 | File: posts_controller.rb [Rails Application Documentation]
10 |
11 |
12 |
13 |
15 |
17 |
19 |
21 |
22 |
23 |
24 |
41 |
42 |
43 |
44 |
45 |
Description
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/doc/app/app/helpers/application_helper_rb.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 | File: application_helper.rb [Rails Application Documentation]
10 |
11 |
12 |
13 |
15 |
17 |
19 |
21 |
22 |
23 |
24 |
41 |
42 |
43 |
44 |
45 |
Description
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/doc/app/app/controllers/application_controller_rb.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 | File: application_controller.rb [Rails Application Documentation]
10 |
11 |
12 |
13 |
15 |
17 |
19 |
21 |
22 |
23 |
24 |
41 |
42 |
43 |
44 |
45 |
Description
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/doc/app/app/helpers/api/v1/posts_helper_rb.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 | File: posts_helper.rb [Rails Application Documentation]
10 |
11 |
12 |
13 |
15 |
17 |
19 |
21 |
22 |
23 |
24 |
41 |
42 |
43 |
44 |
45 |
Description
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/doc/app/app/helpers/api/v2/posts_helper_rb.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 | File: posts_helper.rb [Rails Application Documentation]
10 |
11 |
12 |
13 |
15 |
17 |
19 |
21 |
22 |
23 |
24 |
41 |
42 |
43 |
44 |
45 |
Description
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/doc/app/app/controllers/api/application_controller_rb.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 | File: application_controller.rb [Rails Application Documentation]
10 |
11 |
12 |
13 |
15 |
17 |
19 |
21 |
22 |
23 |
24 |
41 |
42 |
43 |
44 |
45 |
Description
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/doc/app/app/controllers/api/v1/posts_controller_rb.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 | File: posts_controller.rb [Rails Application Documentation]
10 |
11 |
12 |
13 |
15 |
17 |
19 |
21 |
22 |
23 |
24 |
41 |
42 |
43 |
44 |
45 |
Description
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/doc/app/app/controllers/api/v2/posts_controller_rb.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 | File: posts_controller.rb [Rails Application Documentation]
10 |
11 |
12 |
13 |
15 |
17 |
19 |
21 |
22 |
23 |
24 |
41 |
42 |
43 |
44 |
45 |
Description
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/doc/app/app/controllers/api/v1/application_controller_rb.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 | File: application_controller.rb [Rails Application Documentation]
10 |
11 |
12 |
13 |
15 |
17 |
19 |
21 |
22 |
23 |
24 |
41 |
42 |
43 |
44 |
45 |
Description
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/doc/app/app/controllers/api/v2/application_controller_rb.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 | File: application_controller.rb [Rails Application Documentation]
10 |
11 |
12 |
13 |
15 |
17 |
19 |
21 |
22 |
23 |
24 |
41 |
42 |
43 |
44 |
45 |
Description
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | Appi::Application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb
3 |
4 | # The test environment is used exclusively to run your application's
5 | # test suite. You never need to work with it otherwise. Remember that
6 | # your test database is "scratch space" for the test suite and is wiped
7 | # and recreated between test runs. Don't rely on the data there!
8 | config.cache_classes = true
9 |
10 | # Log error messages when you accidentally call methods on nil.
11 | config.whiny_nils = true
12 |
13 | # Show full error reports and disable caching
14 | config.consider_all_requests_local = true
15 | config.action_controller.perform_caching = false
16 |
17 | # Raise exceptions instead of rendering exception templates
18 | config.action_dispatch.show_exceptions = false
19 |
20 | # Disable request forgery protection in test environment
21 | config.action_controller.allow_forgery_protection = false
22 |
23 | # Tell Action Mailer not to deliver emails to the real world.
24 | # The :test delivery method accumulates sent emails in the
25 | # ActionMailer::Base.deliveries array.
26 | config.action_mailer.delivery_method = :test
27 |
28 | # Use SQL instead of Active Record's schema dumper when creating the test database.
29 | # This is necessary if your schema can't be completely dumped by the schema dumper,
30 | # like if you have constraints or database-specific column types
31 | # config.active_record.schema_format = :sql
32 |
33 | # Print deprecation notices to the stderr
34 | config.active_support.deprecation = :stderr
35 | end
36 |
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | Appi::Application.configure do
2 | # Settings specified here will take precedence over those in config/application.rb
3 |
4 | # The production environment is meant for finished, "live" apps.
5 | # Code is not reloaded between requests
6 | config.cache_classes = true
7 |
8 | # Full error reports are disabled and caching is turned on
9 | config.consider_all_requests_local = false
10 | config.action_controller.perform_caching = true
11 |
12 | # Specifies the header that your server uses for sending files
13 | config.action_dispatch.x_sendfile_header = "X-Sendfile"
14 |
15 | # For nginx:
16 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
17 |
18 | # If you have no front-end server that supports something like X-Sendfile,
19 | # just comment this out and Rails will serve the files
20 |
21 | # See everything in the log (default is :info)
22 | # config.log_level = :debug
23 |
24 | # Use a different logger for distributed setups
25 | # config.logger = SyslogLogger.new
26 |
27 | # Use a different cache store in production
28 | # config.cache_store = :mem_cache_store
29 |
30 | # Disable Rails's static asset server
31 | # In production, Apache or nginx will already do this
32 | config.serve_static_assets = false
33 |
34 | # Enable serving of images, stylesheets, and javascripts from an asset server
35 | # config.action_controller.asset_host = "http://assets.example.com"
36 |
37 | # Disable delivery errors, bad email addresses will be ignored
38 | # config.action_mailer.raise_delivery_errors = false
39 |
40 | # Enable threaded mode
41 | # config.threadsafe!
42 |
43 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
44 | # the I18n.default_locale when a translation can not be found)
45 | config.i18n.fallbacks = true
46 |
47 | # Send deprecation notices to registered listeners
48 | config.active_support.deprecation = :notify
49 | end
50 |
--------------------------------------------------------------------------------
/config/application.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path('../boot', __FILE__)
2 |
3 | require 'rails/all'
4 |
5 | # If you have a Gemfile, require the gems listed there, including any gems
6 | # you've limited to :test, :development, or :production.
7 | Bundler.require(:default, Rails.env) if defined?(Bundler)
8 |
9 | module Appi
10 | class Application < Rails::Application
11 | # Settings in config/environments/* take precedence over those specified here.
12 | # Application configuration should go into files in config/initializers
13 | # -- all .rb files in that directory are automatically loaded.
14 |
15 | # Custom directories with classes and modules you want to be autoloadable.
16 | # config.autoload_paths += %W(#{config.root}/extras)
17 |
18 | # Only load the plugins named here, in the order given (default is alphabetical).
19 | # :all can be used as a placeholder for all plugins not explicitly named.
20 | # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
21 |
22 | # Activate observers that should always be running.
23 | # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
24 |
25 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
26 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
27 | # config.time_zone = 'Central Time (US & Canada)'
28 |
29 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
30 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
31 | # config.i18n.default_locale = :de
32 |
33 | # JavaScript files you want as :defaults (application.js is always included).
34 | # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
35 |
36 | # Configure the default encoding used in templates for Ruby 1.9.
37 | config.encoding = "utf-8"
38 |
39 | # Configure sensitive parameters which will be filtered from the log file.
40 | config.filter_parameters += [:password]
41 | end
42 | end
43 |
--------------------------------------------------------------------------------
/spec/controllers/api/v1/posts_controller_spec.rb:
--------------------------------------------------------------------------------
1 | require 'spec_helper'
2 |
3 | describe Api::V1::PostsController do
4 |
5 | describe 'get index' do
6 |
7 | before :each do
8 | 3.times { Factory(:post) }
9 |
10 | request.env['CONTENT_TYPE'] = 'application/json'
11 | get :index, format: 'json'
12 | end
13 |
14 | it "should respond with success" do
15 | response.response_code.should == 200
16 | end
17 |
18 | it "should respond with 3 records" do
19 | @attributes = JSON.parse(response.body)
20 | @attributes.count.should == 3
21 | end
22 | end
23 |
24 | describe 'get show' do
25 |
26 | describe 'if post exists' do
27 |
28 | before :each do
29 | @post = Factory(:post, content: 'tere')
30 |
31 | get :show, id: @post.id, format: 'json'
32 | end
33 |
34 | it "should respond with success" do
35 | response.response_code.should == 200
36 | end
37 |
38 | it "should respond with the post" do
39 | @attributes = JSON.parse(response.body)
40 | @returned_post = Post.find(@attributes['id'])
41 |
42 | @returned_post.should == @post
43 | end
44 | end
45 |
46 | describe "if post does not exist" do
47 |
48 | before :each do
49 | get :show, id: 321, format: 'json'
50 | end
51 |
52 | it "should respond with not_found" do
53 | response.response_code.should == 404
54 | end
55 | end
56 |
57 | describe "post create" do
58 |
59 | before :each do
60 | request.env['CONTENT_TYPE'] = 'application/json'
61 |
62 | attributes = {
63 | post: {
64 | content: 'Posted from API'
65 | }
66 | }
67 |
68 | request.env['RAW_POST_DATA'] = attributes.to_json
69 |
70 | post :create, format: 'json'
71 |
72 | @attributes = JSON.parse(response.body)
73 | end
74 |
75 | it "should respond with created" do
76 | response.response_code.should == 201
77 | end
78 |
79 | it "should respond with created post" do
80 | @attributes['content'].should == 'Posted from API'
81 | end
82 |
83 | it "should have only allowed attributes in response object" do
84 | @attributes.keys.should =~ ['id', 'content', 'updated_at']
85 | end
86 | end
87 |
88 | end
89 |
90 | end
91 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: http://rubygems.org/
3 | specs:
4 | abstract (1.0.0)
5 | actionmailer (3.0.6)
6 | actionpack (= 3.0.6)
7 | mail (~> 2.2.15)
8 | actionpack (3.0.6)
9 | activemodel (= 3.0.6)
10 | activesupport (= 3.0.6)
11 | builder (~> 2.1.2)
12 | erubis (~> 2.6.6)
13 | i18n (~> 0.5.0)
14 | rack (~> 1.2.1)
15 | rack-mount (~> 0.6.14)
16 | rack-test (~> 0.5.7)
17 | tzinfo (~> 0.3.23)
18 | activemodel (3.0.6)
19 | activesupport (= 3.0.6)
20 | builder (~> 2.1.2)
21 | i18n (~> 0.5.0)
22 | activerecord (3.0.6)
23 | activemodel (= 3.0.6)
24 | activesupport (= 3.0.6)
25 | arel (~> 2.0.2)
26 | tzinfo (~> 0.3.23)
27 | activeresource (3.0.6)
28 | activemodel (= 3.0.6)
29 | activesupport (= 3.0.6)
30 | activesupport (3.0.6)
31 | arel (2.0.9)
32 | builder (2.1.2)
33 | diff-lcs (1.1.2)
34 | erubis (2.6.6)
35 | abstract (>= 1.0.0)
36 | factory_girl (1.3.3)
37 | factory_girl_rails (1.0)
38 | factory_girl (~> 1.3)
39 | rails (>= 3.0.0.beta4)
40 | haml (3.0.25)
41 | i18n (0.5.0)
42 | kgio (2.3.3)
43 | mail (2.2.15)
44 | activesupport (>= 2.3.6)
45 | i18n (>= 0.4.0)
46 | mime-types (~> 1.16)
47 | treetop (~> 1.4.8)
48 | mime-types (1.16)
49 | mysql2 (0.2.7)
50 | polyglot (0.3.1)
51 | rack (1.2.2)
52 | rack-mount (0.6.14)
53 | rack (>= 1.0.0)
54 | rack-test (0.5.7)
55 | rack (>= 1.0)
56 | rails (3.0.6)
57 | actionmailer (= 3.0.6)
58 | actionpack (= 3.0.6)
59 | activerecord (= 3.0.6)
60 | activeresource (= 3.0.6)
61 | activesupport (= 3.0.6)
62 | bundler (~> 1.0)
63 | railties (= 3.0.6)
64 | railties (3.0.6)
65 | actionpack (= 3.0.6)
66 | activesupport (= 3.0.6)
67 | rake (>= 0.8.7)
68 | thor (~> 0.14.4)
69 | rake (0.8.7)
70 | rspec (2.5.0)
71 | rspec-core (~> 2.5.0)
72 | rspec-expectations (~> 2.5.0)
73 | rspec-mocks (~> 2.5.0)
74 | rspec-core (2.5.1)
75 | rspec-expectations (2.5.0)
76 | diff-lcs (~> 1.1.2)
77 | rspec-mocks (2.5.0)
78 | rspec-rails (2.5.0)
79 | actionpack (~> 3.0)
80 | activesupport (~> 3.0)
81 | railties (~> 3.0)
82 | rspec (~> 2.5.0)
83 | thor (0.14.6)
84 | treetop (1.4.9)
85 | polyglot (>= 0.3.1)
86 | tzinfo (0.3.26)
87 | unicorn (3.5.0)
88 | kgio (~> 2.3)
89 | rack
90 |
91 | PLATFORMS
92 | ruby
93 |
94 | DEPENDENCIES
95 | factory_girl_rails (= 1.0)
96 | haml
97 | mysql2
98 | rails (= 3.0.6)
99 | rspec-rails (>= 2.0.0.beta.22)
100 | unicorn
101 |
--------------------------------------------------------------------------------
/config/locales/rails.en.yml:
--------------------------------------------------------------------------------
1 | en:
2 | errors:
3 | template:
4 | header: "%{model} couldn't be saved"
5 | body: "Following problems occured:"
6 |
7 | activemodel:
8 | errors:
9 | template:
10 | header:
11 | one: "One error occure when saving %{model}"
12 | other: "%{count} errors occured when saving %{model}"
13 | # The variable :count is also available
14 | body: "There we're problems with the following fields:"
15 |
16 | activerecord:
17 | errors:
18 | # model.errors.full_messages normat.
19 | format: "%{attribute} %{message}"
20 |
21 | template:
22 | header:
23 | one: "One error occure when saving %{model}"
24 | other: "%{count} errors occured when saving %{model}"
25 | # The variable :count is also available
26 | body: "There we're problems with the following fields:"
27 |
28 | # The values :model, :attribute and :value are always available for interpolation
29 | # The value :count is available when applicable. Can be used for pluralization.
30 | messages:
31 | blank: "%{attribute} can't be blank"
32 | invalid: "%{attribute} is invalid"
33 | too_short: "%{attribute} is too short"
34 | too_long: "%{attribute} is too long"
35 | wrong_length: "%{attribute} is the wrong length"
36 | taken: "%{attribute}, {value}, is already taken"
37 | # Append your own errors here or at the model/attributes scope.
38 |
39 | # You can define own errors for models or model attributes.
40 | # The values :model, :attribute and :value are always available for interpolation.
41 | #
42 | # For example,
43 | # models:
44 | # user:
45 | # blank: "This is a custom blank message for %{model}: %{attribute}"
46 | # attributes:
47 | # login:
48 | # blank: "This is a custom blank message for User login"
49 | # Will define custom blank validation message for User model and
50 | # custom blank validation message for login attribute of User model.
51 | # models:
52 |
53 | # Translate model names. Used in Model.human_name().
54 | models:
55 | post: "Post"
56 | #
57 | # Translate model attribute names. Used in Model.human_attribute_name(attribute).
58 | attributes:
59 | post:
60 | content: "Content"
61 |
62 | date:
63 | formats:
64 | # Use the strftime parameters for formats.
65 | # When no format has been given, it uses default.
66 | # You can provide other formats here if you like!
67 | default: "%Y-%m-%d"
68 | short: "%e %b"
69 | long: "%e %B %Y"
70 |
71 | day_names: [söndag, måndag, tisdag, onsdag, torsdag, fredag, lördag]
72 | abbr_day_names: [sön, mån, tis, ons, tor, fre, lör]
73 |
74 | # Don't forget the nil at the beginning; there's no such thing as a 0th month
75 | month_names: [~, januari, februari, mars, april, maj, juni, juli, augusti, september, oktober, november, december]
76 | abbr_month_names: [~, jan, feb, mar, apr, maj, jun, jul, aug, sep, okt, nov, dec]
77 | # Used in date_select and datime_select.
78 | order: [ :day, :month, :year ]
79 |
80 | time:
81 | formats:
82 | default: "%a, %e %b %Y %H:%M:%S %z"
83 | short: "%e %b %H:%M"
84 | long: "%e %B %Y %H:%M"
85 | am: ""
86 | pm: ""
87 |
88 | # Used in array.to_sentence.
89 | support:
90 | array:
91 | words_connector: ", "
92 | two_words_connector: " och "
93 | last_word_connector: " och "
94 | select:
95 | # default value for :prompt => true in FormOptionsHelper
96 | prompt: "Välj"
97 |
98 | helpers:
99 | submit:
100 | create: "Skapa %{model}"
101 | update: "Uppdatera %{model}"
102 |
103 |
--------------------------------------------------------------------------------
/doc/app/doc/README_FOR_APP.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 | File: README_FOR_APP [Rails Application Documentation]
10 |
11 |
12 |
13 |
15 |
17 |
19 |
21 |
22 |
23 |
24 |
106 |
107 |
108 |
109 | Use this README file to introduce your application and point to useful
110 | places in the API for learning more. Run
111 | “rake doc:app” to generate API
112 | documentation for your models, controllers, helpers, and libraries.
113 |
114 |
115 |
116 |
117 |
122 |
123 |
124 |
125 |
--------------------------------------------------------------------------------
/doc/app/index.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 | Rails Application Documentation
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | Rails Application Documentation
23 |
24 |
25 | This is the API documentation for 'Rails Application Documentation'.
26 |
27 |
28 |
29 |
30 | Files
31 |
36 |
37 |
38 | Classes/Modules
39 |
78 |
79 | Methods
80 |
107 |
108 |
113 |
114 |
115 |
--------------------------------------------------------------------------------
/doc/app/PostsHelper.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 | Module: PostsHelper
9 |
10 |
11 |
12 |
14 |
16 |
18 |
20 |
21 |
22 |
23 |
24 |
137 |
138 |
139 |
PostsHelper
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
Disabled; run with --debug to generate this.
160 |
161 |
162 |
163 |
168 |
169 |
170 |
171 |
172 |
--------------------------------------------------------------------------------
/doc/app/API.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 | Module: Api
9 |
10 |
11 |
12 |
14 |
16 |
18 |
20 |
21 |
22 |
23 |
24 |
145 |
146 |
147 |
Api
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
Disabled; run with --debug to generate this.
168 |
169 |
170 |
171 |
176 |
177 |
178 |
179 |
180 |
--------------------------------------------------------------------------------
/doc/app/API/V1/PostsHelper.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 | Module: Api::V1::PostsHelper
9 |
10 |
11 |
12 |
14 |
16 |
18 |
20 |
21 |
22 |
23 |
24 |
137 |
138 |
139 |
Api::V1::PostsHelper
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
Disabled; run with --debug to generate this.
160 |
161 |
162 |
163 |
168 |
169 |
170 |
171 |
172 |
--------------------------------------------------------------------------------
/doc/app/API/V2/PostsHelper.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 | Module: Api::V2::PostsHelper
9 |
10 |
11 |
12 |
14 |
16 |
18 |
20 |
21 |
22 |
23 |
24 |
137 |
138 |
139 |
Api::V2::PostsHelper
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
Disabled; run with --debug to generate this.
160 |
161 |
162 |
163 |
168 |
169 |
170 |
171 |
172 |
--------------------------------------------------------------------------------
/doc/app/API/V1.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 | Module: Api::V1
9 |
10 |
11 |
12 |
14 |
16 |
18 |
20 |
21 |
22 |
23 |
24 |
145 |
146 |
147 |
Api::V1
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
Disabled; run with --debug to generate this.
168 |
169 |
170 |
171 |
176 |
177 |
178 |
179 |
180 |
--------------------------------------------------------------------------------
/doc/app/API/V2.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 | Module: Api::V2
9 |
10 |
11 |
12 |
14 |
16 |
18 |
20 |
21 |
22 |
23 |
24 |
145 |
146 |
147 |
Api::V2
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
Disabled; run with --debug to generate this.
168 |
169 |
170 |
171 |
176 |
177 |
178 |
179 |
180 |
--------------------------------------------------------------------------------
/doc/app/ApplicationController.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 | Class: ApplicationController
9 |
10 |
11 |
12 |
14 |
16 |
18 |
20 |
21 |
22 |
23 |
24 |
144 |
145 |
146 |
ApplicationController
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
Disabled; run with --debug to generate this.
167 |
168 |
169 |
170 |
175 |
176 |
177 |
178 |
179 |
--------------------------------------------------------------------------------
/doc/app/API/V1/ApplicationController.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 | Class: API::V1::ApplicationController
9 |
10 |
11 |
12 |
14 |
16 |
18 |
20 |
21 |
22 |
23 |
24 |
144 |
145 |
146 |
API::V1::ApplicationController
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
Disabled; run with --debug to generate this.
167 |
168 |
169 |
170 |
175 |
176 |
177 |
178 |
179 |
--------------------------------------------------------------------------------
/doc/app/API/V2/ApplicationController.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 | Class: API::V2::ApplicationController
9 |
10 |
11 |
12 |
14 |
16 |
18 |
20 |
21 |
22 |
23 |
24 |
144 |
145 |
146 |
API::V2::ApplicationController
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
Disabled; run with --debug to generate this.
167 |
168 |
169 |
170 |
175 |
176 |
177 |
178 |
179 |
--------------------------------------------------------------------------------
/public/javascripts/rails.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | // Technique from Juriy Zaytsev
3 | // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
4 | function isEventSupported(eventName) {
5 | var el = document.createElement('div');
6 | eventName = 'on' + eventName;
7 | var isSupported = (eventName in el);
8 | if (!isSupported) {
9 | el.setAttribute(eventName, 'return;');
10 | isSupported = typeof el[eventName] == 'function';
11 | }
12 | el = null;
13 | return isSupported;
14 | }
15 |
16 | function isForm(element) {
17 | return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM'
18 | }
19 |
20 | function isInput(element) {
21 | if (Object.isElement(element)) {
22 | var name = element.nodeName.toUpperCase()
23 | return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA'
24 | }
25 | else return false
26 | }
27 |
28 | var submitBubbles = isEventSupported('submit'),
29 | changeBubbles = isEventSupported('change')
30 |
31 | if (!submitBubbles || !changeBubbles) {
32 | // augment the Event.Handler class to observe custom events when needed
33 | Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap(
34 | function(init, element, eventName, selector, callback) {
35 | init(element, eventName, selector, callback)
36 | // is the handler being attached to an element that doesn't support this event?
37 | if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) ||
38 | (!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) {
39 | // "submit" => "emulated:submit"
40 | this.eventName = 'emulated:' + this.eventName
41 | }
42 | }
43 | )
44 | }
45 |
46 | if (!submitBubbles) {
47 | // discover forms on the page by observing focus events which always bubble
48 | document.on('focusin', 'form', function(focusEvent, form) {
49 | // special handler for the real "submit" event (one-time operation)
50 | if (!form.retrieve('emulated:submit')) {
51 | form.on('submit', function(submitEvent) {
52 | var emulated = form.fire('emulated:submit', submitEvent, true)
53 | // if custom event received preventDefault, cancel the real one too
54 | if (emulated.returnValue === false) submitEvent.preventDefault()
55 | })
56 | form.store('emulated:submit', true)
57 | }
58 | })
59 | }
60 |
61 | if (!changeBubbles) {
62 | // discover form inputs on the page
63 | document.on('focusin', 'input, select, texarea', function(focusEvent, input) {
64 | // special handler for real "change" events
65 | if (!input.retrieve('emulated:change')) {
66 | input.on('change', function(changeEvent) {
67 | input.fire('emulated:change', changeEvent, true)
68 | })
69 | input.store('emulated:change', true)
70 | }
71 | })
72 | }
73 |
74 | function handleRemote(element) {
75 | var method, url, params;
76 |
77 | var event = element.fire("ajax:before");
78 | if (event.stopped) return false;
79 |
80 | if (element.tagName.toLowerCase() === 'form') {
81 | method = element.readAttribute('method') || 'post';
82 | url = element.readAttribute('action');
83 | params = element.serialize();
84 | } else {
85 | method = element.readAttribute('data-method') || 'get';
86 | url = element.readAttribute('href');
87 | params = {};
88 | }
89 |
90 | new Ajax.Request(url, {
91 | method: method,
92 | parameters: params,
93 | evalScripts: true,
94 |
95 | onComplete: function(request) { element.fire("ajax:complete", request); },
96 | onSuccess: function(request) { element.fire("ajax:success", request); },
97 | onFailure: function(request) { element.fire("ajax:failure", request); }
98 | });
99 |
100 | element.fire("ajax:after");
101 | }
102 |
103 | function handleMethod(element) {
104 | var method = element.readAttribute('data-method'),
105 | url = element.readAttribute('href'),
106 | csrf_param = $$('meta[name=csrf-param]')[0],
107 | csrf_token = $$('meta[name=csrf-token]')[0];
108 |
109 | var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
110 | element.parentNode.insert(form);
111 |
112 | if (method !== 'post') {
113 | var field = new Element('input', { type: 'hidden', name: '_method', value: method });
114 | form.insert(field);
115 | }
116 |
117 | if (csrf_param) {
118 | var param = csrf_param.readAttribute('content'),
119 | token = csrf_token.readAttribute('content'),
120 | field = new Element('input', { type: 'hidden', name: param, value: token });
121 | form.insert(field);
122 | }
123 |
124 | form.submit();
125 | }
126 |
127 |
128 | document.on("click", "*[data-confirm]", function(event, element) {
129 | var message = element.readAttribute('data-confirm');
130 | if (!confirm(message)) event.stop();
131 | });
132 |
133 | document.on("click", "a[data-remote]", function(event, element) {
134 | if (event.stopped) return;
135 | handleRemote(element);
136 | event.stop();
137 | });
138 |
139 | document.on("click", "a[data-method]", function(event, element) {
140 | if (event.stopped) return;
141 | handleMethod(element);
142 | event.stop();
143 | });
144 |
145 | document.on("submit", function(event) {
146 | var element = event.findElement(),
147 | message = element.readAttribute('data-confirm');
148 | if (message && !confirm(message)) {
149 | event.stop();
150 | return false;
151 | }
152 |
153 | var inputs = element.select("input[type=submit][data-disable-with]");
154 | inputs.each(function(input) {
155 | input.disabled = true;
156 | input.writeAttribute('data-original-value', input.value);
157 | input.value = input.readAttribute('data-disable-with');
158 | });
159 |
160 | var element = event.findElement("form[data-remote]");
161 | if (element) {
162 | handleRemote(element);
163 | event.stop();
164 | }
165 | });
166 |
167 | document.on("ajax:after", "form", function(event, element) {
168 | var inputs = element.select("input[type=submit][disabled=true][data-disable-with]");
169 | inputs.each(function(input) {
170 | input.value = input.readAttribute('data-original-value');
171 | input.removeAttribute('data-original-value');
172 | input.disabled = false;
173 | });
174 | });
175 |
176 | Ajax.Responders.register({
177 | onCreate: function(request) {
178 | var csrf_meta_tag = $$('meta[name=csrf-token]')[0];
179 |
180 | if (csrf_meta_tag) {
181 | var header = 'X-CSRF-Token',
182 | token = csrf_meta_tag.readAttribute('content');
183 |
184 | if (!request.options.requestHeaders) {
185 | request.options.requestHeaders = {};
186 | }
187 | request.options.requestHeaders[header] = token;
188 | }
189 | }
190 | });
191 | })();
192 |
--------------------------------------------------------------------------------
/doc/app/API/V2/PostsController.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 | Class: Api::V2::PostsController
9 |
10 |
11 |
12 |
14 |
16 |
18 |
20 |
21 |
22 |
23 |
24 |
153 |
154 |
155 |
Api::V2::PostsController
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 | index ()
180 | click to toggle source
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
192 |
193 |
194 | 3: def index
195 | 4: @posts = Post .all
196 | 5:
197 | 6: respond_with @posts
198 | 7: end
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
Disabled; run with --debug to generate this.
218 |
219 |
220 |
221 |
226 |
227 |
228 |
229 |
230 |
--------------------------------------------------------------------------------
/doc/app/API/ApplicationController.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 | Class: API::ApplicationController
9 |
10 |
11 |
12 |
14 |
16 |
18 |
20 |
21 |
22 |
23 |
24 |
155 |
156 |
157 |
API::ApplicationController
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 | parse_body_json ()
182 | click to toggle source
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
194 |
195 |
196 | 7: def parse_body_json
197 | 8: @attributes = JSON .parse (request .body .read )
198 | 9: end
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 | record_not_found ()
216 | click to toggle source
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
228 |
229 |
230 | 11: def record_not_found
231 | 12: head :not_found
232 | 13: end
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
Disabled; run with --debug to generate this.
252 |
253 |
254 |
255 |
260 |
261 |
262 |
263 |
264 |
--------------------------------------------------------------------------------
/doc/app/Post.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 | Class: Post
9 |
10 |
11 |
12 |
14 |
16 |
18 |
20 |
21 |
22 |
23 |
24 |
155 |
156 |
157 |
Post
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 | new_through_api (attrs)
182 | click to toggle source
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
194 |
195 |
196 | 5: def self .new_through_api (attrs )
197 | 6: allowed_attributes = ['content' ]
198 | 7: attrs .reject! {| k ,v | ! allowed_attributes .include? (k )}
199 | 8:
200 | 9: new attrs
201 | 10: end
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 | as_json (options = {})
225 | click to toggle source
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
237 |
238 |
239 | 12: def as_json (options = {})
240 | 13: {
241 | 14: id : id ,
242 | 15: content : content ,
243 | 16: updated_at : updated_at
244 | 17: }
245 | 18: end
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
Disabled; run with --debug to generate this.
265 |
266 |
267 |
268 |
273 |
274 |
275 |
276 |
277 |
--------------------------------------------------------------------------------
/doc/app/ApplicationHelper.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 | Module: ApplicationHelper
9 |
10 |
11 |
12 |
14 |
16 |
18 |
20 |
21 |
22 |
23 |
24 |
146 |
147 |
148 |
ApplicationHelper
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 | error_messages (record)
173 | click to toggle source
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
185 |
186 |
187 | 3: def error_messages (record )
188 | 4: if record .errors .any?
189 | 5: class_name = record .class .name .underscore
190 | 6:
191 | 7: concat tag (:div , { class : 'errorExplanation' }, true )
192 | 8:
193 | 9: concat content_tag (:h2 , t ('errors.template.header' , model : t ("activerecord.models.#{class_name}" )))
194 | 10: concat content_tag (:p , t ('errors.template.body' ))
195 | 11:
196 | 12: concat tag (:ul , nil , true )
197 | 13:
198 | 14: record .errors .each do | e , message |
199 | 15: name = t ("activerecord.attributes.#{class_name}.#{e}" )
200 | 16: concat content_tag (:li , "#{message}" )
201 | 17: end
202 | 18:
203 | 19: concat '</ul>' .html_safe
204 | 20:
205 | 21: concat '</div>' .html_safe
206 | 22: end
207 | 23: end
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
Disabled; run with --debug to generate this.
227 |
228 |
229 |
230 |
235 |
236 |
237 |
238 |
239 |
--------------------------------------------------------------------------------
/doc/app/API/V1/PostsController.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 | Class: Api::V1::PostsController
9 |
10 |
11 |
12 |
14 |
16 |
18 |
20 |
21 |
22 |
23 |
24 |
157 |
158 |
159 |
Api::V1::PostsController
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 | create ()
184 | click to toggle source
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
196 |
197 |
198 | 17: def create
199 | 18: @post = Post .new_through_api (@attributes ['post' ])
200 | 19: @post .save
201 | 20:
202 | 21: respond_with @post
203 | 22: end
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 | index ()
221 | click to toggle source
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
233 |
234 |
235 | 5: def index
236 | 6: @posts = Post .all
237 | 7:
238 | 8: respond_with @posts
239 | 9: end
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 | show ()
257 | click to toggle source
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
269 |
270 |
271 | 11: def show
272 | 12: @post = Post .find (params [:id ])
273 | 13:
274 | 14: respond_with @post
275 | 15: end
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
Disabled; run with --debug to generate this.
295 |
296 |
297 |
298 |
303 |
304 |
305 |
306 |
307 |
--------------------------------------------------------------------------------
/doc/app/PostsController.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 | Class: PostsController
9 |
10 |
11 |
12 |
14 |
16 |
18 |
20 |
21 |
22 |
23 |
24 |
157 |
158 |
159 |
PostsController
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 | create ()
184 | click to toggle source
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
196 |
197 |
198 | 9: def create
199 | 10: @post = Post .new params [:post ]
200 | 11:
201 | 12: if @post .save
202 | 13: redirect_to :back
203 | 14: else
204 | 15: load_posts
205 | 16: render 'index'
206 | 17: end
207 | 18: end
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 | index ()
225 | click to toggle source
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
237 |
238 |
239 | 5: def index
240 | 6: @post = Post .new
241 | 7: end
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 | load_posts ()
265 | click to toggle source
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
277 |
278 |
279 | 22: def load_posts
280 | 23: @posts = Post .all (order : 'created_at desc' )
281 | 24: end
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
Disabled; run with --debug to generate this.
301 |
302 |
303 |
304 |
309 |
310 |
311 |
312 |
313 |
--------------------------------------------------------------------------------
/doc/app/rdoc.css:
--------------------------------------------------------------------------------
1 | /*
2 | * "Darkfish" Rdoc CSS
3 | * $Id: rdoc.css 54 2009-01-27 01:09:48Z deveiant $
4 | *
5 | * Author: Michael Granger
6 | *
7 | */
8 |
9 | /* Base Green is: #6C8C22 */
10 |
11 | *{ padding: 0; margin: 0; }
12 |
13 | body {
14 | background: #efefef;
15 | font: 14px "Helvetica Neue", Helvetica, Tahoma, sans-serif;
16 | }
17 | body.class, body.module, body.file {
18 | margin-left: 40px;
19 | }
20 | body.file-popup {
21 | font-size: 90%;
22 | margin-left: 0;
23 | }
24 |
25 | h1 {
26 | font-size: 300%;
27 | text-shadow: rgba(135,145,135,0.65) 2px 2px 3px;
28 | color: #6C8C22;
29 | }
30 | h2,h3,h4 { margin-top: 1.5em; }
31 |
32 | :link,
33 | :visited {
34 | color: #6C8C22;
35 | text-decoration: none;
36 | }
37 | :link:hover,
38 | :visited:hover {
39 | border-bottom: 1px dotted #6C8C22;
40 | }
41 |
42 | pre {
43 | background: #ddd;
44 | padding: 0.5em 0;
45 | }
46 |
47 |
48 | /* @group Generic Classes */
49 |
50 | .initially-hidden {
51 | display: none;
52 | }
53 |
54 | .quicksearch-field {
55 | width: 98%;
56 | background: #ddd;
57 | border: 1px solid #aaa;
58 | height: 1.5em;
59 | -webkit-border-radius: 4px;
60 | }
61 | .quicksearch-field:focus {
62 | background: #f1edba;
63 | }
64 |
65 | .missing-docs {
66 | font-size: 120%;
67 | background: white url(images/wrench_orange.png) no-repeat 4px center;
68 | color: #ccc;
69 | line-height: 2em;
70 | border: 1px solid #d00;
71 | opacity: 1;
72 | padding-left: 20px;
73 | text-indent: 24px;
74 | letter-spacing: 3px;
75 | font-weight: bold;
76 | -webkit-border-radius: 5px;
77 | -moz-border-radius: 5px;
78 | }
79 |
80 | .target-section {
81 | border: 2px solid #dcce90;
82 | border-left-width: 8px;
83 | padding: 0 1em;
84 | background: #fff3c2;
85 | }
86 |
87 | /* @end */
88 |
89 |
90 | /* @group Index Page, Standalone file pages */
91 | body.indexpage {
92 | margin: 1em 3em;
93 | }
94 | body.indexpage p,
95 | body.indexpage div,
96 | body.file p {
97 | margin: 1em 0;
98 | }
99 |
100 | .indexpage ul,
101 | .file #documentation ul {
102 | line-height: 160%;
103 | list-style: none;
104 | }
105 | .indexpage ul :link,
106 | .indexpage ul :visited {
107 | font-size: 16px;
108 | }
109 |
110 | .indexpage li,
111 | .file #documentation li {
112 | padding-left: 20px;
113 | background: url(images/bullet_black.png) no-repeat left 4px;
114 | }
115 | .indexpage li.module {
116 | background: url(images/package.png) no-repeat left 4px;
117 | }
118 | .indexpage li.class {
119 | background: url(images/ruby.png) no-repeat left 4px;
120 | }
121 | .indexpage li.file {
122 | background: url(images/page_white_text.png) no-repeat left 4px;
123 | }
124 | .file li p,
125 | .indexpage li p {
126 | margin: 0 0;
127 | }
128 |
129 | /* @end */
130 |
131 | /* @group Top-Level Structure */
132 |
133 | .class #metadata,
134 | .file #metadata,
135 | .module #metadata {
136 | float: left;
137 | width: 260px;
138 | }
139 |
140 | .class #documentation,
141 | .file #documentation,
142 | .module #documentation {
143 | margin: 2em 1em 5em 300px;
144 | min-width: 340px;
145 | }
146 |
147 | .file #metadata {
148 | margin: 0.8em;
149 | }
150 |
151 | #validator-badges {
152 | clear: both;
153 | margin: 1em 1em 2em;
154 | }
155 |
156 | /* @end */
157 |
158 | /* @group Metadata Section */
159 | #metadata .section {
160 | background-color: #dedede;
161 | -moz-border-radius: 5px;
162 | -webkit-border-radius: 5px;
163 | border: 1px solid #aaa;
164 | margin: 0 8px 16px;
165 | font-size: 90%;
166 | overflow: hidden;
167 | }
168 | #metadata h3.section-header {
169 | margin: 0;
170 | padding: 2px 8px;
171 | background: #ccc;
172 | color: #666;
173 | -moz-border-radius-topleft: 4px;
174 | -moz-border-radius-topright: 4px;
175 | -webkit-border-top-left-radius: 4px;
176 | -webkit-border-top-right-radius: 4px;
177 | border-bottom: 1px solid #aaa;
178 | }
179 | #metadata #home-section h3.section-header {
180 | border-bottom: 0;
181 | }
182 |
183 | #metadata ul,
184 | #metadata dl,
185 | #metadata p {
186 | padding: 8px;
187 | list-style: none;
188 | }
189 |
190 | #file-metadata ul {
191 | padding-left: 28px;
192 | list-style-image: url(images/page_green.png);
193 | }
194 |
195 | dl.svninfo {
196 | color: #666;
197 | margin: 0;
198 | }
199 | dl.svninfo dt {
200 | font-weight: bold;
201 | }
202 |
203 | ul.link-list li {
204 | white-space: nowrap;
205 | }
206 | ul.link-list .type {
207 | font-size: 8px;
208 | text-transform: uppercase;
209 | color: white;
210 | background: #969696;
211 | padding: 2px 4px;
212 | -webkit-border-radius: 5px;
213 | }
214 |
215 | /* @end */
216 |
217 |
218 | /* @group Project Metadata Section */
219 | #project-metadata {
220 | margin-top: 3em;
221 | }
222 |
223 | .file #project-metadata {
224 | margin-top: 0em;
225 | }
226 |
227 | #project-metadata .section {
228 | border: 1px solid #aaa;
229 | }
230 | #project-metadata h3.section-header {
231 | border-bottom: 1px solid #aaa;
232 | position: relative;
233 | }
234 | #project-metadata h3.section-header .search-toggle {
235 | position: absolute;
236 | right: 5px;
237 | }
238 |
239 |
240 | #project-metadata form {
241 | color: #777;
242 | background: #ccc;
243 | padding: 8px 8px 16px;
244 | border-bottom: 1px solid #bbb;
245 | }
246 | #project-metadata fieldset {
247 | border: 0;
248 | }
249 |
250 | #no-class-search-results {
251 | margin: 0 auto 1em;
252 | text-align: center;
253 | font-size: 14px;
254 | font-weight: bold;
255 | color: #aaa;
256 | }
257 |
258 | /* @end */
259 |
260 |
261 | /* @group Documentation Section */
262 | #description {
263 | font-size: 100%;
264 | color: #333;
265 | }
266 |
267 | #description p {
268 | margin: 1em 0.4em;
269 | }
270 |
271 | #description li p {
272 | margin: 0;
273 | }
274 |
275 | #description ul {
276 | margin-left: 1.5em;
277 | }
278 | #description ul li {
279 | line-height: 1.4em;
280 | }
281 |
282 | #description dl,
283 | #documentation dl {
284 | margin: 8px 1.5em;
285 | border: 1px solid #ccc;
286 | }
287 | #description dl {
288 | font-size: 14px;
289 | }
290 |
291 | #description dt,
292 | #documentation dt {
293 | padding: 2px 4px;
294 | font-weight: bold;
295 | background: #ddd;
296 | }
297 | #description dd,
298 | #documentation dd {
299 | padding: 2px 12px;
300 | }
301 | #description dd + dt,
302 | #documentation dd + dt {
303 | margin-top: 0.7em;
304 | }
305 |
306 | #documentation .section {
307 | font-size: 90%;
308 | }
309 | #documentation h3.section-header {
310 | margin-top: 2em;
311 | padding: 0.75em 0.5em;
312 | background-color: #dedede;
313 | color: #333;
314 | font-size: 150%;
315 | border: 1px solid #bbb;
316 | -moz-border-radius: 3px;
317 | -webkit-border-radius: 3px;
318 | }
319 |
320 | #constants-list > dl,
321 | #attributes-list > dl {
322 | margin: 1em 0 2em;
323 | border: 0;
324 | }
325 | #constants-list > dl dt,
326 | #attributes-list > dl dt {
327 | padding-left: 0;
328 | font-weight: bold;
329 | font-family: Monaco, "Andale Mono";
330 | background: inherit;
331 | }
332 | #constants-list > dl dt a,
333 | #attributes-list > dl dt a {
334 | color: inherit;
335 | }
336 | #constants-list > dl dd,
337 | #attributes-list > dl dd {
338 | margin: 0 0 1em 0;
339 | padding: 0;
340 | color: #666;
341 | }
342 |
343 | /* @group Method Details */
344 |
345 | #documentation .method-source-code {
346 | display: none;
347 | }
348 |
349 | #documentation .method-detail {
350 | margin: 0.5em 0;
351 | padding: 0.5em 0;
352 | cursor: pointer;
353 | }
354 | #documentation .method-detail:hover {
355 | background-color: #f1edba;
356 | }
357 | #documentation .method-heading {
358 | position: relative;
359 | padding: 2px 4px 0 20px;
360 | font-size: 125%;
361 | font-weight: bold;
362 | color: #333;
363 | background: url(images/brick.png) no-repeat left bottom;
364 | }
365 | #documentation .method-heading :link,
366 | #documentation .method-heading :visited {
367 | color: inherit;
368 | }
369 | #documentation .method-click-advice {
370 | position: absolute;
371 | top: 2px;
372 | right: 5px;
373 | font-size: 10px;
374 | color: #9b9877;
375 | visibility: hidden;
376 | padding-right: 20px;
377 | line-height: 20px;
378 | background: url(images/zoom.png) no-repeat right top;
379 | }
380 | #documentation .method-detail:hover .method-click-advice {
381 | visibility: visible;
382 | }
383 |
384 | #documentation .method-alias .method-heading {
385 | color: #666;
386 | background: url(images/brick_link.png) no-repeat left bottom;
387 | }
388 |
389 | #documentation .method-description,
390 | #documentation .aliases {
391 | margin: 0 20px;
392 | line-height: 1.2em;
393 | color: #666;
394 | }
395 | #documentation .aliases {
396 | padding-top: 4px;
397 | font-style: italic;
398 | cursor: default;
399 | }
400 | #documentation .method-description p {
401 | padding: 0;
402 | }
403 | #documentation .method-description p + p {
404 | margin-bottom: 0.5em;
405 | }
406 | #documentation .method-description ul {
407 | margin-left: 1.5em;
408 | }
409 |
410 | #documentation .attribute-method-heading {
411 | background: url(images/tag_green.png) no-repeat left bottom;
412 | }
413 | #documentation #attribute-method-details .method-detail:hover {
414 | background-color: transparent;
415 | cursor: default;
416 | }
417 | #documentation .attribute-access-type {
418 | font-size: 60%;
419 | text-transform: uppercase;
420 | vertical-align: super;
421 | padding: 0 2px;
422 | }
423 | /* @end */
424 |
425 | /* @end */
426 |
427 |
428 |
429 | /* @group Source Code */
430 |
431 | div.method-source-code {
432 | background: #262626;
433 | color: #efefef;
434 | margin: 1em;
435 | padding: 0.5em;
436 | border: 1px dashed #999;
437 | overflow: hidden;
438 | }
439 |
440 | div.method-source-code pre {
441 | background: inherit;
442 | padding: 0;
443 | color: white;
444 | overflow: auto;
445 | }
446 |
447 | /* @group Ruby keyword styles */
448 |
449 | .ruby-constant { color: #7fffd4; background: transparent; }
450 | .ruby-keyword { color: #00ffff; background: transparent; }
451 | .ruby-ivar { color: #eedd82; background: transparent; }
452 | .ruby-operator { color: #00ffee; background: transparent; }
453 | .ruby-identifier { color: #ffdead; background: transparent; }
454 | .ruby-node { color: #ffa07a; background: transparent; }
455 | .ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
456 | .ruby-regexp { color: #ffa07a; background: transparent; }
457 | .ruby-value { color: #7fffd4; background: transparent; }
458 |
459 | /* @end */
460 | /* @end */
461 |
462 |
463 | /* @group File Popup Contents */
464 |
465 | .file #metadata,
466 | .file-popup #metadata {
467 | }
468 |
469 | .file-popup dl {
470 | font-size: 80%;
471 | padding: 0.75em;
472 | background-color: #dedede;
473 | color: #333;
474 | border: 1px solid #bbb;
475 | -moz-border-radius: 3px;
476 | -webkit-border-radius: 3px;
477 | }
478 | .file dt {
479 | font-weight: bold;
480 | padding-left: 22px;
481 | line-height: 20px;
482 | background: url(images/page_white_width.png) no-repeat left top;
483 | }
484 | .file dt.modified-date {
485 | background: url(images/date.png) no-repeat left top;
486 | }
487 | .file dt.requires {
488 | background: url(images/plugin.png) no-repeat left top;
489 | }
490 | .file dt.scs-url {
491 | background: url(images/wrench.png) no-repeat left top;
492 | }
493 |
494 | .file dl dd {
495 | margin: 0 0 1em 0;
496 | }
497 | .file #metadata dl dd ul {
498 | list-style: circle;
499 | margin-left: 20px;
500 | padding-top: 0;
501 | }
502 | .file #metadata dl dd ul li {
503 | }
504 |
505 |
506 | .file h2 {
507 | margin-top: 2em;
508 | padding: 0.75em 0.5em;
509 | background-color: #dedede;
510 | color: #333;
511 | font-size: 120%;
512 | border: 1px solid #bbb;
513 | -moz-border-radius: 3px;
514 | -webkit-border-radius: 3px;
515 | }
516 |
517 | /* @end */
518 |
519 |
520 |
521 |
522 | /* @group ThickBox Styles */
523 | #TB_window {
524 | font: 12px Arial, Helvetica, sans-serif;
525 | color: #333333;
526 | }
527 |
528 | #TB_secondLine {
529 | font: 10px Arial, Helvetica, sans-serif;
530 | color:#666666;
531 | }
532 |
533 | #TB_window :link,
534 | #TB_window :visited { color: #666666; }
535 | #TB_window :link:hover,
536 | #TB_window :visited:hover { color: #000; }
537 | #TB_window :link:active,
538 | #TB_window :visited:active { color: #666666; }
539 | #TB_window :link:focus,
540 | #TB_window :visited:focus { color: #666666; }
541 |
542 | #TB_overlay {
543 | position: fixed;
544 | z-index:100;
545 | top: 0px;
546 | left: 0px;
547 | height:100%;
548 | width:100%;
549 | }
550 |
551 | .TB_overlayMacFFBGHack {background: url(images/macFFBgHack.png) repeat;}
552 | .TB_overlayBG {
553 | background-color:#000;
554 | filter:alpha(opacity=75);
555 | -moz-opacity: 0.75;
556 | opacity: 0.75;
557 | }
558 |
559 | * html #TB_overlay { /* ie6 hack */
560 | position: absolute;
561 | height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px');
562 | }
563 |
564 | #TB_window {
565 | position: fixed;
566 | background: #ffffff;
567 | z-index: 102;
568 | color:#000000;
569 | display:none;
570 | border: 4px solid #525252;
571 | text-align:left;
572 | top:50%;
573 | left:50%;
574 | }
575 |
576 | * html #TB_window { /* ie6 hack */
577 | position: absolute;
578 | margin-top: expression(0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px');
579 | }
580 |
581 | #TB_window img#TB_Image {
582 | display:block;
583 | margin: 15px 0 0 15px;
584 | border-right: 1px solid #ccc;
585 | border-bottom: 1px solid #ccc;
586 | border-top: 1px solid #666;
587 | border-left: 1px solid #666;
588 | }
589 |
590 | #TB_caption{
591 | height:25px;
592 | padding:7px 30px 10px 25px;
593 | float:left;
594 | }
595 |
596 | #TB_closeWindow{
597 | height:25px;
598 | padding:11px 25px 10px 0;
599 | float:right;
600 | }
601 |
602 | #TB_closeAjaxWindow{
603 | padding:7px 10px 5px 0;
604 | margin-bottom:1px;
605 | text-align:right;
606 | float:right;
607 | }
608 |
609 | #TB_ajaxWindowTitle{
610 | float:left;
611 | padding:7px 0 5px 10px;
612 | margin-bottom:1px;
613 | font-size: 22px;
614 | }
615 |
616 | #TB_title{
617 | background-color: #6C8C22;
618 | color: #dedede;
619 | height:40px;
620 | }
621 | #TB_title :link,
622 | #TB_title :visited {
623 | color: white !important;
624 | border-bottom: 1px dotted #dedede;
625 | }
626 |
627 | #TB_ajaxContent{
628 | clear:both;
629 | padding:2px 15px 15px 15px;
630 | overflow:auto;
631 | text-align:left;
632 | line-height:1.4em;
633 | }
634 |
635 | #TB_ajaxContent.TB_modal{
636 | padding:15px;
637 | }
638 |
639 | #TB_ajaxContent p{
640 | padding:5px 0px 5px 0px;
641 | }
642 |
643 | #TB_load{
644 | position: fixed;
645 | display:none;
646 | height:13px;
647 | width:208px;
648 | z-index:103;
649 | top: 50%;
650 | left: 50%;
651 | margin: -6px 0 0 -104px; /* -height/2 0 0 -width/2 */
652 | }
653 |
654 | * html #TB_load { /* ie6 hack */
655 | position: absolute;
656 | margin-top: expression(0 - parseInt(this.offsetHeight / 2) + (TBWindowMargin = document.documentElement && document.documentElement.scrollTop || document.body.scrollTop) + 'px');
657 | }
658 |
659 | #TB_HideSelect{
660 | z-index:99;
661 | position:fixed;
662 | top: 0;
663 | left: 0;
664 | background-color:#fff;
665 | border:none;
666 | filter:alpha(opacity=0);
667 | -moz-opacity: 0;
668 | opacity: 0;
669 | height:100%;
670 | width:100%;
671 | }
672 |
673 | * html #TB_HideSelect { /* ie6 hack */
674 | position: absolute;
675 | height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px');
676 | }
677 |
678 | #TB_iframeContent{
679 | clear:both;
680 | border:none;
681 | margin-bottom:-1px;
682 | margin-top:1px;
683 | _margin-bottom:1px;
684 | }
685 |
686 | /* @end */
687 |
688 | /* @group Debugging Section */
689 |
690 | #debugging-toggle {
691 | text-align: center;
692 | }
693 | #debugging-toggle img {
694 | cursor: pointer;
695 | }
696 |
697 | #rdoc-debugging-section-dump {
698 | display: none;
699 | margin: 0 2em 2em;
700 | background: #ccc;
701 | border: 1px solid #999;
702 | }
703 |
704 |
705 |
706 | /* @end */
707 |
--------------------------------------------------------------------------------