Allow software licenses

This commit is contained in:
Sophie 2024-04-05 06:23:30 +00:00 committed by Mirjan Hoffmann
parent 6fac8477fa
commit 5f1e99cb4b
3 changed files with 182 additions and 82 deletions

View file

@ -45,5 +45,7 @@
"LABEL_URL_PLACEHOLDER": "Direktlink zur Resource (Voreinstellung GitHub/GitLab Pages URL)",
"LABEL_YAML_METADATA": "YAML Metadaten",
"LABEL_NO_INSTITUTION_FOUND": "Keine passende Institution gefunden",
"LABEL_DATE_PUBLISHED": "Veröffentlichungsdatum"
"LABEL_DATE_PUBLISHED": "Veröffentlichungsdatum",
"LABEL_SOFTWARE_LICENSE": "Software-Lizenz",
"LABEL_CC_LICENSE": "CC-Lizenz"
}

View file

@ -45,5 +45,7 @@
"LABEL_URL_PLACEHOLDER": "Direct link to the resource (default GitHub/GitLab Pages URL)",
"LABEL_YAML_METADATA": "YAML Metadata",
"LABEL_NO_INSTITUTION_FOUND": "No matching institution found",
"LABEL_DATE_PUBLISHED": "Date published"
"LABEL_DATE_PUBLISHED": "Date published",
"LABEL_SOFTWARE_LICENSE": "Software license",
"LABEL_CC_LICENSE": "CC license"
}

View file

@ -170,42 +170,57 @@
</div>
<div class="form-group row">
<label for="choicesLicense" class="col-sm-2 col-form-label" data-i18n="LABEL_LICENSE">Lizenz</label>
<div class="col-sm-7" id="choicesLicense">
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" onclick="chooseLicense()" class="form-check-input" id="inputLicenseBY" value="BY"
checked>
<span data-i18n="LABEL_LICENSE_CHECKBOX_BY">darf ohne Namensnennung verwendet werden</span>
</label>
<div class="col-sm-2">
<input type="radio" value="ccLicense" name="license" id="radioLicenseCC" onchange="ccOrSoftwareLicense()" checked>
<label data-i18n="LABEL_CC_LICENSE">CC-Lizenz</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" onclick="chooseLicense()" class="form-check-input" id="inputLicenseSA" value="SA"
checked>
<span data-i18n="LABEL_LICENSE_CHECKBOX_SA">darf unter anderer Lizenz veröffentlicht werden</span>
</label>
<div class="col-sm-6" id="choicesLicense">
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" onclick="chooseCCLicense()" class="form-check-input" id="inputLicenseBY" value="BY"
checked>
<span data-i18n="LABEL_LICENSE_CHECKBOX_BY">darf ohne Namensnennung verwendet werden</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" onclick="chooseCCLicense()" class="form-check-input" id="inputLicenseSA" value="SA"
checked>
<span data-i18n="LABEL_LICENSE_CHECKBOX_SA">darf unter anderer Lizenz veröffentlicht werden</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" onclick="chooseCCLicense()" class="form-check-input" id="inputLicenseND" value="ND"
checked>
<span data-i18n="LABEL_LICENSE_CHECKBOX_ND">darf verändert werden</span>
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" onclick="chooseCCLicense()" class="form-check-input" id="inputLicenseNC" value="NC"
checked>
<span data-i18n="LABEL_LICENSE_CHECKBOX_NC">darf kommerziell genutzt werden</span>
<input type="hidden" id="licenseUrl"
value="https://creativecommons.org/share-your-work/public-domain/cc0/">
</label>
</div>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" onclick="chooseLicense()" class="form-check-input" id="inputLicenseND" value="ND"
checked>
<span data-i18n="LABEL_LICENSE_CHECKBOX_ND">darf verändert werden</span>
</label>
<div class="col-sm-2">
<label for="choicesLicense" id="choosenLicense" class="col-form-label">CC-0</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" onclick="chooseLicense()" class="form-check-input" id="inputLicenseNC" value="NC"
checked>
<span data-i18n="LABEL_LICENSE_CHECKBOX_NC">darf kommerziell genutzt werden</span>
<input type="hidden" id="licenseUrl"
value="https://creativecommons.org/share-your-work/public-domain/cc0/">
</label>
<label for="choicesLicense" class="col-sm-2 col-form-label"></label>
<div class="col-sm-2" id="softwareLicense">
<input type="radio" value="softwareLicenseInput" name="license" id="radioLicenseSoftware" onchange="ccOrSoftwareLicense()">
<label data-i18n="LABEL_SOFTWARE_LICENSE">Software-Lizenz</label>
</div>
</div>
<div class="col-sm-3">
<label for="choicesLicense" id="choosenLicense" class="col-form-label">CC-0</label>
</div>
</div>
<div class="col-sm-8" style="padding-top: 1ch">
<select data-style="input-dropdown" data-width="100%" class="selectpicker" id="inputSoftwareLicense" data-live-search="true" data-i18n-title="LABEL_LICENSE" required disabled>
</select>
<div class="valid-feedback"></div>
<div class="invalid-feedback" data-i18n="LABEL_MANDATORY_FIELD">Pflichtfeld</div>
</div>
</div>
<div class="form-group row">
<label for="inputSubjectOf" class="col-sm-2 col-form-label" data-i18n="LABEL_SUBJECT">Fach</label>
<div class="col-sm-10">
@ -293,7 +308,8 @@
async function init() {
await loadVocabs();
await i18nLoader();
chooseLicense();
chooseCCLicense();
addSoftwareLicenses();
addCreator();
$("#inputEducationalLevel option[value='https://w3id.org/kim/educationalLevel/level_A']").attr("selected", "true");
$('.selectpicker').selectpicker('refresh');
@ -302,7 +318,9 @@
if (userLang) {
changeLanguage(userLang);
}
}
let vocabInstitutions = []
function loadVocabs() {
@ -385,8 +403,50 @@
}
];
const softwareLicenses = [
{
name: 'Apache License 2.0',
url:'https://opensource.org/license/apache-2-0'
},
{
name: 'BSD 2-Clause "Simplified" License',
url: 'https://opensource.org/license/bsd-2-clause'
},
{
name: 'BSD 3-Clause "New" or "Revised" License',
url: 'https://opensource.org/license/bsd-3-clause',
},
{
name: 'GNU General Public License v2.0',
url: 'https://opensource.org/license/gpl-2-0',
},
{
name: 'GNU General Public License v3.0',
url: 'https://opensource.org/license/gpl-3-0',
},
{
name: 'GNU Lesser General Public License v2.1',
url: 'https://opensource.org/license/lgpl-2-1',
},
{
name: 'GNU Affero General Public License v3.0',
url: 'https://www.gnu.org/licenses/agpl-3.0.html',
},
{
name: 'MIT License',
url: 'https://opensource.org/license/mit',
},
{
name: 'GNU Free Documentation License',
url: 'https://www.gnu.org/licenses/fdl-1.3.html',
},
{
name: 'Zero-Clause BSD',
url: 'https://opensource.org/license/0bsd'
}
]
function chooseLicense() {
function chooseCCLicense() {
const by = document.getElementById("inputLicenseBY")
const sa = document.getElementById("inputLicenseSA")
const nd = document.getElementById("inputLicenseND")
@ -478,6 +538,27 @@
}
}
function addSoftwareLicenses() {
softwareLicenses.forEach((item) => {
$("#inputSoftwareLicense").append('<option value="' + item.url + '" data-i18n="' + item.name + '">'+item.name+'</option>');
});
}
function ccOrSoftwareLicense() {
if(document.getElementById("radioLicenseCC").checked) {
document.getElementById("inputLicenseBY").disabled = false;
document.getElementById("choicesLicense").style = "";
chooseCCLicense();
document.getElementById("inputSoftwareLicense").setAttribute("disabled", "true");
} else {
document.getElementById("inputLicenseBY").disabled = true;
document.getElementById("choicesLicense").style = "color: gray";
document.getElementById("choosenLicense").style = "color: gray";
document.getElementById("inputSoftwareLicense").removeAttribute("disabled");
}
$('.selectpicker').selectpicker('refresh');
}
function splitKeywords(keywordString) {
const keywords = keywordString.split(",");
return keywords.map((k) => k.trim());
@ -712,7 +793,11 @@
type: "LearningResource",
name: document.getElementById("inputTitle").value,
description: document.getElementById("inputDescription").value,
license: document.getElementById("licenseUrl").value
}
if(document.getElementById("radioLicenseCC").checked) {
meta.license = document.getElementById("licenseUrl").value
} else {
meta.license = document.getElementById("inputSoftwareLicense").value
}
if (identifier) {
meta.id = identifier;
@ -791,7 +876,7 @@
document.getElementById("inputDescription").value = data.description ? data.description : "";
$('#inputLanguage').val(data.inLanguage ? data.inLanguage : []).selectpicker('refresh');
$('#inputSubjectOf').val(aboutIds).selectpicker('refresh');
setLicense(licenseUrl)
setLicense((data.license && data.license.id) ? idMap(data.license) : data.license)
document.getElementById("inputImage").value = data.image ? data.image : "";
$('#inputResourceType').val(learningResourceTypeIds).selectpicker('refresh');
if (educationalLevelIds.length > 0) {
@ -805,52 +890,63 @@
}
}
function setLicense(license) {
const by = document.getElementById("inputLicenseBY")
const sa = document.getElementById("inputLicenseSA")
const nd = document.getElementById("inputLicenseND")
const nc = document.getElementById("inputLicenseNC")
if (license.startsWith("https://creativecommons.org/publicdomain/zero/")) {
by.checked = true;
sa.checked = true;
nd.checked = true;
nc.checked = true;
} else if (license.startsWith("https://creativecommons.org/licenses/by/")) {
by.checked = false;
sa.checked = true;
nd.checked = true;
nc.checked = true;
} else if (license.startsWith("https://creativecommons.org/licenses/by-sa/")) {
by.checked = false;
sa.checked = false;
nd.checked = true;
nc.checked = true;
} else if (license.startsWith("https://creativecommons.org/licenses/by-nd/")) {
by.checked = false;
sa.checked = true;
nd.checked = false;
nc.checked = true;
} else if (license.startsWith("https://creativecommons.org/licenses/by-nc/")) {
by.checked = false;
sa.checked = true;
nd.checked = true;
nc.checked = false;
} else if (license.startsWith("https://creativecommons.org/licenses/by-nc-sa/")) {
by.checked = false;
sa.checked = false;
nd.checked = true;
nc.checked = false;
} else if (license.startsWith("https://creativecommons.org/licenses/by-nc-nd/")) {
by.checked = false;
sa.checked = true;
nd.checked = false;
nc.checked = false;
if (license.startsWith("https://creativecommons.org/")) {
const by = document.getElementById("inputLicenseBY")
const sa = document.getElementById("inputLicenseSA")
const nd = document.getElementById("inputLicenseND")
const nc = document.getElementById("inputLicenseNC")
if (license.startsWith("https://creativecommons.org/publicdomain/zero/")) {
by.checked = true;
sa.checked = true;
nd.checked = true;
nc.checked = true;
} else if (license.startsWith("https://creativecommons.org/licenses/by/")) {
by.checked = false;
sa.checked = true;
nd.checked = true;
nc.checked = true;
} else if (license.startsWith("https://creativecommons.org/licenses/by-sa/")) {
by.checked = false;
sa.checked = false;
nd.checked = true;
nc.checked = true;
} else if (license.startsWith("https://creativecommons.org/licenses/by-nd/")) {
by.checked = false;
sa.checked = true;
nd.checked = false;
nc.checked = true;
} else if (license.startsWith("https://creativecommons.org/licenses/by-nc/")) {
by.checked = false;
sa.checked = true;
nd.checked = true;
nc.checked = false;
} else if (license.startsWith("https://creativecommons.org/licenses/by-nc-sa/")) {
by.checked = false;
sa.checked = false;
nd.checked = true;
nc.checked = false;
} else if (license.startsWith("https://creativecommons.org/licenses/by-nc-nd/")) {
by.checked = false;
sa.checked = true;
nd.checked = false;
nc.checked = false;
} else {
by.checked = false;
sa.checked = false;
nd.checked = false;
nc.checked = false;
}
chooseCCLicense();
} else {
by.checked = false;
sa.checked = false;
nd.checked = false;
nc.checked = false;
document.getElementById("inputSoftwareLicense").name = softwareLicenses.find(l => l.url == license).name;
document.getElementById("inputSoftwareLicense").value = license;
document.getElementById("radioLicenseSoftware").checked = "true";
document.getElementById("inputLicenseBY").disabled = true;
document.getElementById("choicesLicense").style = "color: gray";
document.getElementById("choosenLicense").style = "color: gray";
document.getElementById("inputSoftwareLicense").removeAttribute("disabled");
$('.selectpicker').selectpicker('refresh');
}
chooseLicense();
}
async function i18nLoader() {