Commit eb375756 authored by Leo Iannacone's avatar Leo Iannacone

server send last lines of files if filename is in config.web.file.preview

parent cd4fbbad
...@@ -106,7 +106,7 @@ function __send_distribution_packages(event_name, socket, data) { ...@@ -106,7 +106,7 @@ function __send_distribution_packages(event_name, socket, data) {
}); });
} }
function __send_file(event_name, socket, data) { function __send_file(event_name, socket, data, last_lines) {
var file_path = utils.get_file_path(data); var file_path = utils.get_file_path(data);
fs.readFile(file_path, 'utf8', function (err, content) { fs.readFile(file_path, 'utf8', function (err, content) {
if (err) { if (err) {
...@@ -114,6 +114,9 @@ function __send_file(event_name, socket, data) { ...@@ -114,6 +114,9 @@ function __send_file(event_name, socket, data) {
return; return;
} }
data.file.orig_name = file_path.split('/').pop(); data.file.orig_name = file_path.split('/').pop();
if (last_lines > 0)
data.file.content = content.split('\n').slice(-25).join('\n');
else
data.file.content = content; data.file.content = content;
data.file.path = file_path.replace(config.debomatic.path, config.routes.debomatic); data.file.path = file_path.replace(config.debomatic.path, config.routes.debomatic);
socket.emit(event_name, data); socket.emit(event_name, data);
...@@ -126,6 +129,9 @@ function __handler_get_file(socket, data) { ...@@ -126,6 +129,9 @@ function __handler_get_file(socket, data) {
data.file.content = null; data.file.content = null;
socket.emit(event_name, data); socket.emit(event_name, data);
}); });
if (config.web.file.preview.indexOf(data.file.name) >= 0 && !data.file.force)
__send_file(_e.file.set, socket, data, config.web.file.num_lines);
else
__send_file(_e.file.set, socket, data); __send_file(_e.file.set, socket, data);
} }
...@@ -165,7 +171,7 @@ function Client(socket) { ...@@ -165,7 +171,7 @@ function Client(socket) {
for (var key in socket_watchers) { for (var key in socket_watchers) {
try { try {
socket_watchers[key].close(); socket_watchers[key].close();
} catch (err) {} } catch (error_watch) {}
} }
}); });
}); });
......
...@@ -47,6 +47,11 @@ config.web.debomatic.dput.login = 'debomatic'; ...@@ -47,6 +47,11 @@ config.web.debomatic.dput.login = 'debomatic';
config.web.debomatic.dput.method = 'scp'; config.web.debomatic.dput.method = 'scp';
config.web.debomatic.dput.unsigned_uploads = false; config.web.debomatic.dput.unsigned_uploads = false;
// list of files get preview
config.web.file = {};
config.web.file.preview = ['buildlog'];
config.web.file.num_lines = 25;
// default ui settings // default ui settings
config.web.preferences = {}; config.web.preferences = {};
config.web.preferences.autoscroll = true; config.web.preferences.autoscroll = true;
......
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