diff --git a/app/assets/images/communication/blocks/templates/license.jpg b/app/assets/images/communication/blocks/templates/license.jpg index 3422b1697e0aa442a8490e0b22d1fb9fd4f4912b..3f76177d3f1e31764dfb5b4171d01defb71dd5f5 100644 Binary files a/app/assets/images/communication/blocks/templates/license.jpg and b/app/assets/images/communication/blocks/templates/license.jpg differ diff --git a/app/services/licenses/creative_commons.rb b/app/services/licenses/creative_commons.rb index d7e8189237796be8c05bcf452ae4d00f7b31daa2..c2ca76aad8d53c2356b0df8fb165082888211a46 100644 --- a/app/services/licenses/creative_commons.rb +++ b/app/services/licenses/creative_commons.rb @@ -15,79 +15,55 @@ class Licenses::CreativeCommons @sharing = sharing == 'true' end - def badge - unless @badge - @badge = 'cc-zero' - if attribution - @badge = 'by' - @badge += '-nc' unless commercial_use - if !derivatives - @badge += '-nd' - elsif !sharing - @badge += '-sa' - end - end - end - @badge + def identifier + @identifier ||= attribution ? identifier_with_attribution + : 'cc-zero' end def url - unless @url - if attribution - @url = 'https://creativecommons.org/licenses/by' - @url += '-nc' unless commercial_use - @url += '-nd' unless derivatives - if derivatives && !sharing - @url += '-sa' - end - @url += '/4.0/' - else - @url = 'https://creativecommons.org/publicdomain/zero/1.0/' - end - end - @url + @url ||= attribution ? "https://creativecommons.org/licenses/#{identifier}/4.0/" + : 'https://creativecommons.org/publicdomain/zero/1.0/' end - def short_name - unless @short_name - if attribution - @short_name = 'CC BY' - @short_name += '-NC' if !commercial_use - @short_name += '-ND' if !derivatives - @short_name += '-SA' if derivatives && !sharing - @short_name += ' 4.0' - else - @short_name = 'CC0 1.0 Universal' - end - end - @short_name + def label + @label ||= attribution ? 'CC0 1.0 Universal' + : label_with_attribution end - def long_name - unless @long_name - if attribution - @long_name = 'Attribution' - @long_name += '-NonCommercial' if !commercial_use - @long_name += '-NoDerivatives' if !derivatives - @long_name += '-ShareAlike' if derivatives && !sharing - @long_name += ' 4.0 International' - else - @long_name = 'CC0 1.0 Universal' - end - end - @long_name + def to_s + "#{label}" end - def name - short_name + def icons + @icons = ['cc'] + if !attribution + @icons << 'zero' + else + @icons << 'by' + @icons << 'nc' if !commercial_use + @icons << 'nd' if !derivatives + @icons << 'sa' if derivatives && !sharing + end + @icons end - def to_s - "#{name}" + protected + + def identifier_with_attribution + identifier = 'by' + identifier += '-nc' if !commercial_use + identifier += '-nd' if !derivatives + identifier += '-sa' if derivatives && !sharing + identifier end - def icons - ['cc'] + def label_with_attribution + label = 'CC BY' + label += '-NC' if !commercial_use + label += '-ND' if !derivatives + label += '-SA' if derivatives && !sharing + label += ' 4.0' + label end end \ No newline at end of file diff --git a/app/views/admin/communication/blocks/templates/license/_snippet.html.erb b/app/views/admin/communication/blocks/templates/license/_snippet.html.erb index 2a92220efa3069a821a7145a217ee1bab9062518..bd7cc3b3f52fac864d710aa6425511b91330d4d8 100644 --- a/app/views/admin/communication/blocks/templates/license/_snippet.html.erb +++ b/app/views/admin/communication/blocks/templates/license/_snippet.html.erb @@ -2,4 +2,4 @@ cc = Licenses::CreativeCommons.create_from_block(block) %> <%= render 'admin/communication/blocks/templates/license/creative_commons/icons', block: block %> -<%= cc.short_name %> \ No newline at end of file +<%= cc.to_s %> \ No newline at end of file diff --git a/app/views/admin/communication/blocks/templates/license/_static.html.erb b/app/views/admin/communication/blocks/templates/license/_static.html.erb index 74f0c1042f5924b546abbc9406d97864e50a5cd8..897509139f9f8c3071c6bff8662c650de2196d02 100644 --- a/app/views/admin/communication/blocks/templates/license/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/license/_static.html.erb @@ -7,9 +7,10 @@ cc = Licenses::CreativeCommons.create_from_block(block) commercial_use: <%= block.template.creative_commons_commercial_use %> derivatives: <%= block.template.creative_commons_derivatives %> sharing: <%= block.template.creative_commons_sharing %> - short_name: >- - <%= cc.short_name %> - long_name: >- - <%= cc.long_name %> + icons: <%= raw cc.icons %> + identifier: >- + <%= cc.identifier %> + label: >- + <%= cc.to_s %> url: >- <%= cc.url -%> \ No newline at end of file diff --git a/app/views/admin/communication/blocks/templates/license/creative_commons/_badge.html.erb b/app/views/admin/communication/blocks/templates/license/creative_commons/_badge.html.erb index 5a9f2ffe573761cd70d6b4de658f58161a62d9c2..08701e3c38db62b6846b4e45f5c4e1b5eaa150d8 100644 --- a/app/views/admin/communication/blocks/templates/license/creative_commons/_badge.html.erb +++ b/app/views/admin/communication/blocks/templates/license/creative_commons/_badge.html.erb @@ -1,8 +1,8 @@ <% cc = Licenses::CreativeCommons.create_from_block(block) -path = "communication/blocks/templates/license/creative_commons/badges/#{cc.badge}.svg" +path = "communication/blocks/templates/license/creative_commons/badges/#{cc.identifier}.svg" %> <%= image_tag path, - alt: cc.badge, + alt: cc.identifier, border: 0, width: 88 %> \ No newline at end of file diff --git a/app/views/admin/communication/blocks/templates/license/creative_commons/_icons.html.erb b/app/views/admin/communication/blocks/templates/license/creative_commons/_icons.html.erb index 88862e92d8bf166facf90de0b893d8e3e11da8d3..1e11b9ffdccbca13cae128b825734bb615973752 100644 --- a/app/views/admin/communication/blocks/templates/license/creative_commons/_icons.html.erb +++ b/app/views/admin/communication/blocks/templates/license/creative_commons/_icons.html.erb @@ -1,26 +1,9 @@ <% icon_width ||= 40 -attribution ||= block.template.creative_commons_attribution -commercial_use ||= block.template.creative_commons_commercial_use -derivatives ||= block.template.creative_commons_derivatives -sharing ||= block.template.creative_commons_sharing - -cc = Licenses::CreativeCommons.create_from_block(block) - +cc = Licenses::CreativeCommons.create_from_block(block) %> <% cc.icons.each do |icon| %> <%= image_tag "communication/blocks/templates/license/creative_commons/icons/#{icon}.svg", width: icon_width, class: 'me-1' %> -<% end %> -<%= image_tag 'communication/blocks/templates/license/creative_commons/icons/cc.svg', width: icon_width, class: 'me-1' %> -<% if attribution == 'false' %> - <%= image_tag 'communication/blocks/templates/license/creative_commons/icons/zero.svg', width: icon_width, class: 'me-1' %> -<% else %> - <%= image_tag 'communication/blocks/templates/license/creative_commons/icons/by.svg', width: icon_width, class: 'me-1' %> - <%= image_tag 'communication/blocks/templates/license/creative_commons/icons/nc.svg', width: icon_width, class: 'me-1' if commercial_use == 'false' %> - <%= image_tag 'communication/blocks/templates/license/creative_commons/icons/nd.svg', width: icon_width, class: 'me-1' if derivatives == 'false' %> - <% if derivatives == 'true' && sharing == 'false' %> - <%= image_tag 'communication/blocks/templates/license/creative_commons/icons/sa.svg', width: icon_width, class: 'me-1' %> - <% end %> <% end %> \ No newline at end of file diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index a19f90c17cc9215618e253dd724844ae7570a474..f240022a67847e4b6a7fad3a4c1d0b0fc38c3ff2 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -474,7 +474,7 @@ en: placeholder: Enter description here remove_key: Remove key figure license: - description: A legal license explained, like Creative Commons. + description: A Creative Commons legal license with a link to the official reference. creative_commons: about_html: Use the <a href="https://creativecommons.org" target="_blank" rel="noreferrer">Creative Commons</a> to share your work. The license chooser is based on <a href="https://chooser-beta.creativecommons.org"target="_blank" rel="noreferrer">chooser-beta.creativecommons.org.org</a>. edit: diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index 39da2cfc24c049eabf64d608adb2af9a3b907887..6058f74fe659bbe6de61b19f59a113e8bf49fdc1 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -471,7 +471,7 @@ fr: label: Description placeholder: Entrer la description license: - description: Une licence juridique de type Creative Commons, avec son explication. + description: Une licence juridique de type Creative Commons, avec sa référence. creative_commons: about_html: Utilisez les licences <a href="https://creativecommons.org" target="_blank" rel="noreferrer">Creative Commons</a> pour partager votre travail. Le sélecteur de licence est basé sur <a href="https://chooser-beta.creativecommons.org"target="_blank" rel="noreferrer">chooser-beta.creativecommons.org.org</a> edit: