图片自动上传,代码测试编译错误过长。
This commit is contained in:
parent
5180fdab39
commit
a39702f962
2
Gemfile
2
Gemfile
|
@ -40,8 +40,6 @@ gem 'kaminari'
|
|||
gem 'elasticsearch-model'
|
||||
gem 'elasticsearch-rails'
|
||||
|
||||
gem 'certified'
|
||||
|
||||
group :development do
|
||||
gem 'grape-swagger'
|
||||
gem 'better_errors', '~> 1.1.0'
|
||||
|
|
|
@ -123,6 +123,7 @@ class StudentWorkController < ApplicationController
|
|||
#-1 默认值 0全部正确并结束 2 超时 -2 编译错误
|
||||
resultObj[:status] = -1
|
||||
resultObj[:results] = result["results"].first #本次测试结果
|
||||
result["error_msg"] = result["error_msg"][0..1023]
|
||||
resultObj[:error_msg] = result["error_msg"] #编译错误时的信息
|
||||
|
||||
#该状态用于存入CodeTests
|
||||
|
|
|
@ -145,11 +145,11 @@ class Kindeditor::AssetsController < ApplicationController
|
|||
Dir.mkdir(dirPath+dirDate)
|
||||
end
|
||||
|
||||
fileStr = []
|
||||
fileStr = ""
|
||||
|
||||
picArry.each_with_index do |picUrl,index|
|
||||
imgBaseName = File.basename(picUrl)
|
||||
tmpImgType = imgBaseName.split(".").last[0..2]
|
||||
tmpImgType = imgBaseName.split(".").last.split("?")[0]
|
||||
# 仅支持如下图片格式:bmp,jpeg,jpg,png,gif,BMP,JPEG,JPG,PNG,GIF
|
||||
|
||||
fileType = tmpImgType.match("gif|jpg|jpeg|png|bmp|BMP|JPEG|JPG|PNG|GIF")
|
||||
|
@ -161,10 +161,13 @@ class Kindeditor::AssetsController < ApplicationController
|
|||
fileDir = dirPath + dirDate + "/"+fileName
|
||||
|
||||
#重点!!
|
||||
begin
|
||||
File.open(fileDir,'wb'){ |f| f.write(open(picUrl).read) }
|
||||
fileDir = fileDir.split("public")[1]
|
||||
fileStr = filedir + "|"
|
||||
|
||||
rescue
|
||||
fileDir = picUrl
|
||||
end
|
||||
fileStr = fileStr+fileDir + "|"
|
||||
end
|
||||
render :text =>fileStr
|
||||
end
|
||||
|
|
|
@ -5993,10 +5993,24 @@ _plugin('core', function(K) {
|
|||
html = html.replace(/\n/g, '<br />$&');
|
||||
}
|
||||
}
|
||||
self.insertHtml(html, true);
|
||||
df();
|
||||
|
||||
// $("#ajax-indicator").hide();
|
||||
// var kePasteContainer = document.getElementById("ke_paste");
|
||||
// if (kePasteContainer == null) {
|
||||
// kePasteContainer = document.createElement("div");
|
||||
// kePasteContainer.id = "ke_paste";
|
||||
// var last=document.body.lastChild;//得到页面的最后个元素
|
||||
// document.body.insertBefore(kePasteContainer,last);//在得到的最后元素之前插入
|
||||
// }
|
||||
// kePasteContainer.innerHTML = html;
|
||||
// $("#ke_paste").hide();
|
||||
//
|
||||
// var imglist = $("#ke_paste").find("img");
|
||||
//
|
||||
// if (imglist.length > 0){
|
||||
// df(self);
|
||||
// }
|
||||
self.insertHtml(html, true);
|
||||
df(self);
|
||||
}
|
||||
K(doc.body).bind('paste', function(e){
|
||||
if (self.pasteType === 0) {
|
||||
|
|
|
@ -353,8 +353,11 @@ function enablePasteImg(_editor) {
|
|||
return;
|
||||
};
|
||||
|
||||
function df() {
|
||||
var img = $(".ke-edit-iframe").contents().find("img");
|
||||
//复制粘贴时把远程图片上传到服务器
|
||||
function df(myself) {
|
||||
// var img = $("#ke_paste").find("img");
|
||||
var currele = document.activeElement;
|
||||
var img = $(currele).contents().find("img");
|
||||
var piccount = 0;
|
||||
var sstr = "";
|
||||
$(img).each(function (i) {
|
||||
|
@ -367,24 +370,42 @@ function df() {
|
|||
sstr += that.attr("src") + "|";
|
||||
}
|
||||
});
|
||||
uploadpic(sstr);
|
||||
uploadpic(sstr,myself);
|
||||
}
|
||||
|
||||
function uploadpic(piclist) {
|
||||
function keShadow(myself)
|
||||
{
|
||||
var keShadowContainer = document.getElementById("ke_shadow");
|
||||
if (keShadowContainer == null) {
|
||||
keShadowContainer = document.createElement("div");
|
||||
keShadowContainer.id = "ke_shadow";
|
||||
keShadowContainer.innerHTML = "<div class='ui-widget-overlay' z-index: 1001;'></div>";
|
||||
$("#ajax-modal").after(keShadowContainer);
|
||||
}
|
||||
var tWidth = document.body.scrollWidth;
|
||||
var tHeight = document.body.scrollHeight;
|
||||
$(".ui-widget-overlay").css("width", tWidth);
|
||||
$(".ui-widget-overlay").css("height", tHeight);
|
||||
$("#ke_shadow").show();
|
||||
myself.readonly();
|
||||
}
|
||||
|
||||
function uploadpic(piclist,myself) {
|
||||
if (piclist.length == 0) return false;
|
||||
$.ajax({
|
||||
url: "/kindeditor/uploadpic",
|
||||
data: "pic=" + piclist,
|
||||
data:{"pic":piclist},
|
||||
type: "GET",
|
||||
beforeSend: function () {
|
||||
$("#ajax-indicator").text("图片上传中请稍等...");
|
||||
// $("#ajax-indicator span").text("图片上传中请稍等...");
|
||||
keShadow(myself);
|
||||
},
|
||||
success: function (msg) {
|
||||
if (msg !== "") {
|
||||
var str = new Array();
|
||||
str = msg.split('|');
|
||||
var img = $(".ke-edit-iframe").contents().find("img");
|
||||
|
||||
var currele = document.activeElement;
|
||||
var img = $(currele).contents().find("img");
|
||||
var tIndex = 0;
|
||||
$(img).each(function (i) {
|
||||
var that = $(this);
|
||||
|
@ -397,8 +418,15 @@ function uploadpic(piclist) {
|
|||
}
|
||||
});
|
||||
}
|
||||
// else $("#confirm").text("上传失败!");
|
||||
// $("#ajax-indicator span").text("载入中...");
|
||||
$("#ke_shadow").hide();
|
||||
myself.readonly(false);
|
||||
}
|
||||
}).fail(function(xhr, status){
|
||||
// $("#ajax-indicator span").text("载入中...");
|
||||
$("#ke_shadow").hide();
|
||||
myself.readonly(false);
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue