Dynamic domain

This commit is contained in:
Bruno SIMON
2016-06-07 14:17:20 +02:00
parent 6e32b80ddd
commit 1126da2747
10 changed files with 31 additions and 16 deletions
+6 -3
View File
@@ -22,6 +22,9 @@ class App
constructor( _options )
{
this.set_options( _options )
this.domain = 'http://' + ip.address() + ':' + this.options.port
this.set_express()
this.set_server()
this.set_socket()
@@ -81,6 +84,8 @@ class App
this.express.set( 'views', path.join( __dirname, 'views' ) )
this.express.use( express.static( path.join( __dirname, 'public' ) ) )
this.express.locals.domain = this.domain
// Controllers
this.express.use( '/', require( './controllers/index.js' ) )
}
@@ -97,11 +102,9 @@ class App
this.server.listen( this.options.port, () =>
{
// URL
let url = 'http://' + ip.address() + ':' + this.options.port
console.log( colors.green( '---------------------------' ) )
console.log( 'server'.green.bold + ' - ' + 'started'.cyan )
console.log( 'server'.green.bold + ' - ' + url.cyan )
console.log( 'server'.green.bold + ' - ' + this.domain.cyan )
} )
}
@@ -1 +1,3 @@
var angular_module = angular.module( 'application', [] );
var application = angular.module( 'application', [] );
application.constant( 'config', config );
@@ -1,4 +1,4 @@
angular_module.controller(
application.controller(
'ProjectController',
[
'$scope',
@@ -1,4 +1,4 @@
angular_module.controller(
application.controller(
'ProjectsController',
[
'$scope',
+4 -3
View File
@@ -1,8 +1,9 @@
angular_module.factory(
application.factory(
'project',
[
'config',
'$timeout',
function( $timeout )
function( config, $timeout )
{
var update_callback = null;
@@ -85,7 +86,7 @@ angular_module.factory(
result.connect = function( project_name )
{
// Connect to socket
var socket = io( 'http://192.168.1.4:3000/project/' + project_name );
var socket = io( config.domain + '/project/' + project_name );
// Connect event
socket.on( 'connect', function()
+4 -3
View File
@@ -1,7 +1,8 @@
angular_module.factory(
application.factory(
'projects',
[
function()
'config',
function( config )
{
update_callback = null;
@@ -14,7 +15,7 @@ angular_module.factory(
};
// Socket
var socket = io( 'http://192.168.1.4:3000/projects' );
var socket = io( config.domain + '/projects' );
socket.on( 'update_projects', function( data )
{
-4
View File
@@ -10,10 +10,6 @@ script(type="text/ng-template",id="folder_template.html")
| {{_file.name}}
section(ng-controller="ProjectController as controller",ng-init="init('" + project_slug + "')")
header.main-header
h1
a(href="/")
| Code Spectat
aside
header.aside-header
| {{project.name}}
+8
View File
@@ -2,6 +2,10 @@ html(ng-app="application")
head
title
| Code Spectat
script.
var config = {
domain : '#{domain}'
}
script(src="/socket.io/socket.io.js")
script(src="/vendors/moment.min.js")
script(src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js")
@@ -14,3 +18,7 @@ html(ng-app="application")
script(src="/javascript/services/projects.js")
link(rel="stylesheet", href="/stylesheets/style.css")
body
header.main-header
h1
a(href=domain)
| Code Spectat