Merge pull request #21 from lexx27/master

Give the option change theme
pull/22/head
Maciej Winnicki 2013-11-01 14:04:46 -07:00
commit a3aead7036
7 changed files with 101 additions and 6 deletions

View File

@ -28,6 +28,7 @@
-p, --port <port> listening port, default 9001
-n, --number <number> starting lines number, default 10
-l, --lines <lines> number on lines stored in browser, default 2000
-t, --theme <theme> name of the theme (default, dark), default "default"
-d, --daemonize run as daemon
-U, --user <username> Basic Authentication username, this option works only along with -P option
-P, --password <password> Basic Authentication password, this option works only along with -U option

View File

@ -20,6 +20,7 @@ var connectBuilder = require('./lib/connect_builder');
.option('-p, --port <port>', 'listening port, default 9001', Number, 9001)
.option('-n, --number <number>', 'starting lines number, default 10', Number, 10)
.option('-l, --lines <lines>', 'number on lines stored in browser, default 2000', Number, 2000)
.option('-t, --theme <theme>', 'name of the theme (default, dark)', String, 'default')
.option('-d, --daemonize', 'run as daemon')
.option('-U, --user <username>',
'Basic Authentication username, this option works only along with -P option', String, false)
@ -56,7 +57,7 @@ var connectBuilder = require('./lib/connect_builder');
* Daemonize process
*/
var logFile = fs.openSync(program.logPath, 'a');
var args = ['-p', program.port, '-n', program.number, '-l', program.lines];
var args = ['-p', program.port, '-n', program.number, '-l', program.lines, '-t', program.theme];
if (doAuthorization) {
args = args.concat(['-U', program.user, '-P', program.password]);
@ -85,7 +86,7 @@ var connectBuilder = require('./lib/connect_builder');
}
builder.static(__dirname + '/lib/web/assets');
builder.index(__dirname + '/lib/web/index.html', program.args.join(' '));
builder.index(__dirname + '/lib/web/index.html', { 'title': program.args.join(' '), 'theme': program.theme });
var app = builder.build();
var server;

View File

@ -20,12 +20,23 @@ var fs = require('fs');
return this.app;
};
ConnectBuilder.prototype.index = function (path, title) {
ConnectBuilder.prototype.index = function (path, htmlDataArgs) {
var htmlData = {title: '', theme: 'default'};
if (typeof htmlDataArgs === 'object') {
for (var prop in htmlDataArgs) {
if (htmlDataArgs[prop]) {
htmlData[prop] = htmlDataArgs[prop];
}
}
}
this.app.use(function (req, res) {
fs.readFile(path, function (err, data) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(data.toString('utf-8').replace(
/__TITLE__/g, title), 'utf-8'
/__TITLE__/g, htmlData.title).replace(
/__THEME__/g, htmlData.theme), 'utf-8'
);
});
});

View File

@ -0,0 +1,79 @@
/* Styles mainly from http://twitter.github.com/bootstrap/ */
@import url(http://fonts.googleapis.com/css?family=Ubuntu+Mono);
* {
padding: 0;
margin: 0;
}
body {
font-family: "Ubuntu Mono","Courier New",Courier;
font-size: 13px;
line-height: 18px;
color: #E0D4C2;
background:#212326;
padding: 45px 0 20px;
}
.navbar {
background-color: #2C2C2C;
background-image: -webkit-linear-gradient(top, #333, #222);
background-repeat: repeat-x;
box-shadow: rgba(0, 0, 0, 0.246094) 0px 1px 3px 0px, rgba(0, 0, 0, 0.0976563) 0px -1px 0px 0px inset;
position: fixed;
left: 0px;
right: 0px;
top: 0px;
color: #fff;
display: block;
height: 24px;
font-size: 20px;
font-weight: 200;
padding: 8px 50px;
}
.navbar .query {
background-color: #626262;
border-color: #151515;
border-radius: 14px 14px 14px 14px;
border-style: solid;
border-width: 1px;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.098) inset, 0 1px 0 0 rgba(255, 255, 255, 0.15);
color: white;
display: inline-block;
float: right;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 13px;
height: 18px;
line-height: 13px;
margin-top: -2px;
padding: 4px 9px;
width: 160px;
}
.navbar .query:focus,
.navbar .query.focused {
padding: 5px 10px;
color: #333333;
text-shadow: 0 1px 0 #ffffff;
background-color: #ffffff;
border: 0;
-webkit-box-shadow: 0 0 3px rgba(0, 0, 0, 0.15);
-moz-box-shadow: 0 0 3px rgba(0, 0, 0, 0.15);
box-shadow: 0 0 3px rgba(0, 0, 0, 0.15);
outline: 0;
}
.log {
white-space: pre-wrap;
}
.log .inner-line {
padding: 0 50px;
margin-left: 96pt;
text-indent: -96pt;
}
.log .line.selected {
background-color: #412A4F;
}

View File

@ -3,7 +3,7 @@
<head>
<title>tail -F __TITLE__</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="/styles.css">
<link rel="stylesheet" type="text/css" href="/styles/__THEME__.css">
</head>
<body>
<div class="navbar">

View File

@ -77,7 +77,10 @@ var connectBuilder = require('../lib/connect_builder');
});
it('returns app that replace index title', function (done) {
var app = connectBuilder().index(__dirname + '/fixtures/index_with_title', 'Test').build();
var app = connectBuilder().index(
__dirname + '/fixtures/index_with_title',
{ 'title': 'Test', 'theme': 'default' })
.build();
app
.request()