beyond_canvas 0.13.1.pre → 0.14.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/icons/file.svg +1 -0
  3. data/app/assets/images/icons/flash_checkbox.svg +1 -0
  4. data/app/assets/images/icons/flash_close.svg +1 -0
  5. data/app/assets/images/icons/flash_error.svg +1 -0
  6. data/app/assets/images/icons/flash_info.svg +1 -0
  7. data/app/assets/images/icons/flash_warning.svg +1 -0
  8. data/app/assets/javascripts/beyond_canvas/base.js +94 -0
  9. data/app/assets/stylesheets/beyond_canvas/base.scss +25 -0
  10. data/app/assets/stylesheets/beyond_canvas/components/_actions.scss +6 -0
  11. data/app/assets/stylesheets/beyond_canvas/components/_buttons.scss +112 -0
  12. data/app/assets/stylesheets/beyond_canvas/components/_cards.scss +34 -0
  13. data/app/assets/stylesheets/beyond_canvas/components/_comments.scss +6 -0
  14. data/app/assets/stylesheets/beyond_canvas/components/_flash.scss +66 -0
  15. data/app/assets/stylesheets/beyond_canvas/components/_forms.scss +43 -0
  16. data/app/assets/stylesheets/beyond_canvas/components/_inputs.scss +97 -0
  17. data/app/assets/stylesheets/beyond_canvas/components/_layouts.scss +7 -0
  18. data/app/assets/stylesheets/beyond_canvas/components/_links.scss +17 -0
  19. data/app/assets/stylesheets/beyond_canvas/components/_main.scss +39 -0
  20. data/app/assets/stylesheets/beyond_canvas/components/_margins.scss +9 -0
  21. data/app/assets/stylesheets/beyond_canvas/components/_markdown.scss +74 -0
  22. data/app/assets/stylesheets/beyond_canvas/components/_notices.scss +58 -0
  23. data/app/assets/stylesheets/beyond_canvas/components/_relative.scss +3 -0
  24. data/app/assets/stylesheets/beyond_canvas/components/_spinner.scss +48 -0
  25. data/app/assets/stylesheets/beyond_canvas/components/_tables.scss +31 -0
  26. data/app/assets/stylesheets/beyond_canvas/components/_texts.scss +7 -0
  27. data/app/assets/stylesheets/beyond_canvas/mailer.scss +5 -0
  28. data/app/assets/stylesheets/beyond_canvas/settings/{_reset_css.sass → _reset_css.scss} +29 -21
  29. data/app/assets/stylesheets/beyond_canvas/settings/_typography.scss +67 -0
  30. data/app/assets/stylesheets/beyond_canvas/settings/_variables.scss +147 -0
  31. data/app/assets/stylesheets/beyond_canvas/utilities/_mixins.scss +24 -0
  32. data/app/controllers/beyond_canvas/application_controller.rb +1 -1
  33. data/app/controllers/beyond_canvas/system_controller.rb +1 -1
  34. data/app/controllers/concerns/beyond_canvas/locale_management.rb +4 -4
  35. data/app/controllers/concerns/beyond_canvas/request_validation.rb +7 -5
  36. data/app/controllers/concerns/beyond_canvas/status_codes.rb +5 -3
  37. data/app/form_builders/beyond_canvas/form_builder.rb +13 -9
  38. data/app/helpers/beyond_canvas/application_helper.rb +17 -18
  39. data/app/helpers/beyond_canvas/locale_switch_helper.rb +1 -1
  40. data/app/javascript/beyond_canvas/base.js +6 -0
  41. data/app/{assets/javascripts/beyond_canvas → javascript/beyond_canvas/initializers}/buttons.js +19 -14
  42. data/app/{assets/javascripts/beyond_canvas → javascript/beyond_canvas/initializers}/flash.js +11 -7
  43. data/app/javascript/beyond_canvas/initializers/inputs.js +39 -0
  44. data/app/views/beyond_canvas/custom/_public_head.html.erb +1 -0
  45. data/app/views/beyond_canvas/locales/_edit.html.erb +8 -0
  46. data/app/views/beyond_canvas/mailer/_header.html.erb +2 -2
  47. data/app/views/beyond_canvas/shared/_flash.html.erb +13 -0
  48. data/app/views/beyond_canvas/shared/_head.html.erb +29 -0
  49. data/app/views/beyond_canvas/shared/_logo.html.erb +2 -0
  50. data/app/views/layouts/beyond_canvas/public.html.erb +16 -0
  51. data/config/initializers/beyond_canvas/filter_parameter_logging.rb +5 -5
  52. data/lib/beyond_canvas.rb +12 -17
  53. data/lib/beyond_canvas/asset_registration.rb +29 -0
  54. data/lib/beyond_canvas/configuration.rb +27 -0
  55. data/lib/beyond_canvas/engine.rb +10 -1
  56. data/lib/beyond_canvas/version.rb +1 -1
  57. data/lib/generators/beyond_canvas/assets/assets_generator.rb +14 -0
  58. data/lib/generators/beyond_canvas/assets/templates/beyond_canvas.js +1 -0
  59. data/lib/generators/beyond_canvas/assets/templates/beyond_canvas.scss +1 -0
  60. data/lib/generators/beyond_canvas/{install_generator.rb → beyond_api/beyond_api_generator.rb} +1 -7
  61. data/lib/generators/beyond_canvas/{custom_styles_generator.rb → custom_styles/custom_styles_generator.rb} +2 -2
  62. data/lib/generators/{templates → beyond_canvas/custom_styles/templates}/beyond_canvas_custom_styles.sass +0 -0
  63. data/lib/generators/beyond_canvas/install/install_generator.rb +35 -0
  64. data/lib/generators/beyond_canvas/install/templates/beyond_canvas.rb.erb +40 -0
  65. data/lib/generators/beyond_canvas/webpacker/plugins/jquery.js +7 -0
  66. data/lib/generators/beyond_canvas/webpacker/templates/beyond_canvas.js +3 -0
  67. data/lib/generators/beyond_canvas/webpacker/templates/beyond_canvas.scss +1 -0
  68. data/lib/generators/beyond_canvas/webpacker/webpacker_generator.rb +26 -0
  69. metadata +86 -70
  70. data/app/assets/javascripts/beyond_canvas.js +0 -3
  71. data/app/assets/javascripts/beyond_canvas/inputs.js +0 -28
  72. data/app/assets/stylesheets/beyond_canvas.sass +0 -25
  73. data/app/assets/stylesheets/beyond_canvas/components/_actions.sass +0 -5
  74. data/app/assets/stylesheets/beyond_canvas/components/_buttons.sass +0 -86
  75. data/app/assets/stylesheets/beyond_canvas/components/_cards.sass +0 -26
  76. data/app/assets/stylesheets/beyond_canvas/components/_comments.sass +0 -5
  77. data/app/assets/stylesheets/beyond_canvas/components/_flash.sass +0 -51
  78. data/app/assets/stylesheets/beyond_canvas/components/_forms.sass +0 -32
  79. data/app/assets/stylesheets/beyond_canvas/components/_inputs.sass +0 -79
  80. data/app/assets/stylesheets/beyond_canvas/components/_layouts.sass +0 -5
  81. data/app/assets/stylesheets/beyond_canvas/components/_links.sass +0 -13
  82. data/app/assets/stylesheets/beyond_canvas/components/_main.sass +0 -28
  83. data/app/assets/stylesheets/beyond_canvas/components/_margins.sass +0 -7
  84. data/app/assets/stylesheets/beyond_canvas/components/_markdown.sass +0 -60
  85. data/app/assets/stylesheets/beyond_canvas/components/_notices.sass +0 -41
  86. data/app/assets/stylesheets/beyond_canvas/components/_relative.sass +0 -2
  87. data/app/assets/stylesheets/beyond_canvas/components/_spinner.sass +0 -38
  88. data/app/assets/stylesheets/beyond_canvas/components/_tables.sass +0 -25
  89. data/app/assets/stylesheets/beyond_canvas/components/_texts.sass +0 -6
  90. data/app/assets/stylesheets/beyond_canvas/mailer.sass +0 -5
  91. data/app/assets/stylesheets/beyond_canvas/settings/_typography.sass +0 -53
  92. data/app/assets/stylesheets/beyond_canvas/settings/_variables.sass +0 -145
  93. data/app/assets/stylesheets/beyond_canvas/utilities/_mixins.sass +0 -19
  94. data/app/views/beyond_canvas/custom/_public_head.html.slim +0 -0
  95. data/app/views/beyond_canvas/locales/_edit.html.slim +0 -6
  96. data/app/views/beyond_canvas/shared/_flash.html.slim +0 -6
  97. data/app/views/beyond_canvas/shared/_head.html.slim +0 -20
  98. data/app/views/beyond_canvas/shared/_logo.html.slim +0 -2
  99. data/app/views/layouts/beyond_canvas/public.html.slim +0 -12
  100. data/config/initializers/beyond_canvas/assets.rb +0 -5
  101. data/lib/generators/templates/beyond_canvas.rb +0 -20
@@ -1,17 +1,21 @@
1
1
  (function($) {
2
- $(document).on('click', '.flash', function() {
3
- closeAlert();
4
- });
5
-
6
- $(document).on('ready page:load turbolinks:load', function() {
7
- $('.flash').each(function() {
2
+ const onDOMReady = function () {
3
+ $('.flash').each(function () {
8
4
  $(this).css('right', -$(this).width() + 'px');
9
5
  });
10
6
 
11
- setTimeout(function() {
7
+ setTimeout(function () {
12
8
  $('.flash').addClass('flash--shown');
13
9
  }, 100);
10
+ };
11
+
12
+ $(document).on('click', '.flash', function() {
13
+ closeAlert();
14
14
  });
15
+
16
+ $(document)
17
+ .ready(onDOMReady)
18
+ .on('ready page:load turbolinks:load', onDOMReady);
15
19
  })(jQuery);
16
20
 
17
21
  function closeAlert() {
@@ -0,0 +1,39 @@
1
+ (function($) {
2
+ const onDOMReady = function () {
3
+ $('input[type="file"]').each(function () {
4
+ var $input = $(this),
5
+ $label = $(`.input__file__text.${$input.attr('id')}`),
6
+ labelVal = $label.html();
7
+
8
+ $input.on('change', function (e) {
9
+ var fileName = '';
10
+
11
+ if (this.files && this.files.length > 1)
12
+ fileName = (this.getAttribute('data-multiple-caption') || '').replace(
13
+ '{count}',
14
+ this.files.length
15
+ );
16
+ else if (e.target.value) fileName = e.target.value.split('\\').pop();
17
+
18
+ if (fileName)
19
+ $label.html(
20
+ `<svg class="input__file__icon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M15 2v5h5v15h-16v-20h11zm1-2h-14v24h20v-18l-6-6z"/></svg>${fileName}`
21
+ );
22
+ else $label.html(labelVal);
23
+ });
24
+
25
+ // Firefox bug fix
26
+ $input
27
+ .on('focus', function () {
28
+ $input.addClass('has-focus');
29
+ })
30
+ .on('blur', function () {
31
+ $input.removeClass('has-focus');
32
+ });
33
+ });
34
+ };
35
+
36
+ $(document)
37
+ .ready(onDOMReady)
38
+ .on('ready page:load turbolinks:load', onDOMReady);
39
+ })(jQuery);
@@ -0,0 +1,8 @@
1
+ <% if defined?(I18n) && I18n.available_locales.count > 1 %>
2
+ <%= form_for :system, url: beyond_canvas.update_locale_path, method: :put do |f| %>
3
+ <%= f.select :locale, I18n.available_locales.collect { |l| [translate_locale(l), l] },
4
+ { selected: cookies[:locale] },
5
+ class: 'select--locale',
6
+ onchange: 'this.form.submit()' %>
7
+ <% end %>
8
+ <% end %>
@@ -1,8 +1,8 @@
1
1
  <!-- Email Header : BEGIN -->
2
2
  <tr>
3
3
  <td style="padding: 20px 0; text-align: center">
4
- <% if BeyondCanvas.configuration.public_logo.present? %>
5
- <%= image_tag BeyondCanvas.configuration.public_logo, width: "200", height: "50", alt: "alt_text", border: "0", style: "height: auto; font-family: sans-serif; font-size: 15px; line-height: 15px; color: #555555;" %>
4
+ <% if BeyondCanvas.configuration.site_logo.present? %>
5
+ <%= image_tag BeyondCanvas.configuration.site_logo, width: "200", height: "50", alt: "alt_text", border: "0", style: "height: auto; font-family: sans-serif; font-size: 15px; line-height: 15px; color: #555555;" %>
6
6
  <% end %>
7
7
  </td>
8
8
  </tr>
@@ -0,0 +1,13 @@
1
+ <% flash.each do |key, value| %>
2
+ <div class="flash">
3
+ <div class="flash__icon flash__icon--<%= key %>">
4
+ <%= get_flash_icon(key) %>
5
+ </div>
6
+ <div class="flash__message">
7
+ <%= value %>
8
+ </div>
9
+ <div class="flash__close">
10
+ <%= inline_svg_tag 'icons/flash_close.svg' %>
11
+ </div>
12
+ </div>
13
+ <% end %>
@@ -0,0 +1,29 @@
1
+ <head>
2
+
3
+ <%= csrf_meta_tags %>
4
+
5
+ <meta content='width=device-width, initial-scale=1.0' name='viewport' />
6
+
7
+ <title><%= full_title(yield :title) %></title>
8
+
9
+ <%= favicon_link_tag BeyondCanvas.configuration.favicon if BeyondCanvas.configuration.favicon %>
10
+
11
+ <% BeyondCanvas.configuration.stylesheets.each do |style, options| %>
12
+ <% if BeyondCanvas.configuration.skip_webpacker %>
13
+ <%= stylesheet_link_tag style, options %>
14
+ <% else %>
15
+ <%= stylesheet_pack_tag style, options %>
16
+ <% end %>
17
+ <% end %>
18
+
19
+ <% BeyondCanvas.configuration.javascripts.each do |path| %>
20
+ <% if BeyondCanvas.configuration.skip_webpacker %>
21
+ <%= javascript_include_tag path %>
22
+ <% else %>
23
+ <%= javascript_pack_tag path %>
24
+ <% end %>
25
+ <% end %>
26
+
27
+ <%= render 'beyond_canvas/custom/public_head' %>
28
+
29
+ </head>
@@ -0,0 +1,2 @@
1
+ <% logo = BeyondCanvas.configuration.site_logo %>
2
+ <%= logo_image_tag(logo) unless logo.nil? %>
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <%= render 'beyond_canvas/shared/head' %>
5
+
6
+ <body class="body--public">
7
+ <main class="main <%= params[:controller].gsub(/[\/_]/, "-") %>--<%= params[:action] %>">
8
+ <%= render 'beyond_canvas/shared/flash' %>
9
+ <%= render 'beyond_canvas/locales/edit' %>
10
+ <div class="main-wrapper">
11
+ <%= render 'beyond_canvas/shared/logo' %>
12
+ <%= yield %>
13
+ </div>
14
+ </main>
15
+ </body>
16
+ </html>
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Filter app installation parameters
4
- Rails.application.config.filter_parameters += [
5
- :access_token_url,
6
- :code,
7
- :return_url,
8
- :signature
4
+ Rails.application.config.filter_parameters += %i[
5
+ access_token_url
6
+ code
7
+ return_url
8
+ signature
9
9
  ]
data/lib/beyond_canvas.rb CHANGED
@@ -4,32 +4,27 @@ require 'beyond_canvas/engine'
4
4
 
5
5
  require 'colorize'
6
6
 
7
+ require 'jquery-rails'
7
8
  require 'bourbon'
8
- require 'slim-rails'
9
+ require 'sassc-rails'
9
10
  require 'inline_svg'
10
11
  require 'http/accept'
11
12
  require 'premailer/rails'
12
13
 
13
14
  require 'beyond_api'
14
15
 
15
- module BeyondCanvas
16
- class << self
17
- attr_accessor :configuration
18
- end
16
+ module BeyondCanvas # :nodoc:
17
+ autoload :AssetRegistration, 'beyond_canvas/asset_registration'
18
+ autoload :Configuration, 'beyond_canvas/configuration'
19
19
 
20
- def self.setup
21
- self.configuration ||= Configuration.new
22
-
23
- yield configuration
24
- end
25
-
26
- class Configuration
27
- attr_accessor :public_logo, :stylesheet_link_tag, :javascript_include_tag
20
+ class << self
21
+ def configuration
22
+ @configuration ||= ::BeyondCanvas::Configuration.new
23
+ end
28
24
 
29
- def initialize
30
- @public_logo = nil
31
- @stylesheet_link_tag = 'application'
32
- @javascript_include_tag = 'application'
25
+ def setup
26
+ configuration.setup!
27
+ yield configuration
33
28
  end
34
29
  end
35
30
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BeyondCanvas
4
+ module AssetRegistration # :nodoc:
5
+ def register_stylesheet(path, options = {})
6
+ stylesheets[path] = options
7
+ end
8
+
9
+ def stylesheets
10
+ @stylesheets ||= {}
11
+ end
12
+
13
+ def clear_stylesheets!
14
+ stylesheets.clear
15
+ end
16
+
17
+ def register_javascript(name)
18
+ javascripts.add name
19
+ end
20
+
21
+ def javascripts
22
+ @javascripts ||= Set.new
23
+ end
24
+
25
+ def clear_javascripts!
26
+ javascripts.clear
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BeyondCanvas
4
+ class Configuration # :nodoc:
5
+ attr_accessor :site_title, :site_logo, :favicon, :skip_webpacker
6
+
7
+ include AssetRegistration
8
+
9
+ def initialize
10
+ @site_title = ::Rails.application.class.name.split('::').first.humanize
11
+ @site_logo = nil
12
+ @favicon = nil
13
+ @skip_webpacker = false
14
+ end
15
+
16
+ def setup!
17
+ register_default_assets
18
+ end
19
+
20
+ private
21
+
22
+ def register_default_assets
23
+ register_stylesheet 'beyond_canvas.css', media: 'screen'
24
+ register_javascript 'beyond_canvas.js'
25
+ end
26
+ end
27
+ end
@@ -1,9 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BeyondCanvas
4
- class Engine < ::Rails::Engine
4
+ class Engine < ::Rails::Engine # :nodoc:
5
5
  isolate_namespace BeyondCanvas
6
6
 
7
+ initializer 'beyond_canvas.assets.precompile' do |app|
8
+ BeyondCanvas.configuration.stylesheets.each do |path, _|
9
+ app.config.assets.precompile << path
10
+ end
11
+ BeyondCanvas.configuration.javascripts.each do |path|
12
+ app.config.assets.precompile << path
13
+ end
14
+ end
15
+
7
16
  config.before_initialize do
8
17
  ActiveSupport.on_load :action_controller do
9
18
  include ::BeyondCanvas::LocaleManagement
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BeyondCanvas
4
- VERSION = '0.13.1.pre'
4
+ VERSION = '0.14.0.pre'
5
5
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BeyondCanvas
4
+ module Generators
5
+ class AssetsGenerator < Rails::Generators::Base # :nodoc:
6
+ source_root File.expand_path('templates', __dir__)
7
+
8
+ def install_assets
9
+ template 'beyond_canvas.js', 'app/assets/javascripts/beyond_canvas.js'
10
+ template 'beyond_canvas.scss', 'app/assets/stylesheets/beyond_canvas.scss'
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1 @@
1
+ //= require beyond_canvas/base
@@ -0,0 +1 @@
1
+ @import "beyond_canvas/base";
@@ -2,13 +2,7 @@
2
2
 
3
3
  module BeyondCanvas
4
4
  module Generators
5
- class InstallGenerator < Rails::Generators::Base
6
- source_root File.expand_path('../templates', __dir__)
7
-
8
- def copy_initializer
9
- template 'beyond_canvas.rb', 'config/initializers/beyond_canvas.rb'
10
- end
11
-
5
+ class BeyondApiGenerator < Rails::Generators::Base # :nodoc:
12
6
  def install_beyond_api
13
7
  require 'beyond_api'
14
8
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  module BeyondCanvas
4
4
  module Generators
5
- class CustomStylesGenerator < Rails::Generators::Base
6
- source_root File.expand_path('../templates', __dir__)
5
+ class CustomStylesGenerator < Rails::Generators::Base # :nodoc:
6
+ source_root File.expand_path('templates', __dir__)
7
7
 
8
8
  def copy_initializer
9
9
  template 'beyond_canvas_custom_styles.sass', 'app/assets/stylesheets/_beyond_canvas_custom_styles.sass'
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BeyondCanvas
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base # :nodoc:
6
+ desc 'Installs Beyond Canvas and generates the necessary files'
7
+
8
+ class_option :skip_webpacker, type: :boolean, default: false, desc: 'Use Sprockets assets instead of Webpacker'
9
+
10
+ source_root File.expand_path('templates', __dir__)
11
+
12
+ def copy_initializer
13
+ @skip_webpacker = options[:skip_webpacker]
14
+
15
+ template 'beyond_canvas.rb.erb', 'config/initializers/beyond_canvas.rb'
16
+ end
17
+
18
+ def setup_routes
19
+ route "mount BeyondCanvas::Engine => '/'"
20
+ end
21
+
22
+ def create_assets
23
+ if options[:skip_webpacker]
24
+ generate 'beyond_canvas:assets'
25
+ else
26
+ generate 'beyond_canvas:webpacker'
27
+ end
28
+ end
29
+
30
+ def install_beyond_api
31
+ generate 'beyond_api:install'
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ BeyondCanvas.setup do |config|
4
+ # ==> Site configuration
5
+
6
+ # Set the title that is displayed on the main layout..
7
+ #
8
+ config.site_title = '<%= Rails.application.class.name.split("::").first.humanize %>'
9
+
10
+ # Set an optional image to be displayed instead of a string. Accepts any
11
+ # string supported by image_tag's source parameter or a SVG file. Overrides
12
+ # :site_title.
13
+ #
14
+ # config.site_logo = 'logo.png'
15
+
16
+ # Set the favicon of the site.
17
+ #
18
+ # config.favicon = 'favicon.ico'
19
+
20
+ # ==> Stylesheets & Javascripts
21
+
22
+ # We recommend using the built in Beyond Canvas layout and loading up your own
23
+ # stylesheets / javascripts to customize the look and feel.
24
+ #
25
+ # To load a stylesheet:
26
+ # config.register_stylesheet 'my_stylesheet.css'
27
+ #
28
+ # You can provide an options hash for more control, which is passed along to stylesheet_link_tag():
29
+ # config.register_stylesheet 'my_print_stylesheet.css', media: :print
30
+ #
31
+ # To load a javascript file:
32
+ # config.register_javascript 'my_javascript.js'
33
+
34
+ # ==> Webpacker
35
+
36
+ # By default, Active Admin uses Webpacker.
37
+ # You can switch to using Sprocket's asset pipeline here.
38
+ #
39
+ <% unless @skip_webpacker %># <% end %>config.skip_webpacker = <%= @skip_webpacker %>
40
+ end