Commit d556be44 authored by Van's avatar Van

add file upload function

养宝宝不容易啊,终于抽出时间打🐎
parent b3314020
...@@ -16,12 +16,13 @@ ...@@ -16,12 +16,13 @@
# #
# Description: Solo language configurations(en_US). # Description: Solo language configurations(en_US).
# Version: 2.4.2.3, Sep 12, 2015 # Version: 2.5.2.3, Sep 16, 2015
# Author: Liang Ding # Author: Liang Ding
# Author: Liyuan Li # Author: Liyuan Li
# Author: Dongxu Wang # Author: Dongxu Wang
# #
uploadFileLabel=Upload()\uff08Please add the QiNiu link to the reference\uff09
accessKey1Label=Access Key: accessKey1Label=Access Key:
secretKey1Label=Secret Key: secretKey1Label=Secret Key:
domain1Label=\u57df\u540d: domain1Label=\u57df\u540d:
......
...@@ -16,12 +16,13 @@ ...@@ -16,12 +16,13 @@
# #
# Description: Solo default language configurations(zh_CN). # Description: Solo default language configurations(zh_CN).
# Version: 2.4.4.11, Sep 12, 2015 # Version: 2.5.4.11, Sep 16, 2015
# Author: Liang Ding # Author: Liang Ding
# Author: Liyuan Li # Author: Liyuan Li
# Author: Dongxu Wang # Author: Dongxu Wang
# #
uploadFileLabel=\u6587\u4ef6\u4e0a\u4f20\uff08\u8bf7\u5c06\u751f\u6210\u7684\u4e03\u725b\u94fe\u63a5\u6dfb\u52a0\u5230\u5f15\u7528\u5904\uff09
accessKey1Label=Access Key\uff1a accessKey1Label=Access Key\uff1a
secretKey1Label=Secret Key\uff1a secretKey1Label=Secret Key\uff1a
domain1Label=\u57df\u540d\uff1a domain1Label=\u57df\u540d\uff1a
......
...@@ -10,6 +10,12 @@ ...@@ -10,6 +10,12 @@
<textarea id="articleContent" name="articleContent" <textarea id="articleContent" name="articleContent"
style="height: 500px;width:100%;"></textarea> style="height: 500px;width:100%;"></textarea>
</div> </div>
<div>
<label>${uploadFileLabel}</label>
<form id="articleUpload" method="POST" enctype="multipart/form-data">
<input type="file" name="file" multiple=""/>
</form>
</div>
<div> <div>
<label>${tags1WithTips1Label}</label> <label>${tags1WithTips1Label}</label>
<input id="tag" type="text"/> <input id="tag" type="text"/>
......
...@@ -130,6 +130,9 @@ ...@@ -130,6 +130,9 @@
</div> </div>
</div> </div>
<script src="${staticServePath}/js/lib/jquery/jquery.min.js"></script> <script src="${staticServePath}/js/lib/jquery/jquery.min.js"></script>
<script src="${staticServePath}/js/lib/jquery/file-upload-9.10.1/vendor/jquery.ui.widget.js"></script>
<script src="${staticServePath}/js/lib/jquery/file-upload-9.10.1/jquery.iframe-transport.js"></script>
<script src="${staticServePath}/js/lib/jquery/file-upload-9.10.1/jquery.fileupload.js"></script>
<script src="${staticServePath}/js/lib/jquery/jquery.bowknot.min.js?${staticResourceVersion}"></script> <script src="${staticServePath}/js/lib/jquery/jquery.bowknot.min.js?${staticResourceVersion}"></script>
<script src="${servePath}/js/lib/tiny_mce/tiny_mce.js"></script> <script src="${servePath}/js/lib/tiny_mce/tiny_mce.js"></script>
<script src="${staticServePath}/js/lib/KindEditor/kindeditor-min.js"></script> <script src="${staticServePath}/js/lib/KindEditor/kindeditor-min.js"></script>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
* *
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a> * @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.3.3, May 30, 2015 * @version 1.2.3.3, Sep 16, 2015
*/ */
admin.article = { admin.article = {
currentEditorType: '', currentEditorType: '',
...@@ -439,6 +439,39 @@ admin.article = { ...@@ -439,6 +439,39 @@ admin.article = {
} }
}); });
// upload
var qiniu = window.qiniu;
$('#articleUpload').fileupload({
multipart: true,
url: "http://upload.qiniu.com/",
formData: function (form) {
var data = form.serializeArray();
data.push({name: 'token', value: qiniu.qiniuUploadToken});
return data;
},
done: function (e, data) {
var qiniuKey = data.result.key;
if (!qiniuKey) {
alert("Upload error");
return;
}
var t = new Date().getTime();
$('#articleUpload').after('<div><a target="_blank" href="http://' + qiniu.qiniuDomain + qiniuKey + '?' + t
+ '">[' + data.files[0].name + ']</a> http://'
+ qiniu.qiniuDomain + qiniuKey + '?' + t + '</div>');
},
fail: function (e, data) {
alert("Upload error: " + data.errorThrown);
}
}).on('fileuploadprocessalways', function (e, data) {
var currentFile = data.files[data.index];
if (data.files.error && currentFile.error) {
alert(currentFile.error);
}
});
// editor // editor
admin.editors.articleEditor = new Editor({ admin.editors.articleEditor = new Editor({
id: "articleContent", id: "articleContent",
......
This diff is collapsed.
...@@ -2,11 +2,6 @@ ...@@ -2,11 +2,6 @@
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<title>{#advimage_dlg.dialog_title}</title> <title>{#advimage_dlg.dialog_title}</title>
<script type="text/javascript" src="../../../jquery/jquery.min.js"></script>
<script type="text/javascript" src="../../../jquery/file-upload-9.10.1/vendor/jquery.ui.widget.js"></script>
<script type="text/javascript" src="../../../jquery/file-upload-9.10.1/jquery.iframe-transport.js"></script>
<script type="text/javascript" src="../../../jquery/file-upload-9.10.1/jquery.fileupload.js"></script>
<script type="text/javascript" src="../../../jquery/file-upload-9.10.1/jquery.fileupload-process.js"></script>
<script type="text/javascript" src="../../tiny_mce_popup.js"></script> <script type="text/javascript" src="../../tiny_mce_popup.js"></script>
<script type="text/javascript" src="../../utils/mctabs.js"></script> <script type="text/javascript" src="../../utils/mctabs.js"></script>
<script type="text/javascript" src="../../utils/form_utils.js"></script> <script type="text/javascript" src="../../utils/form_utils.js"></script>
...@@ -35,7 +30,7 @@ ...@@ -35,7 +30,7 @@
<table role="presentation" class="properties"> <table role="presentation" class="properties">
<tr> <tr>
<td class="column1"><label id="srclabel" for="src">{#advimage_dlg.src}</label></td> <td class="column1"><label id="srclabel" for="src">{#advimage_dlg.src}</label></td>
<td> <td colspan="2">
<table role="presentation" border="0" cellspacing="0" cellpadding="0"> <table role="presentation" border="0" cellspacing="0" cellpadding="0">
<tr> <tr>
<td><input name="src" type="text" id="src" value="" class="mceFocus" onchange="ImageDialog.showPreviewImage(this.value);" aria-required="true" /></td> <td><input name="src" type="text" id="src" value="" class="mceFocus" onchange="ImageDialog.showPreviewImage(this.value);" aria-required="true" /></td>
...@@ -43,13 +38,6 @@ ...@@ -43,13 +38,6 @@
</tr> </tr>
</table> </table>
</td> </td>
<td>
<label>
Upload
<input type="file" style="width: 1px;opacity: .001;" id="imageUpload"
accept="image/gif, image/jpeg, image/png" />
</label>
</td>
</tr> </tr>
<tr> <tr>
<td><label for="src_list">{#advimage_dlg.image_list}</label></td> <td><label for="src_list">{#advimage_dlg.image_list}</label></td>
......
...@@ -6,8 +6,6 @@ var ImageDialog = { ...@@ -6,8 +6,6 @@ var ImageDialog = {
if (url = tinyMCEPopup.getParam("external_image_list_url")) if (url = tinyMCEPopup.getParam("external_image_list_url"))
document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>'); document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
ImageDialog.uploadImage();
}, },
init: function (ed) { init: function (ed) {
var f = document.forms[0], nl = f.elements, ed = tinyMCEPopup.editor, dom = ed.dom, n = ed.selection.getNode(), fl = tinyMCEPopup.getParam('external_image_list', 'tinyMCEImageList'); var f = document.forms[0], nl = f.elements, ed = tinyMCEPopup.editor, dom = ed.dom, n = ed.selection.getNode(), fl = tinyMCEPopup.getParam('external_image_list', 'tinyMCEImageList');
...@@ -476,49 +474,6 @@ var ImageDialog = { ...@@ -476,49 +474,6 @@ var ImageDialog = {
}, },
changeMouseMove: function () { changeMouseMove: function () {
}, },
uploadImage: function () {
$(function () {
var qiniu = window.parent.qiniu;
console.log(qiniu);
$('#imageUpload').fileupload({
multipart: true,
pasteZone: null,
dropZone: null,
url: "http://upload.qiniu.com/",
formData: function (form) {
var data = form.serializeArray();
data.push({name: 'token', value: qiniu.qiniuUploadToken});
return data;
},
submit: function (e, data) {
},
done: function (e, data) {
// console.log(data.result)
var qiniuKey = data.result.key;
if (!qiniuKey) {
alert("Upload error");
return;
}
var t = new Date().getTime();
$('#src').val(qiniu.qiniuDomain + qiniuKey + '?' + t);
ImageDialog.showPreviewImage(qiniu.qiniuDomain + qiniuKey + '?' + t);
},
fail: function (e, data) {
alert("Upload error: " + data.errorThrown);
}
}).on('fileuploadprocessalways', function (e, data) {
var currentFile = data.files[data.index];
if (data.files.error && currentFile.error) {
alert(currentFile.error);
}
});
});
},
showPreviewImage: function (u, st) { showPreviewImage: function (u, st) {
if (!u) { if (!u) {
tinyMCEPopup.dom.setHTML('prev', ''); tinyMCEPopup.dom.setHTML('prev', '');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment