Skip to content

Commit d7ab2fb

Browse files
committed
customizer: remove gist creation.
GitHub removed anonymous gist creation a few months ago. https://blog.github.com/2018-02-18-deprecation-notice-removing-anonymous-gist-creation/
1 parent 6de7ba4 commit d7ab2fb

File tree

1 file changed

+12
-54
lines changed

1 file changed

+12
-54
lines changed

docs/assets/js/src/customizer.js

+12-54
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ window.onload = function () { // wait for load in a dumb way because B-0
3232
throw err
3333
}
3434

35-
function showSuccess(msg) {
36-
$('<div class="bs-callout bs-callout-info">' +
37-
'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>' + msg +
38-
'</div>').insertAfter('.bs-customize-download')
39-
}
40-
4135
function showAlert(type, msg, insertAfter) {
4236
$('<div class="alert alert-' + type + '">' + msg + '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>')
4337
.insertAfter(insertAfter)
@@ -49,42 +43,6 @@ window.onload = function () { // wait for load in a dumb way because B-0
4943
return match && decodeURIComponent(match[1].replace(/\+/g, ' '))
5044
}
5145

52-
function createGist(configJson, callback) {
53-
var data = {
54-
description: 'Bootstrap Customizer Config',
55-
'public': true,
56-
files: {
57-
'config.json': {
58-
content: configJson
59-
}
60-
}
61-
}
62-
$.ajax({
63-
url: 'https://api.github.com/gists',
64-
type: 'POST',
65-
contentType: 'application/json; charset=UTF-8',
66-
dataType: 'json',
67-
data: JSON.stringify(data)
68-
})
69-
.success(function (result) {
70-
var gistUrl = result.html_url;
71-
var origin = window.location.protocol + '//' + window.location.host
72-
var customizerUrl = origin + window.location.pathname + '?id=' + result.id
73-
showSuccess('<strong>Success!</strong> Your configuration has been saved to <a href="' + gistUrl + '">' + gistUrl + '</a> ' +
74-
'and can be revisited here at <a href="' + customizerUrl + '">' + customizerUrl + '</a> for further customization.')
75-
history.replaceState(false, document.title, customizerUrl)
76-
callback(gistUrl, customizerUrl)
77-
})
78-
.error(function (err) {
79-
try {
80-
showError('<strong>Ruh roh!</strong> Could not save gist file, configuration not saved.', err)
81-
} catch (sameErr) {
82-
// deliberately ignore the error
83-
}
84-
callback('<none>', '<none>')
85-
})
86-
}
87-
8846
function getCustomizerData() {
8947
var vars = {}
9048

@@ -252,8 +210,8 @@ window.onload = function () { // wait for load in a dumb way because B-0
252210
return promise.reject(parseErr)
253211
}
254212
try {
255-
intoResult[baseFilename + '.css'] = cw + tree.toCSS()
256-
intoResult[baseFilename + '.min.css'] = cw + tree.toCSS({ compress: true })
213+
intoResult[baseFilename + '.css'] = tree.toCSS()
214+
intoResult[baseFilename + '.min.css'] = tree.toCSS({ compress: true })
257215
} catch (compileErr) {
258216
return promise.reject(compileErr)
259217
}
@@ -335,7 +293,7 @@ window.onload = function () { // wait for load in a dumb way because B-0
335293
.toArray()
336294
.join('\n')
337295

338-
preamble = cw + preamble
296+
preamble = preamble + cw
339297
js = jqueryCheck + jqueryVersionCheck + js
340298

341299
return {
@@ -437,21 +395,19 @@ window.onload = function () { // wait for load in a dumb way because B-0
437395
var $compileBtn = $('#btn-compile')
438396

439397
$compileBtn.on('click', function (e) {
440-
var configData = getCustomizerData()
441-
var configJson = JSON.stringify(configData, null, 2)
442-
443398
e.preventDefault()
444399

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

447-
createGist(configJson, function (gistUrl, customizerUrl) {
448-
configData.customizerUrl = customizerUrl
449-
configJson = JSON.stringify(configData, null, 2)
402+
function generate() {
403+
var configData = getCustomizerData()
404+
var configJson = JSON.stringify(configData, null, 2)
405+
var origin = window.location.protocol + '//' + window.location.host
406+
var customizerUrl = origin + window.location.pathname
450407

451408
var preamble = '/*!\n' +
452409
' * Generated using the Bootstrap Customizer (' + customizerUrl + ')\n' +
453-
' * Config saved to config.json and ' + gistUrl + '\n' +
454-
' */\n'
410+
' */\n\n'
455411

456412
$.when(
457413
generateCSS(preamble),
@@ -465,7 +421,9 @@ window.onload = function () { // wait for load in a dumb way because B-0
465421
}, 0)
466422
})
467423
})
468-
})
424+
}
425+
426+
generate()
469427
});
470428

471429
parseUrl()

0 commit comments

Comments
 (0)