artalkjs / artalkgo Goto Github PK
View Code? Open in Web Editor NEW[Deprecated] Moved to ArtalkJS/Artalk monorepo
Home Page: https://github.com/ArtalkJS/Artalk
License: GNU Lesser General Public License v3.0
[Deprecated] Moved to ArtalkJS/Artalk monorepo
Home Page: https://github.com/ArtalkJS/Artalk
License: GNU Lesser General Public License v3.0
你好,感谢大佬的开源贡献,最近想学习一下这个项目,但是在运行时遇到了一些问题,比如配置文件中的 app_key 该如何生成,貌似没有相关文档
ERRO[0000] CREATE TABLE `sites` (`id` bigint unsigned AUTO_INCREMENT,`created_at` datetime(3) NULL,`updated_at` datetime(3) NULL,`deleted_at` datetime(3) NULL,`name` longtext,`urls` longtext,`users` longtext,PRIMARY KEY (`id`),INDEX idx_sites_deleted_at (`deleted_at`),UNIQUE INDEX idx_sites_name (`name`)) [7.659879ms] error="Error 1170: BLOB/TEXT column 'name' used in key specification without a key length"
ERRO[0000] SELECT * FROM `sites` WHERE name = '唔该博客' AND `sites`.`deleted_at` IS NULL ORDER BY `sites`.`id` LIMIT 1 [2.043661ms] error="Error 1146: Table 'artalk.sites' doesn't exist"
ERRO[0000] INSERT INTO `sites` (`created_at`,`updated_at`,`deleted_at`,`name`,`urls`,`users`) VALUES ('2021-11-30 18:29:16.34','2021-11-30 18:29:16.34',NULL,'唔该博客','','') [4.668251ms] error="Error 1146: Table 'artalk.sites' doesn't exist"
ERRO[0000] Create Site error: Error 1146: Table 'artalk.sites' doesn't exist
db:
type: "mysql" # 支持 mysql, sqlite, pgsql, sqlserver
dsn: "root:root@tcp(192.168.1.100:3306)/artalk?charset=utf8mb4&parseTime=True&loc=Local"
artalk/artalk-go:2.0.5
5.7.32
管理员地址是什么,文档没介绍后端管理地址,没找到,不知道怎么访问后端,管理评论和配置
上传成功后能否也把图片文件删掉
ArtalkGo/http/api_main_img_upload.go
Lines 156 to 171 in 3b3947c
哈喽 非常感谢作者开源
在导入valine历史评论的过程中发现一个问题:
导入评论时必须指定 目标站点 URL 如 https://xxx.com
这样会让导入的那些评论的 page_key 字段自动拼接目标站点 URL
而如果前端 实例化时pageKey
为相对路径时,就没法正确的展示评论,必须手动去数据库将历史评论的 目标站点 URL 前缀去除。
由于朋友的安利,打算从Waline转Artalk来啦~
大概看了一下文档,好像没有支持企业微信的通知,不知后面是否有支持的计划?
使用 MariaDB 10.5.12数据库,连接方式使用mysql。
启动后数据库只创建了sites表,报如下错误
ERROR CREATE TABLE pages
(id
bigint unsigned AUTO_INCREMENT,created_at
datetime(3) NULL,updated_at
datetime(3) NULL,deleted_at
datetime(3) NULL,key
varchar(191),title
longtext,admin_only
boolean,site_name
varchar(191),vote_up
bigint,vote_down
bigint,PRIMARY KEY (id
),INDEX idx_pages_deleted_at (deleted_at
),INDEX idx_pages_key (key
),INDEX idx_pages_site_name (site_name
),CONSTRAINT fk_pages_site
FOREIGN KEY (site_name
) REFERENCES sites
(name
)) [505.1µs] error=Error 1005: Can't create table artalk
.pages
(errno: 150 "Foreign key constraint is incorrectly formed")
ERROR SELECT * FROM users
WHERE (LOWER(name) = LOWER('admin') AND LOWER(email) = LOWER('[email protected]')) AND users
.deleted_at
IS NULL ORDER BY users
.id
LIMIT 1 [537.9µs] error=Error 1146: Table 'artalk.users' doesn't exist
ERROR INSERT INTO users
(created_at
,updated_at
,deleted_at
,name
,email
,link
,password
,badge_name
,badge_color
,last_ip
,last_ua
,is_admin
,is_in_conf
) VALUES ('2022-02-08 04:26:29.312','2022-02-08 04:26:29.312',NULL,'admin','[email protected]','','','管理员','#FF6C00','','',true,true) [518.5µs] error=Error 1146: Table 'artalk.users' doesn't exist
ERROR SELECT * FROM users
WHERE is_in_conf = 1 AND users
.deleted_at
IS NULL [0s] error=Error 1146: Table 'artalk.users' doesn't exist
原因: 当配置文件修改时,文件inode会改变,而容器仅存储了首次挂载的inode,导致读取不到而启动失败.
可采用入口点脚本作shell判断实现.
Line 136 in ed54720
mysql/mariadb 的随机函数是 rand()
吧。
希望 api 返回最新评论,增加返回用户头像地址。。
1.获取前 N 位最新评论数据。
2.获取前 N 位 PV 数最高的文章。
3.根据 URL 批量获取对应文章的评论数。
博客可以拿来实现热门文章、最新评论、文章评论数量显示。
我看兼容性下有句
高效缓存:支持 Redis, In-Memory
但是我没找到如何让Artalk远程连接Redis数据库
按照文档设置了飞书通知,测试发现没有作用。检查了Artalk文档和飞书机器人文档,设置应该没有问题,飞书机器人没有设置任何禁止策略。查看后台日志也没有任何输出。
由于数据迁移工具常常发生变动,将其单独拆分成一个程序,利于及时更新。
ERRO[0181] SELECT * FROM `pages` WHERE (key = 'http://127.0.0.1:8888/post/java-urlencoder' AND site_name = '唔该博客') AND `pages`.`deleted_at` IS NULL ORDER BY `pages`.`id` LIMIT 1 [704.131µs] error="Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key = ? AND site_name = ?) AND `pages`.`deleted_at` IS NULL ORDER BY `pages`.`id' at line 1"
column key in table pages and notifies is mysql reserved word
如果是多拨用户,通过负载均衡会产生多个不同 IP 随机请求的情况,判断不准确。
正在使用的Redis带有密码认证,ArtalkGo在使用redis做缓存时,如何设置?
密码认证无法关闭。
例子
Redis访问链接:redis://default:YOCnibb5ijA9eltMBI1RGb2SVBFEdN56@redis-12875.c57.us-east-1-4.ec2.cloud.redislabs.com:12875
如何配置?
# 缓存
cache:
type: "builtin" # 支持 redis, memcache, builtin (自带缓存)
expires: 30 # 缓存过期时间 (单位:分钟)
warm_up: false # 程序启动时预热缓存
server: "" # 连接缓存服务器 (例如:"localhost:6379")
我在一台新装的Windows Server 2019上部署,无论将timezone
设为何值结果均等效于UTC+0
。
在debug模式可以看到这里insert了一个19:28:58进去,但我是在第二天的3:28启动的。
实际上,在添加评论的时候,在前端显示的结果也会是8小时前。
由于我不太了解Golang,所以去查了一下原因,找到了语言下的一个issue
golang/go#38453
Line 67 in ed54720
同时根据上面issue提供的线索,我用procmon探了一下zoneinfo.zip的读取,是在运行盘符:\usr\local\go\lib\time\zoneinfo.zip
上。我拷了一份过去,目前工作正常,不过这个问题确实影响在win上的直接部署。
由于创建数据表直接使用了 Golang 的 ORM 框架 Gorm,之前开发也没有测试到有这些问题
目前 ArtalkGo 使用 MariaDB 和 MySQL 数据库需要“曲线救国”的方式....
之后有时间会修改,但修改数据表结构,版本更新老版本与新版,对老用户来说,数据迁移又是一个麻烦事 🥲🥲🥲
Originally posted by @qwqcode in #14 (comment)
由于 model 定义了很多 boolean 类型的字段,使用 gorm 进行查询 where 方法查询很多地方直接传递了字符串 xxx = 1
,在 MySQL 数据库和 SQLite 下 gorm 拼接的语句能正常工作。
参考:f420fb5
然而,由于 pgsql 字段类型丰富,自带 boolean 字段类型;而 MySQL 本身无,故 gorm 创建字段类型 tinyint
来替代。导致了 pgsql 数据库和 MySQL 查询语句的差异性。
解决办法:将所有 boolean 字段类型改成 int,消除 gorm 创建 table 在不同数据库间的类型差异性。
另外还有很多问题,MySQL 和 SQLite 外键约束功能正常,而 PgSQL 测试不正常。
适配难度较大,需要一定的时间和精力,暂时搁置。
目前仅测试兼容 MySQL 和 SQLite 两种数据库。
开启所有评论都需要审核后
moderator:
pending_default: true
存在以下问题:
希望是这样的逻辑:
看了作者的作品,小小年纪能有如此造诣实属不易,加油
另给一点不成熟的小建议
1、尽量采用依赖注入的方式进行开发,比如lib.DB
这种全局变量最好不用,虽然开发起来比较简单,但是不利于扩展,也不利于测试,推荐使用google wire,https://github.com/google/wire
2、模块之间尽可能的使用DDD**进行拆分,基于接口开发,利于mock单元测试
一点小建议,希望对你有帮助
这样就能简化更新流程,执行 artalk-go upgrade
一键升级到最新版本
突然间,无法登录了,相关日志:
Artalk (2.1.4/2ad6864)
-> A Selfhosted Comment System.
-> https://artalk.js.org
-------------------------------
⇨ http server started on [::]:23366
echo: http: panic serving 127.0.0.1:38796: interface conversion: interface {} is string, not []uint8
goroutine 52 [running]:
net/http.(*conn).serve.func1(0xc00026cd20)
/usr/local/go/src/net/http/server.go:1804 +0x153
panic(0x14d4a00, 0xc0007f6b70)
/usr/local/go/src/runtime/panic.go:971 +0x499
github.com/ArtalkJS/ArtalkGo/http.getActionLastTime(0x1927aa8, 0xc00024abe0, 0x157f5a0, 0xc0008f0cc0, 0x16a72c7)
/go/src/github.com/ArtalkJS/ArtalkGo/http/permission.go:163 +0x189
github.com/ArtalkJS/ArtalkGo/http.IsActionInTimeFrame(0x1927aa8, 0xc00024abe0, 0xc000896600)
/go/src/github.com/ArtalkJS/ArtalkGo/http/permission.go:150 +0x39
github.com/ArtalkJS/ArtalkGo/http.IsReqNeedCaptchaCheck(0x1927aa8, 0xc00024abe0, 0xd)
/go/src/github.com/ArtalkJS/ArtalkGo/http/permission.go:127 +0x105
github.com/ArtalkJS/ArtalkGo/http.ActionLimitMiddleware.func1.1(0x1927aa8, 0xc00024abe0, 0xc0000e0000, 0x0)
/go/src/github.com/ArtalkJS/ArtalkGo/http/permission.go:59 +0x1f7
github.com/onrik/logrus/echo.Middleware.func1.1(0x1927aa8, 0xc00024abe0, 0x16b7df2, 0x1b)
/go/pkg/mod/github.com/onrik/[email protected]/echo/middleware.go:62 +0x16e
github.com/labstack/echo/v4/middleware.CORSWithConfig.func1.1(0x1927aa8, 0xc00024abe0, 0x3, 0x4)
/go/pkg/mod/github.com/labstack/echo/[email protected]/middleware/cors.go:186 +0x1016
github.com/labstack/echo/v4.(*Echo).ServeHTTP(0xc000662480, 0x1904a28, 0xc00087f180, 0xc00084ec00)
/go/pkg/mod/github.com/labstack/echo/[email protected]/echo.go:654 +0x2bc
net/http.serverHandler.ServeHTTP(0xc000182e00, 0x1904a28, 0xc00087f180, 0xc00084ec00)
/usr/local/go/src/net/http/server.go:2867 +0xa3
net/http.(*conn).serve(0xc00026cd20, 0x1909fd0, 0xc000755280)
/usr/local/go/src/net/http/server.go:1932 +0x8cd
created by net/http.(*Server).Serve
/usr/local/go/src/net/http/server.go:2993 +0x39b
感谢作者提供如此优秀的开源项目🙏🙏🙏
在使用中遇到了这个问题,不太懂相关代码,希望好心人能帮忙解答下🙏
hello artalk-sidebar
index.f7f00175.js:1 hello artalk-sidebar
index.f7f00175.js:1 非法请求:Referer 不被允许
onError @ index.f7f00175.js:1
(anonymous) @ index.f7f00175.js:1
a @ index.f7f00175.js:1
index.f7f00175.js:1 Uncaught (in promise) Object
a @ index.f7f00175.js:1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.