Browse Source

底部备案信息&博客详情作者信息

layui
yirenyishi 6 years ago
parent
commit
f0c3ae4efc
  1. 6
      controllers/BlogController.go
  2. 2
      controllers/MapController.go
  3. BIN
      data/beeblog.db
  4. 5
      models/Blog.go
  5. 5
      models/User.go
  6. 3
      service/BlogService.go
  7. 12
      static/css/blog.css
  8. 27
      static/css/common.css
  9. 7
      static/css/login.css
  10. BIN
      static/img/wxcode.png
  11. 31
      views/blog.html
  12. 3
      views/blogs.html
  13. 3
      views/login.html
  14. 3
      views/regist.html

6
controllers/BlogController.go

@ -42,6 +42,8 @@ func (this *BlogController) Get() {
if err == nil {
this.Data["Blog"] = blog
}
this.Data["NickName"] = this.GetSession("nickname")
this.Data["IsLogin"] = this.GetSession("nickname") != nil
this.TplName = "blog.html"
}
@ -83,9 +85,7 @@ func (this *BlogController) BlogsPage() {
return
}
NickName:= this.GetSession("nickname")
fmt.Print("current user ",NickName)
this.Data["NickName"] = NickName
this.Data["NickName"] = this.GetSession("nickname")
this.Data["IsLogin"] = this.GetSession("nickname") != nil
this.Data["Page"] = pages
this.Data["Cats"] = cats

2
controllers/MapController.go

@ -7,6 +7,8 @@ type MapController struct {
}
func (this *MapController) Get() {
this.Data["NickName"] = this.GetSession("nickname")
this.Data["IsLogin"] = this.GetSession("nickname") != nil
this.Data["IsMap"] = true
this.TplName = "map.html"
}

BIN
data/beeblog.db

Binary file not shown.

5
models/Blog.go

@ -1,6 +1,8 @@
package models
import "time"
import (
"time"
)
type Blog struct {
Id int64
@ -18,6 +20,7 @@ type Blog struct {
Delflag int `orm:"default(0)"`
CategoryId int64
User *User `orm:"-"`
UserName string `orm:"-"`
HeadImg string `orm:"-"`
CateName string `orm:"-"`

5
models/User.go

@ -17,4 +17,9 @@ type User struct {
Sex int
DescInfo string
Ctime time.Time `orm:"auto_now_add;type(datetime)"`
BlogCount int
BlogBrowes int
BlogComment int
BlogLike int
}

3
service/BlogService.go

@ -33,8 +33,7 @@ func GetBlog(id int64) (*models.Blog, error) {
user := &models.User{Id: blog.UserId}
err = o.Read(user)
if err == nil {
blog.UserName = user.UserName
blog.HeadImg = user.Headimg
blog.User = user
}
var labels []*models.NLabel
qs := o.QueryTable(&models.NLabel{})

12
static/css/blog.css

@ -1,13 +1,21 @@
.blog-root{
height: 100%;
margin: 50px 4% 0 4%;
margin: 50px 4% 0 300px;
}
.blog-info{
text-align: center;
}
.blog-info em{
padding: 0 8px !important;
}
.blog-user{
position: fixed;
top: 60px;
left: 20px;
width: 260px;
height: 100%;
background-color: #f9f9f9;
}

27
static/css/common.css

@ -46,3 +46,30 @@ body {
.cursor {
cursor: pointer
}
.footer-root{
position: relative;
width: 100%;
height: 105px;
}
.footer-friend{
text-align: center;
height: 25px;
line-height: 25px;
color: #555;
}
.footer-friend a{
color: #555;
text-decoration: none;
}
.wxcode{
position: absolute;
right: 0;
top: -5px;
}
.login-footer .wxcode{
margin-right: 20px;
}

7
static/css/login.css

@ -33,3 +33,10 @@
height: 35px !important;
}
.login-footer{
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 110px;
}

BIN
static/img/wxcode.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

31
views/blog.html

@ -5,10 +5,38 @@
<body>
<div class="root-container">
{{template "nav" .}}
<div class="blog-user">
<div style="height: 50px;line-height: 50px">
<a href=""><img src="/static/img/2.png" alt="头像" class="img-circle"></a>
<a href="" 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: 100px">
<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: 100px">
<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;"/>
</div>
<div class="blog-root">
<h1 style="text-align: center">{{.Blog.Title}}</h1>
<div class="blog-info">
<span><a href="">{{.Blog.UserName}}</a></span>
<span><a href="">{{.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">
@ -21,6 +49,7 @@
{{str2html .Blog.BlogHtml}}
</div>
</div>
</div>
</body>
</html>

3
views/blogs.html

@ -80,6 +80,9 @@
</div>
</nav>
</div>
<hr style="height:1px;border:none;border-top:1px solid #EEE"/>
{{template "footer"}}
</div>
</div>
</body>

3
views/login.html

@ -25,6 +25,9 @@
</div>
</div>
</div>
<div class="login-footer">
{{template "footer"}}
</div>
</div>
</div>
</body>

3
views/regist.html

@ -25,6 +25,9 @@
</div>
</div>
</div>
<div class="login-footer">
{{template "footer"}}
</div>
</div>
</div>
</body>

Loading…
Cancel
Save