summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorJason Croft2016-05-13 10:00:34 -0400
committerJason Croft2016-05-13 10:00:34 -0400
commitedcb766b63694948b91094995ca7720c1ea222c3 (patch)
treedec62a6567e429b76d1e11f8e243d08ae6b22cb9 /public
parentba0a8f584a0655552e3ed95cd5ef006eeb408eef (diff)
Apply "snippets_enabled only" logic to import modal.
Better parsing for snippet import. Add python filetype.
Diffstat (limited to 'public')
-rw-r--r--public/js/index.js19
1 files changed, 14 insertions, 5 deletions
diff --git a/public/js/index.js b/public/js/index.js
index fbaf95fb..a1e0445b 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -250,8 +250,9 @@ var fileTypes = {
"php": "php",
"sh": "bash",
"rb": "ruby",
- "html": "html"
-}
+ "html": "html",
+ "py": "python"
+};
//editor settings
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);
});
data.projects.forEach(function(project) {
+ if (!project.snippets_enabled) {
+ return;
+ }
$('<option>').val(project.id).text(project.path_with_namespace).appendTo("#snippetImportModalProjects");
});
$("#snippetImportModalProjects").prop('disabled',false);
@@ -1484,13 +1488,18 @@ $("#snippetImportModalConfirm").click(function () {
.success(function(data) {
var content = '# ' + (data.title || "Snippet Import");
var fileInfo = data.file_name.split('.');
+ fileInfo[1] = (fileInfo[1]) ? fileInfo[1] : "md";
$.get(fullURL + '/raw' + accessToken)
.success(function (raw) {
if (raw) {
- content += "\n\n```";
- content += fileTypes[fileInfo[1]] + "=\n";
+ content += "\n\n";
+ if (fileInfo[1] != "md") {
+ content += "```" + fileTypes[fileInfo[1]] + "\n";
+ }
content += raw;
- content += "\n```";
+ if (fileInfo[1] != "md") {
+ content += "\n```";
+ }
replaceAll(content);
}
})