| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,19 +1,9 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | - function base64(str) { | ||
| 5 | - return 'data:image/png;base64,' + str.toString('base64'); | ||
| 6 | - } | ||
| 7 | - | ||
| 8 | - | ||
| 9 | 4 | module.exports = function content(grunt) { | |
| 10 | 5 | ||
| 11 | - var src = 'dist/all.js', | ||
| 12 | - tokens = { | ||
| 13 | - logo: '$LOGO$', | ||
| 14 | - primary: '$WORDMARK_PRIMARY$', | ||
| 15 | - secondary: '$WORDMARK_SECONDARY$' | ||
| 16 | - }; | ||
| 6 | + var src = 'dist/all.js'; | ||
| 17 | 7 | ||
| 18 | 8 | function processContent(str) { | |
| 19 | 9 | var bundles = grunt.file.expand('locales/**/*.properties'), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,21 +8,26 @@ function base64(str) { | |||
| 8 | 8 | ||
| 9 | 9 | module.exports = function images(grunt) { | |
| 10 | 10 | ||
| 11 | - var src = 'dist/all.js', | ||
| 12 | - tokens = { | ||
| 13 | - logo: '$LOGO$', | ||
| 14 | - primary: '$WORDMARK_PRIMARY$', | ||
| 15 | - secondary: '$WORDMARK_SECONDARY$' | ||
| 16 | - }; | ||
| 11 | + var src = 'dist/all.js'; | ||
| 17 | 12 | ||
| 18 | 13 | function processImages(str) { | |
| 19 | - var logo = grunt.file.read('src/theme/images/logo.png', { encoding: null }), | ||
| 20 | - primary = grunt.file.read('src/theme/images/wordmark_white.png', { encoding: null }), | ||
| 21 | - secondary = grunt.file.read('src/theme/images/wordmark_blue.png', { encoding: null }); | ||
| 22 | - | ||
| 23 | - str = str.replace(tokens.logo, base64(logo)); | ||
| 24 | - str = str.replace(tokens.primary, base64(primary)); | ||
| 25 | - str = str.replace(tokens.secondary, base64(secondary)); | ||
| 14 | + var files = grunt.file.expand('src/theme/images/*.*'), | ||
| 15 | + templates = {}, | ||
| 16 | + name, | ||
| 17 | + token, | ||
| 18 | + contents; | ||
| 19 | + | ||
| 20 | + files.forEach(function (file) { | ||
| 21 | + name = file.split(/src\/theme\/images\/(.*)\.(.*)/); | ||
| 22 | + token = '$' + name[1].toUpperCase() + '$'; | ||
| 23 | + contents = grunt.file.read(file, { encoding: null }); | ||
| 24 | + | ||
| 25 | + if (contents) { | ||
| 26 | + str = str.replace(token, base64(contents)); | ||
| 27 | + } else { | ||
| 28 | + grunt.fail.warn('Looks like ' + file + ' is missing. Check that it exists.'); | ||
| 29 | + } | ||
| 30 | + }); | ||
| 26 | 31 | ||
| 27 | 32 | return str; | |
| 28 | 33 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments