Skip to content

Commit

Permalink
Merge pull request #216 from Martii/Issue-210ReverseHandledKeys
Browse files Browse the repository at this point in the history
Issue 210 reverse handled keys

Merging for sizzle... he can test and deploy but we're lagging behind a bit here.
  • Loading branch information
Marti Martz committed Jun 29, 2014
2 parents 2dfae45 + e5ad348 commit 7d9eae2
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 55 deletions.
100 changes: 50 additions & 50 deletions controllers/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,47 @@ var getScriptPageTasks = function (options) {
.caseInsensitive(script.issuesCategorySlug), open: {$ne: false} });
tasks.push(countTask(scriptOpenIssueCountQuery, options, 'issueCount'));

// Show collaborators of the script
if (script.meta.author && script.meta.collaborator) {
options.hasCollab = true;
if (typeof script.meta.collaborator === 'string') {
options.script.collaborators = [{ url: encodeURIComponent(script.meta.collaborator), text: script.meta.collaborator }];
// Show the groups the script belongs to
tasks.push(function (callback) {
script.hasGroups = false;
script.groups = [];

Group.find({
_scriptIds: script._id
}, function (err, scriptGroupList) {
if (err) return callback(err);

scriptGroupList = _.map(scriptGroupList, modelParser.parseGroup);

script.hasGroups = scriptGroupList.length > 0;
script.groups = scriptGroupList;

callback();
});
});

// Show homepages of the script
if (script.meta.homepageURL) {
if (typeof script.meta.homepageURL === 'string') {
htmlStub = '<a href="' + script.meta.homepageURL + '"></a>';
if (htmlStub === sanitizeHtml(htmlStub, htmlWhitelistLink)) {
options.script.homepages = [{
url: script.meta.homepageURL,
text: decodeURI(script.meta.homepageURL),
hasNoFollow: !/^(?:https?:\/\/)?openuserjs\.org\//i.test(script.meta.homepageURL)
}];
}
} else {
options.script.collaborators = [];
script.meta.collaborator.forEach(function (collaborator) {
options.script.collaborators.push({ url: encodeURIComponent(collaborator), text: collaborator });
options.script.homepages = [];
script.meta.homepageURL.forEach(function (homepage) {
htmlStub = '<a href="' + homepage + '"></a>';
if (htmlStub === sanitizeHtml(htmlStub, htmlWhitelistLink)) {
options.script.homepages.unshift({
url: homepage,
text: decodeURI(homepage),
hasNoFollow: !/^(?:https?:\/\/)?openuserjs\.org/i.test(homepage)
});
}
});
}
}
Expand All @@ -85,7 +117,7 @@ var getScriptPageTasks = function (options) {
} else {
options.script.copyrights = [];
script.meta.copyright.forEach(function (copyright) {
options.script.copyrights.push({ name: copyright });
options.script.copyrights.unshift({ name: copyright });
});
}
}
Expand All @@ -97,58 +129,26 @@ var getScriptPageTasks = function (options) {
} else {
options.script.licenses = [];
script.meta.license.forEach(function (license) {
options.script.licenses.push({ name: license });
options.script.licenses.unshift({ name: license });
});
}
} else if (!script.isLib) {
options.script.licenses = [{ name: 'MIT License (Expat)' }];
}

// Show homepages of the script
if (script.meta.homepageURL) {
if (typeof script.meta.homepageURL === 'string') {
htmlStub = '<a href="' + script.meta.homepageURL + '"></a>';
if (htmlStub === sanitizeHtml(htmlStub, htmlWhitelistLink)) {
options.script.homepages = [{
url: script.meta.homepageURL,
text: decodeURI(script.meta.homepageURL),
hasNoFollow: !/^(?:https?:\/\/)?openuserjs\.org\//i.test(script.meta.homepageURL)
}];
}
// Show collaborators of the script
if (script.meta.author && script.meta.collaborator) {
options.hasCollab = true;
if (typeof script.meta.collaborator === 'string') {
options.script.collaborators = [{ url: encodeURIComponent(script.meta.collaborator), text: script.meta.collaborator }];
} else {
options.script.homepages = [];
script.meta.homepageURL.forEach(function (homepage) {
htmlStub = '<a href="' + homepage + '"></a>';
if (htmlStub === sanitizeHtml(htmlStub, htmlWhitelistLink)) {
options.script.homepages.push({
url: homepage,
text: decodeURI(homepage),
hasNoFollow: !/^(?:https?:\/\/)?openuserjs\.org/i.test(homepage)
});
}
options.script.collaborators = [];
script.meta.collaborator.forEach(function (collaborator) {
options.script.collaborators.unshift({ url: encodeURIComponent(collaborator), text: collaborator });
});
}
}

// Show the groups the script belongs to
tasks.push(function (callback) {
script.hasGroups = false;
script.groups = [];

Group.find({
_scriptIds: script._id
}, function (err, scriptGroupList) {
if (err) return callback(err);

scriptGroupList = _.map(scriptGroupList, modelParser.parseGroup);

script.hasGroups = scriptGroupList.length > 0;
script.groups = scriptGroupList;

callback();
});
});

// Show which libraries hosted on the site a script uses
if (!script.isLib && script.uses && script.uses.length > 0) {
script.usesLibs = true;
Expand Down
10 changes: 5 additions & 5 deletions views/pages/newScriptPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<h2><i class="fa fa-tags"></i> Script Metadata</h2>
<div class="panel panel-default">
<div class="panel-body">
<p>You can read about most userscript metadata blocks on the <a href="http://wiki.greasespot.net/Metadata_Block">greasespot wiki</a> and at the <a href="https://sf.net/apps/mediawiki/greasemonkey/index.php?title=Metadata_Block">greasemonkey sourceforge wiki</a>.</p>
<p>You can read about most userscript metadata blocks on the <a href="http://wiki.greasespot.net/Metadata_Block">Greasespot wiki</a> and at the <a href="https://sourceforge.net/p/greasemonkey/wiki/Metadata_Block/">Greasemonkey on SourceForge wiki</a>.</p>
</div>
</div>
<h3>OpenUserJS.org Specific</h3>
Expand All @@ -31,19 +31,19 @@ <h4 class="list-group-item-heading"><code>@description This script even does the

<div class="list-group-item active">
<h4 class="list-group-item-heading"><code>@copyright Year, Author (Author Website)</code></h4>
<p class="list-group-item-text">[<a href="https://sf.net/apps/mediawiki/greasemonkey/index.php?title=Metadata_Block#.40copyright">Wiki Link</a>] Specially formatted on the script page. All values shown.</p>
<p class="list-group-item-text">Specially formatted on the script page. All values shown in reverse order.</p>
</div>
<div class="list-group-item active">
<h4 class="list-group-item-heading"><code>@icon url</code></h4>
<p class="list-group-item-text">A url or data url. Resolution should be near 48px by 48px, Used in the script list page at 16px and on the script page at ~45px. Last value is shown.</p>
</div>
<div class="list-group-item active">
<h4 class="list-group-item-heading"><code>@license License Type; License Homepage</code></h4>
<p class="list-group-item-text">[<a href="https://sf.net/apps/mediawiki/greasemonkey/index.php?title=Metadata_Block#.40license">Wiki Link</a>] Specially formatted on the script page. All values shown. If absent MIT License (Expat) is implied.</p>
<p class="list-group-item-text">Specially formatted on the script page. All values shown in reverse order. If absent MIT License (Expat) is implied.</p>
</div>
<div class="list-group-item active">
<h4 class="list-group-item-heading"><code>@homepageURL url</code></h4>
<p class="list-group-item-text">A url of http, https or mailto protocol. Specially formatted on the script page. All values shown.</p>
<p class="list-group-item-text">A url of http, https or mailto protocol. Specially formatted on the script page. All values shown in reverse order.</p>
</div>
<div class="list-group-item active">
<h4 class="list-group-item-heading"><code>@supportURL url</code></h4>
Expand All @@ -55,7 +55,7 @@ <h4 class="list-group-item-heading"><code>@author {{#authedUser}}{{authedUser.na
</div>
<div class="list-group-item inactive">
<h4 class="list-group-item-heading"><code>@collaborator username</code></h4>
<p class="list-group-item-text">Can be defined multiple times. Required for <a href="#collaboration">Collaboration</a>. All values shown. This key is subject to change.</p>
<p class="list-group-item-text">Can be defined multiple times. Required for <a href="#collaboration">Collaboration</a>. All values shown in reverse order. This key is subject to change.</p>
</div>
</div>

Expand Down

0 comments on commit 7d9eae2

Please sign in to comment.