Skip to content

Commit

Permalink
fixing some creepy bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
daonb committed May 23, 2012
1 parent ce3c531 commit 3a0b0f2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
7 changes: 2 additions & 5 deletions lib/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ module.exports = function(app){
});
}
else {
if(path.substr(path.length - 1, 1) !== '/'){
path += '/';
}
var o;
if (app.enabled('local'))
o = {
Expand All @@ -42,9 +39,9 @@ module.exports = function(app){
path: '/api/v2'+path
};

console.log('Got request to', path);
console.log('>>> passing request to', o.path);
http.get(o, function(res){
console.log('Got response from',path,'with status',res.statusCode);
console.log('<<< Got response from',o.path,'with status',res.statusCode);
if(res.statusCode === 200){
var data = [];
res.on('data', function(chunk){
Expand Down
10 changes: 6 additions & 4 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@ module.exports = function(app) {
* @param res
*/
api: function(req, res, next){
console.log('LOG: API call to ', req.params.path);
rest.get(req.path.substr(7), function(err, data){
var uri = req.originalUrl.substr(7)
console.log('LOG: API call to ', uri);
rest.get(uri, function(err, data){
res.send(data)
})
})
},
get: function(req, res, next){
var controller = req.params.controller,
id = req.params.id,
action = req.params.action || (id ? 'show' : 'index');

if(~req.path.indexOf('css') || ~req.path.indexOf('txt') ||
~req.path.indexOf('js') || ~req.path.indexOf('img')){
~req.path.indexOf('js') || ~req.path.indexOf('img') ||
controller == 'api') {
next();
} else {
rest.get(req.path, function(err, data){
Expand Down
4 changes: 2 additions & 2 deletions views/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
<a class="brand" href="{{main_url}}">כנסת פתוחה</a>
<div class="nav-collapse">
<ul class="nav">
<li id="bill-nav"><a href="/bill">חקיקה</a></li>
<li id="bill-nav"><a href="/bill/">חקיקה</a></li>
<li><a href="#">ועדות</a></li>
<li id="member-nav"><a href="/member">חברי כנסת</a></li>
<li id="member-nav"><a href="/member/">חברי כנסת</a></li>
</ul>
<div id="search" class="pull-right navbar-search">{{search_form}}</div>
<ul class="nav pull-right">
Expand Down

0 comments on commit 3a0b0f2

Please sign in to comment.