diff --git a/app/models/communication/block/template/license.rb b/app/models/communication/block/template/license.rb index 6e0bd8605cc11e581dc6e7fe73a3356fd19a139f..a34d1f2fbdf055ca94c420649fd07ab2d11a6255 100644 --- a/app/models/communication/block/template/license.rb +++ b/app/models/communication/block/template/license.rb @@ -1,4 +1,5 @@ class Communication::Block::Template::License < Communication::Block::Template::Base + has_component :description, :rich_text has_component :type, :option, options: [:creative_commons] has_component :creative_commons_attribution, :option, options: [:false, :true] has_component :creative_commons_commercial_use, :option, options: [:true, :false] diff --git a/app/services/licenses/creative_commons.rb b/app/services/licenses/creative_commons.rb index 9efc25c8def5aac5d925deb95ccd75d820b42fcc..d7e8189237796be8c05bcf452ae4d00f7b31daa2 100644 --- a/app/services/licenses/creative_commons.rb +++ b/app/services/licenses/creative_commons.rb @@ -42,10 +42,52 @@ class Licenses::CreativeCommons end @url += '/4.0/' else - @url = 'http://creativecommons.org/publicdomain/zero/1.0/' + @url = 'https://creativecommons.org/publicdomain/zero/1.0/' end end @url 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 + 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 + end + + def name + short_name + end + + def to_s + "#{name}" + end + + def icons + ['cc'] + end + end \ No newline at end of file diff --git a/app/views/admin/communication/blocks/templates/license/_edit.html.erb b/app/views/admin/communication/blocks/templates/license/_edit.html.erb index 5bf393e8947567bd23cdad301199e5a13445f0ea..0aa9ff2d108af6e0948c4cd7a4f53e9ae10b3536 100644 --- a/app/views/admin/communication/blocks/templates/license/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/license/_edit.html.erb @@ -1,3 +1,9 @@ +<div class="row pure__row--small"> + <div class="col-xl-6"> + <%= block_component_edit block, :description %> + </div> +</div> + <%= block_component_edit block, :type %> <div v-show="data.type == 'creative_commons'"> 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 b4b2d2def2be798cc94d8f44f036226e49a2c95c..2a92220efa3069a821a7145a217ee1bab9062518 100644 --- a/app/views/admin/communication/blocks/templates/license/_snippet.html.erb +++ b/app/views/admin/communication/blocks/templates/license/_snippet.html.erb @@ -1,2 +1,5 @@ +<% +cc = Licenses::CreativeCommons.create_from_block(block) +%> <%= render 'admin/communication/blocks/templates/license/creative_commons/icons', block: block %> -<%= render 'admin/communication/blocks/templates/license/creative_commons/name', block: block %> \ No newline at end of file +<%= cc.short_name %> \ 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 37a5aa2e08f375889ef1d7e0d40911361aa79f39..74f0c1042f5924b546abbc9406d97864e50a5cd8 100644 --- a/app/views/admin/communication/blocks/templates/license/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/license/_static.html.erb @@ -1,12 +1,15 @@ +<% +cc = Licenses::CreativeCommons.create_from_block(block) +%> <%= block_component_static block, :type -%> creative_commons: 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 %> - name: >- - <%= render 'admin/communication/blocks/templates/license/creative_commons/name', block: block -%> - full_name: >- - <%= render 'admin/communication/blocks/templates/license/creative_commons/full_name', block: block -%> + short_name: >- + <%= cc.short_name %> + long_name: >- + <%= cc.long_name %> url: >- - <%= render 'admin/communication/blocks/templates/license/creative_commons/url', block: block -%> \ No newline at end of file + <%= cc.url -%> \ No newline at end of file diff --git a/app/views/admin/communication/blocks/templates/license/creative_commons/_full_name.html.erb b/app/views/admin/communication/blocks/templates/license/creative_commons/_full_name.html.erb deleted file mode 100644 index ef7b712612d166498f223fb0f6ebddb291a2f6e0..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/blocks/templates/license/creative_commons/_full_name.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -<% -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 -%> -<% if attribution == 'false' %>CC0 1.0 Universal -<% else %>Attribution<% if commercial_use == 'false' %>-NonCommercial<% end %><% - if derivatives == 'false' %>-NoDerivatives<% end %><% - if derivatives == 'true' && sharing == 'false' %>-ShareAlike<% end %> 4.0 International -<% end %> \ 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 f97afee00f2e5307bf17ece8956dcfb4f3675b45..88862e92d8bf166facf90de0b893d8e3e11da8d3 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 @@ -4,7 +4,15 @@ 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.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' %> diff --git a/app/views/admin/communication/blocks/templates/license/creative_commons/_name.html.erb b/app/views/admin/communication/blocks/templates/license/creative_commons/_name.html.erb deleted file mode 100644 index 45443cd03c414ff0b37b4426b4a107b215f02a6b..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/blocks/templates/license/creative_commons/_name.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -<% -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 -%> -<% if attribution == 'false' %>CC0 1.0 Universal -<% else %>CC BY<% if commercial_use == 'false' %>-NC<% end %><% - if derivatives == 'false' %>-ND<% end %><% - if derivatives == 'true' && sharing == 'false' %>-SA<% end %> 4.0 -<% end %> \ No newline at end of file diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index a5b6f5603e37e0eb67fa6301e80daf5f42bd6ea3..a19f90c17cc9215618e253dd724844ae7570a474 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -498,6 +498,8 @@ en: options: true: Yes. Others can share adaptations of my work under any terms. false: No. Others must use the same CC license if they adapt my work. + description: + label: Description organization_chart: description: People and their jobs. edit: diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index 59558034f5d6f4430672c4af33abf0f41e9dc115..39da2cfc24c049eabf64d608adb2af9a3b907887 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -495,6 +495,8 @@ fr: options: true: Oui. D'autres personnes peuvent partager des adaptations de mon œuvre dans n'importe quelles conditions. false: Non. Les autres doivent utiliser la même licence CC s'ils adaptent mon œuvre. + description: + label: Description organization_chart: description: Une liste de personnes, avec photo, fonction et lien vers la page de la personne. edit: