2
0
mirror of https://github.com/tenrok/bootstrap.git synced 2026-06-11 18:02:28 +03:00

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/
This commit is contained in:
XhmikosR
2018-09-19 13:33:58 +03:00
parent 6de7ba427b
commit d7ab2fbd5b
+12 -54
View File
@@ -32,12 +32,6 @@ window.onload = function () { // wait for load in a dumb way because B-0
throw err throw err
} }
function showSuccess(msg) {
$('<div class="bs-callout bs-callout-info">' +
'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>' + msg +
'</div>').insertAfter('.bs-customize-download')
}
function showAlert(type, msg, insertAfter) { function showAlert(type, msg, insertAfter) {
$('<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>') $('<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>')
.insertAfter(insertAfter) .insertAfter(insertAfter)
@@ -49,42 +43,6 @@ window.onload = function () { // wait for load in a dumb way because B-0
return match && decodeURIComponent(match[1].replace(/\+/g, ' ')) return match && decodeURIComponent(match[1].replace(/\+/g, ' '))
} }
function createGist(configJson, callback) {
var data = {
description: 'Bootstrap Customizer Config',
'public': true,
files: {
'config.json': {
content: configJson
}
}
}
$.ajax({
url: 'https://api.github.com/gists',
type: 'POST',
contentType: 'application/json; charset=UTF-8',
dataType: 'json',
data: JSON.stringify(data)
})
.success(function (result) {
var gistUrl = result.html_url;
var origin = window.location.protocol + '//' + window.location.host
var customizerUrl = origin + window.location.pathname + '?id=' + result.id
showSuccess('<strong>Success!</strong> Your configuration has been saved to <a href="' + gistUrl + '">' + gistUrl + '</a> ' +
'and can be revisited here at <a href="' + customizerUrl + '">' + customizerUrl + '</a> for further customization.')
history.replaceState(false, document.title, customizerUrl)
callback(gistUrl, customizerUrl)
})
.error(function (err) {
try {
showError('<strong>Ruh roh!</strong> Could not save gist file, configuration not saved.', err)
} catch (sameErr) {
// deliberately ignore the error
}
callback('<none>', '<none>')
})
}
function getCustomizerData() { function getCustomizerData() {
var vars = {} var vars = {}
@@ -252,8 +210,8 @@ window.onload = function () { // wait for load in a dumb way because B-0
return promise.reject(parseErr) return promise.reject(parseErr)
} }
try { try {
intoResult[baseFilename + '.css'] = cw + tree.toCSS() intoResult[baseFilename + '.css'] = tree.toCSS()
intoResult[baseFilename + '.min.css'] = cw + tree.toCSS({ compress: true }) intoResult[baseFilename + '.min.css'] = tree.toCSS({ compress: true })
} catch (compileErr) { } catch (compileErr) {
return promise.reject(compileErr) return promise.reject(compileErr)
} }
@@ -335,7 +293,7 @@ window.onload = function () { // wait for load in a dumb way because B-0
.toArray() .toArray()
.join('\n') .join('\n')
preamble = cw + preamble preamble = preamble + cw
js = jqueryCheck + jqueryVersionCheck + js js = jqueryCheck + jqueryVersionCheck + js
return { return {
@@ -437,21 +395,19 @@ window.onload = function () { // wait for load in a dumb way because B-0
var $compileBtn = $('#btn-compile') var $compileBtn = $('#btn-compile')
$compileBtn.on('click', function (e) { $compileBtn.on('click', function (e) {
var configData = getCustomizerData()
var configJson = JSON.stringify(configData, null, 2)
e.preventDefault() e.preventDefault()
$compileBtn.attr('disabled', 'disabled') $compileBtn.attr('disabled', 'disabled')
createGist(configJson, function (gistUrl, customizerUrl) { function generate() {
configData.customizerUrl = customizerUrl var configData = getCustomizerData()
configJson = JSON.stringify(configData, null, 2) var configJson = JSON.stringify(configData, null, 2)
var origin = window.location.protocol + '//' + window.location.host
var customizerUrl = origin + window.location.pathname
var preamble = '/*!\n' + var preamble = '/*!\n' +
' * Generated using the Bootstrap Customizer (' + customizerUrl + ')\n' + ' * Generated using the Bootstrap Customizer (' + customizerUrl + ')\n' +
' * Config saved to config.json and ' + gistUrl + '\n' + ' */\n\n'
' */\n'
$.when( $.when(
generateCSS(preamble), generateCSS(preamble),
@@ -465,7 +421,9 @@ window.onload = function () { // wait for load in a dumb way because B-0
}, 0) }, 0)
}) })
}) })
}) }
generate()
}); });
parseUrl() parseUrl()