Commit 582358b6 authored by gergely-ujvari's avatar gergely-ujvari

H main controller uses baseurl from Helper

parent d71d1261
imports = [ imports = [
'bootstrap' 'bootstrap'
'ngRoute' 'ngRoute'
'h.helper'
'h.controllers' 'h.controllers'
'h.directives' 'h.directives'
'h.app_directives' 'h.app_directives'
......
...@@ -9,20 +9,15 @@ class App ...@@ -9,20 +9,15 @@ class App
this.$inject = [ this.$inject = [
'$element', '$filter', '$http', '$location', '$rootScope', '$scope', '$timeout', '$element', '$filter', '$http', '$location', '$rootScope', '$scope', '$timeout',
'annotator', 'authentication', 'streamfilter' 'annotator', 'authentication', 'baseurl', 'streamfilter'
] ]
constructor: ( constructor: (
$element, $filter, $http, $location, $rootScope, $scope, $timeout $element, $filter, $http, $location, $rootScope, $scope, $timeout
annotator, authentication, streamfilter annotator, authentication, baseurl, streamfilter
) -> ) ->
# Get the base URL from the base tag or the app location init_path = document.init_path
baseUrl = angular.element('head base')[0]?.href $scope.baseurl = baseurl[..-(init_path.toString().length)] + '__streamer__'
baseUrl ?= ($location.absUrl().replace $location.url(), '') delete document.init_path
# Strip an empty hash and end in exactly one slash
baseUrl = baseUrl.replace /#$/, ''
baseUrl = baseUrl.replace /\/*$/, '/'
$scope.baseUrl = baseUrl
{plugins, host, providers} = annotator {plugins, host, providers} = annotator
...@@ -469,12 +464,6 @@ class App ...@@ -469,12 +464,6 @@ class App
$scope.initUpdater = -> $scope.initUpdater = ->
$scope.new_updates = 0 $scope.new_updates = 0
# Quick hack until we unify all the routes.
# We need to eliminate the distinction between the app and the site
# because it's not useful. The site is the app, stupid!
# Then everything will be relative to the same base.
path = $scope.baseUrl.replace(/\/\w+\/$/, '/')
path = "#{path}__streamer__"
# Collect all uris we should watch # Collect all uris we should watch
uris = (e for e of annotator.plugins.Store.entities).join ',' uris = (e for e of annotator.plugins.Store.entities).join ','
...@@ -486,7 +475,7 @@ class App ...@@ -486,7 +475,7 @@ class App
.setClausesParse('uri:[' + uris) .setClausesParse('uri:[' + uris)
.getFilter() .getFilter()
$scope.updater = new SockJS(path) $scope.updater = new SockJS($scope.baseurl)
$scope.updater.onopen = => $scope.updater.onopen = =>
sockmsg = sockmsg =
......
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