From 5738cd49fb7307dd5f6c203ff7db10364ea66afa Mon Sep 17 00:00:00 2001 From: ccd0 Date: Tue, 16 Jun 2015 09:48:09 -0700 Subject: [PATCH] Move CSS importing code into Gruntfile.coffee. --- Gruntfile.coffee | 7 +++++++ src/General/Main.coffee | 9 +-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Gruntfile.coffee b/Gruntfile.coffee index 49959fe56..f95978860 100755 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -8,6 +8,12 @@ module.exports = (grunt) -> json = (data) -> "`#{JSON.stringify(data).replace(/`/g, '\\`')}`" + importCSS = (filenames...) -> + grunt.template.process( + filenames.map((name) -> grunt.file.read "src/General/css/#{name}.css").join(''), + {data: grunt.config 'pkg'} + ).trim().replace(/\n+/g, '\n').split(/^/m).map(JSON.stringify).join(' +\n').replace(/`/g, '\\`') + importHTML = (filename) -> html grunt.template.process(grunt.file.read("src/General/html/#{filename}.html").replace(/^ +/gm, '').replace(/\r?\n/g, ''), data: grunt.config('pkg')) @@ -69,6 +75,7 @@ module.exports = (grunt) -> options: process: Object.create(null, data: get: -> pkg = grunt.config 'pkg' + pkg.importCSS = importCSS pkg.importHTML = importHTML pkg.html = html pkg.assert = assert diff --git a/src/General/Main.coffee b/src/General/Main.coffee index b0e6fcd5e..a29e2f10e 100755 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -301,14 +301,7 @@ Main = $.ready -> cb() if Main.isThisPageLegit() - css: `<%= - grunt.template.process( - ['font-awesome', 'style', 'yotsuba', 'yotsuba-b', 'futaba', 'burichan', 'tomorrow', 'photon'].map(function(name) { - return grunt.file.read('src/General/css/'+name+'.css'); - }).join(''), - {data: {type: type}} - ).trim().replace(/\n+/g, '\n').split(/^/m).map(JSON.stringify).join(' +\n').replace(/`/g, '\\`') - %>` + css: `<%= importCSS('font-awesome', 'style', 'yotsuba', 'yotsuba-b', 'futaba', 'burichan', 'tomorrow', 'photon') %>` features: [ ['Polyfill', Polyfill]