Refactor sharing links

This commit is contained in:
benweet 2014-10-12 18:57:58 +01:00
parent af05cb3a75
commit 10addd0acc
22 changed files with 185 additions and 114 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

View File

@ -7,7 +7,7 @@ define([
"text!html/buttonHtmlCodeSettingsBlock.html" "text!html/buttonHtmlCodeSettingsBlock.html"
], function($, _, utils, Extension, buttonHtmlCodeHTML, buttonHtmlCodeSettingsBlockHTML) { ], function($, _, utils, Extension, buttonHtmlCodeHTML, buttonHtmlCodeSettingsBlockHTML) {
var buttonHtmlCode = new Extension("buttonHtmlCode", 'Button "HTML code"', true, true); var buttonHtmlCode = new Extension("buttonHtmlCode", 'Button "HTML code"', true);
buttonHtmlCode.settingsBlock = buttonHtmlCodeSettingsBlockHTML; buttonHtmlCode.settingsBlock = buttonHtmlCodeSettingsBlockHTML;
buttonHtmlCode.defaultConfig = { buttonHtmlCode.defaultConfig = {
template: "<%= documentHTML %>" template: "<%= documentHTML %>"

View File

@ -7,7 +7,7 @@ define([
"text!html/buttonStatSettingsBlock.html" "text!html/buttonStatSettingsBlock.html"
], function($, _, utils, Extension, buttonStatHTML, buttonStatSettingsBlockHTML) { ], function($, _, utils, Extension, buttonStatHTML, buttonStatSettingsBlockHTML) {
var buttonStat = new Extension("buttonStat", 'Button "Statistics"', true, true); var buttonStat = new Extension("buttonStat", 'Button "Statistics"', true);
buttonStat.settingsBlock = buttonStatSettingsBlockHTML; buttonStat.settingsBlock = buttonStatSettingsBlockHTML;
buttonStat.defaultConfig = { buttonStat.defaultConfig = {
name1: "Characters", name1: "Characters",

View File

@ -18,29 +18,40 @@ define([
}; };
var fileDesc; var fileDesc;
var shareListElt; var shareEditorListElt;
var $msgShareListElt; var shareViewerListElt;
var $msgNoShareElt; var $msgNoShareEditorElt;
var $msgNoShareViewerElt;
var refreshDocumentSharing = function(fileDescParameter) { var refreshDocumentSharing = function(fileDescParameter) {
if(fileDescParameter !== undefined && fileDescParameter !== fileDesc) { if(fileDescParameter !== undefined && fileDescParameter !== fileDesc) {
return; return;
} }
var linkListHtml = _.reduce(fileDesc.publishLocations, function(result, attributes) { var editorLinkListHtml = _.reduce(fileDesc.syncLocations, function(result, attributes) {
var params = sharing.getViewerParams(attributes); var params = sharing.getEditorParams(attributes);
if(params) { if(params) {
var link = constants.MAIN_URL + 'viewer?' + $.param(params); var link = constants.MAIN_URL + 'editor#!' + $.param(params);
result += _.template(dialogManageSharingLocationHTML, { result += _.template(dialogManageSharingLocationHTML, {
link: link, link: link
title: fileDesc.title
}); });
} }
return result; return result;
}, ''); }, '');
shareListElt.innerHTML = linkListHtml; shareEditorListElt.innerHTML = editorLinkListHtml;
$msgNoShareEditorElt.toggleClass('hide', editorLinkListHtml.length !== 0);
$msgShareListElt.toggleClass('hide', linkListHtml.length === 0); var viewerLinkListHtml = _.reduce(fileDesc.publishLocations, function(result, attributes) {
$msgNoShareElt.toggleClass('hide', linkListHtml.length !== 0); var params = sharing.getViewerParams(attributes);
if(params) {
var link = constants.MAIN_URL + 'viewer#!' + $.param(params);
result += _.template(dialogManageSharingLocationHTML, {
link: link
});
}
return result;
}, '');
shareViewerListElt.innerHTML = viewerLinkListHtml;
$msgNoShareViewerElt.toggleClass('hide', viewerLinkListHtml.length !== 0);
}; };
dialogManageSharing.onFileSelected = function(fileDescParameter) { dialogManageSharing.onFileSelected = function(fileDescParameter) {
@ -48,21 +59,22 @@ define([
refreshDocumentSharing(fileDescParameter); refreshDocumentSharing(fileDescParameter);
}; };
dialogManageSharing.onNewPublishSuccess = function(fileDescParameter, publishAttributes) { dialogManageSharing.onSyncExportSuccess = refreshDocumentSharing;
refreshDocumentSharing(fileDescParameter); dialogManageSharing.onSyncRemoved = refreshDocumentSharing;
if(sharing.getViewerParams(publishAttributes)) { dialogManageSharing.onNewPublishSuccess = refreshDocumentSharing;
$('.modal').modal('hide');
$('.modal-manage-sharing').modal('show');
}
};
dialogManageSharing.onPublishRemoved = refreshDocumentSharing; dialogManageSharing.onPublishRemoved = refreshDocumentSharing;
dialogManageSharing.onReady = function() { dialogManageSharing.onReady = function() {
var modalElt = document.querySelector('.modal-manage-sharing'); var modalElt = document.querySelector('.modal-manage-sharing');
shareListElt = modalElt.querySelector('.share-list'); shareEditorListElt = modalElt.querySelector('.share-editor-list');
$msgShareListElt = $(modalElt.querySelectorAll('.msg-share-list')); shareViewerListElt = modalElt.querySelector('.share-viewer-list');
$msgNoShareElt = $(modalElt.querySelectorAll('.msg-no-share')); $msgNoShareEditorElt = $(modalElt.querySelectorAll('.msg-no-share-editor'));
$msgNoShareViewerElt = $(modalElt.querySelectorAll('.msg-no-share-viewer'));
$(modalElt).on('show.bs.modal', function() {
$(modalElt.querySelector('input')).each(function() {
this.value = $(this).data('value');
});
});
}; };
return dialogManageSharing; return dialogManageSharing;

View File

@ -33,6 +33,9 @@ define([
var eventMgr; var eventMgr;
userCustom.onEventMgrCreated = function(eventMgrParameter) { userCustom.onEventMgrCreated = function(eventMgrParameter) {
eventMgr = eventMgrParameter; eventMgr = eventMgrParameter;
eventMgr.addListener('onReady', function() {
utils.createTooltip(".tooltip-usercustom-extension", tooltipUserCustomExtensionHTML);
});
}; };
userCustom.onLoadSettings = function() { userCustom.onLoadSettings = function() {
@ -62,9 +65,5 @@ define([
} }
}; };
userCustom.onReady = function() {
utils.createTooltip(".tooltip-usercustom-extension", tooltipUserCustomExtensionHTML);
};
return userCustom; return userCustom;
}); });

View File

@ -49,6 +49,14 @@ define([
this.getUserId = function() { this.getUserId = function() {
return userId; return userId;
}; };
var authUser = parseInt(storage[accountId + '.authUser'] || 0);
this.setAuthUser = function(value) {
authUser = value;
storage[accountId + '.authUser'] = authUser;
};
this.getAuthUser = function() {
return authUser;
};
} }
var googleHelper = {}; var googleHelper = {};
@ -190,7 +198,7 @@ define([
} }
else { else {
// Success but we need to check the user id // Success but we need to check the user id
authorizationMgr.authuser = authuser; authorizationMgr.setAuthUser(authuser);
immediate === true && authuser++; immediate === true && authuser++;
task.chain(getTokenInfo); task.chain(getTokenInfo);
} }

View File

@ -382,7 +382,7 @@
Are you sure you want to delete "<span class="file-title"></span>"? Are you sure you want to delete "<span class="file-title"></span>"?
</p> </p>
<blockquote> <blockquote>
<b>Note:</b> It won't delete the file on synchronized locations. <p><b>Note:</b> It won't delete the file on synchronized locations.</p>
</blockquote> </blockquote>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
@ -656,10 +656,10 @@
This will save "<span class="file-title"></span>" to CouchDB and keep it synchronized. This will save "<span class="file-title"></span>" to CouchDB and keep it synchronized.
</p> </p>
<blockquote> <blockquote>
<b>Tip:</b> You can use a <p><b>Tip:</b> You can use a
<a href="http://jekyllrb.com/docs/frontmatter/" <a href="http://jekyllrb.com/docs/frontmatter/"
target="_blank">YAML front matter</a> to specify tags for your document. target="_blank">YAML front matter</a> to specify tags for your document.</p>
Alternatively, you can place comma separated tags in squared brackets at the beginning of the document title. <p>Alternatively, you can place comma separated tags in squared brackets at the beginning of the document title.</p>
</blockquote> </blockquote>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
@ -688,8 +688,8 @@
</p> </p>
<div class="sync-list"></div> <div class="sync-list"></div>
<blockquote> <blockquote>
<b>Note:</b> Removing a synchronized location will not delete any <p><b>Note:</b> Removing a synchronized location will not delete any
file. file.</p>
</blockquote> </blockquote>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
@ -962,7 +962,7 @@
</p> </p>
<div class="publish-list"></div> <div class="publish-list"></div>
<blockquote> <blockquote>
<b>Note:</b> Removing a publish location will not delete the actual publication. <p><b>Note:</b> Removing a publish location will not delete the actual publication.</p>
</blockquote> </blockquote>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
@ -983,23 +983,28 @@
<h2 class="modal-title">Sharing</h2> <h2 class="modal-title">Sharing</h2>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p class="msg-share-list hide"> <p>Collaborate on "<span class="file-title"></span>" using the following link(s):</p>
"<span class="file-title"></span>" can be shared using the following link(s): <p class="msg-no-share-editor"><b>No sharing link yet!</b>
</p>
<div class="msg-share-list share-list hide"></div>
<p class="msg-no-share hide alert alert-danger"><b>No sharing link yet!</b>
</p>
<p class="msg-no-share hide">To collaborate on this document, use <i class="icon-provider-gdrive"></i> <b>Google Drive</b>
or <i class="icon-provider-dropbox"></i> <b>Dropbox</b> synchronization from the <i class="icon-provider-stackedit"></i> menu.
</p>
<p class="msg-no-share hide">To share a frozen version of this document within StackEdit, just <a
href="#" class="action-publish-gist" data-dismiss="modal">publish it as a Gist</a> in
Markdown format from the <i class="icon-provider-stackedit"></i> menu.
</p> </p>
<div class="share-editor-list"></div>
<blockquote> <blockquote>
<b>Tip:</b> You can open any URL within StackEdit using <a <p><b>Note:</b> To collaborate on this document, just <a
href="#" class="action-sync-export-dialog-couchdb" data-dismiss="modal">save it on CouchDB</a>.
To collaborate via Google Drive or Dropbox, you have to share the file manually from Google Drive/Dropbox websites.</p>
</blockquote>
<p>Share a read-only version of "<span class="file-title"></span>" using the following link(s):</p>
<p class="msg-no-share-viewer"><b>No sharing link yet!</b>
</p>
<div class="share-viewer-list"></div>
<blockquote>
<p><b>Note:</b> To share a read-only version of this document, just <a
href="#" class="action-publish-gist" data-dismiss="modal">publish it as a Gist</a> in
Markdown format.</p>
</blockquote>
<blockquote>
<p><b>Tip:</b> You can open any markdown URL within StackEdit Viewer using <a
href="viewer#!url=https://raw.github.com/benweet/stackedit/master/README.md" href="viewer#!url=https://raw.github.com/benweet/stackedit/master/README.md"
title="Sharing example"><code>viewer#!url=</code></a>. title="Sharing example"><code>viewer#!url=</code></a>.</p>
</blockquote> </blockquote>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
@ -1334,8 +1339,10 @@
<div class="modal-body"> <div class="modal-body">
<p>StackEdit has stopped because another instance was running in <p>StackEdit has stopped because another instance was running in
the same browser.</p> the same browser.</p>
<blockquote>If you want to reopen StackEdit, click on <blockquote>
"Reload".</blockquote> <p>If you want to reopen StackEdit, click on
"Reload".</p>
</blockquote>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<a href="javascript:window.location.reload();" <a href="javascript:window.location.reload();"
@ -1355,7 +1362,9 @@
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p class="redirect-msg"></p> <p class="redirect-msg"></p>
<blockquote>Please click <b>OK</b> to proceed.</blockquote> <blockquote>
<p>Please click <b>OK</b> to proceed.</p>
</blockquote>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<a class="btn btn-default" data-dismiss="modal">Cancel</a> <a class="btn btn-default" data-dismiss="modal">Cancel</a>
@ -1417,7 +1426,7 @@
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p>To perform this request, you need to configure another Google Drive account in StackEdit.</p> <p>To perform this request, you need to configure another Google Drive account in StackEdit.</p>
<blockquote>Do you want to proceed?</blockquote> <blockquote><b>Do you want to proceed?</b></blockquote>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<a href="#" class="btn btn-default action-remove-google-drive-state" <a href="#" class="btn btn-default action-remove-google-drive-state"
@ -1441,7 +1450,9 @@
<p>This feature is restricted to sponsor users as it's a web service hosted on Amazon EC2. <p>This feature is restricted to sponsor users as it's a web service hosted on Amazon EC2.
Note that sponsoring StackEdit would cost you only $5/year.</p> Note that sponsoring StackEdit would cost you only $5/year.</p>
<p>To see how a PDF looks <a target="_blank" href="/Welcome%20document.pdf">click here</a>.</p> <p>To see how a PDF looks <a target="_blank" href="/Welcome%20document.pdf">click here</a>.</p>
<blockquote><b>Tip:</b> PDFs are fully customizable via Settings>Advanced>PDF template/options.</blockquote> <blockquote>
<p><b>Tip:</b> PDFs are fully customizable via Settings>Advanced>PDF template/options.</p>
</blockquote>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<a href="#" class="btn btn-primary" <a href="#" class="btn btn-primary"

View File

@ -97,8 +97,10 @@
<div class="modal-body"> <div class="modal-body">
<p>StackEdit has stopped because another instance was running in <p>StackEdit has stopped because another instance was running in
the same browser.</p> the same browser.</p>
<blockquote>If you want to reopen StackEdit, click on <blockquote>
"Reload".</blockquote> <p>If you want to reopen StackEdit, click on
"Reload".</p>
</blockquote>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<a href="javascript:window.location.reload();" <a href="javascript:window.location.reload();"

View File

@ -58,8 +58,8 @@
</div> </div>
</div> </div>
<blockquote> <blockquote>
<b>Note:</b> Removing a local document will not delete the linked file on Google <p><b>Note:</b> Removing a local document will not delete the linked file on Google
Drive. Drive.</p>
</blockquote> </blockquote>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">

View File

@ -48,8 +48,8 @@
</a> </a>
</p> </p>
<blockquote> <blockquote>
<b>Tip:</b> You can move or rename the file afterwards within Google <p><b>Tip:</b> You can move or rename the file afterwards within Google
Drive. Drive.</p>
</blockquote> </blockquote>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">

View File

@ -1,5 +1,7 @@
<div class="input-group"> <div class="entry">
<a href="<%= link %>" class="input-group-addon" title="Sharing location"><i <div class="input-group">
class="icon-link"></i></a> <input class="form-control" type="text" <a href="<%= link %>" class="input-group-addon" title="Sharing location"><i
value="<%= link %>" disabled /> class="icon-link"></i></a> <input class="form-control" type="text"
data-value="<%= link %>">
</div>
</div> </div>

View File

@ -1,5 +1,5 @@
<p>Renders modified sections only.</p> <p>Renders modified sections only.</p>
<blockquote> <blockquote>
<b>Note:</b> Document sections are based on title elements (h1, h2...). Therefore if <p><b>Note:</b> Document sections are based on title elements (h1, h2...). Therefore if
your document does not contain any title, performance will not be increased. your document does not contain any title, performance will not be increased.</p>
</blockquote> </blockquote>

View File

@ -1,7 +1,7 @@
<p>Binds together editor and preview scrollbars.</p> <p>Binds together editor and preview scrollbars.</p>
<blockquote> <blockquote>
<b>Note:</b> The mapping between Markdown and HTML is based on the <p><b>Note:</b> The mapping between Markdown and HTML is based on the
position of the title elements (h1, h2...) in the page. Therefore if position of the title elements (h1, h2...) in the page. Therefore if
your document does not contain any title, the mapping will be linear and your document does not contain any title, the mapping will be linear and
consequently less accurate. consequently less accurate.</p>
</blockquote> </blockquote>

View File

@ -19,6 +19,6 @@ cond(no)->op
```</code> ```</code>
</pre> </pre>
<blockquote> <blockquote>
<b>Note:</b> Markdown Extra extension has to be enabled with GFM fenced code blocks option. <p><b>Note:</b> Markdown Extra extension has to be enabled with GFM fenced code blocks option.</p>
</blockquote> </blockquote>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -22,6 +22,9 @@ define([
couchdbProvider.importPreferencesInputIds = [ couchdbProvider.importPreferencesInputIds = [
PROVIDER_COUCHDB + "-tag" PROVIDER_COUCHDB + "-tag"
]; ];
couchdbProvider.editorSharingAttributes = [
"id"
];
couchdbProvider.getSyncLocationLink = function(attributes) { couchdbProvider.getSyncLocationLink = function(attributes) {
return [ return [
@ -57,14 +60,26 @@ define([
return syncAttributes; return syncAttributes;
} }
function importFilesFromIds(ids) { function importFilesFromIds(ids, cb) {
couchdbHelper.downloadContent(ids.map(function(id) { var importIds = [];
_.each(ids, function(id) {
var syncIndex = createSyncIndex(id);
var fileDesc = fileMgr.getFileFromSyncIndex(syncIndex);
if(fileDesc !== undefined) {
return eventMgr.onError('"' + fileDesc.title + '" is already in your local documents.');
}
importIds.push(id);
});
if(ids.length === 0) {
return cb && cb();
}
couchdbHelper.downloadContent(importIds.map(function(id) {
return { return {
_id: id _id: id
}; };
}), function(error, result) { }), function(error, result) {
if(error) { if(error) {
return; return cb && cb(error);
} }
var fileDescList = []; var fileDescList = [];
var fileDesc; var fileDesc;
@ -82,6 +97,7 @@ define([
eventMgr.onSyncImportSuccess(fileDescList, couchdbProvider); eventMgr.onSyncImportSuccess(fileDescList, couchdbProvider);
fileMgr.selectFile(fileDesc); fileMgr.selectFile(fileDesc);
} }
cb && cb();
}); });
} }
@ -93,16 +109,7 @@ define([
.compact() .compact()
.unique() .unique()
.value(); .value();
var importIds = []; importFilesFromIds(ids);
_.each(ids, function(id) {
var syncIndex = createSyncIndex(id);
var fileDesc = fileMgr.getFileFromSyncIndex(syncIndex);
if(fileDesc !== undefined) {
return eventMgr.onError('"' + fileDesc.title + '" is already in your local documents.');
}
importIds.push(id);
});
importFilesFromIds(importIds);
} }
}; };
@ -228,6 +235,10 @@ define([
}); });
}; };
couchdbProvider.importPrivate = function(importParameters, callback) {
importFilesFromIds([importParameters.id], callback);
};
eventMgr.addListener("onReady", function() { eventMgr.addListener("onReady", function() {
if(constants.COUCHDB_URL == settings.couchdbUrl) { if(constants.COUCHDB_URL == settings.couchdbUrl) {
$('.msg-default-couchdb').removeClass('hide'); $('.msg-default-couchdb').removeClass('hide');

View File

@ -25,7 +25,7 @@ define([
]; ];
gdriveProvider.getSyncLocationLink = gdriveProvider.getPublishLocationLink = function(attributes) { gdriveProvider.getSyncLocationLink = gdriveProvider.getPublishLocationLink = function(attributes) {
var authuser = googleHelper.getAuthorizationMgr(accountId).authuser; var authuser = googleHelper.getAuthorizationMgr(accountId).getAuthUser();
return [ return [
'https://docs.google.com/file/d/', 'https://docs.google.com/file/d/',
attributes.id, attributes.id,
@ -59,14 +59,14 @@ define([
return syncAttributes; return syncAttributes;
} }
function importFilesFromIds(ids) { function importFilesFromIds(ids, cb) {
googleHelper.downloadMetadata(ids, accountId, function(error, result) { googleHelper.downloadMetadata(ids, accountId, function(error, result) {
if(error) { if(error) {
return; return cb && cb(error);
} }
googleHelper.downloadContent(result, accountId, function(error, result) { googleHelper.downloadContent(result, accountId, function(error, result) {
if(error) { if(error) {
return; return cb && cb(error);
} }
var fileDescList = []; var fileDescList = [];
var fileDesc; var fileDesc;
@ -88,6 +88,7 @@ define([
eventMgr.onSyncImportSuccess(fileDescList, gdriveProvider); eventMgr.onSyncImportSuccess(fileDescList, gdriveProvider);
fileMgr.selectFile(fileDesc); fileMgr.selectFile(fileDesc);
} }
cb && cb();
}); });
}); });
} }
@ -369,8 +370,7 @@ define([
storage.removeItem('gdrive.state'); storage.removeItem('gdrive.state');
if(state.action == "create") { if(state.action == "create") {
eventMgr.onMessage('Please wait while creating your document on ' + providerName); googleHelper.upload(undefined, state.folderId, constants.GDRIVE_DEFAULT_FILE_TITLE, settings.defaultContent, undefined, undefined, accountId, utils.lockUI(function(error, file) {
googleHelper.upload(undefined, state.folderId, constants.GDRIVE_DEFAULT_FILE_TITLE, settings.defaultContent, undefined, undefined, accountId, function(error, file) {
if(error) { if(error) {
return; return;
} }
@ -380,7 +380,7 @@ define([
var fileDesc = fileMgr.createFile(file.title, file.content, undefined, syncLocations); var fileDesc = fileMgr.createFile(file.title, file.content, undefined, syncLocations);
fileMgr.selectFile(fileDesc); fileMgr.selectFile(fileDesc);
eventMgr.onMessage('"' + file.title + '" created successfully on ' + providerName + '.'); eventMgr.onMessage('"' + file.title + '" created successfully on ' + providerName + '.');
}); }));
} }
else if(state.action == "open") { else if(state.action == "open") {
var importIds = []; var importIds = [];
@ -394,8 +394,7 @@ define([
importIds.push(id); importIds.push(id);
} }
}); });
eventMgr.onMessage('Please wait while loading your document from ' + providerName); importFilesFromIds(importIds, utils.lockUI());
importFilesFromIds(importIds);
} }
}); });

View File

@ -7,6 +7,7 @@ define([
"fileMgr", "fileMgr",
"classes/AsyncTask", "classes/AsyncTask",
"classes/Provider", "classes/Provider",
"providers/couchdbProvider",
"providers/downloadProvider", "providers/downloadProvider",
"providers/gistProvider" "providers/gistProvider"
], function($, _, constants, utils, eventMgr, fileMgr, AsyncTask, Provider) { ], function($, _, constants, utils, eventMgr, fileMgr, AsyncTask, Provider) {
@ -61,36 +62,49 @@ define([
eventMgr.addListener("onReady", function() { eventMgr.addListener("onReady", function() {
// Check parameters to see if we have to download a shared document // Check parameters to see if we have to download a shared document
var providerId = utils.getURLParameter("provider"); var importParameters, provider, providerId = utils.getURLParameter("provider");
if(window.viewerMode) { if(window.viewerMode) {
if(providerId === undefined) { if(providerId === undefined) {
providerId = "download"; providerId = "download";
} }
var provider = providerMap[providerId]; provider = providerMap[providerId];
if(provider === undefined) { if(provider === undefined) {
return; return;
} }
var importParameters = {}; importParameters = {};
_.each(provider.viewerSharingAttributes, function(attributeName) { if(_.some(provider.viewerSharingAttributes, function(attributeName) {
var parameter = utils.getURLParameter(attributeName); var parameter = utils.getURLParameter(attributeName);
if(!parameter) { if(!parameter) {
importParameters = undefined; return 1;
return;
} }
importParameters[attributeName] = parameter; importParameters[attributeName] = parameter;
}); })) {
if(importParameters === undefined) {
return; return;
} }
$("#preview-contents, .navbar .file-title-navbar").hide(); provider.importPublic(importParameters, utils.lockUI(function(error, title, content) {
provider.importPublic(importParameters, function(error, title, content) {
$("#preview-contents, .navbar .file-title-navbar").show();
if(error) { if(error) {
return; return;
} }
var fileDesc = fileMgr.createFile(title, content, undefined, undefined, true); var fileDesc = fileMgr.createFile(title, content, undefined, undefined, true);
fileMgr.selectFile(fileDesc); fileMgr.selectFile(fileDesc);
}); }));
}
else if(providerId) {
provider = providerMap[providerId];
if(provider === undefined) {
return;
}
importParameters = {};
if(_.some(provider.editorSharingAttributes, function(attributeName) {
var parameter = utils.getURLParameter(attributeName);
if(!parameter) {
return 1;
}
importParameters[attributeName] = parameter;
})) {
return;
}
provider.importPrivate(importParameters, utils.lockUI());
} }
}); });

View File

@ -1014,17 +1014,14 @@ a {
.modal-manage-sync .sync-list, .modal-manage-sync .sync-list,
.modal-manage-publish .publish-list, .modal-manage-publish .publish-list,
.modal-manage-sharing .share-list { .modal-manage-sharing .share-editor-list,
.modal-manage-sharing .share-viewer-list {
margin-bottom: 20px; margin-bottom: 20px;
.entry { .entry {
margin-bottom: 10px; margin-bottom: 10px;
} }
} }
.share-list .form-control {
width: 280px
}
.publish-custom-template-collapse { .publish-custom-template-collapse {
margin-bottom: 0; margin-bottom: 0;
textarea { textarea {

View File

@ -418,6 +418,21 @@ define([
}); });
}; };
utils.lockUI = function(cb) {
var eltsToHide = $([
'#wmd-input',
'#preview-contents',
'.navbar .file-title-navbar',
'.navbar .left-buttons',
'.navbar .right-buttons',
'.navbar .buttons-dropdown'
].join(',')).hide();
return function() {
eltsToHide.show();
cb && cb.apply(null, arguments);
};
};
var entityMap = { var entityMap = {
"&": "&amp;", "&": "&amp;",
"<": "&lt;", "<": "&lt;",

View File

@ -5,16 +5,17 @@
<title>StackEdit Editor</title> <title>StackEdit Editor</title>
<link rel="canonical" href="https://stackedit.io/editor"> <link rel="canonical" href="https://stackedit.io/editor">
<link rel="icon" href="res-min/img/stackedit-32.ico" type="image/x-icon"> <link rel="icon" href="res-min/img/stackedit-32.ico" type="image/x-icon">
<link rel="icon" sizes="192x192" href="res-min/img/logo-highres.png">
<link rel="shortcut icon" href="res-min/img/stackedit-32.ico" type="image/x-icon"> <link rel="shortcut icon" href="res-min/img/stackedit-32.ico" type="image/x-icon">
<link rel="shortcut icon" sizes="196x196" href="res-min/img/nice-highres.png"> <link rel="shortcut icon" sizes="192x192" href="res-min/img/logo-highres.png">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="res-min/img/logo-ipad-retina.png">
<meta name="description" content="Full-featured, open-source Markdown editor based on PageDown, the Markdown library used by Stack Overflow and the other Stack Exchange sites."> <meta name="description" content="Full-featured, open-source Markdown editor based on PageDown, the Markdown library used by Stack Overflow and the other Stack Exchange sites.">
<meta name="author" content="Benoit Schweblin"> <meta name="author" content="Benoit Schweblin">
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"> <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">
<meta name="mobile-web-app-capable" content="yes"> <meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="msvalidate.01" content="5E47EE6F67B069C17E3CDD418351A612"> <meta name="msvalidate.01" content="5E47EE6F67B069C17E3CDD418351A612">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="/res-min/img/logo-ipad-retina.png"/>
<script> <script>
// Use ?debug to serve original JavaScript files instead of minified // Use ?debug to serve original JavaScript files instead of minified
window.baseDir = 'res'; window.baseDir = 'res';