diff options
| -rw-r--r-- | app/controllers/related_assets_controller.rb | 1 | ||||
| -rw-r--r-- | app/helpers/content_helper.rb | 6 | ||||
| -rw-r--r-- | app/models/asset.rb | 4 | ||||
| -rw-r--r-- | app/views/content/_asset_credits.html.erb | 6 | ||||
| -rw-r--r-- | app/views/content/_headline_image.html.erb | 15 | ||||
| -rw-r--r-- | app/views/nodes/edit.html.erb | 1 | ||||
| -rw-r--r-- | public/javascripts/admin_interface.js | 6 | ||||
| -rw-r--r-- | public/javascripts/public.js | 21 | ||||
| -rw-r--r-- | public/javascripts/related_assets.js | 1 | ||||
| -rw-r--r-- | public/stylesheets/ccc.css | 26 |
10 files changed, 71 insertions, 16 deletions
diff --git a/app/controllers/related_assets_controller.rb b/app/controllers/related_assets_controller.rb index da82cde..2fefaf7 100644 --- a/app/controllers/related_assets_controller.rb +++ b/app/controllers/related_assets_controller.rb | |||
| @@ -26,6 +26,7 @@ class RelatedAssetsController < ApplicationController | |||
| 26 | id: related.id, | 26 | id: related.id, |
| 27 | asset_id: asset.id, | 27 | asset_id: asset.id, |
| 28 | name: asset.name, | 28 | name: asset.name, |
| 29 | has_credit: asset.has_credit?, | ||
| 29 | thumb_url: asset.upload.url(:thumb), | 30 | thumb_url: asset.upload.url(:thumb), |
| 30 | large_url: asset.upload.url(:large), | 31 | large_url: asset.upload.url(:large), |
| 31 | original_url: asset.upload.url, | 32 | original_url: asset.upload.url, |
diff --git a/app/helpers/content_helper.rb b/app/helpers/content_helper.rb index 5b67259..b3c6bad 100644 --- a/app/helpers/content_helper.rb +++ b/app/helpers/content_helper.rb | |||
| @@ -153,7 +153,7 @@ module ContentHelper | |||
| 153 | 153 | ||
| 154 | def asset_credit(asset) | 154 | def asset_credit(asset) |
| 155 | return nil unless asset | 155 | return nil unless asset |
| 156 | return nil if asset.creator.blank? && asset.source_url.blank? && asset.license_key.blank? | 156 | return nil unless asset.has_credit? |
| 157 | 157 | ||
| 158 | license = AssetLicense.find(asset.license_key) | 158 | license = AssetLicense.find(asset.license_key) |
| 159 | 159 | ||
| @@ -173,4 +173,8 @@ module ContentHelper | |||
| 173 | full = license_text ? safe_join([attribution, license_text], ", ") : attribution | 173 | full = license_text ? safe_join([attribution, license_text], ", ") : attribution |
| 174 | safe_join([full, "."]) | 174 | safe_join([full, "."]) |
| 175 | end | 175 | end |
| 176 | |||
| 177 | def glightbox_data(image, title) | ||
| 178 | "title: #{title.to_s.tr(';', ',')};" | ||
| 179 | end | ||
| 176 | end | 180 | end |
diff --git a/app/models/asset.rb b/app/models/asset.rb index 8bea1b3..4a295d8 100644 --- a/app/models/asset.rb +++ b/app/models/asset.rb | |||
| @@ -15,4 +15,8 @@ class Asset < ApplicationRecord | |||
| 15 | def image? | 15 | def image? |
| 16 | IMAGE_CONTENT_TYPES.include?(upload_content_type) | 16 | IMAGE_CONTENT_TYPES.include?(upload_content_type) |
| 17 | end | 17 | end |
| 18 | |||
| 19 | def has_credit? | ||
| 20 | creator.present? || source_url.present? || license_key.present? | ||
| 21 | end | ||
| 18 | end | 22 | end |
diff --git a/app/views/content/_asset_credits.html.erb b/app/views/content/_asset_credits.html.erb index 85739d0..5959abd 100644 --- a/app/views/content/_asset_credits.html.erb +++ b/app/views/content/_asset_credits.html.erb | |||
| @@ -1,11 +1,9 @@ | |||
| 1 | <% if @page.assets.images.any? %> | 1 | <% if @page.assets.images.any? %> |
| 2 | <div id="asset_credits"> | 2 | <div id="asset_credits"> |
| 3 | <% @page.assets.images.each do |image| %> | 3 | <% @page.assets.images.each do |image| %> |
| 4 | <% credit = asset_credit(image) %> | ||
| 5 | <% next unless credit %> | ||
| 6 | <div id="credit_for_asset_<%= image.id %>" | 4 | <div id="credit_for_asset_<%= image.id %>" |
| 7 | class="glightbox-desc<%= " headline_credit" if image == @headline_asset %>"> | 5 | class="asset_credit_block<%= " headline_credit" if image == @headline_asset %>"> |
| 8 | <%= credit %> | 6 | <%= asset_credit(image) %> |
| 9 | </div> | 7 | </div> |
| 10 | <% end %> | 8 | <% end %> |
| 11 | </div> | 9 | </div> |
diff --git a/app/views/content/_headline_image.html.erb b/app/views/content/_headline_image.html.erb index c764d22..e7b821b 100644 --- a/app/views/content/_headline_image.html.erb +++ b/app/views/content/_headline_image.html.erb | |||
| @@ -5,8 +5,9 @@ | |||
| 5 | image_tag(@headline_asset.upload.url(:headline)), | 5 | image_tag(@headline_asset.upload.url(:headline)), |
| 6 | @headline_asset.upload.url, | 6 | @headline_asset.upload.url, |
| 7 | :class => "glightbox", | 7 | :class => "glightbox", |
| 8 | :data => { :gallery => "page-#{@page.node.id}", :title => @headline_asset.name, | 8 | :data => { :gallery => "page-#{@page.node.id}", |
| 9 | :description => "#credit_for_asset_#{@headline_asset.id}" } | 9 | :glightbox => glightbox_data(@headline_asset, @headline_asset.name), |
| 10 | :"credit-selector" => (@headline_asset.has_credit? ? "#credit_for_asset_#{@headline_asset.id}" : nil) } | ||
| 10 | ) %> | 11 | ) %> |
| 11 | <% if gallery_images.size > 1 %> | 12 | <% if gallery_images.size > 1 %> |
| 12 | <div class="right"><%= "#{gallery_images.size} #{t(:images)}" %></div> | 13 | <div class="right"><%= "#{gallery_images.size} #{t(:images)}" %></div> |
| @@ -15,14 +16,16 @@ | |||
| 15 | <%= link_to "#{gallery_images.size} #{t(:images)}, #{t(:open_gallery)}", | 16 | <%= link_to "#{gallery_images.size} #{t(:images)}, #{t(:open_gallery)}", |
| 16 | gallery_images.first.upload.url, | 17 | gallery_images.first.upload.url, |
| 17 | :class => "glightbox right", | 18 | :class => "glightbox right", |
| 18 | :data => { :gallery => "page-#{@page.node.id}", :title => gallery_images.first.name, | 19 | :data => { :gallery => "page-#{@page.node.id}", |
| 19 | :description => "#credit_for_asset_#{gallery_images.first.id}" } %> | 20 | :glightbox => glightbox_data(gallery_images.first, gallery_images.first.name), |
| 21 | :"credit-selector" => (gallery_images.first.has_credit? ? "#credit_for_asset_#{gallery_images.first.id}" : nil) } %> | ||
| 20 | <% end %> | 22 | <% end %> |
| 21 | 23 | ||
| 22 | <% gallery_images.each do |image| %> | 24 | <% gallery_images.each do |image| %> |
| 23 | <% next if image == @headline_asset %> | 25 | <% next if image == @headline_asset %> |
| 24 | <% next if !@headline_asset && image == gallery_images.first %> | 26 | <% next if !@headline_asset && image == gallery_images.first %> |
| 25 | <%= link_to "", image.upload.url, :class => "glightbox", :style => "display: none", | 27 | <%= link_to "", image.upload.url, :class => "glightbox", :style => "display: none", |
| 26 | :data => { :gallery => "page-#{@page.node.id}", :title => image.name, | 28 | :data => { :gallery => "page-#{@page.node.id}", |
| 27 | :description => "#credit_for_asset_#{image.id}" } %> | 29 | :glightbox => glightbox_data(image, image.name), |
| 30 | :"credit-selector" => (image.has_credit? ? "#credit_for_asset_#{image.id}" : nil) } %> | ||
| 28 | <% end %> | 31 | <% end %> |
diff --git a/app/views/nodes/edit.html.erb b/app/views/nodes/edit.html.erb index da682f0..07b42d4 100644 --- a/app/views/nodes/edit.html.erb +++ b/app/views/nodes/edit.html.erb | |||
| @@ -86,6 +86,7 @@ | |||
| 86 | data-large-url="<%= related.asset.upload.url(:large) %>" | 86 | data-large-url="<%= related.asset.upload.url(:large) %>" |
| 87 | data-original-url="<%= related.asset.upload.url %>" | 87 | data-original-url="<%= related.asset.upload.url %>" |
| 88 | data-name="<%= related.asset.name %>" | 88 | data-name="<%= related.asset.name %>" |
| 89 | data-has-credit="<%= related.asset.has_credit? %>" | ||
| 89 | data-headline="<%= related.headline? %>" | 90 | data-headline="<%= related.headline? %>" |
| 90 | class="<%= "is_headline" if related.headline? %>"> | 91 | class="<%= "is_headline" if related.headline? %>"> |
| 91 | <span class="related_asset_handle"><%= icon("grip-vertical", library: "tabler", "aria-hidden": true) %></span> | 92 | <span class="related_asset_handle"><%= icon("grip-vertical", library: "tabler", "aria-hidden": true) %></span> |
diff --git a/public/javascripts/admin_interface.js b/public/javascripts/admin_interface.js index 7fb1dc2..f378c46 100644 --- a/public/javascripts/admin_interface.js +++ b/public/javascripts/admin_interface.js | |||
| @@ -282,6 +282,7 @@ cccms = { | |||
| 282 | large: $(this).data('large-url'), | 282 | large: $(this).data('large-url'), |
| 283 | original: $(this).data('original-url'), | 283 | original: $(this).data('original-url'), |
| 284 | name: $(this).data('name'), | 284 | name: $(this).data('name'), |
| 285 | hasCredit: $(this).data('has-credit') === true, | ||
| 285 | headline: $(this).data('headline') === true | 286 | headline: $(this).data('headline') === true |
| 286 | }; | 287 | }; |
| 287 | }).get(); | 288 | }).get(); |
| @@ -320,8 +321,11 @@ cccms = { | |||
| 320 | : 'inline-image inline-image--half inline-image--' + placement; | 321 | : 'inline-image inline-image--half inline-image--' + placement; |
| 321 | 322 | ||
| 322 | var esc = cccms.inline_images.escape_attr; | 323 | var esc = cccms.inline_images.escape_attr; |
| 324 | var titleForGlightbox = (item.name || '').replace(/;/g, ','); | ||
| 325 | var glightboxOpts = 'title: ' + esc(titleForGlightbox) + | ||
| 326 | (item.hasCredit ? '; description: #credit_for_asset_' + esc(item.id) : '') + ';'; | ||
| 323 | var html = '<a href="' + esc(item.original) + '" class="glightbox" data-gallery="page-' + esc(cccms.inline_images.node_id) + '"' + | 327 | var html = '<a href="' + esc(item.original) + '" class="glightbox" data-gallery="page-' + esc(cccms.inline_images.node_id) + '"' + |
| 324 | ' data-title="' + esc(item.name) + '" data-description="#credit_for_asset_' + esc(item.id) + '">' + | 328 | ' data-glightbox="' + glightboxOpts + '">' + |
| 325 | '<img src="' + esc(item.large) + '" class="' + classes + '" alt="' + esc(item.name) + '"></a>'; | 329 | '<img src="' + esc(item.large) + '" class="' + classes + '" alt="' + esc(item.name) + '"></a>'; |
| 326 | 330 | ||
| 327 | cccms.inline_images.editor.insertContent(html); | 331 | cccms.inline_images.editor.insertContent(html); |
diff --git a/public/javascripts/public.js b/public/javascripts/public.js index a9250ca..7f38f66 100644 --- a/public/javascripts/public.js +++ b/public/javascripts/public.js | |||
| @@ -1,6 +1,25 @@ | |||
| 1 | document.addEventListener('DOMContentLoaded', function(){ | 1 | document.addEventListener('DOMContentLoaded', function(){ |
| 2 | 2 | ||
| 3 | GLightbox({ selector: '.glightbox' }); | 3 | GLightbox({ |
| 4 | selector: '.glightbox', | ||
| 5 | afterSlideLoad: function(slideData) { | ||
| 6 | var trigger = document.querySelectorAll('.glightbox')[slideData.index]; | ||
| 7 | var selector = trigger && trigger.dataset.creditSelector; | ||
| 8 | if (!selector) return; | ||
| 9 | |||
| 10 | var source = document.querySelector(selector); | ||
| 11 | var container = slideData.slide.querySelector('.gdesc-inner'); | ||
| 12 | if (!source || !container) return; | ||
| 13 | |||
| 14 | var target = container.querySelector('.gslide-desc'); | ||
| 15 | if (!target) { | ||
| 16 | target = document.createElement('div'); | ||
| 17 | target.className = 'gslide-desc'; | ||
| 18 | container.appendChild(target); | ||
| 19 | } | ||
| 20 | target.innerHTML = source.innerHTML; | ||
| 21 | } | ||
| 22 | }); | ||
| 4 | 23 | ||
| 5 | document.getElementById("light-mode").addEventListener("change", () => { | 24 | document.getElementById("light-mode").addEventListener("change", () => { |
| 6 | if (document.getElementById("light-mode").checked) | 25 | if (document.getElementById("light-mode").checked) |
diff --git a/public/javascripts/related_assets.js b/public/javascripts/related_assets.js index cc07d86..c6c6a19 100644 --- a/public/javascripts/related_assets.js +++ b/public/javascripts/related_assets.js | |||
| @@ -87,6 +87,7 @@ related_assets = { | |||
| 87 | var item = $($("#related_asset_template").html().trim()); | 87 | var item = $($("#related_asset_template").html().trim()); |
| 88 | item.attr("data-url", related.url); | 88 | item.attr("data-url", related.url); |
| 89 | item.attr("data-asset-id", related.asset_id); | 89 | item.attr("data-asset-id", related.asset_id); |
| 90 | item.attr("data-has-credit", related.has_credit); | ||
| 90 | item.attr("data-large-url", related.large_url); | 91 | item.attr("data-large-url", related.large_url); |
| 91 | item.attr("data-original-url", related.original_url); | 92 | item.attr("data-original-url", related.original_url); |
| 92 | item.attr("data-name", related.name); | 93 | item.attr("data-name", related.name); |
diff --git a/public/stylesheets/ccc.css b/public/stylesheets/ccc.css index 8358d06..9654594 100644 --- a/public/stylesheets/ccc.css +++ b/public/stylesheets/ccc.css | |||
| @@ -727,7 +727,6 @@ div.teaser_ruler { | |||
| 727 | min-width: 0; | 727 | min-width: 0; |
| 728 | } | 728 | } |
| 729 | 729 | ||
| 730 | |||
| 731 | .inline-image--full { | 730 | .inline-image--full { |
| 732 | width: 100%; | 731 | width: 100%; |
| 733 | margin: 1rem 0; | 732 | margin: 1rem 0; |
| @@ -748,10 +747,31 @@ div.teaser_ruler { | |||
| 748 | margin-left: 1rem; | 747 | margin-left: 1rem; |
| 749 | } | 748 | } |
| 750 | 749 | ||
| 751 | #asset_credits .glightbox-desc { | 750 | #asset_credits .asset_credit_block { |
| 752 | display: none; | 751 | display: none; |
| 753 | } | 752 | } |
| 754 | 753 | ||
| 755 | #asset_credits .headline_credit { | 754 | #asset_credits .asset_credit_block.headline_credit { |
| 756 | display: block; | 755 | display: block; |
| 757 | } | 756 | } |
| 757 | |||
| 758 | #asset_credits { | ||
| 759 | border-top: dotted 1px silver; | ||
| 760 | } | ||
| 761 | |||
| 762 | #asset_credits, | ||
| 763 | .right { | ||
| 764 | font-style: italic; | ||
| 765 | font-family: Georgia; | ||
| 766 | font-size: 0.9rem; | ||
| 767 | color: color-mix(in srgb, CanvasText, #808080); | ||
| 768 | } | ||
| 769 | |||
| 770 | .glightbox-clean .gslide-description { | ||
| 771 | background: Canvas !important; | ||
| 772 | } | ||
| 773 | |||
| 774 | .glightbox-clean .gslide-title, | ||
| 775 | .glightbox-clean .gslide-desc { | ||
| 776 | color: CanvasText !important; | ||
| 777 | } | ||
