diff --git a/controllers/BlogController.go b/controllers/BlogController.go index d9b3d2b..900f94f 100644 --- a/controllers/BlogController.go +++ b/controllers/BlogController.go @@ -140,6 +140,9 @@ func (this *BlogController) Get() { userService.CountBrows(blog.UserId) blogService.EditBlogBrows(id) } + blog.User.Salt = "" + blog.User.UserPwd = "" + utils.ESSave(blog) return } diff --git a/go.mod b/go.mod index e413f9d..8cc99e0 100644 --- a/go.mod +++ b/go.mod @@ -10,3 +10,5 @@ require ( github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect google.golang.org/appengine v1.6.1 // indirect ) + +go 1.13 diff --git a/static/css/common.css b/static/css/common.css index 0285519..69bf867 100644 --- a/static/css/common.css +++ b/static/css/common.css @@ -263,7 +263,7 @@ img { .home-container{ height: 100%; - margin: 50px 5% 0 5%; + margin: 50px 5% 60px 5%; } .home-container hr{ margin: 0; diff --git a/static/css/common.min.css b/static/css/common.min.css index ace93cb..4bd87a0 100644 --- a/static/css/common.min.css +++ b/static/css/common.min.css @@ -1,2 +1,2 @@ -body{font-size:14px!important;background:#fff;color:#353535}#cnzz_stat_icon_1277992374{text-align:center;display:block}#cnzz_stat_icon_1277992374 a{color:rgba(255,255,255,.7)!important}a{color:#28a3ef;text-decoration:none}.layui-nav{text-align:right}.navbar-default{border-color:#f8d9ea!important}.img-circle-large{width:110px;height:110px}.root-container{height:100%;width:100%;max-width:100%}.nav-container{max-height:50px;position:fixed;width:100%;z-index:1000;left:0;top:0}.nav-container li a:hover{transform:rotate(5deg) scale(1.1)}.nav-container p{display:inline-block;float:left;line-height:48px;font-size:20px}.layui-nav .layui-this:after,.layui-nav-bar,.layui-nav-tree .layui-nav-itemed:after{height:2px}::-webkit-scrollbar{width:1px}::-webkit-scrollbar-track-piece{background-color:rgba(0,0,0,0);-webkit-border-radius:6px}.cursor{cursor:pointer}.footer-root{color:rgba(255,255,255,.7);position:relative;width:100%;height:105px;display:flex}.footer-friend{text-align:center;height:25px;line-height:25px}.footer-friend a{color:rgba(255,255,255,.7);text-decoration:none}.img-circle{width:31px;height:31px;border-radius:50%}.login-footer .wxcode{margin-right:20px}.layui-nav .layui-nav-item{line-height:48px}.footer-container{background-color:#393d49;padding:30px 5% 0 5%}.pagination{margin:18px 0}.pagination ul li{line-height:20px;width:20px;height:20px;display:inline-block;border-color:#28a3ef;font-size:16px}.pagination ul li .next .prev{font-size:20px!important}.pagination ul .active{background-color:#28a3ef}.pagination ul .active a{color:#fff}.breadcrumb-container{padding:20px}.blog-root{height:100%;width:68%;margin:40px auto}.blog-root .blog-title{display:block;margin:60px 0 20px 0;text-align:center}.blog-root .blog-detaile{color:#2f2f2f}.blog-root .blog-detaile pre{border:1px #d2e8b9 solid;box-shadow:1px 1px 2px 2px #d2e8b9;margin:5px 0}.blog-root .blog-detaile h4{font-size:20px;font-weight:500}.blog-user{position:fixed;top:60px;left:5px;width:100px;height:100%;background-color:#f9f9f9}.blog-info{padding:15px}.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:22px;line-height:22px;text-align:right;padding-top:26px}.blog-info .blog-author .blog-label label{color:#888;border:1px dotted #aaa;padding:5px;border-radius:5px;font-size:10px}.blog-info .blog-author .author-headimg .img-circle{width:48px!important;height:48px!important;margin-top:0!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{width:68%;margin:0 auto}.comms-root a{text-decoration:none}img{max-width:100%!important}.blog-referral{width:100%;margin:40px auto}.blog-referral p{padding:3px 0}.layui-code-view .layui-code-ol li{margin-left:0!important}.home-container{height:100%;margin:50px 5% 0 5%}.home-container hr{margin:0}.home-hearder{margin:10px 0;display:flex;height:30px;line-height:30px}.home-hearder .m-select{color:#353535;width:150px;display:inline-block;height:32px;border-radius:3px;padding:4px 14px}.home-hearder .layui-btn-group .active a{color:#fff}.home-hearder .layui-btn-group a{color:#353535;text-decoration:none}.nelson-btn{color:#ec6149!important;border-radius:15px;border:1px solid #bbb!important}.nelson-btn:hover{background:#fff!important;color:#ec6149!important;border-radius:15px;border:1px solid #ec6149!important}.home-content{display:flex;min-height:36px;line-height:36px}.home-content-title{display:inline-block;flex:1}.home-content-desc{display:flex}.home-content-desc span{display:inline-block;text-align:center}.blog-root h5{color:#888;font-size:14px;margin:9px 0;font-family:inherit;font-weight:700;line-height:1.5}.blog-root a{text-decoration:none}.blog-root p{margin:1px 0 9px}.login-root{background:#f0e7db url("/static/img/login.png") no-repeat;position:absolute;min-height:100%;width:100%;overflow:hidden}.login-root .input-container{position:fixed;left:65%;top:33px;background:url("/static/img/loginbg.png") no-repeat center top}.login-root .input-container .input-root{width:370px;height:500px}.login-root .input-container .input-root p{font-size:21px;text-align:center;padding-top:195px}.login-root .input-container .input-root .inputs-class{padding:0 50px}.login-root .input-container .input-root .input-group{display:table;border-collapse:separate}.login-root .input-container .input-root .inputs-class .input-class{height:32px;margin:18px 0;display:flex}.login-root .input-container .input-root .inputs-class .input-class input{flex:1;height:26px!important;padding:2px 14px;font-size:12px;line-height:1.5;border-radius:3px;border-top-left-radius:0;border-bottom-left-radius:0;display:table-cell;border:1px solid #ccc} -.login-root .input-container .input-root .inputs-class .input-class .input-group-addon{color:#555;line-height:26px!important;font-size:12px;padding:2px 14px;line-height:1.5;border-radius:3px;display:table-cell;border:1px solid #ccc;border-right:0}.login-footer{position:absolute;bottom:0;left:0;width:100%;height:110px}.login-root{background:#f0e7db url("/static/img/login.png") no-repeat;position:absolute;min-height:100%;width:100%;overflow:hidden}.login-root .input-container{position:fixed;left:65%;top:33px;background:url("/static/img/loginbg.png") no-repeat center top}.login-root .input-container .input-root{width:370px;height:500px}.login-root .input-container .input-root p{font-size:21px;text-align:center;padding-top:195px}.login-root .input-container .input-root .inputs-class{padding:0 50px}.login-root .input-container .input-root .input-group{display:table;border-collapse:separate}.login-root .input-container .input-root .inputs-class .input-class{height:32px;margin:18px 0;display:flex}.login-root .input-container .input-root .inputs-class .input-class input{flex:1;height:26px!important;padding:2px 14px;font-size:12px;line-height:1.5;border-radius:3px;border-top-left-radius:0;border-bottom-left-radius:0;display:table-cell;border:1px solid #ccc}.login-root .input-container .input-root .inputs-class .input-class .input-group-addon{color:#555;line-height:26px!important;font-size:12px;padding:2px 14px;line-height:1.5;border-radius:3px;display:table-cell;border:1px solid #ccc;border-right:0}.login-footer{position:absolute;bottom:0;left:0;width:100%;height:110px}.me-menu{position:fixed;top:60px;left:20px;width:260px;height:100%;background-color:#f9f9f9}.me-menu p{cursor:pointer;font-size:15px;color:#555;margin:0;height:32px;line-height:32px}.me-menu .active{color:#3cbef8!important}.me-menu p a{margin-left:5px;color:#555;text-decoration:none}.me-menu .active span{display:inline-block;height:100%;width:2px;background-color:#3cbef8}.me-menu .active a{color:#3cbef8;vertical-align:top;height:32px;line-height:32px;display:inline-block}.me-blog-root{height:100%;margin:50px 4% 0 0}.me-blog-list{margin-left:300px}.me-blog-list p{height:30px;line-height:30px;margin:0;font-size:15px}.me-footer{position:absolute;bottom:0;left:0;width:100%;height:110px;padding:0 4%}.me-blog-footer{height:110px;padding:0 4%;margin-left:290px}.info-header{flex:1}.info-header span{margin-right:6px}.uinfo{color:#515a6e;margin:5px}.udesc span{margin-right:8px}.blog-list{display:flex;font-size:16px;min-height:35px;line-height:35px}.us-root{margin-top:50px;display:flex;margin-left:5%;font-size:16px;min-height:720px;height:100%}.us-root p{padding:5px 0;color:#323232}.blog-title{display:flex;height:50px;line-height:50px}.blog-title input{padding-left:12px;flex:1;height:44px;border:0}.blog-title button{height:32px;color:#fff;margin-top:9px}.w-e-toolbar{height:40px;line-height:30px}.map-root{position:absolute;width:100%;height:100%;left:0;top:0}.map-root .map-container{width:100%;height:100%}.amap-logo,.amap-copyright{display:none!important;visibility:hidden!important}.blog-detaile p code{color:red;padding:2px 5px}.search-root{margin-top:50px}.search-root .input-class{display:table;border-collapse:separate}.search-root .input-class{width:50%;height:32px;margin:18px auto;display:flex}.search-root .input-class input{flex:1;height:36px!important;padding:2px 14px;font-size:12px;line-height:1.5;border-radius:3px;border-top-right-radius:0;border-bottom-right-radius:0;display:table-cell;border:1px solid #3385ff}.search-root .input-class .input-group-addon{color:#555;height:36px;line-height:36px!important;font-size:17px!important;font-size:12px;padding:2px 14px;line-height:36px;border-radius:3px;display:table-cell;background-color:#3385ff;border-top-left-radius:0;border-bottom-left-radius:0;color:#fff;border:1px solid #3385ff;border-left:none;cursor:pointer}.search-result{margin:35px 15%}.search-item{padding:7px 15px}.search-result a{display:block;cursor:pointer;height:25px;line-height:25px;font-size:16px;text-decoration:#00c6ff;flex:1}.search-result .search-title{display:flex}.search-result span{cursor:pointer;font-size:12px;height:25px;line-height:25px}.search-content{font-size:12px} \ No newline at end of file +html,body{font-size:14px!important;background:#fff;color:#353535;height:100%;width:100%}#cnzz_stat_icon_1277992374{text-align:center;display:block}#cnzz_stat_icon_1277992374 a{color:rgba(255,255,255,.7)!important}a{text-decoration:none}.layui-nav{text-align:right}.navbar-default{border-color:#f8d9ea!important}.img-circle-large{width:110px;height:110px}.root-container{height:100%;width:100%;max-width:100%}.nav-container{max-height:50px;position:fixed;width:100%;z-index:1000;left:0;top:0}.nav-container li a:hover{transform:rotate(5deg) scale(1.1)}.nav-container p{display:inline-block;float:left;line-height:48px;font-size:20px}::-webkit-scrollbar{width:1px}::-webkit-scrollbar-track-piece{background-color:rgba(0,0,0,0);-webkit-border-radius:6px}.cursor{cursor:pointer}.footer-root{color:rgba(255,255,255,.7);position:relative;width:100%;height:105px;display:flex}.footer-friend{text-align:center;height:25px;line-height:25px}.footer-friend a{color:rgba(255,255,255,.7);text-decoration:none}.img-circle{width:31px;height:31px;border-radius:50%}.login-footer .wxcode{margin-right:20px}.layui-nav .layui-nav-item{line-height:49px!important}.layui-nav .layui-nav-item a{height:49px!important;line-height:49px}.layui-nav .layui-this:after,.layui-nav-bar,.layui-nav-tree .layui-nav-itemed:after{height:1px}.footer-container{background-color:#393d49;padding:30px 5% 0 5%}.pagination{margin:18px 0}.pagination ul li{line-height:20px;width:20px;height:20px;display:inline-block;border-color:#28a3ef;font-size:16px}.pagination ul li .next .prev{font-size:20px!important}.pagination ul .active{background-color:#28a3ef}.pagination ul .active a{color:#fff}.breadcrumb-container{padding:20px}.blog-root{width:68%;margin:40px auto}.blog-root a{color:#28a3ef!important}.blog-root .blog-title{display:block;margin:60px 0 20px 0;text-align:center}.blog-root .blog-detaile{color:#2f2f2f}.blog-root .blog-detaile pre{border:1px #d2e8b9 solid;box-shadow:1px 1px 2px 2px #d2e8b9;margin:5px 0}.blog-root .blog-detaile h4{font-size:20px;font-weight:500}.blog-user{position:fixed;top:60px;left:5px;width:100px;height:100%;background-color:#f9f9f9}.blog-info{padding:15px}.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:22px;line-height:22px;text-align:right;padding-top:26px}.blog-info .blog-author .blog-label label{color:#888;border:1px dotted #aaa;padding:5px;border-radius:5px;font-size:10px}.blog-info .blog-author .author-headimg .img-circle{width:48px!important;height:48px!important;margin-top:0!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{width:68%;margin:0 auto}.comms-root a{text-decoration:none}img{max-width:100%!important}.blog-referral{width:100%;margin:40px auto}.blog-referral p{padding:3px 0}.layui-code-view .layui-code-ol li{margin-left:0!important}.home-container{height:100%;margin:50px 5% 60px 5%}.home-container hr{margin:0}.home-hearder{margin:10px 0;display:flex;height:30px;line-height:30px}.home-hearder .m-select{color:#353535;width:150px;display:inline-block;height:32px;border-radius:3px;padding:4px 14px}.home-hearder .layui-btn-group .active a{color:#fff}.home-hearder .layui-btn-group a{color:#353535;text-decoration:none}.nelson-btn{color:#ec6149!important;border-radius:15px;border:1px solid #bbb!important}.nelson-btn:hover{background:#fff!important;color:#ec6149!important;border-radius:15px;border:1px solid #ec6149!important}.home-content{display:flex;min-height:36px;line-height:36px}.home-content-title{display:inline-block;flex:1}.home-content-desc{display:flex}.home-content-desc span{display:inline-block;text-align:center}.blog-root h5{color:#888;font-size:14px;margin:9px 0;font-family:inherit;font-weight:700;line-height:1.5}.blog-root a{text-decoration:none}.blog-root p{margin:1px 0 9px}.login-root{background:#f0e7db url("/static/img/login.png") no-repeat;position:absolute;min-height:100%;width:100%;overflow:hidden}.login-root .input-container{position:fixed;left:65%;top:33px;background:url("/static/img/loginbg.png") no-repeat center top}.login-root .input-container .input-root{width:370px;height:500px}.login-root .input-container .input-root .inputs-class{margin-top:220px;padding:10px 50px 10px 50px}.login-root .input-container .input-root .regist{margin-top:200px}.login-root .input-container .input-root .inputs-class .login-bottom{margin-top:10px;text-align:right}.login-root .input-container .input-root .input-group{display:table;border-collapse:separate}.login-root .input-container .input-root .inputs-class .input-class{height:32px;margin:18px 0;display:flex} +.login-root .input-container .input-root .inputs-class .input-class input{flex:1;height:26px!important;padding:2px 14px;font-size:12px;line-height:1.5;border-radius:3px;border-top-left-radius:0;border-bottom-left-radius:0;display:table-cell;border:1px solid #ccc}.login-root .input-container .input-root .inputs-class .input-class .input-group-addon{color:#555;line-height:26px!important;font-size:12px;padding:2px 14px;line-height:1.5;border-radius:3px;display:table-cell;border:1px solid #ccc;border-right:0}.login-footer{position:absolute;bottom:0;left:0;width:100%;height:110px}.login-root{background:#f0e7db url("/static/img/login.png") no-repeat;position:absolute;min-height:100%;width:100%;overflow:hidden}.login-root .input-container{position:fixed;left:65%;top:33px;background:url("/static/img/loginbg.png") no-repeat center top}.login-root .input-container .input-root{width:370px;height:500px}.login-root .input-container .input-root p{font-size:21px;text-align:center;padding-top:195px}.login-root .input-container .input-root .inputs-class{padding:0 50px}.login-root .input-container .input-root .input-group{display:table;border-collapse:separate}.login-root .input-container .input-root .inputs-class .input-class{height:32px;margin:18px 0;display:flex}.login-root .input-container .input-root .inputs-class .input-class input{flex:1;height:26px!important;padding:2px 14px;font-size:12px;line-height:1.5;border-radius:3px;border-top-left-radius:0;border-bottom-left-radius:0;display:table-cell;border:1px solid #ccc}.login-root .input-container .input-root .inputs-class .input-class .input-group-addon{color:#555;line-height:26px!important;font-size:12px;padding:2px 14px;line-height:1.5;border-radius:3px;display:table-cell;border:1px solid #ccc;border-right:0}.login-footer{position:absolute;bottom:0;left:0;width:100%;height:110px}.me-menu{position:fixed;top:60px;left:20px;width:260px;height:100%;background-color:#f9f9f9}.me-menu p{cursor:pointer;font-size:15px;color:#555;margin:0;height:32px;line-height:32px}.me-menu .active{color:#3cbef8!important}.me-menu p a{margin-left:5px;color:#555;text-decoration:none}.me-menu .active span{display:inline-block;height:100%;width:2px;background-color:#3cbef8}.me-menu .active a{color:#3cbef8;vertical-align:top;height:32px;line-height:32px;display:inline-block}.me-blog-root{height:100%;margin:50px 4% 0 0}.me-blog-list{margin-left:300px}.me-blog-list p{height:30px;line-height:30px;margin:0;font-size:15px}.me-footer{position:absolute;bottom:0;left:0;width:100%;height:110px;padding:0 4%}.me-blog-footer{height:110px;padding:0 4%;margin-left:290px}.info-header{flex:1}.info-header span{margin-right:6px}.uinfo{color:#515a6e;margin:5px}.udesc span{margin-right:8px}.blog-list{display:flex;font-size:16px;min-height:35px;line-height:35px}.us-root{margin-top:50px;display:flex;margin-left:5%;font-size:16px;min-height:720px;height:100%}.us-root p{padding:5px 0;color:#323232}.us-root a{color:#28a3ef!important}.blog-title{display:flex;height:50px;line-height:50px}.blog-title input{padding-left:12px;flex:1;height:44px;border:0}.blog-title button{height:32px;color:#fff;margin-top:9px}.w-e-toolbar{height:40px;line-height:30px}.map-root{position:absolute;width:100%;height:100%;left:0;top:0}.map-root .map-container{width:100%;height:100%}.amap-logo,.amap-copyright{display:none!important;visibility:hidden!important}.blog-detaile p code{color:red;padding:2px 5px}.search-root{margin-top:50px}.search-root .input-class{display:table;border-collapse:separate}.search-root .input-class{width:50%;height:32px;margin:18px auto;display:flex}.search-root .input-class input{flex:1;height:36px!important;padding:2px 14px;font-size:12px;line-height:1.5;border-radius:3px;border-top-right-radius:0;border-bottom-right-radius:0;display:table-cell;border:1px solid #3385ff}.search-root .input-class .input-group-addon{color:#555;height:36px;line-height:36px!important;font-size:17px!important;font-size:12px;padding:2px 14px;line-height:36px;border-radius:3px;display:table-cell;background-color:#3385ff;border-top-left-radius:0;border-bottom-left-radius:0;color:#fff;border:1px solid #3385ff;border-left:none;cursor:pointer}.search-result{margin:35px 15%}.search-item{padding:7px 15px}.search-result a{display:block;cursor:pointer;height:25px;line-height:25px;font-size:16px;text-decoration:#00c6ff;flex:1}.search-result .search-title{display:flex}.search-result span{cursor:pointer;font-size:12px;height:25px;line-height:25px}.search-content{font-size:12px} \ No newline at end of file diff --git a/utils/EsUtil.go b/utils/EsUtil.go index d458446..4dac778 100644 --- a/utils/EsUtil.go +++ b/utils/EsUtil.go @@ -11,8 +11,10 @@ import ( "strconv" "time" ) + var client *elastic.Client -var host = "http://106.12.3.97:8209/" +var host = "http://47.98.109.5:8209/" + const mapping = ` { "settings":{ @@ -61,7 +63,7 @@ func init() { } } -func Index() { +func Index() { ctx := context.Background() exists, err := client.IndexExists("beeblog").Do(ctx) if err != nil { @@ -81,15 +83,16 @@ func Index() { } } -func ESSave(blog *models.Blog) { +func ESSave(blog *models.Blog) { ctx := context.Background() - id := strconv.FormatInt(blog.Id,10) + id := strconv.FormatInt(blog.Id, 10) _, err := client.Index().Index("beeblog").Type("beeblog").Id(id).BodyJson(blog).Do(ctx) if err != nil { fmt.Println(err) return } } + //删除 func ESDelete(id string) { _, err := client.Delete().Index("beeblog"). @@ -102,20 +105,20 @@ func ESDelete(id string) { } } -func Search(key string) (*models.Blog,error) { +func Search(key string) (*models.Blog, error) { ctx := context.Background() - query := elastic.NewMultiMatchQuery(key,"Title","BlogHtml") + query := elastic.NewMultiMatchQuery(key, "Title", "BlogHtml") searchResult, err := client.Search(). - Index("beeblog"). // 指定index,返回一个*SearchService对象 + Index("beeblog"). // 指定index,返回一个*SearchService对象 //Type("beeblog"). - Query(query). // 设置查询体,返回同一个*SearchService对象 + Query(query). // 设置查询体,返回同一个*SearchService对象 //Sort("user", true). // 按照user升序排列 //From(0).Size(10). // 从第一条数据,找十条,即0-9 - Pretty(true). // 使查询request和返回的结果格式美观 - Do(ctx) // 返回一个*SearchResult + Pretty(true). // 使查询request和返回的结果格式美观 + Do(ctx) // 返回一个*SearchResult if err != nil { - println("search error",err.Error()) - return nil,err + println("search error", err.Error()) + return nil, err } fmt.Printf("找到 [%d] 组tweets\n", searchResult.Hits.TotalHits) // 查看匹配到多少组数据 @@ -124,10 +127,10 @@ func Search(key string) (*models.Blog,error) { for _, item := range searchResult.Each(reflect.TypeOf(typ)) { //从搜索结果中取数据的方法 t := item.(models.Blog) fmt.Printf("%#v\n", t) - return &t,nil + return &t, nil } if err != nil { panic(err) } - return nil,nil -} \ No newline at end of file + return nil, nil +} diff --git a/views/T.header.tpl b/views/T.header.tpl index 27ada73..1416e9e 100644 --- a/views/T.header.tpl +++ b/views/T.header.tpl @@ -8,17 +8,15 @@ {{else}} {{end}} - + -{{/* - {{/* */}} + -{{/* */}} -{{/* */}} + {{end}} \ No newline at end of file