Skip to content

Commit

Permalink
BDE-139: Remove highlighting from FF extension
Browse files Browse the repository at this point in the history
  • Loading branch information
ktouchie committed Jun 4, 2018
1 parent 4cff639 commit 0735c0e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
1 change: 0 additions & 1 deletion app/json.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<script src="scripts/browser.js"></script>
<script src="scripts/background.js"></script>
<script src="scripts/json.js"></script>
<script src="libs/highlight.js"></script>

</body>
</html>
6 changes: 5 additions & 1 deletion app/scripts.babel/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ limitations under the License.
$(() => {
chrome.runtime.getBackgroundPage((bkg) => {
document.getElementById('json-string').textContent = bkg._text;
hljs.initHighlighting();
try {
hljs.initHighlighting();
} catch (e) {
console.log('Sorry! JSON highlighting only available in Chrome.');
}
});
});
28 changes: 26 additions & 2 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ function prependScript(node, file) {
node.prepend(`<script src="${file}"></script>`);
}

function appendScript(node, file) {
node.append(`<script src="${file}"></script>`);
}

gulp.task('lint', lint([
'app/scripts.babel/*.js',
'app/vendor.babel/**/*.js',
Expand All @@ -136,6 +140,7 @@ gulp.task('extras', () => {
'app/*.*',
'app/_locales/**',
'app/libs/**',
'!app/libs/highlight.js',
'!app/vendor.babel',
'!app/scripts.babel',
'!app/*.json',
Expand Down Expand Up @@ -197,6 +202,7 @@ gulp.task('build:chrome', ['build:base'], (done) => {
}
gulp.src(dist('base', '**/*'))
.pipe(filter(['**', '!**/about.html']))
.pipe(filter(['**', '!**/json.html']))
.pipe(gulp.dest(dist('chrome')));

gulp.src(dist('base', 'about.html'))
Expand All @@ -207,6 +213,15 @@ gulp.task('build:chrome', ['build:base'], (done) => {
}))
.pipe(gulp.dest(dist('chrome')));

gulp.src(dist('base', 'json.html'))
.pipe(cheerio(($) => {
const $body = $('body');
appendScript($body, 'libs/highlight.js');
}))
.pipe(gulp.dest(dist('chrome')));

gulp.src('app/libs/highlight.js').pipe(gulp.dest(dist('chrome/libs')));

util.log(`Building Chrome Extension: ${version}`);

gulp.src('app/vendor/chrome/manifest.json')
Expand All @@ -233,6 +248,15 @@ gulp.task('build:sinon-chrome', ['build:chrome'], () => {
.pipe(filter(['**', '!**/es-reindex.html']))
.pipe(gulp.dest(dist(target)));

gulp.src(dist('base', 'json.html'))
.pipe(cheerio(($) => {
const $body = $('body');
appendScript($body, 'libs/highlight.js');
}))
.pipe(gulp.dest(dist('chrome')));

gulp.src('app/libs/highlight.js').pipe(gulp.dest(dist('chrome/libs')));

// Add sinon-chrome.min script
gulp.src(require.resolve('sinon-chrome/bundle/sinon-chrome.min.js'))
.pipe(gulp.dest(dist(target, 'scripts')))
Expand All @@ -251,7 +275,7 @@ gulp.task('build:sinon-chrome', ['build:chrome'], () => {
const $head = $('head');
// !! Order matters; as we use `prepend`, last added will be first.
prependScript($head, 'scripts/background.js');
prependScript($head, 'scripts/injecter.js')
prependScript($head, 'scripts/injecter.js');
prependScript($head, 'scripts/sinon-chrome.min.js');
}))
.pipe(gulp.dest(dist(target)));
Expand All @@ -261,7 +285,7 @@ gulp.task('build:sinon-chrome', ['build:chrome'], () => {
const $head = $('head');
// !! Order matters; as we use `prepend`, last added will be first.
prependScript($head, 'scripts/background.js');
prependScript($head, 'scripts/injecter.js')
prependScript($head, 'scripts/injecter.js');
prependScript($head, 'scripts/sinon-chrome.min.js');
const date = new Date().getFullYear();
$('#version').text(`Version ${version}`);
Expand Down

0 comments on commit 0735c0e

Please sign in to comment.