<commit_before>var express = require('express');
var app = module.exports = express();
var api = require('lib/db-api');
var config = require('lib/config');
var path = require('path');
var resolve = path.resolve;
var log = require('debug')('democracyos:facebook-card');

app.get('/law/:id', function(req, res, next){    
  log('Facebook Request /law/%s', req.params.id);
  api.law.get(req.params.id, function (err, lawDoc) {
    if (err) return _handleError(err, req, res);
    log('Serving Facebook law %s', lawDoc.id);
    var baseUrl = config.protocol + "://" + config.host + (config.host=="localhost" ? (":" + config.port) : "");
    res.render(resolve(__dirname, 'law.jade'),
                       { law: lawDoc,
                         baseUrl : baseUrl,
                         config : config
                       });
  });
})

app.get('*', function(req, res, next){    
  log('Facebook Request generic page');
  var baseUrl = config.protocol + "://" + config.host + (config.host=="localhost" ? (":" + config.port) : "");
  res.render(resolve(__dirname, 'generic.jade'),
                     { baseUrl : baseUrl,
                      config : config});
})<commit_msg>[facebook-card] - User url component to build urls<commit_after>var express = require('express');
var app = module.exports = express();
var api = require('lib/db-api');
var config = require('lib/config');
var path = require('path');
var url = require('url');
var resolve = path.resolve;
var log = require('debug')('democracyos:facebook-card');

app.get('/law/:id', function(req, res, next){    
  log('Facebook Request /law/%s', req.params.id);
  api.law.get(req.params.id, function (err, lawDoc) {
    if (err) return _handleError(err, req, res);
    log('Serving Facebook law %s', lawDoc.id);
    var baseUrl = url.format({
        protocol: config('protocol')
      , hostname: config('host')
      , port: config('port')
    });
    res.render(resolve(__dirname, 'law.jade'),
                       { law: lawDoc,
                         baseUrl : baseUrl,
                         config : config
                       });
  });
})

app.get('*', function(req, res, next){    
  log('Facebook Request generic page');
  var baseUrl = url.format({
      protocol: config('protocol')
    , hostname: config('host')
    , port: config('port')
  });
  res.render(resolve(__dirname, 'generic.jade'),
                     { baseUrl : baseUrl,
                      config : config});
})
{'fraction_non_alphanumeric': 0.17525354969574036, 'fraction_numerical': 0.0, 'mean_word_length': 2.543103448275862, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2197473', 'n_tokens_mistral': 741, 'n_tokens_neox': 725, 'n_words': 173}