rocket_cms 0.1.13 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed1a64eb57baf03872734690527a98a0e18941ad
4
- data.tar.gz: 86cf1d01b615448a3614335bbd3f082cc252191b
3
+ metadata.gz: 95971eec71ab1ccd3dde678684018ba68aeb7a46
4
+ data.tar.gz: 057425d0d665bf2e6168e652de3e14be7671f09f
5
5
  SHA512:
6
- metadata.gz: f488b1b964d7aec6568244a537d1c77d07ac86846e5d8e82ba56838390c10da9597c7c27ebab134b781f1161e84c98390c57d0434bfcf0b9b67fef64b85da246
7
- data.tar.gz: 3bcc95ae984e863f9564a45a0132c43ac4d815a6f09624e52778ab9d489be73ba4210c6d34e7a9bf54a5567bb10806ccdf5a66f155f8a0d9ea4ef76070c0c247
6
+ metadata.gz: c33fef7e1df446f2f5d728c097187fc74cc963b024d3d2625dd6e15472f661f00bf083e81f3ca32862b4278c76a85ea510f625c993e573c758b65c2faffc59fc
7
+ data.tar.gz: d91076a1b71e42e2148c8028774097e9c2f1c51a7b274fe8e00ee4eecea1d2bc269eb5bcbea0f655938095eeef51e0f70a00a808f33c49cf3855e27a118f3737
data/README.md CHANGED
@@ -25,7 +25,28 @@ Or install it yourself as:
25
25
 
26
26
  ## Usage
27
27
 
28
- TODO: Write usage instructions here
28
+ ### Using app generator
29
+
30
+ Make sure you have rails 4.1 installed
31
+
32
+ rails -v
33
+
34
+ If not, uninstall rails and install again
35
+
36
+ gem uninstall rails
37
+ gem install rocket_cms
38
+
39
+ Then run:
40
+
41
+ rails new my_app -T -O -m https://raw.github.com/rs-pro/rocket_cms/master/template.rb
42
+
43
+ generator creates a new RVM gemset, so after cd'ing to app dir, you should run `bundle install` again if you use rvm.
44
+
45
+ ### Documentation
46
+
47
+ It's basically Mongoid + Rails Admin + some of our common models and controllers, capistrano config, etc.
48
+
49
+ See their documentation for more info
29
50
 
30
51
  ## Contributing
31
52
 
@@ -1,2 +1,6 @@
1
1
  @import rocket_cms/*.sass
2
2
  @import rocket_cms/*.scss
3
+
4
+ html
5
+ -moz-font-smoothing: antialiased
6
+ -webkit-font-smoothing: antialiased
@@ -1,29 +1,3 @@
1
1
  class ContactsController < ApplicationController
2
- def new
3
- @contact_message = ContactMessage.new
4
- end
5
-
6
- def create
7
- @contact_message = ContactMessage.new(message_params)
8
- if RocketCMS.configuration.contacts_captcha
9
- meth = :save_with_captcha
10
- else
11
- meth = :save
12
- end
13
-
14
- if @contact_message.send(meth)
15
- redirect_to :contacts_sent
16
- else
17
- flash.now[:alert] = @contact_message.errors.full_messages.join("\n")
18
- render action: "new"
19
- end
20
- end
21
-
22
- def sent
23
- end
24
-
25
- private
26
- def message_params
27
- params.require(:contact_message).permit(RocketCMS.configuration.contacts_fields.keys + [:name, :email, :phone, :content, :captcha, :captcha_key])
28
- end
2
+ include RocketCMS::Controllers::Contacts
29
3
  end
@@ -0,0 +1,5 @@
1
+ class HomeController < ApplicationController
2
+ def index
3
+ end
4
+ end
5
+
@@ -1,22 +1,3 @@
1
1
  class NewsController < ApplicationController
2
- def index
3
- @news = News.enabled.after_now.by_date
4
-
5
- unless RocketCMS.configuration.news_per_page.nil?
6
- @news = @news.page(params[:page])
7
- end
8
- end
9
-
10
- def show
11
- @news = News.after_now.find(params[:id])
12
- end
13
-
14
- private
15
- def page_title
16
- if @news.class.name == 'News'
17
- @news.page_title
18
- else
19
- super
20
- end
21
- end
2
+ include RocketCMS::Controllers::News
22
3
  end
@@ -1,12 +1,4 @@
1
1
  class PagesController < ApplicationController
2
- def show
3
- if @seo_page.nil? || !@seo_page.persisted?
4
- unless params[:id].blank?
5
- @seo_page = Page.enabled.find(params[:id])
6
- end
7
- end
8
- if @seo_page.nil?
9
- render_404
10
- end
11
- end
2
+ include RocketCMS::Controllers::Pages
12
3
  end
4
+
@@ -1,25 +1,3 @@
1
1
  class SearchController < ApplicationController
2
- def index
3
- if params[:query].blank?
4
- @results = []
5
- else
6
- @results = Mongoid::Elasticsearch.search({
7
- body: {
8
- query: {
9
- query_string: {
10
- query: Mongoid::Elasticsearch::Utils.clean(params[:query])
11
- }
12
- },
13
- highlight: {
14
- fields: {
15
- name: {},
16
- content: {}
17
- }
18
- }
19
- }},
20
- page: params[:page],
21
- per_page: RocketCMS.configuration.search_per_page,
22
- )
23
- end
24
- end
2
+ include RocketCMS::Controllers::Search
25
3
  end
@@ -7,7 +7,7 @@ class Ckeditor::Picture < Ckeditor::Asset
7
7
  validates_attachment_content_type :data, :content_type => ['image/gif', 'image/jpeg', 'image/jpg', 'image/png'], if: :data?
8
8
  end
9
9
 
10
- validates_attachment_size :data, :less_than => 2.megabytes
10
+ validates_attachment_size :data, :less_than => 10.megabytes
11
11
  validates_attachment_presence :data
12
12
 
13
13
  def url_content
@@ -0,0 +1 @@
1
+ (c) 2014 etc
@@ -0,0 +1 @@
1
+ RocketCMS test app
@@ -0,0 +1,23 @@
1
+ %html lang="ru"
2
+ %head
3
+ %meta charset="UTF-8"
4
+ %meta name="viewport" content="width=device-width, maximum-scale=1"
5
+ %title= page_title
6
+ = yield :meta
7
+ = csrf_meta_tags
8
+ = favicon_link_tag '/favicon.ico'
9
+ = stylesheet_link_tag "application", media: "all"
10
+ = javascript_include_tag "application"
11
+ /[if lt IE 9]
12
+ = javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"
13
+ %body
14
+ #root
15
+ = render 'shared/messages'
16
+ #sidebar
17
+ = render_navigation &navigation(:main)
18
+ #content
19
+ = yield
20
+ #root_footer
21
+ #footer
22
+ = render 'blocks/footer'
23
+
@@ -0,0 +1,24 @@
1
+ doctype html
2
+ html lang="ru"
3
+ head
4
+ meta charset="UTF-8"
5
+ meta name="viewport" content="width=device-width, maximum-scale=1"
6
+ title= page_title
7
+ = yield :meta
8
+ = csrf_meta_tags
9
+ = favicon_link_tag '/favicon.ico'
10
+ = stylesheet_link_tag "application", media: "all"
11
+ = javascript_include_tag "application"
12
+ /[if lt IE 9]
13
+ = javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js"
14
+ body
15
+ #root
16
+ = render 'shared/messages'
17
+ #sidebar
18
+ = render_navigation &navigation(:main)
19
+ #content
20
+ = yield
21
+ #root_footer
22
+ #footer
23
+ = render 'blocks/footer'
24
+
@@ -3,12 +3,15 @@
3
3
  - unless obj.h1.blank?
4
4
  %h1= obj.h1
5
5
  - if obj.content.blank?
6
- = raw @seo_page.page_content unless @seo_page.nil?
7
- = render 'shared/admin_link', obj: @seo_page
6
+ - unless @seo_page.nil?
7
+ = raw @seo_page.page_content
8
+ = render 'shared/admin_link', obj: @seo_page
8
9
  - else
9
10
  = raw obj.content
11
+ - if !obj.nil? && (@seo_page.nil? || obj.id != @seo_page.id || obj.class.name != @seo_page.class.name)
10
12
  = render 'shared/admin_link', obj: obj
11
13
 
12
14
  - content_for :meta do
13
15
  = render 'shared/meta', obj: obj
14
16
  = render 'shared/og', title: obj.get_og_title, image: obj.og_image
17
+
@@ -1,6 +1,6 @@
1
- en:
1
+ ru:
2
2
  admin:
3
3
  actions:
4
4
  custom_show_in_app:
5
- title: 'В приложении'
5
+ title: 'На сайте'
6
6
  menu: "Показать на сайте"
@@ -0,0 +1,15 @@
1
+ require 'rails/generators'
2
+ require File.expand_path('../utils', __FILE__)
3
+
4
+ module RocketCms
5
+ class AbilityGenerator < Rails::Generators::Base
6
+ source_root File.expand_path('../templates', __FILE__)
7
+ include Generators::Utils::InstanceMethods
8
+
9
+ desc 'RocketCMS CanCan Ability config generator'
10
+ def ability
11
+ template 'ability.erb', 'app/models/ability.rb'
12
+ end
13
+ end
14
+ end
15
+
@@ -8,11 +8,12 @@ module RocketCms
8
8
  source_root File.expand_path('../templates', __FILE__)
9
9
  include Generators::Utils::InstanceMethods
10
10
 
11
- argument :_namespace, type: :string, required: false, desc: 'RailsAdmin url namespace'
11
+ #argument :_namespace, type: :string, required: false, desc: 'RailsAdmin url namespace'
12
12
  desc 'RocketCMS RailsAdmin config generator'
13
13
 
14
14
  def install
15
- namespace = ask_for('Where do you want to mount rails_admin?', 'admin', _namespace)
15
+ #namespace = ask_for('Where do you want to mount rails_admin?', 'admin', _namespace)
16
+ namespace = 'admin'
16
17
  route("mount RailsAdmin::Engine => '/#{namespace}', as: 'rails_admin'")
17
18
  template 'admin.erb', 'config/initializers/rails_admin.rb'
18
19
  end
@@ -0,0 +1,15 @@
1
+ require 'rails/generators'
2
+ require File.expand_path('../utils', __FILE__)
3
+
4
+ module RocketCms
5
+ class LayoutGenerator < Rails::Generators::Base
6
+ source_root File.expand_path("../../../..", __FILE__)
7
+ include Generators::Utils::InstanceMethods
8
+
9
+ desc 'RocketCMS Layout generator'
10
+ def layout
11
+ template('app/views/layouts/application.html.slim', 'app/views/layouts/application.html.slim')
12
+ end
13
+ end
14
+ end
15
+
@@ -45,6 +45,7 @@ RailsAdmin.config do |config|
45
45
  end
46
46
 
47
47
  toggle
48
+ toggle_menu
48
49
  end
49
50
 
50
51
  config.main_app_name = ['<%= Rails.application.class.name.split('::')[0] %>', 'Админка']
@@ -68,4 +69,4 @@ module RailsAdmin
68
69
  end
69
70
  end
70
71
  end
71
- end
72
+ end
@@ -54,4 +54,11 @@ module RocketCMS
54
54
  autoload :News, 'rocket_cms/models/news'
55
55
  autoload :ContactMessage, 'rocket_cms/models/contact_message'
56
56
  end
57
+
58
+ module Controllers
59
+ autoload :Contacts, 'rocket_cms/controllers/contacts'
60
+ autoload :News, 'rocket_cms/controllers/news'
61
+ autoload :Pages, 'rocket_cms/controllers/pages'
62
+ autoload :Search, 'rocket_cms/controllers/search'
63
+ end
57
64
  end
@@ -0,0 +1,42 @@
1
+ module RocketCMS
2
+ module Controllers
3
+ module Contacts
4
+ extend ActiveSupport::Concern
5
+ def new
6
+ @contact_message = ContactMessage.new
7
+ after_initialize
8
+ end
9
+
10
+ def create
11
+ @contact_message = ContactMessage.new(message_params)
12
+ after_initialize
13
+ if RocketCMS.configuration.contacts_captcha
14
+ meth = :save_with_captcha
15
+ else
16
+ meth = :save
17
+ end
18
+ if @contact_message.send(meth)
19
+ after_create
20
+ redirect_to :contacts_sent
21
+ else
22
+ flash.now[:alert] = @contact_message.errors.full_messages.join("\n")
23
+ render action: "new"
24
+ end
25
+ end
26
+
27
+ def sent
28
+ end
29
+
30
+ private
31
+ def after_initialize
32
+ # overrideable hook for updating message
33
+ end
34
+ def after_create
35
+ # overrideable hook for updating message
36
+ end
37
+ def message_params
38
+ params.require(:contact_message).permit(RocketCMS.configuration.contacts_fields.keys + [:name, :email, :phone, :content, :captcha, :captcha_key])
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,31 @@
1
+ module RocketCMS
2
+ module Controllers
3
+ module News
4
+ extend ActiveSupport::Concern
5
+
6
+ def index
7
+ @news = model.enabled.after_now.by_date
8
+
9
+ unless RocketCMS.configuration.news_per_page.nil?
10
+ @news = @news.page(params[:page])
11
+ end
12
+ end
13
+
14
+ def show
15
+ @news = model.after_now.find(params[:id])
16
+ end
17
+
18
+ private
19
+ def model
20
+ ::News
21
+ end
22
+ def page_title
23
+ if @news.class.name == 'News'
24
+ @news.page_title
25
+ else
26
+ super
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,18 @@
1
+ module RocketCMS
2
+ module Controllers
3
+ module Pages
4
+ extend ActiveSupport::Concern
5
+ def show
6
+ if @seo_page.nil? || !@seo_page.persisted?
7
+ unless params[:id].blank?
8
+ @seo_page = Page.enabled.find(params[:id])
9
+ end
10
+ end
11
+ if @seo_page.nil?
12
+ render_404
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -0,0 +1,30 @@
1
+ module RocketCMS
2
+ module Controllers
3
+ module Search
4
+ extend ActiveSupport::Concern
5
+ def index
6
+ if params[:query].blank?
7
+ @results = []
8
+ else
9
+ @results = Mongoid::Elasticsearch.search({
10
+ body: {
11
+ query: {
12
+ query_string: {
13
+ query: Mongoid::Elasticsearch::Utils.clean(params[:query])
14
+ }
15
+ },
16
+ highlight: {
17
+ fields: {
18
+ name: {},
19
+ content: {}
20
+ }
21
+ }
22
+ }},
23
+ page: params[:page],
24
+ per_page: RocketCMS.configuration.search_per_page,
25
+ )
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -25,6 +25,7 @@ module RocketCMS
25
25
  end
26
26
 
27
27
  RocketCMS.configuration.contacts_fields.each_pair do |fn, ft|
28
+ next if ft.nil?
28
29
  field fn, type: ft
29
30
  end
30
31
 
@@ -1,14 +1,13 @@
1
1
  # require this file to load the tasks
2
2
  require 'rake'
3
3
 
4
- # Require sitemap_generator at runtime. If we don't do this the ActionView helpers are included
4
+ # Require generator at runtime. If we don't do this the ActionView helpers are included
5
5
  # before the Rails environment can be loaded by other Rake tasks, which causes problems
6
6
  # for those tasks when rendering using ActionView.
7
7
  namespace :rs do
8
- # Require sitemap_generator only. When installed as a plugin the require will fail, so in
8
+ # Require generator only. When installed as a plugin the require will fail, so in
9
9
  # that case, load the environment first.
10
10
  task :require do
11
11
  Rake::Task['environment'].invoke
12
12
  end
13
-
14
13
  end
@@ -1,3 +1,3 @@
1
1
  module RocketCms
2
- VERSION = "0.1.13"
2
+ VERSION = "0.2.10"
3
3
  end
@@ -21,10 +21,11 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency 'bundler'
22
22
  spec.add_development_dependency 'rake'
23
23
 
24
+ spec.add_dependency 'rails', '~> 4.1.4'
24
25
  spec.add_dependency 'mongoid', '~> 4.0.0.beta1'
25
26
  spec.add_dependency 'jquery-rails'
26
27
  spec.add_dependency 'glebtv-mongoid_nested_set'
27
- spec.add_dependency 'simple_form', '~> 3.0'
28
+ spec.add_dependency 'simple_form'
28
29
  spec.add_dependency 'glebtv-simple_captcha'
29
30
  spec.add_dependency 'htmlentities'
30
31
  spec.add_dependency 'sanitize'
@@ -47,4 +48,6 @@ Gem::Specification.new do |spec|
47
48
  spec.add_dependency 'sitemap_generator'
48
49
  spec.add_dependency 'kaminari'
49
50
  spec.add_dependency 'addressable'
51
+ spec.add_dependency 'thor'
52
+ spec.add_dependency 'uglifier'
50
53
  end
@@ -0,0 +1,511 @@
1
+ rails_spec = (Gem.loaded_specs["railties"] || Gem.loaded_specs["rails"])
2
+ version = rails_spec.version.to_s
3
+
4
+ if Gem::Version.new(version) < Gem::Version.new('4.1.0')
5
+ puts "You are using an old version of Rails (#{version})"
6
+ puts "Please update"
7
+ puts "Stopping"
8
+ exit 1
9
+ end
10
+
11
+ remove_file 'Gemfile'
12
+ create_file 'Gemfile' do <<-TEXT
13
+ source 'https://rubygems.org'
14
+
15
+ gem 'spring', group: 'development'
16
+
17
+ TEXT
18
+ end
19
+
20
+ remove_file '.gitignore'
21
+ create_file '.gitignore' do <<-TEXT
22
+ # See https://help.github.com/articles/ignoring-files for more about ignoring files.
23
+ #
24
+ # If you find yourself ignoring temporary files generated by your text editor
25
+ # or operating system, you probably want to add a global ignore instead:
26
+ # git config --global core.excludesfile '~/.gitignore_global'
27
+
28
+ /.bundle
29
+ /log/*.log
30
+ /tmp
31
+ /public/system
32
+ /public/ckeditor_assets
33
+ /public/assets
34
+ /config/mongoid.yml
35
+ /config/sectets.yml
36
+ TEXT
37
+ end
38
+
39
+ create_file 'extra/.gitkeep' do <<-TEXT
40
+ TEXT
41
+ end
42
+
43
+ remove_file 'config/initializers/cookies_serializer.rb'
44
+ create_file 'config/initializers/cookies_serializer.rb' do <<-TEXT
45
+ # Be sure to restart your server when you modify this file.
46
+ # json serializer breaks Devise + Mongoid. DO NOT ENABLE
47
+ # See https://github.com/plataformatec/devise/pull/2882
48
+ # Rails.application.config.action_dispatch.cookies_serializer = :json
49
+ Rails.application.config.action_dispatch.cookies_serializer = :marshal
50
+ TEXT
51
+ end
52
+
53
+
54
+
55
+ remove_file 'app/controllers/application_controller.rb'
56
+ create_file 'app/controllers/application_controller.rb' do <<-TEXT
57
+ class ApplicationController < ActionController::Base
58
+ include RocketCMS::Controller
59
+ end
60
+ TEXT
61
+ end
62
+
63
+ create_file 'config/navigation.rb' do <<-TEXT
64
+ # empty file to please simple_navigation, we are not using it
65
+ # See https://github.com/rs-pro/rocket_cms/blob/master/app/controllers/concerns/rs_menu.rb
66
+ TEXT
67
+ end
68
+
69
+ #gsub_file 'Gemfile', /^(.*)sass-rails(.*)$/, ''
70
+
71
+ gem 'rails', '4.1.4'
72
+
73
+ gem 'mongoid', '~> 4.0.0'
74
+ gem 'sass', '~> 3.3.9'
75
+
76
+ gem 'rocket_cms'
77
+
78
+ gem 'sass-rails', github: 'rails/sass-rails', ref: '3a9e47db7d769221157c82229fc1bade55b580f0'
79
+ gem 'compass-rails', '~> 2.0.0'
80
+ gem 'compass', '~> 1.0.0.alpha.20'
81
+ gem 'slim-rails'
82
+ gem 'rs_russian'
83
+ gem 'sentry-raven'
84
+ gem 'cancancan'
85
+
86
+ gem_group :development do
87
+ gem 'better_errors'
88
+ gem 'binding_of_caller'
89
+ gem 'pry-rails'
90
+ gem 'capistrano', '~> 3.2.0', require: false
91
+ gem 'rvm1-capistrano3', require: false
92
+ gem 'glebtv-capistrano-unicorn', require: false
93
+ gem 'capistrano-bundler', require: false
94
+ gem 'capistrano-rails', require: false
95
+ gem 'capistrano-rails-console'
96
+ gem 'hipchat'
97
+ gem 'coffee-rails-source-maps'
98
+ gem 'compass-rails-source-maps'
99
+ end
100
+
101
+ gem_group :test do
102
+ #gem 'capybara'
103
+ #gem 'poltergeist'
104
+ #gem 'simplecov', require: false
105
+ gem 'rspec-rails'
106
+ gem 'database_cleaner'
107
+ gem 'email_spec'
108
+ gem 'glebtv-mongoid-rspec'
109
+ #gem 'rspec-collection_matchers'
110
+ #gem 'timecop'
111
+ gem 'ffaker'
112
+ gem 'factory_girl_rails'
113
+ end
114
+
115
+ remove_file 'config/routes.rb'
116
+ create_file 'config/routes.rb' do <<-TEXT
117
+ Rails.application.routes.draw do
118
+ end
119
+ TEXT
120
+ end
121
+
122
+ application "config.i18n.enforce_available_locales = true"
123
+ application "config.i18n.available_locales = [:ru, :en]"
124
+ application "config.i18n.default_locale = :ru"
125
+ application "config.i18n.locale = :ru"
126
+
127
+ application 'config.autoload_paths += %W(#{config.root}/extra)'
128
+ application 'config.eager_load_paths += %W(#{config.root}/extra)'
129
+
130
+ application 'config.time_zone = "Europe/Moscow"'
131
+ application 'config.assets.paths << Rails.root.join("app", "assets", "fonts")'
132
+
133
+ create_file 'README.md', "## Project generated by RocketCMS\n\n"
134
+
135
+ create_file '.ruby-version', "#{RUBY_VERSION}\n"
136
+ create_file '.ruby-gemset', "#{app_name}\n"
137
+
138
+ run 'bundle install --without production'
139
+ # generate "mongoid:config"
140
+
141
+ create_file 'config/mongoid.yml' do <<-TEXT
142
+ development:
143
+ sessions:
144
+ default:
145
+ database: #{app_name.downcase}_development
146
+ hosts:
147
+ - localhost:27017
148
+ test:
149
+ sessions:
150
+ default:
151
+ database: #{app_name.downcase}_test
152
+ hosts:
153
+ - localhost:27017
154
+ TEXT
155
+ end
156
+
157
+ generate "devise:install"
158
+ generate "devise", "User"
159
+ gsub_file 'app/models/user.rb', '# :confirmable, :lockable, :timeoutable and :omniauthable', '# :confirmable, :registerable, :timeoutable and :omniauthable'
160
+ gsub_file 'app/models/user.rb', ':registerable,', ' :lockable,'
161
+ gsub_file 'app/models/user.rb', '# field :failed_attempts', 'field :failed_attempts'
162
+ gsub_file 'app/models/user.rb', '# field :unlock_token', 'field :unlock_token'
163
+ gsub_file 'app/models/user.rb', '# field :locked_at', 'field :locked_at'
164
+
165
+ route "mount Ckeditor::Engine => '/ckeditor'"
166
+ generate "rocket_cms:admin"
167
+ generate "rocket_cms:ability"
168
+ generate "rocket_cms:layout"
169
+
170
+ generate "rspec:install"
171
+
172
+ route "root 'home#index'"
173
+ route "get '*slug' => 'pages#show'"
174
+ route "resources :pages, only: [:show]"
175
+
176
+ route "get 'search' => 'search#index', as: :search"
177
+
178
+ route "get 'contacts/sent' => 'contacts#sent', as: :contacts_sent"
179
+ route "post 'contacts' => 'contacts#create', as: :create_contacts"
180
+ route "get 'contacts' => 'contacts#new', as: :contacts"
181
+
182
+ route "resources :news, only: [:index, :show]"
183
+
184
+ gsub_file 'config/application.rb', /^(.*)config.time_zone(.*)$/, "config.time_zone = 'Europe/Moscow'"
185
+
186
+ #capify!
187
+
188
+ remove_file 'db/seeds.rb'
189
+ admin_pw = (0...8).map { (65 + rand(26)).chr }.join
190
+ create_file 'db/seeds.rb' do <<-TEXT
191
+ admin_pw = "#{admin_pw}"
192
+ User.destroy_all
193
+ User.create!(email: 'admin@#{app_name.downcase}.ru', password: admin_pw, password_confirmation: admin_pw)
194
+ TEXT
195
+ end
196
+
197
+ remove_file 'Capfile'
198
+ create_file 'Capfile' do <<-TEXT
199
+ # Load DSL and Setup Up Stages
200
+ require 'capistrano/setup'
201
+
202
+ # Includes default deployment tasks
203
+ require 'capistrano/deploy'
204
+
205
+ require 'rvm1/capistrano3'
206
+ require 'capistrano/bundler'
207
+ require 'capistrano/rails/assets'
208
+ #require "whenever/capistrano"
209
+
210
+ require 'capistrano/unicorn'
211
+
212
+ require 'capistrano/rails/console'
213
+
214
+ # Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
215
+ Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }
216
+ TEXT
217
+ end
218
+
219
+ remove_file 'public/robots.txt'
220
+ create_file 'public/robots.txt' do <<-TEXT
221
+ User-Agent: *
222
+ Disallow: /
223
+ TEXT
224
+ end
225
+
226
+ port = rand(100..999) * 10
227
+
228
+ create_file 'unicorn.conf' do <<-TEXT
229
+ listen #{port}
230
+ worker_processes 1
231
+ timeout 120
232
+ TEXT
233
+ end
234
+
235
+ create_file 'config/unicorn.rb' do <<-TEXT
236
+ rails_env = ENV['RAILS_ENV'] || 'production'
237
+
238
+ deploy_to = "/data/#{app_name.downcase}/app"
239
+ #{'rails_root = "#{deploy_to}/current"'}
240
+
241
+ #{'tmp_dir = "#{deploy_to}/shared/tmp"
242
+ pid_dir = "#{tmp_dir}/pids"
243
+ if File.directory?(tmp_dir) && !File.directory?(pid_dir)
244
+ puts "creating pid dir #{pid_dir}"
245
+ Dir.mkdir(pid_dir)
246
+ end
247
+ pid_file = "#{pid_dir}/unicorn.pid"'}
248
+
249
+ #{'log_file = "#{deploy_to}/shared/log/unicorn.log"'}
250
+ #{'err_log_file = "#{deploy_to}/shared/log/unicorn.error.log"'}
251
+
252
+ old_pid_file = pid_file + '.oldbin'
253
+
254
+ worker_processes 1
255
+ working_directory rails_root
256
+
257
+ timeout 120
258
+
259
+ # Specify path to socket unicorn listens to,
260
+ # we will use this in our nginx.conf later
261
+
262
+ listen "127.0.0.1:#{port}"
263
+
264
+ pid pid_file
265
+
266
+ # Set log file paths
267
+ stderr_path err_log_file
268
+ stdout_path log_file
269
+
270
+ # http://tech.tulentsev.com/2012/03/deploying-with-sinatra-capistrano-unicorn/
271
+ # NOTE: http://unicorn.bogomips.org/SIGNALS.html
272
+ preload_app true
273
+
274
+ # make sure that Bundler finds the Gemfile
275
+ before_exec do |server|
276
+ ENV['BUNDLE_GEMFILE'] = File.join( rails_root, 'Gemfile' )
277
+ end
278
+
279
+ before_fork do |server, worker|
280
+ # при использовании preload_app = true здесь должно быть закрытие всех открытых сокетов
281
+
282
+ # Mongoid сам заботится о переконнекте
283
+ # http://two.mongoid.org/docs/upgrading.html
284
+
285
+ # http://stackoverflow.com/a/9498372/2041969
286
+ # убиваем параллельный старый-процесс просле старта нового
287
+ if File.exists?( old_pid_file )
288
+ begin
289
+ Process.kill( "QUIT", File.read( old_pid_file ).to_i )
290
+ rescue Errno::ENOENT, Errno::ESRCH
291
+ puts "Old master alerady dead"
292
+ end
293
+ end
294
+ end
295
+
296
+ after_fork do |server, worker|
297
+ # pid-ы дочерних процессов
298
+ #{'child_pid_file = server.config[:pid].sub(".pid", ".#{worker.nr}.pid")'}
299
+ #{'system( "echo #{Process.pid} > #{child_pid_file}" )'}
300
+ end= ENV['RAILS_ENV'] || 'production'
301
+ TEXT
302
+ end
303
+
304
+ create_file 'config/deploy.rb' do <<-TEXT
305
+ set :user, "#{app_name.downcase}"
306
+ set :application, '#{app_name.downcase}'
307
+ set :scm, :git
308
+ set :repo_url, 'git@github.com:rs-pro/#{app_name.downcase}.git'
309
+
310
+ # ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
311
+ set :branch, ENV["REVISION"] || ENV["BRANCH_NAME"] || "master"
312
+
313
+ #{'set :deploy_to, "/data/#{fetch :application}/app"'}
314
+
315
+ # require 'hipchat/capistrano'
316
+ # set :hipchat_token, ""
317
+ # set :hipchat_room_name, "#{app_name}"
318
+ # set :hipchat_announce, false
319
+
320
+ set :rvm_type, :user
321
+ #{'set :rvm_ruby_version, "2.1.2@#{fetch :application}"'}
322
+ set :use_sudo, false
323
+
324
+ set :keep_releases, 20
325
+
326
+ set :linked_files, %w{config/mongoid.yml config/secrets.yml}
327
+ set :linked_dirs, %w{log tmp vendor/bundle public/assets public/system public/uploads public/ckeditor_assets public/sitemap}
328
+
329
+ namespace :db do
330
+ desc "Create the indexes defined on your mongoid models"
331
+ task :create_mongoid_indexes do
332
+ on roles(:app) do
333
+ execute :rake, "db:mongoid:create_indexes"
334
+ end
335
+ end
336
+ end
337
+
338
+ namespace :deploy do
339
+ task :restart do
340
+ end
341
+ #after :finishing, 'deploy:cleanup'
342
+ desc "Update the crontab"
343
+ task :update_crontab do
344
+ on roles(:app) do
345
+ #{'execute "cd #{release_path}; #{fetch(:tmp_dir)}/#{fetch :application}/rvm-auto.sh . bundle exec whenever --update-crontab #{fetch :user} --set \'environment=#{fetch :stage}&current_path=#{release_path}\'; true"'}
346
+ end
347
+ end
348
+ end
349
+
350
+ after 'deploy:publishing', 'deploy:restart'
351
+ after 'deploy:restart', 'unicorn:duplicate'
352
+ # before "deploy:update_crontab", 'rvm1:hook'
353
+ # after "deploy:restart", "deploy:update_crontab"
354
+ TEXT
355
+ end
356
+
357
+ create_file 'config/deploy/production.rb' do <<-TEXT
358
+ set :stage, :production
359
+
360
+ server 'rscz.ru', user: '#{app_name.downcase}', roles: %w{web app db}
361
+
362
+ set :rails_env, 'production'
363
+ set :unicorn_env, 'production'
364
+ set :unicorn_rack_env, 'production'
365
+ TEXT
366
+ end
367
+
368
+ create_file 'lib/tasks/dl.thor' do <<-TEXT
369
+ class Dl < Thor
370
+ package_name "dl"
371
+ include Thor::Actions
372
+
373
+ no_commands do
374
+ def load_env
375
+ return if defined?(Rails)
376
+ require File.expand_path("../../../config/environment", __FILE__)
377
+ end
378
+
379
+ def env_from
380
+ 'production'
381
+ end
382
+ def ssh_host
383
+ '#{app_name.downcase}.ru'
384
+ end
385
+ def ssh_user
386
+ '#{app_name.downcase}'
387
+ end
388
+ def ssh_opts
389
+ {}
390
+ end
391
+
392
+ def remote_dump_path
393
+ '/data/#{app_name.downcase}/tmp_dump'
394
+ end
395
+ def remote_app_path
396
+ "/data/#{app_name.downcase}/app/current"
397
+ end
398
+
399
+ def local_auth(conf)
400
+ if conf['password'].nil?
401
+ ""
402
+ else
403
+ #{'"-u #{conf["username"]} -p #{conf["password"]}]"'}
404
+ end
405
+ end
406
+ end
407
+
408
+ desc "download", "clone files and DB from production"
409
+ def download
410
+ load_env
411
+ require 'net/ssh'
412
+
413
+ puts "backup remote DB via ssh"
414
+ r_conf = nil
415
+ Net::SSH.start(ssh_host, ssh_user, ssh_opts) do |ssh|
416
+ r_conf = YAML.load(ssh.exec!("cat #{'#{remote_app_path}'}/config/mongoid.yml"))[env_from]['sessions']['default']
417
+ puts ssh.exec!("rm -R #{'#{remote_dump_path}'}")
418
+ puts ssh.exec!("mkdir -p #{'#{remote_dump_path}'}")
419
+ dump = "mongodump -u #{'#{r_conf[\'username\']} -p #{r_conf[\'password\']} -d #{r_conf[\'database\']} --authenticationDatabase #{r_conf[\'database\']} -o #{remote_dump_path}"'}
420
+ puts dump
421
+ puts ssh.exec!(dump)
422
+ end
423
+ conf = YAML.load_file(Rails.root.join('config', 'mongoid.yml'))[Rails.env]['sessions']['default']
424
+ db_to = conf['database']
425
+ db_path = Rails.root.join("tmp", "dmp", "dump", db_to).to_s
426
+ #{'`mkdir -p #{db_path}`'}
427
+ #{'rsync = "rsync -e ssh --progress -lzuogthvr #{ssh_user}@#{ssh_host}:#{remote_dump_path}/#{r_conf[\'database\']}/ #{db_path}/"'}
428
+ puts rsync
429
+ pipe = IO.popen(rsync)
430
+ while (line = pipe.gets)
431
+ print line
432
+ end
433
+
434
+ puts "restoring DB"
435
+ if Rails.env.staging?
436
+ #{'restore = "mongorestore --drop -d #{db_to} -u #{remote_db_user} -p #{remote_db_pass} --authenticationDatabase admin #{db_path}"'}
437
+ else
438
+ #{'restore = "mongorestore --drop -d #{db_to} #{local_auth(conf)} #{db_path}"'}
439
+ end
440
+ puts restore
441
+ pipe = IO.popen(restore)
442
+ while (line = pipe.gets)
443
+ print line
444
+ end
445
+
446
+ #{'rsync = "rsync -e ssh --progress -lzuogthvr #{ssh_user}@#{ssh_host}:#{remote_app_path}/public/system/ #{Rails.root.join(\'public/system\')}/"'}
447
+ puts rsync
448
+ pipe = IO.popen(rsync)
449
+ while (line = pipe.gets)
450
+ print line
451
+ end
452
+
453
+ #{'rsync = "rsync -e ssh --progress -lzuogthvr #{ssh_user}@#{ssh_host}:#{remote_app_path}/public/ckeditor_assets/ #{Rails.root.join(\'public/ckeditor_assets\')}/"'}
454
+ puts rsync
455
+ pipe = IO.popen(rsync)
456
+ while (line = pipe.gets)
457
+ print line
458
+ end
459
+ puts "cloned files"
460
+ puts "done"
461
+ end
462
+ end
463
+ TEXT
464
+ end
465
+ remove_file 'app/views/layouts/application.html.erb'
466
+
467
+ application do <<-TEXT
468
+ config.generators do |g|
469
+ g.test_framework :rspec
470
+ g.view_specs false
471
+ g.helper_specs false
472
+ g.feature_specs false
473
+ g.template_engine :slim
474
+ g.stylesheets false
475
+ g.javascripts false
476
+ g.helper false
477
+ g.fixture_replacement :factory_girl, :dir => 'spec/factories'
478
+ end
479
+ TEXT
480
+ end
481
+
482
+ remove_file 'app/assets/stylesheets/application.css'
483
+ create_file 'app/assets/stylesheets/application.css.sass' do <<-TEXT
484
+ @import 'compass'
485
+ @import 'rocket_cms'
486
+
487
+ #wrapper
488
+ width: 960px
489
+ margin: 0 auto
490
+ #sidebar
491
+ float: left
492
+ width: 200px
493
+ #content
494
+ float: right
495
+ width: 750px
496
+
497
+ @import "compass/layout/sticky-footer"
498
+ +sticky-footer(50px)
499
+ TEXT
500
+ end
501
+
502
+ remove_file 'app/assets/javascripts/application.js'
503
+ create_file 'app/assets/javascripts/application.js.coffee' do <<-TEXT
504
+ #= require rocket_cms
505
+ TEXT
506
+ end
507
+
508
+ git :init
509
+ git add: "."
510
+ git commit: %Q{ -m 'Initial commit' }
511
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rocket_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebtv
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-11 00:00:00.000000000 Z
11
+ date: 2014-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 4.1.4
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 4.1.4
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: mongoid
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -84,16 +98,16 @@ dependencies:
84
98
  name: simple_form
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - "~>"
101
+ - - ">="
88
102
  - !ruby/object:Gem::Version
89
- version: '3.0'
103
+ version: '0'
90
104
  type: :runtime
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - "~>"
108
+ - - ">="
95
109
  - !ruby/object:Gem::Version
96
- version: '3.0'
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: glebtv-simple_captcha
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -402,6 +416,34 @@ dependencies:
402
416
  - - ">="
403
417
  - !ruby/object:Gem::Version
404
418
  version: '0'
419
+ - !ruby/object:Gem::Dependency
420
+ name: thor
421
+ requirement: !ruby/object:Gem::Requirement
422
+ requirements:
423
+ - - ">="
424
+ - !ruby/object:Gem::Version
425
+ version: '0'
426
+ type: :runtime
427
+ prerelease: false
428
+ version_requirements: !ruby/object:Gem::Requirement
429
+ requirements:
430
+ - - ">="
431
+ - !ruby/object:Gem::Version
432
+ version: '0'
433
+ - !ruby/object:Gem::Dependency
434
+ name: uglifier
435
+ requirement: !ruby/object:Gem::Requirement
436
+ requirements:
437
+ - - ">="
438
+ - !ruby/object:Gem::Version
439
+ version: '0'
440
+ type: :runtime
441
+ prerelease: false
442
+ version_requirements: !ruby/object:Gem::Requirement
443
+ requirements:
444
+ - - ">="
445
+ - !ruby/object:Gem::Version
446
+ version: '0'
405
447
  description: RocketCMS
406
448
  email:
407
449
  - glebtv@gmail.com
@@ -431,6 +473,7 @@ files:
431
473
  - app/controllers/concerns/rs_menu.rb
432
474
  - app/controllers/concerns/rs_pages.rb
433
475
  - app/controllers/contacts_controller.rb
476
+ - app/controllers/home_controller.rb
434
477
  - app/controllers/news_controller.rb
435
478
  - app/controllers/pages_controller.rb
436
479
  - app/controllers/search_controller.rb
@@ -451,6 +494,7 @@ files:
451
494
  - app/models/menu.rb
452
495
  - app/models/news.rb
453
496
  - app/models/page.rb
497
+ - app/views/blocks/_footer.html.haml
454
498
  - app/views/contact_mailer/new_message_email.html.haml
455
499
  - app/views/contacts/new.html.haml
456
500
  - app/views/contacts/sent.html.haml
@@ -458,6 +502,9 @@ files:
458
502
  - app/views/errors/error_403.html.haml
459
503
  - app/views/errors/error_404.html.haml
460
504
  - app/views/errors/error_500.html.haml
505
+ - app/views/home/index.html.haml
506
+ - app/views/layouts/application.html.haml
507
+ - app/views/layouts/application.html.slim
461
508
  - app/views/news/index.html.haml
462
509
  - app/views/news/show.html.haml
463
510
  - app/views/pages/show.html.haml
@@ -482,7 +529,9 @@ files:
482
529
  - config/locales/ru.simple_captcha.yml
483
530
  - config/locales/ru.simple_form.yml
484
531
  - lib/filename_to_slug.rb
532
+ - lib/generators/rocket_cms/ability_generator.rb
485
533
  - lib/generators/rocket_cms/admin_generator.rb
534
+ - lib/generators/rocket_cms/layout_generator.rb
486
535
  - lib/generators/rocket_cms/templates/ability.erb
487
536
  - lib/generators/rocket_cms/templates/admin.erb
488
537
  - lib/generators/rocket_cms/utils.rb
@@ -492,6 +541,10 @@ files:
492
541
  - lib/rocket_cms/admin.rb
493
542
  - lib/rocket_cms/configuration.rb
494
543
  - lib/rocket_cms/controller.rb
544
+ - lib/rocket_cms/controllers/contacts.rb
545
+ - lib/rocket_cms/controllers/news.rb
546
+ - lib/rocket_cms/controllers/pages.rb
547
+ - lib/rocket_cms/controllers/search.rb
495
548
  - lib/rocket_cms/elastic_search.rb
496
549
  - lib/rocket_cms/engine.rb
497
550
  - lib/rocket_cms/model.rb
@@ -506,6 +559,7 @@ files:
506
559
  - lib/rocket_cms/version.rb
507
560
  - lib/smart_excerpt.rb
508
561
  - rocket_cms.gemspec
562
+ - template.rb
509
563
  homepage: https://github.com/rs-pro/rocket_cms
510
564
  licenses:
511
565
  - MIT