Skip to content

Commit

Permalink
Rework system help template
Browse files Browse the repository at this point in the history
* Throw in a descriptive label for `@license` value instead of actual. Seems that it's being taken too literally a few times.
* Changing library template to simplest, current form, until can decide if the OpenUserJS block truly is wanted for this methodology here.
* Stop collection of OUJS parts too and those validations... should decide by the end of the week... if on the very, very, very small decision there is another type like "UserCSS" this methodology could conflict... may revert after pondering or not.


Applies to OpenUserJS#1232
  • Loading branch information
Martii committed Nov 13, 2017
1 parent 16044bb commit c4f5b2a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 146 deletions.
84 changes: 0 additions & 84 deletions controllers/scriptStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -1124,28 +1124,6 @@ exports.getMeta = function (aBufs, aCallback) {
aCallback(null);
};

function isEqualKeyset(aOpenUserJSKeyset, aUserSriptKeyset) {
var aOpenUserJSKey = null;
var aUserScriptKey = null;
var i = null;

if (!aUserSriptKeyset || aUserSriptKeyset.length !== aOpenUserJSKeyset.length) {
// No UserScript block keyset or not mirrored exactly.
return false;
} else {
for (i = 0; (aOpenUserJSKey = aOpenUserJSKeyset[i]) &&
(aUserScriptKey = aUserSriptKeyset[i]); i++) {

if (aOpenUserJSKey !== aUserScriptKey) {
// Keyset must exist exactly positioned in both
return false;
}
}
}

return true;
}

exports.storeScript = function (aUser, aMeta, aBuf, aCallback, aUpdate) {
var isLibrary = typeof aMeta === 'string';
var name = null;
Expand All @@ -1156,7 +1134,6 @@ exports.storeScript = function (aUser, aMeta, aBuf, aCallback, aUpdate) {
var downloadURL = null;
var userscriptKeyset = null;
var userscriptKey = null;
var openuserjsKeyset = null;
var thisKeyComponents = null;
var thatSPDX = null;
var htmlStub = null;
Expand Down Expand Up @@ -1233,69 +1210,8 @@ exports.storeScript = function (aUser, aMeta, aBuf, aCallback, aUpdate) {
}


// `name` validations including localizations
userscriptKeyset = findMeta(aMeta, 'UserScript.name.value');
openuserjsKeyset = findMeta(aMeta, 'OpenUserJS.name.value');

if (openuserjsKeyset) {
if (!isEqualKeyset(openuserjsKeyset, userscriptKeyset)) {
// Keysets in both blocks do not match exactly... reject
aCallback(null);
return;
}
}


// `description` validations including localizations
userscriptKeyset = findMeta(aMeta, 'UserScript.description.value');
openuserjsKeyset = findMeta(aMeta, 'OpenUserJS.description.value');

if (openuserjsKeyset) {
if (!isEqualKeyset(openuserjsKeyset, userscriptKeyset)) {
// Keysets in both blocks do not match exactly... reject
aCallback(null);
return;
}
}


// `version` validations
userscriptKeyset = findMeta(aMeta, 'UserScript.version.0.value');
openuserjsKeyset = findMeta(aMeta, 'OpenUserJS.version.0.value');

if (openuserjsKeyset) {
if (!isEqualKeyset(openuserjsKeyset, userscriptKeyset)) {
// Keysets in both blocks do not match exactly... reject
aCallback(null);
return;
}
}


// `copyright` validations
userscriptKeyset = findMeta(aMeta, 'UserScript.copyright.value');
openuserjsKeyset = findMeta(aMeta, 'OpenUserJS.copyright.value');

if (openuserjsKeyset) {
if (!isEqualKeyset(openuserjsKeyset, userscriptKeyset)) {
// Keysets in both blocks do not match exactly... reject
aCallback(null);
return;
}
}


// `license` validations
userscriptKeyset = findMeta(aMeta, 'UserScript.license.value');
openuserjsKeyset = findMeta(aMeta, 'OpenUserJS.license.value');

if (openuserjsKeyset) {
if (!isEqualKeyset(openuserjsKeyset, userscriptKeyset)) {
// Keysets in both block do not match exactly... reject
aCallback(null);
return;
}
}

if (userscriptKeyset) {
thatSPDX = userscriptKeyset[userscriptKeyset.length - 1].split('; ')[0].replace(/\+$/, '');
Expand Down
51 changes: 3 additions & 48 deletions public/pegjs/blockOpenUserJS.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@ Test the generated parser with some input for peg.js site at https://pegjs.org/o
// @author Marti
// @collaborator sizzle
// @unstableMinify Some reason
// @name RFC 2606§3 - Hello, World!
// @name:es ¡Hola mundo!
// @name:fr Salut tout le monde!
// @description Test values with known UserScript metadata keys.
// @description:es Prueba de valores con UserScript metadatos llaves conocidas.
// @description:fr Valeurs d'essai avec des clés de métadonnées UserScript connues.
// @version 1.2.3
// @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
// @licence (CC); https://creativecommons.org/licenses/by-nc-sa/3.0/
// @copyright 2013+, OpenUserJS Group (https://github.com/orgs/OpenUserJs/people)
// ==/OpenUserJS==
*/
Expand Down Expand Up @@ -48,8 +38,7 @@ line =
data:
(
item1 /
items1 /
item1Localized
items1
)
'\n'?
{
Expand All @@ -64,8 +53,7 @@ item1 =
keyword:
(
'author' /
'unstableMinify' /
'version'
'unstableMinify'
)
whitespace
value: non_newline
Expand All @@ -78,43 +66,10 @@ item1 =
};
}

item1Localized =
keyword:
(
'name' /
'description'
)
locale: (':' localeValue:$[a-zA-Z-]+ {
return localeValue;
})?
whitespace
value: non_newline
{
var keywordUpmixed = upmix(keyword);

var obj = {
unique: true,

key: keywordUpmixed,
value: value.replace(/\s+$/, '')
}

if (locale) {
obj.key += ':' + locale;
obj.keyword = keywordUpmixed;
obj.locale = locale;
}

return obj;
}

items1 =
keyword:
(
'collaborator' /
'license' /
'licence' /
'copyright'
'collaborator'
)
whitespace
value: non_newline
Expand Down
15 changes: 1 addition & 14 deletions views/includes/scripts/scriptEditor.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,8 @@
? [
'// ==UserScript==',
'// @exclude *',
'// @namespace https://openuserjs.org/users/' + username,
'',
'// ==OpenUserJS==',
'// @name Getting Started with a Library',
'// @description '
+ 'Showing the current basic and recommended format for a Library script.',
'// @copyright ' + year + ', ' + username
+ ' (https://openuserjs.org/users/' + username + ')',
'// @license GPL-3.0+; http://www.gnu.org/licenses/gpl-3.0.txt',
'// @version 0.0.0',
'// ==/UserScript==',
'',
'// @author ' + username,
'// ==/OpenUserJS==',
'',
'/**',
' *',
' * Please begin typing or paste your Library now.',
Expand All @@ -113,7 +100,7 @@
'Showing the current basic and recommended format for a User script.',
'// @copyright ' + year + ', ' + username
+ ' (https://openuserjs.org/users/' + username + ')',
'// @license GPL-3.0+; http://www.gnu.org/licenses/gpl-3.0.txt',
'// @license OSI-SPDX-Short-Identifier',
'// @version 0.0.0',
'// @include https://www.example.com/*',
'// @grant none',
Expand Down

0 comments on commit c4f5b2a

Please sign in to comment.