cmor_galleries 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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +44 -0
- data/Rakefile +19 -0
- data/app/assets/config/cmor_galleries_manifest.js +2 -0
- data/app/assets/javascripts/cmor/galleries/application/keep.js +0 -0
- data/app/assets/javascripts/cmor/galleries/application.js +14 -0
- data/app/assets/stylesheets/cmor/galleries/application/keep.css +0 -0
- data/app/assets/stylesheets/cmor/galleries/application.css +15 -0
- data/app/controllers/cmor/galleries/application_controller.rb +5 -0
- data/app/controllers/cmor/galleries/application_resources_controller.rb +11 -0
- data/app/controllers/cmor/galleries/picture_galleries_controller.rb +17 -0
- data/app/models/cmor/galleries/application_record.rb +5 -0
- data/app/models/cmor/galleries/picture_detail.rb +26 -0
- data/app/models/cmor/galleries/picture_gallery.rb +88 -0
- data/app/view_helpers/cmor/galleries/galleries_helper.rb +34 -0
- data/app/view_helpers/cmor/galleries/pictures_helper.rb +37 -0
- data/app/views/cmor/galleries/galleries_helper/_render.html.haml +17 -0
- data/app/views/cmor/galleries/picture_galleries/index.html.haml +16 -0
- data/app/views/cmor/galleries/picture_galleries/show.html.haml +18 -0
- data/app/views/cmor/galleries/pictures_helper/_render.html.haml +15 -0
- data/app/views/layouts/cmor/galleries/application.html.erb +14 -0
- data/config/initializers/assets.rb +1 -0
- data/config/locales/de.yml +48 -0
- data/config/locales/en.yml +46 -0
- data/config/routes.rb +9 -0
- data/db/migrate/20180301153325_create_cmor_galleries_picture_galleries.rb +11 -0
- data/db/migrate/20180302082402_create_cmor_galleries_picture_details.rb +14 -0
- data/lib/cmor/galleries/configuration.rb +12 -0
- data/lib/cmor/galleries/engine.rb +13 -0
- data/lib/cmor/galleries/version.rb +7 -0
- data/lib/cmor/galleries.rb +10 -0
- data/lib/cmor_galleries.rb +7 -0
- data/lib/generators/cmor/galleries/install/install_generator.rb +24 -0
- data/lib/generators/cmor/galleries/install/templates/initializer.rb +27 -0
- data/lib/generators/cmor/galleries/install/templates/routes.source +3 -0
- data/lib/tasks/cmor_galleries_tasks.rake +4 -0
- data/spec/dummy/config/initializers/cmor_galleries.rb +27 -0
- data/spec/dummy/config/initializers/i18n.rb +2 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20190325174835_create_active_storage_tables.active_storage.rb +27 -0
- data/spec/dummy/db/migrate/20190325174856_create_cmor_galleries_picture_galleries.cmor_galleries.rb +12 -0
- data/spec/dummy/db/migrate/20190325174857_create_cmor_galleries_picture_details.cmor_galleries.rb +15 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +122 -0
- data/spec/dummy/log/test.log +143 -0
- data/spec/dummy/tmp/development_secret.txt +1 -0
- data/spec/dummy/tmp/storage/B8/o7/B8o7CDJi1ubYmEcP3ZAGkEiM +0 -0
- data/spec/dummy/tmp/storage/Hp/aX/HpaXaXSTTBQhyk9pwjiXNpvs +0 -0
- data/spec/factories/cmor_galleries_picture_details.rb +17 -0
- data/spec/factories/cmor_galleries_picture_galleries.rb +5 -0
- data/spec/files/cmor/galleries/picture_details/example.png +0 -0
- data/spec/models/cmor/galleries/picture_detail_spec.rb +7 -0
- data/spec/models/cmor/galleries/picture_gallery_spec.rb +8 -0
- data/spec/models/generic_spec.rb +50 -0
- data/spec/models/i18n_spec.rb +41 -0
- data/spec/rails_helper.rb +62 -0
- data/spec/rails_helper.rb~ +58 -0
- data/spec/spec_helper.rb +96 -0
- data/spec/spec_helper.rb~ +96 -0
- data/spec/support/capybara.rb +1 -0
- data/spec/support/factory_bot.rb +5 -0
- data/spec/support/rao-shoulda_matchers.rb +5 -0
- data/spec/support/shoulda_matchers.rb +8 -0
- data/spec/support~/factory_bot_rails.rb +11 -0
- data/spec/support~/shoulda_matchers.rb +8 -0
- metadata +430 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7a2521c29e89d210dbb3aeec3024e1fbd61b465efd9764d10d72aed06118d44a
|
4
|
+
data.tar.gz: 228910545e1265ae45eeeac233d72c11b01ea885ceb10d6d00f8c42c8486471a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2f2e777d1a08c41744a4a137b30ef3aa37f3cb5e95323467a88f499cca1500fc31fe044d4a9282851e25e20c5e0a49d56d6c69151eda24d2aa476ba33c223190
|
7
|
+
data.tar.gz: 3267d64c74a520ec46f23e2233ab888824679d39f61f6af35db711c03645cf8182a429b6e20c2886bf687afa261b7f0e399dee0bdb0b7019f27019a500a2c273
|
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::Galleries
|
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_galleries'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
```bash
|
20
|
+
$ bundle
|
21
|
+
```
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
```bash
|
25
|
+
$ gem install cmor_galleries
|
26
|
+
```
|
27
|
+
|
28
|
+
Add migrations and migrate:
|
29
|
+
|
30
|
+
```bash
|
31
|
+
$ rake cmor_galleries:install:migrations && rake db:migrate
|
32
|
+
```
|
33
|
+
|
34
|
+
Install routes and initializer:
|
35
|
+
|
36
|
+
```bash
|
37
|
+
$ rails g cmor:galleries: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::Galleries'
|
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'
|
File without changes
|
@@ -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
|
File without changes
|
@@ -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,11 @@
|
|
1
|
+
module Cmor::Galleries
|
2
|
+
class ApplicationResourcesController < Cmor::Galleries::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
|
+
|
9
|
+
helper Twitter::Bootstrap::Components::Rails::V4::ComponentsHelper
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Cmor::Galleries
|
2
|
+
class PictureGalleriesController < ApplicationResourcesController
|
3
|
+
def self.resource_class
|
4
|
+
Cmor::Galleries::PictureGallery
|
5
|
+
end
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def load_collection_scope
|
10
|
+
super.published
|
11
|
+
end
|
12
|
+
|
13
|
+
def load_resource_scope
|
14
|
+
super.published
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Cmor
|
2
|
+
module Galleries
|
3
|
+
class PictureDetail < ApplicationRecord
|
4
|
+
include ActsAsPublished::ActiveRecord
|
5
|
+
|
6
|
+
belongs_to :picture_gallery
|
7
|
+
belongs_to :asset, class_name: 'ActiveStorage::Attachment', dependent: :destroy
|
8
|
+
|
9
|
+
acts_as_list scope: :picture_gallery
|
10
|
+
|
11
|
+
def human
|
12
|
+
title || id
|
13
|
+
end
|
14
|
+
|
15
|
+
module DisplayCodesConcern
|
16
|
+
extend ActiveSupport::Concern
|
17
|
+
|
18
|
+
def display_code_for_erb
|
19
|
+
"<%= pictures_helper(self).render(id: #{id}) %>"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
include DisplayCodesConcern
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module Cmor
|
2
|
+
module Galleries
|
3
|
+
class PictureGallery < ApplicationRecord
|
4
|
+
include ActsAsPublished::ActiveRecord
|
5
|
+
|
6
|
+
has_many_attached :assets
|
7
|
+
|
8
|
+
acts_as_published
|
9
|
+
|
10
|
+
validates :name, presence: true, uniqueness: true
|
11
|
+
|
12
|
+
module PictureDetails
|
13
|
+
extend ActiveSupport::Concern
|
14
|
+
|
15
|
+
included do
|
16
|
+
has_many :picture_details, -> { order(position: :asc) }, inverse_of: :picture_gallery, dependent: :destroy, autosave: true
|
17
|
+
before_validation :cleanup_orphaned_picture_details
|
18
|
+
before_validation :ensure_picture_details
|
19
|
+
end
|
20
|
+
|
21
|
+
def append_assets
|
22
|
+
assets
|
23
|
+
end
|
24
|
+
|
25
|
+
def append_assets=(assets)
|
26
|
+
if Rails.version < '6.0.0'
|
27
|
+
self.assets = assets
|
28
|
+
else
|
29
|
+
self.assets.attach(assets)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def overwrite_assets
|
34
|
+
assets
|
35
|
+
end
|
36
|
+
|
37
|
+
def overwrite_assets=(assets)
|
38
|
+
return if assets.nil? || assets.empty?
|
39
|
+
self.picture_details.map { |pd| pd.mark_for_destruction }
|
40
|
+
self.assets = assets
|
41
|
+
end
|
42
|
+
|
43
|
+
def picture_details_count
|
44
|
+
picture_details.count
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def cleanup_orphaned_picture_details
|
50
|
+
picture_details.each do |picture_detail|
|
51
|
+
picture_detail.destroy if picture_detail.asset.nil?
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def ensure_picture_details
|
56
|
+
(assets - picture_details.all.map(&:asset)).map do |asset|
|
57
|
+
build_picture_detail_for_asset(asset)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def build_picture_detail_for_asset(asset)
|
62
|
+
picture_details.build(asset: asset, published: published)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
include PictureDetails
|
67
|
+
|
68
|
+
|
69
|
+
def human
|
70
|
+
name
|
71
|
+
end
|
72
|
+
|
73
|
+
def assets_count
|
74
|
+
assets.count
|
75
|
+
end
|
76
|
+
|
77
|
+
module DisplayCodesConcern
|
78
|
+
extend ActiveSupport::Concern
|
79
|
+
|
80
|
+
def display_code_for_erb
|
81
|
+
"<%= galleries_helper(self).render(name: '#{name}') %>"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
include DisplayCodesConcern
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Cmor
|
2
|
+
module Galleries
|
3
|
+
# Usage:
|
4
|
+
#
|
5
|
+
# # app/controllers/application_vontroller.rb
|
6
|
+
# class ApplicationController < ActionController::Base
|
7
|
+
# view_helper Cmor::Galleries::GalleriesHelper, as: :galleries_helper
|
8
|
+
# # ...
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
# # app/views/home/index.html.haml
|
12
|
+
# = galleries_helper(self).render(name: 'main', variant_options: { combine_options: { resize: "255x255^", extent: "255x255", gravity: "center"} }, show_details: true)
|
13
|
+
#
|
14
|
+
# Default options are taken from Cmor::Galleries::Configuration.galleries_helper_render_default_options.
|
15
|
+
# You can set this option in the initializer.
|
16
|
+
#
|
17
|
+
class GalleriesHelper < Rao::ViewHelper::Base
|
18
|
+
def initialize(context)
|
19
|
+
@context = context
|
20
|
+
end
|
21
|
+
|
22
|
+
def render(options = {})
|
23
|
+
options.reverse_merge!(Cmor::Galleries::Configuration.galleries_helper_render_default_options)
|
24
|
+
|
25
|
+
name = options.delete(:name)
|
26
|
+
variant_options = options.delete(:variant_options)
|
27
|
+
show_details = options.delete(:show_details)
|
28
|
+
|
29
|
+
resource = Cmor::Galleries::PictureGallery.where(name: name).first
|
30
|
+
c.render partial: 'cmor/galleries/galleries_helper/render', locals: { resource: resource, variant_options: variant_options, show_details: show_details }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Cmor
|
2
|
+
module Galleries
|
3
|
+
# Usage:
|
4
|
+
#
|
5
|
+
# # app/controllers/application_vontroller.rb
|
6
|
+
# class ApplicationController < ActionController::Base
|
7
|
+
# view_helper Cmor::Galleries::PicturesHelper, as: :pictures_helper
|
8
|
+
# # ...
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
# # app/views/home/index.html.haml
|
12
|
+
# = pictures_helper(self).render(name: 'main', variant_options: { combine_options: { resize: "255x255^", extent: "255x255", gravity: "center"} }, show_details: true)
|
13
|
+
#
|
14
|
+
# Default options are taken from Cmor::Galleries::Configuration.pictures_helper_render_default_options.
|
15
|
+
# You can set this option in the initializer.
|
16
|
+
#
|
17
|
+
# You can pass the image_tag_only option to render just the <img>-tag without a bootstrap card.
|
18
|
+
#
|
19
|
+
class PicturesHelper < Rao::ViewHelper::Base
|
20
|
+
def initialize(context)
|
21
|
+
@context = context
|
22
|
+
end
|
23
|
+
|
24
|
+
def render(options = {})
|
25
|
+
options.reverse_merge!(Cmor::Galleries::Configuration.pictures_helper_render_default_options)
|
26
|
+
|
27
|
+
id = options.delete(:id)
|
28
|
+
variant_options = options.delete(:variant_options) || {}
|
29
|
+
show_details = options.delete(:show_details)
|
30
|
+
image_tag_only = options.delete(:image_tag_only)
|
31
|
+
|
32
|
+
resource = Cmor::Galleries::PictureDetail.where(id: id).first
|
33
|
+
c.render partial: 'cmor/galleries/pictures_helper/render', locals: { resource: resource, variant_options: variant_options, show_details: show_details, image_tag_only: image_tag_only }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
- if resource.nil?
|
2
|
+
- else
|
3
|
+
%div{ id: dom_id(resource), class: dom_class(resource) }
|
4
|
+
%notextile
|
5
|
+
.row
|
6
|
+
- resource.picture_details.published.each do |picture_detail|
|
7
|
+
.col-md-6.col-lg-3.d-flex.align-items-stretch.mb-4
|
8
|
+
= bootstrap_card(additional_css_classes: 'text-center border-0 w-100') do
|
9
|
+
%a{ href: main_app.url_for(picture_detail.asset), data: { gallery: dom_id(resource) } }
|
10
|
+
%img{ src: main_app.url_for(picture_detail.asset.variant(variant_options)) }
|
11
|
+
- if show_details
|
12
|
+
.card-body
|
13
|
+
%h5.card-title
|
14
|
+
= picture_detail.title
|
15
|
+
%p.card-text
|
16
|
+
= picture_detail.description
|
17
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
%h1= resource_class.model_name.human(count: :other)
|
2
|
+
|
3
|
+
.row
|
4
|
+
- @collection.each do |picture_gallery|
|
5
|
+
.col-4
|
6
|
+
- image_options = if picture_gallery.picture_details.first.try(:asset).present?
|
7
|
+
- { src: main_app.url_for(picture_gallery.picture_details.first.asset.variant(Cmor::Galleries::Configuration.thumbnail_variant_options)) }
|
8
|
+
- else
|
9
|
+
- {}
|
10
|
+
= bootstrap_card(image_options: image_options, additional_css_classes: 'text-center border-0') do
|
11
|
+
.card-body
|
12
|
+
%h5.card-title
|
13
|
+
= picture_gallery.name
|
14
|
+
%p.card-text
|
15
|
+
= picture_gallery.description
|
16
|
+
= link_to(t('.show'), picture_gallery, class: 'btn btn-primary')
|
@@ -0,0 +1,18 @@
|
|
1
|
+
%h1= @resource.name
|
2
|
+
|
3
|
+
%div{ id: dom_id(@resource), class: dom_class(@resource) }
|
4
|
+
.row
|
5
|
+
- @resource.picture_details.each do |picture_detail|
|
6
|
+
.col-md-6.col-lg-3.d-flex.align-items-stretch.mb-4
|
7
|
+
= bootstrap_card(additional_css_classes: 'text-center border-0' ) do
|
8
|
+
%a{ href: main_app.url_for(picture_detail.asset), data: { gallery: dom_id(@resource) } }
|
9
|
+
%img.img-fluid{ src: main_app.url_for(picture_detail.asset.variant(Cmor::Galleries::Configuration.thumbnail_variant_options)) }
|
10
|
+
.card-body
|
11
|
+
%h5.card-title
|
12
|
+
= picture_detail.title
|
13
|
+
%p.card-text
|
14
|
+
= picture_detail.description
|
15
|
+
|
16
|
+
.row.mt-4
|
17
|
+
.col-12
|
18
|
+
= link_to(t('.back'), last_location, class: 'btn btn-primary')
|
@@ -0,0 +1,15 @@
|
|
1
|
+
- if resource.nil?
|
2
|
+
- else
|
3
|
+
%notextile
|
4
|
+
- if image_tag_only
|
5
|
+
%img.img-responsive{ src: main_app.url_for(resource.asset.variant(variant_options)) }
|
6
|
+
- else
|
7
|
+
.row{ id: dom_id(resource), class: dom_class(resource) }
|
8
|
+
.col-md-6.col-lg-3.d-flex.align-items-stretch.mb-4
|
9
|
+
= bootstrap_card(image_options: { src: main_app.url_for(resource.asset.variant(variant_options)) }, additional_css_classes: 'text-center border-0 w-100' ) do
|
10
|
+
- if show_details
|
11
|
+
.card-body
|
12
|
+
%h5.card-title
|
13
|
+
= resource.title
|
14
|
+
%p.card-text
|
15
|
+
= resource.description
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Cmor galleries</title>
|
5
|
+
<%= stylesheet_link_tag "cmor/galleries/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "cmor/galleries/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_galleries.css cmor_galleries.js )
|
@@ -0,0 +1,48 @@
|
|
1
|
+
de:
|
2
|
+
routes:
|
3
|
+
cmor_galleries_engine: bilder
|
4
|
+
picture_galleries: galerien
|
5
|
+
activerecord:
|
6
|
+
models:
|
7
|
+
cmor/galleries/picture_detail:
|
8
|
+
one: Bilddetail
|
9
|
+
other: Bilddetails
|
10
|
+
cmor/galleries/picture_gallery:
|
11
|
+
one: Bildgalerie
|
12
|
+
other: Bildgalerien
|
13
|
+
attributes:
|
14
|
+
cmor/galleries/picture_gallery:
|
15
|
+
id: ID
|
16
|
+
append_assets: Bilder hinzufügen
|
17
|
+
description: Beschreibung
|
18
|
+
display_code_for_erb: Anzeigecode (erb)
|
19
|
+
name: Name
|
20
|
+
overwrite_assets: Bilder ersetzen
|
21
|
+
picture_details_count: Bilder
|
22
|
+
preview: Vorschau
|
23
|
+
published_at: Veröffentlicht am
|
24
|
+
published: Veröffentlicht
|
25
|
+
created_at: Erstellt am
|
26
|
+
updated_at: Aktualisiert am
|
27
|
+
cmor/galleries/picture_detail:
|
28
|
+
id: ID
|
29
|
+
asset_id: Datei
|
30
|
+
asset: Datei
|
31
|
+
description: Beschreibung
|
32
|
+
display_code_for_erb: Anzeigecode (erb)
|
33
|
+
picture_gallery_id: Galerie
|
34
|
+
picture_gallery: Galerie
|
35
|
+
position: Position
|
36
|
+
preview: Vorschau
|
37
|
+
published_at: Veröffentlicht am
|
38
|
+
published: Veröffentlicht
|
39
|
+
title: Titel
|
40
|
+
created_at: Erstellt am
|
41
|
+
updated_at: Aktualisiert am
|
42
|
+
cmor:
|
43
|
+
galleries:
|
44
|
+
picture_galleries:
|
45
|
+
index:
|
46
|
+
show: Anzeigen
|
47
|
+
show:
|
48
|
+
back: Zurück
|
@@ -0,0 +1,46 @@
|
|
1
|
+
en:
|
2
|
+
routes:
|
3
|
+
cmor_galleries_engine: pictures
|
4
|
+
picture_galleries: galleries
|
5
|
+
activerecord:
|
6
|
+
models:
|
7
|
+
cmor/galleries/picture_detail:
|
8
|
+
one: Picture detail
|
9
|
+
other: Picture details
|
10
|
+
cmor/galleries/picture_gallery:
|
11
|
+
one: Gallery
|
12
|
+
other: Galleries
|
13
|
+
attributes:
|
14
|
+
cmor/galleries/picture_gallery:
|
15
|
+
id: ID
|
16
|
+
name: Name
|
17
|
+
description: Description
|
18
|
+
display_code_for_erb: Display code (erb)
|
19
|
+
picture_details_count: Pictures
|
20
|
+
preview: Preview
|
21
|
+
published: Published
|
22
|
+
published_at: Published at
|
23
|
+
created_at: Created at
|
24
|
+
updated_at: Updated at
|
25
|
+
cmor/galleries/picture_detail:
|
26
|
+
id: ID
|
27
|
+
asset_id: File
|
28
|
+
asset: File
|
29
|
+
description: Description
|
30
|
+
display_code_for_erb: Display code (erb)
|
31
|
+
picture_gallery_id: Gallery
|
32
|
+
picture_gallery: Gallery
|
33
|
+
position: Position
|
34
|
+
preview: Preview
|
35
|
+
published_at: Published at
|
36
|
+
published: Published
|
37
|
+
title: Title
|
38
|
+
created_at: Created at
|
39
|
+
updated_at: Updated at
|
40
|
+
cmor:
|
41
|
+
galleries:
|
42
|
+
picture_galleries:
|
43
|
+
index:
|
44
|
+
show: Show
|
45
|
+
show:
|
46
|
+
back: Back
|
data/config/routes.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateCmorGalleriesPictureDetails < ActiveRecord::Migration[5.2]
|
2
|
+
def change
|
3
|
+
create_table :cmor_galleries_picture_details do |t|
|
4
|
+
t.integer :picture_gallery_id
|
5
|
+
t.integer :asset_id
|
6
|
+
t.string :title
|
7
|
+
t.text :description
|
8
|
+
t.integer :position
|
9
|
+
t.timestamp :published_at
|
10
|
+
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Cmor::Galleries
|
2
|
+
module Configuration
|
3
|
+
def configure
|
4
|
+
yield self
|
5
|
+
end
|
6
|
+
|
7
|
+
mattr_accessor(:base_controller) { '::FrontendController' }
|
8
|
+
mattr_accessor(:galleries_helper_render_default_options) { { variant_options: {}, show_details: false } }
|
9
|
+
mattr_accessor(:pictures_helper_render_default_options) { { image_tag_only: true } }
|
10
|
+
mattr_accessor(:thumbnail_variant_options) { { combine_options: { resize: "384x216^", extent: "384x216", gravity: "center"} } }
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Cmor::Galleries
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace Cmor::Galleries
|
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?(FactoryBot)
|
12
|
+
end
|
13
|
+
end
|