Skip to content
Snippets Groups Projects
Commit 364a5c96 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

refactor

parent 1e7ed9dd
No related branches found
No related tags found
No related merge requests found
Showing
with 74 additions and 29 deletions
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]
......
......@@ -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
<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'">
......
<%
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
<%
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
<%
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
......@@ -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' %>
......
<%
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
......@@ -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:
......
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment