comfortable_mexican_loveseat 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 04947abf7141c7a6f43624475caf1347bc716da0
4
- data.tar.gz: 989d1298bdc486b0b5b6e735264155ed9957b494
3
+ metadata.gz: 15b3119762be0e76fcddd50c19d3f28b0eed88bb
4
+ data.tar.gz: 9c519962fae4a23c4c14cb104ce0b61135b832cb
5
5
  SHA512:
6
- metadata.gz: 14a1cfb6aafdd27b56365af142a0c41f0f1832d5d99e9a2725f0689b98afc70b234ca2097b16ab6489a83c1e6b67cd37e89e5ac94e34f9d2acccba7988373f8c
7
- data.tar.gz: 74e8cd88afde594ce6f8e5bf933878beb4d589edf48921cc14d41631f89ef33f68a28b4be0bbb3df9099087c15d027f12281361375c2b5d85daf27e32d2a984f
6
+ metadata.gz: ac08c834572f0c10708f227f911c296f3a394f594dc6b4df49878fb36f929db486ee5e8e359ec9cd2e1a2d026c7a1be2b82c8a0e4fbfb507c3e328dc93f1e331
7
+ data.tar.gz: 4e4e7bf33c72a5b66c38702ac27d36076818eb59b0b8264d0cea863e79dbc914232e75daf4a31c0d442a8646fd2278f14c15e4afdead035531c0871c9f940212
data/README.rdoc CHANGED
@@ -34,7 +34,7 @@ By default when using the Loveseat, all trailing slash URLs ('myapp.com/example/
34
34
 
35
35
  === Page Meta Tags
36
36
 
37
- By default when you create an application, it comes with meta description; page title; no-index; index; and canonical link fields that can be filled in on a per-page basis. To display these tags, add this to your <tt>application.html.erb</tt>:
37
+ By default when you create an application, it comes with meta description; page title; index; canonical link; and Social Media (Google+, Facebook, and Twitter) fields that can be filled in on a per-page basis. To display these tags, add this to your <tt>application.html.erb</tt>:
38
38
 
39
39
  <title><%= comfy_page_title %></title>
40
40
  <%= comfy_seo_tags %>
@@ -0,0 +1,22 @@
1
+ module Eventify
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ resource_class.state_machine.events.map(&:name).each do |event|
6
+ define_method event do
7
+ respond_to do |format|
8
+ format.html do
9
+ resource.assign_attributes(permitted_params[resource_instance_name]) if permitted_params[resource_instance_name]
10
+
11
+ if resource.fire_state_event(event)
12
+ redirect_to [current_namespace, current_parent, resource], notice: t('flash.success', action_name: resource_class.human_state_event_name(event).capitalize)
13
+ else
14
+ flash[:alert] = resource.errors.full_messages.join('<br>')
15
+ render action: :show
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,92 @@
1
+ module Localizify
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ helper_method :default_locale?
6
+
7
+ prepend_before_action :set_available_locale, :set_locale
8
+ end
9
+
10
+ def default_locale?
11
+ I18n.locale == I18n.default_locale
12
+ end
13
+
14
+ def set_available_locale
15
+ begin
16
+ unless (cms_locales = ::Comfy::Cms::Site.pluck(:locale)).any?
17
+ cms_locales = [I18n.default_locale]
18
+ end
19
+ rescue
20
+ cms_locales = [I18n.default_locale]
21
+ end
22
+
23
+ I18n.available_locales = cms_locales.uniq
24
+ end
25
+
26
+ def set_locale
27
+ return true if kind_of?(Comfy::Cms::ContentController)
28
+
29
+ unless [params[:locale].try(:to_sym)].compact.include?(parsed_locale.to_sym)
30
+ begin
31
+ redirect_to url_for(locale: parsed_locale)
32
+ rescue
33
+ redirect_to root_path(locale: parsed_locale)
34
+ end
35
+ end
36
+
37
+ I18n.locale = parsed_locale
38
+ cookify_locale
39
+ end
40
+
41
+ def parsed_locale
42
+ cms_locale || param_locale || cookie_locale || accept_locale || I18n.default_locale
43
+ end
44
+
45
+ def cookify_locale
46
+ cookies[:locale] = { value: I18n.locale.to_s, expires: 1.year.from_now }
47
+ end
48
+
49
+ def uncookify_locale
50
+ cookies.delete(:locale)
51
+ end
52
+
53
+ def locale_available?(locale)
54
+ I18n.available_locales.include?(locale.try(:to_sym))
55
+ end
56
+
57
+ def cms_locale
58
+ nil
59
+ end
60
+
61
+ def user_locale
62
+ current_user && locale_available?(current_user.domain) ? current_user.domain.to_sym : nil
63
+ end
64
+
65
+ def param_locale
66
+ locale_available?(params[:locale]) ? params[:locale].try(:to_sym) : nil
67
+ end
68
+
69
+ def cookie_locale
70
+ cookies[:locale] && locale_available?(cookies[:locale]) ? cookies[:locale].try(:to_sym) : nil
71
+ end
72
+
73
+ def domain_locale
74
+ parsed_locale = request.host.split('.').last.try(:to_s)
75
+ locale_available?(parsed_locale) ? parsed_locale.try(:to_sym) : nil
76
+ end
77
+
78
+ def accept_locale
79
+ if request.env['HTTP_ACCEPT_LANGUAGE'].present?
80
+ parsed_locale = request.env['HTTP_ACCEPT_LANGUAGE'].gsub(/\s+/, '').split(',').first
81
+ parsed_locale = parsed_locale.scan(/^[a-z]{2}-[a-z]{2}|[a-z]{2}/i).first if parsed_locale
82
+ parsed_locale = parsed_locale.split('-').last.try(:downcase).try(:to_sym) if parsed_locale
83
+
84
+ locale_available?(parsed_locale) ? parsed_locale.try(:to_sym) : nil
85
+ end
86
+ end
87
+
88
+ def default_url_options(options = {})
89
+ options.merge(locale: I18n.locale || I18n.default_locale)
90
+ end
91
+
92
+ end
@@ -0,0 +1,28 @@
1
+ module Permitify
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ before_action :require_permission!
6
+ end
7
+
8
+ def require_permission!
9
+ return false unless current_admin
10
+ return true if current_admin_is_updating_profile?
11
+ unless current_admin.permitted_to?(params)
12
+ respond_to do |format|
13
+ format.html { redirect_to polymorphic_path([:admin, :root]), alert: t('flash.unpermitted') }
14
+ format.xml { head :ok }
15
+ format.js do
16
+ flash.now[:alert] = t('flash.unpermitted')
17
+ render js: "window.location = '#{polymorphic_path([:admin, :root])}'"
18
+ end
19
+ end
20
+ return false
21
+ end
22
+ end
23
+
24
+ def current_admin_is_updating_profile?
25
+ params[:id].to_i == current_admin.id && params[:controller] == "admin/admins" && params[:action] == "update"
26
+ end
27
+ end
28
+
@@ -0,0 +1,22 @@
1
+ module Redirectify
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ helper_method :back_or_default_path
6
+ end
7
+
8
+ def back_or_default_path(default_path)
9
+ referer_path || default_path
10
+ end
11
+
12
+ def referer_path
13
+ return if request.referer.blank?
14
+
15
+ routing_hash = Rails.application.routes.recognize_path(request.referer)
16
+ referer_uri = request.referer.dup.delete(['?', URI.parse(request.referer).query].join)
17
+
18
+ request.referer if url_for(routing_hash) == referer_uri
19
+ rescue
20
+ nil
21
+ end
22
+ end
@@ -0,0 +1,39 @@
1
+ module Routify
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ helper_method :current_namespace, :current_parent, :site_url, :site
6
+
7
+ def namespaces
8
+ self.class.namespaces
9
+ end
10
+ end
11
+
12
+ private
13
+
14
+ def current_parent
15
+ parent if respond_to?(:parent, true)
16
+ end
17
+
18
+ def current_namespace
19
+ namespaces.first
20
+ end
21
+
22
+ def site_url
23
+ 'site' if params[:site_id].present?
24
+ end
25
+
26
+ def site (current_resource = resource)
27
+ current_resource.site if current_resource.respond_to?(:site)
28
+ end
29
+
30
+ module ClassMethods
31
+ def current_namespace
32
+ namespaces.first
33
+ end
34
+
35
+ def namespaces
36
+ name.split('::').slice(0...-1).map(&:underscore).map(&:to_s)
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,15 @@
1
+ module Sortify
2
+
3
+ def apply_sorting(chain, order_class = resource_class)
4
+ params[:order] ||= 'id_desc'
5
+ if params[:order] && params[:order] =~ /^([\w\_\.]+)_(desc|asc)$/
6
+ column = $1
7
+ order = $2
8
+ table = order_class.column_names.include?(column) ? order_class.table_name : nil
9
+ table_column = (column =~ /\./) ? column : [table, order_class.connection.quote_column_name(column)].compact.join(".")
10
+ chain.reorder("#{table_column} #{order}")
11
+ else
12
+ chain
13
+ end
14
+ end
15
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comfortable_mexican_loveseat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Bahlke
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-08-14 00:00:00.000000000 Z
12
+ date: 2015-08-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -109,6 +109,12 @@ files:
109
109
  - app/controllers/comfy/admin/cms/base_controller.rb
110
110
  - app/controllers/comfy/admin/cms/layouts_controller.rb
111
111
  - app/controllers/comfy/cms/content_controller.rb
112
+ - app/controllers/concerns/eventify.rb
113
+ - app/controllers/concerns/localizify.rb
114
+ - app/controllers/concerns/permitify.rb
115
+ - app/controllers/concerns/redirectify.rb
116
+ - app/controllers/concerns/routify.rb
117
+ - app/controllers/concerns/sortify.rb
112
118
  - app/helpers/comfy/cms_helper.rb
113
119
  - app/models/comfy/cms/snippet.rb
114
120
  - app/views/comfy/admin/cms/files/_form.html.haml