Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
智布道
OneBlog
提交
e22af215
O
OneBlog
项目概览
智布道
/
OneBlog
9 个月 前同步成功
通知
11
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
OneBlog
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
e22af215
编写于
6月 21, 2019
作者:
智布道
👁
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
🐛
优化前台发布评论的代码,解决iphone端右上角菜单无法点出的问题(感谢lzhpo同学)
上级
2c557116
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
28 addition
and
20 deletion
+28
-20
blog-admin/src/main/java/com/zyd/blog/controller/RestApiController.java
.../main/java/com/zyd/blog/controller/RestApiController.java
+0
-6
blog-admin/src/main/java/com/zyd/blog/core/config/WebMvcConfig.java
.../src/main/java/com/zyd/blog/core/config/WebMvcConfig.java
+1
-1
blog-core/src/main/java/com/zyd/blog/business/service/impl/BizCommentServiceImpl.java
...zyd/blog/business/service/impl/BizCommentServiceImpl.java
+25
-11
blog-web/src/main/resources/templates/layout/header.ftl
blog-web/src/main/resources/templates/layout/header.ftl
+2
-2
未找到文件。
blog-admin/src/main/java/com/zyd/blog/controller/RestApiController.java
浏览文件 @
e22af215
...
...
@@ -2,8 +2,6 @@ package com.zyd.blog.controller;
import
com.zyd.blog.business.annotation.BussinessLog
;
import
com.zyd.blog.business.enums.FileUploadType
;
import
com.zyd.blog.business.service.BizArticleService
;
import
com.zyd.blog.business.service.SysConfigService
;
import
com.zyd.blog.core.websocket.server.ZydWebsocketServer
;
import
com.zyd.blog.core.websocket.util.WebSocketUtil
;
import
com.zyd.blog.file.FileUploader
;
...
...
@@ -36,10 +34,6 @@ import java.util.Map;
@RequestMapping
(
"/api"
)
public
class
RestApiController
{
@Autowired
private
BizArticleService
articleService
;
@Autowired
private
SysConfigService
configService
;
@Autowired
private
ZydWebsocketServer
websocketServer
;
...
...
blog-admin/src/main/java/com/zyd/blog/core/config/WebMvcConfig.java
浏览文件 @
e22af215
...
...
@@ -22,7 +22,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
@Override
public
void
addInterceptors
(
InterceptorRegistry
registry
)
{
registry
.
addInterceptor
(
rememberAuthenticationInterceptor
)
.
excludePathPatterns
(
"/passport/**"
,
"/error/**"
,
"/assets/**"
,
"/getKaptcha/**"
,
"favicon.ico"
)
.
excludePathPatterns
(
"/passport/**"
,
"/error/**"
,
"/assets/**"
,
"/getKaptcha/**"
,
"
/websocket"
,
"
favicon.ico"
)
.
addPathPatterns
(
"/**"
);
}
}
blog-core/src/main/java/com/zyd/blog/business/service/impl/BizCommentServiceImpl.java
浏览文件 @
e22af215
...
...
@@ -147,36 +147,50 @@ public class BizCommentServiceImpl implements BizCommentService {
@RedisCache
(
flush
=
true
)
public
Comment
comment
(
Comment
comment
)
throws
ZhydCommentException
{
SysConfig
sysConfig
=
configService
.
getByKey
(
ConfigKeyEnum
.
ANONYMOUS
.
getKey
());
boolean
anonymous
=
true
;
if
(
null
!=
sysConfig
)
{
String
anonymous
=
sysConfig
.
getConfigValue
();
if
(!
StringUtils
.
isEmpty
(
anonymous
)
&&
!
"1"
.
equals
(
anonymous
)
&&
!
SessionUtil
.
isLogin
())
{
throw
new
ZhydCommentException
(
"站长已关闭匿名评论,请先登录!"
);
}
anonymous
=
Boolean
.
valueOf
(
sysConfig
.
getConfigValue
());
}
// 非匿名且未登录
if
(!
anonymous
&&
!
SessionUtil
.
isLogin
())
{
throw
new
ZhydCommentException
(
"站长已关闭匿名评论,请先登录!"
);
}
// 过滤文本内容,防止xss
this
.
filterContent
(
comment
);
if
(
SessionUtil
.
isLogin
())
{
// 已登录且非匿名,使用当前登录用户的信息评论
if
(
SessionUtil
.
isLogin
()
&&
!
anonymous
)
{
this
.
setCurrentLoginUserInfo
(
comment
);
}
else
{
this
.
setCurrentAnonymousUserInfo
(
comment
);
}
List
<
String
>
avatars
=
configService
.
getRandomUserAvatar
();
if
(
StringUtils
.
isEmpty
(
comment
.
getAvatar
())
&&
!
CollectionUtils
.
isEmpty
(
avatars
))
{
Collections
.
shuffle
(
avatars
);
int
randomIndex
=
new
Random
().
nextInt
(
avatars
.
size
());
comment
.
setAvatar
(
avatars
.
get
(
randomIndex
));
// 用户没有头像时, 使用随机默认的头像
if
(
StringUtils
.
isEmpty
(
comment
.
getAvatar
()))
{
List
<
String
>
avatars
=
configService
.
getRandomUserAvatar
();
if
(!
CollectionUtils
.
isEmpty
(
avatars
))
{
Collections
.
shuffle
(
avatars
);
int
randomIndex
=
new
Random
().
nextInt
(
avatars
.
size
());
comment
.
setAvatar
(
avatars
.
get
(
randomIndex
));
}
}
if
(
StringUtils
.
isEmpty
(
comment
.
getStatus
()))
{
comment
.
setStatus
(
CommentStatusEnum
.
VERIFYING
.
toString
());
}
// set当前评论者的设备信息
this
.
setCurrentDeviceInfo
(
comment
);
// set当前评论者的位置信息
this
.
setCurrentLocation
(
comment
);
// 保存
this
.
insert
(
comment
);
// 发送邮件通知
this
.
sendEmail
(
comment
);
return
comment
;
}
...
...
@@ -192,7 +206,7 @@ public class BizCommentServiceImpl implements BizCommentService {
throw
new
ZhydCommentException
(
"说点什么吧"
);
}
// 过滤非法属性和无用的空标签
if
(!
XssKillerUtil
.
isValid
(
content
))
{
if
(!
XssKillerUtil
.
isValid
(
content
)
||
!
XssKillerUtil
.
isValid
(
comment
.
getAvatar
())
)
{
throw
new
ZhydCommentException
(
"请不要使用特殊标签"
);
}
content
=
XssKillerUtil
.
clean
(
content
.
trim
()).
replaceAll
(
"(<p><br></p>)|(<p></p>)"
,
""
);
...
...
blog-web/src/main/resources/templates/layout/header.ftl
浏览文件 @
e22af215
...
...
@@ -141,12 +141,12 @@
<div class="menu-box">
<div class="navbar-header">
<span class="pull-right nav-search toggle-search" data-toggle="modal" data-target=".nav-search-box"><i class="fa fa-search"></i></span>
<
a type="button"
class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<
button
class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</
a
>
</
button
>
<a class="navbar-brand logo" href="#"></a>
</div>
<div id="navbar" class="navbar-collapse collapse">
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录