Skip to content

Commit

Permalink
added output for file name in compressed file
Browse files Browse the repository at this point in the history
  • Loading branch information
dtan committed Jun 27, 2011
1 parent 43f2608 commit c67e35c
Showing 1 changed file with 10 additions and 33 deletions.
43 changes: 10 additions & 33 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ var utils = require('./railway_utils'),
},
undef;

function generic_tag (name, inner, params, override) {
function generic_tag(name, inner, params, override) {
return '<' + name + html_tag_params(params, override) + '>' + inner + '</' + name + '>';
}

function generic_sc_tag (name, params, override) {
function generic_sc_tag(name, params, override) {
return '<' + name + html_tag_params(params, override) + ' />';
}

function data_param (key) {
function data_param(key) {
if (this[key]) {
this['data-' + key] = this[key];
delete this[key];
}
}

function HelperSet (ctl) {
function HelperSet(ctl) {
var controller = ctl;
this.controller = ctl;

Expand Down Expand Up @@ -82,18 +82,7 @@ HelperSet.prototype.stylesheet_link_tag = function () {
mergeFiles('stylesheets', args).forEach(function (file) {
delete options.href;
// there should be an option to change the /stylesheets/ folder
/*
var isExternalFile = regexps.isHttp.test(file),
isCached = file.match(regexps.cached),
href = !isExternalFile ? "/stylesheets/" + file + exts.css : file,
isProd = isProd();
*/
var href = checkFile('css', file);
/*
if (!isCached && !isProd && !isExternalFile) {
href += '?' + Date.now()
}
*/
links.push(generic_sc_tag('link', options, { href: href }));
});
return links.join('\n ');
Expand All @@ -119,19 +108,7 @@ HelperSet.prototype.javascript_include_tag = function () {
}
var scripts = [];
mergeFiles('javascripts', args).forEach(function (file) {
/*
var isExternalFile = regexps.isHttp.test(file),
isCached = regexps.cached.test(file),
// there should be an option to change the /javascripts/ folder
href = !isExternalFile ? "/javascripts/" + file + exts.js : file,
isProd = isProd();
*/
var href = checkFile('js', file);
/*
if (!isExternalFile && !isProd && !isCached) {
href += '?' + Date.now();
}
*/
delete options.src;
scripts.push(generic_tag('script', '', options, {src: href}));
});
Expand All @@ -143,15 +120,15 @@ var merged = {
javascripts: {ext: exts.js}
};

function mergeFiles (scope, files) {
function mergeFiles(scope, files) {
// ensure that feature is enabled
if (app.disabled('merge ' + scope)) {
return files;
}
var ext = merged[scope].ext;
var result = [];
var shasum = crypto.createHash('sha1');
var minify = [];
var ext = merged[scope].ext,
result = [],
shasum = crypto.createHash('sha1'),
minify = [];

// only merge local files
files.forEach(function (file) {
Expand All @@ -165,7 +142,6 @@ function mergeFiles (scope, files) {

// calculate name of new script based on names of merged files
var digest = shasum.digest('hex');

// check cache state (undefined = not cached, false = cache in progress, String = cached)
var cached = merged[scope][digest];
if (cached) {
Expand All @@ -188,6 +164,7 @@ function mergeFiles (scope, files) {
if (exists) {
counter += 1;
fs.readFile(filename, 'utf8', function (err, data) {
stream.write('// /' + scope + '/' + file + ext + '\n');
stream.write(data + '\n');
done();
});
Expand Down

0 comments on commit c67e35c

Please sign in to comment.