├── log └── .gitkeep ├── lib ├── tasks │ └── .gitkeep ├── assets │ └── .gitkeep └── templates │ └── erb │ └── scaffold │ └── _form.html.erb ├── public ├── favicon.ico ├── robots.txt ├── 400.html ├── 404.html ├── 500.html └── 422.html ├── app ├── mailers │ └── .gitkeep ├── assets │ ├── javascripts │ │ ├── ace │ │ │ ├── mode-text.js │ │ │ ├── mode-plain_text.js │ │ │ ├── mode-properties.js │ │ │ ├── mode-lucene.js │ │ │ ├── mode-sql.js │ │ │ ├── mode-ada.js │ │ │ ├── mode-scheme.js │ │ │ ├── mode-lisp.js │ │ │ ├── mode-textile.js │ │ │ ├── mode-cobol.js │ │ │ ├── mode-toml.js │ │ │ ├── mode-diff.js │ │ │ ├── theme-github.js │ │ │ ├── ext-modelist.js │ │ │ ├── mode-verilog.js │ │ │ ├── mode-c9search.js │ │ │ ├── mode-tex.js │ │ │ ├── mode-ini.js │ │ │ ├── mode-latex.js │ │ │ ├── mode-sh.js │ │ │ ├── mode-rdoc.js │ │ │ ├── mode-batchfile.js │ │ │ ├── mode-snippets.js │ │ │ ├── mode-tmsnippet.js │ │ │ ├── mode-yaml.js │ │ │ ├── mode-pascal.js │ │ │ ├── mode-python.js │ │ │ ├── mode-tcl.js │ │ │ ├── mode-makefile.js │ │ │ ├── mode-mushcode_high_rules.js │ │ │ ├── mode-r.js │ │ │ └── mode-livescript.js │ │ ├── application.js │ │ └── header.js │ └── stylesheets │ │ ├── application.css │ │ ├── code_prettify.css │ │ └── bootstrap_and_overrides.css.less ├── views │ ├── favorites │ │ └── just_required_for_rspec │ ├── gists │ │ ├── page.js.erb │ │ ├── mine_page.js.erb │ │ ├── user_page.js.erb │ │ ├── user_fav_page.js.erb │ │ ├── add_gist_files_input.js.erb │ │ ├── _page.html.erb │ │ ├── _mine_page.html.erb │ │ ├── new.html.erb │ │ ├── edit.html.erb │ │ ├── _user_page.html.erb │ │ ├── mine.html.erb │ │ ├── index.html.erb │ │ ├── _gist_files_input.html.erb │ │ ├── _fork_of.html.erb │ │ ├── _forks.html.erb │ │ ├── _user_fav_page.html.erb │ │ ├── _history.html.erb │ │ ├── _list.html.erb │ │ ├── _form.html.erb │ │ └── show.html.erb │ ├── users │ │ ├── edit.html.erb │ │ ├── _form.html.erb │ │ └── show.html.erb │ ├── common │ │ ├── _flash_error.html.erb │ │ ├── _flash_notice.html.erb │ │ ├── _search_form.html.erb │ │ ├── _favorites.html.erb │ │ └── _mygists.html.erb │ ├── sessions │ │ └── failure.html.erb │ ├── kaminari │ │ ├── _gap.html.erb │ │ ├── _first_page.html.erb │ │ ├── _last_page.html.erb │ │ ├── _page.html.erb │ │ └── _paginator.html.erb │ ├── comments │ │ ├── _form.html.erb │ │ └── _list.html.erb │ ├── layouts │ │ └── application.html.erb │ └── root │ │ └── index.html.erb ├── models │ ├── concerns │ │ └── basic_persistence.rb │ ├── gist_file.rb │ ├── comment.rb │ ├── favorite.rb │ ├── user.rb │ ├── gist_history.rb │ ├── gist_fork_creation.rb │ ├── gist_persistence.rb │ └── gist.rb ├── controllers │ ├── root_controller.rb │ ├── favorites_controller.rb │ ├── comments_controller.rb │ ├── sessions_controller.rb │ ├── users_controller.rb │ └── application_controller.rb └── helpers │ └── application_helper.rb ├── screenshot1.png ├── screenshot2.png ├── bin ├── rake ├── bundle └── rails ├── Rakefile ├── .buildpacks ├── config ├── environment.rb ├── initializers │ ├── session_store.rb │ ├── filter_parameter_logging.rb │ ├── mime_types.rb │ ├── kaminari_config.rb │ ├── omniauth.rb │ ├── secret_token.rb │ ├── unlimited_strength_cryptography.rb │ ├── backtrace_silencers.rb │ ├── quiet_assets.rb │ ├── wrap_parameters.rb │ ├── inflections.rb │ └── client_side_validations.rb ├── boot.rb ├── locales │ ├── zh.yml │ ├── en.yml │ ├── simple_form.zh.yml │ └── simple_form.en.yml ├── database.yml ├── routes.rb ├── environments │ ├── development.rb │ ├── test.rb │ └── production.rb └── application.rb ├── config.ru ├── db ├── migrate │ ├── 20140110041301_add_email_to_users.rb │ ├── 20121003054038_create_gist_histories.rb │ ├── 20121008094826_create_favorites.rb │ ├── 20121003022144_create_users.rb │ ├── 20121003022400_create_comments.rb │ ├── 20121015023421_change_gist_histories_gist_id_not_null.rb │ ├── 20121003022313_create_gist_files.rb │ └── 20121003022220_create_gists.rb ├── seeds.rb └── schema.rb ├── spec ├── models │ ├── gist_file_spec.rb │ ├── comment_spec.rb │ ├── favorite_spec.rb │ ├── concerns │ │ └── basic_persistence_spec.rb │ ├── gist_fork_creation_spec.rb │ ├── gist_history_spec.rb │ ├── user_spec.rb │ ├── gist_persistence_spec.rb │ └── gist_spec.rb ├── routing │ ├── root_routing_spec.rb │ ├── users_routing_spec.rb │ ├── sessions_routing_spec.rb │ ├── comments_routing_spec.rb │ ├── favorites_routing_spec.rb │ └── gists_routing_spec.rb ├── requests │ ├── gists_spec.rb │ └── users_spec.rb ├── factories.rb ├── controllers │ ├── root_controller_spec.rb │ ├── application_controller_spec.rb │ ├── favorites_controller_spec.rb │ ├── comments_controller_spec.rb │ └── sessions_controller_spec.rb ├── spec_helper.rb └── helpers │ └── application_helper_spec.rb ├── .travis.yml ├── .gitignore ├── LICENSE.txt ├── app.json ├── Gemfile ├── README.md └── CHAGELOG /log/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tasks/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/mailers/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/assets/javascripts/ace/mode-text.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/views/favorites/just_required_for_rspec: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-Agent: * 2 | Allow: / 3 | -------------------------------------------------------------------------------- /app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | //= require twitter/bootstrap 2 | -------------------------------------------------------------------------------- /screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seratch/gistub/HEAD/screenshot1.png -------------------------------------------------------------------------------- /screenshot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/seratch/gistub/HEAD/screenshot2.png -------------------------------------------------------------------------------- /app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | *= require_self 3 | *= require_tree . 4 | */ 5 | -------------------------------------------------------------------------------- /app/views/gists/page.js.erb: -------------------------------------------------------------------------------- 1 | $('#gists').html('<%= j(render(:partial => 'gists/page')) %>'); 2 | prettyPrint(); 3 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative '../config/boot' 3 | require 'rake' 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /app/views/gists/mine_page.js.erb: -------------------------------------------------------------------------------- 1 | $('#gists').html('<%= j(render(:partial => 'gists/mine_page')) %>'); 2 | prettyPrint(); 3 | -------------------------------------------------------------------------------- /app/views/gists/user_page.js.erb: -------------------------------------------------------------------------------- 1 | $('#user_gists').html('<%= j(render(:partial => 'gists/user_page')) %>'); 2 | prettyPrint(); 3 | -------------------------------------------------------------------------------- /public/400.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |

4 | 400 Bad Request 5 |

6 |
7 |
8 | 9 | -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |

4 | 404 Not Found 5 |

6 |
7 |
8 | 9 | -------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |

4 | 500 Internal Server Error 5 |

6 |
7 |
8 | -------------------------------------------------------------------------------- /app/assets/javascripts/header.js: -------------------------------------------------------------------------------- 1 | //= require jquery 2 | //= require jquery_ujs 3 | //= require code_prettify 4 | //= require_tree . 5 | 6 | -------------------------------------------------------------------------------- /app/views/gists/user_fav_page.js.erb: -------------------------------------------------------------------------------- 1 | $('#favorites').html('<%= j(render(:partial => 'gists/user_fav_page')) %>'); 2 | prettyPrint(); 3 | 4 | -------------------------------------------------------------------------------- /app/views/users/edit.html.erb: -------------------------------------------------------------------------------- 1 |
2 | 3 | <%= render 'users/form' %> 4 | 5 |
6 |
7 |
8 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |

4 | 422 Unprocessable Entity 5 |

6 |
7 |
8 | 9 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rake 2 | 3 | require File.expand_path('../config/application', __FILE__) 4 | 5 | Gistub::Application.load_tasks 6 | 7 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /.buildpacks: -------------------------------------------------------------------------------- 1 | https://github.com/rcaught/heroku-buildpack-cmake 2 | https://codon-buildpacks.s3.amazonaws.com/buildpacks/frederick/heroku-buildpack-ruby.tgz 3 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | require File.expand_path('../application', __FILE__) 3 | 4 | Gistub::Application.initialize! 5 | 6 | -------------------------------------------------------------------------------- /config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | Gistub::Application.config.session_store :cookie_store, key: '_gistub_session' 3 | 4 | -------------------------------------------------------------------------------- /app/views/common/_flash_error.html.erb: -------------------------------------------------------------------------------- 1 | <% if flash[:error] %> 2 |
3 | <%= flash[:error] %> 4 |
5 | <% end %> 6 | -------------------------------------------------------------------------------- /app/views/common/_flash_notice.html.erb: -------------------------------------------------------------------------------- 1 | <% if flash[:notice] %> 2 |
3 | <%= flash[:notice] %> 4 |
5 | <% end %> 6 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path('../../config/application', __FILE__) 3 | require_relative '../config/boot' 4 | require 'rails/commands' 5 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | require ::File.expand_path('../config/environment', __FILE__) 2 | 3 | map ENV['RAILS_RELATIVE_URL_ROOT'] || "/" do 4 | run Gistub::Application 5 | end 6 | 7 | -------------------------------------------------------------------------------- /app/views/gists/add_gist_files_input.js.erb: -------------------------------------------------------------------------------- 1 | $('#gist_files_input').append('<%= j(render(:partial => 'gist_files_input', :locals => { :gist_file => GistFile.new }) ) %>'); 2 | -------------------------------------------------------------------------------- /db/migrate/20140110041301_add_email_to_users.rb: -------------------------------------------------------------------------------- 1 | class AddEmailToUsers < ActiveRecord::Migration 2 | def change 3 | add_column :users, :email, :string 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /app/views/gists/_page.html.erb: -------------------------------------------------------------------------------- 1 |
2 | <%= paginate @gists, :remote => true, :window => 6, :params => {:action => 'page'} %> 3 | <%= render :partial => 'gists/list' %> 4 |
5 | -------------------------------------------------------------------------------- /app/views/gists/_mine_page.html.erb: -------------------------------------------------------------------------------- 1 |
2 | <%= paginate @gists, :remote => true, :window => 6, :params => {:action => 'mine_page'} %> 3 | <%= render :partial => 'gists/list' %> 4 |
5 | -------------------------------------------------------------------------------- /app/views/gists/new.html.erb: -------------------------------------------------------------------------------- 1 |
2 | 3 |

 New Gist

4 |
5 | <%= render 'gists/form' %> 6 | 7 |
8 |
9 |
10 | -------------------------------------------------------------------------------- /app/views/sessions/failure.html.erb: -------------------------------------------------------------------------------- 1 |
2 | 3 |

Authentication Cancelled

4 |
5 | <%= link_to 'Back to home', root_path %> 6 | 7 |
8 |
9 |
10 | -------------------------------------------------------------------------------- /app/models/concerns/basic_persistence.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | module BasicPersistence 3 | 4 | def transaction 5 | ActiveRecord::Base.transaction do 6 | yield 7 | end 8 | end 9 | 10 | end 11 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | # Set up gems listed in the Gemfile. 3 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 4 | 5 | require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) 6 | -------------------------------------------------------------------------------- /app/controllers/root_controller.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | class RootController < ApplicationController 3 | 4 | respond_to :html 5 | 6 | def index 7 | @gists = Gist.limit(5).recent 8 | end 9 | 10 | end 11 | -------------------------------------------------------------------------------- /app/views/common/_search_form.html.erb: -------------------------------------------------------------------------------- 1 |
2 | <%= form_tag search_gists_path, :method => :get do %> 3 | <%= text_field_tag :search_query, @search_query, :placeholder => "Search", :class => "span3" %> 4 | <% end %> 5 |
6 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/models/gist_file.rb: -------------------------------------------------------------------------------- 1 | class GistFile < ActiveRecord::Base 2 | 3 | validates :name, :presence => true 4 | validates :body, :presence => true 5 | validates :gist_history_id, :presence => true 6 | 7 | belongs_to :gist_history 8 | 9 | end 10 | -------------------------------------------------------------------------------- /app/views/gists/edit.html.erb: -------------------------------------------------------------------------------- 1 |
2 | 3 | <%= render 'form' %> 4 | 5 | <%= link_to 'Show', @gist %> | 6 | <%= link_to 'Back', gists_path %> 7 | 8 |
9 |
10 | <%= render :partial => 'gists/history' %> 11 |
12 | -------------------------------------------------------------------------------- /spec/models/gist_file_spec.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | require 'spec_helper' 3 | 4 | describe GistFile do 5 | 6 | it 'is available' do 7 | gist_file = create(:gist_file) 8 | expect(gist_file.gist_history).not_to be_nil 9 | end 10 | 11 | end 12 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | rvm: 3 | - jruby-19mode 4 | - 2.1.5 5 | # TODO: tests on Ruby 2.2.0 6 | # - 2.2.0 7 | bundler_args: --without postgresql 8 | env: 9 | - DB=sqlite 10 | script: 11 | - RAILS_ENV=test bundle exec rake --trace db:migrate spec 12 | 13 | -------------------------------------------------------------------------------- /app/views/gists/_user_page.html.erb: -------------------------------------------------------------------------------- 1 |
2 | <%= paginate @gists, :remote => true, :window => 6, 3 | :params => {:controller => 'gists', :action => 'user_page', :user_id => @user.id} 4 | %> 5 | <%= render :partial => 'gists/list' %> 6 |
7 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | # Be sure to restart your server when you modify this file. 3 | 4 | # Add new mime types for use in respond_to blocks: 5 | # Mime::Type.register "text/richtext", :rtf 6 | # Mime::Type.register_alias "text/html", :iphone 7 | -------------------------------------------------------------------------------- /spec/routing/root_routing_spec.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | require "spec_helper" 3 | 4 | describe RootController do 5 | describe "routing" do 6 | 7 | it "routes to root" do 8 | expect(get("/")).to route_to("root#index") 9 | end 10 | 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /app/models/comment.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | class Comment < ActiveRecord::Base 3 | 4 | validates :body, presence: true 5 | validates :gist_id, presence: true 6 | validates :user_id, presence: true 7 | 8 | belongs_to :gist 9 | belongs_to :user 10 | 11 | end 12 | -------------------------------------------------------------------------------- /spec/models/comment_spec.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | require 'spec_helper' 3 | 4 | describe Comment do 5 | 6 | it 'is available' do 7 | comment = create(:comment) 8 | expect(comment.user).not_to be_nil 9 | expect(comment.gist).not_to be_nil 10 | end 11 | 12 | end 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .bundle 3 | .loadpath 4 | .project 5 | .rvmrc 6 | .idea 7 | Thumbs.db 8 | log/*.log 9 | db/*.sqlite3 10 | doc/* 11 | public/cache/**/* 12 | tmp/ 13 | vendor/ 14 | public/assets/ 15 | coverage/ 16 | backup/ 17 | test/reports 18 | out/ 19 | untitled/ 20 | *.iml 21 | 22 | -------------------------------------------------------------------------------- /spec/models/favorite_spec.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | require 'spec_helper' 3 | 4 | describe Favorite do 5 | 6 | it 'is available' do 7 | favorite = create(:favorite) 8 | expect(favorite.user).not_to be_nil 9 | expect(favorite.gist).not_to be_nil 10 | end 11 | 12 | end 13 | -------------------------------------------------------------------------------- /app/models/favorite.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | class Favorite < ActiveRecord::Base 3 | 4 | validates :gist_id, presence: true 5 | validates :user_id, presence: true 6 | 7 | belongs_to :gist 8 | belongs_to :user 9 | 10 | scope :recent, lambda { order(:created_at).reverse_order } 11 | 12 | end 13 | -------------------------------------------------------------------------------- /db/migrate/20121003054038_create_gist_histories.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | class CreateGistHistories < ActiveRecord::Migration 3 | def change 4 | create_table :gist_histories do |t| 5 | t.integer :gist_id 6 | t.integer :user_id 7 | 8 | t.timestamps 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /config/initializers/kaminari_config.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | Kaminari.configure do |config| 3 | # config.default_per_page = 25 4 | # config.window = 4 5 | # config.outer_window = 0 6 | # config.left = 0 7 | # config.right = 0 8 | # config.page_method_name = :page 9 | # config.param_name = :page 10 | end 11 | -------------------------------------------------------------------------------- /db/migrate/20121008094826_create_favorites.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | class CreateFavorites < ActiveRecord::Migration 3 | def change 4 | create_table :favorites do |t| 5 | t.integer :user_id, :null => false 6 | t.integer :gist_id, :null => false 7 | 8 | t.timestamps 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/models/concerns/basic_persistence_spec.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | 3 | require 'spec_helper' 4 | 5 | describe BasicPersistence do 6 | 7 | describe '#transaction' do 8 | it 'works' do 9 | Gist.transaction do 10 | Gist.where(:id => 123).first 11 | end 12 | end 13 | end 14 | 15 | end 16 | -------------------------------------------------------------------------------- /spec/requests/gists_spec.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | require 'spec_helper' 3 | 4 | describe "Gists" do 5 | 6 | describe "GET /gists" do 7 | it "works" do 8 | 3.times do 9 | create(:gist) 10 | end 11 | get gists_path 12 | expect(response.status).to be(200) 13 | end 14 | end 15 | 16 | end 17 | -------------------------------------------------------------------------------- /config/locales/zh.yml: -------------------------------------------------------------------------------- 1 | zh: 2 | activerecord: 3 | models: 4 | gist: 纪要 5 | gist_file: 文件 6 | gist_history: 历史 7 | user: 用户 8 | favorite: 收藏 9 | comment: 评论 10 | attributes: 11 | user: 12 | nickname: 昵称 13 | omniauth_provider: 认证 14 | omniauth_uid: 用户ID 15 | hello: "Hello world" 16 | -------------------------------------------------------------------------------- /db/migrate/20121003022144_create_users.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | class CreateUsers < ActiveRecord::Migration 3 | def change 4 | create_table :users do |t| 5 | t.string :nickname 6 | t.string :omniauth_provider, :null => false 7 | t.string :omniauth_uid, :null => false 8 | 9 | t.timestamps 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /db/migrate/20121003022400_create_comments.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | class CreateComments < ActiveRecord::Migration 3 | def change 4 | create_table :comments do |t| 5 | t.integer :gist_id, :null => false 6 | t.integer :user_id, :null => false 7 | t.text :body, :null => false 8 | 9 | t.timestamps 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /db/migrate/20121015023421_change_gist_histories_gist_id_not_null.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | class ChangeGistHistoriesGistIdNotNull < ActiveRecord::Migration 3 | def up 4 | change_column :gist_histories, :gist_id, :integer, :null => false 5 | end 6 | 7 | def down 8 | change_column :gist_histories, :gist_id, :integer, :null => true 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /db/migrate/20121003022313_create_gist_files.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | class CreateGistFiles < ActiveRecord::Migration 3 | def change 4 | create_table :gist_files do |t| 5 | t.string :name, :null => false 6 | t.text :body, :null => false 7 | t.integer :gist_history_id, :null => false 8 | 9 | t.timestamps 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /config/initializers/omniauth.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | Rails.application.config.middleware.use OmniAuth::Builder do 3 | require 'openid/store/filesystem' 4 | provider :open_id, 5 | :identifier => ENV['GISTUB_OPENID_IDENTIFIER'].presence || 'https://www.google.com/accounts/o8/id', 6 | :store => OpenID::Store::Filesystem.new("#{Rails.root}/tmp/openid") 7 | end 8 | -------------------------------------------------------------------------------- /db/migrate/20121003022220_create_gists.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | class CreateGists < ActiveRecord::Migration 3 | def change 4 | create_table :gists do |t| 5 | t.string :title, :null => false 6 | t.boolean :is_public, :null => false 7 | t.integer :user_id 8 | t.integer :source_gist_id 9 | 10 | t.timestamps 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | en: 2 | activerecord: 3 | models: 4 | gist: Gist 5 | gist_file: File 6 | gist_history: History 7 | user: User 8 | favorite: Favorite 9 | comment: Comment 10 | attributes: 11 | user: 12 | nickname: Nickname 13 | omniauth_provider: Authentication 14 | omniauth_uid: UID 15 | hello: "Hello world" 16 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | # This file should contain all the record creation needed to seed the database with its default values. 3 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). 4 | # 5 | # Examples: 6 | # 7 | # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) 8 | # Mayor.create(name: 'Emanuel', city: cities.first) 9 | -------------------------------------------------------------------------------- /config/initializers/secret_token.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | Gistub::Application.config.secret_token = ENV['GISTUB_SECRET_TOKEN'] || '9d823ec9de09d00bec258fee515a324f9499cc3d334bdd8955a4e779094cf1bf37f6c2d77ff65ef6222ab038a8b49f6e1fd81949b05ffdbaa64e5df2fc5f507b' 3 | Gistub::Application.config.secret_key_base = ENV['GISTUB_SECRET_KEY_BASE'] || 'something like 4f9499cc3d334bdd8955a4e779094cf1bf37f6c2' 4 | 5 | -------------------------------------------------------------------------------- /spec/requests/users_spec.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | require 'spec_helper' 3 | 4 | describe "Users" do 5 | 6 | describe "GET /user/:id" do 7 | it "works" do 8 | user = create(:user, :nickname => 'XXXXX') 9 | get user_path(user) 10 | expect(response.status).to be(200) 11 | expect(response.body.include?("XXXXX")).to be_true 12 | end 13 | end 14 | 15 | end 16 | -------------------------------------------------------------------------------- /config/initializers/unlimited_strength_cryptography.rb: -------------------------------------------------------------------------------- 1 | # http://stackoverflow.com/questions/14552303/opensslcipherciphererror-with-rails4-on-jruby 2 | 3 | if RUBY_PLATFORM == 'java' 4 | security_class = java.lang.Class.for_name('javax.crypto.JceSecurity') 5 | restricted_field = security_class.get_declared_field('isRestricted') 6 | restricted_field.accessible = true 7 | restricted_field.set nil, false 8 | end 9 | 10 | -------------------------------------------------------------------------------- /app/views/kaminari/_gap.html.erb: -------------------------------------------------------------------------------- 1 | <%# Non-link tag that stands for skipped pages... 2 | - available local variables 3 | current_page: a page object for the currently displayed page 4 | num_pages: total number of pages 5 | per_page: number of items to fetch per page 6 | remote: data-remote 7 | -%> 8 |
  • <%= raw(t 'views.pagination.truncate') %>
  • 9 | -------------------------------------------------------------------------------- /lib/templates/erb/scaffold/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%%= simple_form_for(@<%= singular_table_name %>) do |f| %> 2 | <%%= f.error_notification %> 3 | 4 |
    5 | <%- attributes.each do |attribute| -%> 6 | <%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %> 7 | <%- end -%> 8 |
    9 | 10 |
    11 | <%%= f.button :submit %> 12 |
    13 | <%% end %> 14 | -------------------------------------------------------------------------------- /app/views/kaminari/_first_page.html.erb: -------------------------------------------------------------------------------- 1 | <%# Link to the "First" page 2 | - available local variables 3 | url: url to the first page 4 | current_page: a page object for the currently displayed page 5 | num_pages: total number of pages 6 | per_page: number of items to fetch per page 7 | remote: data-remote 8 | -%> 9 |
  • 10 | <%= link_to raw(t 'views.pagination.first'), url, :remote => remote %> 11 |
  • 12 | -------------------------------------------------------------------------------- /spec/models/gist_fork_creation_spec.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | 3 | require 'spec_helper' 4 | 5 | describe GistForkCreation do 6 | 7 | describe '#save!' do 8 | it 'works' do 9 | gist_fork_creation = GistForkCreation.new 10 | gist_to_fork = create(:gist_history).gist 11 | current_user = nil 12 | result = gist_fork_creation.save!(gist_to_fork, current_user) 13 | expect(result).not_to be_nil 14 | end 15 | end 16 | 17 | end 18 | -------------------------------------------------------------------------------- /app/views/gists/mine.html.erb: -------------------------------------------------------------------------------- 1 |
    2 | 3 | <%= render :partial => 'common/flash_notice' %> 4 | 5 |

     My Gists 6 | <%= render :partial => 'common/search_form' %> 7 |

    8 |
    9 | 10 | <%= render :partial => 'gists/mine_page' %> 11 | 12 | 17 | 18 |
    19 |
    20 |
    21 | -------------------------------------------------------------------------------- /config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | # Be sure to restart your server when you modify this file. 3 | 4 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 5 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 6 | 7 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 8 | # Rails.backtrace_cleaner.remove_silencers! 9 | -------------------------------------------------------------------------------- /app/assets/javascripts/ace/mode-plain_text.js: -------------------------------------------------------------------------------- 1 | ace.define("ace/mode/plain_text",["require","exports","module","ace/lib/oop","ace/mode/text","ace/tokenizer","ace/mode/text_highlight_rules","ace/mode/behaviour"],function(e,t,n){var r=e("../lib/oop"),i=e("./text").Mode,s=e("../tokenizer").Tokenizer,o=e("./text_highlight_rules").TextHighlightRules,u=e("./behaviour").Behaviour,a=function(){this.$tokenizer=new s((new o).getRules()),this.$behaviour=new u};r.inherits(a,i),function(){this.getNextLineIndent=function(e,t,n){return""}}.call(a.prototype),t.Mode=a}) -------------------------------------------------------------------------------- /app/views/kaminari/_last_page.html.erb: -------------------------------------------------------------------------------- 1 | <%# Link to the "Last" page 2 | - available local variables 3 | url: url to the last page 4 | current_page: a page object for the currently displayed page 5 | num_pages: total number of pages 6 | per_page: number of items to fetch per page 7 | remote: data-remote 8 | -%> 9 | 12 | -------------------------------------------------------------------------------- /config/initializers/quiet_assets.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | if Rails.env.development? 3 | Rails.application.assets.logger = Logger.new('/dev/null') 4 | Rails::Rack::Logger.class_eval do 5 | def call_with_quiet_assets(env) 6 | previous_level = Rails.logger.level 7 | Rails.logger.level = Logger::ERROR if env['PATH_INFO'] =~ %r{^/assets/} 8 | call_without_quiet_assets(env) 9 | ensure 10 | Rails.logger.level = previous_level 11 | end 12 | alias_method_chain :call, :quiet_assets 13 | end 14 | end 15 | 16 | -------------------------------------------------------------------------------- /app/views/gists/index.html.erb: -------------------------------------------------------------------------------- 1 |
    2 | 3 | <%= render :partial => 'common/flash_notice' %> 4 | 5 | <% @gist_list_title ||= "Gists" %> 6 |

     <%= @gist_list_title %> 7 | <%= render :partial => 'common/search_form' %> 8 |

    9 |
    10 | 11 |
    12 | <%= render :partial => 'gists/page' %> 13 |
    14 | 15 | 20 | 21 |
    22 |
    23 |
    24 | -------------------------------------------------------------------------------- /app/views/kaminari/_page.html.erb: -------------------------------------------------------------------------------- 1 | <%# Link showing page number 2 | - available local variables 3 | page: a page object for "this" page 4 | url: url to this page 5 | current_page: a page object for the currently displayed page 6 | num_pages: total number of pages 7 | per_page: number of items to fetch per page 8 | remote: data-remote 9 | -%> 10 |
  • 11 | <%= link_to page, url, opts = {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %> 12 |
  • 13 | -------------------------------------------------------------------------------- /config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | # Be sure to restart your server when you modify this file. 3 | # 4 | # This file contains settings for ActionController::ParamsWrapper which 5 | # is enabled by default. 6 | 7 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 8 | ActiveSupport.on_load(:action_controller) do 9 | wrap_parameters format: [:json] 10 | end 11 | 12 | # Disable root element in JSON by default. 13 | ActiveSupport.on_load(:active_record) do 14 | self.include_root_in_json = false 15 | end 16 | -------------------------------------------------------------------------------- /app/views/common/_favorites.html.erb: -------------------------------------------------------------------------------- 1 | <% if current_user.present? %> 2 | 3 |

    Favorite Gists

    4 | 5 | <% my_favorite_gists.each do |gist| %> 6 |
    7 |   8 | <%= link_to gist.title, gist %> 9 |
    10 | 11 | created <%= time_ago_in_words(gist.created_at) + ' ago' %> 12 | 13 |
    14 | <% end %> 15 | 16 | <%= link_to "More...", user_path(current_user) %> 17 | 18 |
    19 | 20 | <% end %> 21 | -------------------------------------------------------------------------------- /app/models/user.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | class User < ActiveRecord::Base 3 | 4 | validates :omniauth_provider, presence: true 5 | validates :omniauth_uid, presence: true 6 | 7 | has_many :gists, -> { order(:updated_at => :desc) } 8 | has_many :comments, -> { order(:updated_at => :desc) } 9 | 10 | def self.create_with_omniauth(auth) 11 | create! do |user| 12 | user.omniauth_provider = auth['provider'] 13 | user.omniauth_uid = auth['uid'] 14 | user.email = auth['info']['email'] 15 | user.nickname = nil 16 | end 17 | end 18 | 19 | 20 | end 21 | -------------------------------------------------------------------------------- /app/views/comments/_form.html.erb: -------------------------------------------------------------------------------- 1 | <% if current_user.present? %> 2 | <% 3 | @comment ||= Comment.new 4 | %> 5 | <%= simple_form_for [@gist, @comment] do |f| %> 6 | 7 | <%= f.error_notification %> 8 | 9 |
    10 | <%= text_area_tag :body, nil, :rows => 8, :class => 'span8' %> 11 |
    12 | 13 |
    14 | <%= f.submit 'Submit', :class => 'btn btn-primary' %> 15 |
    16 | 17 | <% end %> 18 | <% else %> 19 | Please <%= link_to 'sign in', signin_path %> to comment. 20 | <% end %> 21 | -------------------------------------------------------------------------------- /app/models/gist_history.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | class GistHistory < ActiveRecord::Base 3 | 4 | validates :gist_id, presence: true 5 | 6 | belongs_to :gist 7 | belongs_to :user 8 | 9 | has_many :gist_files 10 | 11 | # Since ActiveRecord 4.0.1, following code doesn't work as expected 12 | #default_scope { order(:id).reverse_order } 13 | default_scope { order(:id => :desc) } 14 | 15 | def gist 16 | Gist.include_private.where(id: gist_id).first 17 | end 18 | 19 | def headline 20 | body = gist_files.first.try(:body) 21 | body.nil? ? '' : body.split("\n").take(3).join("\n") 22 | end 23 | 24 | end 25 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | # Be sure to restart your server when you modify this file. 3 | 4 | # Add new inflection rules using the following format 5 | # (all these examples are active by default): 6 | # ActiveSupport::Inflector.inflections do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | # 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /app/views/gists/_gist_files_input.html.erb: -------------------------------------------------------------------------------- 1 | <% id = gist_file.try(:id) || "new#{Time.now.to_f.to_s.gsub(/\./, '')}" %> 2 |
    3 |
    4 | <%= text_field_tag 'gist_file_names[]', gist_file.try(:name), :placeholder => 'name this file...', :class => 'span8 gist_file_name', :id => "gist_file_names_#{id}"%> 5 |
    6 |
    7 | <%= text_area_tag 'gist_file_bodies[]', gist_file.try(:body), :rows => 15, :class => 'span8 gist_file_body', :id => "gist_file_bodies_#{id}" %> 8 |
    9 | Remove this…
    10 |
    11 | 12 | -------------------------------------------------------------------------------- /spec/routing/users_routing_spec.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | require "spec_helper" 3 | 4 | describe UsersController do 5 | describe "routing" do 6 | 7 | it "routes to #show" do 8 | expect(get("/users/1")).to route_to("users#show", :id => "1") 9 | end 10 | 11 | it "routes to #edit" do 12 | expect(get("/users/1/edit")).to route_to("users#edit", :id => "1") 13 | end 14 | 15 | it "routes to #update" do 16 | expect(put("/users/1")).to route_to("users#update", :id => "1") 17 | end 18 | 19 | it "routes to #destroy" do 20 | expect(delete("/users/1")).to route_to("users#destroy", :id => "1") 21 | end 22 | 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite version 3.x 2 | # gem install sqlite3 3 | # 4 | # Ensure the SQLite 3 gem is defined in your Gemfile 5 | # gem 'sqlite3' 6 | development: 7 | adapter: sqlite3 8 | database: db/development.sqlite3 9 | pool: 5 10 | timeout: 5000 11 | 12 | # Warning: The database defined as "test" will be erased and 13 | # re-generated from your development database when you run "rake". 14 | # Do not set this db to the same as development or production. 15 | test: 16 | adapter: sqlite3 17 | database: db/test.sqlite3 18 | pool: 5 19 | timeout: 5000 20 | 21 | production: 22 | adapter: sqlite3 23 | database: db/production.sqlite3 24 | pool: 5 25 | timeout: 5000 26 | -------------------------------------------------------------------------------- /app/views/common/_mygists.html.erb: -------------------------------------------------------------------------------- 1 | <% if current_user.present? %> 2 | 3 |

    My Gists

    4 | 5 | <% my_gists.each do |gist| %> 6 |
    7 | <% if gist.is_public %> 8 |   9 | <% else %> 10 |   11 | <% end %> 12 | <%= link_to gist.title, gist %> 13 |
    14 | 15 | created <%= time_ago_in_words(gist.created_at) + ' ago' %> 16 | 17 |
    18 | <% end %> 19 | 20 | <%= link_to "More...", user_path(current_user) %> 21 | 22 |
    23 | 24 | <% end %> 25 | -------------------------------------------------------------------------------- /app/views/users/_form.html.erb: -------------------------------------------------------------------------------- 1 |

    Editing User

    2 |
    3 | <%= simple_form_for @user, :html => {:class => 'form-horizontal'} do |f| %> 4 | 5 | <%= render :partial => 'common/flash_notice' %> 6 | <%= f.error_notification %> 7 | 8 |
    9 | <%= f.input :nickname, :input_html => {:class => 'span6'} %> 10 | <%= f.input :omniauth_provider, :input_html => {:class => 'span6'}, :disabled => true %> 11 | <%= f.input :omniauth_uid, :input_html => {:class => 'span6'}, :disabled => true %> 12 |
    13 | 14 |
    15 | <%= f.submit 'Submit', :class => 'btn btn-info' %> 16 | <%= link_to 'Cancel', root_path, :class => 'btn' %> 17 |
    18 | 19 | <% end %> 20 | -------------------------------------------------------------------------------- /app/views/gists/_fork_of.html.erb: -------------------------------------------------------------------------------- 1 | <% if @gist.source_gist.present? %> 2 |
    3 |

    Fork of

    4 | 20 | <% end %> 21 | -------------------------------------------------------------------------------- /app/models/gist_fork_creation.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | class GistForkCreation 3 | include BasicPersistence 4 | 5 | def save!(gist_to_fork, current_user) 6 | transaction do 7 | created_gist = Gist.create!( 8 | title: gist_to_fork.title, 9 | source_gist_id: gist_to_fork.id, 10 | user_id: current_user.try(:id) 11 | ) 12 | created_history = GistHistory.create!(gist_id: created_gist.id) 13 | gist_to_fork.latest_history.gist_files.each do |file| 14 | GistFile.create( 15 | gist_history_id: created_history.id, 16 | name: file.name, 17 | body: file.body 18 | ) 19 | end 20 | created_gist 21 | end 22 | end 23 | 24 | end 25 | -------------------------------------------------------------------------------- /app/controllers/favorites_controller.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | class FavoritesController < ApplicationController 3 | 4 | before_action :login_required 5 | 6 | respond_to :html 7 | 8 | def create 9 | @gist = Gist.find_commentable_gist(params[:gist_id], current_user.try(:id)) 10 | fav = Favorite.new 11 | fav.gist_id = @gist.id 12 | fav.user_id = current_user.id 13 | if fav.save 14 | redirect_to gist_path(@gist.id), notice: 'You liked this gist.' 15 | else 16 | render action: '../gists/show' 17 | end 18 | end 19 | 20 | def destroy 21 | own_fav = Favorite.where(id: params[:id], user_id: current_user.try(:id)).first 22 | destroy_and_redirect_to_gist(own_fav, 'Your love is cancelled.', 'Not found.') 23 | end 24 | 25 | end 26 | -------------------------------------------------------------------------------- /app/views/gists/_forks.html.erb: -------------------------------------------------------------------------------- 1 | <% if @gist.forks.present? %> 2 |
    3 |

    Forks

    4 | 22 | <% end %> 23 | -------------------------------------------------------------------------------- /spec/routing/sessions_routing_spec.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | require "spec_helper" 3 | 4 | describe SessionsController do 5 | describe "routing" do 6 | 7 | it "routes to #start" do 8 | expect(get("/signin")).to route_to("sessions#start") 9 | end 10 | 11 | it "routes to #callback" do 12 | expect(get("/auth/open_id/callback")).to route_to("sessions#create", :provider => 'open_id') 13 | expect(post("/auth/open_id/callback")).to route_to("sessions#create", :provider => 'open_id') 14 | end 15 | 16 | it "routes to #destroy" do 17 | expect(get("/signout")).to route_to("sessions#destroy") 18 | end 19 | 20 | it "routes to #failure" do 21 | expect(get("/auth/failure")).to route_to("sessions#failure") 22 | end 23 | 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /config/locales/simple_form.zh.yml: -------------------------------------------------------------------------------- 1 | zh: 2 | simple_form: 3 | "yes": '确定' 4 | "no": '取消' 5 | required: 6 | text: '必填' 7 | mark: '*' 8 | # You can uncomment the line below if you need to overwrite the whole required html. 9 | # When using html, text and mark won't be used. 10 | # html: '*' 11 | error_notification: 12 | default_message: "请查看以下错误信息:" 13 | # Labels and hints examples 14 | # labels: 15 | # defaults: 16 | # password: 'Password' 17 | # user: 18 | # new: 19 | # email: 'E-mail to sign in.' 20 | # edit: 21 | # email: 'E-mail.' 22 | # hints: 23 | # defaults: 24 | # username: 'User name to sign in.' 25 | # password: 'No special characters, please.' 26 | -------------------------------------------------------------------------------- /config/locales/simple_form.en.yml: -------------------------------------------------------------------------------- 1 | en: 2 | simple_form: 3 | "yes": 'Yes' 4 | "no": 'No' 5 | required: 6 | text: 'required' 7 | mark: '*' 8 | # You can uncomment the line below if you need to overwrite the whole required html. 9 | # When using html, text and mark won't be used. 10 | # html: '*' 11 | error_notification: 12 | default_message: "Please review the problems below:" 13 | # Labels and hints examples 14 | # labels: 15 | # defaults: 16 | # password: 'Password' 17 | # user: 18 | # new: 19 | # email: 'E-mail to sign in.' 20 | # edit: 21 | # email: 'E-mail.' 22 | # hints: 23 | # defaults: 24 | # username: 'User name to sign in.' 25 | # password: 'No special characters, please.' 26 | 27 | -------------------------------------------------------------------------------- /app/views/kaminari/_paginator.html.erb: -------------------------------------------------------------------------------- 1 | <%# The container tag 2 | - available local variables 3 | current_page: a page object for the currently displayed page 4 | num_pages: total number of pages 5 | per_page: number of items to fetch per page 6 | remote: data-remote 7 | paginator: the paginator that renders the pagination tags inside 8 | -%> 9 | <%= paginator.render do -%> 10 | 23 | <% end -%> 24 | -------------------------------------------------------------------------------- /config/initializers/client_side_validations.rb: -------------------------------------------------------------------------------- 1 | # -*- encoding : utf-8 -*- 2 | # ClientSideValidations Initializer 3 | 4 | # Uncomment to disable uniqueness validator, possible security issue 5 | # ClientSideValidations::Config.disabled_validators = [:uniqueness] 6 | 7 | # Uncomment to validate number format with current I18n locale 8 | # ClientSideValidations::Config.number_format_with_locale = true 9 | 10 | # Uncomment the following block if you want each input field to have the validation messages attached. 11 | ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| 12 | unless html_tag =~ /^