Skip to content

Commit 45f5841

Browse files
committed
Merge pull request twbs#15464 from twbs/address-15419
Address twbs#15419
2 parents 6c383c5 + 35073fc commit 45f5841

File tree

5 files changed

+54
-11
lines changed

5 files changed

+54
-11
lines changed

Gruntfile.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module.exports = function (grunt) {
1818
var fs = require('fs');
1919
var path = require('path');
2020
var npmShrinkwrap = require('npm-shrinkwrap');
21+
var generateGlyphiconsData = require('./grunt/bs-glyphicons-data-generator.js');
2122
var BsLessdocParser = require('./grunt/bs-lessdoc-parser.js');
2223
var getLessVarsData = function () {
2324
var filePath = path.join(__dirname, 'less/variables.less');
@@ -464,6 +465,8 @@ module.exports = function (grunt) {
464465
// This can be overzealous, so its changes should always be manually reviewed!
465466
grunt.registerTask('change-version-number', 'sed');
466467

468+
grunt.registerTask('build-glyphicons-data', function () { generateGlyphiconsData.call(this, grunt); });
469+
467470
// task for building customizer
468471
grunt.registerTask('build-customizer', ['build-customizer-html', 'build-raw-files']);
469472
grunt.registerTask('build-customizer-html', 'jade');
@@ -483,7 +486,7 @@ module.exports = function (grunt) {
483486
grunt.registerTask('lint-docs-css', ['csslint:docs', 'csslint:examples']);
484487
grunt.registerTask('docs-js', ['uglify:docsJs', 'uglify:customize']);
485488
grunt.registerTask('lint-docs-js', ['jshint:assets', 'jscs:assets']);
486-
grunt.registerTask('docs', ['docs-css', 'lint-docs-css', 'docs-js', 'lint-docs-js', 'clean:docs', 'copy:docs', 'build-customizer']);
489+
grunt.registerTask('docs', ['docs-css', 'lint-docs-css', 'docs-js', 'lint-docs-js', 'clean:docs', 'copy:docs', 'build-glyphicons-data', 'build-customizer']);
487490

488491
grunt.registerTask('prep-release', ['jekyll:github', 'compress']);
489492

dist/css/bootstrap.css

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/_data/glyphicons.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- glyphicon-asterisk
55
- glyphicon-plus
66
- glyphicon-euro
7+
- glyphicon-eur
78
- glyphicon-minus
89
- glyphicon-cloud
910
- glyphicon-envelope
@@ -207,8 +208,6 @@
207208
- glyphicon-level-up
208209
- glyphicon-copy
209210
- glyphicon-paste
210-
- glyphicon-door
211-
- glyphicon-key
212211
- glyphicon-alert
213212
- glyphicon-equalizer
214213
- glyphicon-king

grunt/bs-glyphicons-data-generator.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*!
2+
* Bootstrap Grunt task for Glyphicons data generation
3+
* http://getbootstrap.com
4+
* Copyright 2014 Twitter, Inc.
5+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
6+
*/
7+
'use strict';
8+
var fs = require('fs');
9+
10+
module.exports = function generateGlyphiconsData(grunt) {
11+
// Pass encoding, utf8, so `readFileSync` will return a string instead of a
12+
// buffer
13+
var glyphiconsFile = fs.readFileSync('less/glyphicons.less', 'utf8');
14+
var glyphiconsLines = glyphiconsFile.split('\n');
15+
16+
// Use any line that starts with ".glyphicon-" and capture the class name
17+
var iconClassName = /^\.(glyphicon-[a-zA-Z0-9-]+)/;
18+
var glyphiconsData = '# This file is generated via Grunt task. **Do not edit directly.**\n' +
19+
'# See the \'build-glyphicons-data\' task in Gruntfile.js.\n\n';
20+
var glyphiconsYml = 'docs/_data/glyphicons.yml';
21+
for (var i = 0, len = glyphiconsLines.length; i < len; i++) {
22+
var match = glyphiconsLines[i].match(iconClassName);
23+
24+
if (match !== null) {
25+
glyphiconsData += '- ' + match[1] + '\n';
26+
}
27+
}
28+
29+
// Create the `_data` directory if it doesn't already exist
30+
if (!fs.existsSync('docs/_data')) {
31+
fs.mkdirSync('docs/_data');
32+
}
33+
34+
try {
35+
fs.writeFileSync(glyphiconsYml, glyphiconsData);
36+
}
37+
catch (err) {
38+
grunt.fail.warn(err);
39+
}
40+
grunt.log.writeln('File ' + glyphiconsYml.cyan + ' created.');
41+
};

less/glyphicons.less

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,14 @@
239239
.glyphicon-level-up { &:before { content: "\e204"; } }
240240
.glyphicon-copy { &:before { content: "\e205"; } }
241241
.glyphicon-paste { &:before { content: "\e206"; } }
242-
.glyphicon-door { &:before { content: "\1f6aa"; } }
243-
.glyphicon-key { &:before { content: "\1f511"; } }
242+
// The following 2 Glyphicons are omitted for the time being because
243+
// they currently use Unicode codepoints that are outside the
244+
// Basic Multilingual Plane (BMP). Older buggy versions of WebKit can't handle
245+
// non-BMP codepoints in CSS string escapes, and thus can't display these two icons.
246+
// Notably, the bug affects some older versions of the Android Browser.
247+
// More info: https://github.com/twbs/bootstrap/issues/10106
248+
// .glyphicon-door { &:before { content: "\1f6aa"; } }
249+
// .glyphicon-key { &:before { content: "\1f511"; } }
244250
.glyphicon-alert { &:before { content: "\e209"; } }
245251
.glyphicon-equalizer { &:before { content: "\e210"; } }
246252
.glyphicon-king { &:before { content: "\e211"; } }

0 commit comments

Comments
 (0)