Apply "snippets_enabled only" logic to import modal.
Better parsing for snippet import. Add python filetype.
This commit is contained in:
parent
ba0a8f584a
commit
edcb766b63
1 changed files with 14 additions and 5 deletions
|
@ -250,8 +250,9 @@ var fileTypes = {
|
||||||
"php": "php",
|
"php": "php",
|
||||||
"sh": "bash",
|
"sh": "bash",
|
||||||
"rb": "ruby",
|
"rb": "ruby",
|
||||||
"html": "html"
|
"html": "html",
|
||||||
}
|
"py": "python"
|
||||||
|
};
|
||||||
|
|
||||||
//editor settings
|
//editor settings
|
||||||
var textit = document.getElementById("textit");
|
var textit = document.getElementById("textit");
|
||||||
|
@ -1248,6 +1249,9 @@ ui.toolbar.import.snippet.click(function () {
|
||||||
return (a.path_with_namespace < b.path_with_namespace) ? -1 : ((a.path_with_namespace > b.path_with_namespace) ? 1 : 0);
|
return (a.path_with_namespace < b.path_with_namespace) ? -1 : ((a.path_with_namespace > b.path_with_namespace) ? 1 : 0);
|
||||||
});
|
});
|
||||||
data.projects.forEach(function(project) {
|
data.projects.forEach(function(project) {
|
||||||
|
if (!project.snippets_enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$('<option>').val(project.id).text(project.path_with_namespace).appendTo("#snippetImportModalProjects");
|
$('<option>').val(project.id).text(project.path_with_namespace).appendTo("#snippetImportModalProjects");
|
||||||
});
|
});
|
||||||
$("#snippetImportModalProjects").prop('disabled',false);
|
$("#snippetImportModalProjects").prop('disabled',false);
|
||||||
|
@ -1484,13 +1488,18 @@ $("#snippetImportModalConfirm").click(function () {
|
||||||
.success(function(data) {
|
.success(function(data) {
|
||||||
var content = '# ' + (data.title || "Snippet Import");
|
var content = '# ' + (data.title || "Snippet Import");
|
||||||
var fileInfo = data.file_name.split('.');
|
var fileInfo = data.file_name.split('.');
|
||||||
|
fileInfo[1] = (fileInfo[1]) ? fileInfo[1] : "md";
|
||||||
$.get(fullURL + '/raw' + accessToken)
|
$.get(fullURL + '/raw' + accessToken)
|
||||||
.success(function (raw) {
|
.success(function (raw) {
|
||||||
if (raw) {
|
if (raw) {
|
||||||
content += "\n\n```";
|
content += "\n\n";
|
||||||
content += fileTypes[fileInfo[1]] + "=\n";
|
if (fileInfo[1] != "md") {
|
||||||
|
content += "```" + fileTypes[fileInfo[1]] + "\n";
|
||||||
|
}
|
||||||
content += raw;
|
content += raw;
|
||||||
content += "\n```";
|
if (fileInfo[1] != "md") {
|
||||||
|
content += "\n```";
|
||||||
|
}
|
||||||
replaceAll(content);
|
replaceAll(content);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue