From c5b5dff7f9761d38727ff14ae876914f10df443b Mon Sep 17 00:00:00 2001 From: Martii Date: Wed, 13 Apr 2016 23:08:52 -0600 Subject: [PATCH] Add `@updateURL` to script homepage * Color changes depending upon lockdown mode ... default class vs info class *(currently white and blue respectively)* * This is useful so there aren't mistakes post published ... many thanks to @jscher2000 for the idea on one placement... more? :) **NOTE** This doesn't cover dynamic searching on Source Code pages as those `@name`s can change. Also using the `url` routines here... `uri` routines are available but need `options` link added in if needed Applies to #970 --- controllers/script.js | 7 +++++++ libs/modelParser.js | 20 ++++++++++++++++++++ views/includes/scriptAuthorToolsPanel.html | 8 ++++++++ views/includes/scripts/clipboard.html | 2 +- views/pages/scriptPage.html | 4 +--- 5 files changed, 37 insertions(+), 4 deletions(-) diff --git a/controllers/script.js b/controllers/script.js index 1eaa50c9b..1b09a803e 100644 --- a/controllers/script.js +++ b/controllers/script.js @@ -376,6 +376,11 @@ exports.view = function (aReq, aRes, aNext) { options.isMod = authedUser && authedUser.isMod; options.isAdmin = authedUser && authedUser.isAdmin; + // Lockdown + options.lockdown = {}; + options.lockdown.scriptStorageRO = process.env.READ_ONLY_SCRIPT_STORAGE === 'true'; + options.lockdown.updateURLCheck = process.env.FORCE_BUSY_UPDATEURL_CHECK === 'true'; + // Script options.script = script = modelParser.parseScript(aScript); options.isOwner = authedUser && authedUser._id == script._authorId; @@ -385,6 +390,8 @@ exports.view = function (aReq, aRes, aNext) { script.scriptInstallPageUrl; script.scriptPermalinkInstallPageXUrl = 'https://' + aReq.get('host') + script.scriptInstallPageXUrl; + script.scriptPermalinkMetaPageUrl = 'https://' + aReq.get('host') + + script.scriptMetaPageUrl; // Page metadata pageMetadata(options, ['About', script.name, (script.isLib ? 'Libraries' : 'Userscripts')], diff --git a/libs/modelParser.js b/libs/modelParser.js index 59b40f5ae..863905da4 100644 --- a/libs/modelParser.js +++ b/libs/modelParser.js @@ -139,6 +139,15 @@ var getScriptInstallPageUrl = function (aScriptData) { (isLib ? '.js' : '.user.js') }; +var getScriptMetaPageUrl = function (aScriptData) { + var isLib = aScriptData.isLib || false; + + return (isLib ? null : '/meta/') + + aScriptData.authorSlugUrl + + '/' + + aScriptData.nameSlugUrl + + '.meta.js' +}; // Uris @@ -173,6 +182,15 @@ var getScriptInstallPageUri = function (aScriptData) { (isLib ? '.js' : '.user.js') }; +var getScriptMetaPageUri = function (aScriptData) { + var isLib = aScriptData.isLib || false; + + return (isLib ? null : '/meta/') + + aScriptData.authorSlugUri + + '/' + + aScriptData.nameSlugUri + + '.meta.js' +}; // @@ -312,6 +330,7 @@ var parseScript = function (aScript) { script.scriptPageUrl = getScriptPageUrl(script); script.scriptInstallPageUrl = getScriptInstallPageUrl(script); script.scriptInstallPageXUrl = script.scriptInstallPageUrl.replace(/(\.user)?\.js/, ''); + script.scriptMetaPageUrl = getScriptMetaPageUrl(script); script.scriptViewSourcePageUrl = getScriptViewSourcePageUrl(script); // Urls: Issues @@ -338,6 +357,7 @@ var parseScript = function (aScript) { script.scriptPageUri = getScriptPageUri(script); script.scriptInstallPageUri = getScriptInstallPageUri(script); script.scriptInstallPageXUri = script.scriptInstallPageUri.replace(/(\.user)?\.js/, ''); + script.scriptMetaPageUri = getScriptMetaPageUri(script); script.scriptViewSourcePageUri = getScriptViewSourcePageUri(script); // Uris: Issues diff --git a/views/includes/scriptAuthorToolsPanel.html b/views/includes/scriptAuthorToolsPanel.html index 9050c255a..db9235210 100644 --- a/views/includes/scriptAuthorToolsPanel.html +++ b/views/includes/scriptAuthorToolsPanel.html @@ -9,6 +9,14 @@
  • Edit Script
  • {{^script.isLib}} +
    +
    + + + + +
    +

    Installs per Version effective

    {{script.meta.version}}{{^script.meta.version}}Current{{/script.meta.version}} {{script.installsSinceUpdate}} installs

    diff --git a/views/includes/scripts/clipboard.html b/views/includes/scripts/clipboard.html index ea978c764..dd29f06e5 100644 --- a/views/includes/scripts/clipboard.html +++ b/views/includes/scripts/clipboard.html @@ -1,7 +1,7 @@