enjoy_cms 0.3.4 → 0.3.5

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: e1cde68353de729109469314593280868f16f916
4
- data.tar.gz: 8d710c2d7de38ddf701c9069f8b03ef7481a794b
3
+ metadata.gz: 7396a7e0de757550c9c23cd91c1a04cfa089a67b
4
+ data.tar.gz: 35134eb111a84278479d77e1f4f1d85f56da950b
5
5
  SHA512:
6
- metadata.gz: dbcd938f54fdc7fa3d5e58c74fcdaa0f2082a8b8defcd3999adb845f6146ff12b03ac2dec980514a04f06b17f56a729b449ffd98f3f4397178eae632fcc5f6a6
7
- data.tar.gz: 1c9120a4a121b5cbdd346f4e801e6695438a7e4ad7e2af9604cf236686e36581cebcf4e34b5b9f128179aea86ac477ce0a94edbc5454328cc8f9471dd7f5b7fa
6
+ metadata.gz: 71d0e398cf285ef3da4687a6ec70d09c9350611413a8d11af1f4eb4271b16e2309ddbe5fff4b733d5ba5a1a5827459c3bd5e75ecba6c2c3b8960043f8cf53b05
7
+ data.tar.gz: c8f2350501b3add07a6b876a1295bb4b92dfc4dcd9c4b35004c24e26d4c30e90f59810663dd90c72b6dbdab7280821695bcd42c357606943758a214b5efac8c1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- enjoy_cms (0.3.4)
4
+ enjoy_cms (0.3.5)
5
5
  ack_rails_admin_jcrop
6
6
  addressable
7
7
  ckeditor
@@ -72,8 +72,8 @@ GEM
72
72
  tzinfo (~> 1.1)
73
73
  addressable (2.4.0)
74
74
  arel (6.0.3)
75
- bcrypt (3.1.10)
76
- bson (4.0.3)
75
+ bcrypt (3.1.11)
76
+ bson (4.0.4)
77
77
  builder (3.2.2)
78
78
  ckeditor (4.1.6)
79
79
  cocaine
@@ -21,10 +21,28 @@ module Enjoy::Localizeable
21
21
  pages.sorted.to_a
22
22
  end
23
23
  def nav_get_url(item)
24
- (params[:locale].blank? ? "" : "/#{params[:locale]}") + (item.redirect.blank? ? item.fullpath : item.redirect)
24
+ _connectable = item.connectable
25
+ if _connectable and _connectable.enabled
26
+ begin
27
+ _routes_namespace = _connectable.respond_to?(:routes_namespace) ? _connectable.routes_namespace : :main_app
28
+ _url = send(_routes_namespace.to_sym).url_for([_connectable, {only_path: true}])
29
+ rescue Exception => exception
30
+ Rails.logger.error exception.message
31
+ Rails.logger.error exception.backtrace.join("\n")
32
+ puts exception.message
33
+ puts exception.backtrace.join("\n")
34
+ capture_exception(exception) if respond_to?(:capture_exception)
35
+
36
+ _url = item.redirect.blank? ? item.fullpath : item.redirect
37
+ end
38
+ else
39
+ _url = item.redirect.blank? ? item.fullpath : item.redirect
40
+ end
41
+ (params[:locale].blank? ? "" : "/#{params[:locale]}") + _url
25
42
  end
26
43
  def find_seo_extra(path)
27
- page_class.enabled.where(fullpath: path.gsub(/(\/ru|\/en)/, "")).first
44
+ _localizable_regexp = Regexp.new("^(#{I18n.available_locales.map { |l| "\\/#{l}"}.join("|")})")
45
+ page_class.enabled.where(fullpath: path.sub(_localizable_regexp, "")).first
28
46
  end
29
47
 
30
48
  def page_class_name
@@ -56,14 +56,14 @@ module Enjoy::NavMenu
56
56
  if _connectable and _connectable.enabled
57
57
  begin
58
58
  _routes_namespace = _connectable.respond_to?(:routes_namespace) ? _connectable.routes_namespace : :main_app
59
- send(_routes_namespace.to_sym).url_for(_connectable)
59
+ send(_routes_namespace.to_sym).url_for([_connectable, {only_path: true}])
60
60
  rescue Exception => exception
61
61
  Rails.logger.error exception.message
62
62
  Rails.logger.error exception.backtrace.join("\n")
63
63
  puts exception.message
64
64
  puts exception.backtrace.join("\n")
65
65
  capture_exception(exception) if respond_to?(:capture_exception)
66
-
66
+
67
67
  item.redirect.blank? ? item.fullpath : item.redirect
68
68
  end
69
69
  else
@@ -1,7 +1,7 @@
1
1
  = render 'shared/obj', obj: @seo_page
2
2
 
3
3
  #enjoy_cms_contact_form
4
- = simple_form_for @contact_message, url: contacts_path do |f|
4
+ = simple_form_for @contact_message, url: enjoy_contacts_path do |f|
5
5
  = f.input :name
6
6
  = f.input :email
7
7
  = f.input :phone
@@ -1,7 +1,7 @@
1
1
  = render 'shared/obj', obj: @seo_page
2
2
 
3
3
  #enjoy_cms_contact_form
4
- = simple_form_for @contact_message, url: contacts_path do |f|
4
+ = simple_form_for @contact_message, url: enjoy_contacts_path do |f|
5
5
  = f.input :name
6
6
  = f.input :email
7
7
  = f.input :phone
@@ -1,6 +1,6 @@
1
1
  .enjoy-search-results
2
2
  h1 Результаты поиска
3
- = form_tag search_path, method: :get, class: 'nav_search' do
3
+ = form_tag enjoy_search_path, method: :get, class: 'nav_search' do
4
4
  = text_field_tag 'query', params[:query], placeholder: "Поиск"
5
5
  = submit_tag 'Найти'
6
6
  ol
@@ -32,8 +32,6 @@ module Enjoy
32
32
 
33
33
  attr_accessor :recreate_contact_message_action
34
34
 
35
- attr_accessor :routes_config
36
-
37
35
  def initialize
38
36
  @news_image_styles = {
39
37
  main: '400x200>',
@@ -58,15 +56,6 @@ module Enjoy
58
56
  @recreate_contact_message_action = "new"
59
57
 
60
58
  @localize = false
61
-
62
- @routes_config = {
63
- use_contacts_path: true,
64
- use_search_path: true,
65
- use_news_path: true,
66
- root_path: "home#index",
67
- use_slug_path: true,
68
- use_pages_path: true
69
- }
70
59
  end
71
60
 
72
61
  def search_enabled=(val)
data/lib/enjoy/engine.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Enjoy
2
2
  class Engine < ::Rails::Engine
3
- isolate_namespace Enjoy
3
+ # isolate_namespace Enjoy
4
4
 
5
5
  rake_tasks do
6
6
  require File.expand_path('../tasks', __FILE__)
@@ -16,7 +16,7 @@ module Enjoy
16
16
  # end
17
17
 
18
18
  included do
19
- enjoy_connectable_field :connected_pages, routes_namespace: :enjoy_cms
19
+ enjoy_connectable_field :connected_pages
20
20
 
21
21
  unless Enjoy.config.news_image_styles.nil?
22
22
  validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/, if: :image?
@@ -0,0 +1,45 @@
1
+ module ActionDispatch::Routing
2
+ class Mapper
3
+
4
+ def enjoy_cms_routes(config = {})
5
+ routes_config = {
6
+ use_contacts_path: true,
7
+ use_search_path: true,
8
+ use_news_path: true,
9
+ root_path: "home#index",
10
+ use_slug_path: true,
11
+ use_pages_path: true
12
+ }
13
+ routes_config.merge!(config)
14
+
15
+ scope module: 'enjoy' do
16
+ if routes_config[:use_contacts_path]
17
+ get 'contacts' => 'contacts#new', as: :enjoy_contacts
18
+ post 'contacts' => 'contacts#create', as: :enjoy_create_contacts
19
+ get 'contacts/sent' => 'contacts#sent', as: :enjoy_contacts_sent
20
+ end
21
+
22
+ if routes_config[:use_search_path]
23
+ get 'search' => 'search#index', as: :enjoy_search
24
+ end
25
+
26
+ if routes_config[:use_news_path]
27
+ resources :news, only: [:index, :show], as: :enjoy_news
28
+ end
29
+
30
+ if routes_config[:root_path]
31
+ root to: routes_config[:root_path]
32
+ end
33
+
34
+ if routes_config[:use_slug_path]
35
+ get '*slug' => 'pages#show'
36
+ end
37
+ if routes_config[:use_pages_path]
38
+ resources :pages, only: [:show], as: :enjoy_pages
39
+ end
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+ end
data/lib/enjoy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Enjoy
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
3
3
  end
data/lib/enjoy_cms.rb CHANGED
@@ -5,6 +5,7 @@ end
5
5
 
6
6
  require 'enjoy/version'
7
7
  require 'devise'
8
+ require 'enjoy/routes'
8
9
 
9
10
  require 'simple_form'
10
11
  require 'enjoy/simple_form_patch'
@@ -0,0 +1,13 @@
1
+ require 'rails/generators'
2
+
3
+ module Enjoy::Config
4
+ class InstallGenerator < Rails::Generators::Base
5
+ source_root File.expand_path('../templates', __FILE__)
6
+
7
+ desc 'Enjoy::CMS Config generator'
8
+ def install
9
+ template 'enjoy_cms.erb', "config/initializers/enjoy_cms.rb"
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,27 @@
1
+ Enjoy.configure do |config|
2
+ ##### defaults #####
3
+ # config.news_image_styles = {
4
+ # main: '400x200>',
5
+ # thumb: '200x100>'
6
+ # }
7
+ # config.news_per_page = 10
8
+ # config.news_excerpt = 12
9
+ # config.news_content_required = true
10
+ #
11
+ # config.error_layout = 'application'
12
+ # config.menu_max_depth = 2
13
+ #
14
+ # config.search_enabled = false
15
+ # config.search_per_page = 10
16
+ # config.search_models = []
17
+ #
18
+ # config.contacts_captcha = false
19
+ # config.contacts_fields = {}
20
+ # config.contacts_message_required = true
21
+ #
22
+ # config.contacts_captcha_error_message = "Код проверки введен неверно"
23
+ # config.recreate_contact_message_action = "new"
24
+ #
25
+ # config.localize = false
26
+
27
+ end
data/template.rb CHANGED
@@ -106,6 +106,7 @@ create_file '.gitignore' do <<-TEXT
106
106
  /tmp/*
107
107
  /public/assets
108
108
  /public/ckeditor_assets
109
+ Gemfile.lock
109
110
  TEXT
110
111
  end
111
112
 
@@ -414,7 +415,7 @@ Rails.application.routes.draw do
414
415
  mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
415
416
  mount Ckeditor::Engine => '/ckeditor'
416
417
 
417
- mount Enjoy::Engine => '/', as: 'enjoy_cms'
418
+ enjoy_cms_routes
418
419
  end
419
420
  TEXT
420
421
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enjoy_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Kiseliev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-04 00:00:00.000000000 Z
11
+ date: 2016-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -520,7 +520,6 @@ files:
520
520
  - config/locales/ru.rails_admin.yml
521
521
  - config/locales/ru.simple_captcha.yml
522
522
  - config/locales/ru.simple_form.yml
523
- - config/routes.rb
524
523
  - enjoy_cms.gemspec
525
524
  - lib/enjoy/admin.rb
526
525
  - lib/enjoy/admin/contact_message.rb
@@ -581,6 +580,7 @@ files:
581
580
  - lib/enjoy/rails_admin_ext/enjoy_html.rb
582
581
  - lib/enjoy/rails_admin_ext/group_patch.rb
583
582
  - lib/enjoy/rails_admin_ext/menu.rb
583
+ - lib/enjoy/routes.rb
584
584
  - lib/enjoy/simple_form_patch.rb
585
585
  - lib/enjoy/tasks.rb
586
586
  - lib/enjoy/version.rb
@@ -589,6 +589,8 @@ files:
589
589
  - lib/generators/enjoy/ability_generator.rb
590
590
  - lib/generators/enjoy/admin_generator.rb
591
591
  - lib/generators/enjoy/capify_generator.rb
592
+ - lib/generators/enjoy/config/install_generator.rb
593
+ - lib/generators/enjoy/config/templates/enjoy_cms.erb
592
594
  - lib/generators/enjoy/layout_generator.rb
593
595
  - lib/generators/enjoy/migration_generator.rb
594
596
  - lib/generators/enjoy/templates/Capfile
data/config/routes.rb DELETED
@@ -1,28 +0,0 @@
1
- Enjoy::Engine.routes.draw do
2
- routes_config = Enjoy.configuration.routes_config
3
-
4
- if !routes_config or routes_config[:use_contacts_path]
5
- get 'contacts' => 'contacts#new', as: :contacts
6
- post 'contacts' => 'contacts#create', as: :create_contacts
7
- get 'contacts/sent' => 'contacts#sent', as: :contacts_sent
8
- end
9
-
10
- if !routes_config or routes_config[:use_search_path]
11
- get 'search' => 'search#index', as: :search
12
- end
13
-
14
- if !routes_config or routes_config[:use_news_path]
15
- resources :news, only: [:index, :show]
16
- end
17
-
18
- if routes_config and routes_config[:root_path]
19
- root to: routes_config[:root_path]
20
- end
21
-
22
- if !routes_config or routes_config[:use_slug_path]
23
- get '*slug' => 'pages#show'
24
- end
25
- if !routes_config or routes_config[:use_pages_path]
26
- resources :pages, only: [:show]
27
- end
28
- end