diff --git a/conf/app.conf b/conf/app.conf index bf2fce5..27aac3c 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -1,6 +1,6 @@ appname = beeblog -runmode = prod +runmode = dev sessionon = true sessiongcmaxlifetime = 36000 diff --git a/main.go b/main.go index 2eed79c..dae5616 100644 --- a/main.go +++ b/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"}, diff --git a/models/DataInit.go b/models/DataInit.go index 0d2512c..def4bff 100644 --- a/models/DataInit.go +++ b/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) -} \ No newline at end of file + 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) +} diff --git a/static/css/blog.css b/static/css/blog.css index d9faf52..0f08f6a 100644 --- a/static/css/blog.css +++ b/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; } \ No newline at end of file diff --git a/static/css/common.css b/static/css/common.css index b30e979..1b0592f 100644 --- a/static/css/common.css +++ b/static/css/common.css @@ -1,6 +1,6 @@ body { font-size: 14px !important; - background: #f5f7f9; + background: #fff; } .navbar-default{ diff --git a/views/blog.html b/views/blog.html index 147f992..6e846ae 100644 --- a/views/blog.html +++ b/views/blog.html @@ -1,68 +1,32 @@ {{template "header" .}} - - - {{.Blog.Title}} - 云悦 - + + +{{.Blog.Title}} - 云悦 +
-{{template "nav" .}} -
-
- 头像 - {{.Blog.User.NickName}} -
-
-
-
- 文章: - {{.Blog.User.BlogCount}} -
-
- 访问: - {{.Blog.User.BlogBrowes}} -
-
-
-
- 评论: - {{.Blog.User.BlogComment}} -
-
- 喜欢: - {{.Blog.User.BlogLike}} -
-
-
- - {{range .Top}} -
-

{{.Title}}

-
-
- {{end}} -
+ {{template "nav" .}}
-

{{.Blog.Title}}

+

{{.Blog.Title}}

- {{if .IsLike}} - - {{else}} - - {{end}} - {{.Blog.User.NickName}} - 时间:{{.Blog.Ctime.Format "2006-01-02"}} - 阅读数:{{.Blog.Browses}} -
- {{range .Blog.Lables}} - - {{end}} +
+
+ 头像 +
+
+ {{.Blog.User.NickName}}
+ {{.Blog.Ctime.Format "2006-01-02"}}阅读 {{.Blog.Browses}} +
+
+ {{range .Blog.Lables}} + + {{end}} +
- {{str2html .Blog.BlogHtml}} + {{str2html .Blog.BlogHtml}}
@@ -71,7 +35,7 @@
- {{range .Blog.Comms}} + {{range .Blog.Comms}}
{{.CUser.NickName}}: {{.ComVal}} @@ -79,7 +43,7 @@ href="javascript:void(0)">回复
- {{range .Childs}} + {{range .Childs}}
{{.CUser.NickName}} 回复 @@ -90,14 +54,24 @@ href="javascript:void(0)">回复
- {{end}} + {{end}}
- {{end}} + {{end}}
- {{template "footer"}} + {{template "footer"}} +
+
+ {{range .Top}} +
+

+ {{.Title}}

+
+
+ {{end}}
@@ -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) {