Commit 0813b08b authored by Leo Iannacone's avatar Leo Iannacone

Merge remote-tracking branch 'github/master' into portable

parents 8876785a 90bc7ff5
{ {
"globals": {
"$": false,
"console": false,
"config": false,
"Utils": false,
"debug_socket": false
},
"globalstrict": true, "globalstrict": true,
"browser": true, "browser": true,
"node": true "node": true
......
...@@ -6,50 +6,54 @@ ...@@ -6,50 +6,54 @@
* Module dependencies. * Module dependencies.
*/ */
var express = require('express'), var http = require('http'),
express = require('express'),
serve_static = require('serve-static'), serve_static = require('serve-static'),
serve_index = require('serve-index'), serve_index = require('serve-index'),
errorhandler = require('errorhandler'), errorhandler = require('errorhandler'),
routes = require('./routes'), routes = require('./routes'),
config = require('./lib/config.js'), config = require('./lib/config.js'),
utils = require('./lib/utils.js'), utils = require('./lib/utils.js'),
http = require('http'),
app = module.exports = express(),
Client = require('./lib/client.js'), Client = require('./lib/client.js'),
Broadcaster = require('./lib/broadcaster.js'); Broadcaster = require('./lib/broadcaster.js');
var app = module.exports = express(),
server = http.createServer(app),
io = require('socket.io')(server),
env = process.env.NODE_ENV || 'development';
// serve dsc files as octet-stream
serve_static.mime.define({
'application/octet-stream': ['dsc']
});
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(serve_static(__dirname + '/public'));
app.use(config.routes.debomatic, serve_index(config.debomatic.path));
app.use(config.routes.debomatic, serve_static(config.debomatic.path));
var env = process.env.NODE_ENV || 'development';
if ('development' == env) { if ('development' == env) {
app.use(errorhandler({ app.use(errorhandler({
dumpExceptions: true, dumpExceptions: true,
showStack: true showStack: true
})); }));
} else if ('development' == env) { } else if ('production' == env) {
app.use(errorhandler()); app.use(errorhandler());
} }
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
// Routes // Routes
app.get('/', routes.index); app.get('/', routes.index);
// distibution page
app.get(config.routes.distribution, routes.distribution); app.get(config.routes.distribution, routes.distribution);
// parefernces page
if (config.routes.preferences) if (config.routes.preferences)
app.get(config.routes.preferences, routes.preferences); app.get(config.routes.preferences, routes.preferences);
// commands page
if (config.routes.commands) if (config.routes.commands)
app.get(config.routes.commands, routes.commands); app.get(config.routes.commands, routes.commands);
// debomatic static page
app.use(config.routes.debomatic, serve_index(config.debomatic.path));
app.use(config.routes.debomatic, serve_static(config.debomatic.path));
// serve stylesheet-javascript
app.use(serve_static(__dirname + '/public'));
var server = http.createServer(app), // serve dsc files as octet-stream
io = require('socket.io').listen(server, config.socket); serve_static.mime.define({
'application/octet-stream': ['dsc']
});
// Listening // Listening
server.listen(config.port, config.host, null, function (err) { server.listen(config.port, config.host, null, function (err) {
......
...@@ -17,9 +17,6 @@ var config = {}; ...@@ -17,9 +17,6 @@ var config = {};
config.host = 'localhost'; config.host = 'localhost';
config.port = 3000; config.port = 3000;
config.socket = {};
config.socket.log = false;
config.debomatic = {}; config.debomatic = {};
config.debomatic.path = '/srv/debomatic-amd64'; config.debomatic.path = '/srv/debomatic-amd64';
config.debomatic.jsonfile = '/var/log/debomatic-json.log'; config.debomatic.jsonfile = '/var/log/debomatic-json.log';
......
/*jshint multistr: true */
'use strict'; 'use strict';
function Parser() { function Parser() {
...@@ -35,4 +36,4 @@ Usage: %s [-c config]\n\ ...@@ -35,4 +36,4 @@ Usage: %s [-c config]\n\
}); });
} }
module.exports = Parser module.exports = Parser;
...@@ -75,11 +75,7 @@ function __get_files_list(dir, onlyDirectories, callback) { ...@@ -75,11 +75,7 @@ function __get_files_list(dir, onlyDirectories, callback) {
} }
function __watch_path_onsocket(event_name, socket, data, watch_path, updater) { function __watch_path_onsocket(event_name, socket, data, watch_path, updater) {
socket.get('watchers', function (err, socket_watchers) { var socket_watchers = socket.watchers || {};
if (!socket_watchers) {
// init socket watchers
socket_watchers = {};
}
try { try {
var watcher = socket_watchers[event_name]; var watcher = socket_watchers[event_name];
if (watcher) if (watcher)
...@@ -108,13 +104,12 @@ function __watch_path_onsocket(event_name, socket, data, watch_path, updater) { ...@@ -108,13 +104,12 @@ function __watch_path_onsocket(event_name, socket, data, watch_path, updater) {
}); });
} }
socket_watchers[event_name] = watcher; socket_watchers[event_name] = watcher;
socket.set('watchers', socket_watchers); socket.watchers = socket_watchers;
}); });
} catch (err) { } catch (err) {
__errors_handler('__watch_path_onsocket <- ' + arguments.callee.caller.name, err, socket); __errors_handler('__watch_path_onsocket <- ' + arguments.callee.caller.name, err, socket);
return; return;
} }
});
} }
function __generic_handler_watcher(event_name, socket, data, watch_path, callback) { function __generic_handler_watcher(event_name, socket, data, watch_path, callback) {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
"serve-static": "*", "serve-static": "*",
"errorhandler ": "*", "errorhandler ": "*",
"ejs": ">= 0.0.1", "ejs": ">= 0.0.1",
"socket.io": "0.*", "socket.io": "1.*",
"tail": "*" "tail": "*"
}, },
"scripts": { "scripts": {
......
{
"globals": {
"$": false,
"console": false,
"config": false
},
"globalstrict": true,
"browser": true
}
// main client javascript // main client javascript
/* global io: false */
/* global Preferences: false */
/* global Page_Generic: false */
/* global Page_Distrubion: false */
'use strict'; 'use strict';
var preferences = new Preferences(); var preferences = new Preferences();
...@@ -23,7 +29,7 @@ if (window.location.pathname == '/') { ...@@ -23,7 +29,7 @@ if (window.location.pathname == '/') {
label = config.debomatic.admin.name; label = config.debomatic.admin.name;
real_email = '<a href="mailto:' + real_email + subject + '">' + label + '</a>'; real_email = '<a href="mailto:' + real_email + subject + '">' + label + '</a>';
$(this).html(real_email); $(this).html(real_email);
}) });
} }
var socket = io.connect('/'); var socket = io.connect('/');
......
'use strict'; 'use strict';
/* global debug: false */ /* global Utils: false */
/* global page_generic: false */ /* global page_generic: false */
/* global debug: false */
/* global debug_socket: false */
// function to get all files in on click // function to get all files in on click
// event comes from HTML // event comes from HTML
...@@ -177,9 +180,11 @@ function Page_Distrubion(socket) { ...@@ -177,9 +180,11 @@ function Page_Distrubion(socket) {
$('#packages .search .text').val(name); $('#packages .search .text').val(name);
$('#packages .search .text').keyup(); $('#packages .search .text').keyup();
}); });
$('#packages .search').show();
packages.select(); packages.select();
} else { } else {
$('#packages ul').append('<li class="text-muted">No packages yet</li>'); $('#packages .search').hide();
$('#packages ul').append('<li class="disabled"><a>No packages yet</a></li>');
} }
packages.show(); packages.show();
sticky.updateOffset(); sticky.updateOffset();
...@@ -356,7 +361,7 @@ function Page_Distrubion(socket) { ...@@ -356,7 +361,7 @@ function Page_Distrubion(socket) {
var file = { var file = {
set: function (socket_data) { set: function (socket_data) {
var new_content = Utils.escape_html(socket_data.file.content); var new_content = Utils.escape_html(socket_data.file.content);
var file_content = $('#file pre'); var file_content = $('#file .content');
view.file = Utils.clone(socket_data.file); view.file = Utils.clone(socket_data.file);
file_content.html(new_content); file_content.html(new_content);
file_content.show(); file_content.show();
...@@ -364,11 +369,11 @@ function Page_Distrubion(socket) { ...@@ -364,11 +369,11 @@ function Page_Distrubion(socket) {
file_content.scrollTop(file_content[0].scrollHeight); file_content.scrollTop(file_content[0].scrollHeight);
}, },
clean: function () { clean: function () {
$('#file pre').html(''); $('#file .content').html('');
$('#file').hide(); $('#file').hide();
}, },
append: function (new_content) { append: function (new_content) {
var file_content = $('#file pre'); var file_content = $('#file .content');
new_content = Utils.escape_html(new_content); new_content = Utils.escape_html(new_content);
if (!current_file_in_preview) { if (!current_file_in_preview) {
file_content.append(new_content); file_content.append(new_content);
...@@ -402,7 +407,7 @@ function Page_Distrubion(socket) { ...@@ -402,7 +407,7 @@ function Page_Distrubion(socket) {
query_data.file.content = null; query_data.file.content = null;
query_data.file.force = force; query_data.file.force = force;
// get a feedback to user while downloading file // get a feedback to user while downloading file
$('#file pre').html('Downloading file, please wait a while ...'); $('#file .content').html('Downloading file, please wait a while ...');
$('#file').show(); $('#file').show();
debug_socket('emit', _e.file, query_data); debug_socket('emit', _e.file, query_data);
socket.emit(_e.file, query_data); socket.emit(_e.file, query_data);
...@@ -414,9 +419,9 @@ function Page_Distrubion(socket) { ...@@ -414,9 +419,9 @@ function Page_Distrubion(socket) {
} }
debug(2, "file set preview", preview); debug(2, "file set preview", preview);
current_file_in_preview = preview; current_file_in_preview = preview;
var file = $('#file pre'); var file = $('#file .content');
if (preview) { if (preview) {
$('#file pre').addClass('preview'); $('#file .content').addClass('preview');
var height = (config.file.num_lines) * var height = (config.file.num_lines) *
parseInt(file.css('line-height').replace(/[^-\d\.]/g, '')) + parseInt(file.css('line-height').replace(/[^-\d\.]/g, '')) +
parseInt(file.css('padding-top').replace(/[^-\d\.]/g, '')) + parseInt(file.css('padding-top').replace(/[^-\d\.]/g, '')) +
...@@ -585,9 +590,9 @@ function Page_Distrubion(socket) { ...@@ -585,9 +590,9 @@ function Page_Distrubion(socket) {
$('#sticky-package').addClass('on-top'); $('#sticky-package').addClass('on-top');
} }
if (!config.preferences.file_background) { if (!config.preferences.file_background) {
$('#file pre').addClass('no-background'); $('#file .content').addClass('no-background');
} }
$('#file pre').css('font-size', config.preferences.file_fontsize); $('#file .content').css('font-size', config.preferences.file_fontsize);
}; };
var select = function () { var select = function () {
...@@ -652,6 +657,12 @@ function Page_Distrubion(socket) { ...@@ -652,6 +657,12 @@ function Page_Distrubion(socket) {
this.start = function () { this.start = function () {
socket.on('connect', function () {
if (!__check_hash_makes_sense())
return;
populate();
});
socket.on(config.events.error, function (socket_error) { socket.on(config.events.error, function (socket_error) {
debug_socket('received', config.events.error, socket_error); debug_socket('received', config.events.error, socket_error);
error.set(socket_error); error.set(socket_error);
...@@ -710,9 +721,6 @@ function Page_Distrubion(socket) { ...@@ -710,9 +721,6 @@ function Page_Distrubion(socket) {
debug(1, 'changing view', 'old:', old_view, 'new:', view); debug(1, 'changing view', 'old:', old_view, 'new:', view);
}); });
if (!__check_hash_makes_sense())
return;
populate();
// Init sticky-package back_on_top on click // Init sticky-package back_on_top on click
$('#sticky-package').on('click', function () { $('#sticky-package').on('click', function () {
......
/* global Utils: false */
/* global debug_socket: false */
'use strict'; 'use strict';
function Page_Generic() { function Page_Generic() {
......
/* global debug: false */
/* global page_generic: false */
'use strict'; 'use strict';
function Preferences() { function Preferences() {
......
...@@ -166,7 +166,7 @@ footer .info { ...@@ -166,7 +166,7 @@ footer .info {
line-height: 35px; line-height: 35px;
} }
#file pre { #file .content {
white-space: pre-wrap; white-space: pre-wrap;
word-break: break-word; word-break: break-word;
} }
...@@ -186,7 +186,7 @@ footer .info { ...@@ -186,7 +186,7 @@ footer .info {
font-size: 75%; font-size: 75%;
} }
#file pre.preview { #file .preview {
overflow:hidden; overflow:hidden;
} }
......
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
<div id="welcome"></div> <div id="welcome"></div>
<div id="file"> <div id="file">
<div class="datestamp"></div> <div class="datestamp"></div>
<pre></pre> <pre class="content"></pre>
<div id="fileOffset"></div> <div id="fileOffset"></div>
</div> </div>
</section> </section>
......
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