Ver a proveniência

博客详情修改

layui
mail_yanpeng@163.com há 6 anos
ascendente
cometimento
a0acfc5316
  1. 2
      conf/app.conf
  2. 7
      main.go
  3. 13
      models/DataInit.go
  4. 81
      static/css/blog.css
  5. 2
      static/css/common.css
  6. 97
      views/blog.html

2
conf/app.conf

@ -1,6 +1,6 @@
appname = beeblog
runmode = prod
runmode = dev
sessionon = true
sessiongcmaxlifetime = 36000

7
main.go

@ -4,6 +4,7 @@ import (
_ "beeblog/routers"
"github.com/astaxie/beego"
"beeblog/models"
"github.com/astaxie/beego/logs"
"github.com/astaxie/beego/orm"
"beeblog/filter"
"github.com/astaxie/beego/plugins/cors"
@ -18,8 +19,10 @@ func main() {
orm.Debug = false
orm.RunSyncdb("default", false, true)
beego.AddFuncMap("NAdd",NAdd)
beego.SetLevel(beego.LevelInformational)
beego.SetLogger("file", `{"filename":"/opt/logs/aiprose.log"}`)
//beego.SetLevel(beego.LevelInformational)
//logs.LevelDebug
//beego.SetLogger("file", `{"filename":"/opt/logs/aiprose.log"}`)
logs.SetLogger(logs.AdapterFile, `{"filename":"test.log","level":3}`)
beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
AllowAllOrigins: true,
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},

13
models/DataInit.go

@ -1,6 +1,7 @@
package models
import (
"github.com/astaxie/beego"
//"github.com/Unknwon/com"
//"os"
//"path"
@ -9,12 +10,12 @@ import (
_ "github.com/go-sql-driver/mysql"
)
const(
_DB_NAME = "data/beeblog.db"
const (
_DB_NAME = "data/beeblog.db"
_SQLITE3_DRIVER = "sqlite3"
)
func RegistDB() {
func RegistDB() {
//if !com.IsExist(_DB_NAME){
// os.MkdirAll(path.Dir(_DB_NAME),os.ModePerm)
// os.Create(_DB_NAME)
@ -23,6 +24,6 @@ func RegistDB() {
//orm.RegisterDriver(_SQLITE3_DRIVER,orm.DRSqlite)
//orm.RegisterDataBase("default",_SQLITE3_DRIVER,_DB_NAME,10)
orm.RegisterModel(new(User),new(Blog),new(NLabel),new(Note),new(NoteColl),new(Category),new(Like),new(Comment))
orm.RegisterDataBase("default", "mysql", "root:booszy@tcp(127.0.0.1:3306)/beeblog?charset=utf8&loc=Local", 30)
}
orm.RegisterModel(new(User), new(Blog), new(NLabel), new(Note), new(NoteColl), new(Category), new(Like), new(Comment))
orm.RegisterDataBase("default", "mysql", "root:"+beego.AppConfig.String("dburl")+"/beeblog?charset=utf8&loc=Local", 30)
}

81
static/css/blog.css

@ -1,26 +1,80 @@
.blog-root{
height: 100%;
margin: 50px 10% 0 350px;
width: 68%;
margin: 40px auto;
}
.blog-info{
text-align: center;
}
.blog-info em{
padding: 0 8px !important;
.blog-root .blog-title{
margin: 60px 0 20px 0;
text-align: center
}
.blog-user{
position: fixed;
top: 60px;
left: 20px;
width: 300px;
left: 5px;
width: 100px;
height: 100%;
background-color: #f9f9f9;
}
.blog-info .blog-author{
display: flex;
}
.blog-info .blog-author .author-headimg{
display: inline-block;
width: 48px;
height: 48px;
}
.blog-info .blog-author .blog-label{
flex: 1;
height: 28px;
line-height: 28px;
text-align: right;
padding-top: 20px;
}
.blog-info .blog-author .blog-label label{
color: #888;
border:1px dotted #aaa;
padding: 0 5px;
border-radius: 5px ;
}
.blog-info .blog-author .author-headimg .img-circle{
width: 48px !important;
height: 48px !important;
margin-top: 0px !important;
}
.blog-info .blog-author .author-info{
display: inline-block;
height: 48px !important;
vertical-align: bottom;
text-align: left;
margin-left: 5px;
}
.blog-info .blog-author .author-info a{
display: inline-block;
height: 28px;
line-height: 28px;
font-size: 16px;
}
.blog-info .blog-author .author-info span{
display: inline-block;
height: 20px;
line-height: 20px;
font-size: 12px;
color: #888;
padding-right: 8px;
}
.blog-info em{
padding: 0 8px !important;
}
.comms-root{
margin: 50px 10% 0 350px;
width: 68%;
margin: 0 auto;
}
.comms-root a{
@ -29,4 +83,9 @@
img {
max-width: 100% !important;
}
.blog-referral{
width: 65%;
margin: 40px auto;
}

2
static/css/common.css

@ -1,6 +1,6 @@
body {
font-size: 14px !important;
background: #f5f7f9;
background: #fff;
}
.navbar-default{

97
views/blog.html

@ -1,68 +1,32 @@
{{template "header" .}}
<meta name="keywords" content="{{.Blog.Title}}">
<meta name="description" content="{{.Blog.Title}}">
<title>{{.Blog.Title}} - 云悦</title>
<link type="text/css" rel="styleSheet" href="/static/css/blog.css"/>
<meta name="keywords" content="{{.Blog.Title}}">
<meta name="description" 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>
{{template "nav" .}}
<div class="blog-root">
<h1 style="text-align: center">{{.Blog.Title}}</h1>
<h1 class="blog-title">{{.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 class="blog-author">
<div class="author-headimg">
<a href="/u/{{.Blog.User.Id}}"><img src="{{.Blog.User.Headimg}}" alt="头像" class="img-circle"></a>
</div>
<div class="author-info">
<a href="/u/{{.Blog.User.Id}}">{{.Blog.User.NickName}}</a><br>
<span>{{.Blog.Ctime.Format "2006-01-02"}}</span><span>阅读 {{.Blog.Browses}}</span>
</div>
<div class="blog-label">
{{range .Blog.Lables}}
<label>{{.Title}}</label>
{{end}}
</div>
</div>
</div>
<div style="width: 100%">
{{str2html .Blog.BlogHtml}}
{{str2html .Blog.BlogHtml}}
</div>
</div>
<div class="comms-root">
@ -71,7 +35,7 @@
<button type="button" class="btn btn-info btn-bordered" id="commBtn">发表评论</button>
</div>
<div class="comm-container">
{{range .Blog.Comms}}
{{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>
@ -79,7 +43,7 @@
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}}
{{range .Childs}}
<div style="margin-left: 18px" class="ccomm-{{.Id}}">
<span>
<a href="/u/{{.CUser.Id}}">{{.CUser.NickName}}</a> 回复
@ -90,14 +54,24 @@
href="javascript:void(0)">回复</a></span>
</div>
{{end}}
{{end}}
</div>
</div>
{{end}}
{{end}}
</div>
<div style="margin-top: 50px">
{{template "footer"}}
{{template "footer"}}
</div>
<div class="blog-referral">
{{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>
</div>
@ -160,6 +134,7 @@
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) {

Carregando…
Cancelar
Guardar