Ver código fonte

seo 优化

layui
mail_yanpeng@163.com 5 anos atrás
pai
commit
f359653139
  1. 14
      controllers/BlogController.go
  2. 1
      models/Blog.go
  3. 2
      views/blog.html
  4. 2
      views/editblog.html
  5. 1
      views/newblog.html

14
controllers/BlogController.go

@ -46,13 +46,14 @@ func (this *BlogController) Save() {
}
title := this.GetString("title")
blogHtml := this.GetString("blogHtml")
blogDesc := this.GetString("blogDesc")
catory := this.GetString("catory")
catoryId, _ := strconv.ParseInt(catory, 10, 64)
labels := this.GetStrings("labels[]")
blog := &models.Blog{Title: title, BlogHtml: blogHtml, CategoryId: catoryId, UserId: uid.(int64)}
blog := &models.Blog{Title: title, BlogHtml: blogHtml, CategoryId: catoryId, UserId: uid.(int64), BlogDesc: blogDesc}
err := blogService.SaveBlog(blog, labels)
if err == nil {
this.Data["json"] = models.ReurnData("",blog.Id)
this.Data["json"] = models.ReurnData("", blog.Id)
} else {
this.Data["json"] = models.ReurnError(500, "保存失败")
}
@ -70,13 +71,14 @@ func (this *BlogController) Edit() {
this.ServeJSON()
return
}
id,_ := this.GetInt64("id")
id, _ := this.GetInt64("id")
title := this.GetString("title")
blogHtml := this.GetString("blogHtml")
blogDesc := this.GetString("blogDesc")
catory := this.GetString("catory")
catoryId, _ := strconv.ParseInt(catory, 10, 64)
labels := this.GetStrings("labels[]")
blog,err :=blogService.GetBlog(id)
blog, err := blogService.GetBlog(id)
if err != nil {
this.Data["json"] = models.ReurnError(500, "保存失败")
this.ServeJSON()
@ -84,6 +86,7 @@ func (this *BlogController) Edit() {
}
blog.Title = title
blog.BlogHtml = blogHtml
blog.BlogDesc = blogDesc
blog.CategoryId = catoryId
blog.Utime = time.Now()
err = blogService.EditBlog(blog, labels)
@ -224,7 +227,6 @@ func (this *BlogController) BlogsPage() {
func (this *BlogController) Search() {
blog, _ := utils.Search("elk")
this.Data["json"] = models.ReurnData("",blog)
this.Data["json"] = models.ReurnData("", blog)
this.ServeJSON()
}

1
models/Blog.go

@ -10,6 +10,7 @@ type Blog struct {
Title string
BlogValue string `orm:"type(text)"`
BlogHtml string `orm:"type(text)"`
BlogDesc string
Ctime time.Time `orm:"auto_now_add;type(datetime)"`
Utime time.Time `orm:"auto_now_add;type(datetime)"`
Browses int64 `orm:"default(0)"`

2
views/blog.html

@ -1,6 +1,6 @@
{{template "header" .}}
<meta name="keywords" content="{{.Blog.Title}}-【码农随笔】">
<meta name="description" content="{{.Blog.Title}}-【码农随笔】">
<meta name="description" content="{{.Blog.BlogDesc}}">
<title>{{.Blog.Title}} - 码农随笔</title>
<link href="https://cdn.bootcss.com/highlight.js/9.15.6/styles/school-book.min.css" rel="stylesheet">
<!--<link href="https://cdn.bootcss.com/highlight.js/9.15.6/styles/atelier-dune-light.min.css" rel="stylesheet">-->

2
views/editblog.html

@ -1,7 +1,6 @@
{{template "header" .}}
<meta name="keywords" content="{{.Blog.Title}}">
<title>{{.Blog.Title}} - 码农随笔</title>
<link type="text/css" rel="styleSheet" href="/static/css/newblog.css"/>
<script src="/static/js/wangEditor.min.js"></script>
</head>
<body>
@ -56,6 +55,7 @@
return
}
tobj.blogHtml = editor.txt.html();
tobj.blogDesc = editor.txt.text().substring(0,200)
storage.setItem("blogHtml", tobj.blogHtml);
storage.setItem("blogTitle", tobj.title);
layer.open({

1
views/newblog.html

@ -54,6 +54,7 @@
return
}
tobj.blogHtml = editor.txt.html();
tobj.blogDesc = editor.txt.text().substring(0,200)
storage.setItem("blogHtml",tobj.blogHtml);
storage.setItem("blogTitle",tobj.title);
layer.open({

Carregando…
Cancelar
Salvar