cmor_core 0.0.1.pre

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.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +28 -0
  4. data/Rakefile +19 -0
  5. data/app/assets/config/cmor_core_manifest.js +2 -0
  6. data/app/assets/javascripts/cmor/core/application.js +13 -0
  7. data/app/assets/javascripts/cmor/core/application/keep.js +0 -0
  8. data/app/assets/javascripts/cmor/core/backend/application.js +13 -0
  9. data/app/assets/javascripts/cmor/core/backend/application/keep.js +0 -0
  10. data/app/assets/javascripts/cmor_core.js +1 -0
  11. data/app/assets/javascripts/cmor_core_backend.js +1 -0
  12. data/app/assets/stylesheets/cmor/core/application.css +4 -0
  13. data/app/assets/stylesheets/cmor/core/application/bootstrap-flex-row.css +35 -0
  14. data/app/assets/stylesheets/cmor/core/application/bottom-margin.css +10 -0
  15. data/app/assets/stylesheets/cmor_core.css +3 -0
  16. data/app/concerns/controller/store_remote_ip_concern.rb +15 -0
  17. data/app/controllers/cmor/core/application_controller.rb +7 -0
  18. data/app/controllers/cmor/core/home_controller.rb +10 -0
  19. data/app/helpers/cmor/core/application_helper.rb +17 -0
  20. data/app/jobs/cmor/core/application_job.rb +6 -0
  21. data/app/mailers/cmor/core/application_mailer.rb +8 -0
  22. data/app/models/cmor/core/application_record.rb +7 -0
  23. data/app/view_helpers/cmor/core/application_view_helper.rb +40 -0
  24. data/app/view_helpers/cmor/core/markup_view_helper.rb +12 -0
  25. data/app/views/cmor/core/backend/active_storage/attachments/_index_table.haml +7 -0
  26. data/app/views/cmor/core/backend/active_storage/blobs/_index_table.haml +15 -0
  27. data/app/views/layouts/cmor/core/application.html.erb +14 -0
  28. data/config/initializers/assets.rb +2 -0
  29. data/config/locales/de.yml +101 -0
  30. data/config/locales/en.yml +102 -0
  31. data/config/routes.rb +5 -0
  32. data/lib/cmor/core.rb +22 -0
  33. data/lib/cmor/core/configuration.rb +16 -0
  34. data/lib/cmor/core/engine.rb +14 -0
  35. data/lib/cmor/core/gemspec.rb +37 -0
  36. data/lib/cmor/core/spec_helpers/feature.rb +30 -0
  37. data/lib/cmor/core/version.rb +7 -0
  38. data/lib/cmor_core.rb +8 -0
  39. data/lib/generators/cmor/core/install/install_generator.rb +30 -0
  40. data/lib/generators/cmor/core/install/templates/frontend_controller.rb +2 -0
  41. data/lib/generators/cmor/core/install/templates/initializer.rb +7 -0
  42. data/lib/generators/cmor/core/install/templates/routes.source +3 -0
  43. data/lib/tasks/cmor_core_tasks.rake +4 -0
  44. data/spec/dummy/app/controllers/frontend_controller.rb +2 -0
  45. data/spec/dummy/config/initializers/cmor_core.rb +7 -0
  46. data/spec/dummy/config/initializers/content_security_policy.rb +25 -0
  47. data/spec/dummy/config/initializers/i18n.rb +2 -0
  48. data/spec/dummy/config/storage.yml +34 -0
  49. data/spec/dummy/db/development.sqlite3 +0 -0
  50. data/spec/dummy/db/migrate/20190325174253_create_active_storage_tables.active_storage.rb +27 -0
  51. data/spec/dummy/db/test.sqlite3 +0 -0
  52. data/spec/dummy/log/development.log +0 -0
  53. data/spec/dummy/tmp/development_secret.txt +1 -0
  54. data/spec/rails_helper.rb +62 -0
  55. data/spec/spec_helper.rb +96 -0
  56. data/spec/support/capybara.rb +1 -0
  57. data/spec/support/factory_bot.rb +5 -0
  58. data/spec/support/rao-shoulda_matchers.rb +5 -0
  59. data/spec/support/shoulda_matchers.rb +8 -0
  60. metadata +395 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c0b099887221df695c0f73987dcda78debae38451ad3a8c56492125cc75d357a
4
+ data.tar.gz: 8c6cb06277888ff0630901552016a68ad361b3eb9f9cad09fcf0ea264505c175
5
+ SHA512:
6
+ metadata.gz: cd69219d45ccd5c594b45829b72b8a776aae5cb99f0fd3ea84ef23f3bbaf310f8086eab2a5ca435af5f18a6b8cb4cdf5b5df70a84294518ed7b1d9cccc8e66d2
7
+ data.tar.gz: 6b4e400634e5d8e4ff971ca9dc616aaff5f6e8e3406426a4e7c9c0c425afe98480c87aba74140a41e4b17322457053f2dd38ff9e8db685f3439b5a31503a72a2
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2017 Roberto Vasquez Angel
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Cmor::Core
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'cmor_core'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install cmor_core
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Cmor::Core'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ Bundler::GemHelper.install_tasks
18
+
19
+ require 'rails/dummy/tasks'
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts/cmor/core .js
2
+ //= link_directory ../stylesheets/cmor/core .css
@@ -0,0 +1,13 @@
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_tree ./application
@@ -0,0 +1,13 @@
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_tree ./application
@@ -0,0 +1 @@
1
+ //= require ./cmor/core/application
@@ -0,0 +1 @@
1
+ //= require ./cmor/core/backend/application
@@ -0,0 +1,4 @@
1
+ /*
2
+ *= require_tree ./application
3
+ *= require_self
4
+ */
@@ -0,0 +1,35 @@
1
+ .row.flex-row {
2
+ display: flex;
3
+ flex-wrap: wrap;
4
+ }
5
+ .row.flex-row > [class*='col-'] {
6
+ display: flex;
7
+ flex-direction: column;
8
+ }
9
+
10
+ /*
11
+ * And with max cross-browser enabled.
12
+ * Nobody should ever write this by hand.
13
+ * Use a preprocesser with autoprefixing.
14
+ */
15
+ .row.flex-row {
16
+ display: -webkit-box;
17
+ display: -webkit-flex;
18
+ display: -ms-flexbox;
19
+ display: flex;
20
+ -webkit-flex-wrap: wrap;
21
+ -ms-flex-wrap: wrap;
22
+ flex-wrap: wrap;
23
+ }
24
+
25
+ .row.flex-row > [class*='col-'] {
26
+ display: -webkit-box;
27
+ display: -webkit-flex;
28
+ display: -ms-flexbox;
29
+ display: flex;
30
+ -webkit-box-orient: vertical;
31
+ -webkit-box-direction: normal;
32
+ -webkit-flex-direction: column;
33
+ -ms-flex-direction: column;
34
+ flex-direction: column;
35
+ }
@@ -0,0 +1,10 @@
1
+ .bottom-margin-1 { margin-bottom: 10px; }
2
+ .bottom-margin-2 { margin-bottom: 20px; }
3
+ .bottom-margin-3 { margin-bottom: 30px; }
4
+ .bottom-margin-4 { margin-bottom: 40px; }
5
+ .bottom-margin-5 { margin-bottom: 50px; }
6
+ .bottom-margin-6 { margin-bottom: 60px; }
7
+ .bottom-margin-7 { margin-bottom: 70px; }
8
+ .bottom-margin-8 { margin-bottom: 80px; }
9
+ .bottom-margin-9 { margin-bottom: 90px; }
10
+ .bottom-margin-10 { margin-bottom: 100px; }
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require cmor/core/application
3
+ */
@@ -0,0 +1,15 @@
1
+ module Controller
2
+ module StoreRemoteIpConcern
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ before_action :store_remote_ip
7
+ end
8
+
9
+ private
10
+
11
+ def store_remote_ip
12
+ RequestLocals.store[:remote_ip] = request.remote_ip
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ module Cmor
2
+ module Core
3
+ class ApplicationController < ActionController::Base
4
+ protect_from_forgery with: :exception
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ module Cmor
2
+ module Core
3
+ class HomeController < Cmor::Core::Configuration.base_controller.constantize
4
+
5
+ def index
6
+ render plain: 'Welcome!'
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ module Cmor
2
+ module Core
3
+ module ApplicationHelper
4
+ def bootstrap_paginate(objects, options = {})
5
+ options.reverse_merge!(theme: 'twitter-bootstrap-3')
6
+
7
+ paginate(objects, options)
8
+ end
9
+
10
+ # def mu(object, method)
11
+ # handler = object.send(method)
12
+ # erb_string = ::ERB.new(object[method.to_sym].to_s, 0).result(binding)
13
+ # handler.class.new(erb_string).to_html.html_safe
14
+ # end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,6 @@
1
+ module Cmor
2
+ module Core
3
+ class ApplicationJob < ActiveJob::Base
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ module Cmor
2
+ module Core
3
+ class ApplicationMailer < ActionMailer::Base
4
+ default from: 'from@example.com'
5
+ layout 'mailer'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ module Cmor
2
+ module Core
3
+ class ApplicationRecord < ActiveRecord::Base
4
+ self.abstract_class = true
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,40 @@
1
+ module Cmor
2
+ module Core
3
+ # Usage:
4
+ #
5
+ # class ApplicationController < ActionController::Base
6
+ # view_helper Cmor::Core::ApplicationViewHelper, as: :core_helper
7
+ # end
8
+ #
9
+ class ApplicationViewHelper < Rao::ViewHelper::Base
10
+ module FlashConcern
11
+ extend ActiveSupport::Concern
12
+
13
+ included do
14
+ def map_message_type_to_context(message_type)
15
+ { success: "success", error: "danger", alert: "warning", notice: "info" }[message_type.to_sym] || message_type.to_s
16
+ end
17
+ end
18
+
19
+ # Usage:
20
+ #
21
+ # # app/views/layouts/application.html.erb
22
+ # <%= core_helper(self).render_flash %>
23
+ #
24
+ def render_flash
25
+ c.flash.each_with_object({}) do |(key, value), memo|
26
+ memo[map_message_type_to_context(key)] = value
27
+ end
28
+ end
29
+
30
+ private
31
+
32
+ def map_message_type_to_context(message_type)
33
+ self.class.map_message_type_to_context(message_type)
34
+ end
35
+ end
36
+
37
+ include FlashConcern
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,12 @@
1
+ module Cmor
2
+ module Core
3
+ class MarkupViewHelper < Rao::ViewHelper::Base
4
+ def render(object, method)
5
+ handler = object.send(method)
6
+ return if handler.nil?
7
+ erb_string = ::ERB.new(object[method.to_sym].to_s, 0).result(binding)
8
+ handler.class.new(erb_string).to_html.html_safe
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ = table.column :name
2
+ = table.column :record
3
+ = table.column :blob do |resource|
4
+ - link_to(resource.blob.filename, [:active_storage, resource.blob])
5
+ = table.column :created_at
6
+ = table.column :additional_actions do |resource|
7
+ - link_to(t('.download'), main_app.url_for(resource.blob), class: 'btn btn-primary btn-xs')
@@ -0,0 +1,15 @@
1
+ = table.column :key
2
+ = table.column :filename do |resource|
3
+ - resource.filename.to_s
4
+ = table.column :content_type
5
+ = table.column :metadata do |resource|
6
+ - capture_haml do
7
+ %ul
8
+ - resource.metadata.each do |key, value|
9
+ %li= "#{key}: #{value}"
10
+ = table.column :byte_size do |resource|
11
+ - number_to_human_size(resource.byte_size)
12
+ = table.column :checksum
13
+ = table.column :created_at
14
+ = table.column :additional_actions do |resource|
15
+ - link_to(t('.download'), main_app.url_for(resource), class: 'btn btn-primary btn-xs')
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Cmor core</title>
5
+ <%= stylesheet_link_tag "cmor/core/application", media: "all" %>
6
+ <%= javascript_include_tag "cmor/core/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,2 @@
1
+ Rails.application.config.assets.precompile += %w( cmor_core.css )
2
+ Rails.application.config.assets.precompile += %w( cmor_core.js )
@@ -0,0 +1,101 @@
1
+ de:
2
+ classes:
3
+ cmor/core/backend/engine: Core
4
+ routes:
5
+ cmor-core-backend-engine: core
6
+ or: oder
7
+ activerecord:
8
+ models:
9
+ acts_as_taggable_on/tag:
10
+ one: Tag
11
+ other: Tag
12
+ acts_as_taggable_on/tagging:
13
+ one: Tagging
14
+ other: Tagging
15
+ delayed/backend/active_record/job:
16
+ one: Hintergrundjob
17
+ other: Hintergrundjobs
18
+ i18n/backend/active_record/translation:
19
+ one: Übersetzung
20
+ other: Übersetzungen
21
+ delayed/job:
22
+ one: Hintergrundjob
23
+ other: Hintergrundjobs
24
+ active_storage/attachment:
25
+ one: Datei
26
+ other: Dateien
27
+ active_storage/blob:
28
+ one: Dateiinhalt
29
+ other: Dateiinhalte
30
+ attributes:
31
+ acts_as_taggable_on/tag:
32
+ id: ID
33
+ name: Name
34
+ taggings_count: Taggings
35
+ color: Farbe
36
+ acts_as_taggable_on/tagging:
37
+ id: ID
38
+ tag: Tag
39
+ tag_id: Tag
40
+ taggable: Getaggtes Objekt
41
+ taggable_id: Getaggtes Objekt
42
+ taggable_type: Getaggtes Objekt-Typ
43
+ tagger: Erstellt durch
44
+ tagger_id: Erstellt durch
45
+ tagger_type: Ersteller Objekt-Typ
46
+ context: Kontext
47
+ created_at: Erstellt am
48
+ delayed/backend/active_record/job:
49
+ id: ID
50
+ priority: Priorität
51
+ attempts: Versuche
52
+ handler: handler
53
+ last_error: Letzter Fehler
54
+ run_at: Gestartet am
55
+ locked_at: Gesperrt am
56
+ failed_at: Gescheitert am
57
+ locked_by: Gesperrt durch
58
+ queue: Warteschlange
59
+ created_at: Erstellt am
60
+ updated_at: Aktualisiert am
61
+ i18n/backend/active_record/translation:
62
+ id: ID
63
+ locale: Sprache
64
+ key: Schlüssel
65
+ value: Wert
66
+ interpolations: Interpolierungen
67
+ is_proc: Ist Prozedur?
68
+ created_at: Erstellt am
69
+ updated_at: Aktualisiert am
70
+ delayed/job:
71
+ priority: Priorität
72
+ attempts: Versuche
73
+ handler: handler
74
+ last_error: Letzter Fehler
75
+ run_at: Gestartet am
76
+ locked_at: Gesperrt am
77
+ failed_at: Gescheitert am
78
+ locked_by: Gesperrt durch
79
+ queue: Warteschlange
80
+ created_at: Erstellt am
81
+ updated_at: Aktualisiert am
82
+ active_storage/attachment:
83
+ id: ID
84
+ additional_actions: Weitere Aktionen
85
+ name: Name
86
+ record: Angehängt an
87
+ record_id: Angehängt an
88
+ record_type: Objekt-Typ
89
+ blob: Datei
90
+ blob_id: Datei
91
+ created_at: Erstellt am
92
+ active_storage/blob:
93
+ id: ID
94
+ additional_actions: Weitere Aktionen
95
+ key: Schlüssel
96
+ filename: Dateiname
97
+ content_type: Dateityp
98
+ metadata: Metadaten
99
+ byte_size: Dateigröße
100
+ checksum: Checksumme
101
+ created_at: Erstellt am