diff --git a/controllers/user.js b/controllers/user.js index 4c5d51e99..839b4d86e 100644 --- a/controllers/user.js +++ b/controllers/user.js @@ -1847,6 +1847,7 @@ exports.editScript = function (aReq, aRes, aNext) { var installNameBase = null; var isLib = aReq.params.isLib; var tasks = []; + var nowDate = null; // Session options.authedUser = authedUser = modelParser.parseUser(authedUser); @@ -1877,6 +1878,9 @@ exports.editScript = function (aReq, aRes, aNext) { var collaborators = null; var licenses = null; var licensePrimary = null; + var copyrights = null; + var copyrightPrimary = null; + var sinceDate = null; //--- if (aErr || !aScript) { @@ -1900,6 +1904,16 @@ exports.editScript = function (aReq, aRes, aNext) { : undefined)).replace(/\+$/, ''); } + copyrights = scriptStorage.findMeta(aScript.meta, 'UserScript.copyright.value'); + if (copyrights) { + copyrightPrimary = copyrights[copyrights.length - 1]; + script.copyrightPrimary = copyrightPrimary; + } else { + sinceDate = new Date(script.updatedISOFormat); + options.script.copyrightPrimary = sinceDate.getFullYear() + ', ' + authedUser.name + + ' (https://openuserjs.org' + authedUser.userPageUrl + ')'; + } + options.isOwner = authedUser && (authedUser._id == script._authorId || collaborators.indexOf(authedUser.name) > -1); modelParser.renderScript(script); @@ -1951,7 +1965,14 @@ exports.editScript = function (aReq, aRes, aNext) { options.isScriptViewSourcePage = true; options.script = {}; + options.script.isLib = isLib; + options.script.licensePrimary = 'MIT'; // NOTE: Site default + + nowDate = new Date(); + options.script.copyrightPrimary = nowDate.getFullYear() + ', ' + authedUser.name + + ' (https://openuserjs.org' + authedUser.userPageUrl + ')'; + options.script.scriptAcceptableOSILicense = []; SPDXOSI.forEach(function (aElement, aIndex, aArray) { if (blockSPDX.indexOf(aElement) === -1) { diff --git a/views/includes/scriptAuthorToolsPanel.html b/views/includes/scriptAuthorToolsPanel.html index 1230bec57..9967ff23c 100644 --- a/views/includes/scriptAuthorToolsPanel.html +++ b/views/includes/scriptAuthorToolsPanel.html @@ -11,6 +11,11 @@ {{/isScriptViewSourcePage}} {{#isScriptViewSourcePage}} + + {{^script.isLib}} +

UserScript Block

+ {{/script.isLib}} + {{^script.isLib}} {{^newScript}}
@@ -30,12 +35,33 @@
{{/newScript}} {{/script.isLib}} + + {{#script.isLib}} +

UserScript and OpenUserJS Block

+ {{/script.isLib}} + +
+
+ + + + + + + + + +
+
+
-
+ -
+ - +