cmor_core_frontend 0.0.37.pre → 0.0.38.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/breadcrumbs/cmor/core/frontend/breadcrumb/path/base.rb +46 -0
- data/app/concerns/cmor/core/frontend/breadcrumb/i18n_concern.rb +32 -0
- data/app/view_helpers/cmor/core/frontend/breadcrumbs_view_helper.rb +37 -21
- data/lib/cmor/core/frontend.rb +1 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +3 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/javascripts/cable.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/controllers/frontend_controller.rb +2 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/jobs/application_job.rb +2 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/models/user.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +36 -0
- data/spec/dummy/bin/update +31 -0
- data/spec/dummy/bin/yarn +11 -0
- data/spec/dummy/config.ru +5 -0
- data/spec/dummy/config/application.rb +30 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +61 -0
- data/spec/dummy/config/environments/production.rb +94 -0
- data/spec/dummy/config/environments/test.rb +46 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/dummy/config/initializers/assets.rb +14 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cmor_core_frontend.rb +13 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +25 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/i18n.rb +2 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/route_translator.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/puma.rb +34 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config/spring.rb +6 -0
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20190819110307_create_users.rb +9 -0
- data/spec/dummy/db/migrate/20190819110320_create_active_storage_tables.active_storage.rb +27 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/log/test.log +34 -0
- data/spec/dummy/package.json +5 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/tmp/development_secret.txt +1 -0
- data/spec/lib/cmor/core/frontend/version_spec.rb +5 -0
- data/spec/rails_helper.rb +62 -0
- data/spec/spec_helper.rb +96 -0
- data/spec/support/rao-view_helper.rb~ +5 -0
- data/spec/view_helpers/cmor/core/frontend/breadcrumbs_view_helper_spec.rb~ +25 -0
- metadata +74 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3805a6c65e725937dbec4ec08d133603516a8298b2077d3d1e75f643116a2b6
|
4
|
+
data.tar.gz: 0d84db04304467a201a478e56441c423d134a6486a2b988363668a1020f4a4d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 178343f3524a17dd9fa2fbc5b352cd8e71627fea0af9d6c8e772f515dde24969c7b36f61f66e4aff44eecb7136a35526e995f5eb1d0fba0de422a4466608d2e0
|
7
|
+
data.tar.gz: 1b27542f4a7b006a8af4572eee75680fc2f8eeaf38b18eeb26991cde5e67970eb5b8930bd6a37ea7b01a32559dd73d7a10d5151b6e14e1d0a8240218aaa56a4e
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Cmor
|
2
|
+
module Core
|
3
|
+
module Frontend
|
4
|
+
module Breadcrumb
|
5
|
+
module Path
|
6
|
+
# You can specify custom breadcrumbs at controller/action level.
|
7
|
+
#
|
8
|
+
# Example:
|
9
|
+
#
|
10
|
+
# Assume you have a PostsController with an index action and you want
|
11
|
+
# to change its breadcrumb. You will have to create a class that
|
12
|
+
# inherits from Cmor::Core::Frontend::Breadcrumb::Path::Base. This
|
13
|
+
# class has to have a breadcrumbs methods that returns an array of
|
14
|
+
# Cmor::Core::Frontend::Breadcrumb::Base.
|
15
|
+
#
|
16
|
+
# # app/breadcrumbs/posts_controller/index_breadcrumb_path.rb
|
17
|
+
# class PostsController::IndexBreadcrumbPath < Cmor::Core::Frontend::Breadcrumb::Path::Base
|
18
|
+
# def breadcrumbs
|
19
|
+
# [
|
20
|
+
# Cmor::Core::Frontend::Breadcrumb::Base.new(title: 'Foo', url: '/foo' ),
|
21
|
+
# Cmor::Core::Frontend::Breadcrumb::Base.new(title: 'Bar', url: '/bar' )
|
22
|
+
# ]
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
class Base
|
27
|
+
extend ActiveModel::Model
|
28
|
+
include I18nConcern
|
29
|
+
|
30
|
+
attr_accessor :context
|
31
|
+
|
32
|
+
def initialize(attrs)
|
33
|
+
attrs.each do |k, v|
|
34
|
+
self.send("#{k}=", v)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def breadcrumbs
|
39
|
+
raise "Child class reponsibility"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Cmor
|
2
|
+
module Core
|
3
|
+
module Frontend
|
4
|
+
module Breadcrumb
|
5
|
+
module I18nConcern
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
def t(identifier, options = {})
|
9
|
+
if identifier.start_with?('.')
|
10
|
+
prefix = self.class.name.underscore
|
11
|
+
|
12
|
+
# Check if we are in a proc by matching the caller string
|
13
|
+
caller_method = if caller[0] =~ /.*<.*>/
|
14
|
+
# If yes omit the last call (that has to be instance_exec) and
|
15
|
+
# fetch the previous one that should be the method that is really
|
16
|
+
# calling us.
|
17
|
+
caller[2].split(' ').last.gsub("'", '').gsub("`", '')
|
18
|
+
else
|
19
|
+
# Otherwise take the first caller
|
20
|
+
caller[0].split(' ').last.gsub("'", '').gsub("`", '')
|
21
|
+
end
|
22
|
+
|
23
|
+
I18n.t("#{prefix}.#{caller_method}.#{identifier}", options)
|
24
|
+
else
|
25
|
+
I18n.t(identifier, options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -10,6 +10,7 @@ module Cmor
|
|
10
10
|
# end
|
11
11
|
#
|
12
12
|
class BreadcrumbsViewHelper < Rao::ViewHelper::Base
|
13
|
+
include Cmor::Core::Frontend::Breadcrumb::I18nConcern
|
13
14
|
# Usage:
|
14
15
|
#
|
15
16
|
# # app/views/layouts/application.html.erb
|
@@ -32,6 +33,13 @@ module Cmor
|
|
32
33
|
# Add breadcrumb to home page
|
33
34
|
b.push(instance_exec(&Cmor::Core::Frontend::Configuration.first_breadcrumb))
|
34
35
|
|
36
|
+
# Are custom breadcrumbs defined?
|
37
|
+
if custom_breadcrumbs.any?
|
38
|
+
b.push << custom_breadcrumbs
|
39
|
+
exclude = []
|
40
|
+
next
|
41
|
+
end
|
42
|
+
|
35
43
|
# Are we showing a cms page?
|
36
44
|
if c.controller.class.name == 'Cmor::Cms::PageController' && c.action_name == 'respond' && c.params[:page] != 'home'
|
37
45
|
# Add breadcrumb for this page
|
@@ -75,6 +83,7 @@ module Cmor
|
|
75
83
|
end
|
76
84
|
end
|
77
85
|
|
86
|
+
breadcrumbs.flatten!
|
78
87
|
breadcrumbs.last.url = nil
|
79
88
|
|
80
89
|
if exclude.any?
|
@@ -92,6 +101,34 @@ module Cmor
|
|
92
101
|
|
93
102
|
private
|
94
103
|
|
104
|
+
def custom_breadcrumbs
|
105
|
+
klass = custom_breadcrumb_path_class
|
106
|
+
if klass.present?
|
107
|
+
klass.new(context: c).breadcrumbs
|
108
|
+
else
|
109
|
+
[]
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def custom_breadcrumb_path_class
|
114
|
+
klass_name = "#{c.controller.class.name}::#{c.action_name.camelize}BreadcrumbPath"
|
115
|
+
# Are we eager loading?
|
116
|
+
if Rails.application.config.eager_load
|
117
|
+
# If so we can ask const_defined?
|
118
|
+
if klass_name.split("::")[0...-1].join("::").constantize.const_defined?(klass_name.split("::").last)
|
119
|
+
klass_name.constantize
|
120
|
+
end
|
121
|
+
else
|
122
|
+
# Else we have to try to constantize the klass name to see if it lazy loads.
|
123
|
+
begin
|
124
|
+
klass_name.constantize
|
125
|
+
rescue NameError => e
|
126
|
+
Rails.logger.debug "No custom breadcrumb path class found. Define #{klass_name} to customize breadcrumbs. Continuing with default breadcrumbs."
|
127
|
+
nil
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
95
132
|
def breadcrumb_for_current_engine
|
96
133
|
return if current_engine.nil?
|
97
134
|
breadcrumb_for_engine(current_engine)
|
@@ -110,27 +147,6 @@ module Cmor
|
|
110
147
|
end
|
111
148
|
end
|
112
149
|
|
113
|
-
def t(identifier, options = {})
|
114
|
-
if identifier.start_with?('.')
|
115
|
-
prefix = self.class.name.underscore
|
116
|
-
|
117
|
-
# Check if we are in a proc by matching the caller string
|
118
|
-
caller_method = if caller[0] =~ /\(required\)>/
|
119
|
-
# If yes omit the last call (that has to be instance_exec) and
|
120
|
-
# fetch the previous one that should be the method that is really
|
121
|
-
# calling us.
|
122
|
-
caller[2].split(' ').last.gsub("'", '').gsub("`", '')
|
123
|
-
else
|
124
|
-
# Otherwise take the first caller
|
125
|
-
caller[0].split(' ').last.gsub("'", '').gsub("`", '')
|
126
|
-
end
|
127
|
-
|
128
|
-
I18n.t("#{prefix}.#{caller_method}.#{identifier}", options)
|
129
|
-
else
|
130
|
-
I18n.t(identifier, options)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
150
|
private
|
135
151
|
|
136
152
|
def label_for(resource)
|
data/lib/cmor/core/frontend.rb
CHANGED
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require rails-ujs
|
14
|
+
//= require activestorage
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// Action Cable provides the framework to deal with WebSockets in Rails.
|
2
|
+
// You can generate new channels where WebSocket features live using the `rails generate channel` command.
|
3
|
+
//
|
4
|
+
//= require action_cable
|
5
|
+
//= require_self
|
6
|
+
//= require_tree ./channels
|
7
|
+
|
8
|
+
(function() {
|
9
|
+
this.App || (this.App = {});
|
10
|
+
|
11
|
+
App.cable = ActionCable.createConsumer();
|
12
|
+
|
13
|
+
}).call(this);
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= csrf_meta_tags %>
|
6
|
+
<%= csp_meta_tag %>
|
7
|
+
|
8
|
+
<%= stylesheet_link_tag 'application', media: 'all' %>
|
9
|
+
<%= javascript_include_tag 'application' %>
|
10
|
+
</head>
|
11
|
+
|
12
|
+
<body>
|
13
|
+
<%= yield %>
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= yield %>
|
data/spec/dummy/bin/rake
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'fileutils'
|
3
|
+
include FileUtils
|
4
|
+
|
5
|
+
# path to your application root.
|
6
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
7
|
+
|
8
|
+
def system!(*args)
|
9
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
10
|
+
end
|
11
|
+
|
12
|
+
chdir APP_ROOT do
|
13
|
+
# This script is a starting point to setup your application.
|
14
|
+
# Add necessary setup steps to this file.
|
15
|
+
|
16
|
+
puts '== Installing dependencies =='
|
17
|
+
system! 'gem install bundler --conservative'
|
18
|
+
system('bundle check') || system!('bundle install')
|
19
|
+
|
20
|
+
# Install JavaScript dependencies if using Yarn
|
21
|
+
# system('bin/yarn')
|
22
|
+
|
23
|
+
# puts "\n== Copying sample files =="
|
24
|
+
# unless File.exist?('config/database.yml')
|
25
|
+
# cp 'config/database.yml.sample', 'config/database.yml'
|
26
|
+
# end
|
27
|
+
|
28
|
+
puts "\n== Preparing database =="
|
29
|
+
system! 'bin/rails db:setup'
|
30
|
+
|
31
|
+
puts "\n== Removing old logs and tempfiles =="
|
32
|
+
system! 'bin/rails log:clear tmp:clear'
|
33
|
+
|
34
|
+
puts "\n== Restarting application server =="
|
35
|
+
system! 'bin/rails restart'
|
36
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'fileutils'
|
3
|
+
include FileUtils
|
4
|
+
|
5
|
+
# path to your application root.
|
6
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
7
|
+
|
8
|
+
def system!(*args)
|
9
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
10
|
+
end
|
11
|
+
|
12
|
+
chdir APP_ROOT do
|
13
|
+
# This script is a way to update your development environment automatically.
|
14
|
+
# Add necessary update steps to this file.
|
15
|
+
|
16
|
+
puts '== Installing dependencies =='
|
17
|
+
system! 'gem install bundler --conservative'
|
18
|
+
system('bundle check') || system!('bundle install')
|
19
|
+
|
20
|
+
# Install JavaScript dependencies if using Yarn
|
21
|
+
# system('bin/yarn')
|
22
|
+
|
23
|
+
puts "\n== Updating database =="
|
24
|
+
system! 'bin/rails db:migrate'
|
25
|
+
|
26
|
+
puts "\n== Removing old logs and tempfiles =="
|
27
|
+
system! 'bin/rails log:clear tmp:clear'
|
28
|
+
|
29
|
+
puts "\n== Restarting application server =="
|
30
|
+
system! 'bin/rails restart'
|
31
|
+
end
|
data/spec/dummy/bin/yarn
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
3
|
+
Dir.chdir(APP_ROOT) do
|
4
|
+
begin
|
5
|
+
exec "yarnpkg", *ARGV
|
6
|
+
rescue Errno::ENOENT
|
7
|
+
$stderr.puts "Yarn executable was not detected in the system."
|
8
|
+
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
|
9
|
+
exit 1
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative 'boot'
|
2
|
+
|
3
|
+
require "rails"
|
4
|
+
# Pick the frameworks you want:
|
5
|
+
require "active_model/railtie"
|
6
|
+
require "active_job/railtie"
|
7
|
+
require "active_record/railtie"
|
8
|
+
require "active_storage/engine"
|
9
|
+
require "action_controller/railtie"
|
10
|
+
require "action_mailer/railtie"
|
11
|
+
require "action_view/railtie"
|
12
|
+
require "action_cable/engine"
|
13
|
+
require "sprockets/railtie"
|
14
|
+
# require "rails/test_unit/railtie"
|
15
|
+
|
16
|
+
Bundler.require(*Rails.groups)
|
17
|
+
require "cmor_core_frontend"
|
18
|
+
|
19
|
+
module Dummy
|
20
|
+
class Application < Rails::Application
|
21
|
+
# Initialize configuration defaults for originally generated Rails version.
|
22
|
+
config.load_defaults 5.2
|
23
|
+
|
24
|
+
# Settings in config/environments/* take precedence over those specified here.
|
25
|
+
# Application configuration can go into files in config/initializers
|
26
|
+
# -- all .rb files in that directory are automatically loaded after loading
|
27
|
+
# the framework and any gems in your application.
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|