Compare commits

..

53 Commits

Author SHA1 Message Date
henry.chen
7c938bf024 chore(release): 2.2.10 2023-12-22 14:12:15 +08:00
henry.chen
65fcc69efa chore: bump all gorm & driver version 2023-12-22 14:10:36 +08:00
henry.chen
d06bab72a5 chore: bump gin swagger version to v1.6.0 2023-12-22 14:03:57 +08:00
henry.chen
95900eec1a chore: rm http header: Expect-CT 2023-12-07 09:55:30 +08:00
henry.chen
dfae78891d chore: update ad config 2023-12-01 13:46:29 +08:00
henry.chen
c515e33e2c chore(release): 2.2.9 2023-09-25 18:14:51 +08:00
henry.chen
5b12dd625b chore: update config 2023-09-25 18:14:41 +08:00
henry.chen
9b918caccd fix: google analytics not work, supported ga4 measurement protocol 2023-09-25 18:12:57 +08:00
Deepzz
2be53379e1 Update writing.md 2023-09-13 10:49:51 +08:00
Deepzz
944e27c58a Update app.yml 2023-09-13 10:45:56 +08:00
Deepzz
92baf970bc Update docker-compose.yml 2023-07-12 17:33:18 +08:00
henry.chen
64a754167a chore(release): 2.2.8 2023-07-12 17:30:37 +08:00
henry.chen
af2a20c34a chore: update 2023-07-12 17:30:34 +08:00
henry.chen
f28d0e77e0 fix(backup): restore db and tests 2023-07-12 17:26:44 +08:00
henry.chen
9a1b4db61a chore: update 2023-07-12 15:14:47 +08:00
henry.chen
c9d04aded3 chore(release): 2.2.7 2023-07-12 15:01:40 +08:00
henry.chen
ee51f678cb fix(backup): 数据恢复错误 2023-07-12 14:59:11 +08:00
Deepzz
434c1bf168 Update README.md 2023-06-19 23:19:00 +08:00
henry.chen
d2de603957 chore(release): 2.2.6 2023-06-19 23:13:56 +08:00
henry.chen
e7fdf6b1db chore(backup): backup blog with prefix: blog 2023-06-19 23:13:45 +08:00
Deepzz
305ae0ee70 Merge pull request #40 from eiblog/dependabot/go_modules/github.com/gin-gonic/gin-1.9.1
chore(deps): bump github.com/gin-gonic/gin from 1.9.0 to 1.9.1
2023-06-12 16:55:16 +08:00
dependabot[bot]
a5749fdab6 chore(deps): bump github.com/gin-gonic/gin from 1.9.0 to 1.9.1
Bumps [github.com/gin-gonic/gin](https://github.com/gin-gonic/gin) from 1.9.0 to 1.9.1.
- [Release notes](https://github.com/gin-gonic/gin/releases)
- [Changelog](https://github.com/gin-gonic/gin/blob/master/CHANGELOG.md)
- [Commits](https://github.com/gin-gonic/gin/compare/v1.9.0...v1.9.1)

---
updated-dependencies:
- dependency-name: github.com/gin-gonic/gin
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-01 20:35:02 +00:00
henry.chen
391f19e2a9 chore(release): 2.2.5 2023-05-26 09:57:35 +08:00
henry.chen
2c6c5bb977 fix(backup): libresolv.so.2: No such file or directory 2023-05-26 09:57:30 +08:00
henry.chen
860a85e209 chore: update go.mod 2023-05-25 16:46:26 +08:00
henry.chen
2a8d9b3bbd chore(release): 2.2.4 2023-05-25 16:44:34 +08:00
henry.chen
1509a68cda fix(ci): fix .dockerignore 2023-05-25 16:44:31 +08:00
henry.chen
7f26503247 chore(release): 2.2.3 2023-05-25 16:16:32 +08:00
henry.chen
235145ed46 chore(ci): print log 2023-05-25 16:16:28 +08:00
henry.chen
20e89d6a76 fix(ci): script file name 2023-05-25 16:08:45 +08:00
henry.chen
d86ab71ad9 chore(release): 2.2.2 2023-05-25 16:06:36 +08:00
henry.chen
4600ed5094 chore(ci): adjust ci 2023-05-25 16:06:31 +08:00
henry.chen
5fcadd1c81 chore(ci): golang version to 1.20 2023-05-17 15:58:44 +08:00
henry.chen
42b106d582 chore(release): 2.2.1 2023-05-17 15:49:04 +08:00
henry.chen
bb06be36fe fix: try to fix backup symbol not found 2023-05-17 15:49:01 +08:00
henry.chen
cb3fb2d2e7 chore(release): 2.2.0 2023-05-17 14:47:23 +08:00
henry.chen
779a23cb75 feat(backup): add restore flag 2023-05-17 14:42:28 +08:00
Deepzz
e2fa96cd62 Update docker-compose.yml 2023-05-15 08:58:56 +08:00
Deepzz
db26fb51e5 Merge pull request #37 from eiblog/dependabot/go_modules/github.com/gin-gonic/gin-1.9.0
chore(deps): bump github.com/gin-gonic/gin from 1.7.7 to 1.9.0
2023-05-06 09:09:41 +08:00
dependabot[bot]
994be5d508 chore(deps): bump github.com/gin-gonic/gin from 1.7.7 to 1.9.0
Bumps [github.com/gin-gonic/gin](https://github.com/gin-gonic/gin) from 1.7.7 to 1.9.0.
- [Release notes](https://github.com/gin-gonic/gin/releases)
- [Changelog](https://github.com/gin-gonic/gin/blob/master/CHANGELOG.md)
- [Commits](https://github.com/gin-gonic/gin/compare/v1.7.7...v1.9.0)

---
updated-dependencies:
- dependency-name: github.com/gin-gonic/gin
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-05 02:39:43 +00:00
henry.chen
a5c3d33565 chore: OpenSearch support mozilla firefox 2023-02-24 10:41:13 +08:00
Deepzz
1ffc58eccf Merge pull request #36 from eiblog/dependabot/go_modules/github.com/gin-gonic/gin-1.7.7
chore(deps): bump github.com/gin-gonic/gin from 1.7.4 to 1.7.7
2023-02-10 09:08:56 +08:00
dependabot[bot]
b6ad4e8949 chore(deps): bump github.com/gin-gonic/gin from 1.7.4 to 1.7.7
Bumps [github.com/gin-gonic/gin](https://github.com/gin-gonic/gin) from 1.7.4 to 1.7.7.
- [Release notes](https://github.com/gin-gonic/gin/releases)
- [Changelog](https://github.com/gin-gonic/gin/blob/master/CHANGELOG.md)
- [Commits](https://github.com/gin-gonic/gin/compare/v1.7.4...v1.7.7)

---
updated-dependencies:
- dependency-name: github.com/gin-gonic/gin
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-09 22:49:33 +00:00
henry.chen
41704917db chore(release): 2.1.18 2023-01-05 14:15:54 +08:00
henry.chen
f6ba716f55 fix(backup): can not execute 2023-01-05 14:15:46 +08:00
henry.chen
b2e6c168c5 fix: disqus api using http post 2023-01-05 13:51:18 +08:00
henry.chen
eca741896f chore(release): 2.1.17 2023-01-05 13:28:48 +08:00
henry.chen
17792e5a7e fix: fist comment of disqus error 2023-01-05 13:25:18 +08:00
henry.chen
04289c633e chore: optimize variable naming 2023-01-05 11:07:56 +08:00
henry.chen
3a5eb6fccc chore(release): 2.1.18 2023-01-05 09:17:39 +08:00
henry.chen
f6d8656c83 fix: 1. template read panic
2. optimization variable naming
2023-01-05 09:17:31 +08:00
henry.chen
4690d5123b chore(release): 2.1.17 2023-01-05 00:00:11 +08:00
henry.chen
a9e8e39d34 fix(disqus): failed to commit disqus comments 2023-01-04 23:58:50 +08:00
43 changed files with 3307 additions and 741 deletions

View File

@@ -1,12 +1,12 @@
# Ignore all files and dirs
*
# Unignore files or dirs
!build
!bin
!conf
!assets
!website
!CHANGELOG.md
!LICENSE
!README.md
.github
bin
docs
.gitignore
db.sqlite
docker-compose.yml
eiblog.conf
Makefile

View File

@@ -9,35 +9,47 @@ jobs:
package:
runs-on: ubuntu-latest
steps:
- name: Golang env
uses: actions/setup-go@v2
with:
go-version: ^1.15
- name: Checkout
uses: actions/checkout@v2
- name: Cache mod
uses: actions/cache@v1
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
platforms: linux/amd64,linux/arm64,linux/arm/v7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker tag
id: vars
run: echo ::set-output name=tag::$(echo ${GITHUB_REF:10})
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Docker login
uses: docker/login-action@v1
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
password: ${{ secrets.DOCKER_PASSWORD }}
username: ${{ secrets.DOCKER_USERNAME }}
- name: Build image
env:
GOPROXY: https://goproxy.io,direct
run: scripts/run_build.sh deepzz0 ${{ steps.vars.outputs.tag }}
- name: Build and push eiblog
uses: docker/build-push-action@v3
with:
context: .
file: ./build/package/eiblog.Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: |
deepzz0/eiblog:${{ steps.vars.outputs.tag }}
deepzz0/eiblog:latest
- name: Build and push backup
uses: docker/build-push-action@v3
with:
context: .
file: ./build/package/backup.Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
tags: |
deepzz0/backup:${{ steps.vars.outputs.tag }}
deepzz0/backup:latest
- name: Package tar
env:

1
.gitignore vendored
View File

@@ -19,3 +19,4 @@ backend
# vendor/
bin
assets/*.*
db.sqlite

View File

@@ -2,6 +2,85 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [2.2.10](https://github.com/eiblog/eiblog/compare/v2.2.9...v2.2.10) (2023-12-22)
### [2.2.9](https://github.com/eiblog/eiblog/compare/v2.2.8...v2.2.9) (2023-09-25)
### Bug Fixes
* google analytics not work, supported ga4 measurement protocol ([9b918ca](https://github.com/eiblog/eiblog/commit/9b918caccd9fd7faff7d253693e075ccd0150c17))
### [2.2.8](https://github.com/eiblog/eiblog/compare/v2.2.7...v2.2.8) (2023-07-12)
### Bug Fixes
* **backup:** restore db and tests ([f28d0e7](https://github.com/eiblog/eiblog/commit/f28d0e77e06dd435dc13a1867f18a011e34b8f53))
### [2.2.7](https://github.com/eiblog/eiblog/compare/v2.2.6...v2.2.7) (2023-07-12)
### Bug Fixes
* **backup:** 数据恢复错误 ([ee51f67](https://github.com/eiblog/eiblog/commit/ee51f678cbf93332fedccf927704e78a6063289c))
### [2.2.6](https://github.com/eiblog/eiblog/compare/v2.2.5...v2.2.6) (2023-06-19)
### [2.2.5](https://github.com/eiblog/eiblog/compare/v2.2.4...v2.2.5) (2023-05-26)
### Bug Fixes
* **backup:** libresolv.so.2: No such file or directory ([2c6c5bb](https://github.com/eiblog/eiblog/commit/2c6c5bb97708683bed8c889a7a1076f1f88ee5a8))
### [2.2.4](https://github.com/eiblog/eiblog/compare/v2.2.3...v2.2.4) (2023-05-25)
### Bug Fixes
* **ci:** fix .dockerignore ([1509a68](https://github.com/eiblog/eiblog/commit/1509a68cda74ace6b4060b5015f20143303ca36f))
### [2.2.3](https://github.com/eiblog/eiblog/compare/v2.2.2...v2.2.3) (2023-05-25)
### Bug Fixes
* **ci:** script file name ([20e89d6](https://github.com/eiblog/eiblog/commit/20e89d6a76f01aee60b98f8ae43a2c65b4fb3904))
### [2.2.2](https://github.com/eiblog/eiblog/compare/v2.2.1...v2.2.2) (2023-05-25)
### [2.2.1](https://github.com/eiblog/eiblog/compare/v2.2.0...v2.2.1) (2023-05-17)
### Bug Fixes
* try to fix backup symbol not found ([bb06be3](https://github.com/eiblog/eiblog/commit/bb06be36fe016e753ca56aa2321ce7e39bffe3e0))
## [2.2.0](https://github.com/eiblog/eiblog/compare/v2.1.18...v2.2.0) (2023-05-17)
### Features
* **backup:** add restore flag ([779a23c](https://github.com/eiblog/eiblog/commit/779a23cb75ab5059826370d08b754569a4af4aea))
### [2.1.18](https://github.com/eiblog/eiblog/compare/v2.1.17...v2.1.18) (2023-01-05)
### Bug Fixes
* **backup:** can not execute ([f6ba716](https://github.com/eiblog/eiblog/commit/f6ba716f554cfb638752875c4842e4ffb1b7e9a6))
* disqus api using http post ([b2e6c16](https://github.com/eiblog/eiblog/commit/b2e6c168c5f63b29cf5c2884e04dd99caa677bc0))
### [2.1.17](https://github.com/eiblog/eiblog/compare/v2.1.16...v2.1.17) (2023-01-05)
### Bug Fixes
* 1. template read panic ([f6d8656](https://github.com/eiblog/eiblog/commit/f6d8656c83591584581383643d109611d7ed2caa))
* **disqus:** failed to commit disqus comments ([a9e8e39](https://github.com/eiblog/eiblog/commit/a9e8e39d342488ec46175997f3df9ab109f2fecf))
* fist comment of disqus error ([17792e5](https://github.com/eiblog/eiblog/commit/17792e5a7edb7e84623d9307555e7983ba306565))
### [2.1.16](https://github.com/eiblog/eiblog/compare/v2.1.15...v2.1.16) (2022-11-20)

View File

@@ -1,4 +1,4 @@
# EiBlog [![Build Status](https://travis-ci.org/eiblog/eiblog.svg?branch=v1.3.0)](https://travis-ci.org/eiblog/eiblog) [![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE.md) [![Versuib](https://img.shields.io/github/tag/eiblog/eiblog.svg)](https://github.com/eiblog/eiblog/releases)
# EiBlog [![License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE.md) [![Versuib](https://img.shields.io/github/tag/eiblog/eiblog.svg)](https://github.com/eiblog/eiblog/releases)
> 博客项目结构参考模版https://github.com/deepzz0/appdemo

View File

@@ -1,13 +1,20 @@
FROM golang:1.20 AS builder
WORKDIR /eiblog
COPY . .
RUN ./scripts/run_build.sh backup
FROM alpine:latest
LABEL maintainer="deepzz.qi@gmail.com"
RUN sed -i "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g" /etc/apk/repositories \
&& apk add --update --no-cache tzdata ca-certificates mongodb-tools
RUN apk add --update --no-cache tzdata ca-certificates \
mongodb-tools libc6-compat gcompat
COPY README.md /app/README.md
COPY CHANGELOG.md /app/CHANGELOG.md
COPY LICENSE /app/LICENSE
COPY bin/backend /app/backend
COPY --from=builder /eiblog/bin/backend /app/backend
COPY conf /app/conf
EXPOSE 9001

View File

@@ -1,13 +1,19 @@
FROM golang:1.20 AS builder
WORKDIR /eiblog
COPY . .
RUN ./scripts/run_build.sh eiblog
FROM alpine:latest
LABEL maintainer="deepzz.qi@gmail.com"
RUN sed -i "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g" /etc/apk/repositories \
&& apk add --update --no-cache tzdata
RUN apk add --update --no-cache tzdata
COPY README.md /app/README.md
COPY CHANGELOG.md /app/CHANGELOG.md
COPY LICENSE /app/LICENSE
COPY bin/backend /app/backend
COPY --from=builder /eiblog/bin/backend /app/backend
COPY conf /app/conf
COPY website /app/website
COPY assets /app/assets

View File

@@ -2,6 +2,7 @@
package main
import (
"flag"
"fmt"
"github.com/eiblog/eiblog/pkg/config"
@@ -12,20 +13,27 @@ import (
"github.com/gin-gonic/gin"
)
var restore bool
func init() {
flag.BoolVar(&restore, "restore", false, "restore data into mongodb")
}
func main() {
fmt.Println("Hi, it's App " + config.Conf.BackupApp.Name)
flag.Parse()
endRun := make(chan error, 1)
runTimer(endRun)
runCommand(restore, endRun)
runHTTPServer(endRun)
fmt.Println(<-endRun)
}
func runTimer(endRun chan error) {
func runCommand(restore bool, endRun chan error) {
go func() {
endRun <- timer.Start()
endRun <- timer.Start(restore)
}()
}

View File

@@ -2,7 +2,7 @@ appname: eiblog
database:
driver: sqlite
source: ./db.sqlite
eshost:
eshost: # http://elasticsearch:9200
eiblogapp:
mode:
name: cmd-eiblog
@@ -28,11 +28,10 @@ eiblogapp:
publickey: wdSgxRm9rdGAlLKFcFdToBe3GT4SibmV7Y8EjJQ0r4GWXeKtxpopMAeIeoI2dTEg
accesstoken: 50023908f39f4607957e909b495326af
google: # 谷歌分析
url: https://www.google-analytics.com/collect
tid: UA-xxxxxx-1
v: "1"
t: pageview
adsense: <script data-ad-client="ca-pub-5384494508691406" async src=""></script>
url: https://www.google-analytics.com/g/collect
tid: G-xxxxxxxxxx
v: "2"
adsense: <script async src="https://pagead2.googlesyndication.com/xxx" crossorigin="anonymous"></script>
qiniu: # 七牛OSS
bucket: eiblog
domain: st.deepzz.com

View File

@@ -11,7 +11,7 @@ services:
- ${PWD}/esdata:/usr/share/elasticsearch/data
restart: always
eiblog:
iamge: deepzz0/eiblog:latest
image: deepzz0/eiblog:latest
volumes:
- ${PWD}/conf:/app/conf
extra_hosts:
@@ -27,6 +27,7 @@ services:
restart: always
backup:
image: deepzz0/backup:latest
#command: ./backend --restore true
volumes:
- ${PWD}/conf:/app/conf
links:

View File

@@ -34,7 +34,7 @@
![article-description](./img/article-description.png)
### 图片懒加载
博客系统提供图片懒加载功能浏览到某个位置图片才会加载以此来提高页面加载速度。我们可根据需要是否使用。当然由此带来的坏处就是rss不能够正确加载图片。后续看是否解决这个问题或朋友提PR。
博客系统提供图片懒加载功能(浏览到某个位置,图片才会加载),以此来提高页面加载速度。我们可根据需要是否使用。~~当然由此带来的坏处就是rss不能够正确加载图片。后续看是否解决这个问题或朋友提PR。~~,已解决。
首先看下图片的`markdown`标准写法:
```

View File

@@ -78,9 +78,6 @@ server {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location ^~ /admin/ {
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
# https://imququ.com/post/web-security-and-response-header.html#toc-1
# 期望CT: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Expect-CT
add_header Expect-CT "max-age=180";
add_header Cache-Control no-cache;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
@@ -93,9 +90,6 @@ server {
location / {
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
# https://imququ.com/post/web-security-and-response-header.html#toc-1
# 期望CT: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Expect-CT
add_header Expect-CT "max-age=180";
add_header Cache-Control no-cache;
# 内容安全策略: https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
add_header Content-Security-Policy "default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' blob: https:; img-src data: https:; media-src https:; style-src 'unsafe-inline' https:; child-src https:; connect-src 'self'; frame-src https://disqus.com";

28
go.mod
View File

@@ -4,23 +4,21 @@ go 1.15
require (
github.com/eiblog/blackfriday v0.0.0-20161010144836-c0ec111761ae
github.com/gin-contrib/sessions v0.0.3
github.com/gin-gonic/gin v1.7.4
github.com/golang/protobuf v1.4.2
github.com/lib/pq v1.10.1
github.com/gin-contrib/sessions v0.0.5
github.com/gin-gonic/gin v1.9.1
github.com/lib/pq v1.10.9
github.com/qiniu/go-sdk/v7 v7.11.0
github.com/satori/go.uuid v1.2.0
github.com/sirupsen/logrus v1.4.2
github.com/sirupsen/logrus v1.9.3
github.com/swaggo/files v0.0.0-20190704085106-630677cd5c14
github.com/swaggo/gin-swagger v1.3.3
github.com/swaggo/swag v1.7.4
go.mongodb.org/mongo-driver v1.5.1
google.golang.org/grpc v1.35.0
google.golang.org/protobuf v1.25.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
gorm.io/driver/clickhouse v0.1.0
gorm.io/driver/mysql v1.0.6
gorm.io/driver/postgres v1.0.8
gorm.io/driver/sqlite v1.1.4
gorm.io/driver/sqlserver v1.0.7
gorm.io/gorm v1.21.9
go.mongodb.org/mongo-driver v1.11.4
gopkg.in/yaml.v3 v3.0.1
gorm.io/driver/clickhouse v0.6.0
gorm.io/driver/mysql v1.5.2
gorm.io/driver/postgres v1.5.4
gorm.io/driver/sqlite v1.5.4
gorm.io/driver/sqlserver v1.5.2
gorm.io/gorm v1.25.5
)

2924
go.sum

File diff suppressed because it is too large Load Diff

12
pkg/cache/cache.go vendored
View File

@@ -25,9 +25,11 @@ var (
// Ei eiblog cache
Ei *Cache
// regenerate pages chan
PagesCh = make(chan string, 2)
PageSeries = "series-md"
// PagesCh regenerate pages chan
PagesCh = make(chan string, 2)
// PageSeries the page series regenerate flag
PageSeries = "series-md"
// PageArchive the page archive regenerate flag
PageArchive = "archive-md"
// ArticleStartID article start id
@@ -518,7 +520,7 @@ func (c *Cache) regeneratePages() {
}
buf.WriteString("\n")
}
c.PageSeries = string(render.RenderPage(buf.Bytes()))
c.PageSeries = string(render.PageRender(buf.Bytes()))
case PageArchive:
sort.Sort(c.Archives)
buf := bytes.Buffer{}
@@ -551,7 +553,7 @@ func (c *Cache) regeneratePages() {
}
}
}
c.PageArchives = string(render.RenderPage(buf.Bytes()))
c.PageArchives = string(render.PageRender(buf.Bytes()))
}
}
}

View File

@@ -14,7 +14,7 @@ import (
// blackfriday 配置
const (
commonHtmlFlags = 0 |
commonHTMLFlags = 0 |
blackfriday.HTML_TOC |
blackfriday.HTML_USE_XHTML |
blackfriday.HTML_USE_SMARTYPANTS |
@@ -42,9 +42,9 @@ var (
regHeader = regexp.MustCompile("</nav></div>")
)
// RenderPage 渲染markdown
func RenderPage(md []byte) []byte {
renderer := blackfriday.HtmlRenderer(commonHtmlFlags, "", "")
// PageRender 渲染markdown
func PageRender(md []byte) []byte {
renderer := blackfriday.HtmlRenderer(commonHTMLFlags, "", "")
return blackfriday.Markdown(md, renderer, commonExtensions)
}
@@ -56,12 +56,12 @@ func GenerateExcerptMarkdown(article *model.Article) {
index := strings.Index(article.Content, "\r\n")
prefix := article.Content[len(blogapp.General.DescPrefix):index]
article.Desc = tools.IgnoreHtmlTag(prefix)
article.Desc = tools.IgnoreHTMLTag(prefix)
article.Content = article.Content[index:]
}
// 查找目录
content := RenderPage([]byte(article.Content))
content := PageRender([]byte(article.Content))
index := regHeader.FindIndex(content)
if index != nil {
article.Header = string(content[0:index[1]])
@@ -73,7 +73,7 @@ func GenerateExcerptMarkdown(article *model.Article) {
// excerpt
index = regIdentifier.FindStringIndex(article.Content)
if index != nil {
article.Excerpt = tools.IgnoreHtmlTag(article.Content[:index[0]])
article.Excerpt = tools.IgnoreHTMLTag(article.Content[:index[0]])
return
}
uc := []rune(article.Content)
@@ -81,5 +81,5 @@ func GenerateExcerptMarkdown(article *model.Article) {
if len(uc) < length {
length = len(uc)
}
article.Excerpt = tools.IgnoreHtmlTag(string(uc[0:length]))
article.Excerpt = tools.IgnoreHTMLTag(string(uc[0:length]))
}

View File

@@ -326,6 +326,11 @@ func (db *mongodb) LoadArticleList(ctx context.Context, search SearchArticles) (
return articles, int(count), nil
}
// DropDatabase drop eiblog database
func (db *mongodb) DropDatabase(ctx context.Context) error {
return db.Database(mongoDBName).Drop(ctx)
}
// counter counter
type counter struct {
Name string

View File

@@ -13,7 +13,7 @@ var (
store Store
acct *model.Account
blogger *model.Blogger
series *model.Series
series *model.Serie
article *model.Article
)
@@ -25,12 +25,12 @@ func init() {
}
// account
acct = &model.Account{
Username: "deepzz",
Password: "deepzz",
Email: "deepzz@example.com",
PhoneN: "12345678900",
Address: "address",
CreateTime: time.Now(),
Username: "deepzz",
Password: "deepzz",
Email: "deepzz@example.com",
PhoneN: "12345678900",
Address: "address",
CreatedAt: time.Now(),
}
// blogger
blogger = &model.Blogger{
@@ -41,11 +41,11 @@ func init() {
Copyright: "Copyright",
}
// series
series = &model.Series{
Slug: "slug",
Name: "series name",
Desc: "series desc",
CreateTime: time.Now(),
series = &model.Serie{
Slug: "slug",
Name: "series name",
Desc: "series desc",
CreatedAt: time.Now(),
}
// article
article = &model.Article{
@@ -55,21 +55,20 @@ func init() {
Count: 0,
Content: "### count",
SerieID: 0,
Tags: "",
Tags: nil,
IsDraft: false,
UpdateTime: time.Now(),
CreateTime: time.Now(),
UpdatedAt: time.Now(),
CreatedAt: time.Now(),
}
}
func TestLoadInsertAccount(t *testing.T) {
acct2, err := store.LoadInsertAccount(context.Background(), acct)
ok, err := store.LoadInsertAccount(context.Background(), acct)
if err != nil {
t.Fatal(err)
}
t.Log(acct2)
t.Log(acct == acct2)
t.Log(ok)
}
func TestUpdateAccount(t *testing.T) {
@@ -86,12 +85,11 @@ func TestUpdateAccount(t *testing.T) {
}
func TestLoadInsertBlogger(t *testing.T) {
blogger2, err := store.LoadInsertBlogger(context.Background(), blogger)
ok, err := store.LoadInsertBlogger(context.Background(), blogger)
if err != nil {
t.Fatal(err)
}
t.Log(blogger2)
t.Log(blogger == blogger2)
t.Log(ok)
}
func TestUpdateBlogger(t *testing.T) {
@@ -104,21 +102,21 @@ func TestUpdateBlogger(t *testing.T) {
}
func TestInsertSeries(t *testing.T) {
err := store.InsertSeries(context.Background(), series)
err := store.InsertSerie(context.Background(), series)
if err != nil {
t.Fatal(err)
}
}
func TestRemoveSeries(t *testing.T) {
err := store.RemoveSeries(context.Background(), 1)
err := store.RemoveSerie(context.Background(), 1)
if err != nil {
t.Fatal(err)
}
}
func TestUpdateSeries(t *testing.T) {
err := store.UpdateSeries(context.Background(), 2, map[string]interface{}{
err := store.UpdateSerie(context.Background(), 2, map[string]interface{}{
"desc": "update desc",
})
if err != nil {
@@ -127,7 +125,7 @@ func TestUpdateSeries(t *testing.T) {
}
func TestLoadAllSeries(t *testing.T) {
series, err := store.LoadAllSeries(context.Background())
series, err := store.LoadAllSerie(context.Background())
if err != nil {
t.Fatal(err)
}
@@ -136,7 +134,7 @@ func TestLoadAllSeries(t *testing.T) {
func TestInsertArticle(t *testing.T) {
article.ID = 12
err := store.InsertArticle(context.Background(), article)
err := store.InsertArticle(context.Background(), article, 10)
if err != nil {
t.Fatal(err)
}
@@ -150,14 +148,14 @@ func TestRemoveArticle(t *testing.T) {
}
func TestDeleteArticle(t *testing.T) {
err := store.DeleteArticle(context.Background(), 12)
err := store.RemoveArticle(context.Background(), 12)
if err != nil {
t.Fatal(err)
}
}
func TestCleanArticles(t *testing.T) {
err := store.CleanArticles(context.Background())
err := store.CleanArticles(context.Background(), time.Now())
if err != nil {
t.Fatal(err)
}
@@ -173,33 +171,13 @@ func TestUpdateArticle(t *testing.T) {
}
}
func TestRecoverArticle(t *testing.T) {
err := store.RecoverArticle(context.Background(), 12)
if err != nil {
t.Fatal(err)
}
}
func TestLoadAllArticle(t *testing.T) {
articles, err := store.LoadAllArticle(context.Background())
_, total, err := store.LoadArticleList(context.Background(), SearchArticles{
Page: 1,
Limit: 1000,
})
if err != nil {
t.Fatal(err)
}
t.Logf("load all articles: %d", len(articles))
}
func TestLoadTrashArticles(t *testing.T) {
articles, err := store.LoadTrashArticles(context.Background())
if err != nil {
t.Fatal(err)
}
t.Logf("load trash articles: %d", len(articles))
}
func TestLoadDraftArticles(t *testing.T) {
articles, err := store.LoadDraftArticles(context.Background())
if err != nil {
t.Fatal(err)
}
t.Logf("load draft articles: %d", len(articles))
t.Logf("load all articles: %d", total)
}

View File

@@ -3,6 +3,7 @@ package store
import (
"context"
"errors"
"time"
"github.com/eiblog/eiblog/pkg/model"
@@ -129,7 +130,7 @@ func (db *rdbms) InsertArticle(ctx context.Context, article *model.Article, star
if id < startID {
id = startID
} else {
id += 1
id++
}
article.ID = id
}
@@ -190,6 +191,11 @@ func (db *rdbms) LoadArticleList(ctx context.Context, search SearchArticles) (mo
return articles, int(count), err
}
// DropDatabase drop eiblog database
func (db *rdbms) DropDatabase(ctx context.Context) error {
return errors.New("can not drop eiblog database in rdbms")
}
// register store
func init() {
Register("mysql", &rdbms{})

View File

@@ -64,6 +64,9 @@ type Store interface {
LoadArticle(ctx context.Context, id int) (*model.Article, error)
// LoadArticleList 查找文章列表
LoadArticleList(ctx context.Context, search SearchArticles) (model.SortedArticles, int, error)
// 危险操作
DropDatabase(ctx context.Context) error
}
// Driver 存储驱动

View File

@@ -69,7 +69,6 @@ type Google struct {
URL string `yaml:"url"`
Tid string `yaml:"tid"`
V string `yaml:"v"`
T string `yaml:"t"`
AdSense string `yaml:"adsense"`
}

View File

@@ -5,8 +5,8 @@ import (
_ "github.com/eiblog/eiblog/pkg/core/backup/docs" // docs
"github.com/gin-gonic/gin"
swaggerFiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
"github.com/swaggo/gin-swagger/swaggerFiles"
)
// RegisterRoutes register routes

View File

@@ -8,8 +8,10 @@ import (
"net/url"
"os"
"os/exec"
"path/filepath"
"time"
"github.com/eiblog/eiblog/pkg/cache/store"
"github.com/eiblog/eiblog/pkg/config"
"github.com/eiblog/eiblog/pkg/internal"
)
@@ -23,7 +25,19 @@ func (s Storage) BackupData(now time.Time) error {
case "mongodb":
return backupFromMongoDB(now)
default:
return errors.New("unsupported database source backup to qiniu")
return errors.New("unsupported source backup to qiniu: " +
config.Conf.Database.Driver)
}
}
// RestoreData implements timer.Storage
func (s Storage) RestoreData() error {
switch config.Conf.Database.Driver {
case "mongodb":
return restoreToMongoDB()
default:
return errors.New("unsupported source restore from qiniu: " +
config.Conf.Database.Driver)
}
}
@@ -61,9 +75,10 @@ func backupFromMongoDB(now time.Time) error {
return err
}
uploadParams := internal.UploadParams{
Name: name,
Size: s.Size(),
Data: f,
Name: filepath.Join("blog", name), // blog/eiblog-xx.tar.gz
Size: s.Size(),
Data: f,
NoCompletePath: true,
Conf: config.Conf.BackupApp.Qiniu,
}
@@ -73,10 +88,58 @@ func backupFromMongoDB(now time.Time) error {
}
// after days delete
deleteParams := internal.DeleteParams{
Name: name,
Days: config.Conf.BackupApp.Validity,
Name: name,
Days: config.Conf.BackupApp.Validity,
NoCompletePath: true,
Conf: config.Conf.BackupApp.Qiniu,
}
return internal.QiniuDelete(deleteParams)
}
func restoreToMongoDB() error {
// backup file
params := internal.ContentParams{
Prefix: "blog/",
Conf: config.Conf.BackupApp.Qiniu,
}
raw, err := internal.QiniuContent(params)
if err != nil {
return err
}
f, err := os.OpenFile("/tmp/eiblog.tar.gz", os.O_WRONLY|os.O_CREATE, 0644)
if err != nil {
return err
}
_, _ = f.Write(raw)
defer f.Close()
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*20)
defer cancel()
// drop database
store, err := store.NewStore(config.Conf.Database.Driver,
config.Conf.Database.Source)
if err != nil {
return err
}
err = store.DropDatabase(ctx)
if err != nil {
return err
}
// unarchive
arg := fmt.Sprintf("tar xzf /tmp/eiblog.tar.gz -C /tmp")
cmd := exec.CommandContext(ctx, "sh", "-c", arg)
err = cmd.Run()
if err != nil {
return err
}
// restore
u, err := url.Parse(config.Conf.Database.Source)
if err != nil {
return err
}
arg = fmt.Sprintf("mongorestore -h %s -d eiblog /tmp/eiblog", u.Host)
cmd = exec.CommandContext(ctx, "sh", "-c", arg)
return cmd.Run()
}

View File

@@ -13,7 +13,7 @@ import (
)
// Start to backup with ticker
func Start() error {
func Start(restore bool) (err error) {
var storage Storage
// backup instance
switch config.Conf.BackupApp.BackupTo {
@@ -24,13 +24,18 @@ func Start() error {
return errors.New("timer: unknown backup to driver: " +
config.Conf.BackupApp.BackupTo)
}
if restore {
err = storage.RestoreData()
if err != nil {
return err
}
logrus.Info("timer: RestoreData success")
}
// parse duration
interval, err := ParseDuration(config.Conf.BackupApp.Interval)
if err != nil {
return err
}
t := time.NewTicker(interval)
for now := range t.C {
err = storage.BackupData(now)
@@ -65,4 +70,5 @@ func ParseDuration(d string) (time.Duration, error) {
// Storage backup backend
type Storage interface {
BackupData(now time.Time) error
RestoreData() error
}

View File

@@ -301,7 +301,7 @@ func handleAPIPostCreate(c *gin.Context) {
}
// 旧文章
article.ID = cid
artc, _ := cache.Ei.FindArticleByID(article.ID)
artc, _ := cache.Ei.FindArticleByID(article.ID) // cache
if artc != nil {
article.IsDraft = false
article.Count = artc.Count

View File

@@ -50,6 +50,7 @@ func handleAdminProfile(c *gin.Context) {
renderHTMLAdminLayout(c, "admin-profile", params)
}
// T tag struct
type T struct {
ID string `json:"id"`
Tags string `json:"tags"`

View File

@@ -3,9 +3,11 @@ package page
import (
"bytes"
"context"
"fmt"
htemplate "html/template"
"io/ioutil"
"math/rand"
"net/http"
"strconv"
"strings"
@@ -198,7 +200,8 @@ func handleDisqusList(c *gin.Context) {
slug := c.Param("slug")
cursor := c.Query("cursor")
if artc := cache.Ei.ArticlesMap[slug]; artc != nil {
artc := cache.Ei.ArticlesMap[slug]
if artc != nil {
dcs.Data.Thread = artc.Thread
}
postsList, err := internal.PostsList(slug, cursor)
@@ -222,13 +225,25 @@ func handleDisqusList(c *gin.Context) {
ID: v.ID,
Name: v.Author.Name,
Parent: v.Parent,
Url: v.Author.ProfileUrl,
URL: v.Author.ProfileURL,
Avatar: v.Author.Avatar.Cache,
CreatedAtStr: tools.ConvertStr(v.CreatedAt),
Message: v.Message,
IsDeleted: v.IsDeleted,
}
}
// query thread & update
if artc != nil && artc.Thread == "" {
if dcs.Data.Thread != "" {
artc.Thread = dcs.Data.Thread
} else if internal.ThreadDetails(artc) == nil {
dcs.Data.Thread = artc.Thread
}
cache.Ei.UpdateArticle(context.Background(), artc.ID,
map[string]interface{}{
"thread": artc.Thread,
})
}
}
// handleDisqusPage 评论页
@@ -261,7 +276,7 @@ type commentsDetail struct {
ID string `json:"id"`
Parent int `json:"parent"`
Name string `json:"name"`
Url string `json:"url"`
URL string `json:"url"`
Avatar string `json:"avatar"`
CreatedAtStr string `json:"createdAtStr"`
Message string `json:"message"`
@@ -274,7 +289,7 @@ func handleDisqusCreate(c *gin.Context) {
defer c.JSON(http.StatusOK, resp)
msg := c.PostForm("message")
email := c.PostForm("author_name")
email := c.PostForm("author_email")
name := c.PostForm("author_name")
thread := c.PostForm("thread")
identifier := c.PostForm("identifier")
@@ -283,7 +298,7 @@ func handleDisqusCreate(c *gin.Context) {
resp.ErrMsg = "参数错误"
return
}
logrus.Info("email: %s comments: %s", email, thread)
logrus.Infof("email: %s comments: %s", email, thread)
comment := internal.PostComment{
Message: msg,
@@ -292,7 +307,7 @@ func handleDisqusCreate(c *gin.Context) {
AuthorEmail: email,
AuthorName: name,
Identifier: identifier,
IpAddress: c.ClientIP(),
IPAddress: c.ClientIP(),
}
postDetail, err := internal.PostCreate(&comment)
if err != nil {
@@ -312,7 +327,7 @@ func handleDisqusCreate(c *gin.Context) {
ID: postDetail.Response.ID,
Name: name,
Parent: postDetail.Response.Parent,
Url: postDetail.Response.Author.ProfileUrl,
URL: postDetail.Response.Author.ProfileURL,
Avatar: postDetail.Response.Author.Avatar.Cache,
CreatedAtStr: tools.ConvertStr(postDetail.Response.CreatedAt),
Message: postDetail.Response.Message,
@@ -321,27 +336,34 @@ func handleDisqusCreate(c *gin.Context) {
}
// handleBeaconPage 服务端推送谷歌统计
// https://www.thyngster.com/ga4-measurement-protocol-cheatsheet/
func handleBeaconPage(c *gin.Context) {
ua := c.Request.UserAgent()
vals := c.Request.URL.Query()
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())
vals.Set("dl", c.Request.Referer()) // document location
vals.Set("en", "page_view") // event name
vals.Set("sct", "1") // Session Count
vals.Set("seg", "1") // Session Engagment
vals.Set("_uip", c.ClientIP()) // user ip
vals.Set("_p", fmt.Sprint(201226219+rand.Intn(499999999))) // random page load hash
vals.Set("_ee", "1") // external event
go func() {
req, err := http.NewRequest("POST", config.Conf.EiBlogApp.Google.URL,
strings.NewReader(vals.Encode()))
url := config.Conf.EiBlogApp.Google.URL + "?" + vals.Encode()
req, err := http.NewRequest("POST", url, nil)
if err != nil {
logrus.Error("HandleBeaconPage.NewRequest: ", err)
return
}
req.Header.Set("User-Agent", ua)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("Sec-Ch-Ua", c.GetHeader("Sec-Ch-Ua"))
req.Header.Set("Sec-Ch-Ua-Platform", c.GetHeader("Sec-Ch-Ua-Platform"))
req.Header.Set("Sec-Ch-Ua-Mobile", c.GetHeader("Sec-Ch-Ua-Mobile"))
res, err := http.DefaultClient.Do(req)
if err != nil {
logrus.Error("HandleBeaconPage.Do: ", err)

View File

@@ -2,6 +2,7 @@
package page
import (
"io/fs"
"path/filepath"
"text/template"
@@ -17,10 +18,15 @@ var htmlTmpl *template.Template
func init() {
htmlTmpl = template.New("eiblog").Funcs(tools.TplFuncMap)
root := filepath.Join(config.WorkDir, "website")
files := tools.ReadDirFiles(root, func(name string) bool {
files := tools.ReadDirFiles(root, func(fi fs.FileInfo) bool {
name := fi.Name()
if name == ".DS_Store" {
return true
}
// should not read template dir
if fi.IsDir() && name == "template" {
return true
}
return false
})
_, err := htmlTmpl.ParseFiles(files...)

View File

@@ -5,8 +5,8 @@ import (
_ "github.com/eiblog/eiblog/pkg/core/eiblog/docs" // docs
"github.com/gin-gonic/gin"
swaggerFiles "github.com/swaggo/files"
ginSwagger "github.com/swaggo/gin-swagger"
"github.com/swaggo/gin-swagger/swaggerFiles"
)
// RegisterRoutes register routes

View File

@@ -16,11 +16,12 @@ import (
// disqus api
const (
apiPostsCount = "https://disqus.com/api/3.0/threads/set.json"
apiPostsList = "https://disqus.com/api/3.0/threads/listPosts.json"
apiPostCreate = "https://disqus.com/api/3.0/posts/create.json"
apiPostApprove = "https://disqus.com/api/3.0/posts/approve.json"
apiThreadCreate = "https://disqus.com/api/3.0/threads/create.json"
apiPostsCount = "https://disqus.com/api/3.0/threads/set.json"
apiPostsList = "https://disqus.com/api/3.0/threads/listPosts.json"
apiPostCreate = "https://disqus.com/api/3.0/posts/create.json"
apiPostApprove = "https://disqus.com/api/3.0/posts/approve.json"
apiThreadCreate = "https://disqus.com/api/3.0/threads/create.json"
apiThreadDetails = "https://disqus.com/api/3.0/threads/details.json"
)
func checkDisqusConfig() error {
@@ -95,8 +96,8 @@ func PostsCount(articles map[string]*model.Article) error {
return nil
}
// postsListResp 获取评论列表
type postsListResp struct {
// PostsListResp 获取评论列表
type PostsListResp struct {
Cursor struct {
HasNext bool
Next string
@@ -113,7 +114,7 @@ type postDetail struct {
IsDeleted bool
Author struct {
Name string
ProfileUrl string
ProfileURL string
Avatar struct {
Cache string
}
@@ -122,7 +123,7 @@ type postDetail struct {
}
// PostsList 评论列表
func PostsList(slug, cursor string) (*postsListResp, error) {
func PostsList(slug, cursor string) (*PostsListResp, error) {
if err := checkDisqusConfig(); err != nil {
return nil, err
}
@@ -148,7 +149,7 @@ func PostsList(slug, cursor string) (*postsListResp, error) {
return nil, errors.New(string(b))
}
result := &postsListResp{}
result := &PostsListResp{}
err = json.Unmarshal(b, result)
if err != nil {
return nil, err
@@ -163,18 +164,19 @@ type PostComment struct {
Thread string
AuthorEmail string
AuthorName string
IpAddress string
IPAddress string
Identifier string
UserAgent string
}
type postCreateResp struct {
// PostCreateResp create comments resp
type PostCreateResp struct {
Code int
Response postDetail
}
// PostCreate 评论文章
func PostCreate(pc *PostComment) (*postCreateResp, error) {
func PostCreate(pc *PostComment) (*PostCreateResp, error) {
if err := checkDisqusConfig(); err != nil {
return nil, err
}
@@ -201,7 +203,7 @@ func PostCreate(pc *PostComment) (*postCreateResp, error) {
if resp.StatusCode != http.StatusOK {
return nil, errors.New(string(b))
}
result := &postCreateResp{}
result := &PostCreateResp{}
err = json.Unmarshal(b, result)
if err != nil {
return nil, err
@@ -294,3 +296,46 @@ func ThreadCreate(article *model.Article, btitle string) error {
article.Thread = result.Response.ID
return nil
}
// threadDetailsResp thread info
type threadDetailsResp struct {
Code int
Response struct {
ID string
}
}
// ThreadDetails thread详细
func ThreadDetails(article *model.Article) error {
if err := checkDisqusConfig(); err != nil {
return err
}
vals := url.Values{}
vals.Set("api_key", config.Conf.EiBlogApp.Disqus.PublicKey)
vals.Set("access_token", config.Conf.EiBlogApp.Disqus.AccessToken)
vals.Set("forum", config.Conf.EiBlogApp.Disqus.ShortName)
vals.Set("thread:ident", "post-"+article.Slug)
resp, err := httpGet(apiThreadDetails + "?" + vals.Encode())
if err != nil {
return err
}
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
if resp.StatusCode != http.StatusOK {
return errors.New(string(b))
}
result := &threadDetailsResp{}
err = json.Unmarshal(b, result)
if err != nil {
return err
}
article.Thread = result.Response.ID
return nil
}

View File

@@ -49,7 +49,7 @@ func checkESConfig() error {
}
// ElasticSearch 搜索文章
func ElasticSearch(query string, size, from int) (*searchIndexResult, error) {
func ElasticSearch(query string, size, from int) (*SearchIndexResult, error) {
if err := checkESConfig(); err != nil {
return nil, err
}
@@ -114,7 +114,7 @@ func ElasticAddIndex(article *model.Article) error {
img := tools.PickFirstImage(article.Content)
mapping := map[string]interface{}{
"title": article.Title,
"content": tools.IgnoreHtmlTag(article.Content),
"content": tools.IgnoreHTMLTag(article.Content),
"slug": article.Slug,
"tag": article.Tags,
"img": img,
@@ -241,8 +241,8 @@ func deleteIndexDocument(index, typ string, ids []string) error {
return nil
}
// searchIndexResult 查询结果
type searchIndexResult struct {
// SearchIndexResult 查询结果
type SearchIndexResult struct {
Took float32 `json:"took"`
Hits struct {
Total int `json:"total"`
@@ -264,7 +264,7 @@ type searchIndexResult struct {
}
// indexQueryDSL 语句查询文档
func indexQueryDSL(index, typ string, size, from int, dsl []byte) (*searchIndexResult, error) {
func indexQueryDSL(index, typ string, size, from int, dsl []byte) (*SearchIndexResult, error) {
rawurl := fmt.Sprintf("%s/%s/%s/_search?size=%d&from=%d", config.Conf.ESHost,
index, typ, size, from)
resp, err := httpPost(rawurl, dsl)
@@ -276,7 +276,7 @@ func indexQueryDSL(index, typ string, size, from int, dsl []byte) (*searchIndexR
if err != nil {
return nil, err
}
result := &searchIndexResult{}
result := &SearchIndexResult{}
err = json.Unmarshal(data, result)
if err != nil {
return nil, err

View File

@@ -5,7 +5,9 @@ import (
"context"
"errors"
"io"
"net/http"
"path/filepath"
"time"
"github.com/eiblog/eiblog/pkg/config"
@@ -15,9 +17,10 @@ import (
// UploadParams upload params
type UploadParams struct {
Name string
Size int64
Data io.Reader
Name string
Size int64
Data io.Reader
NoCompletePath bool
Conf config.Qiniu
}
@@ -28,7 +31,10 @@ func QiniuUpload(params UploadParams) (string, error) {
params.Conf.SecretKey == "" {
return "", errors.New("qiniu config error")
}
key := completeQiniuKey(params.Name)
key := params.Name
if !params.NoCompletePath {
key = filepath.Base(params.Name)
}
mac := qbox.NewMac(params.Conf.AccessKey,
params.Conf.SecretKey)
@@ -65,15 +71,19 @@ func QiniuUpload(params UploadParams) (string, error) {
// DeleteParams delete params
type DeleteParams struct {
Name string
Days int
Name string
Days int
NoCompletePath bool
Conf config.Qiniu
}
// QiniuDelete 删除文件
func QiniuDelete(params DeleteParams) error {
key := completeQiniuKey(params.Name)
key := params.Name
if !params.NoCompletePath {
key = completeQiniuKey(params.Name)
}
mac := qbox.NewMac(params.Conf.AccessKey,
params.Conf.SecretKey)
@@ -95,6 +105,47 @@ func QiniuDelete(params DeleteParams) error {
return bucketManager.Delete(params.Conf.Bucket, key)
}
// ContentParams list params
type ContentParams struct {
Prefix string
Conf config.Qiniu
}
// QiniuContent 获取文件列表
func QiniuContent(params ContentParams) ([]byte, error) {
mac := qbox.NewMac(params.Conf.AccessKey,
params.Conf.SecretKey)
// region
region, err := storage.GetRegion(params.Conf.AccessKey, params.Conf.Bucket)
if err != nil {
return nil, err
}
cfg := &storage.Config{
UseHTTPS: true,
Region: region,
}
// manager
bucketManager := storage.NewBucketManager(mac, cfg)
// list file
files, _, _, _, err := bucketManager.ListFiles(params.Conf.Bucket, params.Prefix, "", "", 1)
if err != nil {
return nil, err
}
if len(files) == 0 {
return nil, errors.New("no file")
}
deadline := time.Now().Add(time.Second * 60).Unix()
url := storage.MakePrivateURLv2(mac, "https://"+params.Conf.Domain, files[0].Key, deadline)
resp, err := http.Get(url)
if err != nil {
return nil, err
}
defer resp.Body.Close()
return io.ReadAll(resp.Body)
}
// completeQiniuKey 修复路径
func completeQiniuKey(name string) string {
ext := filepath.Ext(name)

View File

@@ -46,3 +46,18 @@ func TestQiniuUpload(t *testing.T) {
})
}
}
func TestQiniuContent(t *testing.T) {
params := ContentParams{
Conf: config.Qiniu{
AccessKey: os.Getenv("QINIU_ACCESSKEY"),
SecretKey: os.Getenv("QINIU_SECRETKEY"),
Bucket: os.Getenv("QINIU_BUCKET"),
Domain: "bu.st.deepzz.com",
},
}
_, err := QiniuContent(params)
if err != nil {
t.Errorf("QiniuList error = %v", err)
}
}

View File

@@ -20,6 +20,7 @@ type Article struct {
SerieID int `gorm:"column:serie_id;not null" bson:"serie_id"` // 专题ID
Tags pq.StringArray `gorm:"column:tags;type:text[]" bson:"tags"` // tags
IsDraft bool `gorm:"column:is_draft;not null" bson:"is_draft"` // 是否是草稿
Thread string `gorm:"column:thread" bson:"thread"` // disqus thread
DeletedAt time.Time `gorm:"column:deleted_at;not null" bson:"deleted_at"` // 删除时间
UpdatedAt time.Time `gorm:"column:updated_at;default:current_timestamp" bson:"updated_at"` // 更新时间
@@ -28,7 +29,6 @@ type Article struct {
Header string `gorm:"-" bson:"-"` // header
Excerpt string `gorm:"-" bson:"-"` // 预览信息
Desc string `gorm:"-" bson:"-"` // 描述
Thread string `gorm:"-" bson:"-"` // disqus thread
Prev *Article `gorm:"-" bson:"-"` // 上篇文章
Next *Article `gorm:"-" bson:"-"` // 下篇文章
}

View File

@@ -1,4 +0,0 @@
.PHONY: protoc
protoc:
@${PWD}/protoc.sh

View File

@@ -1,226 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.13.0
// source: cmd-demo/demo.proto
package cmd_demo
import (
proto "github.com/golang/protobuf/proto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type UserInfoReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
}
func (x *UserInfoReq) Reset() {
*x = UserInfoReq{}
if protoimpl.UnsafeEnabled {
mi := &file_cmd_demo_demo_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UserInfoReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UserInfoReq) ProtoMessage() {}
func (x *UserInfoReq) ProtoReflect() protoreflect.Message {
mi := &file_cmd_demo_demo_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use UserInfoReq.ProtoReflect.Descriptor instead.
func (*UserInfoReq) Descriptor() ([]byte, []int) {
return file_cmd_demo_demo_proto_rawDescGZIP(), []int{0}
}
func (x *UserInfoReq) GetUserId() int64 {
if x != nil {
return x.UserId
}
return 0
}
type UserInfoResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
}
func (x *UserInfoResp) Reset() {
*x = UserInfoResp{}
if protoimpl.UnsafeEnabled {
mi := &file_cmd_demo_demo_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UserInfoResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UserInfoResp) ProtoMessage() {}
func (x *UserInfoResp) ProtoReflect() protoreflect.Message {
mi := &file_cmd_demo_demo_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use UserInfoResp.ProtoReflect.Descriptor instead.
func (*UserInfoResp) Descriptor() ([]byte, []int) {
return file_cmd_demo_demo_proto_rawDescGZIP(), []int{1}
}
func (x *UserInfoResp) GetUserId() int64 {
if x != nil {
return x.UserId
}
return 0
}
func (x *UserInfoResp) GetUsername() string {
if x != nil {
return x.Username
}
return ""
}
var File_cmd_demo_demo_proto protoreflect.FileDescriptor
var file_cmd_demo_demo_proto_rawDesc = []byte{
0x0a, 0x13, 0x63, 0x6d, 0x64, 0x2d, 0x64, 0x65, 0x6d, 0x6f, 0x2f, 0x64, 0x65, 0x6d, 0x6f, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x64, 0x65, 0x6d, 0x6f, 0x22, 0x26, 0x0a, 0x0b, 0x55,
0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73,
0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65,
0x72, 0x49, 0x64, 0x22, 0x43, 0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52,
0x65, 0x73, 0x70, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01,
0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08,
0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x32, 0x3b, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72,
0x12, 0x33, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x11, 0x2e, 0x64,
0x65, 0x6d, 0x6f, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x1a,
0x12, 0x2e, 0x64, 0x65, 0x6d, 0x6f, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52,
0x65, 0x73, 0x70, 0x22, 0x00, 0x42, 0x19, 0x5a, 0x17, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63,
0x6d, 0x64, 0x2d, 0x64, 0x65, 0x6d, 0x6f, 0x3b, 0x63, 0x6d, 0x64, 0x5f, 0x64, 0x65, 0x6d, 0x6f,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_cmd_demo_demo_proto_rawDescOnce sync.Once
file_cmd_demo_demo_proto_rawDescData = file_cmd_demo_demo_proto_rawDesc
)
func file_cmd_demo_demo_proto_rawDescGZIP() []byte {
file_cmd_demo_demo_proto_rawDescOnce.Do(func() {
file_cmd_demo_demo_proto_rawDescData = protoimpl.X.CompressGZIP(file_cmd_demo_demo_proto_rawDescData)
})
return file_cmd_demo_demo_proto_rawDescData
}
var file_cmd_demo_demo_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_cmd_demo_demo_proto_goTypes = []interface{}{
(*UserInfoReq)(nil), // 0: demo.UserInfoReq
(*UserInfoResp)(nil), // 1: demo.UserInfoResp
}
var file_cmd_demo_demo_proto_depIdxs = []int32{
0, // 0: demo.User.UserInfo:input_type -> demo.UserInfoReq
1, // 1: demo.User.UserInfo:output_type -> demo.UserInfoResp
1, // [1:2] is the sub-list for method output_type
0, // [0:1] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_cmd_demo_demo_proto_init() }
func file_cmd_demo_demo_proto_init() {
if File_cmd_demo_demo_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_cmd_demo_demo_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UserInfoReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_cmd_demo_demo_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UserInfoResp); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_cmd_demo_demo_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_cmd_demo_demo_proto_goTypes,
DependencyIndexes: file_cmd_demo_demo_proto_depIdxs,
MessageInfos: file_cmd_demo_demo_proto_msgTypes,
}.Build()
File_cmd_demo_demo_proto = out.File
file_cmd_demo_demo_proto_rawDesc = nil
file_cmd_demo_demo_proto_goTypes = nil
file_cmd_demo_demo_proto_depIdxs = nil
}

View File

@@ -1,19 +0,0 @@
syntax = "proto3";
option go_package = "proto/cmd-demo;cmd_demo";
package demo;
message UserInfoReq {
int64 user_id = 1;
}
message UserInfoResp {
int64 user_id = 1;
string username = 2;
}
// User service
service User {
rpc UserInfo(UserInfoReq) returns (UserInfoResp) {}
}

View File

@@ -1,97 +0,0 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
package cmd_demo
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion7
// UserClient is the client API for User service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type UserClient interface {
UserInfo(ctx context.Context, in *UserInfoReq, opts ...grpc.CallOption) (*UserInfoResp, error)
}
type userClient struct {
cc grpc.ClientConnInterface
}
func NewUserClient(cc grpc.ClientConnInterface) UserClient {
return &userClient{cc}
}
func (c *userClient) UserInfo(ctx context.Context, in *UserInfoReq, opts ...grpc.CallOption) (*UserInfoResp, error) {
out := new(UserInfoResp)
err := c.cc.Invoke(ctx, "/demo.User/UserInfo", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// UserServer is the server API for User service.
// All implementations must embed UnimplementedUserServer
// for forward compatibility
type UserServer interface {
UserInfo(context.Context, *UserInfoReq) (*UserInfoResp, error)
mustEmbedUnimplementedUserServer()
}
// UnimplementedUserServer must be embedded to have forward compatible implementations.
type UnimplementedUserServer struct {
}
func (UnimplementedUserServer) UserInfo(context.Context, *UserInfoReq) (*UserInfoResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method UserInfo not implemented")
}
func (UnimplementedUserServer) mustEmbedUnimplementedUserServer() {}
// UnsafeUserServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to UserServer will
// result in compilation errors.
type UnsafeUserServer interface {
mustEmbedUnimplementedUserServer()
}
func RegisterUserServer(s grpc.ServiceRegistrar, srv UserServer) {
s.RegisterService(&_User_serviceDesc, srv)
}
func _User_UserInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UserInfoReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServer).UserInfo(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/demo.User/UserInfo",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServer).UserInfo(ctx, req.(*UserInfoReq))
}
return interceptor(ctx, in, info, handler)
}
var _User_serviceDesc = grpc.ServiceDesc{
ServiceName: "demo.User",
HandlerType: (*UserServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "UserInfo",
Handler: _User_UserInfo_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "cmd-demo/demo.proto",
}

View File

@@ -1,11 +0,0 @@
#!/usr/bin/env sh
set -e
for file in */*.proto; do
if test -f $file; then
protoc --go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
$file;
fi
done

View File

@@ -1,33 +1,3 @@
#!/usr/bin/env sh
_registry="$1"
_tag="$2"
_platform="linux/amd64,linux/arm64,linux/386"
if [ -z "$_registry" ] || [ -z "$_tag" ]; then
echo "Please specify image repository and tag."
exit 0;
fi
# create and use builder
docker buildx inspect builder >/dev/null 2>&1
if [ "$?" != "0" ]; then
docker buildx create --use --name builder
fi
# prepare dir ./bin
mkdir -p ./bin
# build demo app
for file in pkg/core/*; do
app="$(basename $file)";
go build -tags prod -ldflags '-extldflags "-static"' -o bin/backend "./cmd/$app"
# docker image
docker buildx build --platform "$_platform" \
-f "build/package/$app.Dockerfile" \
-t "$_registry/$app:latest" \
-t "$_registry/$app:$_tag" \
--push .
done
# clean dir ./bin
rm -rf ./bin
go build -tags prod -ldflags '-extldflags "-static"' -o bin/backend "./cmd/$1"

View File

@@ -5,6 +5,7 @@ import (
"crypto/sha256"
"fmt"
"io"
"io/fs"
"io/ioutil"
"path"
"regexp"
@@ -22,13 +23,13 @@ func EncryptPasswd(name, pass string) string {
}
// ReadDirFiles 读取目录
func ReadDirFiles(dir string, filter func(name string) bool) (files []string) {
func ReadDirFiles(dir string, filter func(fi fs.FileInfo) bool) (files []string) {
fileInfos, err := ioutil.ReadDir(dir)
if err != nil {
return
}
for _, fi := range fileInfos {
if filter(fi.Name()) {
if filter(fi) {
continue
}
if fi.IsDir() {
@@ -42,19 +43,19 @@ func ReadDirFiles(dir string, filter func(name string) bool) (files []string) {
// 2016-10-22T07:03:01
const (
JUST_NOW = "几秒前"
MINUTES_AGO = "%d分钟前"
HOURS_AGO = "%d小时前"
DAYS_AGO = "%d天前"
MONTH_AGO = "%d月前"
YEARS_AGO = "%d年前"
JustNow = "几秒前"
MinutesAgo = "%d分钟前"
HoursAgo = "%d小时前"
DaysAgo = "%d天前"
MonthAgo = "%d月前"
YearsAgo = "%d年前"
)
// ConvertStr 时间转换为间隔
func ConvertStr(str string) string {
t, err := time.ParseInLocation("2006-01-02T15:04:05", str, time.UTC)
if err != nil {
return JUST_NOW
return JustNow
}
now := time.Now().UTC()
y1, m1, d1 := t.Date()
@@ -62,17 +63,17 @@ func ConvertStr(str string) string {
h1, mi1, s1 := t.Clock()
h2, mi2, s2 := now.Clock()
if y := y2 - y1; y > 1 || (y == 1 && m2-m1 >= 0) {
return fmt.Sprintf(YEARS_AGO, y)
return fmt.Sprintf(YearsAgo, y)
} else if m := y*12 + int(m2-m1); m > 1 || (m == 1 && d2-d1 >= 0) {
return fmt.Sprintf(MONTH_AGO, m)
return fmt.Sprintf(MonthAgo, m)
} else if d := m*dayIn(y1, m1) + d2 - d1; d > 1 || (d == 1 && h2-h1 >= 0) {
return fmt.Sprintf(DAYS_AGO, d)
return fmt.Sprintf(DaysAgo, d)
} else if h := d*24 + h2 - h1; h > 1 || (h == 1 && mi2-mi1 >= 0) {
return fmt.Sprintf(HOURS_AGO, h)
return fmt.Sprintf(HoursAgo, h)
} else if mi := h*60 + mi2 - mi1; mi > 1 || (mi == 1 && s2-s1 >= 0) {
return fmt.Sprintf(MINUTES_AGO, mi)
return fmt.Sprintf(MinutesAgo, mi)
}
return JUST_NOW
return JustNow
}
// dayIn 获取天数
@@ -120,8 +121,8 @@ var (
regexpEnter = regexp.MustCompile(`\s+`)
)
// IgnoreHtmlTag 去掉 html tag
func IgnoreHtmlTag(src string) string {
// IgnoreHTMLTag 去掉 html tag
func IgnoreHTMLTag(src string) string {
// 去除所有尖括号内的HTML代码
src = regexpBrackets.ReplaceAllString(src, "")
// 去除换行符

View File

@@ -1,3 +1,3 @@
{{define "ana_js"}}
!function(e,n,o){var t=e.screen,a=encodeURIComponent,r=["dt="+a(n.title),"dr="+a(n.referrer),"ul="+(o.language||o.browserLanguage),"sd="+t.colorDepth+"-bit","sr="+t.width+"x"+t.height,"_="+ +new Date],i="?"+r.join("&");e.__beacon_img=new Image,e.__beacon_img.src="/beacon.html"+i}(window,document,navigator,location);
{{end}}
!function(e,n,o){var t=e.screen,a=encodeURIComponent,r=["dt="+a(n.title),"dr="+a(n.referrer),"ul="+(o.language||o.browserLanguage).toLowerCase(),"sd="+t.colorDepth+"-bit","sr="+t.width+"x"+t.height,"_="+ +new Date],i="?"+r.join("&");e.__beacon_img=new Image,e.__beacon_img.src="/beacon.html"+i}(window,document,navigator,location);
{{end}}

View File

@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>{{.BTitle}}</ShortName>
<Description>{{.SubTitle}}</Description>
<Url type="text/html" template="https://{{.Host}}/search.html?q={searchTerms}" />
<InputEncoding>UTF-8</InputEncoding>
<Url type="text/html" method="get" template="https://{{.Host}}/search.html?q={searchTerms}" />
<moz:SearchForm>https://{{.Host}}/search.html</moz:SearchForm>
</OpenSearchDescription>