remove sharing

This commit is contained in:
Mo Bitar
2017-01-14 12:33:28 -06:00
parent 66298b8799
commit 36ada08a33
17 changed files with 37 additions and 372 deletions

View File

@@ -87,7 +87,6 @@ module.exports = function(grunt) {
'vendor/assets/bower_components/lodash/dist/lodash.min.js',
'vendor/assets/bower_components/restangular/dist/restangular.js',
'vendor/assets/bower_components/marked/lib/marked.js',
'vendor/assets/bower_components/ng-dialog/js/ngDialog.min.js',
'vendor/assets/javascripts/crypto/*.js'
],
dest: 'vendor/assets/javascripts/lib.js',
@@ -100,9 +99,7 @@ module.exports = function(grunt) {
css: {
src: [
'vendor/assets/stylesheets/app.css',
'vendor/assets/bower_components/ng-dialog/css/ngDialog.css',
'vendor/assets/bower_components/ng-dialog/css/ngDialog-theme-default.css',
'vendor/assets/stylesheets/app.css'
],
dest: 'vendor/assets/stylesheets/app.css'
}

View File

@@ -10,8 +10,7 @@ if(window.crypto.subtle) {
angular.module('app.frontend', [
'ui.router',
'restangular',
'ngDialog'
'restangular'
])
.config(function (RestangularProvider, apiControllerProvider) {

View File

@@ -1,6 +1,5 @@
class BaseCtrl {
constructor($rootScope, modelManager, apiController, dbManager) {
apiController.getCurrentUser(function(){});
dbManager.openDatabase(null, function(){
// new database, delete syncToken so that items can be refetched entirely from server
apiController.clearSyncToken();

View File

@@ -171,7 +171,6 @@ angular.module('app.frontend')
this.onContentFocus = function() {
this.showSampler = false;
$rootScope.$broadcast("editorFocused");
this.editingUrl = false;
}
this.onNameBlur = function() {
@@ -202,64 +201,8 @@ angular.module('app.frontend')
}
}
this.editUrlPressed = function() {
this.showMenu = false;
var url = this.publicUrlForNote(this.note);
url = url.replace(this.note.presentation_name, "");
this.url = {base: url, token : this.note.presentation_name};
this.editingUrl = true;
}
this.saveUrl = function($event) {
$event.target.blur();
var original = this.note.presentation_name;
this.note.presentation_name = this.url.token;
this.note.setDirty(true);
apiController.sync(function(response){
if(response && response.error) {
this.note.presentation_name = original;
this.url.token = original;
alert("This URL is not available.");
} else {
this.editingUrl = false;
}
}.bind(this))
}
this.shareNote = function() {
function openInNewTab(url) {
var a = document.createElement("a");
a.target = "_blank";
a.href = url;
a.click();
}
apiController.shareItem(this.note, function(note){
openInNewTab(this.publicUrlForNote(note));
}.bind(this))
this.showMenu = false;
}
this.unshareNote = function() {
apiController.unshareItem(this.note, function(note){
})
this.showMenu = false;
}
this.publicUrlForNote = function() {
return this.note.presentationURL();
}
this.clickedMenu = function() {
if(this.note.locked) {
alert("This note has been shared without an account, and can therefore not be changed.")
} else {
this.showMenu = !this.showMenu;
}
this.showMenu = !this.showMenu;
}
this.deleteNote = function() {

View File

@@ -67,29 +67,6 @@ angular.module('app.frontend')
this.removeTag()(this.tag);
}
this.selectedTagShare = function() {
this.showMenu = false;
if(!apiController.isUserSignedIn()) {
alert("You must be signed in to share a tag.");
return;
}
if(this.tag.all) {
alert("You cannot share the 'All' tag.");
return;
}
apiController.shareItem(this.tag, function(response){})
}
this.selectedTagUnshare = function() {
this.showMenu = false;
apiController.unshareItem(this.tag, function(response){
})
}
this.selectFirstNote = function(createNew) {
var visibleNotes = this.tag.notes.filter(function(note){
return note.visible;

View File

@@ -1,12 +0,0 @@
angular.module('app.frontend')
.controller('UsernameModalCtrl', function ($scope, apiController, Restangular, callback, $timeout) {
$scope.formData = {};
$scope.saveUsername = function() {
apiController.setUsername($scope.formData.username, function(response){
var username = response.username;
callback(username);
$scope.closeThisDialog();
})
}
});

View File

@@ -115,15 +115,6 @@ class Item {
return [];
}
referencesAffectedBySharingChange() {
// should be overriden to determine which references should be decrypted/encrypted
return [];
}
isPublic() {
return this.presentation_name;
}
isEncrypted() {
return this.encryptionEnabled() && this.content.substring(0, 3) === '001' ? true : false;
}
@@ -131,9 +122,4 @@ class Item {
encryptionEnabled() {
return this.enc_item_key;
}
presentationURL() {
return this.presentation_url;
}
}

View File

@@ -65,19 +65,6 @@ class Note extends Item {
return this.tags;
}
referencesAffectedBySharingChange() {
return super.referencesAffectedBySharingChange();
}
get hasOnePublicTag() {
for (var tag of this.tags) {
if(tag.isPublic()) {
return true
}
}
return false;
}
safeText() {
return this.text || "";
}
@@ -90,14 +77,6 @@ class Note extends Item {
return {uuid: this.uuid}
}
isSharedIndividually() {
return this.presentation_name;
}
isPublic() {
return super.isPublic() || this.hasOnePublicTag;
}
get content_type() {
return "Note";
}

View File

@@ -62,8 +62,4 @@ class Tag extends Item {
allReferencedObjects() {
return this.notes;
}
referencesAffectedBySharingChange() {
return this.notes;
}
}

View File

@@ -20,13 +20,22 @@ angular.module('app.frontend')
}
this.$get = function($rootScope, Restangular, modelManager, ngDialog, dbManager) {
return new ApiController($rootScope, Restangular, modelManager, ngDialog, dbManager);
this.$get = function($rootScope, Restangular, modelManager, dbManager) {
return new ApiController($rootScope, Restangular, modelManager, dbManager);
}
function ApiController($rootScope, Restangular, modelManager, ngDialog, dbManager) {
function ApiController($rootScope, Restangular, modelManager, dbManager) {
this.user = {};
var userData = localStorage.getItem("user");
if(userData) {
this.user = JSON.parse(userData);
} else {
// legacy, check for uuid
var idData = localStorage.getItem("uuid");
if(idData) {
this.user = {uuid: idData};
}
}
this.syncToken = localStorage.getItem("syncToken");
/*
@@ -64,10 +73,6 @@ angular.module('app.frontend')
return localStorage.getItem("jwt");
}
this.userId = function() {
return localStorage.getItem("uuid");
}
this.getAuthParamsForEmail = function(email, callback) {
var request = Restangular.one("auth", "params");
request.get({email: email}).then(function(response){
@@ -79,22 +84,6 @@ angular.module('app.frontend')
})
}
this.getCurrentUser = function(callback) {
if(!localStorage.getItem("jwt")) {
callback(null);
return;
}
Restangular.one("users/current").get().then(function(response){
var user = response.plain();
_.merge(this.user, user);
callback();
}.bind(this))
.catch(function(response){
console.log("Error getting current user", response);
callback(response.data);
})
}
this.login = function(email, password, callback) {
this.getAuthParamsForEmail(email, function(authParams){
if(!authParams) {
@@ -108,7 +97,7 @@ angular.module('app.frontend')
_.merge(request, params);
request.post().then(function(response){
localStorage.setItem("jwt", response.token);
localStorage.setItem("uuid", response.user.uuid);
localStorage.setItem("user", JSON.stringify(response.user));
localStorage.setItem("auth_params", JSON.stringify(authParams));
callback(response);
})
@@ -128,7 +117,7 @@ angular.module('app.frontend')
_.merge(request, params);
request.post().then(function(response){
localStorage.setItem("jwt", response.token);
localStorage.setItem("uuid", response.user.uuid);
localStorage.setItem("user", JSON.stringify(response.user));
localStorage.setItem("auth_params", JSON.stringify(_.omit(authParams, ["pw_nonce"])));
callback(response);
})
@@ -189,20 +178,6 @@ angular.module('app.frontend')
}
/*
User
*/
this.setUsername = function(username, callback) {
var request = Restangular.one("users", this.userId());
request.username = username;
request.patch().then(function(response){
this.user.username = response.username;
callback(response.plain());
}.bind(this))
}
/*
Items
*/
@@ -329,7 +304,7 @@ angular.module('app.frontend')
}
this.createRequestParamsForItem = function(item, additionalFields) {
return this.paramsForItem(item, !item.isPublic(), additionalFields, false);
return this.paramsForItem(item, true, additionalFields, false);
}
this.paramsForExportFile = function(item, encrypted) {
@@ -345,8 +320,7 @@ angular.module('app.frontend')
console.assert(!item.dummy, "Item is dummy, should not have gotten here.", item.dummy)
var params = {uuid: item.uuid, content_type: item.content_type,
presentation_name: item.presentation_name, deleted: item.deleted};
var params = {uuid: item.uuid, content_type: item.content_type, deleted: item.deleted};
if(encrypted) {
this.encryptSingleItem(itemCopy, this.retrieveMk());
@@ -369,47 +343,6 @@ angular.module('app.frontend')
return params;
}
this.shareItem = function(item, callback) {
if(!this.isUserSignedIn()) {
alert("You must be signed in to share.");
return;
}
var shareFn = function() {
item.presentation_name = "_auto_";
var needsUpdate = [item].concat(item.referencesAffectedBySharingChange() || []);
needsUpdate.forEach(function(needingUpdate){
needingUpdate.setDirty(true);
})
this.sync();
}.bind(this)
if(!this.user.username) {
ngDialog.open({
template: 'frontend/modals/username.html',
controller: 'UsernameModalCtrl',
resolve: {
callback: function() {
return shareFn;
}
},
className: 'ngdialog-theme-default',
disableAnimation: true
});
} else {
shareFn();
}
}
this.unshareItem = function(item, callback) {
item.presentation_name = null;
var needsUpdate = [item].concat(item.referencesAffectedBySharingChange() || []);
needsUpdate.forEach(function(needingUpdate){
needingUpdate.setDirty(true);
})
this.sync(null);
}
/*
Import
*/
@@ -491,36 +424,13 @@ angular.module('app.frontend')
return makeTextFile(JSON.stringify(data, null, 2 /* pretty print */));
}
/*
Merging
*/
// this.mergeLocalDataRemotely = function(user, callback) {
// var request = Restangular.one("users", this.userId()).one("merge");
// var tags = user.tags;
// request.items = user.items;
// request.items.forEach(function(item){
// if(item.tag_id) {
// var tag = tags.filter(function(tag){return tag.uuid == item.tag_id})[0];
// item.tag_name = tag.title;
// }
// })
// request.post().then(function(response){
// callback();
// localStorage.removeItem('user');
// })
// }
this.staticifyObject = function(object) {
return JSON.parse(JSON.stringify(object));
}
this.writeItemsToLocalStorage = function(items, callback) {
var params = items.map(function(item) {
return this.paramsForItem(item, false, ["created_at", "updated_at", "presentation_url", "dirty"], true)
return this.paramsForItem(item, false, ["created_at", "updated_at", "dirty"], true)
}.bind(this));
dbManager.saveItems(params, callback);

View File

@@ -114,72 +114,3 @@
}
}
}
.menu-right-container {
float: right;
margin-top: -2px;
color: white;
white-space: nowrap;
width: 70%;
overflow: hidden;
display: inline-block;
a {
color: black;
}
.public-link {
font-weight: bold;
font-size: 12px;
height: 20px;
text-align: right;
text-overflow: ellipsis;
overflow: hidden;
color: black;
.url {
text-align: right;
.icon {
margin-right: 4px;
}
a {
color: white;
text-decoration: none;
overflow: hidden;
white-space: nowrap;
width: 90%;
text-overflow: ellipsis;
&:hover {
text-decoration: underline;;
}
}
}
.edit-url {
// float: left;
border: none;
outline: none;
margin-top: -3px;
}
}
> .icon {
float: left;
position: relative;
}
.info-panel {
min-width: 255px;
text-align: left;
font-size: 14px;
margin-right: 18px;
margin-bottom: 18px;
font-weight: normal;
}
}

View File

@@ -1,10 +1,9 @@
.section.editor{"ng-class" => "{'fullscreen' : ctrl.fullscreen}"}
.content
-# %span.fullscreen-ghost-bar{"ng-if" => "ctrl.fullscreen"}
.section-title-bar.editor-heading{"ng-class" => "{'shared' : ctrl.note.isPublic(), 'fullscreen' : ctrl.fullscreen }"}
.section-title-bar.editor-heading{"ng-class" => "{'fullscreen' : ctrl.fullscreen }"}
.title
%input.input#note-title-editor{"ng-model" => "ctrl.note.title", "ng-keyup" => "$event.keyCode == 13 && ctrl.saveTitle($event)",
"ng-disabled" => "ctrl.note.locked", "ng-change" => "ctrl.nameChanged()", "ng-focus" => "ctrl.onNameFocus()",
"ng-change" => "ctrl.nameChanged()", "ng-focus" => "ctrl.onNameFocus()",
"select-on-click" => "true"}
.save-status {{ctrl.noteStatus}}
.section-menu
@@ -12,24 +11,16 @@
%li.dropdown
%a.dropdown-toggle{"ng-click" => "ctrl.clickedMenu(); ctrl.showExtensions = false"}
File
%span.caret{"ng-if" => "!ctrl.note.locked"}
%span{"ng-if" => " ctrl.note.locked"}
.inline-icon.icon-lock
%span.caret
%span.sr-only
%ul.dropdown-menu.dropdown-menu-left.nt-dropdown-menu.dark{"ng-if" => "ctrl.showMenu && !ctrl.note.locked"}
%ul.dropdown-menu.dropdown-menu-left.nt-dropdown-menu.dark{"ng-if" => "ctrl.showMenu"}
%li{"ng-click" => "ctrl.selectedMenuItem(); ctrl.toggleFullScreen()"}
.text Toggle Fullscreen
.shortcut Cmd + O
%li{"ng-click" => "ctrl.selectedMenuItem(); ctrl.toggleMarkdown()"}
.text Toggle Markdown Preview
.shortcut Cmd + M
%li{"ng-if" => "!ctrl.note.isSharedIndividually()", "ng-click" => "ctrl.selectedMenuItem(); ctrl.shareNote()"}
.text Share
%li{"ng-if" => "ctrl.note.isSharedIndividually()", "ng-click" => "ctrl.selectedMenuItem(); ctrl.editUrlPressed()"}
.text Edit URL
%li{"ng-if" => "ctrl.note.isSharedIndividually()", "ng-click" => "ctrl.selectedMenuItem(); ctrl.unshareNote()"}
.text Unshare
%li{"ng-click" => "ctrl.deleteNote()"}
.text Delete
%li.sep
@@ -45,21 +36,8 @@
.panel.panel-default.info-panel{"ng-if" => "ctrl.showMarkdown"}
.panel-body{"style" => "text-align: center; color: black;"}
This editor is Markdown enabled.
.menu-right-container
.public-link{"ng-if" => "ctrl.note.isPublic()"}
%a.url{"ng-if" => "!ctrl.editingUrl", "href" => "{{ctrl.publicUrlForNote(ctrl.note)}}", "target" => "_blank"}
%span.icon-rss.icon
%span{"ng-if" => "ctrl.note.isSharedIndividually()"}{{ctrl.publicUrlForNote(note)}}
.edit-url{"ng-if" => "ctrl.editingUrl"}
{{ctrl.url.base}}
%input.input{"ng-model" => "ctrl.url.token", "ng-keyup" => "$event.keyCode == 13 && ctrl.saveUrl($event)",
"ng-disabled" => "ctrl.note.locked", "ng-change" => "ctrl.urlChanged()", "ng-focus" => "ctrl.onUrlFocus()",
"select-on-click" => "true", "autofocus" => "true"}
.editor-content{"ng-class" => "{'shared' : ctrl.note.isPublic(), 'fullscreen' : ctrl.fullscreen }"}
.sampler-container{"ng-if" => "ctrl.showSampler", "ng-click" => "ctrl.focusEditor()"}
%strong.name-sampler.sampler{"typewrite" => "true", "text" => "ctrl.demoNoteNames", "type-delay" => "30", "initial-delay" => "1.5s",
"iteration-callback" => "ctrl.callback", "prebegin-fn" => "ctrl.prebeginFn", "iteration-delay" => "2000", "cursor" => ""}
%textarea.editable#note-text-editor{"ng-class" => "{'fullscreen' : ctrl.fullscreen }", "ng-disabled" => "ctrl.note.locked", "ng-show" => "ctrl.editorMode == 'edit'", "ng-model" => "ctrl.note.text",
.editor-content{"ng-class" => "{'fullscreen' : ctrl.fullscreen }"}
%textarea.editable#note-text-editor{"ng-class" => "{'fullscreen' : ctrl.fullscreen }", "ng-show" => "ctrl.editorMode == 'edit'", "ng-model" => "ctrl.note.text",
"ng-change" => "ctrl.contentChanged()", "ng-click" => "ctrl.clickedTextArea()", "ng-focus" => "ctrl.onContentFocus()"}
.preview{"ng-class" => "{'fullscreen' : ctrl.fullscreen }", "ng-if" => "ctrl.editorMode == 'preview'", "ng-bind-html" => "ctrl.renderedContent()", "ng-dblclick" => "ctrl.onPreviewDoubleClick()"}

View File

@@ -4,12 +4,12 @@
.items
.item.account
%div{"ng-click" => "ctrl.accountMenuPressed()"}
%div{"ng-if" => "ctrl.user.email"} Account
%div{"ng-if" => "!ctrl.user.email"} Sign in or Register
%div{"ng-if" => "ctrl.user"} Account
%div{"ng-if" => "!ctrl.user"} Sign in or Register
.panel.panel-default.account-panel.panel-right{"ng-if" => "ctrl.showAccountMenu"}
.panel-body
.account-items
.account-item.registration-login{"ng-if" => "!ctrl.user.email"}
.account-item.registration-login{"ng-if" => "!ctrl.user"}
.account-item
.meta-container
.title Server
@@ -46,11 +46,10 @@
Because notes are locally encrypted using a secret key derived from your password, there's no way to decrypt these notes if you forget your password.
For this reason, Standard Notes cannot offer a password reset option. You <strong>must</strong> make sure to store or remember your password.
.account-item{"ng-if" => "ctrl.user.email"}
.account-item{"ng-if" => "ctrl.user"}
.email {{ctrl.user.email}}
.server {{ctrl.serverData.url}}
.links{"ng-if" => "ctrl.user.email"}
.links{"ng-if" => "ctrl.user"}
-# .link-item
-# %a{"ng-click" => "ctrl.changePasswordPressed()"} Change Password
-# %form.account-form{"ng-if" => "ctrl.showNewPasswordForm", 'ng-submit' => 'ctrl.submitPasswordChange()', 'name' => "passwordChangeForm"}
@@ -71,8 +70,8 @@
.desc Notes are encrypted locally before being sent to the server. Neither the server owner nor an intrusive entity can decrypt your locally encrypted notes.
.action-container
%span.status-title Status:
{{ctrl.encryptionStatusForNotes()}} (shared notes not encrypted)
.account-item{"ng-if" => "ctrl.user.email"}
{{ctrl.encryptionStatusForNotes()}}
.account-item{"ng-if" => "ctrl.user"}
.meta-container
.title Data Archives
.options{"style" => "font-size: 12px; margin-top: 4px;"}

View File

@@ -1,2 +0,0 @@
%strong Choose a public username for all your shared note tags.
%input{"style" => "margin-top: 10px; padding-left: 8px;", "type" => "text", "ng-keyup" => "$event.keyCode == 13 && saveUsername($event)", "ng-model" => "formData.username"}

View File

@@ -15,23 +15,9 @@
%span.sr-only
%ul.dropdown-menu.dropdown-menu-left.nt-dropdown-menu.dark{"ng-if" => "ctrl.showMenu"}
%li{"ng-if" => "!ctrl.tag.isPublic()"}
%a.text{"ng-click" => "ctrl.selectedMenuItem(); ctrl.selectedTagShare($event)"} Share Tag
%li{"ng-if" => "ctrl.tag.isPublic()"}
%a.text{"ng-click" => "ctrl.selectedMenuItem(); ctrl.selectedTagUnshare()"} Unshare Tag
%li{"ng-if" => "!ctrl.tag.all"}
%li
%a.text{"ng-click" => "ctrl.selectedMenuItem(); ctrl.selectedTagDelete()"} Delete Tag
.menu-right-container
.public-link{"ng-if" => "ctrl.tag.isPublic()"}
%a.url{"ng-if" => "!ctrl.editingUrl", "href" => "{{ctrl.tag.presentationURL()}}", "target" => "_blank"}
%span.icon-rss.icon
{{ctrl.tag.presentationURL()}}
.edit-url{"ng-if" => "ctrl.editingUrl"}
{{ctrl.url.base}}
%input.input{"ng-model" => "ctrl.url.token", "ng-keyup" => "$event.keyCode == 13 && ctrl.saveUrl($event)",
"ng-change" => "ctrl.urlChanged()", "ng-focus" => "ctrl.onUrlFocus()",
"select-on-click" => "true", "autofocus" => "true"}
.note{"ng-repeat" => "note in ctrl.tag.notes | filter: ctrl.filterNotes",
"ng-click" => "ctrl.selectNote(note)", "ng-class" => "{'selected' : ctrl.selectedNote == note}",
"ng-attr-draggable" => "{{note.dummy ? undefined : 'true'}}", "note" => "note"}

View File

@@ -11,7 +11,7 @@
.tag{"ng-repeat" => "tag in ctrl.tags", "ng-click" => "ctrl.selectTag(tag)", "ng-class" => "{'selected' : ctrl.selectedTag == tag}",
"droppable" => true, "drop" => "ctrl.handleDrop", "tag" => "tag"}
.icon.icon-rss{"ng-if" => "tag.isPublic()"}
%input.title{"ng-disabled" => "tag != ctrl.selectedTag", "ng-model" => "tag.title",
"ng-keyup" => "$event.keyCode == 13 && ctrl.saveTag($event, tag)", "mb-autofocus" => "true", "should-focus" => "ctrl.newTag",
"ng-change" => "ctrl.tagTitleDidChange(tag)", "ng-focus" => "ctrl.onTagTitleFocus(tag)"}

View File

@@ -10,8 +10,7 @@
"angular": "1.6.1",
"angular-ui-router": "^0.3.2",
"restangular": "^1.6.1",
"marked": "0.3.6",
"ng-dialog" : "0.6.6"
"marked": "0.3.6"
},
"resolutions": {
"angular": "1.6.1"