Created
April 25, 2017 16:52
-
-
Save lajunta/bc53e82eac9eecee09d4867d65110ab6 to your computer and use it in GitHub Desktop.
new ror template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ProxyChains-3.1 (http://proxychains.sf.net) | |
run("rm Gemfile") | |
run("touch Gemfile") | |
add_source "https://gems.ruby-china.org/" | |
gem 'rails' | |
gem 'sass-rails' | |
gem 'slim-rails' | |
#gem 'bulma-rails' | |
gem 'dalli' | |
gem 'bson' | |
gem 'rucaptcha' | |
gem 'mongoid' | |
gem 'kaminari' | |
gem 'kaminari-mongoid' | |
gem 'puma' | |
gem 'bootstrap-sass' | |
gem 'font-awesome-sass' | |
gem 'lwqzx' | |
gem 'zbox' | |
gem 'mongo_grid', '0.2.6' | |
gem 'uglifier' | |
gem 'coffee-rails' | |
gem 'turbolinks' | |
gem 'jbuilder' | |
gem 'jquery-rails' | |
gem 'bcrypt' | |
gem_group :development, :test do | |
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] | |
gem 'capybara' | |
gem 'selenium-webdriver' | |
end | |
gem_group :development do | |
gem 'web-console' | |
gem 'listen' | |
gem 'spring' | |
gem 'spring-watcher-listen' | |
end | |
route %q(root to: 'welcome#index') | |
route %q(get "download/:id" => "grid#download" , :as=>:download) | |
route %q(get "see/:id" => "grid#see" , :as=>:see) | |
puts "初始化 mongo_grid " | |
initializer 'mongo_grid.rb', <<-CODE | |
name = Rails.application.class.parent.to_s.downcase | |
MongoGrid.configure do |config| | |
config.db_name = name+"_"+Rails.env | |
config.db_url = "127.0.0.1:27017" | |
end | |
CODE | |
puts "初始化 rucaptcha " | |
initializer 'rucaptcha.rb', <<-CODE | |
RuCaptcha.configure do | |
self.cache_store = :mem_cache_store | |
end | |
CODE | |
puts "设置环境" | |
puts "--------------------------------------------------------" | |
environment "Mongoid::QueryCache.enabled = true" | |
environment "Slim::Engine.options[:pretty] = true" | |
puts "更改 application.css " | |
puts "--------------------------------------------------------" | |
run("rm app/assets/stylesheets/application.css") | |
file "app/assets/stylesheets/application.scss", <<-CODE | |
/* | |
*= require_tree . | |
*= require_self | |
*/ | |
@import "bootstrap-sprockets"; | |
@import "bootstrap"; | |
@import "font-awesome-sprockets"; | |
@import "font-awesome"; | |
CODE | |
puts "更改 application.js " | |
puts "--------------------------------------------------------" | |
run("rm app/assets/javascripts/application.js") | |
file "app/assets/javascripts/application.js", <<-CODE | |
//= require jquery | |
//= require bootstrap-sprockets | |
//= require jquery_ujs | |
//= require_tree . | |
$(document).ready(function(){ | |
}); | |
//= require turbolinks | |
CODE | |
puts "设置 mongoid , kaminari" | |
puts "--------------------------------------------------------" | |
#app_name=ask("应用名称是什么?") | |
run("rails g mongoid:config") | |
generate("kaminari:config") | |
#generate("kaminari:views bootstrap3") | |
generate(:controller, "welcome","home","index") | |
puts "生成 grid controller" | |
puts "--------------------------------------------------------" | |
file "app/controllers/grid_controller.rb", <<-CODE | |
class GridController < ApplicationController | |
layout nil | |
def download(gid=params[:id]) | |
id = BSON::ObjectId.from_string(gid) | |
file=MongoGrid.grid.find_one(_id: id) | |
type = file.info.metadata[:content_type] | |
send_data file.data, :filename => file.filename, :type=>type,:disposition => "attach" | |
end | |
def see(gid=params[:id]) | |
id = BSON::ObjectId.from_string(gid) | |
file=MongoGrid.grid.find_one(_id: id) | |
type = file.info.metadata[:content_type] | |
response.header["Accept-Ranges"]= "bytes" | |
response.header["Content-Transfer-Encoding"] = "binary" | |
send_data file.data, :filename => file.filename,\ | |
:type=>type,:disposition => "inline", stream: true,buffer_size: 4096 | |
end | |
end | |
CODE | |
puts "post setup" | |
puts "--------------------------------------------------------" | |
after_bundle do | |
git :init | |
git add: "." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment