Skip to content

Commit

Permalink
add option for commercial license, plus translations
Browse files Browse the repository at this point in the history
  • Loading branch information
Floppy committed Jan 29, 2024
1 parent 37e5a29 commit 7b9d6da
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
7 changes: 6 additions & 1 deletion app/helpers/models_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,18 @@ def license_select_options(selected: nil)
CC-PDDC
CC0-1.0
MIT
LicenseRef-Commercial
].map { |id|
[
Spdx.licenses[id]["name"] + " (#{id})",
t_license(id),
id
]
},
selected: selected
)
end

def t_license(license)
t("licenses.%{id}" % {id: license.delete(".")}, default: license)
end
end
4 changes: 3 additions & 1 deletion app/views/models/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
<tr>
<td><%= icon "card-heading", "License" %></td>
<td>
<%= link_to @model.license, Spdx.licenses[@model.license]["reference"] %>
<%= Spdx.licenses[@model.license]&.fetch("reference") ?
link_to(t_license(@model.license), Spdx.licenses[@model.license]["reference"]) :
t_license(@model.license) %>
</td>
</tr>
<% end %>
Expand Down
1 change: 1 addition & 0 deletions config/i18n-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ ignore_unused:
- 'activerecord.attributes.*'
- 'activerecord.models.*'
- 'problems.categories.*'
- 'licenses.*'
# - '{devise,kaminari,will_paginate}.*'
# - 'simple_form.{yes,no}'
# - 'simple_form.{placeholders,hints,labels}.*'
Expand Down
11 changes: 11 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ en:
libraries:
general:
new: New Library
licenses:
CC-BY-40: Creative Commons Attrbution
CC-BY-NC-40: Creative Commons Attribution NonCommercial
CC-BY-NC-ND-40: Creative Commons Attribution NonCommercial NoDerivatives
CC-BY-NC-SA-40: Creative Commons Attribution NonCommercial ShareAlike
CC-BY-ND-40: Creative Commons Attribution NoDerivatives
CC-BY-SA-40: Creative Commons Attribution ShareAlike
CC-PDDC: Creative Commons Public Domain Declaration
CC0-10: Creative Commons Zero
LicenseRef-Commercial: Commercial; private use only
MIT: MIT
model_files:
show:
duplicate_card:
Expand Down
6 changes: 6 additions & 0 deletions spec/models/model_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
m = build(:model, license: "Made up license")
expect(m).not_to be_valid
end

it "allows LicenseRef-Commercial to represent private use only" do
# See https://scancode-licensedb.aboutcode.org/commercial-license.html
m = build(:model, license: "LicenseRef-Commercial")
expect(m).to be_valid
end
end

it "strips leading and trailing separators from paths" do
Expand Down

0 comments on commit 7b9d6da

Please sign in to comment.