Home

Awesome

<img src="gpressdatadir/public/gpress-logo.png" height="150px" />

介绍

Web3内容平台,Hertz + Go template + FTS5全文检索,支持以太坊和百度超级链,兼容Hugo、WordPress生态,使用Wasm扩展插件,只需200M内存

作为静态站点: gpress生成的静态文件和Hugo一致,也可以简单认为gpress是Hugo的后台管理,兼容Hugo主题生态,已迁移多款Hugo主题:evendoksbookgeekdoc......
作为动态站点: gpress功能简单,只有7个菜单,5张表,5000行代码,使用SQLite,一键启动,只需200M内存,支持全文检索.兼容WordPress主题生态,已迁移多款WordPress主题:generatepressastra......
作为Web3: gpress已支持以太坊和百度超级链账户体系,会基于Wasm持续迭代去中心功能,让数据自由一点点......
作为后浪: 相对于Hugo、WordPress等优秀的内容平台,gpress还有很多不足,功能简单而又稚嫩......
帮助文档: 点击查看帮助文档

个人博客 jiagou.com 使用gpress搭建,搜索和后台管理是动态,其他是静态页面.
<img src="gpressdatadir/public/index.png" width="600px">

开发环境

gprss使用了 https://github.com/wangfenjin/simple 作为FTS5的全文检索扩展,编译好的libsimple文件放到 gpressdatadir/fts5 目录下,如果gpress启动报错连不上数据库,请检查libsimple文件是否正确,如果需要重新编译libsimple,请参考 https://github.com/wangfenjin/simple.

默认端口660,后台管理地址 http://127.0.0.1:660/admin/login
需要先解压gpressdatadir/dict.zip
运行 go run --tags "fts5" .
打包: go build --tags "fts5" -ldflags "-w -s"

开发环境需要配置CGO编译,设置set CGO_ENABLED=1,下载mingw64cmake,并把bin配置到环境变量,注意把mingw64/bin/mingw32-make.exe 改名为 make.exe
注意修改vscode的launch.json,增加 ,"buildFlags": "--tags=fts5" 用于调试fts5
test需要手动测试:go test -timeout 30s --tags "fts5" -run ^TestReadmks$ gitee.com/gpress/gpress
打包: go build --tags "fts5" -ldflags "-w -s"
重新编译simple时,建议使用https://github.com/wangfenjin/simple编译好的.
注意修改widnows编译脚本,去掉 mingw64 编译依赖的libgcc_s_seh-1.dlllibstdc++-6.dll,同时关闭BUILD_TEST_EXAMPLE,有冲突

rmdir /q /s build
mkdir build && cd build
cmake .. -G "Unix Makefiles" -DBUILD_TEST_EXAMPLE=OFF -DCMAKE_INSTALL_PREFIX=release -DCMAKE_CXX_FLAGS="-static-libgcc -static-libstdc++" -DCMAKE_EXE_LINKER_FLAGS="-Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic"
make && make install

静态化

后台 刷新站点 功能会生成静态html文件到 statichtml 目录,同时生成gzip_static文件.需要把正在使用的主题的 css,js,imagegpressdatadir/public目录复制到 statichtml目录下,或者用Nginx反向代理指定目录,不复制文件.
nginx 配置示例如下:

### 当前在用主题(default)的css文件
location ~ ^/css/ {
    #gzip_static on;
    root /data/gpress/gpressdatadir/template/theme/default;  
}
### 当前在用主题(default)的js文件
location ~ ^/js/ {
    #gzip_static on;
    root /data/gpress/gpressdatadir/template/theme/default;  
}
### 当前在用主题(default)的image文件
location ~ ^/image/ {
    root /data/gpress/gpressdatadir/template/theme/default;  
}
### search-data.json FlexSearch搜索的JSON数据
location ~ ^/public/search-data.json {
    #gzip_static on;
    root /data/gpress/gpressdatadir;  
}
### public 公共文件
location ~ ^/public/ {
    root /data/gpress/gpressdatadir;  
}
    
### admin 后台管理,请求动态服务
location ~ ^/admin/ {
    proxy_redirect     off;
    proxy_set_header   Host      $host;
    proxy_set_header   X-Real-IP $remote_addr;
    proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
    proxy_set_header   X-Forwarded-Proto $scheme;
    proxy_pass  http://127.0.0.1:660;  
}
###  静态html目录
location / {
    proxy_redirect     off;
    proxy_set_header   Host      $host;
    proxy_set_header   X-Real-IP $remote_addr;
    proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
    proxy_set_header   X-Forwarded-Proto $scheme; 
    ## 存在q查询参数,使用动态服务.也支持FlexSearch解析public/search-data.json
    if ($arg_q) { 
       proxy_pass  http://127.0.0.1:660;  
       break;
    }

    #### gzip 静态压缩配置 开始####
    #gzip_static on;
    ## 请求的是个目录,302重定向到 目录下的 index.html
    #if ( -d $request_filename ) {
        ## 不是 / 结尾
    #    rewrite [^\/]$ $uri/index.html redirect;
        ##以 / 结尾的
    #    rewrite ^(.*) ${uri}index.html redirect;      
    #}
    #### gzip 静态压缩配置 结束####

    
    root   /data/gpress/gpressdatadir/statichtml;
    index  index.html index.htm;
}

阿里云计算巢

点击部署gpress到阿里云计算巢,也可以单独购买阿里云最低配服务器,进行部署.选择张家口机房,规格ecs.t6-c4m1.large,配置2核CPU 0.5G内存 20G高效云盘 RockyLinux9 按使用流量-带宽峰值80M,一年100元,五年200元左右.

表结构

ID默认使用时间戳(23位)+随机数(9位),全局唯一.
建表语句gpressdatadir/gpress.sql

配置(表名:config)

安装时会读取gpressdatadir/install_config.json

columnName类型说明备注
idstring主键gpress_config
basePathstring基础路径默认 /
jwtSecretstringjwt密钥随机生成
jwttokenKeystringjwt的key默认 jwttoken
serverPortstringIP:端口默认 :660
timeoutintjwt超时时间秒默认 7200
maxRequestBodySizeint最大请求默认 20M
proxystringhttp代理地址
createTimestring创建时间2006-01-02 15:04:05
updateTimestring更新时间2006-01-02 15:04:05
createUserstring创建人初始化 system
sortNoint排序正序
statusint状态链接访问(0),公开(1),置顶(2),私密(3)

用户(表名:user)

后台只有一个用户.

columnName类型说明备注
idstring主键gpress_admin
accountstring登录名称默认admin
passWordstring密码-
userNamestring说明-
createTimestring创建时间2006-01-02 15:04:05
updateTimestring更新时间2006-01-02 15:04:05
createUserstring创建人初始化 system
sortNoint排序正序
statusint状态链接访问(0),公开(1),置顶(2),私密(3)

站点信息(site)

站点的信息,例如 title,logo,keywords,description等

columnName类型说明备注
idstring主键gpress_site
titlestring站点名称-
keywordstring关键字-
descriptionstring站点描述-
themestring默认主题默认使用default
themePCstringPC主题先从cookie获取,如果没有从Header头取值,写入cookie,默认使用default
themeWAPstring手机主题先从cookie获取,如果没有从Header头取值,写入cookie,默认使用default
themeWEIXINstring微信主题先从cookie获取,如果没有从Header头取值,写入cookie,默认使用default
logostringlogo-
faviconstringFavicon-
createTimestring创建时间2006-01-02 15:04:05
updateTimestring更新时间2006-01-02 15:04:05
createUserstring创建人初始化 system
sortNoint排序正序
statusint状态链接访问(0),公开(1),置顶(2),私密(3)

导航菜单(表名:category)

columnName类型说明备注
idstring主键-
namestring导航名称-
hrefURLstring跳转路径-
hrefTargetstring跳转方式_self,_blank,_parent,_top
pidstring父导航ID父导航ID
moduleIDstringmodule表ID导航菜单下的文章默认使用的模型字段
comCodestring逗号隔开的全路径逗号隔开的全路径
templateFilestring模板文件当前导航页的模板
childTemplateFilestring子主题模板文件子页面默认使用的模板,子页面如果不设置,默认使用这个模板
keywordstring导航关键字
descriptionstring导航描述
createTimestring创建时间2006-01-02 15:04:05
updateTimestring更新时间2006-01-02 15:04:05
createUserstring创建人初始化 system
sortNoint排序正序
statusint状态链接访问(0),公开(1),置顶(2),私密(3)

文章内容(表名:content)

columnName类型说明是否分词备注
idstring主键-
moduleIDstring模型ID文章使用的模型字段
titlestring文章标题使用 jieba 分词器
keywordstring内容关键字使用 jieba 分词器
descriptionstring内容描述使用 jieba 分词器
hrefURLstring自身页面路径-
subtitlestring副标题使用 jieba 分词器
authorstring作者使用 jieba 分词器
tagstring标签使用 jieba 分词器
tocstring目录使用 jieba 分词器
summarystring摘要使用 jieba 分词器
categoryNamestring导航菜单,逗号(,)隔开使用 jieba 分词器.
categoryIDstring导航ID-
comCodestring逗号隔开的全路径逗号隔开的全路径
templateFilestring模板文件模板
contentstring文章内容
markdownstringMarkdown内容
thumbnailstring封面图
createTimestring创建时间-2006-01-02 15:04:05
updateTimestring更新时间-2006-01-02 15:04:05
createUserstring创建人-初始化 system
sortNoint排序-正序
statusint状态-链接访问(0),公开(1),置顶(2),私密(3)