Não pode escolher mais do que 25 tópicos
Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
227 linhas
10 KiB
227 linhas
10 KiB
{{template "header"}}
|
|
<meta name="keywords" content="{{.Blog.Title}}">
|
|
<title>{{.Blog.Title}} - 个人随笔</title>
|
|
<link type="text/css" rel="styleSheet" href="/static/css/blog.css"/>
|
|
</head>
|
|
<body>
|
|
<div class="root-container">
|
|
{{template "nav" .}}
|
|
<div class="blog-user">
|
|
<div style="height: 50px;line-height: 50px">
|
|
<a href="/u/{{.Blog.User.Id}}"><img src="{{.Blog.User.Headimg}}" alt="头像" class="img-circle"></a>
|
|
<a href="/u/{{.Blog.User.Id}}"
|
|
style="margin-left: 15px;font-size: 18px;text-decoration: none">{{.Blog.User.NickName}}</a>
|
|
</div>
|
|
<hr style="height:1px;border:none;border-top:1px solid #EEE;margin: 6px;"/>
|
|
<div style="display: flex;height: 30px;line-height: 30px;">
|
|
<div style="display: inline-block;width: 120px">
|
|
<span>文章: </span>
|
|
<span>{{.Blog.User.BlogCount}}</span>
|
|
</div>
|
|
<div style="display: inline-block;flex: 1">
|
|
<span>访问: </span>
|
|
<span>{{.Blog.User.BlogBrowes}}</span>
|
|
</div>
|
|
</div>
|
|
<div style="display: flex;height: 30px;line-height: 30px;">
|
|
<div style="display: inline-block;width: 120px">
|
|
<span>评论: </span>
|
|
<span>{{.Blog.User.BlogComment}}</span>
|
|
</div>
|
|
<div style="display: inline-block;flex: 1">
|
|
<span>喜欢: </span>
|
|
<span>{{.Blog.User.BlogLike}}</span>
|
|
</div>
|
|
</div>
|
|
<hr style="height:1px;border:none;border-top:1px solid #EEE;margin: 6px;"/>
|
|
|
|
{{range .Top}}
|
|
<div>
|
|
<a href="/blog/{{.Id}}"><p
|
|
style="max-width:290px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">{{.Title}}</p>
|
|
</a>
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
<div class="blog-root">
|
|
<h1 style="text-align: center">{{.Blog.Title}}</h1>
|
|
<div class="blog-info">
|
|
{{if .IsLike}}
|
|
<span><img src="/static/img/liked.png" alt="" onclick="unlike({{.Blog.Id}})"></span>
|
|
{{else}}
|
|
<span><img src="/static/img/like.png" alt="" onclick="like({{.Blog.Id}})"></span>
|
|
{{end}}
|
|
<span><a href="/u/{{.Blog.User.Id}}">{{.Blog.User.NickName}}</a></span>
|
|
<span><em>时间:</em>{{.Blog.Ctime.Format "2006-01-02"}}</span>
|
|
<span><em>阅读数:</em>{{.Blog.Browses}}</span>
|
|
<div class="tag-group" style="display: inline-block">
|
|
{{range .Blog.Lables}}
|
|
<label class='tag tag-info disabled'>{{.Title}}</label>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
<div style="width: 100%">
|
|
{{str2html .Blog.BlogHtml}}
|
|
</div>
|
|
</div>
|
|
<div class="comms-root">
|
|
<textarea class="form-control" rows="3" id="commval"></textarea>
|
|
<div style="text-align: end">
|
|
<button type="button" class="btn btn-info btn-bordered" id="commBtn">发表评论</button>
|
|
</div>
|
|
<div class="comm-container">
|
|
{{range .Blog.Comms}}
|
|
<div style="font-size: 14px;margin-top: 10px" class="pcomm-{{.Id}}">
|
|
<span><a href="/u/{{.CUser.Id}}">{{.CUser.NickName}}</a>:</span>
|
|
<span>{{.ComVal}}</span>
|
|
<span onclick="recomm({{.Id}},0,this)" style="font-size: 10px"><a
|
|
href="javascript:void(0)">回复</a></span>
|
|
<hr style="height:1px;border:none;border-top:1px solid #EEE;margin: 5px"/>
|
|
<div class="child-container">
|
|
{{range .Childs}}
|
|
<div style="margin-left: 18px" class="ccomm-{{.Id}}">
|
|
<span>
|
|
<a href="/u/{{.CUser.Id}}">{{.CUser.NickName}}</a> 回复
|
|
<a href="/u/{{.BUser.Id}}">{{.BUser.NickName}}</a>:
|
|
</span>
|
|
<span>{{.ComVal}}</span>
|
|
<span onclick="recomm({{.Id}},1)" style="font-size: 10px"><a
|
|
href="javascript:void(0)">回复</a></span>
|
|
</div>
|
|
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
|
|
<div style="margin-top: 50px">
|
|
{{template "footer"}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
<script>
|
|
$(function () {
|
|
$("#commBtn").click(function () {
|
|
var commval = $("#commval").val()
|
|
if (!commval || commval.trim().length < 3) {
|
|
layer.msg('评论最少三个字', function () {
|
|
});
|
|
return
|
|
}
|
|
$.post('/comms/save', {
|
|
blog: {{.Blog.Id}},
|
|
commval: commval
|
|
},
|
|
function (data) {
|
|
if (data.Status == 0) {
|
|
var res = ' <div style="font-size: 14px;margin-top: 10px" class="pcomm-' + data.Data.Id + '">\n' +
|
|
' <span><a href="/u/' + data.Data.CuserId + '">' + data.Data.CUser.NickName + '</a>:</span>\n' +
|
|
' <span>' + commval + '</span>\n' +
|
|
'<span onclick="recomm(' + data.Data.Id + ',0)" style="font-size: 10px"><a href="javascript:void(0)">回复</a></span>' +
|
|
' <hr style="height:1px;border:none;border-top:1px solid #EEE;margin: 5px"/>\n' +
|
|
' <div class="child-container"></div> </div>'
|
|
$(".comm-container").append(res)
|
|
$("#commval").val("")
|
|
layer.msg("保存成功", {icon: 6});
|
|
} else if (data.Status == 401) {
|
|
window.location.href = "/login"
|
|
} else {
|
|
layer.msg("保存失败", {icon: 5});
|
|
window.location.href = "/"
|
|
}
|
|
}, 'json')
|
|
})
|
|
debugger
|
|
/*百度收录*/
|
|
var bp = document.createElement('script');
|
|
var curProtocol = window.location.protocol.split(':')[0];
|
|
if (curProtocol === 'https') {
|
|
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
|
|
}
|
|
else {
|
|
bp.src = 'http://push.zhanzhang.baidu.com/push.js';
|
|
}
|
|
var s = document.getElementsByTagName("script")[0];
|
|
s.parentNode.insertBefore(bp, s);
|
|
|
|
/*360收录*/
|
|
var qihuo = document.createElement('script');
|
|
if (curProtocol === 'https') {
|
|
qihuo.src = 'https://jspassport.ssl.qhimg.com/11.0.1.js?d33b14200fa89b7ecd3780341cd234c';
|
|
}
|
|
else {
|
|
qihuo.src = 'http://js.passport.qihucdn.com/11.0.1.js?d33b14200fa89b7ecd3780341cd234c4';
|
|
}
|
|
qihuo.id = "sozz"
|
|
var s = document.getElementsByTagName("script")[1];
|
|
s.parentNode.insertBefore(qihuo, s);
|
|
})
|
|
function recomm(pid, flag) {
|
|
layer.prompt({title: '请输入评论内容', value: name, formType: 2}, function (val, index) {
|
|
if (val.trim().length < 3) {
|
|
layer.msg('评论最少三个字', function () {
|
|
});
|
|
layer.close(index);
|
|
return
|
|
}
|
|
$.post('/comms/save', {blog: {{.Blog.Id}},commval: val,pid: pid},
|
|
function (data) {
|
|
if (data.Status == 0) {
|
|
var res = '<div style="margin-left: 18px" class="ccomm-' + data.Data.Id + '">\n' +
|
|
' <span>\n' +
|
|
' <a href="/u/' + data.Data.CUser.Id + '">' + data.Data.CUser.NickName + '</a> 回复\n' +
|
|
' <a href="/u/' + data.Data.BUser.Id + '">' + data.Data.BUser.NickName + '</a>:\n' +
|
|
' </span>\n' +
|
|
' <span>' + val + '</span>\n' +
|
|
' <span onclick="recomm(' + data.Data.Id + ',1)" style="font-size: 10px"><a href="javascript:void(0)">回复</a></span>\n' +
|
|
' </div>'
|
|
if (flag == 0) {
|
|
$(".pcomm-" + pid + " .child-container").append(res)
|
|
} else {
|
|
$($(".ccomm-" + pid)[0]).parent().append(res)
|
|
}
|
|
$("#commval").val("")
|
|
layer.close(index);
|
|
layer.msg("保存成功", {icon: 6});
|
|
} else if (data.Status == 401) {
|
|
window.location.href = "/login"
|
|
} else {
|
|
layer.msg("保存失败", {icon: 5});
|
|
window.location.href = "/"
|
|
}
|
|
}, 'json')
|
|
});
|
|
}
|
|
|
|
function like(id) {
|
|
$.get('/like/' + id,
|
|
function (data) {
|
|
if (data.Status == 0) {
|
|
window.location.href = window.location.href
|
|
} else if (data.Status == 401) {
|
|
window.location.href = "/login"
|
|
} else {
|
|
layer.msg("服务器异常", {icon: 5});
|
|
}
|
|
}, 'json')
|
|
}
|
|
|
|
function unlike(id) {
|
|
$.get('/unlike/' + id,
|
|
function (data) {
|
|
if (data.Status == 0) {
|
|
window.location.href = window.location.href
|
|
} else if (data.Status == 401) {
|
|
window.location.href = "/login"
|
|
} else if (data.Status == 403) {
|
|
layer.msg("暂无权限", {icon: 5});
|
|
} else {
|
|
layer.msg("服务器异常", {icon: 5});
|
|
}
|
|
}, 'json')
|
|
}
|
|
</script>
|
|
</html>
|