mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-26 03:33:58 -05:00
Update to move dropbox app key setting to common.js and will auto load client-side related scripts
This commit is contained in:
parent
a816420302
commit
a70ebf7762
7 changed files with 39 additions and 43 deletions
|
@ -123,8 +123,7 @@ Third-party integration api key settings
|
||||||
| ------- | --------- | ----------- |
|
| ------- | --------- | ----------- |
|
||||||
| facebook, twitter, github, dropbox | `config.json` | for signin |
|
| facebook, twitter, github, dropbox | `config.json` | for signin |
|
||||||
| imgur | `config.json` | for image upload |
|
| imgur | `config.json` | for image upload |
|
||||||
| dropbox | `public/views/foot.ejs` | for chooser and saver |
|
| google drive, dropbox | `public/js/common.js` | for export and import |
|
||||||
| google drive | `public/js/common.js`/ `config.json` (enable) | for export and import |
|
|
||||||
|
|
||||||
|
|
||||||
Operational Transformation
|
Operational Transformation
|
||||||
|
|
|
@ -61,7 +61,6 @@ var twitter = config.twitter || false;
|
||||||
var github = config.github || false;
|
var github = config.github || false;
|
||||||
var dropbox = config.dropbox || false;
|
var dropbox = config.dropbox || false;
|
||||||
var imgur = config.imgur || false;
|
var imgur = config.imgur || false;
|
||||||
var googleDrive = config.googleDrive || false;
|
|
||||||
|
|
||||||
function getserverurl() {
|
function getserverurl() {
|
||||||
var url = '';
|
var url = '';
|
||||||
|
@ -112,6 +111,5 @@ module.exports = {
|
||||||
twitter: twitter,
|
twitter: twitter,
|
||||||
github: github,
|
github: github,
|
||||||
dropbox: dropbox,
|
dropbox: dropbox,
|
||||||
imgur: imgur,
|
imgur: imgur
|
||||||
googleDrive: googleDrive,
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -72,8 +72,7 @@ function responseError(res, code, detail, msg) {
|
||||||
code: code,
|
code: code,
|
||||||
detail: detail,
|
detail: detail,
|
||||||
msg: msg,
|
msg: msg,
|
||||||
useCDN: config.usecdn,
|
useCDN: config.usecdn
|
||||||
googleDrive: config.googleDrive,
|
|
||||||
});
|
});
|
||||||
res.write(content);
|
res.write(content);
|
||||||
res.end();
|
res.end();
|
||||||
|
@ -95,8 +94,7 @@ function showIndex(req, res, next) {
|
||||||
facebook: config.facebook,
|
facebook: config.facebook,
|
||||||
twitter: config.twitter,
|
twitter: config.twitter,
|
||||||
github: config.github,
|
github: config.github,
|
||||||
dropbox: config.dropbox,
|
dropbox: config.dropbox
|
||||||
googleDrive: config.googleDrive,
|
|
||||||
});
|
});
|
||||||
res.write(content);
|
res.write(content);
|
||||||
res.end();
|
res.end();
|
||||||
|
@ -126,8 +124,7 @@ function responseHackMD(res, note) {
|
||||||
facebook: config.facebook,
|
facebook: config.facebook,
|
||||||
twitter: config.twitter,
|
twitter: config.twitter,
|
||||||
github: config.github,
|
github: config.github,
|
||||||
dropbox: config.dropbox,
|
dropbox: config.dropbox
|
||||||
googleDrive: config.googleDrive,
|
|
||||||
});
|
});
|
||||||
var buf = html;
|
var buf = html;
|
||||||
res.writeHead(200, {
|
res.writeHead(200, {
|
||||||
|
|
|
@ -4,8 +4,10 @@ var urlpath = ''; // sub url path, like: www.example.com/<urlpath>
|
||||||
//settings
|
//settings
|
||||||
var debug = false;
|
var debug = false;
|
||||||
|
|
||||||
var GOOGLE_API_KEY = 'change this';
|
var GOOGLE_API_KEY = '';
|
||||||
var GOOGLE_CLIENT_ID = 'change this';
|
var GOOGLE_CLIENT_ID = '';
|
||||||
|
|
||||||
|
var DROPBOX_APP_KEY = '';
|
||||||
|
|
||||||
var port = window.location.port;
|
var port = window.location.port;
|
||||||
var serverurl = window.location.protocol + '//' + (domain ? domain : window.location.hostname) + (port ? ':' + port : '') + (urlpath ? '/' + urlpath : '');
|
var serverurl = window.location.protocol + '//' + (domain ? domain : window.location.hostname) + (port ? ':' + port : '') + (urlpath ? '/' + urlpath : '');
|
||||||
|
|
|
@ -1048,6 +1048,35 @@ function showMessageModal(title, header, href, text, success) {
|
||||||
modal.modal('show');
|
modal.modal('show');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if dropbox app key is set and load scripts
|
||||||
|
if (DROPBOX_APP_KEY) {
|
||||||
|
$('<script>')
|
||||||
|
.attr('type', 'text/javascript')
|
||||||
|
.attr('src', 'https://www.dropbox.com/static/api/2/dropins.js')
|
||||||
|
.attr('id', 'dropboxjs')
|
||||||
|
.attr('data-app-key', DROPBOX_APP_KEY)
|
||||||
|
.appendTo('body');
|
||||||
|
} else {
|
||||||
|
ui.toolbar.import.dropbox.hide();
|
||||||
|
ui.toolbar.export.dropbox.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if google api key and client id are set and load scripts
|
||||||
|
if (GOOGLE_API_KEY && GOOGLE_CLIENT_ID) {
|
||||||
|
$('<script>')
|
||||||
|
.attr('type', 'text/javascript')
|
||||||
|
.attr('src', 'https://www.google.com/jsapi')
|
||||||
|
.appendTo('body');
|
||||||
|
|
||||||
|
$('<script>')
|
||||||
|
.attr('type', 'text/javascript')
|
||||||
|
.attr('src', 'https://apis.google.com/js/client:plusone.js?onload=onGoogleClientLoaded')
|
||||||
|
.appendTo('body');
|
||||||
|
} else {
|
||||||
|
ui.toolbar.import.googleDrive.hide();
|
||||||
|
ui.toolbar.export.googleDrive.hide();
|
||||||
|
}
|
||||||
|
|
||||||
//button actions
|
//button actions
|
||||||
//share
|
//share
|
||||||
ui.toolbar.publish.attr("href", noteurl + "/publish");
|
ui.toolbar.publish.attr("href", noteurl + "/publish");
|
||||||
|
|
|
@ -71,12 +71,6 @@
|
||||||
<script src="<%- url %>/vendor/md-toc.js" defer></script>
|
<script src="<%- url %>/vendor/md-toc.js" defer></script>
|
||||||
<script src="<%- url %>/vendor/showup/showup.js" defer></script>
|
<script src="<%- url %>/vendor/showup/showup.js" defer></script>
|
||||||
<script src="<%- url %>/vendor/randomColor.js" defer></script>
|
<script src="<%- url %>/vendor/randomColor.js" defer></script>
|
||||||
<% if(dropbox) { %>
|
|
||||||
<script type="text/javascript" src="https://www.dropbox.com/static/api/2/dropins.js" id="dropboxjs" data-app-key="change this" async defer></script>
|
|
||||||
<% } %>
|
|
||||||
<% if(googleDrive) { %>
|
|
||||||
<script src="https://www.google.com/jsapi" defer></script>
|
|
||||||
<% } %>
|
|
||||||
<script src="<%- url %>/js/google-drive-upload.js" defer></script>
|
<script src="<%- url %>/js/google-drive-upload.js" defer></script>
|
||||||
<script src="<%- url %>/js/google-drive-picker.js" defer></script>
|
<script src="<%- url %>/js/google-drive-picker.js" defer></script>
|
||||||
<script src="<%- url %>/js/common.js" defer></script>
|
<script src="<%- url %>/js/common.js" defer></script>
|
||||||
|
@ -85,6 +79,3 @@
|
||||||
<script src="<%- url %>/js/history.js" defer></script>
|
<script src="<%- url %>/js/history.js" defer></script>
|
||||||
<script src="<%- url %>/js/index.js" defer></script>
|
<script src="<%- url %>/js/index.js" defer></script>
|
||||||
<script src="<%- url %>/js/syncscroll.js" defer></script>
|
<script src="<%- url %>/js/syncscroll.js" defer></script>
|
||||||
<% if(googleDrive) { %>
|
|
||||||
<script src="https://apis.google.com/js/client:plusone.js?onload=onGoogleClientLoaded" defer></script>
|
|
||||||
<% } %>
|
|
||||||
|
|
|
@ -33,31 +33,21 @@
|
||||||
<li role="presentation"><a role="menuitem" class="ui-beta-slide" tabindex="-1" href="#" target="_blank"><i class="fa fa-tv fa-fw"></i> Slide Mode</a>
|
<li role="presentation"><a role="menuitem" class="ui-beta-slide" tabindex="-1" href="#" target="_blank"><i class="fa fa-tv fa-fw"></i> Slide Mode</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
<% if((googleDrive == "true") || (typeof dropbox !== 'undefined' && dropbox) || (typeof github !== 'undefined' && github)) { %>
|
|
||||||
<li class="dropdown-header">Export</li>
|
<li class="dropdown-header">Export</li>
|
||||||
<% if(typeof dropbox !== 'undefined' && dropbox) { %>
|
|
||||||
<li role="presentation"><a role="menuitem" class="ui-save-dropbox" tabindex="-1" href="#" target="_self"><i class="fa fa-dropbox fa-fw"></i> Dropbox</a>
|
<li role="presentation"><a role="menuitem" class="ui-save-dropbox" tabindex="-1" href="#" target="_self"><i class="fa fa-dropbox fa-fw"></i> Dropbox</a>
|
||||||
</li>
|
</li>
|
||||||
<% } %>
|
|
||||||
<% if(googleDrive == "true") { %>
|
|
||||||
<li role="presentation"><a role="menuitem" class="ui-save-google-drive" tabindex="-1" href="#" target="_self"><i class="fa fa-cloud-upload fa-fw"></i> Google Drive</a>
|
<li role="presentation"><a role="menuitem" class="ui-save-google-drive" tabindex="-1" href="#" target="_self"><i class="fa fa-cloud-upload fa-fw"></i> Google Drive</a>
|
||||||
</li>
|
</li>
|
||||||
<% } %>
|
|
||||||
<% if(typeof github !== 'undefined' && github) { %>
|
<% if(typeof github !== 'undefined' && github) { %>
|
||||||
<li role="presentation"><a role="menuitem" class="ui-save-gist" tabindex="-1" href="#" target="_blank"><i class="fa fa-github fa-fw"></i> Gist</a>
|
<li role="presentation"><a role="menuitem" class="ui-save-gist" tabindex="-1" href="#" target="_blank"><i class="fa fa-github fa-fw"></i> Gist</a>
|
||||||
</li>
|
</li>
|
||||||
<% } %>
|
<% } %>
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
<% } %>
|
|
||||||
<li class="dropdown-header">Import</li>
|
<li class="dropdown-header">Import</li>
|
||||||
<% if(typeof dropbox !== 'undefined' && dropbox) { %>
|
|
||||||
<li role="presentation"><a role="menuitem" class="ui-import-dropbox" tabindex="-1" href="#" target="_self"><i class="fa fa-dropbox fa-fw"></i> Dropbox</a>
|
<li role="presentation"><a role="menuitem" class="ui-import-dropbox" tabindex="-1" href="#" target="_self"><i class="fa fa-dropbox fa-fw"></i> Dropbox</a>
|
||||||
</li>
|
</li>
|
||||||
<% } %>
|
|
||||||
<% if(googleDrive == "true") { %>
|
|
||||||
<li role="presentation"><a role="menuitem" class="ui-import-google-drive" tabindex="-1" href="#" target="_self"><i class="fa fa-cloud-download fa-fw"></i> Google Drive</a>
|
<li role="presentation"><a role="menuitem" class="ui-import-google-drive" tabindex="-1" href="#" target="_self"><i class="fa fa-cloud-download fa-fw"></i> Google Drive</a>
|
||||||
</li>
|
</li>
|
||||||
<% } %>
|
|
||||||
<li role="presentation"><a role="menuitem" class="ui-import-gist" href="#" data-toggle="modal" data-target="#gistImportModal"><i class="fa fa-github fa-fw"></i> Gist</a>
|
<li role="presentation"><a role="menuitem" class="ui-import-gist" href="#" data-toggle="modal" data-target="#gistImportModal"><i class="fa fa-github fa-fw"></i> Gist</a>
|
||||||
</li>
|
</li>
|
||||||
<li role="presentation"><a role="menuitem" class="ui-import-clipboard" href="#" data-toggle="modal" data-target="#clipboardModal"><i class="fa fa-clipboard fa-fw"></i> Clipboard</a>
|
<li role="presentation"><a role="menuitem" class="ui-import-clipboard" href="#" data-toggle="modal" data-target="#clipboardModal"><i class="fa fa-clipboard fa-fw"></i> Clipboard</a>
|
||||||
|
@ -128,31 +118,21 @@
|
||||||
<li role="presentation"><a role="menuitem" class="ui-beta-slide" tabindex="-1" href="#" target="_blank"><i class="fa fa-tv fa-fw"></i> Slide Mode</a>
|
<li role="presentation"><a role="menuitem" class="ui-beta-slide" tabindex="-1" href="#" target="_blank"><i class="fa fa-tv fa-fw"></i> Slide Mode</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
<% if((googleDrive == "true") || (typeof dropbox !== 'undefined' && dropbox) || (typeof github !== 'undefined' && github)) { %>
|
|
||||||
<li class="dropdown-header">Export</li>
|
<li class="dropdown-header">Export</li>
|
||||||
<% if(typeof dropbox !== 'undefined' && dropbox) { %>
|
|
||||||
<li role="presentation"><a role="menuitem" class="ui-save-dropbox" tabindex="-1" href="#" target="_self"><i class="fa fa-dropbox fa-fw"></i> Dropbox</a>
|
<li role="presentation"><a role="menuitem" class="ui-save-dropbox" tabindex="-1" href="#" target="_self"><i class="fa fa-dropbox fa-fw"></i> Dropbox</a>
|
||||||
</li>
|
</li>
|
||||||
<% } %>
|
|
||||||
<% if(googleDrive == "true") { %>
|
|
||||||
<li role="presentation"><a role="menuitem" class="ui-save-google-drive" tabindex="-1" href="#" target="_self"><i class="fa fa-cloud-upload fa-fw"></i> Google Drive</a>
|
<li role="presentation"><a role="menuitem" class="ui-save-google-drive" tabindex="-1" href="#" target="_self"><i class="fa fa-cloud-upload fa-fw"></i> Google Drive</a>
|
||||||
</li>
|
</li>
|
||||||
<% } %>
|
|
||||||
<% if(typeof github !== 'undefined' && github) { %>
|
<% if(typeof github !== 'undefined' && github) { %>
|
||||||
<li role="presentation"><a role="menuitem" class="ui-save-gist" tabindex="-1" href="#" target="_blank"><i class="fa fa-github fa-fw"></i> Gist</a>
|
<li role="presentation"><a role="menuitem" class="ui-save-gist" tabindex="-1" href="#" target="_blank"><i class="fa fa-github fa-fw"></i> Gist</a>
|
||||||
</li>
|
</li>
|
||||||
<% } %>
|
<% } %>
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
<% } %>
|
|
||||||
<li class="dropdown-header">Import</li>
|
<li class="dropdown-header">Import</li>
|
||||||
<% if(typeof dropbox !== 'undefined' && dropbox) { %>
|
|
||||||
<li role="presentation"><a role="menuitem" class="ui-import-dropbox" tabindex="-1" href="#" target="_self"><i class="fa fa-dropbox fa-fw"></i> Dropbox</a>
|
<li role="presentation"><a role="menuitem" class="ui-import-dropbox" tabindex="-1" href="#" target="_self"><i class="fa fa-dropbox fa-fw"></i> Dropbox</a>
|
||||||
</li>
|
</li>
|
||||||
<% } %>
|
|
||||||
<% if(googleDrive == "true") { %>
|
|
||||||
<li role="presentation"><a role="menuitem" class="ui-import-google-drive" tabindex="-1" href="#" target="_self"><i class="fa fa-cloud-download fa-fw"></i> Google Drive</a>
|
<li role="presentation"><a role="menuitem" class="ui-import-google-drive" tabindex="-1" href="#" target="_self"><i class="fa fa-cloud-download fa-fw"></i> Google Drive</a>
|
||||||
</li>
|
</li>
|
||||||
<% } %>
|
|
||||||
<li role="presentation"><a role="menuitem" class="ui-import-gist" href="#" data-toggle="modal" data-target="#gistImportModal"><i class="fa fa-github fa-fw"></i> Gist</a>
|
<li role="presentation"><a role="menuitem" class="ui-import-gist" href="#" data-toggle="modal" data-target="#gistImportModal"><i class="fa fa-github fa-fw"></i> Gist</a>
|
||||||
</li>
|
</li>
|
||||||
<li role="presentation"><a role="menuitem" class="ui-import-clipboard" href="#" data-toggle="modal" data-target="#clipboardModal"><i class="fa fa-clipboard fa-fw"></i> Clipboard</a>
|
<li role="presentation"><a role="menuitem" class="ui-import-clipboard" href="#" data-toggle="modal" data-target="#clipboardModal"><i class="fa fa-clipboard fa-fw"></i> Clipboard</a>
|
||||||
|
|
Loading…
Reference in a new issue