nice minimal example node server serving outstanding issues

This commit is contained in:
Radek Stepan 2012-05-22 17:29:38 +01:00
parent 47868fad8a
commit f095be9b1a
4 changed files with 98 additions and 245 deletions

View File

@ -33,15 +33,15 @@ app.configure 'production', ->
app.use express.errorHandler()
# Routes
app.get '/', (req, res) ->
app.get '/issues', (req, res) ->
https.request(options, (response) ->
if response.statusCode is 200
str = ""
response.on "data", (chunk) -> str += chunk
json = ""
response.on "data", (chunk) -> json += chunk
response.on "end", ->
res.render 'index',
'issues': str
res.render 'issues',
'issues': JSON.parse json
, (html) -> res.send html, 'Content-Type': 'text/html', 200
).end()

View File

@ -1,228 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>GitHub Issues Burndown Chart</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/burndown.js"></script>
</head>
<body>
<header class="navbar blue blue2 navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<ul class="nav pull-left">
<li class="active"><a href="#"><i class="icon-white icon-fire"></i> Burn down</a></li>
</ul>
<ul class="nav pull-right">
<li><a href="#"><i class="icon-white icon-book"></i> Core InterMine Project</a></li>
</ul>
</div>
</div>
</header>
<section class="container-fluid pad40">
<section class="row-fluid">
<div class="span2 sideBar">
<br>
<ul>
<li class="active">
<figure>
<i class="icon-fire"></i> Burn down &nbsp;&nbsp;<span class="badge badge-warning">0.7</span>
</figure>
</li>
<li>
<figure>
<i class="icon-tasks"></i> Projects &nbsp;&nbsp;<span class="badge badge-info">4</span>
</figure>
</li>
</ul>
</div>
<section class="span10 content borBox"><div class="row-fluid">
<div class="page-header">
<h1>Burn down chart <small>to keep us on track</small></h1>
</div>
</div>
<br>
<div class="row-fluid">
<div class="span12">
<table class="table table-bordered">
<thead>
<tr><th>#</th>
<th>Date</th>
<th>Title</th>
<th>Description</th>
<th>Amount Due</th>
<th>Actions</th>
<th><input id="checkall" type="checkbox"></th>
</tr></thead>
<tbody>
<tr>
<td>1</td>
<td>4/3/12</td>
<td>Yammer-Design</td>
<td>Design new logo for Yammer.Inc</td>
<td>$450</td>
<td>
<div class="btn-group sharp" data-toggle="radio">
<button class="btn btn-mini btn-success"><i class="icon-white icon-shopping-cart"></i></button>
<button class="btn btn-mini btn-success"><i class="icon-white icon-pencil"></i></button>
<button class="btn btn-mini btn-success"><i class="icon-white icon-eye-open"></i></button>
</div>
</td>
<td><input type="checkbox"></td>
</tr>
<tr>
<td>2</td>
<td>4/3/12</td>
<td>Yammer-Design</td>
<td>Design new logo for Yammer.Inc</td>
<td>$450</td>
<td>
<div class="btn-group sharp" data-toggle="radio">
<button class="btn btn-mini btn-success"><i class="icon-white icon-shopping-cart"></i></button>
<button class="btn btn-mini btn-success"><i class="icon-white icon-pencil"></i></button>
<button class="btn btn-mini btn-success"><i class="icon-white icon-eye-open"></i></button>
</div>
</td>
<td><input type="checkbox"></td>
</tr>
<tr>
<td>3</td>
<td>4/3/12</td>
<td>Yammer-Design</td>
<td>Design new logo for Yammer.Inc</td>
<td>$450</td>
<td>
<div class="btn-group sharp" data-toggle="radio">
<button class="btn btn-mini btn-success"><i class="icon-white icon-shopping-cart"></i></button>
<button class="btn btn-mini btn-success"><i class="icon-white icon-pencil"></i></button>
<button class="btn btn-mini btn-success"><i class="icon-white icon-eye-open"></i></button>
</div>
</td>
<td><input type="checkbox"></td>
</tr>
<tr>
<td>4</td>
<td>4/3/12</td>
<td>Yammer-Design</td>
<td>Design new logo for Yammer.Inc</td>
<td>$450</td>
<td>
<div class="btn-group sharp" data-toggle="radio">
<button class="btn btn-mini btn-success"><i class="icon-white icon-shopping-cart"></i></button>
<button class="btn btn-mini btn-success"><i class="icon-white icon-pencil"></i></button>
<button class="btn btn-mini btn-success"><i class="icon-white icon-eye-open"></i></button>
</div>
</td>
<td><input type="checkbox"></td>
</tr>
<tr>
<td>5</td>
<td>4/3/12</td>
<td>Yammer-Design</td>
<td>Design new logo for Yammer.Inc</td>
<td>$450</td>
<td>
<div class="btn-group sharp" data-toggle="radio">
<button class="btn btn-mini btn-success"><i class="icon-white icon-shopping-cart"></i></button>
<button class="btn btn-mini btn-success"><i class="icon-white icon-pencil"></i></button>
<button class="btn btn-mini btn-success"><i class="icon-white icon-eye-open"></i></button>
</div>
</td>
<td><input type="checkbox"></td>
</tr>
<tr>
<td>6</td>
<td>4/3/12</td>
<td>Yammer-Design</td>
<td>Design new logo for Yammer.Inc</td>
<td>$450</td>
<td>
<div class="btn-group sharp" data-toggle="radio">
<button class="btn btn-mini btn-success"><i class="icon-white icon-shopping-cart"></i></button>
<button class="btn btn-mini btn-success"><i class="icon-white icon-pencil"></i></button>
<button class="btn btn-mini btn-success"><i class="icon-white icon-eye-open"></i></button>
</div>
</td>
<td><input type="checkbox"></td>
</tr>
<tr>
<td>7</td>
<td>4/3/12</td>
<td>Yammer-Design</td>
<td>Design new logo for Yammer.Inc</td>
<td>$450</td>
<td>
<div class="btn-group sharp" data-toggle="radio">
<button class="btn btn-mini btn-success"><i class="icon-white icon-shopping-cart"></i></button>
<button class="btn btn-mini btn-success"><i class="icon-white icon-pencil"></i></button>
<button class="btn btn-mini btn-success"><i class="icon-white icon-eye-open"></i></button>
</div>
</td>
<td><input type="checkbox"></td>
</tr>
<tr>
<td>8</td>
<td>4/3/12</td>
<td>Yammer-Design</td>
<td>Design new logo for Yammer.Inc</td>
<td>$450</td>
<td>
<div class="btn-group sharp" data-toggle="radio">
<button class="btn btn-mini btn-success"><i class="icon-white icon-shopping-cart"></i></button>
<button class="btn btn-mini btn-success"><i class="icon-white icon-pencil"></i></button>
<button class="btn btn-mini btn-success"><i class="icon-white icon-eye-open"></i></button>
</div>
</td>
<td><input type="checkbox"></td>
</tr>
<tr>
<td>9</td>
<td>4/3/12</td>
<td>Yammer-Design</td>
<td>Design new logo for Yammer.Inc</td>
<td>$450</td>
<td>
<div class="btn-group sharp" data-toggle="radio">
<button class="btn btn-mini btn-success"><i class="icon-white icon-shopping-cart"></i></button>
<button class="btn btn-mini btn-success"><i class="icon-white icon-pencil"></i></button>
<button class="btn btn-mini btn-success"><i class="icon-white icon-eye-open"></i></button>
</div>
</td>
<td><input type="checkbox"></td>
</tr>
<tr>
<td>10</td>
<td>4/3/12</td>
<td>Yammer-Design</td>
<td>Design new logo for Yammer.Inc</td>
<td>$450</td>
<td>
<div class="btn-group sharp" data-toggle="radio">
<button class="btn btn-mini btn-success"><i class="icon-white icon-shopping-cart"></i></button>
<button class="btn btn-mini btn-success"><i class="icon-white icon-pencil"></i></button>
<button class="btn btn-mini btn-success"><i class="icon-white icon-eye-open"></i></button>
</div>
</td>
<td><input type="checkbox"></td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
</section>
</section>
</body>
</html>

View File

@ -1,12 +0,0 @@
<!doctype html>
<html>
<head>
<title>Express</title>
<link rel="stylesheet" href="/stylesheets/style.css"/>
</head>
<body>
<h1>Express</h1>
<p>Welcome to Express</p>
<code><%- @issues %></code>
</body>
</html>

93
templates/issues.eco Normal file
View File

@ -0,0 +1,93 @@
<!doctype html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>Burndown App</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/burndown.js"></script>
</head>
<body>
<header class="navbar blue blue2 navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<ul class="nav pull-left">
<li><a><i class="icon-white icon-fire"></i> Burndown App</a></li>
</ul>
<ul class="nav pull-right">
<li><a><i class="icon-white icon-book"></i> Core InterMine Project</a></li>
</ul>
</div>
</div>
</header>
<section class="container-fluid pad40">
<section class="row-fluid">
<div class="span2 sideBar">
<br>
<ul>
<li>
<figure>
<i class="icon-signal"></i> Burndown Chart &nbsp;&nbsp;<span class="badge badge-warning">0.7</span>
</figure>
</li>
<li class="active">
<figure>
<i class="icon-tasks"></i> Issues &nbsp;&nbsp;<span class="badge badge-info"><%= @issues.length %></span>
</figure>
</li>
</ul>
</div>
<section class="span10 content borBox">
<div class="row-fluid">
<div class="page-header">
<h1>List of outstanding issues</h1>
</div>
</div>
<br>
<div class="row-fluid">
<div class="span12">
<table class="table table-bordered">
<thead>
<tr>
<th>#</th>
<th>Title</th>
<th>Opened</th>
<th>Updated</th>
<th>Opened By</th>
<th>Assigned To</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<% for issue in @issues: %>
<tr>
<td><%= issue.number %></td>
<td><%= issue.title %></td>
<td><%= issue.created_at %></td>
<td><%= issue.updated_at %></td>
<td><%= issue.user.login %></td>
<td><%= issue.assignee?.login %></td>
<td>
<a target="_new" href="<%= issue.html_url %>">
<button class="btn btn-mini btn-success"><i class="icon-white icon-eye-open"></i></button>
</a>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</section>
</section>
</section>
</body>
</html>