🍎 评论框显示头像

pull/18/head
ruibaby 2018-06-12 12:24:49 +08:00
parent 000f7ed465
commit 1220484f3b
4 changed files with 97 additions and 3 deletions

24
pom.xml
View File

@ -23,7 +23,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<version>2.0.2.RELEASE</version>
<relativePath/>
</parent>
@ -149,7 +149,29 @@
<scope>true</scope>
</dependency>
<!-- 又拍云 -->
<dependency>
<groupId>com.upyun</groupId>
<artifactId>java-sdk</artifactId>
<version>4.0.1</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>nexus-aliyun</id>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<profiles>
<!-- 生产环境打包配置 -->
<profile>

View File

@ -1,8 +1,53 @@
package cc.ryanc.halo.web.controller.api;
import cc.ryanc.halo.model.dto.Archive;
import cc.ryanc.halo.model.dto.JsonResult;
import cc.ryanc.halo.service.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author : RYAN0UP
* @date : 2018/6/6
*/
@RestController
@RequestMapping(value = "/api/archives")
public class ApiArchivesController {
@Autowired
private PostService postService;
/**
*
*
* @return JsonResult
*/
@GetMapping(value = "/year")
public JsonResult archivesYear(){
List<Archive> archives = postService.findPostGroupByYear();
if(null!=archives || archives.size()>0){
return new JsonResult(200,"success",archives);
}else {
return new JsonResult(200,"empty");
}
}
/**
*
*
* @return JsonResult
*/
@GetMapping(value = "/year/month")
public JsonResult archivesYearAndMonth(){
List<Archive> archives = postService.findPostGroupByYearAndMonth();
if(null!=archives || archives.size()>0){
return new JsonResult(200,"success",archives);
}else {
return new JsonResult(200,"empty");
}
}
}

View File

@ -29,7 +29,7 @@
<li>
<a href="/admin/comments?status=1">
<div class="pull-left">
<img src="http://www.gravatar.com/avatar/${comment.commentAuthorAvatarMd5?default("hash")}?s=256&d=${options.native_comment_avatar?default("mm")}" class="img-circle" alt="User Image">
<img src="//www.gravatar.com/avatar/${comment.commentAuthorAvatarMd5?default("hash")}?s=256&d=${options.native_comment_avatar?default("mm")}" class="img-circle" alt="User Image">
</div>
<h4>${comment.commentAuthor}
<small> ${comment.commentDate?string("yyyy/MM/dd HH:mm")}</small>

View File

@ -22,6 +22,7 @@
padding: 10px;
overflow: hidden;
position: relative;
margin-left: 58px;
}
input, textarea, button {
@ -172,6 +173,22 @@
font-size: 12px;
color: #555;
}
.comment-avatar{
position: relative;
float: left;
}
.comment-avatar img{
border-radius: 100%;
-webkit-transition: 0.4s;
-webkit-transition: -webkit-transform 0.4s ease-out;
transition: transform 0.4s ease-out;
-moz-transition: -moz-transform 0.4s ease-out;
cursor: pointer;
}
.comment-avatar img:hover{
transform: rotate(360deg);
}
.native-nav{
padding: 10px 0;
@ -193,12 +210,15 @@
}
</style>
<div class="native-comment">
<div class="comment-avatar">
<img src="//www.gravatar.com/avatar/none?s=256&d=${options.native_comment_avatar?default('mm')}" height="48" width="48" class="comment-author-avatar">
</div>
<div class="native-wrap">
<div class="comment-header">
<input type="hidden" name="postId" value="${post.postId?c}">
<input type="hidden" name="commentParent" id="commentParent" value="0">
<input type="text" class="comment-input comment-input-who" name="commentAuthor" id="commentAuthor" placeholder="昵称(必填)">
<input type="text" class="comment-input comment-input-email" name="commentAuthorEmail" id="commentAuthorEmail" placeholder="邮箱(选填)">
<input type="text" class="comment-input comment-input-email" name="commentAuthorEmail" id="commentAuthorEmail" onblur="loadAvatar()" placeholder="邮箱(选填)">
<input type="text" class="comment-input comment-input-website" name="commentAuthorUrl" id="commentAuthorUrl" placeholder="网址(选填)">
</div>
<div class="comment-content">
@ -258,6 +278,7 @@
$("#commentAuthor").val(localStorage.getItem("author"));
$("#commentAuthorEmail").val(localStorage.getItem("email"));
$("#commentAuthorUrl").val(localStorage.getItem("url"));
loadAvatar();
});
$('#btn-push').click(function () {
var author = $("#commentAuthor");
@ -310,6 +331,12 @@
$('#commentContent').val("@"+commentParentAuthor+": ");
$('#commentContent').focus();
});
function loadAvatar() {
$(".comment-author-avatar").attr("src","//www.gravatar.com/avatar/"+md5(localStorage.getItem("email"))+"?s=256&d=${options.native_comment_avatar?default('mm')}");
if($('input[name=commentAuthorEmail]').val()!='' && $('input[name=commentAuthorEmail]').val()!=null){
$(".comment-author-avatar").attr("src","//www.gravatar.com/avatar/"+md5($('input[name=commentAuthorEmail]').val())+"?s=256&d=${options.native_comment_avatar?default('mm')}");
}
}
var parser = new UAParser();
function show_ua(string){
parser.setUA(string);