Created
August 26, 2014 09:58
-
-
Save tilgovi/f94565b2beb6623a79e9 to your computer and use it in GitHub Desktop.
Sketches for forced login, bridge changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 318158cf7ee82797969e5ab2fa559ca6ab4dfa6a | |
Merge: 0610025 a17f146 | |
Author: Randall Leeds <tilgovi@hypothes.is> | |
Date: Mon Jul 28 22:29:32 2014 -0700 | |
WIP on master: 0610025 Bump annotator-store version for security fix | |
diff --cc h/static/scripts/app_directives.coffee | |
index 7bac3cc,7bac3cc..4e03cca | |
diff --cc h/static/scripts/controllers.coffee | |
index 6534ad1,6534ad1..e3d3915 | |
--- a/h/static/scripts/controllers.coffee | |
+++ b/h/static/scripts/controllers.coffee | |
@@@ -732,6 -732,6 +728,20 @@@ | |
delete target.trustedDiffHTML | |
target.showDiff = false | |
++ """ | |
++ unless $scope.model.persona | |
++ readyToCreate = $scope.$watch 'session.$promise', (promise) -> | |
++ return unless promise | |
++ promise.then (session) -> | |
++ return unless session.persona | |
++ annotation = annotator.plugins.Bridge.cache[$routeParams.tag] | |
++ annotator.publish 'beforeAnnotationCreated', annotation | |
++ drafts.add annotation | |
++ $scope.annotation = annotation | |
++ $scope.editing = true | |
++ readyToCreate() | |
++ """ | |
++ | |
class Viewer | |
this.$inject = [ | |
diff --cc h/static/scripts/guest.coffee | |
index 6475283,6475283..a1e70cc | |
--- a/h/static/scripts/guest.coffee | |
+++ b/h/static/scripts/guest.coffee | |
@@@ -269,6 -269,6 +269,11 @@@ class Annotator.Guest extends Annotato | |
this.removeEvents() | |
++ showEditor: (annotation) => | |
++ @panel?.notify | |
++ method: "showEditor" | |
++ params: annotation.$$tag | |
++ | |
showViewer: (viewName, annotations, focused = false) => | |
@panel?.notify | |
method: "showViewer" | |
@@@ -292,8 -292,8 +297,6 @@@ | |
ids: (a.id for a in annotations when a.id) | |
focused: focused | |
-- showEditor: (annotation) => @plugins.Bridge.showEditor annotation | |
-- | |
addEmphasis: (annotations) => | |
@panel?.notify | |
method: "addEmphasis" | |
@@@ -491,7 -491,7 +494,9 @@@ | |
this.subscribe('annotationEditorSubmit', save) | |
# Display the editor. | |
-- this.showEditor(annotation, position) | |
++ @plugins.Bridge.sync(annotation, => | |
++ this.showEditor(annotation, position) | |
++ ) | |
# We have to clear the selection. | |
# (Annotator does this automatically by focusing on | |
diff --cc h/static/scripts/plugin/bridge.coffee | |
index 4b56e39,4b56e39..2ea9b6e | |
--- a/h/static/scripts/plugin/bridge.coffee | |
+++ b/h/static/scripts/plugin/bridge.coffee | |
@@@ -243,14 -243,14 +243,14 @@@ class Annotator.Plugin.Bridge extends A | |
@annotator.loadAnnotations newOnes | |
) | |
-- .bind('showEditor', (ctx, annotation) => | |
-- @annotator.showEditor (this._parse annotation) | |
-- ) | |
-- | |
.bind('enableAnnotating', (ctx, state) => | |
@annotator.enableAnnotating state, false | |
) | |
++ .bind('sync', (ctx, annotation) => | |
++ this._format this._parse annotation | |
++ ) | |
++ | |
# Send out a beacon to let other frames know to connect to us | |
_beacon: -> | |
queue = [window.top] | |
@@@ -411,13 -411,13 +411,14 @@@ | |
callback: cb | |
annotation | |
-- showEditor: (annotation) -> | |
-- this._notify | |
-- method: 'showEditor' | |
-- params: this._format annotation | |
-- this | |
-- | |
enableAnnotating: (state) -> | |
this._notify | |
method: 'enableAnnotating' | |
params: state | |
++ | |
++ sync: (annotation, cb) -> | |
++ this._call | |
++ method: 'sync' | |
++ params: this._format annotation | |
++ callback: cb | |
++ annotation | |
diff --cc h/static/scripts/services.coffee | |
index 2053db9,2053db9..d4a9bec | |
--- a/h/static/scripts/services.coffee | |
+++ b/h/static/scripts/services.coffee | |
@@@ -228,7 -228,7 +228,9 @@@ class Hypothesis extends Annotato | |
), 100 | |
_setupXDM: (options) -> | |
++ $location = @element.injector().get '$location' | |
$rootScope = @element.injector().get '$rootScope' | |
++ drafts = @element.injector().get 'drafts' | |
# jschannel chokes FF and Chrome extension origins. | |
if (options.origin.match /^chrome-extension:\/\//) or | |
@@@ -259,11 -259,11 +261,20 @@@ | |
$rootScope.$apply => this.show() | |
) | |
++ .bind('showEditor', (ctx, tag) => | |
++ return unless this.discardDrafts() | |
++ $rootScope.$apply => | |
++ $location.path('/editor').search({tag}) | |
++ this.show() | |
++ ) | |
++ | |
.bind('showViewer', (ctx, {view, ids, focused}) => | |
ids ?= [] | |
return unless this.discardDrafts() | |
$rootScope.$apply => | |
-- this.showViewer view, this._getAnnotationsFromIDs(ids), focused | |
++ $location.path('/viewer') | |
++ this.updateViewer view, this._getAnnotationsFromIDs(ids), focused | |
++ this.show() | |
) | |
.bind('updateViewer', (ctx, {view, ids, focused}) => | |
@@@ -400,42 -400,42 +411,30 @@@ | |
updateViewer: (viewName, annotations=[], focused = false) => | |
annotations = annotations.filter (a) -> a? | |
-- @element.injector().invoke [ | |
-- '$rootScope', | |
-- ($rootScope) => | |
-- @buildReplyList annotations | |
++ $rootScope = @element.injector().get '$rootScope' | |
-- # Do we have to replace the focused list with this? | |
-- if focused | |
-- # Nuke the old focus list | |
-- $rootScope.focused = [] | |
-- # Add the new elements | |
-- for a in annotations | |
-- $rootScope.focus a, true, true | |
-- else | |
-- # Go over the old list, and unfocus the ones | |
-- # that are not on this list | |
-- for a in $rootScope.focused.slice() when a not in annotations | |
-- $rootScope.unFocus a, true, true | |
-- | |
-- # Update the main annotations list | |
-- $rootScope.annotations = annotations | |
-- | |
-- unless $rootScope.viewState.view is viewName | |
-- # We are changing the view | |
-- $rootScope.viewState.view = viewName | |
-- $rootScope.showViewSort true, true | |
-- ] | |
-- this | |
++ @buildReplyList annotations | |
-- showViewer: (viewName, annotations=[], focused = false) => | |
-- this.show() | |
-- @element.injector().invoke [ | |
-- '$location', | |
-- ($location) => | |
-- $location.path('/viewer').replace() | |
-- ] | |
-- this.updateViewer viewName, annotations, focused | |
++ # Do we have to replace the focused list with this? | |
++ if focused | |
++ # Nuke the old focus list | |
++ $rootScope.focused = [] | |
++ # Add the new elements | |
++ for a in annotations | |
++ $rootScope.focus a, true, true | |
++ else | |
++ # Go over the old list, and unfocus the ones | |
++ # that are not on this list | |
++ for a in $rootScope.focused.slice() when a not in annotations | |
++ $rootScope.unFocus a, true, true | |
++ | |
++ # Update the main annotations list | |
++ $rootScope.annotations = annotations | |
++ | |
++ unless $rootScope.viewState.view is viewName | |
++ # We are changing the view | |
++ $rootScope.viewState.view = viewName | |
++ $rootScope.showViewSort true, true | |
addEmphasis: (annotations=[]) => | |
annotations = annotations.filter (a) -> a? # Filter out null annotations | |
@@@ -454,34 -454,34 +453,6 @@@ | |
p.channel.notify | |
method: 'adderClick' | |
-- showEditor: (annotation) => | |
-- this.show() | |
-- @element.injector().invoke [ | |
-- '$location', '$rootScope', 'drafts' | |
-- ($location, $rootScope, drafts) => | |
-- @ongoing_edit = annotation | |
-- | |
-- unless this.plugins.Auth? and this.plugins.Auth.haveValidToken() | |
-- $rootScope.$apply -> | |
-- $rootScope.$broadcast 'showAuth', true | |
-- for p in @providers | |
-- p.channel.notify method: 'onEditorHide' | |
-- return | |
-- | |
-- # Set the path | |
-- search = | |
-- id: annotation.id | |
-- action: 'create' | |
-- $location.path('/editor').search(search) | |
-- | |
-- # Store the draft | |
-- drafts.add annotation | |
-- | |
-- # Digest the change | |
-- $rootScope.$digest() | |
-- ] | |
-- this | |
-- | |
show: => | |
@element.scope().frame.visible = true | |
@@@ -583,15 -583,15 +554,6 @@@ | |
return unless this.discardDrafts() | |
if name is 'highlight' | |
-- # Check login state first | |
-- unless @plugins.Permissions?.user | |
-- scope = @element.scope() | |
-- # If we are not logged in, start the auth process | |
-- scope.ongoingHighlightSwitch = true | |
-- scope.sheet.collapsed = false | |
-- this.show() | |
-- return | |
-- | |
this.socialView.name = 'single-player' | |
else | |
this.socialView.name = 'none' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment