cmor_files 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 (120) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +44 -0
  4. data/Rakefile +19 -0
  5. data/app/assets/config/cmor_files_manifest.js +2 -0
  6. data/app/assets/javascripts/cmor/files/application/keep.js +0 -0
  7. data/app/assets/javascripts/cmor/files/application.js +14 -0
  8. data/app/assets/stylesheets/cmor/files/application/keep.css +0 -0
  9. data/app/assets/stylesheets/cmor/files/application.css +15 -0
  10. data/app/controllers/cmor/files/application_controller.rb +5 -0
  11. data/app/controllers/cmor/files/application_resources_controller.rb +18 -0
  12. data/app/controllers/cmor/files/folders_controller.rb +19 -0
  13. data/app/helpers/cmor/files/application_helper.rb +4 -0
  14. data/app/jobs/cmor/files/application_job.rb +4 -0
  15. data/app/mailers/cmor/files/application_mailer.rb +6 -0
  16. data/app/models/cmor/files/application_record.rb +5 -0
  17. data/app/models/cmor/files/file_detail.rb +6 -0
  18. data/app/models/cmor/files/folder.rb +71 -0
  19. data/app/views/cmor/files/folders/index.haml +9 -0
  20. data/app/views/cmor/files/folders/show.haml +17 -0
  21. data/app/views/layouts/cmor/files/application.html.erb +14 -0
  22. data/config/initializers/assets.rb +1 -0
  23. data/config/initializers/i18n.rb +2 -0
  24. data/config/locales/de.yml +44 -0
  25. data/config/locales/en.yml +44 -0
  26. data/config/routes.rb +7 -0
  27. data/db/migrate/20180301094240_create_cmor_files_folders.rb +11 -0
  28. data/db/migrate/20180302082402_create_cmor_files_file_details.rb +13 -0
  29. data/lib/cmor/files/configuration.rb +9 -0
  30. data/lib/cmor/files/engine.rb +13 -0
  31. data/lib/cmor/files/version.rb +7 -0
  32. data/lib/cmor/files.rb +10 -0
  33. data/lib/cmor_files.rb +6 -0
  34. data/lib/generators/cmor/files/install/install_generator.rb +24 -0
  35. data/lib/generators/cmor/files/install/templates/initializer.rb +7 -0
  36. data/lib/generators/cmor/files/install/templates/routes.source +3 -0
  37. data/lib/tasks/cmor_files_tasks.rake +4 -0
  38. data/spec/config/locales/de.yml +3 -0
  39. data/spec/dummy/config/initializers/cmor_files.rb +7 -0
  40. data/spec/dummy/config/initializers/i18n.rb +2 -0
  41. data/spec/dummy/db/development.sqlite3 +0 -0
  42. data/spec/dummy/db/migrate/20190325174535_create_active_storage_tables.active_storage.rb +27 -0
  43. data/spec/dummy/db/migrate/20190325174557_create_cmor_files_folders.cmor_files.rb +12 -0
  44. data/spec/dummy/db/migrate/20190325174558_create_cmor_files_file_details.cmor_files.rb +14 -0
  45. data/spec/dummy/db/test.sqlite3 +0 -0
  46. data/spec/dummy/log/development.log +122 -0
  47. data/spec/dummy/log/test.log +143 -0
  48. data/spec/dummy/tmp/development_secret.txt +1 -0
  49. data/spec/dummy/tmp/storage/Bh/RE/BhREgVesQFJGKZawuwybEm9o +0 -0
  50. data/spec/dummy/tmp/storage/x9/kn/x9knsAYKxaGksCFoE1kksZUn +0 -0
  51. data/spec/dummy~/Rakefile +6 -0
  52. data/spec/dummy~/app/assets/config/manifest.js +4 -0
  53. data/spec/dummy~/app/assets/javascripts/application.js +14 -0
  54. data/spec/dummy~/app/assets/javascripts/cable.js +13 -0
  55. data/spec/dummy~/app/assets/stylesheets/application.css +15 -0
  56. data/spec/dummy~/app/channels/application_cable/channel.rb +4 -0
  57. data/spec/dummy~/app/channels/application_cable/connection.rb +4 -0
  58. data/spec/dummy~/app/controllers/application_controller.rb +2 -0
  59. data/spec/dummy~/app/helpers/application_helper.rb +2 -0
  60. data/spec/dummy~/app/jobs/application_job.rb +2 -0
  61. data/spec/dummy~/app/mailers/application_mailer.rb +4 -0
  62. data/spec/dummy~/app/models/application_record.rb +3 -0
  63. data/spec/dummy~/app/views/layouts/application.html.erb +14 -0
  64. data/spec/dummy~/app/views/layouts/mailer.html.erb +13 -0
  65. data/spec/dummy~/app/views/layouts/mailer.text.erb +1 -0
  66. data/spec/dummy~/bin/bundle +3 -0
  67. data/spec/dummy~/bin/rails +4 -0
  68. data/spec/dummy~/bin/rake +4 -0
  69. data/spec/dummy~/bin/setup +36 -0
  70. data/spec/dummy~/bin/update +31 -0
  71. data/spec/dummy~/bin/yarn +11 -0
  72. data/spec/dummy~/config/application.rb +30 -0
  73. data/spec/dummy~/config/boot.rb +5 -0
  74. data/spec/dummy~/config/cable.yml +10 -0
  75. data/spec/dummy~/config/database.yml +25 -0
  76. data/spec/dummy~/config/environment.rb +5 -0
  77. data/spec/dummy~/config/environments/development.rb +61 -0
  78. data/spec/dummy~/config/environments/production.rb +94 -0
  79. data/spec/dummy~/config/environments/test.rb +46 -0
  80. data/spec/dummy~/config/initializers/application_controller_renderer.rb +8 -0
  81. data/spec/dummy~/config/initializers/assets.rb +14 -0
  82. data/spec/dummy~/config/initializers/backtrace_silencers.rb +7 -0
  83. data/spec/dummy~/config/initializers/cmor/files.rb +7 -0
  84. data/spec/dummy~/config/initializers/content_security_policy.rb +22 -0
  85. data/spec/dummy~/config/initializers/cookies_serializer.rb +5 -0
  86. data/spec/dummy~/config/initializers/filter_parameter_logging.rb +4 -0
  87. data/spec/dummy~/config/initializers/inflections.rb +16 -0
  88. data/spec/dummy~/config/initializers/mime_types.rb +4 -0
  89. data/spec/dummy~/config/initializers/wrap_parameters.rb +14 -0
  90. data/spec/dummy~/config/locales/en.yml +33 -0
  91. data/spec/dummy~/config/puma.rb +34 -0
  92. data/spec/dummy~/config/routes.rb +3 -0
  93. data/spec/dummy~/config/spring.rb +6 -0
  94. data/spec/dummy~/config/storage.yml +35 -0
  95. data/spec/dummy~/config.ru +5 -0
  96. data/spec/dummy~/db/development.sqlite3 +0 -0
  97. data/spec/dummy~/db/schema.rb +41 -0
  98. data/spec/dummy~/db/test.sqlite3 +0 -0
  99. data/spec/dummy~/log/test.log +0 -0
  100. data/spec/dummy~/package.json +5 -0
  101. data/spec/dummy~/public/404.html +67 -0
  102. data/spec/dummy~/public/422.html +67 -0
  103. data/spec/dummy~/public/500.html +66 -0
  104. data/spec/dummy~/public/apple-touch-icon-precomposed.png +0 -0
  105. data/spec/dummy~/public/apple-touch-icon.png +0 -0
  106. data/spec/dummy~/public/favicon.ico +0 -0
  107. data/spec/factories/cmor_files_file_details.rb +17 -0
  108. data/spec/factories/cmor_files_folders.rb +5 -0
  109. data/spec/files/cmor/files/file_details/example.png +0 -0
  110. data/spec/models/cmor/files/file_detail_spec.rb +7 -0
  111. data/spec/models/cmor/files/folder_spec.rb +12 -0
  112. data/spec/models/generic_spec.rb +50 -0
  113. data/spec/models/i18n_spec.rb +41 -0
  114. data/spec/rails_helper.rb +62 -0
  115. data/spec/spec_helper.rb +96 -0
  116. data/spec/support/capybara.rb +1 -0
  117. data/spec/support/factory_bot.rb +5 -0
  118. data/spec/support/rao-shoulda_matchers.rb +5 -0
  119. data/spec/support/shoulda_matchers.rb +8 -0
  120. metadata +469 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 70cd107d2c4ac0eaed207ec61a5916d139aaa98c4ea80b5d7574005df010d719
4
+ data.tar.gz: 4bf97f90e9f6383c520ffc791c8657634e2e425a02a9d76ef1007cb8b3ea3e1b
5
+ SHA512:
6
+ metadata.gz: 5df2312bdfa0ba43c4617d6e3a84c5b927f6a22003f7ecd686b758402fa575af0d9075881490d92724689a5e5ee6158f6e2242c76b8e7e10f831359a198ff892
7
+ data.tar.gz: 9c915b00bd25a3c006b46e32b8b19400108fb15948dc48f0795306f1ad4f40988702dea607aeafb701f3df4d7daaa0f7887795c455feeb877463569e690ebc35
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2018 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,44 @@
1
+ # Cmor::Files
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Prerequisites
8
+
9
+ Make sure you have installed and configured active storage.
10
+
11
+ ## Installation
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'cmor_files'
16
+ ```
17
+
18
+ And then execute:
19
+ ```bash
20
+ $ bundle
21
+ ```
22
+
23
+ Or install it yourself as:
24
+ ```bash
25
+ $ gem install cmor_files
26
+ ```
27
+
28
+ Add migrations and migrate:
29
+
30
+ ```bash
31
+ $ rake cmor_files:install:migrations && rake db:migrate
32
+ ```
33
+
34
+ Install routes and initializer:
35
+
36
+ ```bash
37
+ $ rails g cmor:files:install
38
+ ```
39
+
40
+ ## Contributing
41
+ Contribution directions go here.
42
+
43
+ ## License
44
+ The gem is available as open source under the terms of the [MIT License](https://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::Files'
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/files .js
2
+ //= link_directory ../stylesheets/cmor/files .css
@@ -0,0 +1,14 @@
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 activestorage
14
+ //= require_tree ./application
@@ -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 ./application
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ module Cmor::Files
2
+ class ApplicationController < Cmor::Files::Configuration.base_controller.constantize
3
+ protect_from_forgery with: :exception
4
+ end
5
+ end
@@ -0,0 +1,18 @@
1
+ module Cmor::Files
2
+ class ApplicationResourcesController < Cmor::Blog::Configuration.base_controller.constantize
3
+ include Rao::ResourcesController::RestActionsConcern
4
+ include Rao::ResourcesController::ResourcesConcern
5
+ include Rao::ResourcesController::RestResourceUrlsConcern
6
+ include Rao::ResourcesController::ResourceInflectionsConcern
7
+ include Rao::ResourcesController::LocationHistoryConcern
8
+ include Rao::Query::Controller::QueryConcern
9
+
10
+ helper Twitter::Bootstrap::Components::Rails::V4::ComponentsHelper
11
+
12
+ private
13
+
14
+ def load_collection_scope
15
+ with_conditions_from_query(resource_class)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ module Cmor::Files
2
+ class FoldersController < ApplicationResourcesController
3
+ helper Rao::Component::ApplicationHelper
4
+
5
+ def self.resource_class
6
+ Cmor::Files::Folder
7
+ end
8
+
9
+ private
10
+
11
+ def load_collection_scope
12
+ super.published
13
+ end
14
+
15
+ def load_resource_scope
16
+ super.published
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,4 @@
1
+ module Cmor::Files
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Cmor::Files
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module Cmor::Files
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: 'from@example.com'
4
+ layout 'mailer'
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Cmor::Files
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ module Cmor::Files
2
+ class FileDetail < ApplicationRecord
3
+ belongs_to :folder
4
+ belongs_to :asset, class_name: 'ActiveStorage::Attachment', dependent: :destroy
5
+ end
6
+ end
@@ -0,0 +1,71 @@
1
+ module Cmor::Files
2
+ class Folder < ApplicationRecord
3
+ include ActsAsPublished::ActiveRecord
4
+
5
+ has_many_attached :assets
6
+
7
+ acts_as_published
8
+
9
+ validates :name, presence: true, uniqueness: true
10
+
11
+ def human
12
+ "#{self.class.model_name.human}: #{I18n.l(created_at)}"
13
+ end
14
+
15
+ def assets_count
16
+ assets.count
17
+ end
18
+
19
+ module FileDetailsConcern
20
+ extend ActiveSupport::Concern
21
+
22
+ included do
23
+ has_many :file_details, inverse_of: :folder, dependent: :destroy, autosave: true
24
+ before_validation :cleanup_orphaned_file_details
25
+ before_validation :ensure_file_details
26
+ end
27
+
28
+ def append_assets
29
+ assets
30
+ end
31
+
32
+ def append_assets=(assets)
33
+ if Rails.version < '6.0.0'
34
+ self.assets = assets
35
+ else
36
+ self.assets.attach(assets)
37
+ end
38
+ end
39
+
40
+ def overwrite_assets
41
+ assets
42
+ end
43
+
44
+ def overwrite_assets=(assets)
45
+ return if assets.nil? || assets.empty?
46
+ self.file_details.map { |fd| fd.mark_for_destruction }
47
+ self.assets = assets
48
+ end
49
+
50
+ private
51
+
52
+ def cleanup_orphaned_file_details
53
+ file_details.each do |file_detail|
54
+ file_detail.destroy if file_detail.asset.nil?
55
+ end
56
+ end
57
+
58
+ def ensure_file_details
59
+ (assets - file_details.all.map(&:asset)).map do |asset|
60
+ build_file_detail_for_asset(asset)
61
+ end
62
+ end
63
+
64
+ def build_file_detail_for_asset(asset)
65
+ file_details.build(asset: asset)
66
+ end
67
+ end
68
+
69
+ include FileDetailsConcern
70
+ end
71
+ end
@@ -0,0 +1,9 @@
1
+ %h1= resource_class.model_name.human(count: :other)
2
+
3
+ .row
4
+ .col-12
5
+ = collection_table(collection: @collection, resource_class: resource_class) do |t|
6
+ = t.column :name
7
+ = t.column :assets_count
8
+ = t.column :actions do |resource|
9
+ - link_to(t('.show'), [resource], class: 'btn btn-primary')
@@ -0,0 +1,17 @@
1
+ %h1= @resource.name
2
+
3
+ .row
4
+ .col-12
5
+ = collection_table(collection: @resource.assets, resource_class: ActiveStorage::Attachment, header: false) do |table|
6
+ = table.column :filename do |resource|
7
+ - resource.blob.filename
8
+ = table.column :blob_byte_size do |resource|
9
+ - number_to_human_size(resource.blob.byte_size)
10
+ = table.column :actions do |resource|
11
+ - capture_haml do
12
+ = link_to(t('.download'), main_app.url_for(resource), class: 'btn btn-primary')
13
+
14
+
15
+ .row.mt-4
16
+ .col-12
17
+ = link_to(t('.back'), last_location, class: 'btn btn-primary')
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Cmor files</title>
5
+ <%= stylesheet_link_tag "cmor/files/application", media: "all" %>
6
+ <%= javascript_include_tag "cmor/files/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1 @@
1
+ Rails.application.config.assets.precompile += %w( cmor_files.css cmor_files.js )
@@ -0,0 +1,2 @@
1
+ Rails.application.config.i18n.available_locales = [:en, :de]
2
+ Rails.application.config.i18n.default_locale = :de
@@ -0,0 +1,44 @@
1
+ de:
2
+ routes:
3
+ cmor_files_engine: dateien
4
+ folders: ordner
5
+ activerecord:
6
+ models:
7
+ cmor/files/file_detail:
8
+ one: Dateidetail
9
+ other: Dateidetails
10
+ cmor/files/folder:
11
+ one: Ordner
12
+ other: Ordner
13
+ attributes:
14
+ cmor/files/file_detail:
15
+ id: ID
16
+ blob_byte_size: Dateigröße
17
+ blob_checksum: Checksumme
18
+ blob_filename: Dateiname
19
+ folder: Ordner
20
+ folder_id: Ordner
21
+ asset: Datei
22
+ asset_id: Datei
23
+ title: Titel
24
+ description: Beschreibung
25
+ position: Position
26
+ created_at: Erstellt am
27
+ updated_at: Aktualisiert am
28
+ cmor/files/folder:
29
+ id: ID
30
+ name: Name
31
+ description: Beschreibung
32
+ assets: Dateien
33
+ assets_count: Dateien
34
+ published_at: Veröffentlicht am
35
+ published: Veröffentlicht
36
+ created_at: Erstellt am
37
+ updated_at: Aktualisiert am
38
+ cmor:
39
+ files:
40
+ folders:
41
+ index:
42
+ show: Anzeigen
43
+ show:
44
+ back: Zurück
@@ -0,0 +1,44 @@
1
+ en:
2
+ routes:
3
+ cmor_files_engine: files
4
+ folders: folders
5
+ activerecord:
6
+ models:
7
+ cmor/files/file_detail:
8
+ one: File detail
9
+ other: File details
10
+ cmor/files/folder:
11
+ one: Folder
12
+ other: Folders
13
+ attributes:
14
+ cmor/files/file_detail:
15
+ id: ID
16
+ blob_byte_size: Filesize
17
+ blob_checksum: Checksum
18
+ blob_filename: Filename
19
+ folder: Folder
20
+ folder_id: Folder
21
+ asset: Asset
22
+ asset_id: Asset
23
+ title: Title
24
+ description: Description
25
+ position: Position
26
+ created_at: Created at
27
+ updated_at: Updated at
28
+ cmor/files/folder:
29
+ id: ID
30
+ name: Name
31
+ description: Description
32
+ assets: Files
33
+ assets_count: Files
34
+ published_at: Published at
35
+ published: Published
36
+ created_at: Created at
37
+ updated_at: Updated at
38
+ cmor:
39
+ files:
40
+ folders:
41
+ index:
42
+ show: Show
43
+ show:
44
+ back: Back
data/config/routes.rb ADDED
@@ -0,0 +1,7 @@
1
+ Cmor::Files::Engine.routes.draw do
2
+ localized do
3
+ scope :cmor_files_engine do
4
+ resources :folders
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ class CreateCmorFilesFolders < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :cmor_files_folders do |t|
4
+ t.string :name
5
+ t.timestamp :published_at
6
+ t.text :description
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ class CreateCmorFilesFileDetails < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :cmor_files_file_details do |t|
4
+ t.integer :folder_id
5
+ t.integer :asset_id
6
+ t.string :title
7
+ t.text :description
8
+ t.integer :position
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ module Cmor::Files
2
+ module Configuration
3
+ def configure
4
+ yield self
5
+ end
6
+
7
+ mattr_accessor(:base_controller) { '::FrontendController' }
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ module Cmor::Files
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Cmor::Files
4
+
5
+ config.generators do |g|
6
+ g.test_framework :rspec
7
+ g.fixture_replacement :factory_bot, dir: 'spec/factories'
8
+ end
9
+
10
+ # config.factory_bot.definition_file_paths =
11
+ # self.root.join(*%w(spec factories)) if defined?(FactoryBotRails)
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ require 'cmor/version'
2
+
3
+ module Cmor
4
+ module Files
5
+ VERSION = ::Cmor::VERSION
6
+ end
7
+ end
data/lib/cmor/files.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'cmor/files/configuration'
2
+ require "cmor/files/engine"
3
+
4
+ module Cmor
5
+ module Files
6
+ extend Configuration
7
+ end
8
+ end
9
+
10
+ Cmor.configure { |c| c.register_configuration(:files, Cmor::Files) }
data/lib/cmor_files.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'cmor_core'
2
+ require 'acts_as_published'
3
+ require 'rao-resources_controller'
4
+ require 'rao-component'
5
+
6
+ require "cmor/files"
@@ -0,0 +1,24 @@
1
+ module Cmor::Files
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ desc 'Generates the initializer'
5
+
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ attr_reader :base_controller_class_name
9
+
10
+ def initialize(*args)
11
+ super
12
+ @base_controller_class_name = ENV.fetch('BASE_CONTROLLER_CLASS_NAME') { '::ApplicationController' }
13
+ end
14
+
15
+ def generate_initializer
16
+ template 'initializer.rb', 'config/initializers/cmor_files.rb'
17
+ end
18
+
19
+ def generate_routes
20
+ route File.read(File.join(File.expand_path('../templates', __FILE__), 'routes.source'))
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,7 @@
1
+ Cmor::Files.configure do |config|
2
+ # Set the base controller for the page controller
3
+ #
4
+ # Default: config.base_controller = '<%= base_controller_class_name %>'
5
+ #
6
+ config.base_controller = '<%= base_controller_class_name %>'
7
+ end
@@ -0,0 +1,3 @@
1
+
2
+
3
+ mount Cmor::Files::Engine, at: '/'
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :cmor/files do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,3 @@
1
+ RSpec.describe do
2
+
3
+ end
@@ -0,0 +1,7 @@
1
+ Cmor::Files.configure do |config|
2
+ # Set the base controller for the page controller
3
+ #
4
+ # Default: config.base_controller = '::ApplicationController'
5
+ #
6
+ config.base_controller = '::ApplicationController'
7
+ end
@@ -0,0 +1,2 @@
1
+ Rails.application.config.i18n.available_locales = [:en, :de]
2
+ Rails.application.config.i18n.default_locale = :de
Binary file
@@ -0,0 +1,27 @@
1
+ # This migration comes from active_storage (originally 20170806125915)
2
+ class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
3
+ def change
4
+ create_table :active_storage_blobs do |t|
5
+ t.string :key, null: false
6
+ t.string :filename, null: false
7
+ t.string :content_type
8
+ t.text :metadata
9
+ t.bigint :byte_size, null: false
10
+ t.string :checksum, null: false
11
+ t.datetime :created_at, null: false
12
+
13
+ t.index [ :key ], unique: true
14
+ end
15
+
16
+ create_table :active_storage_attachments do |t|
17
+ t.string :name, null: false
18
+ t.references :record, null: false, polymorphic: true, index: false
19
+ t.references :blob, null: false
20
+
21
+ t.datetime :created_at, null: false
22
+
23
+ t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true
24
+ t.foreign_key :active_storage_blobs, column: :blob_id
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,12 @@
1
+ # This migration comes from cmor_files (originally 20180301094240)
2
+ class CreateCmorFilesFolders < ActiveRecord::Migration[5.2]
3
+ def change
4
+ create_table :cmor_files_folders do |t|
5
+ t.string :name
6
+ t.timestamp :published_at
7
+ t.text :description
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ # This migration comes from cmor_files (originally 20180302082402)
2
+ class CreateCmorFilesFileDetails < ActiveRecord::Migration[5.2]
3
+ def change
4
+ create_table :cmor_files_file_details do |t|
5
+ t.integer :folder_id
6
+ t.integer :asset_id
7
+ t.string :title
8
+ t.text :description
9
+ t.integer :position
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
Binary file