Commit ac0e853c authored by Randall Leeds's avatar Randall Leeds

Merge pull request #1320 from hypothesis/427-standalone-app

Turn the standalone page into the app
parents d7ca3ffa 66348097
...@@ -5,7 +5,6 @@ imports = [ ...@@ -5,7 +5,6 @@ imports = [
'h.controllers' 'h.controllers'
'h.directives' 'h.directives'
'h.app_directives' 'h.app_directives'
'h.displayer'
'h.helpers' 'h.helpers'
'h.flash' 'h.flash'
'h.filters' 'h.filters'
...@@ -38,6 +37,9 @@ configure = [ ...@@ -38,6 +37,9 @@ configure = [
$delegate $delegate
] ]
$routeProvider.when '/a/:id',
controller: 'ViewerController'
templateUrl: 'viewer.html'
$routeProvider.when '/editor', $routeProvider.when '/editor',
controller: 'EditorController' controller: 'EditorController'
templateUrl: 'editor.html' templateUrl: 'editor.html'
......
...@@ -260,6 +260,9 @@ class App ...@@ -260,6 +260,9 @@ class App
$scope.search.show = not angular.equals($location.search(), {}) $scope.search.show = not angular.equals($location.search(), {})
unless next.$$route.originalPath is '/stream' unless next.$$route.originalPath is '/stream'
if current and next.$$route.originalPath is '/a/:id'
$scope.reloadAnnotations()
$scope.search.update = (searchCollection) -> $scope.search.update = (searchCollection) ->
return unless annotator.discardDrafts() return unless annotator.discardDrafts()
return unless searchCollection.models.length return unless searchCollection.models.length
...@@ -284,7 +287,10 @@ class App ...@@ -284,7 +287,10 @@ class App
query.quote = query.quote.concat(value.split(/\s+/)) query.quote = query.quote.concat(value.split(/\s+/))
unless angular.equals $location.search(), query unless angular.equals $location.search(), query
$location.path('/page_search').search(query) if $location.path() == '/viewer'
$location.path('/page_search').search(query)
else
$location.path('/stream').search(query)
$scope.search.clear = -> $scope.search.clear = ->
$location.url('/viewer') $location.url('/viewer')
...@@ -301,6 +307,27 @@ class App ...@@ -301,6 +307,27 @@ class App
$scope.$root.annotations = [] $scope.$root.annotations = []
$scope.store = plugins.Store $scope.store = plugins.Store
_id = $route.current.params.id
_promise = null
# Load any initial annotations that should be displayed
if _id
if $scope.loadAnnotations
# Load annotations from inline page data
plugins.Store._onLoadAnnotations $scope.loadAnnotations
delete $scope.loadAnnotations
_promise = $scope.loadAnnotations
else
# Load annotations from the API
# XXX: Two requests here is less than ideal
_promise = plugins.Store.loadAnnotationsFromSearch({_id})
.then ->
plugins.Store.loadAnnotationsFromSearch({references: _id})
$q.when _promise, ->
thread = annotator.threading.getContainer _id
$scope.$root.annotations = [thread.message]
return unless Store return unless Store
# XXX: Hacky hacky stuff to ensure that any search requests in-flight # XXX: Hacky hacky stuff to ensure that any search requests in-flight
...@@ -346,7 +373,7 @@ class App ...@@ -346,7 +373,7 @@ class App
annotations = (a for a in annotations when a not in deleted) annotations = (a for a in annotations when a not in deleted)
if annotations.length is 0 if annotations.length is 0
annotator.unsubscribe 'annotationsLoaded', cleanup annotator.unsubscribe 'annotationsLoaded', cleanup
$route.reload() $rootScope.$digest()
, 10 , 10
cleanup (a for a in annotations when a.thread) cleanup (a for a in annotations when a.thread)
annotator.subscribe 'annotationsLoaded', cleanup annotator.subscribe 'annotationsLoaded', cleanup
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment