chore: rename blog->eiblog

This commit is contained in:
deepzz0
2021-04-29 11:17:20 +08:00
parent 9c341f88d2
commit 2fbc5fa024
27 changed files with 193 additions and 97 deletions

8
pkg/core/backup/api.go Normal file
View File

@@ -0,0 +1,8 @@
// Package backup provides ...
package backup
// @title APP Demo API
// @version 1.0
// @description This is a sample server celler server.
// @BasePath /api

View File

@@ -1,6 +1,6 @@
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag at
// 2021-04-26 15:31:15.52194 +0800 CST m=+0.022347488
// 2021-04-29 11:12:59.387582 +0800 CST m=+0.016433684
package docs

View File

@@ -12,7 +12,7 @@ import (
"github.com/eiblog/eiblog/pkg/cache"
"github.com/eiblog/eiblog/pkg/config"
"github.com/eiblog/eiblog/pkg/core/blog"
"github.com/eiblog/eiblog/pkg/core/eiblog"
"github.com/eiblog/eiblog/pkg/internal"
"github.com/eiblog/eiblog/pkg/model"
"github.com/eiblog/eiblog/tools"
@@ -67,7 +67,7 @@ func handleAcctLogin(c *gin.Context) {
return
}
// 登录成功
blog.SetLogin(c, user)
eiblog.SetLogin(c, user)
cache.Ei.Account.LoginIP = c.ClientIP()
cache.Ei.Account.LoginAt = time.Now()
@@ -197,7 +197,7 @@ func handleAPIPostDelete(c *gin.Context) {
var ids []int
for _, v := range c.PostFormArray("cid[]") {
id, err := strconv.Atoi(v)
if err != nil || id < config.Conf.BlogApp.General.StartID {
if err != nil || id < config.Conf.EiBlogApp.General.StartID {
responseNotice(c, NoticeNotice, "参数错误", "")
return
}

View File

@@ -1,5 +1,5 @@
// Package blog provides ...
package blog
// Package eiblog provides ...
package eiblog
import (
"net/http"

View File

@@ -0,0 +1,65 @@
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag at
// 2021-04-29 11:12:59.414073 +0800 CST m=+0.019228292
package docs
import (
"bytes"
"encoding/json"
"github.com/alecthomas/template"
"github.com/swaggo/swag"
)
var doc = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "This is a sample server celler server.",
"title": "APP Demo API",
"contact": {},
"license": {},
"version": "1.0"
},
"host": "{{.Host}}",
"basePath": "/api",
"paths": {}
}`
type swaggerInfo struct {
Version string
Host string
BasePath string
Schemes []string
Title string
Description string
}
// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = swaggerInfo{ Schemes: []string{}}
type s struct{}
func (s *s) ReadDoc() string {
t, err := template.New("swagger_info").Funcs(template.FuncMap{
"marshal": func(v interface {}) string {
a, _ := json.Marshal(v)
return string(a)
},
}).Parse(doc)
if err != nil {
return doc
}
var tpl bytes.Buffer
if err := t.Execute(&tpl, SwaggerInfo); err != nil {
return doc
}
return tpl.String()
}
func init() {
swag.Register(swag.Name, &s{})
}

View File

@@ -0,0 +1,13 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server celler server.",
"title": "APP Demo API",
"contact": {},
"license": {},
"version": "1.0"
},
"host": "{{.Host}}",
"basePath": "/api",
"paths": {}
}

View File

@@ -0,0 +1,10 @@
basePath: /api
host: '{{.Host}}'
info:
contact: {}
description: This is a sample server celler server.
license: {}
title: APP Demo API
version: "1.0"
paths: {}
swagger: "2.0"

View File

@@ -46,8 +46,8 @@ func timerFeed() {
params := map[string]interface{}{
"Title": cache.Ei.Blogger.BTitle,
"SubTitle": cache.Ei.Blogger.SubTitle,
"Host": config.Conf.BlogApp.Host,
"FeedrURL": config.Conf.BlogApp.FeedRPC.FeedrURL,
"Host": config.Conf.EiBlogApp.Host,
"FeedrURL": config.Conf.EiBlogApp.FeedRPC.FeedrURL,
"BuildDate": now.Format(time.RFC1123Z),
"Articles": articles,
}
@@ -75,7 +75,7 @@ func timerSitemap() {
params := map[string]interface{}{
"Articles": cache.Ei.Articles,
"Host": config.Conf.BlogApp.Host,
"Host": config.Conf.EiBlogApp.Host,
}
f, err := os.OpenFile("assets/sitemap.xml", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
if err != nil {
@@ -101,7 +101,7 @@ func generateOpensearch() {
params := map[string]string{
"BTitle": cache.Ei.Blogger.BTitle,
"SubTitle": cache.Ei.Blogger.SubTitle,
"Host": config.Conf.BlogApp.Host,
"Host": config.Conf.EiBlogApp.Host,
}
f, err := os.OpenFile("assets/opensearch.xml", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
if err != nil {
@@ -124,7 +124,7 @@ func generateRobots() {
return
}
params := map[string]string{
"Host": config.Conf.BlogApp.Host,
"Host": config.Conf.EiBlogApp.Host,
}
f, err := os.OpenFile("assets/robots.txt", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
if err != nil {
@@ -147,7 +147,7 @@ func generateCrossdomain() {
return
}
params := map[string]string{
"Host": config.Conf.BlogApp.Host,
"Host": config.Conf.EiBlogApp.Host,
}
f, err := os.OpenFile("assets/crossdomain.xml", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
if err != nil {

View File

@@ -13,7 +13,7 @@ import (
"github.com/eiblog/eiblog/pkg/cache"
"github.com/eiblog/eiblog/pkg/cache/store"
"github.com/eiblog/eiblog/pkg/config"
"github.com/eiblog/eiblog/pkg/core/blog"
"github.com/eiblog/eiblog/pkg/core/eiblog"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
@@ -23,7 +23,7 @@ import (
func baseBEParams(c *gin.Context) gin.H {
return gin.H{
"Author": cache.Ei.Account.Username,
"Qiniu": config.Conf.BlogApp.Qiniu,
"Qiniu": config.Conf.EiBlogApp.Qiniu,
}
}
@@ -31,8 +31,8 @@ func baseBEParams(c *gin.Context) gin.H {
func handleLoginPage(c *gin.Context) {
logout := c.Query("logout")
if logout == "true" {
blog.SetLogout(c)
} else if blog.IsLogined(c) {
eiblog.SetLogout(c)
} else if eiblog.IsLogined(c) {
c.Redirect(http.StatusFound, "/admin/profile")
return
}
@@ -70,7 +70,7 @@ func handleAdminPost(c *gin.Context) {
params["Title"] = "撰写文章 | " + cache.Ei.Blogger.BTitle
}
params["Path"] = c.Request.URL.Path
params["Domain"] = config.Conf.BlogApp.Host
params["Domain"] = config.Conf.EiBlogApp.Host
params["Series"] = cache.Ei.Series
var tags []T
for tag := range cache.Ei.TagArticles {
@@ -104,7 +104,7 @@ func handleAdminPosts(c *gin.Context) {
params["KW"] = kw
var max int
params["List"], max = cache.Ei.PageArticleBE(se, kw, false, false,
pg, config.Conf.BlogApp.General.PageSize)
pg, config.Conf.EiBlogApp.General.PageSize)
if pg < max {
vals.Set("page", fmt.Sprint(pg+1))
params["Next"] = vals.Encode()

View File

@@ -26,19 +26,19 @@ func baseFEParams(c *gin.Context) gin.H {
cookie, err := c.Request.Cookie("v")
if err != nil || cookie.Value !=
fmt.Sprint(config.Conf.BlogApp.StaticVersion) {
version = config.Conf.BlogApp.StaticVersion
fmt.Sprint(config.Conf.EiBlogApp.StaticVersion) {
version = config.Conf.EiBlogApp.StaticVersion
}
return gin.H{
"BlogName": cache.Ei.Blogger.BlogName,
"SubTitle": cache.Ei.Blogger.SubTitle,
"BTitle": cache.Ei.Blogger.BTitle,
"BeiAn": cache.Ei.Blogger.BeiAn,
"Domain": config.Conf.BlogApp.Host,
"Domain": config.Conf.EiBlogApp.Host,
"CopyYear": time.Now().Year(),
"Twitter": config.Conf.BlogApp.Twitter,
"Qiniu": config.Conf.BlogApp.Qiniu,
"Disqus": config.Conf.BlogApp.Disqus,
"Twitter": config.Conf.EiBlogApp.Twitter,
"Qiniu": config.Conf.EiBlogApp.Qiniu,
"Disqus": config.Conf.EiBlogApp.Disqus,
"Version": version,
}
}
@@ -65,7 +65,7 @@ func handleHomePage(c *gin.Context) {
pn = 1
}
params["Prev"], params["Next"], params["List"] = cache.Ei.PageArticleFE(pn,
config.Conf.BlogApp.General.PageNum)
config.Conf.EiBlogApp.General.PageNum)
renderHTMLHomeLayout(c, "home", params)
}
@@ -151,7 +151,7 @@ func handleSearchPage(c *gin.Context) {
params["Word"] = q
vals := c.Request.URL.Query()
result, err := internal.ElasticSearch(q, config.Conf.BlogApp.General.PageNum, start-1)
result, err := internal.ElasticSearch(q, config.Conf.EiBlogApp.General.PageNum, start-1)
if err != nil {
logrus.Error("HandleSearchPage.ElasticSearch: ", err)
} else {
@@ -163,17 +163,17 @@ func handleSearchPage(c *gin.Context) {
}
}
params["SearchResult"] = result
if num := start - config.Conf.BlogApp.General.PageNum; num > 0 {
if num := start - config.Conf.EiBlogApp.General.PageNum; num > 0 {
vals.Set("start", fmt.Sprint(num))
params["Prev"] = vals.Encode()
}
if num := start + config.Conf.BlogApp.General.PageNum; result.Hits.Total >= num {
if num := start + config.Conf.EiBlogApp.General.PageNum; result.Hits.Total >= num {
vals.Set("start", fmt.Sprint(num))
params["Next"] = vals.Encode()
}
}
} else {
params["HotWords"] = config.Conf.BlogApp.HotWords
params["HotWords"] = config.Conf.EiBlogApp.HotWords
}
renderHTMLHomeLayout(c, "search", params)
}
@@ -324,16 +324,16 @@ func handleBeaconPage(c *gin.Context) {
ua := c.Request.UserAgent()
vals := c.Request.URL.Query()
vals.Set("v", config.Conf.BlogApp.Google.V)
vals.Set("tid", config.Conf.BlogApp.Google.Tid)
vals.Set("t", config.Conf.BlogApp.Google.T)
vals.Set("v", config.Conf.EiBlogApp.Google.V)
vals.Set("tid", config.Conf.EiBlogApp.Google.Tid)
vals.Set("t", config.Conf.EiBlogApp.Google.T)
cookie, _ := c.Cookie("u")
vals.Set("cid", cookie)
vals.Set("dl", c.Request.Referer())
vals.Set("uip", c.ClientIP())
go func() {
req, err := http.NewRequest("POST", config.Conf.BlogApp.Google.URL,
req, err := http.NewRequest("POST", config.Conf.EiBlogApp.Google.URL,
strings.NewReader(vals.Encode()))
if err != nil {
logrus.Error("HandleBeaconPage.NewRequest: ", err)

View File

@@ -2,7 +2,7 @@
package swag
import (
_ "github.com/eiblog/eiblog/pkg/core/blog/docs" // docs
_ "github.com/eiblog/eiblog/pkg/core/eiblog/docs" // docs
"github.com/gin-gonic/gin"
ginSwagger "github.com/swaggo/gin-swagger"