mirror of https://github.com/halo-dev/halo
👽 1. 发表文章页可直接弹出附件窗口,2. 修复了我疑惑了很久的事:为啥我天天收到测试邮件,原来是我单元测试的邮箱配置没有删。
parent
eb3de2f27e
commit
704ca6cf54
|
@ -8,6 +8,7 @@ import cc.ryanc.halo.service.AttachmentService;
|
|||
import cc.ryanc.halo.service.LogsService;
|
||||
import cc.ryanc.halo.utils.HaloUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
@ -81,12 +82,16 @@ public class AttachmentController {
|
|||
@GetMapping(value = "/select")
|
||||
public String selectAttachment(Model model,
|
||||
@RequestParam(value = "page", defaultValue = "0") Integer page,
|
||||
@RequestParam(value = "id") String id) {
|
||||
@RequestParam(value = "id",defaultValue = "none") String id,
|
||||
@RequestParam(value = "type",defaultValue = "normal") String type) {
|
||||
Sort sort = new Sort(Sort.Direction.DESC, "attachId");
|
||||
Pageable pageable = PageRequest.of(page, 18, sort);
|
||||
Page<Attachment> attachments = attachmentService.findAllAttachments(pageable);
|
||||
model.addAttribute("attachments", attachments);
|
||||
model.addAttribute("id", id);
|
||||
if(StringUtils.equals(type,"post")){
|
||||
return "admin/widget/_attachment-select-post";
|
||||
}
|
||||
return "admin/widget/_attachment-select";
|
||||
}
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@
|
|||
<table class="table table-bordered table-hover text-center">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>标题</th>
|
||||
<th width="50%">标题</th>
|
||||
<th>状态</th>
|
||||
<th>日期</th>
|
||||
</tr>
|
||||
|
|
|
@ -100,7 +100,7 @@
|
|||
</#list>
|
||||
<#else>
|
||||
<tr>
|
||||
<td colspan="5" style="text-align: center;">暂无页面</td>
|
||||
<td colspan="6" style="text-align: center;">暂无页面</td>
|
||||
</tr>
|
||||
</#if>
|
||||
</tbody>
|
||||
|
|
|
@ -12,11 +12,19 @@
|
|||
#post_title{
|
||||
font-weight: 400;
|
||||
}
|
||||
#btnOpenAttach{margin-left:4px;padding:3px 6px;position:relative;top:-4px;border:1px solid #ccc;border-radius:2px;background:#fff;text-shadow:none;font-weight:600;font-size:12px;line-height:normal;color:#3c8dbc;cursor:pointer;transition:all .2s ease-in-out}
|
||||
#btnOpenAttach:hover{background:#3c8dbc;color:#fff}
|
||||
.form-horizontal .control-label{
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
<section class="content-header">
|
||||
<h1>
|
||||
<h1 style="display: inline-block;">
|
||||
新建页面
|
||||
</h1>
|
||||
<a id="btnOpenAttach" href="#" onclick="openAttachCopy()">
|
||||
附件库
|
||||
</a>
|
||||
<ol class="breadcrumb">
|
||||
<li>
|
||||
<a data-pjax="true" href="#"><i class="fa fa-dashboard"></i> 首页</a>
|
||||
|
@ -119,6 +127,18 @@
|
|||
scrollbar: false
|
||||
});
|
||||
}
|
||||
function openAttachCopy() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '所有附件',
|
||||
shadeClose: true,
|
||||
shade: 0.5,
|
||||
maxmin: true,
|
||||
area: ['90%', '90%'],
|
||||
content: '/admin/attachments/select?type=post',
|
||||
scrollbar: false
|
||||
});
|
||||
}
|
||||
var editor;
|
||||
function loadEditor() {
|
||||
editor = editormd("markdown-editor", {
|
||||
|
|
|
@ -61,7 +61,11 @@
|
|||
<#if posts.content?size gt 0>
|
||||
<#list posts.content as post>
|
||||
<tr>
|
||||
<td>${post.postTitle}</td>
|
||||
<#if post.postTitle?length gt 20>
|
||||
<td>${post.postTitle?substring(0,20)}...</td>
|
||||
<#else >
|
||||
<td>${post.postTitle}</td>
|
||||
</#if>
|
||||
<td>
|
||||
<#if post.categories?size gt 0>
|
||||
<#list post.categories as cate>
|
||||
|
@ -109,7 +113,7 @@
|
|||
</#list>
|
||||
<#else>
|
||||
<tr>
|
||||
<th colspan="6" style="text-align: center">暂无文章</th>
|
||||
<th colspan="7" style="text-align: center">暂无文章</th>
|
||||
</tr>
|
||||
</#if>
|
||||
</tbody>
|
||||
|
|
|
@ -13,11 +13,17 @@
|
|||
#post_title{
|
||||
font-weight: 400;
|
||||
}
|
||||
#btnOpenAttach{margin-left:4px;padding:3px 6px;position:relative;top:-4px;border:1px solid #ccc;border-radius:2px;background:#fff;text-shadow:none;font-weight:600;font-size:12px;line-height:normal;color:#3c8dbc;cursor:pointer;transition:all .2s ease-in-out}
|
||||
#btnOpenAttach:hover{background:#3c8dbc;color:#fff}
|
||||
.form-horizontal .control-label{
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
<section class="content-header">
|
||||
<h1>
|
||||
新建文章
|
||||
</h1>
|
||||
<h1 style="display: inline-block;">新建文章</h1>
|
||||
<a id="btnOpenAttach" href="#" onclick="openAttachCopy()">
|
||||
附件库
|
||||
</a>
|
||||
<ol class="breadcrumb">
|
||||
<li>
|
||||
<a data-pjax="true" href="#"><i class="fa fa-dashboard"></i> 首页</a>
|
||||
|
@ -194,6 +200,19 @@
|
|||
scrollbar: false
|
||||
});
|
||||
}
|
||||
|
||||
function openAttachCopy() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '所有附件',
|
||||
shadeClose: true,
|
||||
shade: 0.5,
|
||||
maxmin: true,
|
||||
area: ['90%', '90%'],
|
||||
content: '/admin/attachments/select?type=post',
|
||||
scrollbar: false
|
||||
});
|
||||
}
|
||||
|
||||
var editor;
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
|
||||
<link rel="stylesheet" href="/static/plugins/bootstrap/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="/static/plugins/toast/css/jquery.toast.min.css">
|
||||
<link rel="stylesheet" href="/static/plugins/fileinput/fileinput.min.css">
|
||||
<link rel="stylesheet" href="/static/css/AdminLTE.min.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<section class="content">
|
||||
<div class="nav-tabs-custom">
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active">
|
||||
<a href="#allAttach" data-toggle="tab">所有附件</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#uploadAttach" data-toggle="tab">选择上传</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="allAttach">
|
||||
<div class="row">
|
||||
<#list attachments.content as attachment>
|
||||
<div class="col-lg-2 col-md-2 col-sm-6 col-xs-6 div-thumbnail">
|
||||
<a href="#" class="thumbnail" data-clipboard-text="${attachment.attachPath}">
|
||||
<img src="${attachment.attachSmallPath}" class="img-responsive">
|
||||
</a>
|
||||
</div>
|
||||
</#list>
|
||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
||||
<div class="no-margin pull-left">
|
||||
第${attachments.number+1}/${attachments.totalPages}页
|
||||
</div>
|
||||
<ul class="pagination no-margin pull-right">
|
||||
<li><a class="btn btn-sm <#if !attachments.hasPrevious()>disabled</#if>" href="/admin/attachments/select" >首页</a> </li>
|
||||
<li><a class="btn btn-sm <#if !attachments.hasPrevious()>disabled</#if>" href="/admin/attachments/select?page=${attachments.number-1}" >上页</a></li>
|
||||
<li><a class="btn btn-sm <#if !attachments.hasNext()>disabled</#if>" href="/admin/attachments/select?page=${attachments.number+1}">下页</a></li>
|
||||
<li><a class="btn btn-sm <#if !attachments.hasNext()>disabled</#if>" href="/admin/attachments/select?page=${attachments.totalPages-1}">尾页</a> </li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane" id="uploadAttach">
|
||||
<div class="row" id="uploadForm">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<div class="file-loading">
|
||||
<input id="uploadImg" class="file-loading" type="file" multiple name="file">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</body>
|
||||
<script src="/static/plugins/jquery/jquery.min.js"></script>
|
||||
<script src="/static/plugins/bootstrap/js/bootstrap.min.js"></script>
|
||||
<script src="/static/plugins/fileinput/fileinput.min.js"></script>
|
||||
<script src="/static/plugins/fileinput/zh.min.js"></script>
|
||||
<script src="/static/plugins/clipboard/clipboard.min.js"></script>
|
||||
<script src="/static/plugins/toast/js/jquery.toast.min.js"></script>
|
||||
<script src="/static/js/app.js"></script>
|
||||
<script>
|
||||
$('#uploadImg').fileinput({
|
||||
language: 'zh',
|
||||
uploadUrl: '/admin/attachments/upload',
|
||||
uploadAsync: true,
|
||||
allowedFileExtensions: ['jpg','gif','png','jpeg','svg'],
|
||||
maxFileCount: 10,
|
||||
enctype : 'multipart/form-data',
|
||||
showClose: false
|
||||
}).on("fileuploaded",function (event,data,previewId,index) {
|
||||
var data = data.jqXHR.responseJSON;
|
||||
if(data.success=="1"){
|
||||
$("#uploadForm").hide(400);
|
||||
$.toast({
|
||||
text: "上传成功!",
|
||||
heading: '提示',
|
||||
icon: 'success',
|
||||
showHideTransition: 'fade',
|
||||
allowToastClose: true,
|
||||
hideAfter: 1000,
|
||||
stack: 1,
|
||||
position: 'top-center',
|
||||
textAlign: 'left',
|
||||
loader: true,
|
||||
loaderBg: '#ffffff',
|
||||
afterHidden: function () {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
$(document).ready(function(){
|
||||
var clipboard = new Clipboard('.thumbnail');
|
||||
});
|
||||
$('.thumbnail').click(function () {
|
||||
showMsg("复制成功","success",1000)
|
||||
})
|
||||
</script>
|
||||
</html>
|
|
@ -22,37 +22,37 @@ import static org.junit.Assert.*;
|
|||
*/
|
||||
public class MailServiceImplTest {
|
||||
|
||||
@Before
|
||||
public void before() throws GeneralSecurityException {
|
||||
// 配置,一次即可
|
||||
OhMyEmail.config(OhMyEmail.SMTP_163(false), "ryan0up@163.com", "wangdashen666");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSendText() throws MessagingException {
|
||||
OhMyEmail.subject("这是一封测试TEXT邮件")
|
||||
.from("RYAN0UP")
|
||||
.to("709831589@qq.com")
|
||||
.text("信件内容")
|
||||
.send();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSendHtml() throws MessagingException {
|
||||
OhMyEmail.subject("这是一封测试HTML邮件")
|
||||
.from("王爵的QQ邮箱")
|
||||
.to("921293209@qq.com")
|
||||
.html("<h1 font=red>信件内容</h1>")
|
||||
.send();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSendAttach() throws MessagingException {
|
||||
OhMyEmail.subject("这是一封测试附件邮件")
|
||||
.from("王爵的QQ邮箱")
|
||||
.to("921293209@qq.com")
|
||||
.html("<h1 font=red>信件内容</h1>")
|
||||
.attach(new File("/Users/biezhi/Downloads/hello.jpeg"), "测试图片.jpeg")
|
||||
.send();
|
||||
}
|
||||
// @Before
|
||||
// public void before() throws GeneralSecurityException {
|
||||
// // 配置,一次即可
|
||||
// OhMyEmail.config(OhMyEmail.SMTP_163(false), "", "");
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testSendText() throws MessagingException {
|
||||
// OhMyEmail.subject("这是一封测试TEXT邮件")
|
||||
// .from("RYAN0UP")
|
||||
// .to("709831589@qq.com")
|
||||
// .text("信件内容")
|
||||
// .send();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testSendHtml() throws MessagingException {
|
||||
// OhMyEmail.subject("")
|
||||
// .from("")
|
||||
// .to("")
|
||||
// .html("")
|
||||
// .send();
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testSendAttach() throws MessagingException {
|
||||
// OhMyEmail.subject("")
|
||||
// .from("")
|
||||
// .to("")
|
||||
// .html("")
|
||||
// .attach(new File(""), "")
|
||||
// .send();
|
||||
// }
|
||||
}
|
Loading…
Reference in New Issue