复制外链图片, 复制到leanote
This commit is contained in:
@ -234,35 +234,39 @@ func (c File) CopyImage(userId, fileId, toUserId string) revel.Result {
|
|||||||
return c.RenderJson(re)
|
return c.RenderJson(re)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 复制外网的图片, 成公共图片 放在/upload下
|
// 复制外网的图片
|
||||||
// 都要好好的计算大小
|
// 都要好好的计算大小
|
||||||
func (c File) CopyHttpImage(src string) revel.Result {
|
func (c File) CopyHttpImage(src string) revel.Result {
|
||||||
re := info.NewRe()
|
re := info.NewRe()
|
||||||
fileUrlPath := "upload/" + c.GetUserId() + "/images"
|
|
||||||
dir := revel.BasePath + "/public/" + fileUrlPath
|
// 生成上传路径
|
||||||
|
newGuid := NewGuid()
|
||||||
|
userId := c.GetUserId()
|
||||||
|
fileUrlPath := "files/" + Digest3(userId) + "/" + userId + "/" + Digest2(newGuid) + "/images"
|
||||||
|
dir := revel.BasePath + "/" + fileUrlPath
|
||||||
err := os.MkdirAll(dir, 0755)
|
err := os.MkdirAll(dir, 0755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.RenderJson(re)
|
return c.RenderJson(re)
|
||||||
}
|
}
|
||||||
filesize, filename, _, ok := netutil.WriteUrl(src, dir)
|
filesize, filename, _, ok := netutil.WriteUrl(src, dir)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
re.Msg = "copy error"
|
re.Msg = "copy error"
|
||||||
return c.RenderJson(re)
|
return c.RenderJson(re)
|
||||||
}
|
}
|
||||||
|
|
||||||
// File
|
// File
|
||||||
fileInfo := info.File{Name: filename,
|
fileInfo := info.File{Name: filename,
|
||||||
Title: filename,
|
Title: filename,
|
||||||
Path: fileUrlPath + "/" + filename,
|
Path: fileUrlPath + "/" + filename,
|
||||||
Size: filesize}
|
Size: filesize}
|
||||||
|
|
||||||
id := bson.NewObjectId();
|
id := bson.NewObjectId()
|
||||||
fileInfo.FileId = id
|
fileInfo.FileId = id
|
||||||
|
|
||||||
re.Id = id.Hex()
|
re.Id = id.Hex()
|
||||||
re.Item = fileInfo.Path
|
// re.Item = fileInfo.Path
|
||||||
re.Ok, re.Msg = fileService.AddImage(fileInfo, "", c.GetUserId(), true)
|
re.Ok, re.Msg = fileService.AddImage(fileInfo, "", c.GetUserId(), true)
|
||||||
|
|
||||||
return c.RenderJson(re)
|
return c.RenderJson(re)
|
||||||
}
|
}
|
||||||
|
@ -47,8 +47,9 @@ define("tinymce/pasteplugin/Clipboard", [
|
|||||||
ajaxPost("/file/copyHttpImage", {src: src}, function(ret) {
|
ajaxPost("/file/copyHttpImage", {src: src}, function(ret) {
|
||||||
if(reIsOk(ret)) {
|
if(reIsOk(ret)) {
|
||||||
// 将图片替换之
|
// 将图片替换之
|
||||||
var src = urlPrefix + "/" + ret.Item;
|
// var src = urlPrefix + "/" + ret.Item;
|
||||||
var dom = editor.dom
|
var src = urlPrefix + "/file/outputImage?fileId=" + ret.Id;
|
||||||
|
var dom = editor.dom;
|
||||||
for(var i in ids) {
|
for(var i in ids) {
|
||||||
var id = ids[i];
|
var id = ids[i];
|
||||||
var imgElm = dom.get(id);
|
var imgElm = dom.get(id);
|
||||||
|
@ -44,26 +44,11 @@ define("tinymce/pasteplugin/Plugin", [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function togglePasteCopyImage() {
|
|
||||||
if (clipboard.copyImage) {
|
|
||||||
this.active(false);
|
|
||||||
clipboard.copyImage = false
|
|
||||||
} else {
|
|
||||||
clipboard.copyImage = true;
|
|
||||||
this.active(true);
|
|
||||||
if (!userIsInformed2) {
|
|
||||||
editor.windowManager.alert(
|
|
||||||
"When copy other site's images (not in leanote) into editor, it will copy the image into your album."
|
|
||||||
);
|
|
||||||
userIsInformed2 = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
self.clipboard = clipboard = new Clipboard(editor);
|
self.clipboard = clipboard = new Clipboard(editor);
|
||||||
self.quirks = new Quirks(editor);
|
self.quirks = new Quirks(editor);
|
||||||
self.wordFilter = new WordFilter(editor);
|
self.wordFilter = new WordFilter(editor);
|
||||||
|
clipboard.copyImage = true;
|
||||||
|
|
||||||
if (editor.settings.paste_as_text) {
|
if (editor.settings.paste_as_text) {
|
||||||
self.clipboard.pasteFormat = "text";
|
self.clipboard.pasteFormat = "text";
|
||||||
@ -116,13 +101,6 @@ define("tinymce/pasteplugin/Plugin", [
|
|||||||
onclick: togglePlainTextPaste,
|
onclick: togglePlainTextPaste,
|
||||||
active: self.clipboard.pasteFormat == "text"
|
active: self.clipboard.pasteFormat == "text"
|
||||||
});
|
});
|
||||||
|
|
||||||
editor.addButton('pasteCopyImage', {
|
|
||||||
icon: 'copy',
|
|
||||||
tooltip: "When Paste other site's image, copy it into my album as public image",
|
|
||||||
onclick: togglePasteCopyImage,
|
|
||||||
active: self.clipboard.copyImage === true
|
|
||||||
});
|
|
||||||
|
|
||||||
editor.addMenuItem('pastetext', {
|
editor.addMenuItem('pastetext', {
|
||||||
text: 'Paste as text',
|
text: 'Paste as text',
|
||||||
|
@ -117,4 +117,4 @@
|
|||||||
writeScripts();
|
writeScripts();
|
||||||
})(this);
|
})(this);
|
||||||
|
|
||||||
// $hash: e0933a5a75e12f26b54b4e7b86f5bdc2
|
// $hash: cb0df1bfb67ded475df65e7e75c7998f
|
@ -232,8 +232,9 @@ define("tinymce/pasteplugin/Clipboard", [
|
|||||||
ajaxPost("/file/copyHttpImage", {src: src}, function(ret) {
|
ajaxPost("/file/copyHttpImage", {src: src}, function(ret) {
|
||||||
if(reIsOk(ret)) {
|
if(reIsOk(ret)) {
|
||||||
// 将图片替换之
|
// 将图片替换之
|
||||||
var src = urlPrefix + "/" + ret.Item;
|
// var src = urlPrefix + "/" + ret.Item;
|
||||||
var dom = editor.dom
|
var src = urlPrefix + "/file/outputImage?fileId=" + ret.Id;
|
||||||
|
var dom = editor.dom;
|
||||||
for(var i in ids) {
|
for(var i in ids) {
|
||||||
var id = ids[i];
|
var id = ids[i];
|
||||||
var imgElm = dom.get(id);
|
var imgElm = dom.get(id);
|
||||||
@ -1103,26 +1104,11 @@ define("tinymce/pasteplugin/Plugin", [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function togglePasteCopyImage() {
|
|
||||||
if (clipboard.copyImage) {
|
|
||||||
this.active(false);
|
|
||||||
clipboard.copyImage = false
|
|
||||||
} else {
|
|
||||||
clipboard.copyImage = true;
|
|
||||||
this.active(true);
|
|
||||||
if (!userIsInformed2) {
|
|
||||||
editor.windowManager.alert(
|
|
||||||
"When copy other site's images (not in leanote) into editor, it will copy the image into your album."
|
|
||||||
);
|
|
||||||
userIsInformed2 = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
self.clipboard = clipboard = new Clipboard(editor);
|
self.clipboard = clipboard = new Clipboard(editor);
|
||||||
self.quirks = new Quirks(editor);
|
self.quirks = new Quirks(editor);
|
||||||
self.wordFilter = new WordFilter(editor);
|
self.wordFilter = new WordFilter(editor);
|
||||||
|
clipboard.copyImage = true;
|
||||||
|
|
||||||
if (editor.settings.paste_as_text) {
|
if (editor.settings.paste_as_text) {
|
||||||
self.clipboard.pasteFormat = "text";
|
self.clipboard.pasteFormat = "text";
|
||||||
@ -1175,13 +1161,6 @@ define("tinymce/pasteplugin/Plugin", [
|
|||||||
onclick: togglePlainTextPaste,
|
onclick: togglePlainTextPaste,
|
||||||
active: self.clipboard.pasteFormat == "text"
|
active: self.clipboard.pasteFormat == "text"
|
||||||
});
|
});
|
||||||
|
|
||||||
editor.addButton('pasteCopyImage', {
|
|
||||||
icon: 'copy',
|
|
||||||
tooltip: "When Paste other site's image, copy it into my album as public image",
|
|
||||||
onclick: togglePasteCopyImage,
|
|
||||||
active: self.clipboard.copyImage === true
|
|
||||||
});
|
|
||||||
|
|
||||||
editor.addMenuItem('pastetext', {
|
editor.addMenuItem('pastetext', {
|
||||||
text: 'Paste as text',
|
text: 'Paste as text',
|
||||||
|
2
public/tinymce/plugins/paste/plugin.min.js
vendored
2
public/tinymce/plugins/paste/plugin.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user