From d24fb48f16bff4d0e6b1bfdeffd2b41c7e61a347 Mon Sep 17 00:00:00 2001 From: Cédric Couralet Date: Wed, 7 Nov 2018 11:32:20 +0000 Subject: Fix menu when gitlab is enabled Signed-off-by: Cédric Couralet --- app.js | 1 + public/views/codimd/header.ejs | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app.js b/app.js index 7795dd83..50b61226 100644 --- a/app.js +++ b/app.js @@ -198,6 +198,7 @@ app.locals.authProviders = { email: config.isEmailEnable, allowEmailRegister: config.allowEmailRegister } +app.locals.enableGitlabSnippets = (!config.gitlab.scope || config.gitlab.scope === 'api') app.use(require('./lib/web/baseRouter')) app.use(require('./lib/web/statusRouter')) diff --git a/public/views/codimd/header.ejs b/public/views/codimd/header.ejs index d8df33b8..56a42eb4 100644 --- a/public/views/codimd/header.ejs +++ b/public/views/codimd/header.ejs @@ -32,7 +32,7 @@
  • <%= __('Slide Mode') %>
  • - <% if((typeof github !== 'undefined' && github) || (typeof dropbox !== 'undefined' && dropbox) || (typeof gitlab !== 'undefined' && gitlab && (!gitlab.scope || gitlab.scope === 'api'))) { %> + <% if((typeof github !== 'undefined' && github) || (typeof dropbox !== 'undefined' && dropbox) || enableGitlabSnippets) { %>
  • Dropbox @@ -41,7 +41,7 @@
  • Gist
  • <% } %> - <% if(typeof gitlab !== 'undefined' && gitlab && (!gitlab.scope || gitlab.scope === 'api')) { %> + <% if(enableGitlabSnippets) { %>
  • Snippet
  • <% } %> @@ -52,7 +52,7 @@
  • Gist
  • - <% if(typeof gitlab !== 'undefined' && gitlab && (!gitlab.scope || gitlab.scope === 'api')) { %> + <% if(enableGitlabSnippets) { %>
  • Snippet
  • <% } %> @@ -134,7 +134,7 @@
  • <%= __('Slide Mode') %>
  • - <% if((typeof github !== 'undefined' && github) || (typeof dropbox !== 'undefined' && dropbox) || (typeof gitlab !== 'undefined' && gitlab && (!gitlab.scope || gitlab.scope === 'api'))) { %> + <% if((typeof github !== 'undefined' && github) || (typeof dropbox !== 'undefined' && dropbox) || enableGitlabSnippets ) { %>
  • Dropbox @@ -143,7 +143,7 @@
  • Gist
  • <% } %> - <% if(typeof gitlab !== 'undefined' && gitlab && (!gitlab.scope || gitlab.scope === 'api')) { %> + <% if(enableGitlabSnippets) { %>
  • Snippet
  • <% } %> @@ -154,7 +154,7 @@
  • Gist
  • - <% if(typeof gitlab !== 'undefined' && gitlab && (!gitlab.scope || gitlab.scope === 'api')) { %> + <% if(enableGitlabSnippets) { %>
  • Snippet
  • <% } %> -- cgit v1.2.3 From 67f8a64f2b1ea653b567a48ac6aa760b03c7189c Mon Sep 17 00:00:00 2001 From: Cédric Couralet Date: Wed, 7 Nov 2018 12:12:50 +0000 Subject: Fix menu for github and dropbox Signed-off-by: Cédric Couralet --- app.js | 6 +++++- lib/config/index.js | 2 ++ public/views/codimd/header.ejs | 8 ++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app.js b/app.js index 50b61226..622d866f 100644 --- a/app.js +++ b/app.js @@ -198,7 +198,11 @@ app.locals.authProviders = { email: config.isEmailEnable, allowEmailRegister: config.allowEmailRegister } -app.locals.enableGitlabSnippets = (!config.gitlab.scope || config.gitlab.scope === 'api') + +// Export/Import menu items +app.locals.enableDropBoxSave = config.isDropboxEnable +app.locals.enableGitHubGist = config.isGitHubEnable +app.locals.enableGitlabSnippets = config.isGitlabSnippetsEnable app.use(require('./lib/web/baseRouter')) app.use(require('./lib/web/statusRouter')) diff --git a/lib/config/index.js b/lib/config/index.js index f8b68e30..501fdca3 100644 --- a/lib/config/index.js +++ b/lib/config/index.js @@ -110,6 +110,8 @@ if (config.gitlab && config.gitlab.version !== 'v4' && config.gitlab.version !== logger.warn('config.js contains wrong version (' + config.gitlab.version + ') for gitlab api; it should be \'v3\' or \'v4\'. Defaulting to v4') config.gitlab.version = 'v4' } +// If gitlab scope is api, enable snippets Export/import +config.isGitlabSnippetsEnable = (!config.gitlab.scope || config.gitlab.scope === 'api') // Only update i18n files in development setups config.updateI18nFiles = (env === Environment.development) diff --git a/public/views/codimd/header.ejs b/public/views/codimd/header.ejs index 56a42eb4..b83838ea 100644 --- a/public/views/codimd/header.ejs +++ b/public/views/codimd/header.ejs @@ -32,12 +32,12 @@
  • <%= __('Slide Mode') %>
  • - <% if((typeof github !== 'undefined' && github) || (typeof dropbox !== 'undefined' && dropbox) || enableGitlabSnippets) { %> + <% if(enableGitHubGist || enableDropBoxSave || enableGitlabSnippets) { %>
  • Dropbox
  • - <% if(typeof github !== 'undefined' && github) { %> + <% if(enableGitHubGist) { %>
  • Gist
  • <% } %> @@ -134,12 +134,12 @@
  • <%= __('Slide Mode') %>
  • - <% if((typeof github !== 'undefined' && github) || (typeof dropbox !== 'undefined' && dropbox) || enableGitlabSnippets ) { %> + <% if(enableGitHubGist || enableDropBoxSave || enableGitlabSnippets) { %>
  • Dropbox
  • - <% if(typeof github !== 'undefined' && github) { %> + <% if(enableGitHubGist) { %>
  • Gist
  • <% } %> -- cgit v1.2.3