├── .github
└── workflows
│ └── main.yaml
├── .gitignore
├── CHANGELOG.md
├── CLA.md
├── LICENSE
├── Logger.go
├── README.md
├── README.zh-CN.md
├── const.go
├── eth_test.go
├── funcMap.go
├── funcmap_test.go
├── go.mod
├── go.sum
├── goldmark_test.go
├── gpressEntity.go
├── gpressdatadir
├── dict.zip
├── fts5
│ ├── libsimple.dll
│ ├── libsimple.dylib
│ ├── libsimple.so
│ └── libsimple.so-aarch64
├── gpress.sql
├── install_config.json
├── libgcc_s_seh-1.dll
├── locales
│ ├── en-US.json
│ └── zh-CN.json
├── post
│ └── 01-nginx-config.md
├── public
│ ├── doc
│ │ ├── image
│ │ │ ├── 000.png
│ │ │ ├── 001.png
│ │ │ ├── 002.png
│ │ │ ├── 003.png
│ │ │ ├── 004.png
│ │ │ ├── 005.png
│ │ │ ├── 006.png
│ │ │ ├── 007.png
│ │ │ ├── 008.png
│ │ │ ├── 009.png
│ │ │ ├── 010.png
│ │ │ ├── 011.png
│ │ │ ├── 012.png
│ │ │ ├── 013.png
│ │ │ ├── 014.png
│ │ │ ├── 015.png
│ │ │ ├── 016.png
│ │ │ ├── 017.png
│ │ │ ├── 018.png
│ │ │ ├── 019.png
│ │ │ └── 020.png
│ │ └── index.md
│ ├── favicon.png
│ ├── gongan.png
│ ├── gpress-logo.png
│ ├── gpress-logo1.png
│ ├── index.png
│ ├── logo.png
│ ├── mqtt3.1.1.html
│ ├── search-config.json
│ ├── upload
│ │ └── upload.txt
│ └── wallet
│ │ ├── TrustWallet.png
│ │ ├── bitkeep.png
│ │ ├── metamask.png
│ │ ├── okx.png
│ │ ├── tokenproket.png
│ │ └── x-pocket.png
├── statichtml
│ └── readme.html
├── template
│ ├── admin
│ │ ├── bodyend.html
│ │ ├── bodystart.html
│ │ ├── category
│ │ │ ├── save.html
│ │ │ └── update.html
│ │ ├── chainlogin.html
│ │ ├── config
│ │ │ └── update.html
│ │ ├── content
│ │ │ ├── list.html
│ │ │ ├── save.html
│ │ │ └── update.html
│ │ ├── css
│ │ │ └── tree.css
│ │ ├── error.html
│ │ ├── header.html
│ │ ├── index.html
│ │ ├── install.html
│ │ ├── js
│ │ │ ├── cherry-markdown
│ │ │ │ ├── cherry-markdown.min.css
│ │ │ │ ├── cherry-markdown.min.js
│ │ │ │ └── fonts
│ │ │ │ │ ├── ch-icon.eot
│ │ │ │ │ ├── ch-icon.svg
│ │ │ │ │ ├── ch-icon.ttf
│ │ │ │ │ ├── ch-icon.woff
│ │ │ │ │ └── ch-icon.woff2
│ │ │ ├── layui
│ │ │ │ ├── css
│ │ │ │ │ ├── layui.css
│ │ │ │ │ └── layui.css.map
│ │ │ │ ├── font
│ │ │ │ │ ├── iconfont.eot
│ │ │ │ │ ├── iconfont.svg
│ │ │ │ │ ├── iconfont.ttf
│ │ │ │ │ ├── iconfont.woff
│ │ │ │ │ └── iconfont.woff2
│ │ │ │ ├── layui.js
│ │ │ │ ├── layui.js.map
│ │ │ │ ├── test.html
│ │ │ │ ├── 免责声明.html
│ │ │ │ └── 官方文档.html
│ │ │ ├── pinyin
│ │ │ │ ├── pinyin-pro.js
│ │ │ │ └── 说明.txt
│ │ │ ├── sha3.min.js
│ │ │ └── wangeditor
│ │ │ │ ├── wangeditor5.min.css
│ │ │ │ └── wangeditor5.min.js
│ │ ├── login.html
│ │ ├── site
│ │ │ └── update.html
│ │ ├── themeTemplate
│ │ │ └── list.html
│ │ └── user
│ │ │ └── update.html
│ └── theme
│ │ └── default
│ │ ├── bodyend.html
│ │ ├── bodystart.html
│ │ ├── category-single.html
│ │ ├── category.html
│ │ ├── content.html
│ │ ├── css
│ │ ├── even.css
│ │ └── fonts
│ │ │ ├── chancery
│ │ │ ├── apple-chancery-webfont.eot
│ │ │ ├── apple-chancery-webfont.svg
│ │ │ ├── apple-chancery-webfont.ttf
│ │ │ ├── apple-chancery-webfont.woff
│ │ │ └── apple-chancery-webfont.woff2
│ │ │ └── iconfont
│ │ │ ├── iconfont.eot
│ │ │ ├── iconfont.svg
│ │ │ ├── iconfont.ttf
│ │ │ └── iconfont.woff
│ │ ├── error.html
│ │ ├── index.html
│ │ ├── js
│ │ ├── classList.min.js
│ │ ├── even.js
│ │ ├── html5shiv.min.js
│ │ ├── jquery.fancybox.min.css
│ │ ├── jquery.fancybox.min.js
│ │ ├── jquery.min.js
│ │ ├── manifest.json
│ │ ├── mermaid.min.js
│ │ ├── respond.min.js
│ │ └── slideout.min.js
│ │ └── tag.html
└── wasm
│ ├── add.go
│ ├── add.wasm
│ └── readme.md
├── hugo_test.go
├── main.go
├── routeAdmin.go
├── routeWeb.go
├── serviceCategory.go
├── serviceConfig.go
├── serviceUser.go
├── utilBase58.go
├── utilCaptcha.go
├── utilGenStaticFile.go
├── utilGoldmark.go
├── utilHertz.go
├── utilJWT.go
├── utilLocale.go
├── utilSQLite.go
├── utilSignature.go
├── utilSignature_test.go
├── utilZIP.go
├── utilzip_test.go
└── wasm_test.go
/.github/workflows/main.yaml:
--------------------------------------------------------------------------------
1 | name: gpress-darwin
2 | ### 手动触发,目前Linux glibc版本不兼容,需要手动编译.两层压缩包
3 | on:
4 | workflow_dispatch:
5 |
6 | jobs:
7 | build:
8 | runs-on: ubuntu-latest
9 | strategy:
10 | matrix:
11 | #goos: [windows, linux, darwin]
12 | goos: [windows, darwin]
13 | goarch: [amd64, arm64]
14 | exclude:
15 | - goarch: arm64
16 | goos: windows
17 | fail-fast: false
18 | env:
19 | GOOS: ${{ matrix.goos }}
20 | GOARCH: ${{ matrix.goarch }}
21 |
22 | steps:
23 | - name: Checkout
24 | uses: actions/checkout@v4
25 | with:
26 | submodules: recursive
27 |
28 | - name: Build
29 | uses: crazy-max/ghaction-xgo@v3
30 | with:
31 | xgo_version: latest
32 | go_version: 1.21
33 | v: true
34 | x: false
35 | race: false
36 | prefix: gpress
37 | dest: build
38 | ldflags: -w -s
39 | tags: fts5
40 | targets: ${{matrix.goos}}/${{matrix.goarch}}
41 | buildmode: default
42 | trimpath: true
43 |
44 | - name: Package
45 | run: |
46 | mkdir -p ./build/temp/gpress/
47 | cd ./gpressdatadir && unzip dict.zip && rm -rf ./dict.zip && cd ..
48 |
49 | if [ "${{ matrix.goos }}" == "darwin" ]; then
50 | if [ "${{ matrix.arch }}" == "arm64" ]; then
51 | mv ./gpressdatadir/fts5/libsimple.dylib ./gpressdatadir/fts5/temp.dylib
52 | else
53 | mv ./gpressdatadir/fts5/libsimple.dylib-amd64 ./gpressdatadir/fts5/temp.dylib
54 | fi
55 | rm -rf ./gpressdatadir/fts5/libsimple*
56 | mv ./gpressdatadir/fts5/temp.dylib ./gpressdatadir/fts5/libsimple.dylib
57 | mv ./build/gpress-${{matrix.goos}}-${{matrix.goarch}} ./build/temp/gpress/gpress
58 | fi
59 |
60 | if [ "${{ matrix.goos }}" == "linux" ]; then
61 | if [ "${{ matrix.arch }}" == "arm64" ]; then
62 | mv ./gpressdatadir/fts5/libsimple.so-aarch64 ./gpressdatadir/fts5/temp.so
63 | else
64 | mv ./gpressdatadir/fts5/libsimple.so ./gpressdatadir/fts5/temp.so
65 | fi
66 | rm -rf ./gpressdatadir/fts5/libsimple*
67 | mv ./gpressdatadir/fts5/temp.so ./gpressdatadir/fts5/libsimple.so
68 | mv ./build/gpress-${{matrix.goos}}-${{matrix.goarch}} ./build/temp/gpress/gpress
69 | fi
70 |
71 | if [ "${{ matrix.goos }}" == "windows" ]; then
72 | mv ./gpressdatadir/fts5/libsimple.dll ./gpressdatadir/fts5/temp.dll
73 | rm -rf ./gpressdatadir/fts5/libsimple*
74 | mv ./gpressdatadir/fts5/temp.dll ./gpressdatadir/fts5/libsimple.dll
75 | mv ./build/gpress-${{matrix.goos}}-${{matrix.goarch}}.exe ./build/temp/gpress/gpress.exe
76 | fi
77 |
78 | mv ./gpressdatadir ./build/temp/gpress/
79 | cd ./build/temp && zip -r gpress.zip ./gpress
80 |
81 | - name: Upload
82 | uses: actions/upload-artifact@v4
83 | with:
84 | name: gpress-${{matrix.goos}}-${{matrix.goarch}}
85 | path: ${{ github.workspace }}/build/temp/gpress.zip
86 | env:
87 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # idea ignore
2 | .idea/
3 | *.ipr
4 | *.iml
5 | *.iws
6 | upload/
7 | install_config.json
8 | search-data.json
9 | install.html
10 | install.html.bak
11 | statichtml
12 | testTable/
13 | dict/
14 | natsdata/
15 | *.db
16 | *.db.fail
17 | .vscode/
18 |
19 | *.swp
20 |
21 | # temp ignore
22 | *.hertz.gz
23 | *.gz
24 | *.log
25 | *.cache
26 | *.diff
27 | *.exe
28 | *.exe~
29 | *.patch
30 | *.tmp
31 | *debug.test
32 | debug.test
33 | __debug_bin
34 |
35 | # system ignore
36 | .DS_Store
37 | Thumbs.db
38 |
39 | # project
40 | *.cert
41 | *.key
42 | .test
43 | iprepo.txt
44 |
45 |
46 | _output
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | v1.1.2
2 | - 完善文档,注释
3 |
4 | v1.1.1
5 | - 感谢@soldier_of_love,拼音生成内容的路径标识
6 | - 去掉路径里的空格
7 | - 完善文档,注释
8 |
9 | v1.1.0
10 | - 增加自定义标签,支持解析视频/音频标签: !video[描述](视频地址) , !audio[描述](音频地址)
11 | - 完善文档,注释
12 |
13 | v1.0.9
14 | - 升级FTS5分词组件
15 | - 依赖Go 1.24
16 | - 增强windows系统的兼容性
17 | - 优化上传文件名
18 | - 优化加载fts5分词扩展
19 | - 完善文档,注释
20 |
21 | v1.0.8
22 | - 后台管理支持多语言
23 | - 上传文件单独目录隔离,避免互相影响
24 | - 后台管理页面增加 更新SQL 功能
25 | - 内容表增加 txID 字段,记录上链交易的Hash;配置表增加 locale 字段,设置语言
26 | - 修改错误的categorys拼写
27 | - 主题管理过滤掉.gz压缩文件
28 | - 动态增加路由映射,去掉routeCategoryMap的处理逻辑
29 | - 完善文档,注释
30 |
31 | v1.0.7
32 | - URI作为导航和内容的ID,例如:/web/是导航ID,/web/nginx-use-hsts是内容ID
33 | - 去掉comCode,moduleID字段,增加signature,signAddress和signChain字段
34 | - 统一映射静态文件,兼容项目前缀路径
35 | - 完善文档,注释
36 |
37 | v1.0.6
38 | - 使用本地的js资源文件
39 | - Nginx 1.26+ 不需要再进行302重定向到目录下的index.html,gzip_static也会生效
40 | - 根据Cookie和User-Agent请求头,为pc,wap,weixin配置不同的主题,并支持HarmonyOS
41 | - site表中siteThemeWEIXIN字段名修改为themeWX
42 | - 修复上传文件路径异常的问题
43 | - 调整后台管理功能实现
44 | - 完善文档,注释
45 |
46 | v1.0.5
47 | - 修复修改项目前缀造成访问异常的bug
48 | - 感谢 @soldier_of_love 的[pr](https://gitee.com/gpress/gpress/pulls/8),eth验签从go-ethereum库切换到dcrd库
49 | - 感谢 @soldier_of_love 的[pr](https://gitee.com/gpress/gpress/pulls/7),优化静态路由配置,不用动态在更新路由
50 | - 感谢 @soldier_of_love 的[pr](https://gitee.com/gpress/gpress/pulls/6),解压失败的情况 合理删除目录
51 | - 感谢 @soldier_of_love 的[pr](https://gitee.com/gpress/gpress/pulls/5),解决sliceCategory2Tree三层及以上层数异常问题
52 | - 感谢 @soldier_of_love 的[pr](https://gitee.com/gpress/gpress/pulls/4),解决AES-CBC模式加解密 部分文本异常
53 | - 感谢 @soldier_of_love 的[pr](https://gitee.com/gpress/gpress/pulls/3),解决非法压缩包上传未删除问题
54 | - 感谢 @soldier_of_love 的[pr](https://gitee.com/gpress/gpress/pulls/2),解决初始化DB副作用
55 | - 完善文档,注释
56 |
57 | v1.0.4
58 | - 统一类型转换方法 convertType, 方便扩展
59 | - 感谢 @lifj22 的[issue](https://gitee.com/gpress/gpress/issues/I9J1RH),导航模板category开头,内容模板content开头
60 | - status字段增加置顶(2),原私密(2)修改为私密(3)
61 | - 完善文档,注释
62 |
63 | v1.0.3
64 | - 栏目页自定义keyword,description,静态化生成sitemap.xml
65 | - 增加seq标签,用于循环数字
66 | - 迁移WordPress主题:[generatepress](https://gitee.com/gpress/wp-generatepress)、[astra](https://wpastra.com)
67 | - 完善文档,注释
68 |
69 | v1.0.2
70 | - templateID 更名为 templateFile
71 | - 修改示例数据
72 | - 优化后台管理页面
73 | - 完善文档,注释
74 |
75 | v1.0.1
76 | - 主题模板支持上传和文件修改
77 | - 增加GitHub Actions文件,用于编译MacOS版本,感谢 @CDCDDCDC 编译libsimple.dylib
78 | - 部署阿里云计算巢服务,方便云平台使用
79 | - 完善文档,注释
80 |
81 | v1.0.0
82 | - 初始化版本
--------------------------------------------------------------------------------
/CLA.md:
--------------------------------------------------------------------------------
1 |
2 | **gpress贡献者许可协议**
3 |
4 | 感谢您对gpress社区(“社区”或者“我们”)拥有及/或管理的开源项目(“项目”)的关注,请完整、仔细、充分阅读本《贡献者许可协议》(“协议”)后,在对协议项下条款均无异议的前提下,签署本协议。
5 |
6 | **提交贡献即认为签署了本协议,若对本协议有异议,请勿提交贡献。**
7 |
8 | 为确保社区及项目合法合规,同时也避免侵犯任何人士的合法权益,我们希望确保:
9 | (1)您对您所提交的贡献具有完整充分的合法权利;
10 | (2)您的提交行为合法且不侵权。
11 |
12 | 您在提交贡献后,仍然对贡献享有应有的合法权利。您不会因为提交贡献而承担任何未约定的义务。
13 |
14 | **一、定义**
15 | 为本协议之目的,除非上下文另有说明,本协议中用语分别具有本条所指含义:
16 | 1.1 “中国”指中华人民共和国。
17 | 1.2 “法律”包括但不限于任何适用的法典、法律、法规、规章、司法解释及规范性文件,包括但不限于《中华人民共和国著作权法》(“著作权法”)、《中华人民共和国计算机软件保护条例》、《中华人民共和国专利法》(“专利法”)。如无特别说明或者其他约定,本协议项下争议优先适用中国法律。
18 | 1.3 “社区”或“我们”指gpress社区。
19 | 1.4 “项目”指社区拥有及/或管理的项目,包括但不限于软件、软件所包含的程序、代码、文字、图片、图形、文档或者其他信息。于本协议签署之日,项目托管于Gitee [https://gitee.com/gpress](https://gitee.com/gpress),托管地址今后可能随实际情况发生变化,具体访问地址以社区实时公布为准。
20 | 1.5 “贡献者”指签署本协议并向社区提交贡献的任何自然人、法人、其他组织以及法律规定的其他主体。
21 | 1.6 “贡献”指由贡献者根据本协议向社区提交的任何程序、代码、文字、图片、图形、文档或者其他作品。
22 | 1.7 “提交”指将“贡献”通过电子邮件或者其他形式发送给“项目”或者“社区”,其他形式包括但不限于讨论、在“项目”相关的电子邮件列表上的交流、在“项目”相关的源代码修订控制、问题跟踪等系统中的操作,但不包括以书面方式明确标记为“非贡献”的交流。
23 | 1.8 “著作权”指《著作权法》规定的各项权利;在任何不适用中国法律的争议中,应指包括《保护文学艺术作品伯尔尼公约》、《世界知识产权组织版权公约》、《与贸易有关的知识产权协定》等国际公约及争议准据法项下规定在内的全部可适用权利。
24 | 1.9 “专利权”指《专利法》规定的各项权利;在任何不适用中国法律的争议中,应指包括《保护工业产权巴黎公约》、《与贸易有关的知识产权协定》等国际公约及争议准据法项下规定在内的全部可适用权利。
25 | 1.10 “合法权利”包括但不限于著作权、版权、专利权、商标权、隐私权以及法律规定的其他权利。
26 | 1.11 “作品”指《著作权法》规定的在文学、艺术和科学领域内具有独创性并能以一定形式表现的智力成果以及《专利法》规定的产品、方法或者其改进所提出的新的技术方案、对产品的形状、构造或者其结合所提出的适于实用的新的技术方案、对产品的整体或者局部的形状、图案或者其结合以及色彩与形状、图案的结合所作出的富有美感并适于工业应用的新设计。在任何不适用中国法律的争议中,应指与著作权及专利权相对应的全部可适用标的。
27 | 1.12 “原创作品”指贡献者作为作者创作、开发的作品或者发明创造。
28 | 1.13 “职务作品”指贡献者作为作者创作、开发但依法属于《著作权法》规定的职务作品的作品或者《专利法》规定的职务发明创造。
29 | 1.14 “合作作品”指贡献者作为作者之一创作、开发但依法属于《著作权法》规定的合作作品的作品或者《专利法》规定的合作完成的发明创造。
30 | 1.15 “委托作品”指贡献者作为作者创作、开发但依法属于《著作权法》规定的委托作品的作品或者《专利法》规定的委托完成的发明创造。
31 | 1.16 “非原创作品”指贡献者以外的人创作、开发的作品。为免歧义,贡献者作为作者之一参与的合作作品属于原创作品,但作为贡献提交时,贡献者应取得合作作者的合法授权。
32 |
33 | **二、著作权许可授权**
34 | 2.1 贡献一经提交,即视为贡献者免费且不可撤销地授予社区、项目及其全部或者部分的接收者永久、非排他、全球性的著作权许可,修改、复制、发行、传播、改编、注释、整理、汇编、开发、展示、分发、再许可或以其他合法方式使用贡献及使用贡献产生的成果。
35 |
36 | **三、专利权许可授权**
37 | 3.1 贡献一经提交,即视为贡献者免费且不可撤销地授予社区、项目及其全部或者部分的接收者永久、非排他、全球性的专利权许可,制造、委托制造、销售、许诺销售、进口或以其他合法方式使用贡献及使用贡献产生的成果。
38 |
39 | **四、稳定运行承诺**
40 | 4.1 社区承诺绝不会主动关闭项目,具体指社区绝不会主动对外关闭项目的访问权限或者清空项目所包含的全部信息。
41 |
42 | **五、原创及不侵权承诺**
43 | 5.1 除严格按第5.4条要求明确标记为非原创的情形之外,贡献者承诺所提交的贡献完全为原创作品,不侵害他人的合法权利,且无以下任何一种情况:
44 | 5.1.1 属于职务作品,单位未签署本协议及/或未同意贡献者提交;
45 | 5.1.2 属于合作作品,合作作者未签署本协议及/或未同意贡献者提交;
46 | 5.1.3 属于委托作品或者著作权、专利权已经对外转让,著作权、专利权的实际持有人未签署本协议及/或未同意贡献者提交。
47 | 5.2 如存在第5.1条任何一种情形的,贡献者应先取得相应授权后再进行提交:
48 | 5.2.1 如有第5.1.1条的情形,贡献者应事先取得单位的授权;
49 | 5.2.2 如有第5.1.2条的情形,贡献者应事先取得合作作者的授权;
50 | 5.2.3 如有第5.1条的情形,贡献者应事先取得著作权、专利权实际持有人的授权。
51 | 5.3 在遵守本第五条约定的基础上,单位作为贡献者签署本协议的,可以授权指定人士以单位名义、单位员工名义或者个人名义提交贡献。
52 | 5.4 如贡献者提交的贡献为非原创作品,则贡献者应当明确标记出非原创部分,并完整列出原创者及/或著作权、专利权持有者的名称。
53 | 5.5 除其他条款约定外,如贡献者提交的贡献在使用时可能涉及任何第三方权利,则贡献者还应当在提交时予以说明,并披露该等限制的完整详细信息。
54 | 5.6 请留意:社区希望保护贡献者的合法权益,免受任何人士的侵犯;社区也倡导尊重原创、保护知识产权,不允许侵犯他人的合法权益。如贡献者提交贡献时,冒名、盗用或者擅自提交他人享有著作权或其他合法权利的作品或者以其他方式侵犯他人合法权益,导致社区承担责任和损失的,社区保留追究责任的权利。
55 |
56 | **六、贡献者权利保护**
57 | 6.1 贡献者签署本协议不应视为放弃原创者身份或署名权。本协议不影响贡献者将其贡献合法用于其他任何目的的权利,社区或者任何其他人士亦不应凭借本协议要求贡献者放弃其他任何合法权利。
58 | 6.2 贡献者签署本协议不应视为承诺对其提交的贡献承担后续支持、维保、适用性、品质保证等义务。社区或者任何其他人士亦不应凭借本协议要求贡献者承担任何未约定的义务。
--------------------------------------------------------------------------------
/Logger.go:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2023 gpress Authors.
2 | //
3 | // This file is part of gpress.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU Affero General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU Affero General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU Affero General Public License
16 | // along with this program. If not, see .
17 |
18 | package main
19 |
20 | import (
21 | "context"
22 |
23 | "github.com/cloudwego/hertz/pkg/common/hlog"
24 | )
25 |
26 | func init() {
27 | // 设置默认的日志显示信息,显示文件和行号
28 | // Set the default log display information, display file and line number.
29 | // log.SetFlags(log.Llongfile | log.LstdFlags)
30 | // 设置日志级别
31 | hlog.SetLevel(hlog.LevelError)
32 | }
33 |
34 | // LogCallDepth 记录日志调用层级,用于定位到业务层代码
35 | // Log Call Depth Record the log call level, used to locate the business layer code
36 | var LogCallDepth = 4
37 |
38 | // FuncLogError 记录error日志
39 | // FuncLogError Record error log
40 | var FuncLogError func(ctx context.Context, err error) = defaultLogError
41 |
42 | // FuncLogPanic 记录panic日志,默认使用"defaultLogPanic"实现
43 | // FuncLogPanic Record panic log, using "defaultLogPanic" by default
44 | var FuncLogPanic func(ctx context.Context, err error) = defaultLogPanic
45 |
46 | func defaultLogError(ctx context.Context, err error) {
47 | //log.Output(LogCallDepth, fmt.Sprintln(err))
48 | hlog.Error(err)
49 | }
50 |
51 | func defaultLogPanic(ctx context.Context, err error) {
52 | defaultLogError(ctx, err)
53 | }
54 |
--------------------------------------------------------------------------------
/const.go:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2023 gpress Authors.
2 | //
3 | // This file is part of gpress.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU Affero General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU Affero General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU Affero General Public License
16 | // along with this program. If not, see .
17 |
18 | package main
19 |
20 | const (
21 | // 默认名称
22 | appName = "gpress"
23 |
24 | // 基本目录
25 | datadir = "gpressdatadir/"
26 | // 数据目录,如果不存在认为是第一次安装启动,会创建默认的数据
27 | sqliteDBfile = datadir + "gpress.db"
28 | // 表信息的名称
29 | //tableInfoName = "tableInfo"
30 | // 表字段的名称
31 | //tableFieldName = "tableField"
32 |
33 | // config 配置的表名称
34 | tableConfigName = "config"
35 |
36 | // user 用户的表名称
37 | tableUserName = "user"
38 | // site 站点信息
39 | tableSiteName = "site"
40 |
41 | // 导航菜单
42 | tableCategoryName = "category"
43 |
44 | // 默认模型
45 | // tableModuleDefaultName = "module_default"
46 | // 文章内容
47 | tableContentName = "content"
48 | //---------------------------//
49 |
50 | // 模板的路径
51 | templateDir = datadir + "template/"
52 |
53 | // 主题的路径
54 | themeDir = templateDir + "theme/"
55 |
56 | // 静态化文件目录,网站生成的静态html
57 | staticHtmlDir = datadir + "statichtml/"
58 |
59 | // 数据默认的创建用户
60 | createUser = "system"
61 |
62 | tokenUserId = "userId"
63 |
64 | letters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
65 |
66 | userTypeKey = "userType" //0访客,1管理员
67 |
68 | defaultPageSize = 10
69 |
70 | searchDataJsonFile = datadir + "public/search-data.json"
71 |
72 | // 静态文件压缩后缀,兼容Nginx gzip_static
73 | compressedFileSuffix = ".gz"
74 |
75 | //版本号
76 | version = "v1.1.2"
77 | )
78 |
--------------------------------------------------------------------------------
/funcmap_test.go:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2023 gpress Authors.
2 | //
3 | // This file is part of gpress.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU Affero General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU Affero General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU Affero General Public License
16 | // along with this program. If not, see .
17 |
18 | package main
19 |
20 | import (
21 | "reflect"
22 | "testing"
23 | )
24 |
25 | func TestDataSliceCategory2Tree(t *testing.T) {
26 | type args struct {
27 | categories []*Category
28 | }
29 | tests := []struct {
30 | name string
31 | args args
32 | want []*Category
33 | }{
34 | {
35 | name: "无节点",
36 | args: args{
37 | categories: nil,
38 | },
39 | want: []*Category{},
40 | },
41 | {
42 | name: "两级节点",
43 | args: args{
44 | categories: []*Category{
45 | {Id: "1", Name: "Category 1", Pid: ""},
46 | {Id: "2", Name: "Category 2", Pid: "1"},
47 | {Id: "3", Name: "Category 3", Pid: ""},
48 | {Id: "4", Name: "Category 4", Pid: "3"},
49 | },
50 | },
51 | want: []*Category{
52 | {
53 | Id: "1",
54 | Name: "Category 1",
55 | Leaf: []*Category{{Id: "2", Name: "Category 2", Pid: "1"}},
56 | },
57 | {
58 | Id: "3",
59 | Name: "Category 3",
60 | Leaf: []*Category{{Id: "4", Name: "Category 4", Pid: "3"}},
61 | },
62 | },
63 | },
64 | {
65 | name: "多级节点",
66 | args: args{
67 | categories: []*Category{
68 | {Id: "1", Name: "Category 1", Pid: ""},
69 | {Id: "2", Name: "Category 2", Pid: "1"},
70 | {Id: "3", Name: "Category 3", Pid: "1"},
71 | {Id: "4", Name: "Category 4", Pid: "2"},
72 | {Id: "5", Name: "Category 5", Pid: "2"},
73 | {Id: "6", Name: "Category 6", Pid: "3"},
74 | },
75 | },
76 | want: []*Category{
77 | {
78 | Id: "1",
79 | Name: "Category 1",
80 | Leaf: []*Category{
81 | {
82 | Id: "2",
83 | Pid: "1",
84 | Name: "Category 2",
85 | Leaf: []*Category{
86 | {
87 | Id: "4",
88 | Pid: "2",
89 | Name: "Category 4",
90 | },
91 | {
92 | Id: "5",
93 | Pid: "2",
94 | Name: "Category 5",
95 | },
96 | },
97 | },
98 | {
99 | Id: "3",
100 | Pid: "1",
101 | Name: "Category 3",
102 | Leaf: []*Category{
103 | {
104 | Id: "6",
105 | Pid: "3",
106 | Name: "Category 6",
107 | },
108 | },
109 | },
110 | },
111 | },
112 | },
113 | },
114 | {
115 | name: "多颗树",
116 | args: args{
117 | categories: []*Category{
118 | {Id: "1", Name: "Category 1", Pid: ""},
119 | {Id: "2", Name: "Category 2", Pid: "1"},
120 | {Id: "3", Name: "Category 3", Pid: ""},
121 | {Id: "4", Name: "Category 4", Pid: "3"},
122 | {Id: "5", Name: "Category 5", Pid: ""},
123 | {Id: "6", Name: "Category 6", Pid: "5"},
124 | },
125 | },
126 | want: []*Category{
127 | {
128 | Id: "1",
129 | Name: "Category 1",
130 | Leaf: []*Category{
131 | {
132 | Id: "2",
133 | Pid: "1",
134 | Name: "Category 2",
135 | },
136 | },
137 | },
138 | {
139 | Id: "3",
140 | Name: "Category 3",
141 | Leaf: []*Category{
142 | {
143 | Id: "4",
144 | Pid: "3",
145 | Name: "Category 4",
146 | },
147 | },
148 | },
149 | {
150 | Id: "5",
151 | Name: "Category 5",
152 | Leaf: []*Category{
153 | {
154 | Id: "6",
155 | Pid: "5",
156 | Name: "Category 6",
157 | },
158 | },
159 | },
160 | },
161 | },
162 | }
163 | for _, tt := range tests {
164 | t.Run(tt.name, func(t *testing.T) {
165 | if got := sliceCategory2Tree(tt.args.categories); !reflect.DeepEqual(got, tt.want) {
166 | t.Errorf("sliceCategory2Tree() = %v, want %v", got, tt.want)
167 | }
168 | })
169 | }
170 | }
171 |
--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
1 | module gitee.com/gpress/gpress
2 |
3 | go 1.24
4 |
5 | require (
6 | gitee.com/chunanyong/zorm v1.7.8
7 | github.com/alecthomas/chroma/v2 v2.18.0
8 | github.com/cloudwego/hertz v0.10.0
9 | github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0
10 | github.com/mattn/go-sqlite3 v1.14.28
11 | github.com/mojocn/base64Captcha v1.3.8
12 | github.com/tetratelabs/wazero v1.9.0
13 | github.com/yuin/goldmark v1.7.12
14 | github.com/yuin/goldmark-emoji v1.0.6
15 | github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc
16 | github.com/yuin/goldmark-meta v1.1.0
17 | go.abhg.dev/goldmark/mermaid v0.5.0
18 | go.abhg.dev/goldmark/toc v0.12.0
19 | golang.org/x/crypto v0.38.0
20 | )
21 |
22 | require (
23 | github.com/bytedance/gopkg v0.1.1 // indirect
24 | github.com/bytedance/sonic v1.13.2 // indirect
25 | github.com/bytedance/sonic/loader v0.2.4 // indirect
26 | github.com/cloudwego/base64x v0.1.5 // indirect
27 | github.com/cloudwego/gopkg v0.1.4 // indirect
28 | github.com/cloudwego/netpoll v0.7.0 // indirect
29 | github.com/dlclark/regexp2 v1.11.5 // indirect
30 | github.com/fsnotify/fsnotify v1.5.4 // indirect
31 | github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
32 | github.com/golang/protobuf v1.5.0 // indirect
33 | github.com/klauspost/cpuid/v2 v2.0.9 // indirect
34 | github.com/nyaruka/phonenumbers v1.0.55 // indirect
35 | github.com/tidwall/gjson v1.14.4 // indirect
36 | github.com/tidwall/match v1.1.1 // indirect
37 | github.com/tidwall/pretty v1.2.0 // indirect
38 | github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
39 | golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
40 | golang.org/x/image v0.23.0 // indirect
41 | golang.org/x/sys v0.33.0 // indirect
42 | google.golang.org/protobuf v1.27.1 // indirect
43 | gopkg.in/yaml.v2 v2.3.0 // indirect
44 | )
45 |
--------------------------------------------------------------------------------
/goldmark_test.go:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2023 gpress Authors.
2 | //
3 | // This file is part of gpress.
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU Affero General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 | //
10 | // This program is distributed in the hope that it will be useful
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU Affero General Public License for more details.
14 | //
15 | // You should have received a copy of the GNU Affero General Public License
16 | // along with this program. If not, see .
17 |
18 | package main
19 |
20 | import (
21 | "fmt"
22 | "os"
23 | "testing"
24 | )
25 |
26 | func TestGoldmarkMeta(t *testing.T) {
27 | source, err := os.ReadFile(datadir + "post/34-es-config.md")
28 | if err != nil {
29 | t.Error(err)
30 | return
31 | }
32 | metaData, tocHtml, html, _ := conver2Html(source)
33 | fmt.Println(metaData["categories"])
34 | fmt.Println(metaData["tags"])
35 | fmt.Println(metaData)
36 | fmt.Println(*tocHtml)
37 | fmt.Println(*html)
38 | }
39 |
--------------------------------------------------------------------------------
/gpressdatadir/dict.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/dict.zip
--------------------------------------------------------------------------------
/gpressdatadir/fts5/libsimple.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/fts5/libsimple.dll
--------------------------------------------------------------------------------
/gpressdatadir/fts5/libsimple.dylib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/fts5/libsimple.dylib
--------------------------------------------------------------------------------
/gpressdatadir/fts5/libsimple.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/fts5/libsimple.so
--------------------------------------------------------------------------------
/gpressdatadir/fts5/libsimple.so-aarch64:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/fts5/libsimple.so-aarch64
--------------------------------------------------------------------------------
/gpressdatadir/install_config.json:
--------------------------------------------------------------------------------
1 | {
2 | "serverPort":":660",
3 | "timeout":7200,
4 | "jwttokenKey":"jwttoken",
5 | "jwtSecret":"",
6 | "basePath":"/",
7 | "proxy":"",
8 | "maxRequestBodySize":20971520,
9 | "locale":"zh-CN"
10 | }
--------------------------------------------------------------------------------
/gpressdatadir/libgcc_s_seh-1.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/libgcc_s_seh-1.dll
--------------------------------------------------------------------------------
/gpressdatadir/locales/en-US.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/gpressdatadir/locales/zh-CN.json:
--------------------------------------------------------------------------------
1 | {
2 | "Install": "安装",
3 | "Congratulations, you have successfully installed GPRESS. Please log in now": "恭喜您,成功安装gpress,现在请登录",
4 | "Please fill in the administrator account": "请填写管理员账号",
5 | "Please fill in the administrator password": "请填写管理员密码",
6 | "Please re-enter the administrator password": "请再次填写管理员密码",
7 | "Use blockchain wallet": "使用区块链钱包",
8 | "Blockchain Address": "区块链Address",
9 | "Blockchain Type": "区块链类型",
10 | "Please select blockchain type": "请选择区块链类型",
11 | "Please select": "请选择",
12 | "XuperChain": "百度超级链",
13 | "Ethereum": "以太坊",
14 | "Address": "Address",
15 | "Please fill in the blockchain Address": "请填写区块链Address",
16 | "Install(using blockchain Address)": "安装(使用区块链Address)",
17 | "Use account and password": "使用账号密码",
18 | "Passwords do not match": "两次密码填写不一致",
19 | "Content Navigation": "内容导航",
20 | "Site Information": "站点信息",
21 | "User Information": "用户信息",
22 | "Theme Template": "主题模板",
23 | "Refresh Site": "刷新站点",
24 | "Settings": "设置",
25 | "Logout": "退出",
26 | "Reload successful": "刷新成功",
27 | "Blockchain wallet login": "区块链钱包登录",
28 | "Blockchain login": "区块链登录",
29 | "Account password login": "账号密码登录",
30 | "Contact us": "联系我们",
31 | "1. Rename gpressdatadir/template/install.html.bak to install.html 2. Settings updated successfully, restart GPRESS to take effect!, reinitialize administrator account and password, data will not be lost": "1.重命名 gpressdatadir/template/install.html.bak 为 install.html 2.重启gpress,重新安装初始化管理员账号密码,数据不会丢失",
32 | "Forgot password": "忘记密码",
33 | "Please install the corresponding wallet": "请安装对应的钱包",
34 | "Info": "信息",
35 | "Login": "登录",
36 | "Account": "账 户",
37 | "Please fill in the account": "请填写账户",
38 | "Password": "密 码",
39 | "Please fill in the password": "请填写密码",
40 | "CAPTCHA": "验证码",
41 | "Please fill in the CAPTCHA": "请填写验证码",
42 | "Blockchain Login": "区块链登录",
43 | "Update Settings": "更新设置",
44 | "Base Path": "基础路径",
45 | "Please fill in the JWT Key": "请填写JWT Key",
46 | "Please fill in the JWT Secret": "请填写JWT Secret",
47 | "Please fill in the IP:Port": "请填写IP:Port",
48 | "Language": "语言",
49 | "Timeout": "超时时间",
50 | "Please fill in the timeout": "请填写超时时间",
51 | "Max Request Size": "最大的请求",
52 | "Submit Changes": "提交修改",
53 | "Update SQL": "更新SQL",
54 | "Please enter the update SQL": "请输入更新SQL",
55 | "SQL execution failed!": "SQL执行失败!",
56 | "SQL executed successfully!": "SQL执行成功!",
57 | "Update error!": "更新错误!",
58 | "Settings updated successfully, restart GPRESS to take effect!": "设置修改成功,重启gpress才能生效!",
59 | "Update failed!": "修改失败!",
60 | "OK": "确定",
61 | "Cancel": "取消",
62 | "Update User Information": "更新用户信息",
63 | "Username": "用户名",
64 | "Update successfully!": "修改成功!",
65 | "Update Site Information": "更新站点信息",
66 | "Name": "名称",
67 | "Please fill in the name": "请填写名称",
68 | "Title": "标题",
69 | "Please fill in the title": "请填写标题",
70 | "Domain": "域名",
71 | "Used to generate the sitemap.xml": "用于生成网站地图sitemap.xml",
72 | "PC Theme": "PC主题",
73 | "Used when accessed by PC browsers": "PC浏览器访问时,使用此主题渲染",
74 | "Mobile Theme": "手机主题",
75 | "Used when accessed by mobile browsers": "手机浏览器访问时,使用此主题渲染",
76 | "WeChat Theme": "微信主题",
77 | "Used when accessed by WeChat": "微信访问时,使用此主题渲染",
78 | "Default Theme": "默认主题",
79 | "Default rendering theme, all themes are located in gpressdatadir/template/theme directory": "默认渲染的主题,所有主题都在gpressdatadir/template/theme目录下",
80 | "Upload Image": "上传图片",
81 | "Footer": "底部信息",
82 | "Site information updated successfully, please Refresh Site": "站点信息修改成功,请刷新站点",
83 | "Only zip format is supported": "仅支持zip格式",
84 | "Upload Theme": "上传主题",
85 | "Theme Market": "主题市场",
86 | "Save File": "保存文件",
87 | "Select the file to modify on the left, display the file content here, edit and modify, click the Save File button to save the changes.": "左侧选择要修改的文件,这里显示文件内容,进行编辑修改,点击保存文件按钮,保存修改的内容。",
88 | "Upload successful": "上传成功",
89 | "Upload error!": "上传错误!",
90 | "Please select the file to modify": "请选择要修改的文件",
91 | "Update error, please try again!": "修改错误,请重试!",
92 | "Theme Name": "主题名称",
93 | "Version": "版本",
94 | "Theme Category": "主题分类",
95 | "Compatible Version": "兼容版本",
96 | "Preview": "预览图",
97 | "Download": "下载",
98 | "Add Navigation Menu": "新增导航菜单",
99 | "Path Identifier": "路径标识",
100 | "Cannot update after saved": "保存后不允许修改",
101 | "Please fill in the path identifier": "请填写路径标识",
102 | "Navigation Name": "导航名称",
103 | "Please fill in the navigation name": "请填写导航名称",
104 | "Redirect Path": "跳转路径",
105 | "Redirect Method": "跳转方式",
106 | "Default": "默认",
107 | "Parent Navigation": "父级导航",
108 | "Page Template": "页面模版",
109 | "Sort": "排序",
110 | "Please fill in the sort number": "请填写排序",
111 | "Status": "状态",
112 | "Public": "公开",
113 | "Link Access": "链接访问",
114 | "Top": "置顶",
115 | "Private": "私密",
116 | "Submit": "提交保存",
117 | "Path identifier can contain letters, numbers, hyphens (-), underscores (_), vertical bars (|), and commas (,)": "路径标识可以包含英文、数字、中划线(-)、下划线(_)、竖线(|)和逗号(,)",
118 | "Save error!": "保存错误!",
119 | "Save successful, continue adding?": "保存成功,是否继续添加?",
120 | "Confirm": "确认",
121 | "Return to List": "返回列表",
122 | "Continue Adding": "继续添加",
123 | "Save failed!": "保存失败!",
124 | "Update Navigation Menu": "更新导航菜单",
125 | "URL Path": "URL路径",
126 | "Update successful, continue editing?": "修改成功,是否继续修改?",
127 | "Continue Editing": "继续修改",
128 | "prev": "上一页",
129 | "next": "下一页",
130 | "first": "首页",
131 | "last": "尾页",
132 | "Total": "共",
133 | "Go to": "到第",
134 | "records": "条",
135 | "pages": "页",
136 | "Add Top Navigation": "新增一级导航",
137 | "All Content": "全部内容",
138 | "Search": "搜索",
139 | "Add Content": "新增内容",
140 | "Navigation Menu": "导航菜单",
141 | "Actions": "操作",
142 | "Unknown": "未知",
143 | "Edit": "编辑",
144 | "Delete": "删除",
145 | "Add Sub Navigation": "新增子导航",
146 | "Edit Navigation": "编辑导航",
147 | "Delete Navigation": "删除导航",
148 | "Confirm deletion?": "确认删除?",
149 | "Delete successful": "删除成功",
150 | "Delete failed!": "删除失败!",
151 | "Please fill in the content title": "请填写文章标题",
152 | "Summary": "摘要",
153 | "Please select a navigation menu": "请选择导航菜单",
154 | "Description": "description",
155 | "Cover Image": "封面图",
156 | "Upload Cover": "上传封面",
157 | "Author": "作者",
158 | "Tag": "tag标签",
159 | "Content format":"内容格式",
160 | "Rich Text": "富文本",
161 | "Path identifier and navigation menu cannot be empty": "路径标识和导航菜单不能为空",
162 | "Please enter content...": "请输入内容...",
163 | "Edit Content": "修改内容",
164 | "Navigation menu cannot be empty": "导航菜单不能为空",
165 | "Incorrect verification code": "验证码错误",
166 | "Account or password cannot be empty": "账户或密码不能为空",
167 | "Account or password is incorrect": "账户或密码错误",
168 | "Address anomaly": "地址异常",
169 | "We currently do not support this type of blockchain account": "暂不支持此类型区块链账户",
170 | "Signature verification failed": "签名校验失败",
171 | "Markdown to HTML conversion error": "Markdown转html错误",
172 | "ID does not exist": "Id不存在",
173 | "JSON data conversion error": "转换json数据错误",
174 | "ID cannot be empty": "id不能为空",
175 | "Failed to update data": "更新数据失败",
176 | "URL path is duplicated, please modify the path identifier": "URL路径重复,请修改路径标识",
177 | "Failed to save data": "保存数据失败",
178 | "Saved successfully!": "保存成功!",
179 | "Cannot delete a navigation item with child elements!": "无法删除有子级的导航!",
180 | "Failed to delete data": "删除数据失败",
181 | "Data deleted successfully": "删除数据成功",
182 | "Updated %d records": "修改 %d 条数据",
183 | "Failed to load install_config.json, using default configuration": "install_config.json加载失败,使用默认配置",
184 | "Load failed, using default":"加载失败,使用默认",
185 | "Please confirm if [%s] needs to be manually renamed to [gpress.db]. If not, please manually delete [%s]": "请确认[%s]是否需要手动重命名为[gpress.db],不需要请手动删除[%s]",
186 | "File anomaly": "文件异常",
187 | "Table check failed,sqliteStatus is false": "表检查失败,sqliteStatus状态为false",
188 | "Table does not exist!": "表不存在!",
189 | "SQL statement error": "sql语句错误",
190 | "Template initialization anomaly": "初始化模板异常",
191 | "Open the front-end in the browse": "浏览器打开前端",
192 | "Open the back-end in the browser": "浏览器打开后台",
193 | "Original data hash does not match": "原始数据Hash不一致",
194 | "The public key in the signature does not match the address":"签名中的公钥和address不匹配",
195 | "Backend management":"后台管理"
196 | }
--------------------------------------------------------------------------------
/gpressdatadir/post/01-nginx-config.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "01.Nginx安装配置"
3 | date: 2017-01-10T17:11:00+08:00
4 | draft: false
5 | tags: ["web"]
6 | categories: ["web"]
7 | author: "springrain"
8 | ---
9 |
10 | ## 1. 准备环境
11 | ```shell
12 | yum -y install openssl-devel zlib-devel libtool automake autoconf make
13 | yum -y install gcc gcc-c++
14 |
15 | #下载Nginx
16 | wget http://nginx.org/download/nginx-1.22.1.tar.gz
17 | #下载PCRE
18 | wget https://jaist.dl.sourceforge.net/project/pcre/pcre/8.45/pcre-8.45.tar.gz
19 | ```
20 | ## 2. 安装nginx
21 | ```shell
22 |
23 | tar -zxf nginx-1.22.1.tar.gz
24 | tar -zxf pcre-8.45.tar.gz
25 |
26 | #进入nginx解压后的目录
27 | cd nginx-1.22.1
28 |
29 | #执行检查
30 | ./configure --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_v2_module --with-http_realip_module --with-pcre=/root/pcre-8.45
31 |
32 | #然后执行:
33 | make
34 | make install
35 | ```
36 | 运行一下,查看是否正常,Nginx默认监听的是80端口
37 | 启动:```/usr/local/nginx/sbin/nginx```
38 | 重启:```/usr/local/nginx/sbin/nginx -s reload```
39 |
40 | 
41 |
42 | **[Windows版本的Nginx](/01/nginx-windows.zip)**
43 |
44 | ## 3. 配置Nginx
45 | 一般是把nginx主文件和server文件分开处理,这样便于管理.
46 | 主文件是:```/usr/local/nginx/conf/nginx.conf```
47 | 给server文件创建一个单独的www文件夹
48 | ```shell
49 | mkdir /usr/local/nginx/www
50 | ```
51 | server配置文件名以 .conf为后缀.
52 |
53 |
54 | **[下载范例配置文件](/01/conf.zip)**
55 |
56 |
57 | ## 4. 开机启动
58 | 编辑 ```vi /etc/rc.d/rc.local``` 在最后加上一行
59 | ```/usr/local/nginx/sbin/nginx```
60 | 建议把nginx目录迁移至数据盘.例如数据库挂载为/data目录
61 | 关闭nginx服务:```/usr/local/nginx/sbin/nginx -s stop```
62 | 迁移目录:```mv /usr/local/nginx /data/nginx```
63 | 建立软链接:```ln -s /usr/local/nginx /usr/local/nginx```
64 | 启动nginx服务:```/usr/local/nginx/sbin/nginx```
65 |
66 | ## 5. 切割日志
67 | Nginx默认并没有实现日志切割,这样所有的日志都在一个文件里,文件很大时会影响访问的性能.通过每天零点调用日志切割的脚本,实现Nginx日志切割.
68 |
69 | cut_nginx_logs.sh 脚本如下:
70 | ```shell
71 | #!/bin/bash
72 | #function:cut nginx log files
73 | #author: http://www.jiagou.com
74 |
75 | ###设置日志文件的路径####
76 | log_files_path="/usr/local/nginx/logs/"
77 | ###日志文件备份的路径####
78 | log_files_dir=${log_files_path}history/$(date -d "yesterday" +"%Y")/$(date -d "yesterday" +"%m")
79 | ###设置日志文件名称###
80 | log_files_name=(domain1.access domain2.access error)
81 | ###nginx主程序###
82 | nginx_sbin="/usr/local/nginx/sbin/nginx"
83 | ###保留日志天数###
84 | save_days=100
85 |
86 | ############################################
87 | #Please do not modify the following script #
88 | ############################################
89 | mkdir -p $log_files_dir
90 |
91 | log_files_num=${#log_files_name[@]}
92 |
93 | #cut nginx log files
94 | for((i=0;i<$log_files_num;i++));do
95 | mv ${log_files_path}${log_files_name[i]}.log ${log_files_dir}/${log_files_name[i]}_$(date -d "yesterday" +"%Y%m%d").log
96 | done
97 |
98 | #delete save_days ago nginx log files
99 | find $log_files_path -mtime +$save_days -exec rm -rf {} \;
100 |
101 | ##reload会重启nginx,重新加载配置文件,reopen只会重建日志文件##
102 | #$nginx_sbin -s reload
103 | $nginx_sbin -s reopen
104 | ```
105 | 把cut_nginx_logs.sh脚本放到```/usr/local/nginx/sbin/``` 目录下,修改可执行权限:
106 | ```shell
107 | chmod 755 /usr/local/nginx/sbin/cut_nginx_logs.sh
108 | ```
109 | 添加定时调用:crontab -e 编辑输入
110 | ```shell
111 | 00 00 * * * /bin/bash /usr/local/nginx/sbin/cut_nginx_logs.sh
112 | ```
113 |
114 |
115 |
--------------------------------------------------------------------------------
/gpressdatadir/public/doc/image/000.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/doc/image/000.png
--------------------------------------------------------------------------------
/gpressdatadir/public/doc/image/001.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/doc/image/001.png
--------------------------------------------------------------------------------
/gpressdatadir/public/doc/image/002.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/doc/image/002.png
--------------------------------------------------------------------------------
/gpressdatadir/public/doc/image/003.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/doc/image/003.png
--------------------------------------------------------------------------------
/gpressdatadir/public/doc/image/004.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/doc/image/004.png
--------------------------------------------------------------------------------
/gpressdatadir/public/doc/image/005.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/doc/image/005.png
--------------------------------------------------------------------------------
/gpressdatadir/public/doc/image/006.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/doc/image/006.png
--------------------------------------------------------------------------------
/gpressdatadir/public/doc/image/007.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/doc/image/007.png
--------------------------------------------------------------------------------
/gpressdatadir/public/doc/image/008.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/doc/image/008.png
--------------------------------------------------------------------------------
/gpressdatadir/public/doc/image/009.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/doc/image/009.png
--------------------------------------------------------------------------------
/gpressdatadir/public/doc/image/010.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/doc/image/010.png
--------------------------------------------------------------------------------
/gpressdatadir/public/doc/image/011.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/doc/image/011.png
--------------------------------------------------------------------------------
/gpressdatadir/public/doc/image/012.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/doc/image/012.png
--------------------------------------------------------------------------------
/gpressdatadir/public/doc/image/013.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/doc/image/013.png
--------------------------------------------------------------------------------
/gpressdatadir/public/doc/image/014.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/doc/image/014.png
--------------------------------------------------------------------------------
/gpressdatadir/public/doc/image/015.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/doc/image/015.png
--------------------------------------------------------------------------------
/gpressdatadir/public/doc/image/016.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/doc/image/016.png
--------------------------------------------------------------------------------
/gpressdatadir/public/doc/image/017.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/doc/image/017.png
--------------------------------------------------------------------------------
/gpressdatadir/public/doc/image/018.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/doc/image/018.png
--------------------------------------------------------------------------------
/gpressdatadir/public/doc/image/019.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/doc/image/019.png
--------------------------------------------------------------------------------
/gpressdatadir/public/doc/image/020.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/doc/image/020.png
--------------------------------------------------------------------------------
/gpressdatadir/public/doc/index.md:
--------------------------------------------------------------------------------
1 | # gpress帮助文档
2 |
3 | ## 简介
4 | Web3内容平台,Hertz + Go template + FTS5全文检索,支持以太坊和百度超级链,兼容Hugo、WordPress生态,使用Wasm扩展插件,只需200M内存
5 |
6 | ## 安装
7 | 运行gpress,会输出访问的路径,根据提示使用浏览器访问 ```http://127.0.0.1:660/admin/login``` 首次运行会进入安装界面.
8 |
9 | 首次运行gpress,一定要先进行安装设置管理员的账号密码.安装界面如下图:
10 |
11 | 输入管理员账号和密码,即完成安装,同时支持区块链账号Address作为管理员用户
12 |
13 | 目前支持以太坊和百度超级链,推荐使用[X-Pocket钱包](https://github.com/shengjian-tech/X-Pocket)
14 |
15 |
16 | ## 登录
17 | 浏览器访问 ```http://127.0.0.1:660/admin/login```,正常显示登录页面,输入安装时设置的账号密码.
18 |
19 | 同时支持使用区块链钱包进行授权登录
20 |
21 |
22 | ## 内容导航
23 | 登录之后,默认查看内容导航功能,左侧是导航菜单,右侧是文章内容
24 |
25 | 新增一级导航,就是新增上级为空的导航,会跳转到新增导航界面.
26 | 选中导航,字体颜色为蓝色,右侧显示改导航下的内容,如下图示例,选中```BlockChain```导航
27 |
28 | 导航后面有功能提示的图标,鼠标悬浮显示功能菜单.
29 |
30 | 有以下四个功能:
31 | - 新增内容:为该导航新增文章内容
32 | - 新增子导航:在该导航下新增子导航
33 | - 编辑导航: 编辑该导航
34 | - 删除导航: 删除该导航
35 | 新增子导航的功能界面如下:
36 |
37 | 编辑导航的功能界面如下:
38 |
39 | 删除导航的功能界面如下:
40 |
41 |
42 | ## 新增/修改内容
43 | 内容管理是gpress的重要功能,新增内容主要设置内容的ID,标题和归属的导航菜单,ID会出现在URL中,且不可更改,例如 ID为```gpress```,访问路径为```http://127.0.0.1:660/web/gpress```.内容有```Markdown```和```富文本```两种格式,根据场景选择使用.
44 |
45 | ## 内容列表
46 | 界面左侧为内容列表,点击```ID```会跳转到前台界面,操作有```预览```,```编辑```和```删除```.```预览```是管理员查看实时数据,通过```ID```跳转的前台界面可能有静态化缓存.
47 | 内容列表有基于```fts5```实现的全文检索功能,输入关键字,点击搜索图标,完成搜索.
48 |
49 | ## 站点信息
50 | 设置站点的基础内容信息,其中主题是读取```gpressdatadir/template/theme```目录下的主题文件夹,更换主题之后,需要点击```刷新站点```功能,刷新前台界面. ```logo```是前台界面显示的logo,后台的logo固定为```gpress```的logo,暂时不支持更改.
51 |
52 | ## 用户信息
53 | 修改管理员的账号信息,功能界面如下:
54 |
55 | ## 主题模板
56 | 主题模板的增删改查功能,管理主题中的自定义模板文件,修改内容和导航菜单时,可以应用自定义的模板文件.
57 |
58 | 支持上传主题zip压缩包,用于新增主题.
59 |
60 | 可以从```主题市场```中下载主题,进行安装
61 |
62 |
63 | ## 刷新站点
64 | 模板更改时需要刷新站点才能生效,同时刷新站点会生成静态文件,用于```Nginx```静态化访问.
65 | ```刷新站点``` 功能会生成静态html文件到 ```statichtml``` 目录,同时生成```gzip_static```文件,需要把正在使用的主题的 ```css,js,image```和```gpressdatadir/public```目录复制到 ```statichtml```目录下,也可以用Nginx反向代理指定目录.
66 | nginx 配置示例如下:
67 | ```conf
68 | ### 当前在用主题(default)的css文件
69 | location ~ ^/css/ {
70 | #gzip_static on;
71 | root /data/gpress/gpressdatadir/template/theme/default;
72 | }
73 | ### 当前在用主题(default)的js文件
74 | location ~ ^/js/ {
75 | #gzip_static on;
76 | root /data/gpress/gpressdatadir/template/theme/default;
77 | }
78 | ### 当前在用主题(default)的image文件
79 | location ~ ^/image/ {
80 | root /data/gpress/gpressdatadir/template/theme/default;
81 | }
82 | ### search-data.json FlexSearch搜索的JSON数据
83 | location ~ ^/public/search-data.json {
84 | #gzip_static on;
85 | root /data/gpress/gpressdatadir;
86 | }
87 | ### public 公共文件
88 | location ~ ^/public/ {
89 | root /data/gpress/gpressdatadir;
90 | }
91 |
92 | ### admin 后台管理,请求动态服务
93 | location ~ ^/admin/ {
94 | proxy_redirect off;
95 | proxy_set_header Host $host;
96 | proxy_set_header X-Real-IP $remote_addr;
97 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
98 | proxy_set_header X-Forwarded-Proto $scheme;
99 | proxy_pass http://127.0.0.1:660;
100 | }
101 | ### 静态html目录
102 | location / {
103 | proxy_redirect off;
104 | proxy_set_header Host $host;
105 | proxy_set_header X-Real-IP $remote_addr;
106 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
107 | proxy_set_header X-Forwarded-Proto $scheme;
108 | ## 存在q查询参数,使用动态服务.也支持FlexSearch解析public/search-data.json
109 | if ($arg_q) {
110 | proxy_pass http://127.0.0.1:660;
111 | break;
112 | }
113 |
114 | ### 开启gzip静态压缩
115 | #gzip_static on;
116 |
117 | ### Nginx 1.26+ 不需要再进行302重定向到目录下的index.html,gzip_static也会生效.这段配置留作记录.
118 | ##if ( -d $request_filename ) {
119 | ## 不是 / 结尾
120 | ## rewrite [^\/]$ $uri/index.html redirect;
121 | ##以 / 结尾的
122 | ## rewrite ^(.*) ${uri}index.html redirect;
123 | ##}
124 |
125 | ### 当前在用主题(default)的静态文件目录
126 | root /data/gpress/gpressdatadir/statichtml/default;
127 |
128 | ## 避免目录 301 重定向,例如 /about 会301到 /about/
129 | try_files $uri $uri/index.html;
130 |
131 | index index.html index.htm;
132 | }
133 |
134 | ```
135 |
136 |
137 | ## 设置
138 | 用于系统设置,需要重启gpress才能生效.
139 |
140 |
141 | ## 退出
142 | 退出管理后台
143 |
144 | ## 阿里云计算巢
145 | [点击部署gpress到阿里云计算巢](https://computenest.console.aliyun.com/service/instance/create/cn-hangzhou?type=user&ServiceId=service-d4000c9b22c54e5cbffe),也可以单独购买阿里云最低配服务器,进行部署.选择```张家口机房```,规格```ecs.t6-c4m1.large```,配置```2核CPU 0.5G内存 20G高效云盘 RockyLinux9 按使用流量-带宽峰值80M```,一年100元,五年200元左右.
--------------------------------------------------------------------------------
/gpressdatadir/public/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/favicon.png
--------------------------------------------------------------------------------
/gpressdatadir/public/gongan.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/gongan.png
--------------------------------------------------------------------------------
/gpressdatadir/public/gpress-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/gpress-logo.png
--------------------------------------------------------------------------------
/gpressdatadir/public/gpress-logo1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/gpress-logo1.png
--------------------------------------------------------------------------------
/gpressdatadir/public/index.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/index.png
--------------------------------------------------------------------------------
/gpressdatadir/public/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/logo.png
--------------------------------------------------------------------------------
/gpressdatadir/public/mqtt3.1.1.html:
--------------------------------------------------------------------------------
1 |
2 |
107 |
108 |
109 |
110 |
111 |
112 | 服务器地址:
113 |
114 |
115 |
116 |
117 |
118 |
119 | 订阅消息
120 | QoS
125 |
126 |
127 |
128 | 发布消息:
129 |
130 |
131 |
132 | 订阅列表
133 |
134 |
135 |
136 |
137 | 订阅消息 |
138 | QoS |
139 | 操作 |
140 |
141 |
142 |
143 |
144 | 接收消息
145 |
146 |
147 |
148 |
149 |
150 |
--------------------------------------------------------------------------------
/gpressdatadir/public/search-config.json:
--------------------------------------------------------------------------------
1 | {
2 | "dataFile": "public/search-data.json",
3 | "indexConfig": null,
4 | "showParent": true,
5 | "showDescription": true
6 | }
--------------------------------------------------------------------------------
/gpressdatadir/public/upload/upload.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/upload/upload.txt
--------------------------------------------------------------------------------
/gpressdatadir/public/wallet/TrustWallet.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/wallet/TrustWallet.png
--------------------------------------------------------------------------------
/gpressdatadir/public/wallet/bitkeep.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/wallet/bitkeep.png
--------------------------------------------------------------------------------
/gpressdatadir/public/wallet/metamask.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/wallet/metamask.png
--------------------------------------------------------------------------------
/gpressdatadir/public/wallet/okx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/wallet/okx.png
--------------------------------------------------------------------------------
/gpressdatadir/public/wallet/tokenproket.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/wallet/tokenproket.png
--------------------------------------------------------------------------------
/gpressdatadir/public/wallet/x-pocket.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/springrain/gpress/911234f8dec21e35cd72b323647d77f02b14d671/gpressdatadir/public/wallet/x-pocket.png
--------------------------------------------------------------------------------
/gpressdatadir/statichtml/readme.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | 静态化文件目录,网站生成的静态html
10 |
11 |
--------------------------------------------------------------------------------
/gpressdatadir/template/admin/bodyend.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |