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