Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Gist & Customizer URLs to customized files & config.json #13205

Merged
merged 2 commits into from
Mar 28, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ module.exports = function (grunt) {
src: '<%= jshint.test.src %>'
},
assets: {
options: {
requireCamelCaseOrUpperCaseIdentifiers: null
},
src: '<%= jshint.assets.src %>'
}
},
Expand Down
2 changes: 1 addition & 1 deletion dist/css/bootstrap.css.map

Large diffs are not rendered by default.

36 changes: 24 additions & 12 deletions docs/assets/js/_src/customizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ window.onload = function () { // wait for load in a dumb way because B-0
return match && decodeURIComponent(match[1].replace(/\+/g, ' '))
}

function createGist(configJson) {
function createGist(configJson, callback) {
var data = {
description: 'Bootstrap Customizer Config',
'public': true,
Expand All @@ -61,10 +61,13 @@ window.onload = function () { // wait for load in a dumb way because B-0
})
.success(function (result) {
var origin = window.location.protocol + '//' + window.location.host
history.replaceState(false, document.title, origin + window.location.pathname + '?id=' + result.id)
var newUrl = origin + window.location.pathname + '?id=' + result.id
history.replaceState(false, document.title, newUrl)
callback(result.html_url, newUrl)
})
.error(function (err) {
showError('<strong>Ruh roh!</strong> Could not save gist file, configuration not saved.', err)
callback('<none>', '<none>')
})
}

Expand Down Expand Up @@ -221,7 +224,7 @@ window.onload = function () { // wait for load in a dumb way because B-0
})
}

function generateCSS() {
function generateCSS(preamble) {
var oneChecked = false
var lessFileIncludes = {}
$('#less-section input').each(function() {
Expand All @@ -242,8 +245,8 @@ window.onload = function () { // wait for load in a dumb way because B-0
$(this).val() && (vars[$(this).prev().text()] = $(this).val())
})

var bsLessSource = generateLESS('bootstrap.less', lessFileIncludes, vars)
var themeLessSource = generateLESS('theme.less', lessFileIncludes, vars)
var bsLessSource = preamble + generateLESS('bootstrap.less', lessFileIncludes, vars)
var themeLessSource = preamble + generateLESS('theme.less', lessFileIncludes, vars)

try {
compileLESS(bsLessSource, 'bootstrap', result)
Expand All @@ -255,7 +258,7 @@ window.onload = function () { // wait for load in a dumb way because B-0
return result
}

function generateJavascript() {
function generateJavascript(preamble) {
var $checked = $('#plugin-section input:checked')
if (!$checked.length) return false

Expand All @@ -265,8 +268,8 @@ window.onload = function () { // wait for load in a dumb way because B-0
.join('\n')

return {
'bootstrap.js': js,
'bootstrap.min.js': cw + uglify(js)
'bootstrap.js': preamble + js,
'bootstrap.min.js': preamble + cw + uglify(js)
}
}

Expand Down Expand Up @@ -322,10 +325,19 @@ window.onload = function () { // wait for load in a dumb way because B-0

$compileBtn.attr('disabled', 'disabled')

generateZip(generateCSS(), generateJavascript(), generateFonts(), configJson, function (blob) {
$compileBtn.removeAttr('disabled')
saveAs(blob, 'bootstrap.zip')
createGist(configJson)
createGist(configJson, function (gistUrl, customizerUrl) {
configData.customizerUrl = customizerUrl
configJson = JSON.stringify(configData, null, 2)

var preamble = '/*!\n' +
' * Generated using the Bootstrap Customizer (' + customizerUrl + ')\n' +
' * Config saved to config.json and ' + gistUrl + '\n' +
' */\n'

generateZip(generateCSS(preamble), generateJavascript(preamble), generateFonts(), configJson, function (blob) {
$compileBtn.removeAttr('disabled')
saveAs(blob, 'bootstrap.zip')
})
})
});

Expand Down
4 changes: 2 additions & 2 deletions docs/assets/js/customize.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/dist/css/bootstrap.css.map

Large diffs are not rendered by default.