mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 12:17:24 +00:00
Compare commits
40 Commits
634d5a348a
...
master
Author | SHA1 | Date | |
---|---|---|---|
bc8d59f7a9 | |||
c8eb519f7e | |||
e117a2e708 | |||
c131f48448 | |||
45beaced89 | |||
af81f66f25 | |||
ff1f6e7340 | |||
0a88a65846 | |||
316929db33 | |||
844233e70d | |||
f5c39e0315 | |||
ed5843cd54 | |||
c0d904e035 | |||
abbd7ed006 | |||
24ba97817a | |||
2848e4c5e1 | |||
d64b1e78ef | |||
5bf2544282 | |||
faa802dd72 | |||
5fe45611c9 | |||
b4a63d3935 | |||
cf5a600372 | |||
8e14a53351 | |||
1ee5d0c9b7 | |||
d1da0dc948 | |||
62d10a989d | |||
f8fa9069a9 | |||
a51d4ec598 | |||
b4e00814bf | |||
b8acd97c11 | |||
8f240823ef | |||
a33171fb20 | |||
993e7f488d | |||
ebfe25e6d8 | |||
f0079003f2 | |||
4e709dd952 | |||
a3fc1cd801 | |||
b804741e27 | |||
44b876ba0e | |||
f067e802a2 |
@@ -12,7 +12,7 @@ COPY frontend/ ./
|
|||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# 第二阶段:构建Go应用
|
# 第二阶段:构建Go应用
|
||||||
FROM golang:1.24-alpine AS backend-builder
|
FROM golang:1.25-alpine AS backend-builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
294
frontend/package-lock.json
generated
294
frontend/package-lock.json
generated
@@ -19,6 +19,7 @@
|
|||||||
"react-icons": "^5.5.0",
|
"react-icons": "^5.5.0",
|
||||||
"react-markdown": "^10.1.0",
|
"react-markdown": "^10.1.0",
|
||||||
"react-router": "^7.5.3",
|
"react-router": "^7.5.3",
|
||||||
|
"remark-gfm": "^4.0.1",
|
||||||
"spark-md5": "^3.0.2",
|
"spark-md5": "^3.0.2",
|
||||||
"tailwindcss": "^4.1.5"
|
"tailwindcss": "^4.1.5"
|
||||||
},
|
},
|
||||||
@@ -4248,6 +4249,16 @@
|
|||||||
"yallist": "^3.0.2"
|
"yallist": "^3.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/markdown-table": {
|
||||||
|
"version": "3.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-3.0.4.tgz",
|
||||||
|
"integrity": "sha512-wiYz4+JrLyb/DqW2hkFJxP7Vd7JuTDm77fvbM8VfEQdmSMqcImWeeRbHwZjBjIFki/VaMK2BhFi7oUUZeM5bqw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"funding": {
|
||||||
|
"type": "github",
|
||||||
|
"url": "https://github.com/sponsors/wooorm"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/masonic": {
|
"node_modules/masonic": {
|
||||||
"version": "4.1.0",
|
"version": "4.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/masonic/-/masonic-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/masonic/-/masonic-4.1.0.tgz",
|
||||||
@@ -4279,6 +4290,34 @@
|
|||||||
"node": ">= 0.4"
|
"node": ">= 0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/mdast-util-find-and-replace": {
|
||||||
|
"version": "3.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/mdast-util-find-and-replace/-/mdast-util-find-and-replace-3.0.2.tgz",
|
||||||
|
"integrity": "sha512-Tmd1Vg/m3Xz43afeNxDIhWRtFZgM2VLyaf4vSTYwudTyeuTneoL3qtWMA5jeLyz/O1vDJmmV4QuScFCA2tBPwg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/mdast": "^4.0.0",
|
||||||
|
"escape-string-regexp": "^5.0.0",
|
||||||
|
"unist-util-is": "^6.0.0",
|
||||||
|
"unist-util-visit-parents": "^6.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/unified"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/mdast-util-find-and-replace/node_modules/escape-string-regexp": {
|
||||||
|
"version": "5.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz",
|
||||||
|
"integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/mdast-util-from-markdown": {
|
"node_modules/mdast-util-from-markdown": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-2.0.2.tgz",
|
||||||
@@ -4303,6 +4342,107 @@
|
|||||||
"url": "https://opencollective.com/unified"
|
"url": "https://opencollective.com/unified"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/mdast-util-gfm": {
|
||||||
|
"version": "3.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mdast-util-gfm/-/mdast-util-gfm-3.1.0.tgz",
|
||||||
|
"integrity": "sha512-0ulfdQOM3ysHhCJ1p06l0b0VKlhU0wuQs3thxZQagjcjPrlFRqY215uZGHHJan9GEAXd9MbfPjFJz+qMkVR6zQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"mdast-util-from-markdown": "^2.0.0",
|
||||||
|
"mdast-util-gfm-autolink-literal": "^2.0.0",
|
||||||
|
"mdast-util-gfm-footnote": "^2.0.0",
|
||||||
|
"mdast-util-gfm-strikethrough": "^2.0.0",
|
||||||
|
"mdast-util-gfm-table": "^2.0.0",
|
||||||
|
"mdast-util-gfm-task-list-item": "^2.0.0",
|
||||||
|
"mdast-util-to-markdown": "^2.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/unified"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/mdast-util-gfm-autolink-literal": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-5HVP2MKaP6L+G6YaxPNjuL0BPrq9orG3TsrZ9YXbA3vDw/ACI4MEsnoDpn6ZNm7GnZgtAcONJyPhOP8tNJQavQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/mdast": "^4.0.0",
|
||||||
|
"ccount": "^2.0.0",
|
||||||
|
"devlop": "^1.0.0",
|
||||||
|
"mdast-util-find-and-replace": "^3.0.0",
|
||||||
|
"micromark-util-character": "^2.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/unified"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/mdast-util-gfm-footnote": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mdast-util-gfm-footnote/-/mdast-util-gfm-footnote-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-sqpDWlsHn7Ac9GNZQMeUzPQSMzR6Wv0WKRNvQRg0KqHh02fpTz69Qc1QSseNX29bhz1ROIyNyxExfawVKTm1GQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/mdast": "^4.0.0",
|
||||||
|
"devlop": "^1.1.0",
|
||||||
|
"mdast-util-from-markdown": "^2.0.0",
|
||||||
|
"mdast-util-to-markdown": "^2.0.0",
|
||||||
|
"micromark-util-normalize-identifier": "^2.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/unified"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/mdast-util-gfm-strikethrough": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mdast-util-gfm-strikethrough/-/mdast-util-gfm-strikethrough-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-mKKb915TF+OC5ptj5bJ7WFRPdYtuHv0yTRxK2tJvi+BDqbkiG7h7u/9SI89nRAYcmap2xHQL9D+QG/6wSrTtXg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/mdast": "^4.0.0",
|
||||||
|
"mdast-util-from-markdown": "^2.0.0",
|
||||||
|
"mdast-util-to-markdown": "^2.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/unified"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/mdast-util-gfm-table": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mdast-util-gfm-table/-/mdast-util-gfm-table-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-78UEvebzz/rJIxLvE7ZtDd/vIQ0RHv+3Mh5DR96p7cS7HsBhYIICDBCu8csTNWNO6tBWfqXPWekRuj2FNOGOZg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/mdast": "^4.0.0",
|
||||||
|
"devlop": "^1.0.0",
|
||||||
|
"markdown-table": "^3.0.0",
|
||||||
|
"mdast-util-from-markdown": "^2.0.0",
|
||||||
|
"mdast-util-to-markdown": "^2.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/unified"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/mdast-util-gfm-task-list-item": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/mdast-util-gfm-task-list-item/-/mdast-util-gfm-task-list-item-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-IrtvNvjxC1o06taBAVJznEnkiHxLFTzgonUdy8hzFVeDun0uTjxxrRGVaNFqkU1wJR3RBPEfsxmU6jDWPofrTQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/mdast": "^4.0.0",
|
||||||
|
"devlop": "^1.0.0",
|
||||||
|
"mdast-util-from-markdown": "^2.0.0",
|
||||||
|
"mdast-util-to-markdown": "^2.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/unified"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/mdast-util-mdx-expression": {
|
"node_modules/mdast-util-mdx-expression": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/mdast-util-mdx-expression/-/mdast-util-mdx-expression-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/mdast-util-mdx-expression/-/mdast-util-mdx-expression-2.0.1.tgz",
|
||||||
@@ -4534,6 +4674,127 @@
|
|||||||
"micromark-util-types": "^2.0.0"
|
"micromark-util-types": "^2.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/micromark-extension-gfm": {
|
||||||
|
"version": "3.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/micromark-extension-gfm/-/micromark-extension-gfm-3.0.0.tgz",
|
||||||
|
"integrity": "sha512-vsKArQsicm7t0z2GugkCKtZehqUm31oeGBV/KVSorWSy8ZlNAv7ytjFhvaryUiCUJYqs+NoE6AFhpQvBTM6Q4w==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"micromark-extension-gfm-autolink-literal": "^2.0.0",
|
||||||
|
"micromark-extension-gfm-footnote": "^2.0.0",
|
||||||
|
"micromark-extension-gfm-strikethrough": "^2.0.0",
|
||||||
|
"micromark-extension-gfm-table": "^2.0.0",
|
||||||
|
"micromark-extension-gfm-tagfilter": "^2.0.0",
|
||||||
|
"micromark-extension-gfm-task-list-item": "^2.0.0",
|
||||||
|
"micromark-util-combine-extensions": "^2.0.0",
|
||||||
|
"micromark-util-types": "^2.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/unified"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/micromark-extension-gfm-autolink-literal": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/micromark-extension-gfm-autolink-literal/-/micromark-extension-gfm-autolink-literal-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-oOg7knzhicgQ3t4QCjCWgTmfNhvQbDDnJeVu9v81r7NltNCVmhPy1fJRX27pISafdjL+SVc4d3l48Gb6pbRypw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"micromark-util-character": "^2.0.0",
|
||||||
|
"micromark-util-sanitize-uri": "^2.0.0",
|
||||||
|
"micromark-util-symbol": "^2.0.0",
|
||||||
|
"micromark-util-types": "^2.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/unified"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/micromark-extension-gfm-footnote": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/micromark-extension-gfm-footnote/-/micromark-extension-gfm-footnote-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-/yPhxI1ntnDNsiHtzLKYnE3vf9JZ6cAisqVDauhp4CEHxlb4uoOTxOCJ+9s51bIB8U1N1FJ1RXOKTIlD5B/gqw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"devlop": "^1.0.0",
|
||||||
|
"micromark-core-commonmark": "^2.0.0",
|
||||||
|
"micromark-factory-space": "^2.0.0",
|
||||||
|
"micromark-util-character": "^2.0.0",
|
||||||
|
"micromark-util-normalize-identifier": "^2.0.0",
|
||||||
|
"micromark-util-sanitize-uri": "^2.0.0",
|
||||||
|
"micromark-util-symbol": "^2.0.0",
|
||||||
|
"micromark-util-types": "^2.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/unified"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/micromark-extension-gfm-strikethrough": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/micromark-extension-gfm-strikethrough/-/micromark-extension-gfm-strikethrough-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-ADVjpOOkjz1hhkZLlBiYA9cR2Anf8F4HqZUO6e5eDcPQd0Txw5fxLzzxnEkSkfnD0wziSGiv7sYhk/ktvbf1uw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"devlop": "^1.0.0",
|
||||||
|
"micromark-util-chunked": "^2.0.0",
|
||||||
|
"micromark-util-classify-character": "^2.0.0",
|
||||||
|
"micromark-util-resolve-all": "^2.0.0",
|
||||||
|
"micromark-util-symbol": "^2.0.0",
|
||||||
|
"micromark-util-types": "^2.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/unified"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/micromark-extension-gfm-table": {
|
||||||
|
"version": "2.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/micromark-extension-gfm-table/-/micromark-extension-gfm-table-2.1.1.tgz",
|
||||||
|
"integrity": "sha512-t2OU/dXXioARrC6yWfJ4hqB7rct14e8f7m0cbI5hUmDyyIlwv5vEtooptH8INkbLzOatzKuVbQmAYcbWoyz6Dg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"devlop": "^1.0.0",
|
||||||
|
"micromark-factory-space": "^2.0.0",
|
||||||
|
"micromark-util-character": "^2.0.0",
|
||||||
|
"micromark-util-symbol": "^2.0.0",
|
||||||
|
"micromark-util-types": "^2.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/unified"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/micromark-extension-gfm-tagfilter": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/micromark-extension-gfm-tagfilter/-/micromark-extension-gfm-tagfilter-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-xHlTOmuCSotIA8TW1mDIM6X2O1SiX5P9IuDtqGonFhEK0qgRI4yeC6vMxEV2dgyr2TiD+2PQ10o+cOhdVAcwfg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"micromark-util-types": "^2.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/unified"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/micromark-extension-gfm-task-list-item": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/micromark-extension-gfm-task-list-item/-/micromark-extension-gfm-task-list-item-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-qIBZhqxqI6fjLDYFTBIa4eivDMnP+OZqsNwmQ3xNLE4Cxwc+zfQEfbs6tzAo2Hjq+bh6q5F+Z8/cksrLFYWQQw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"devlop": "^1.0.0",
|
||||||
|
"micromark-factory-space": "^2.0.0",
|
||||||
|
"micromark-util-character": "^2.0.0",
|
||||||
|
"micromark-util-symbol": "^2.0.0",
|
||||||
|
"micromark-util-types": "^2.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/unified"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/micromark-factory-destination": {
|
"node_modules/micromark-factory-destination": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/micromark-factory-destination/-/micromark-factory-destination-2.0.1.tgz",
|
||||||
@@ -5524,6 +5785,24 @@
|
|||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/remark-gfm": {
|
||||||
|
"version": "4.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/remark-gfm/-/remark-gfm-4.0.1.tgz",
|
||||||
|
"integrity": "sha512-1quofZ2RQ9EWdeN34S79+KExV1764+wCUGop5CPL1WGdD0ocPpu91lzPGbwWMECpEpd42kJGQwzRfyov9j4yNg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/mdast": "^4.0.0",
|
||||||
|
"mdast-util-gfm": "^3.0.0",
|
||||||
|
"micromark-extension-gfm": "^3.0.0",
|
||||||
|
"remark-parse": "^11.0.0",
|
||||||
|
"remark-stringify": "^11.0.0",
|
||||||
|
"unified": "^11.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/unified"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/remark-parse": {
|
"node_modules/remark-parse": {
|
||||||
"version": "11.0.0",
|
"version": "11.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-11.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-11.0.0.tgz",
|
||||||
@@ -5557,6 +5836,21 @@
|
|||||||
"url": "https://opencollective.com/unified"
|
"url": "https://opencollective.com/unified"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/remark-stringify": {
|
||||||
|
"version": "11.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/remark-stringify/-/remark-stringify-11.0.0.tgz",
|
||||||
|
"integrity": "sha512-1OSmLd3awB/t8qdoEOMazZkNsfVTeY4fTsgzcQFdXNq8ToTN4ZGwrMnlda4K6smTFKD+GRV6O48i6Z4iKgPPpw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/mdast": "^4.0.0",
|
||||||
|
"mdast-util-to-markdown": "^2.0.0",
|
||||||
|
"unified": "^11.0.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/unified"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/resolve-from": {
|
"node_modules/resolve-from": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
"react-icons": "^5.5.0",
|
"react-icons": "^5.5.0",
|
||||||
"react-markdown": "^10.1.0",
|
"react-markdown": "^10.1.0",
|
||||||
"react-router": "^7.5.3",
|
"react-router": "^7.5.3",
|
||||||
|
"remark-gfm": "^4.0.1",
|
||||||
"spark-md5": "^3.0.2",
|
"spark-md5": "^3.0.2",
|
||||||
"tailwindcss": "^4.1.5"
|
"tailwindcss": "^4.1.5"
|
||||||
},
|
},
|
||||||
|
@@ -4,14 +4,16 @@ export default function Badge({
|
|||||||
children,
|
children,
|
||||||
className,
|
className,
|
||||||
onClick,
|
onClick,
|
||||||
|
selectable = false,
|
||||||
}: {
|
}: {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
className?: string;
|
className?: string;
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
|
selectable?: boolean;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
className={`badge ${!className?.includes("badge-") && "badge-primary"} select-none ${className}`}
|
className={`badge ${!className?.includes("badge-") && "badge-primary"} ${className} ${!selectable && "select-none"}`}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { createRoot } from "react-dom/client";
|
import { createRoot } from "react-dom/client";
|
||||||
|
import { i18nContext } from "../utils/i18n";
|
||||||
|
import { i18nData } from "../i18n.ts";
|
||||||
|
|
||||||
export default function showPopup(
|
export default function showPopup(
|
||||||
content: React.ReactNode,
|
content: React.ReactNode,
|
||||||
@@ -9,10 +11,18 @@ export default function showPopup(
|
|||||||
|
|
||||||
const div = document.createElement("div");
|
const div = document.createElement("div");
|
||||||
div.style.position = "fixed";
|
div.style.position = "fixed";
|
||||||
if (eRect.x > window.innerWidth / 2) {
|
if (window.innerWidth > 400) {
|
||||||
div.style.right = `${window.innerWidth - eRect.x}px`;
|
if (eRect.x > window.innerWidth / 2) {
|
||||||
|
div.style.right = `${window.innerWidth - eRect.x}px`;
|
||||||
|
} else {
|
||||||
|
div.style.left = `${eRect.x}px`;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
div.style.left = `${eRect.x}px`;
|
if (eRect.x > window.innerWidth / 2) {
|
||||||
|
div.style.right = `8px`;
|
||||||
|
} else {
|
||||||
|
div.style.left = `8px`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (eRect.y > window.innerHeight / 2) {
|
if (eRect.y > window.innerHeight / 2) {
|
||||||
div.style.bottom = `${window.innerHeight - eRect.y}px`;
|
div.style.bottom = `${window.innerHeight - eRect.y}px`;
|
||||||
@@ -43,7 +53,9 @@ export default function showPopup(
|
|||||||
document.body.appendChild(mask);
|
document.body.appendChild(mask);
|
||||||
|
|
||||||
createRoot(div).render(
|
createRoot(div).render(
|
||||||
<context.Provider value={close}>{content}</context.Provider>,
|
<context.Provider value={close}>
|
||||||
|
<i18nContext.Provider value={i18nData}>{content}</i18nContext.Provider>
|
||||||
|
</context.Provider>,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -203,7 +203,11 @@ export function QuickAddTagDialog({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setError(null);
|
setError(null);
|
||||||
const names = text.split(separator).filter((n) => n.length > 0);
|
let sep: string | RegExp = separator;
|
||||||
|
if (sep === " ") {
|
||||||
|
sep = /\s+/;
|
||||||
|
}
|
||||||
|
const names = text.split(sep).filter((n) => n.length > 0);
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const res = await network.getOrCreateTags(names, type);
|
const res = await network.getOrCreateTags(names, type);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
@@ -1,6 +1,10 @@
|
|||||||
@import "tailwindcss";
|
@import "tailwindcss";
|
||||||
@plugin "daisyui";
|
@plugin "daisyui";
|
||||||
|
|
||||||
|
@theme {
|
||||||
|
--breakpoint-xs: 30rem;
|
||||||
|
}
|
||||||
|
|
||||||
/* Pink Theme */
|
/* Pink Theme */
|
||||||
@plugin "daisyui/theme" {
|
@plugin "daisyui/theme" {
|
||||||
name: "pink";
|
name: "pink";
|
||||||
|
@@ -104,6 +104,7 @@ export interface RFile {
|
|||||||
is_redirect: boolean;
|
is_redirect: boolean;
|
||||||
user: User;
|
user: User;
|
||||||
resource?: Resource;
|
resource?: Resource;
|
||||||
|
hash?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UploadingFile {
|
export interface UploadingFile {
|
||||||
|
@@ -75,7 +75,9 @@ function PinnedResources() {
|
|||||||
}
|
}
|
||||||
const prefetchData = app.getPreFetchData();
|
const prefetchData = app.getPreFetchData();
|
||||||
if (prefetchData && prefetchData.background) {
|
if (prefetchData && prefetchData.background) {
|
||||||
navigator.setBackground(network.getResampledImageUrl(prefetchData.background));
|
navigator.setBackground(
|
||||||
|
network.getResampledImageUrl(prefetchData.background),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (prefetchData && prefetchData.pinned) {
|
if (prefetchData && prefetchData.pinned) {
|
||||||
cachedPinnedResources = prefetchData.pinned;
|
cachedPinnedResources = prefetchData.pinned;
|
||||||
@@ -97,7 +99,7 @@ function PinnedResources() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 p-4">
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-4 p-4">
|
||||||
{pinnedResources.map((resource) => (
|
{pinnedResources.map((resource) => (
|
||||||
<PinnedResourceItem key={resource.id} resource={resource} />
|
<PinnedResourceItem key={resource.id} resource={resource} />
|
||||||
))}
|
))}
|
||||||
@@ -111,7 +113,7 @@ function PinnedResourceItem({ resource }: { resource: Resource }) {
|
|||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
href={`/resources/${resource.id}`}
|
href={`/resources/${resource.id}`}
|
||||||
className={"p-2 cursor-pointer block"}
|
className={"cursor-pointer block"}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
navigate(`/resources/${resource.id}`);
|
navigate(`/resources/${resource.id}`);
|
||||||
@@ -119,7 +121,7 @@ function PinnedResourceItem({ resource }: { resource: Resource }) {
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className={
|
className={
|
||||||
"card shadow hover:shadow-md transition-shadow bg-base-100-tr82"
|
"shadow hover:shadow-md transition-shadow rounded-2xl overflow-clip relative"
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{resource.image != null && (
|
{resource.image != null && (
|
||||||
@@ -127,12 +129,12 @@ function PinnedResourceItem({ resource }: { resource: Resource }) {
|
|||||||
<img
|
<img
|
||||||
src={network.getResampledImageUrl(resource.image.id)}
|
src={network.getResampledImageUrl(resource.image.id)}
|
||||||
alt="cover"
|
alt="cover"
|
||||||
className="w-full aspect-[5/2] object-cover"
|
className="w-full aspect-[7/3] object-cover"
|
||||||
/>
|
/>
|
||||||
</figure>
|
</figure>
|
||||||
)}
|
)}
|
||||||
<div className="p-4">
|
<div className="p-4 absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent">
|
||||||
<h2 className="card-title break-all">{resource.title}</h2>
|
<h2 className="break-all card-title text-white">{resource.title}</h2>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
@@ -181,7 +181,7 @@ export default function StorageView() {
|
|||||||
handleSetDefault(s.id);
|
handleSetDefault(s.id);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<a>t("Set as Default")</a>
|
<a>{t("Set as Default")}</a>
|
||||||
</PopupMenuItem>
|
</PopupMenuItem>
|
||||||
)}
|
)}
|
||||||
</ul>,
|
</ul>,
|
||||||
|
@@ -37,6 +37,7 @@ import {
|
|||||||
MdOutlineFolderSpecial,
|
MdOutlineFolderSpecial,
|
||||||
MdOutlineLink,
|
MdOutlineLink,
|
||||||
MdOutlineOpenInNew,
|
MdOutlineOpenInNew,
|
||||||
|
MdOutlineVerifiedUser,
|
||||||
} from "react-icons/md";
|
} from "react-icons/md";
|
||||||
import { app } from "../app.ts";
|
import { app } from "../app.ts";
|
||||||
import { uploadingManager } from "../network/uploading.ts";
|
import { uploadingManager } from "../network/uploading.ts";
|
||||||
@@ -61,6 +62,7 @@ import KunApi, {
|
|||||||
kunResourceTypeToString,
|
kunResourceTypeToString,
|
||||||
} from "../network/kun.ts";
|
} from "../network/kun.ts";
|
||||||
import { Debounce } from "../utils/debounce.ts";
|
import { Debounce } from "../utils/debounce.ts";
|
||||||
|
import remarkGfm from "remark-gfm";
|
||||||
|
|
||||||
export default function ResourcePage() {
|
export default function ResourcePage() {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
@@ -238,7 +240,7 @@ export default function ResourcePage() {
|
|||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
<CollectionDialog rid={resource.id} />
|
<CollectionDialog rid={resource.id} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -447,6 +449,7 @@ function Article({ resource }: { resource: ResourceDetails }) {
|
|||||||
return (
|
return (
|
||||||
<article>
|
<article>
|
||||||
<Markdown
|
<Markdown
|
||||||
|
remarkPlugins={[remarkGfm]}
|
||||||
components={{
|
components={{
|
||||||
p: ({ node, ...props }) => {
|
p: ({ node, ...props }) => {
|
||||||
if (
|
if (
|
||||||
@@ -685,6 +688,7 @@ function fileSizeToString(size: number) {
|
|||||||
|
|
||||||
function FileTile({ file }: { file: RFile }) {
|
function FileTile({ file }: { file: RFile }) {
|
||||||
const buttonRef = createRef<HTMLButtonElement>();
|
const buttonRef = createRef<HTMLButtonElement>();
|
||||||
|
const buttonRef2 = createRef<HTMLButtonElement>();
|
||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
@@ -693,8 +697,8 @@ function FileTile({ file }: { file: RFile }) {
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={"card shadow bg-base-100 mb-4"}>
|
<div className={"card shadow bg-base-100 mb-4 p-4"}>
|
||||||
<div className={"p-4 flex flex-row items-center"}>
|
<div className={"flex flex-row items-center"}>
|
||||||
<div className={"grow"}>
|
<div className={"grow"}>
|
||||||
<h4 className={"font-bold break-all"}>{file.filename}</h4>
|
<h4 className={"font-bold break-all"}>{file.filename}</h4>
|
||||||
<div className={"text-sm my-1 comment_tile"}>
|
<div className={"text-sm my-1 comment_tile"}>
|
||||||
@@ -725,11 +729,22 @@ function FileTile({ file }: { file: RFile }) {
|
|||||||
<MdOutlineArchive size={16} className={"inline-block"} />
|
<MdOutlineArchive size={16} className={"inline-block"} />
|
||||||
{file.is_redirect ? t("Redirect") : fileSizeToString(file.size)}
|
{file.is_redirect ? t("Redirect") : fileSizeToString(file.size)}
|
||||||
</Badge>
|
</Badge>
|
||||||
|
{file.hash && (
|
||||||
|
<Badge
|
||||||
|
className={
|
||||||
|
"badge-soft badge-accent text-xs mr-2 break-all hidden sm:inline-flex"
|
||||||
|
}
|
||||||
|
selectable={true}
|
||||||
|
>
|
||||||
|
<MdOutlineVerifiedUser size={16} className={"inline-block"} />
|
||||||
|
Md5: {file.hash}
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
<DeleteFileDialog fileId={file.id} uploaderId={file.user.id} />
|
<DeleteFileDialog fileId={file.id} uploaderId={file.user.id} />
|
||||||
<UpdateFileInfoDialog file={file} />
|
<UpdateFileInfoDialog file={file} />
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className={"flex flex-row items-center"}>
|
<div className={`flex-row items-center hidden xs:flex`}>
|
||||||
{file.size > 10 * 1024 * 1024 ? (
|
{file.size > 10 * 1024 * 1024 ? (
|
||||||
<button
|
<button
|
||||||
ref={buttonRef}
|
ref={buttonRef}
|
||||||
@@ -759,6 +774,32 @@ function FileTile({ file }: { file: RFile }) {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex flex-row-reverse xs:hidden p-2">
|
||||||
|
{file.size > 10 * 1024 * 1024 ? (
|
||||||
|
<button
|
||||||
|
ref={buttonRef2}
|
||||||
|
className={"btn btn-primary btn-soft btn-sm"}
|
||||||
|
onClick={() => {
|
||||||
|
if (!app.cloudflareTurnstileSiteKey) {
|
||||||
|
const link = network.getFileDownloadLink(file.id, "");
|
||||||
|
window.open(link, "_blank");
|
||||||
|
} else {
|
||||||
|
showPopup(<CloudflarePopup file={file} />, buttonRef2.current!);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<MdOutlineDownload size={20} />
|
||||||
|
</button>
|
||||||
|
) : (
|
||||||
|
<a
|
||||||
|
href={network.getFileDownloadLink(file.id, "")}
|
||||||
|
target="_blank"
|
||||||
|
className={"btn btn-primary btn-soft btn-sm"}
|
||||||
|
>
|
||||||
|
<MdOutlineDownload size={24} />
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -62,7 +62,7 @@ export default function TagsPage() {
|
|||||||
{tags.map((tag) => (
|
{tags.map((tag) => (
|
||||||
<Badge
|
<Badge
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
navigate(`/tag/${tag.name}`);
|
navigate(`/tag/${encodeURIComponent(tag.name)}`);
|
||||||
}}
|
}}
|
||||||
key={tag.name}
|
key={tag.name}
|
||||||
className={
|
className={
|
||||||
|
66
go.mod
66
go.mod
@@ -1,23 +1,47 @@
|
|||||||
module nysoure
|
module nysoure
|
||||||
|
|
||||||
go 1.24
|
go 1.25.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gofiber/fiber/v3 v3.0.0-beta.4
|
github.com/gofiber/fiber/v3 v3.0.0-rc.1
|
||||||
github.com/golang-jwt/jwt/v5 v5.2.2
|
github.com/golang-jwt/jwt/v5 v5.3.0
|
||||||
golang.org/x/crypto v0.37.0
|
golang.org/x/crypto v0.42.0
|
||||||
gorm.io/driver/sqlite v1.5.7
|
gorm.io/driver/sqlite v1.6.0
|
||||||
gorm.io/gorm v1.26.1
|
gorm.io/gorm v1.31.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/blevesearch/bleve v1.0.14
|
||||||
github.com/chai2010/webp v1.4.0
|
github.com/chai2010/webp v1.4.0
|
||||||
gorm.io/driver/mysql v1.5.7
|
github.com/disintegration/imaging v1.6.2
|
||||||
|
github.com/stretchr/testify v1.11.1
|
||||||
|
gorm.io/driver/mysql v1.6.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/disintegration/imaging v1.6.2 // indirect
|
filippo.io/edwards25519 v1.1.0 // indirect
|
||||||
github.com/go-sql-driver/mysql v1.7.0 // indirect
|
github.com/RoaringBitmap/roaring v0.4.23 // indirect
|
||||||
|
github.com/blevesearch/go-porterstemmer v1.0.3 // indirect
|
||||||
|
github.com/blevesearch/mmap-go v1.0.2 // indirect
|
||||||
|
github.com/blevesearch/segment v0.9.0 // indirect
|
||||||
|
github.com/blevesearch/snowballstem v0.9.0 // indirect
|
||||||
|
github.com/blevesearch/zap/v11 v11.0.14 // indirect
|
||||||
|
github.com/blevesearch/zap/v12 v12.0.14 // indirect
|
||||||
|
github.com/blevesearch/zap/v13 v13.0.6 // indirect
|
||||||
|
github.com/blevesearch/zap/v14 v14.0.5 // indirect
|
||||||
|
github.com/blevesearch/zap/v15 v15.0.3 // indirect
|
||||||
|
github.com/couchbase/vellum v1.0.2 // indirect
|
||||||
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
|
github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2 // indirect
|
||||||
|
github.com/go-sql-driver/mysql v1.8.1 // indirect
|
||||||
|
github.com/golang/protobuf v1.3.2 // indirect
|
||||||
|
github.com/golang/snappy v0.0.1 // indirect
|
||||||
|
github.com/mschoch/smat v0.2.0 // indirect
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
|
github.com/steveyen/gtreap v0.1.0 // indirect
|
||||||
|
github.com/willf/bitset v1.1.10 // indirect
|
||||||
|
go.etcd.io/bbolt v1.3.5 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
@@ -32,11 +56,10 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/andybalholm/brotli v1.1.1 // indirect
|
github.com/andybalholm/brotli v1.2.0 // indirect
|
||||||
github.com/fxamacker/cbor/v2 v2.8.0 // indirect
|
github.com/gofiber/schema v1.6.0 // indirect
|
||||||
github.com/gofiber/schema v1.3.0 // indirect
|
github.com/gofiber/utils/v2 v2.0.0-rc.1 // indirect
|
||||||
github.com/gofiber/utils/v2 v2.0.0-beta.8 // indirect
|
github.com/gomarkdown/markdown v0.0.0-20250810172220-2e2c11897d1a
|
||||||
github.com/gomarkdown/markdown v0.0.0-20250311123330-531bef5e742b
|
|
||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||||
github.com/jinzhu/now v1.1.5 // indirect
|
github.com/jinzhu/now v1.1.5 // indirect
|
||||||
@@ -45,13 +68,12 @@ require (
|
|||||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
github.com/mattn/go-sqlite3 v1.14.28 // indirect
|
github.com/mattn/go-sqlite3 v1.14.28 // indirect
|
||||||
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c // indirect
|
github.com/philhofer/fwd v1.2.0 // indirect
|
||||||
github.com/tinylib/msgp v1.2.5 // indirect
|
github.com/tinylib/msgp v1.3.0 // indirect
|
||||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||||
github.com/valyala/fasthttp v1.61.0 // indirect
|
github.com/valyala/fasthttp v1.65.0 // indirect
|
||||||
github.com/x448/float16 v0.8.4 // indirect
|
golang.org/x/image v0.31.0
|
||||||
golang.org/x/image v0.28.0
|
golang.org/x/net v0.43.0 // indirect
|
||||||
golang.org/x/net v0.39.0 // indirect
|
golang.org/x/sys v0.36.0 // indirect
|
||||||
golang.org/x/sys v0.32.0 // indirect
|
golang.org/x/text v0.29.0 // indirect
|
||||||
golang.org/x/text v0.26.0 // indirect
|
|
||||||
)
|
)
|
||||||
|
204
go.sum
204
go.sum
@@ -1,39 +1,102 @@
|
|||||||
github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA=
|
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||||
github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA=
|
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||||
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
|
github.com/RoaringBitmap/roaring v0.4.23 h1:gpyfd12QohbqhFO4NVDUdoPOCXsyahYRQhINmlHxKeo=
|
||||||
|
github.com/RoaringBitmap/roaring v0.4.23/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06Mq5mKs52e1TwOo=
|
||||||
|
github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ=
|
||||||
|
github.com/andybalholm/brotli v1.2.0/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY=
|
||||||
|
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||||
|
github.com/blevesearch/bleve v1.0.14 h1:Q8r+fHTt35jtGXJUM0ULwM3Tzg+MRfyai4ZkWDy2xO4=
|
||||||
|
github.com/blevesearch/bleve v1.0.14/go.mod h1:e/LJTr+E7EaoVdkQZTfoz7dt4KoDNvDbLb8MSKuNTLQ=
|
||||||
|
github.com/blevesearch/blevex v1.0.0 h1:pnilj2Qi3YSEGdWgLj1Pn9Io7ukfXPoQcpAI1Bv8n/o=
|
||||||
|
github.com/blevesearch/blevex v1.0.0/go.mod h1:2rNVqoG2BZI8t1/P1awgTKnGlx5MP9ZbtEciQaNhswc=
|
||||||
|
github.com/blevesearch/cld2 v0.0.0-20200327141045-8b5f551d37f5/go.mod h1:PN0QNTLs9+j1bKy3d/GB/59wsNBFC4sWLWG3k69lWbc=
|
||||||
|
github.com/blevesearch/go-porterstemmer v1.0.3 h1:GtmsqID0aZdCSNiY8SkuPJ12pD4jI+DdXTAn4YRcHCo=
|
||||||
|
github.com/blevesearch/go-porterstemmer v1.0.3/go.mod h1:angGc5Ht+k2xhJdZi511LtmxuEf0OVpvUUNrwmM1P7M=
|
||||||
|
github.com/blevesearch/mmap-go v1.0.2 h1:JtMHb+FgQCTTYIhtMvimw15dJwu1Y5lrZDMOFXVWPk0=
|
||||||
|
github.com/blevesearch/mmap-go v1.0.2/go.mod h1:ol2qBqYaOUsGdm7aRMRrYGgPvnwLe6Y+7LMvAB5IbSA=
|
||||||
|
github.com/blevesearch/segment v0.9.0 h1:5lG7yBCx98or7gK2cHMKPukPZ/31Kag7nONpoBt22Ac=
|
||||||
|
github.com/blevesearch/segment v0.9.0/go.mod h1:9PfHYUdQCgHktBgvtUOF4x+pc4/l8rdH0u5spnW85UQ=
|
||||||
|
github.com/blevesearch/snowballstem v0.9.0 h1:lMQ189YspGP6sXvZQ4WZ+MLawfV8wOmPoD/iWeNXm8s=
|
||||||
|
github.com/blevesearch/snowballstem v0.9.0/go.mod h1:PivSj3JMc8WuaFkTSRDW2SlrulNWPl4ABg1tC/hlgLs=
|
||||||
|
github.com/blevesearch/zap/v11 v11.0.14 h1:IrDAvtlzDylh6H2QCmS0OGcN9Hpf6mISJlfKjcwJs7k=
|
||||||
|
github.com/blevesearch/zap/v11 v11.0.14/go.mod h1:MUEZh6VHGXv1PKx3WnCbdP404LGG2IZVa/L66pyFwnY=
|
||||||
|
github.com/blevesearch/zap/v12 v12.0.14 h1:2o9iRtl1xaRjsJ1xcqTyLX414qPAwykHNV7wNVmbp3w=
|
||||||
|
github.com/blevesearch/zap/v12 v12.0.14/go.mod h1:rOnuZOiMKPQj18AEKEHJxuI14236tTQ1ZJz4PAnWlUg=
|
||||||
|
github.com/blevesearch/zap/v13 v13.0.6 h1:r+VNSVImi9cBhTNNR+Kfl5uiGy8kIbb0JMz/h8r6+O4=
|
||||||
|
github.com/blevesearch/zap/v13 v13.0.6/go.mod h1:L89gsjdRKGyGrRN6nCpIScCvvkyxvmeDCwZRcjjPCrw=
|
||||||
|
github.com/blevesearch/zap/v14 v14.0.5 h1:NdcT+81Nvmp2zL+NhwSvGSLh7xNgGL8QRVZ67njR0NU=
|
||||||
|
github.com/blevesearch/zap/v14 v14.0.5/go.mod h1:bWe8S7tRrSBTIaZ6cLRbgNH4TUDaC9LZSpRGs85AsGY=
|
||||||
|
github.com/blevesearch/zap/v15 v15.0.3 h1:Ylj8Oe+mo0P25tr9iLPp33lN6d4qcztGjaIsP51UxaY=
|
||||||
|
github.com/blevesearch/zap/v15 v15.0.3/go.mod h1:iuwQrImsh1WjWJ0Ue2kBqY83a0rFtJTqfa9fp1rbVVU=
|
||||||
github.com/chai2010/webp v1.4.0 h1:6DA2pkkRUPnbOHvvsmGI3He1hBKf/bkRlniAiSGuEko=
|
github.com/chai2010/webp v1.4.0 h1:6DA2pkkRUPnbOHvvsmGI3He1hBKf/bkRlniAiSGuEko=
|
||||||
github.com/chai2010/webp v1.4.0/go.mod h1:0XVwvZWdjjdxpUEIf7b9g9VkHFnInUSYujwqTLEuldU=
|
github.com/chai2010/webp v1.4.0/go.mod h1:0XVwvZWdjjdxpUEIf7b9g9VkHFnInUSYujwqTLEuldU=
|
||||||
|
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||||
|
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||||
|
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||||
|
github.com/couchbase/ghistogram v0.1.0/go.mod h1:s1Jhy76zqfEecpNWJfWUiKZookAFaiGOEoyzgHt9i7k=
|
||||||
|
github.com/couchbase/moss v0.1.0/go.mod h1:9MaHIaRuy9pvLPUJxB8sh8OrLfyDczECVL37grCIubs=
|
||||||
|
github.com/couchbase/vellum v1.0.2 h1:BrbP0NKiyDdndMPec8Jjhy0U47CZ0Lgx3xUC2r9rZqw=
|
||||||
|
github.com/couchbase/vellum v1.0.2/go.mod h1:FcwrEivFpNi24R3jLOs3n+fs5RnuQnQqCLBJ1uAg1W4=
|
||||||
|
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
|
||||||
|
github.com/cznic/b v0.0.0-20181122101859-a26611c4d92d h1:SwD98825d6bdB+pEuTxWOXiSjBrHdOl/UVp75eI7JT8=
|
||||||
|
github.com/cznic/b v0.0.0-20181122101859-a26611c4d92d/go.mod h1:URriBxXwVq5ijiJ12C7iIZqlA69nTlI+LgI6/pwftG8=
|
||||||
|
github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548/go.mod h1:e6NPNENfs9mPDVNRekM7lKScauxd5kXTr1Mfyig6TDM=
|
||||||
|
github.com/cznic/strutil v0.0.0-20181122101858-275e90344537/go.mod h1:AHHPPPXTw0h6pVabbcbyGRK1DckRn7r/STdZEeIDzZc=
|
||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
|
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
|
||||||
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
|
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
|
||||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||||
github.com/fxamacker/cbor/v2 v2.8.0 h1:fFtUGXUzXPHTIUdne5+zzMPTfffl3RD5qYnkY40vtxU=
|
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64=
|
||||||
github.com/fxamacker/cbor/v2 v2.8.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
|
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg=
|
||||||
|
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0=
|
||||||
|
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||||
|
github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM=
|
||||||
|
github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
|
||||||
|
github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2 h1:Ujru1hufTHVb++eG6OuNDKMxZnGIvF6o/u8q/8h2+I4=
|
||||||
|
github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE=
|
||||||
|
github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31 h1:gclg6gY70GLy3PbkQ1AERPfmLMMagS60DKF78eWwLn8=
|
||||||
|
github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24=
|
||||||
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
|
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
|
||||||
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
|
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
|
||||||
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
|
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
|
||||||
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
|
||||||
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||||
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||||
github.com/gofiber/fiber/v3 v3.0.0-beta.4 h1:KzDSavvhG7m81NIsmnu5l3ZDbVS4feCidl4xlIfu6V0=
|
github.com/gofiber/fiber/v3 v3.0.0-rc.1 h1:034MxesK6bqGkidP+QR+Ysc1ukOacBWOHCarCKC1xfg=
|
||||||
github.com/gofiber/fiber/v3 v3.0.0-beta.4/go.mod h1:/WFUoHRkZEsGHyy2+fYcdqi109IVOFbVwxv1n1RU+kk=
|
github.com/gofiber/fiber/v3 v3.0.0-rc.1/go.mod h1:hFdT00oT0XVuQH1/z2i5n1pl/msExHDUie1SsLOkCuM=
|
||||||
github.com/gofiber/schema v1.3.0 h1:K3F3wYzAY+aivfCCEHPufCthu5/13r/lzp1nuk6mr3Q=
|
github.com/gofiber/schema v1.6.0 h1:rAgVDFwhndtC+hgV7Vu5ItQCn7eC2mBA4Eu1/ZTiEYY=
|
||||||
github.com/gofiber/schema v1.3.0/go.mod h1:YYwj01w3hVfaNjhtJzaqetymL56VW642YS3qZPhuE6c=
|
github.com/gofiber/schema v1.6.0/go.mod h1:WNZWpQx8LlPSK7ZaX0OqOh+nQo/eW2OevsXs1VZfs/s=
|
||||||
github.com/gofiber/utils/v2 v2.0.0-beta.8 h1:ZifwbHZqZO3YJsx1ZhDsWnPjaQ7C0YD20LHt+DQeXOU=
|
github.com/gofiber/utils/v2 v2.0.0-rc.1 h1:b77K5Rk9+Pjdxz4HlwEBnS7u5nikhx7armQB8xPds4s=
|
||||||
github.com/gofiber/utils/v2 v2.0.0-beta.8/go.mod h1:1lCBo9vEF4RFEtTgWntipnaScJZQiM8rrsYycLZ4n9c=
|
github.com/gofiber/utils/v2 v2.0.0-rc.1/go.mod h1:Y1g08g7gvST49bbjHJ1AVqcsmg93912R/tbKWhn6V3E=
|
||||||
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
|
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
|
||||||
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
|
||||||
github.com/gomarkdown/markdown v0.0.0-20250311123330-531bef5e742b h1:EY/KpStFl60qA17CptGXhwfZ+k1sFNJIUNR8DdbcuUk=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/gomarkdown/markdown v0.0.0-20250311123330-531bef5e742b/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
|
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
|
||||||
|
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||||
|
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
|
||||||
|
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||||
|
github.com/gomarkdown/markdown v0.0.0-20250810172220-2e2c11897d1a h1:l7A0loSszR5zHd/qK53ZIHMO8b3bBSmENnQ6eKnUT0A=
|
||||||
|
github.com/gomarkdown/markdown v0.0.0-20250810172220-2e2c11897d1a/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
|
||||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
|
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||||
|
github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99 h1:twflg0XRTjwKpxb/jFExr4HGq6on2dEOmnL6FV+fgPw=
|
||||||
|
github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||||
|
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||||
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
|
github.com/ikawaha/kagome.ipadic v1.1.2/go.mod h1:DPSBbU0czaJhAb/5uKQZHMc9MTVRpDugJfX+HddPHHg=
|
||||||
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||||
|
github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U=
|
||||||
|
github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ=
|
||||||
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||||
github.com/k3a/html2text v1.2.1 h1:nvnKgBvBR/myqrwfLuiqecUtaK1lB9hGziIJKatNFVY=
|
github.com/k3a/html2text v1.2.1 h1:nvnKgBvBR/myqrwfLuiqecUtaK1lB9hGziIJKatNFVY=
|
||||||
@@ -43,6 +106,8 @@ github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYW
|
|||||||
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||||
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
|
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
|
||||||
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||||
|
github.com/kljensen/snowball v0.6.0/go.mod h1:27N7E8fVU5H68RlUmnWwZCfxgt4POBJfENGMvNRhldw=
|
||||||
|
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||||
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
@@ -55,55 +120,102 @@ github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
|||||||
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
|
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
|
||||||
github.com/minio/minio-go/v7 v7.0.91 h1:tWLZnEfo3OZl5PoXQwcwTAPNNrjyWwOh6cbZitW5JQc=
|
github.com/minio/minio-go/v7 v7.0.91 h1:tWLZnEfo3OZl5PoXQwcwTAPNNrjyWwOh6cbZitW5JQc=
|
||||||
github.com/minio/minio-go/v7 v7.0.91/go.mod h1:uvMUcGrpgeSAAI6+sD3818508nUyMULw94j2Nxku/Go=
|
github.com/minio/minio-go/v7 v7.0.91/go.mod h1:uvMUcGrpgeSAAI6+sD3818508nUyMULw94j2Nxku/Go=
|
||||||
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c h1:dAMKvw0MlJT1GshSTtih8C2gDs04w8dReiOGXrGLNoY=
|
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||||
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=
|
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||||
|
github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg=
|
||||||
|
github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM=
|
||||||
|
github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw=
|
||||||
|
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
|
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||||
|
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||||
|
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||||
|
github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
|
||||||
|
github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM=
|
||||||
|
github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||||
|
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||||
github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
|
github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
|
||||||
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
|
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
|
||||||
|
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||||
|
github.com/shamaton/msgpack/v2 v2.3.0 h1:eawIa7lQmwRv0V6rdmL/5Ev9KdJHk07eQH3ceJi3BUw=
|
||||||
|
github.com/shamaton/msgpack/v2 v2.3.0/go.mod h1:6khjYnkx73f7VQU7wjcFS9DFjs+59naVWJv1TB7qdOI=
|
||||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
|
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
|
||||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||||
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
|
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
|
||||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||||
github.com/tinylib/msgp v1.2.5 h1:WeQg1whrXRFiZusidTQqzETkRpGjFjcIhW6uqWH09po=
|
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
|
||||||
github.com/tinylib/msgp v1.2.5/go.mod h1:ykjzy2wzgrlvpDCRc4LA8UXy6D8bzMSuAF3WD57Gok0=
|
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||||
|
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||||
|
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||||
|
github.com/steveyen/gtreap v0.1.0 h1:CjhzTa274PyJLJuMZwIzCO1PfC00oRa8d1Kc78bFXJM=
|
||||||
|
github.com/steveyen/gtreap v0.1.0/go.mod h1:kl/5J7XbrOmlIbYIXdRHDDE5QxHqpk0cmkT7Z4dM9/Y=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
|
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||||
|
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||||
|
github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
|
||||||
|
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
|
||||||
|
github.com/tebeka/snowball v0.4.2/go.mod h1:4IfL14h1lvwZcp1sfXuuc7/7yCsvVffTWxWxCLfFpYg=
|
||||||
|
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok=
|
||||||
|
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8=
|
||||||
|
github.com/tinylib/msgp v1.1.0/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
|
||||||
|
github.com/tinylib/msgp v1.3.0 h1:ULuf7GPooDaIlbyvgAxBV/FI7ynli6LZ1/nVUNu+0ww=
|
||||||
|
github.com/tinylib/msgp v1.3.0/go.mod h1:ykjzy2wzgrlvpDCRc4LA8UXy6D8bzMSuAF3WD57Gok0=
|
||||||
|
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||||
github.com/valyala/fasthttp v1.61.0 h1:VV08V0AfoRaFurP1EWKvQQdPTZHiUzaVoulX1aBDgzU=
|
github.com/valyala/fasthttp v1.65.0 h1:j/u3uzFEGFfRxw79iYzJN+TteTJwbYkru9uDp3d0Yf8=
|
||||||
github.com/valyala/fasthttp v1.61.0/go.mod h1:wRIV/4cMwUPWnRcDno9hGnYZGh78QzODFfo1LTUhBog=
|
github.com/valyala/fasthttp v1.65.0/go.mod h1:P/93/YkKPMsKSnATEeELUCkG8a7Y+k99uxNHVbKINr4=
|
||||||
|
github.com/willf/bitset v1.1.10 h1:NotGKqX0KwQ72NUzqrjZq5ipPNDQex9lo3WpaS8L2sc=
|
||||||
|
github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
|
||||||
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
|
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
|
||||||
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
|
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
|
||||||
|
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||||
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
|
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
|
||||||
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
|
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
|
||||||
|
go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0=
|
||||||
|
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
|
||||||
|
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE=
|
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
|
||||||
golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc=
|
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
|
||||||
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||||
golang.org/x/image v0.27.0 h1:C8gA4oWU/tKkdCfYT6T2u4faJu3MeNS5O8UPWlPF61w=
|
golang.org/x/image v0.31.0 h1:mLChjE2MV6g1S7oqbXC0/UcKijjm5fnJLUYKIYrLESA=
|
||||||
golang.org/x/image v0.27.0/go.mod h1:xbdrClrAUway1MUTEZDq9mz/UpRwYAkFFNUslZtcB+g=
|
golang.org/x/image v0.31.0/go.mod h1:R9ec5Lcp96v9FTF+ajwaH3uGxPH4fKfHHAVbUILxghA=
|
||||||
golang.org/x/image v0.28.0 h1:gdem5JW1OLS4FbkWgLO+7ZeFzYtL3xClb97GaUzYMFE=
|
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/image v0.28.0/go.mod h1:GUJYXtnGKEUgggyzh+Vxt+AviiCcyiwpsl8iQ8MvwGY=
|
|
||||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY=
|
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
|
||||||
golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E=
|
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
|
||||||
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20181221143128-b4a75ba826a6/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
|
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
|
||||||
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
|
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
|
||||||
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
|
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
|
||||||
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
|
|
||||||
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
|
|
||||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||||
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||||
|
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gorm.io/driver/mysql v1.5.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo=
|
gorm.io/driver/mysql v1.6.0 h1:eNbLmNTpPpTOVZi8MMxCi2aaIm0ZpInbORNXDwyLGvg=
|
||||||
gorm.io/driver/mysql v1.5.7/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM=
|
gorm.io/driver/mysql v1.6.0/go.mod h1:D/oCC2GWK3M/dqoLxnOlaNKmXz8WNTfcS9y5ovaSqKo=
|
||||||
gorm.io/driver/sqlite v1.5.7 h1:8NvsrhP0ifM7LX9G4zPB97NwovUakUxc+2V2uuf3Z1I=
|
gorm.io/driver/sqlite v1.6.0 h1:WHRRrIiulaPiPFmDcod6prc4l2VGVWHz80KspNsxSfQ=
|
||||||
gorm.io/driver/sqlite v1.5.7/go.mod h1:U+J8craQU6Fzkcvu8oLeAQmi50TkwPEhHDEjQZXDah4=
|
gorm.io/driver/sqlite v1.6.0/go.mod h1:AO9V1qIQddBESngQUKWL9yoH93HIeA1X6V633rBwyT8=
|
||||||
gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
|
gorm.io/gorm v1.31.0 h1:0VlycGreVhK7RF/Bwt51Fk8v0xLiiiFdbGDPIZQ7mJY=
|
||||||
gorm.io/gorm v1.26.1 h1:ghB2gUI9FkS46luZtn6DLZ0f6ooBJ5IbVej2ENFDjRw=
|
gorm.io/gorm v1.31.0/go.mod h1:XyQVbO2k6YkOis7C2437jSit3SsDK72s7n7rsSHd+Gs=
|
||||||
gorm.io/gorm v1.26.1/go.mod h1:8Z33v652h4//uMA76KjeDH8mJXPm1QNCYrMeatR0DOE=
|
|
||||||
|
2
main.go
2
main.go
@@ -21,6 +21,8 @@ func main() {
|
|||||||
|
|
||||||
app.Use(middleware.ErrorHandler)
|
app.Use(middleware.ErrorHandler)
|
||||||
|
|
||||||
|
app.Use(middleware.RealUserMiddleware)
|
||||||
|
|
||||||
app.Use(middleware.JwtMiddleware)
|
app.Use(middleware.JwtMiddleware)
|
||||||
|
|
||||||
app.Use(middleware.FrontendMiddleware)
|
app.Use(middleware.FrontendMiddleware)
|
||||||
|
@@ -205,7 +205,7 @@ func deleteFile(c fiber.Ctx) error {
|
|||||||
|
|
||||||
func downloadFile(c fiber.Ctx) error {
|
func downloadFile(c fiber.Ctx) error {
|
||||||
cfToken := c.Query("cf_token")
|
cfToken := c.Query("cf_token")
|
||||||
s, filename, err := service.DownloadFile(c.Params("id"), cfToken)
|
s, filename, err := service.DownloadFile(c.Params("id"), cfToken, c.Locals("real_user") == true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@@ -56,7 +56,7 @@ func handleGetResource(c fiber.Ctx) error {
|
|||||||
return model.NewRequestError("Invalid resource ID")
|
return model.NewRequestError("Invalid resource ID")
|
||||||
}
|
}
|
||||||
host := c.Hostname()
|
host := c.Hostname()
|
||||||
resource, err := service.GetResource(uint(id), host)
|
resource, err := service.GetResource(uint(id), host, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@@ -1,12 +1,17 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gofiber/fiber/v3"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"nysoure/server/model"
|
"nysoure/server/model"
|
||||||
"nysoure/server/service"
|
"nysoure/server/service"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/gofiber/fiber/v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
maxTagNameLength = 20
|
||||||
)
|
)
|
||||||
|
|
||||||
func handleCreateTag(c fiber.Ctx) error {
|
func handleCreateTag(c fiber.Ctx) error {
|
||||||
@@ -15,6 +20,9 @@ func handleCreateTag(c fiber.Ctx) error {
|
|||||||
return model.NewRequestError("name is required")
|
return model.NewRequestError("name is required")
|
||||||
}
|
}
|
||||||
tag = strings.TrimSpace(tag)
|
tag = strings.TrimSpace(tag)
|
||||||
|
if len([]rune(tag)) > maxTagNameLength {
|
||||||
|
return model.NewRequestError("Tag name too long")
|
||||||
|
}
|
||||||
uid, ok := c.Locals("uid").(uint)
|
uid, ok := c.Locals("uid").(uint)
|
||||||
if !ok {
|
if !ok {
|
||||||
return model.NewUnAuthorizedError("You must be logged in to create a tag")
|
return model.NewUnAuthorizedError("You must be logged in to create a tag")
|
||||||
@@ -159,6 +167,9 @@ func getOrCreateTags(c fiber.Ctx) error {
|
|||||||
if name == "" {
|
if name == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if len([]rune(name)) > maxTagNameLength {
|
||||||
|
return model.NewRequestError("Tag name too long: " + name)
|
||||||
|
}
|
||||||
names = append(names, name)
|
names = append(names, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,6 +12,10 @@ import (
|
|||||||
|
|
||||||
var db *gorm.DB
|
var db *gorm.DB
|
||||||
|
|
||||||
|
var (
|
||||||
|
ready = false
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if os.Getenv("DB_PORT") != "" {
|
if os.Getenv("DB_PORT") != "" {
|
||||||
host := os.Getenv("DB_HOST")
|
host := os.Getenv("DB_HOST")
|
||||||
@@ -22,10 +26,18 @@ func init() {
|
|||||||
dsn := user + ":" + password + "@tcp(" + host + ":" + port + ")/" + dbName + "?charset=utf8mb4&parseTime=True&loc=Local"
|
dsn := user + ":" + password + "@tcp(" + host + ":" + port + ")/" + dbName + "?charset=utf8mb4&parseTime=True&loc=Local"
|
||||||
var err error
|
var err error
|
||||||
// wait for mysql to be ready
|
// wait for mysql to be ready
|
||||||
time.Sleep(5 * time.Second)
|
retrys := 5
|
||||||
db, err = gorm.Open(mysql.Open(dsn), &gorm.Config{})
|
for {
|
||||||
if err != nil {
|
db, err = gorm.Open(mysql.Open(dsn), &gorm.Config{})
|
||||||
panic("failed to connect database")
|
if err == nil {
|
||||||
|
ready = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
retrys--
|
||||||
|
if retrys < 0 {
|
||||||
|
panic("failed to connect database: " + err.Error())
|
||||||
|
}
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var err error
|
var err error
|
||||||
@@ -54,3 +66,15 @@ func init() {
|
|||||||
func GetDB() *gorm.DB {
|
func GetDB() *gorm.DB {
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsReady() bool {
|
||||||
|
return ready
|
||||||
|
}
|
||||||
|
|
||||||
|
func Close() error {
|
||||||
|
sqlDB, err := db.DB()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return sqlDB.Close()
|
||||||
|
}
|
||||||
|
@@ -73,7 +73,7 @@ func GetUploadingFilesOlderThan(time time.Time) ([]model.UploadingFile, error) {
|
|||||||
return files, nil
|
return files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateFile(filename string, description string, resourceID uint, storageID *uint, storageKey string, redirectUrl string, size int64, userID uint) (*model.File, error) {
|
func CreateFile(filename string, description string, resourceID uint, storageID *uint, storageKey string, redirectUrl string, size int64, userID uint, hash string) (*model.File, error) {
|
||||||
if storageID == nil && redirectUrl == "" {
|
if storageID == nil && redirectUrl == "" {
|
||||||
return nil, errors.New("storageID and redirectUrl cannot be both empty")
|
return nil, errors.New("storageID and redirectUrl cannot be both empty")
|
||||||
}
|
}
|
||||||
@@ -88,6 +88,7 @@ func CreateFile(filename string, description string, resourceID uint, storageID
|
|||||||
StorageKey: storageKey,
|
StorageKey: storageKey,
|
||||||
Size: size,
|
Size: size,
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
|
Hash: hash,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := db.Transaction(func(tx *gorm.DB) error {
|
err := db.Transaction(func(tx *gorm.DB) error {
|
||||||
@@ -99,6 +100,11 @@ func CreateFile(filename string, description string, resourceID uint, storageID
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
err = tx.Model(&model.Resource{}).Where("id = ?", resourceID).
|
||||||
|
UpdateColumn("modified_time", time.Now()).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -200,13 +206,14 @@ func SetFileStorageKey(id string, storageKey string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetFileStorageKeyAndSize(id string, storageKey string, size int64) error {
|
func SetFileStorageKeyAndSize(id string, storageKey string, size int64, hash string) error {
|
||||||
f := &model.File{}
|
f := &model.File{}
|
||||||
if err := db.Where("uuid = ?", id).First(f).Error; err != nil {
|
if err := db.Where("uuid = ?", id).First(f).Error; err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
f.StorageKey = storageKey
|
f.StorageKey = storageKey
|
||||||
f.Size = size
|
f.Size = size
|
||||||
|
f.Hash = hash
|
||||||
if err := db.Save(f).Error; err != nil {
|
if err := db.Save(f).Error; err != nil {
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
return model.NewNotFoundError("file not found")
|
return model.NewNotFoundError("file not found")
|
||||||
|
@@ -4,7 +4,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"nysoure/server/model"
|
"nysoure/server/model"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
@@ -16,6 +15,7 @@ import (
|
|||||||
|
|
||||||
func CreateResource(r model.Resource) (model.Resource, error) {
|
func CreateResource(r model.Resource) (model.Resource, error) {
|
||||||
err := db.Transaction(func(tx *gorm.DB) error {
|
err := db.Transaction(func(tx *gorm.DB) error {
|
||||||
|
r.ModifiedTime = time.Now()
|
||||||
err := tx.Create(&r).Error
|
err := tx.Create(&r).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -36,7 +36,9 @@ func GetResourceByID(id uint) (model.Resource, error) {
|
|||||||
var r model.Resource
|
var r model.Resource
|
||||||
if err := db.Preload("User").
|
if err := db.Preload("User").
|
||||||
Preload("Images").
|
Preload("Images").
|
||||||
Preload("Tags").
|
Preload("Tags", func(db *gorm.DB) *gorm.DB {
|
||||||
|
return db.Select("id", "name", "type", "alias_of")
|
||||||
|
}).
|
||||||
Preload("Files").
|
Preload("Files").
|
||||||
Preload("Files.User").
|
Preload("Files.User").
|
||||||
First(&r, id).Error; err != nil {
|
First(&r, id).Error; err != nil {
|
||||||
@@ -70,9 +72,9 @@ func GetResourceList(page, pageSize int, sort model.RSort) ([]model.Resource, in
|
|||||||
order := ""
|
order := ""
|
||||||
switch sort {
|
switch sort {
|
||||||
case model.RSortTimeAsc:
|
case model.RSortTimeAsc:
|
||||||
order = "created_at ASC"
|
order = "modified_time ASC"
|
||||||
case model.RSortTimeDesc:
|
case model.RSortTimeDesc:
|
||||||
order = "created_at DESC"
|
order = "modified_time DESC"
|
||||||
case model.RSortViewsAsc:
|
case model.RSortViewsAsc:
|
||||||
order = "views ASC"
|
order = "views ASC"
|
||||||
case model.RSortViewsDesc:
|
case model.RSortViewsDesc:
|
||||||
@@ -82,7 +84,7 @@ func GetResourceList(page, pageSize int, sort model.RSort) ([]model.Resource, in
|
|||||||
case model.RSortDownloadsDesc:
|
case model.RSortDownloadsDesc:
|
||||||
order = "downloads DESC"
|
order = "downloads DESC"
|
||||||
default:
|
default:
|
||||||
order = "created_at DESC" // Default sort order
|
order = "modified_time DESC" // Default sort order
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := db.Offset((page - 1) * pageSize).Limit(pageSize).Preload("User").Preload("Images").Preload("Tags").Order(order).Find(&resources).Error; err != nil {
|
if err := db.Offset((page - 1) * pageSize).Limit(pageSize).Preload("User").Preload("Images").Preload("Tags").Order(order).Find(&resources).Error; err != nil {
|
||||||
@@ -101,6 +103,7 @@ func UpdateResource(r model.Resource) error {
|
|||||||
r.Images = nil
|
r.Images = nil
|
||||||
r.Tags = nil
|
r.Tags = nil
|
||||||
r.Files = nil
|
r.Files = nil
|
||||||
|
r.ModifiedTime = time.Now()
|
||||||
if err := db.Save(&r).Error; err != nil {
|
if err := db.Save(&r).Error; err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -141,180 +144,6 @@ func DeleteResource(id uint) error {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func splitQuery(query string) []string {
|
|
||||||
var keywords []string
|
|
||||||
|
|
||||||
query = strings.TrimSpace(query)
|
|
||||||
if query == "" {
|
|
||||||
return keywords
|
|
||||||
}
|
|
||||||
|
|
||||||
l, r := 0, 0
|
|
||||||
inQuote := false
|
|
||||||
quoteChar := byte(0)
|
|
||||||
|
|
||||||
for r < len(query) {
|
|
||||||
if (query[r] == '"' || query[r] == '\'') && (r == 0 || query[r-1] != '\\') {
|
|
||||||
if !inQuote {
|
|
||||||
inQuote = true
|
|
||||||
quoteChar = query[r]
|
|
||||||
l = r + 1
|
|
||||||
} else if query[r] == quoteChar {
|
|
||||||
if r > l {
|
|
||||||
keywords = append(keywords, strings.TrimSpace(query[l:r]))
|
|
||||||
}
|
|
||||||
inQuote = false
|
|
||||||
r++
|
|
||||||
l = r
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
} else if !inQuote && query[r] == ' ' {
|
|
||||||
if r > l {
|
|
||||||
keywords = append(keywords, strings.TrimSpace(query[l:r]))
|
|
||||||
}
|
|
||||||
for r < len(query) && query[r] == ' ' {
|
|
||||||
r++
|
|
||||||
}
|
|
||||||
l = r
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
r++
|
|
||||||
}
|
|
||||||
|
|
||||||
if l < len(query) {
|
|
||||||
keywords = append(keywords, strings.TrimSpace(query[l:r]))
|
|
||||||
}
|
|
||||||
|
|
||||||
return keywords
|
|
||||||
}
|
|
||||||
|
|
||||||
func Search(query string, page, pageSize int) ([]model.Resource, int, error) {
|
|
||||||
query = strings.TrimSpace(query)
|
|
||||||
|
|
||||||
keywords := splitQuery(query)
|
|
||||||
if len(keywords) == 0 {
|
|
||||||
return nil, 0, nil
|
|
||||||
}
|
|
||||||
resource, err := searchWithKeyword(keywords[0])
|
|
||||||
if err != nil {
|
|
||||||
return nil, 0, err
|
|
||||||
}
|
|
||||||
if len(keywords) > 1 {
|
|
||||||
for _, keyword := range keywords[1:] {
|
|
||||||
r := make([]model.Resource, 0, len(resource))
|
|
||||||
for _, res := range resource {
|
|
||||||
if strings.Contains(res.Title, keyword) {
|
|
||||||
r = append(r, res)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
ok := false
|
|
||||||
for _, at := range res.AlternativeTitles {
|
|
||||||
if strings.Contains(at, keyword) {
|
|
||||||
r = append(r, res)
|
|
||||||
ok = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ok {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
for _, tag := range res.Tags {
|
|
||||||
if tag.Name == keyword {
|
|
||||||
r = append(r, res)
|
|
||||||
ok = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
resource = r
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
startIndex := (page - 1) * pageSize
|
|
||||||
endIndex := startIndex + pageSize
|
|
||||||
if startIndex > len(resource) {
|
|
||||||
return nil, 0, nil
|
|
||||||
}
|
|
||||||
if endIndex > len(resource) {
|
|
||||||
endIndex = len(resource)
|
|
||||||
}
|
|
||||||
totalPages := (len(resource) + pageSize - 1) / pageSize
|
|
||||||
|
|
||||||
result := make([]model.Resource, 0, endIndex-startIndex)
|
|
||||||
for i := startIndex; i < endIndex; i++ {
|
|
||||||
var r model.Resource
|
|
||||||
if err := db.Model(&r).Preload("User").Preload("Images").Preload("Tags").Where("id=?", resource[i].ID).First(&r).Error; err != nil {
|
|
||||||
return nil, 0, err
|
|
||||||
}
|
|
||||||
result = append(result, r)
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, totalPages, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func searchWithKeyword(keyword string) ([]model.Resource, error) {
|
|
||||||
if len(keyword) == 0 {
|
|
||||||
return nil, nil
|
|
||||||
} else if len([]rune(keyword)) > 100 {
|
|
||||||
return nil, model.NewRequestError("Keyword is too long")
|
|
||||||
}
|
|
||||||
|
|
||||||
var resources []model.Resource
|
|
||||||
|
|
||||||
if len([]rune(keyword)) < 20 {
|
|
||||||
var tag model.Tag
|
|
||||||
var err error
|
|
||||||
if tag, err = GetTagByName(keyword); err != nil {
|
|
||||||
if !model.IsNotFoundError(err) {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if tag.AliasOf != nil {
|
|
||||||
tag, err = GetTagByID(*tag.AliasOf)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var tagIds []uint
|
|
||||||
tagIds = append(tagIds, tag.ID)
|
|
||||||
for _, alias := range tag.Aliases {
|
|
||||||
tagIds = append(tagIds, alias.ID)
|
|
||||||
}
|
|
||||||
subQuery := db.Table("resource_tags").
|
|
||||||
Select("resource_id").
|
|
||||||
Where("tag_id IN ?", tagIds).
|
|
||||||
Group("resource_id")
|
|
||||||
if err := db.Where("id IN (?)", subQuery).Select("id", "title", "alternative_titles").Preload("Tags").Find(&resources).Error; err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var titleResult []model.Resource
|
|
||||||
if err := db.Where("title LIKE ?", "%"+keyword+"%").Or("alternative_titles LIKE ?", "%"+keyword+"%").Select("id", "title", "alternative_titles").Preload("Tags").Find(&titleResult).Error; err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(titleResult) > 0 {
|
|
||||||
if len(resources) == 0 {
|
|
||||||
resources = titleResult
|
|
||||||
} else {
|
|
||||||
resourceMap := make(map[uint]model.Resource)
|
|
||||||
for _, res := range resources {
|
|
||||||
resourceMap[res.ID] = res
|
|
||||||
}
|
|
||||||
for _, res := range titleResult {
|
|
||||||
if _, exists := resourceMap[res.ID]; !exists {
|
|
||||||
resources = append(resources, res)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return resources, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetResourceByTag(tagID uint, page int, pageSize int) ([]model.Resource, int, error) {
|
func GetResourceByTag(tagID uint, page int, pageSize int) ([]model.Resource, int, error) {
|
||||||
tag, err := GetTagByID(tagID)
|
tag, err := GetTagByID(tagID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -563,3 +392,72 @@ func RandomResource() (model.Resource, error) {
|
|||||||
return resource, nil // Return the found resource
|
return resource, nil // Return the found resource
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetResourcesIdWithTag(tagID uint) ([]uint, error) {
|
||||||
|
tag, err := GetTagByID(tagID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if tag.AliasOf != nil {
|
||||||
|
tag, err = GetTagByID(*tag.AliasOf)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var tagIds []uint
|
||||||
|
tagIds = append(tagIds, tag.ID)
|
||||||
|
for _, alias := range tag.Aliases {
|
||||||
|
tagIds = append(tagIds, alias.ID)
|
||||||
|
}
|
||||||
|
var result []model.Resource
|
||||||
|
subQuery := db.Table("resource_tags").
|
||||||
|
Select("resource_id").
|
||||||
|
Where("tag_id IN ?", tagIds).
|
||||||
|
Group("resource_id")
|
||||||
|
if err := db.Model(&model.Resource{}).
|
||||||
|
Where("id IN (?)", subQuery).
|
||||||
|
Order("created_at DESC").
|
||||||
|
Limit(10000).
|
||||||
|
Select("id", "created_at").
|
||||||
|
Find(&result).
|
||||||
|
Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
ids := make([]uint, len(result))
|
||||||
|
for i, r := range result {
|
||||||
|
ids[i] = r.ID
|
||||||
|
}
|
||||||
|
return ids, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func BatchGetResources(ids []uint) ([]model.Resource, error) {
|
||||||
|
var resources []model.Resource
|
||||||
|
|
||||||
|
for _, id := range ids {
|
||||||
|
var r model.Resource
|
||||||
|
if err := db.
|
||||||
|
Preload("User").
|
||||||
|
Preload("Images").
|
||||||
|
Preload("Tags").
|
||||||
|
First(&r, id).Error; err != nil {
|
||||||
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for i, tag := range r.Tags {
|
||||||
|
if tag.AliasOf != nil {
|
||||||
|
t, err := GetTagByID(*tag.AliasOf)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else {
|
||||||
|
r.Tags[i].Type = t.Type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resources = append(resources, r)
|
||||||
|
}
|
||||||
|
|
||||||
|
return resources, nil
|
||||||
|
}
|
||||||
|
@@ -2,10 +2,11 @@ package dao
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/gofiber/fiber/v3/log"
|
|
||||||
"nysoure/server/model"
|
"nysoure/server/model"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/gofiber/fiber/v3/log"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ func CreateTag(tag string) (model.Tag, error) {
|
|||||||
if err := db.Create(&t).Error; err != nil {
|
if err := db.Create(&t).Error; err != nil {
|
||||||
return model.Tag{}, err
|
return model.Tag{}, err
|
||||||
}
|
}
|
||||||
return t, nil
|
return GetTagByID(t.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateTagWithType(tag string, tagType string) (model.Tag, error) {
|
func CreateTagWithType(tag string, tagType string) (model.Tag, error) {
|
||||||
@@ -81,13 +82,34 @@ func GetTagByName(name string) (model.Tag, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SetTagInfo(id uint, description string, aliasOf *uint, tagType string) error {
|
func SetTagInfo(id uint, description string, aliasOf *uint, tagType string) error {
|
||||||
|
// Get the tag information
|
||||||
old, err := GetTagByID(id)
|
old, err := GetTagByID(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if aliasOf != nil && len(old.Aliases) > 0 {
|
|
||||||
return model.NewRequestError("Tag already has aliases, cannot set alias_of")
|
// If the alias tag is an alias itself, we need to find its root tag
|
||||||
|
if aliasOf != nil {
|
||||||
|
tag, err := GetTagByID(*aliasOf)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if tag.AliasOf != nil {
|
||||||
|
aliasOf = tag.AliasOf
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the tag has aliases, we need to update their alias_of field
|
||||||
|
if aliasOf != nil && len(old.Aliases) > 0 {
|
||||||
|
for _, alias := range old.Aliases {
|
||||||
|
err := db.Model(&alias).Update("alias_of", *aliasOf).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the tag information
|
||||||
t := model.Tag{Model: gorm.Model{
|
t := model.Tag{Model: gorm.Model{
|
||||||
ID: id,
|
ID: id,
|
||||||
}, Description: description, Type: tagType, AliasOf: aliasOf}
|
}, Description: description, Type: tagType, AliasOf: aliasOf}
|
||||||
@@ -112,24 +134,51 @@ func ListTags() ([]model.Tag, error) {
|
|||||||
|
|
||||||
// SetTagAlias sets a tag with the given ID having the given alias.
|
// SetTagAlias sets a tag with the given ID having the given alias.
|
||||||
func SetTagAlias(tagID uint, alias string) error {
|
func SetTagAlias(tagID uint, alias string) error {
|
||||||
// Set a tag as an alias of another tag
|
exists, err := ExistsTagByID(tagID)
|
||||||
var t model.Tag
|
if err != nil {
|
||||||
if err := db.Where("name = ?", alias).First(&t).Error; err != nil {
|
return err
|
||||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
}
|
||||||
// create
|
if !exists {
|
||||||
newTag, err := CreateTag(alias)
|
return model.NewNotFoundError("Tag not found")
|
||||||
if err != nil {
|
}
|
||||||
return err
|
|
||||||
}
|
exists, err = ExistsTag(alias)
|
||||||
t = newTag
|
if err != nil {
|
||||||
} else {
|
return err
|
||||||
|
}
|
||||||
|
if !exists {
|
||||||
|
// Create the alias tag if it does not exist
|
||||||
|
_, err := CreateTag(alias)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if t.ID == tagID {
|
// Get the alias tag
|
||||||
return model.NewRequestError("Tag cannot be an alias of itself")
|
tag, err := GetTagByName(alias)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
return db.Model(&t).Update("alias_of", tagID).Error
|
// If the alias tag is an alias itself, we need to find its root tag
|
||||||
|
if tag.AliasOf != nil {
|
||||||
|
tag, err = GetTagByID(*tag.AliasOf)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If the tag has aliases, we need to update their alias_of field
|
||||||
|
for _, alias := range tag.Aliases {
|
||||||
|
err := db.Model(&alias).Update("alias_of", tagID).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tag.Aliases = nil
|
||||||
|
// A tag cannot be an alias of itself
|
||||||
|
if tag.ID == tagID {
|
||||||
|
return model.NewRequestError("A tag cannot be an alias of itself")
|
||||||
|
}
|
||||||
|
// Set the alias_of field of the tag
|
||||||
|
return db.Model(&tag).Update("alias_of", tagID).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveTagAliasOf sets a tag is an independent tag, removing its alias relationship.
|
// RemoveTagAliasOf sets a tag is an independent tag, removing its alias relationship.
|
||||||
@@ -171,3 +220,19 @@ func ClearUnusedTags() error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ExistsTag(name string) (bool, error) {
|
||||||
|
var count int64
|
||||||
|
if err := db.Model(&model.Tag{}).Where("name = ?", name).Count(&count).Error; err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
return count > 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func ExistsTagByID(id uint) (bool, error) {
|
||||||
|
var count int64
|
||||||
|
if err := db.Model(&model.Tag{}).Where("id = ?", id).Count(&count).Error; err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
return count > 0, nil
|
||||||
|
}
|
||||||
|
109
server/dao/tag_test.go
Normal file
109
server/dao/tag_test.go
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestTag(t *testing.T) {
|
||||||
|
// Create tags
|
||||||
|
tag1, err := CreateTag("test1")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag2, err := CreateTag("test2")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag3, err := CreateTagWithType("test3", "type1")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
|
||||||
|
// Get tag by ID
|
||||||
|
fetchedTag, err := GetTagByID(tag1.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, tag1.Name, fetchedTag.Name)
|
||||||
|
|
||||||
|
// Get tag by Name
|
||||||
|
fetchedTag, err = GetTagByName(tag2.Name)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, tag2.ID, fetchedTag.ID)
|
||||||
|
|
||||||
|
// Search tags
|
||||||
|
tags, err := SearchTag("test", true)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.GreaterOrEqual(t, len(tags), 3)
|
||||||
|
|
||||||
|
// Update tag
|
||||||
|
err = SetTagInfo(tag1.ID, "updated description", nil, "updated type")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
updatedTag, err := GetTagByID(tag1.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, "updated description", updatedTag.Description)
|
||||||
|
assert.Equal(t, "updated type", updatedTag.Type)
|
||||||
|
|
||||||
|
// Set tag alias
|
||||||
|
err = SetTagAlias(tag1.ID, tag2.Name)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
err = SetTagAlias(tag1.ID, tag3.Name)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
err = SetTagAlias(tag1.ID, "test4")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag4, err := GetTagByName("test4")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag1, err = GetTagByID(tag1.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
aliasesIDs := []uint{}
|
||||||
|
for _, alias := range tag1.Aliases {
|
||||||
|
aliasesIDs = append(aliasesIDs, alias.ID)
|
||||||
|
}
|
||||||
|
assert.Equal(t, []uint{tag2.ID, tag3.ID, tag4.ID}, aliasesIDs)
|
||||||
|
|
||||||
|
// let a tag which has alias point to another tag
|
||||||
|
tag5, err := CreateTag("test5")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
err = SetTagAlias(tag5.ID, tag1.Name)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag1, err = GetTagByID(tag1.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag2, err = GetTagByID(tag2.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag3, err = GetTagByID(tag3.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag4, err = GetTagByID(tag4.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag5, err = GetTagByID(tag5.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Empty(t, tag1.Aliases)
|
||||||
|
assert.Equal(t, &tag5.ID, tag1.AliasOf)
|
||||||
|
assert.Equal(t, &tag5.ID, tag2.AliasOf)
|
||||||
|
assert.Equal(t, &tag5.ID, tag3.AliasOf)
|
||||||
|
assert.Equal(t, &tag5.ID, tag4.AliasOf)
|
||||||
|
assert.Nil(t, tag5.AliasOf)
|
||||||
|
|
||||||
|
// Same operation as above, but using `SetTagInfo`
|
||||||
|
tag6, err := CreateTag("test6")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
err = SetTagInfo(tag5.ID, "", &tag6.ID, "")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag1, err = GetTagByID(tag1.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag2, err = GetTagByID(tag2.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag3, err = GetTagByID(tag3.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag4, err = GetTagByID(tag4.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag5, err = GetTagByID(tag5.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
tag6, err = GetTagByID(tag6.ID)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, &tag6.ID, tag1.AliasOf)
|
||||||
|
assert.Equal(t, &tag6.ID, tag2.AliasOf)
|
||||||
|
assert.Equal(t, &tag6.ID, tag3.AliasOf)
|
||||||
|
assert.Equal(t, &tag6.ID, tag4.AliasOf)
|
||||||
|
assert.Equal(t, &tag6.ID, tag5.AliasOf)
|
||||||
|
assert.Empty(t, tag5.Aliases)
|
||||||
|
assert.Nil(t, tag6.AliasOf)
|
||||||
|
|
||||||
|
// cleanup
|
||||||
|
_ = Close()
|
||||||
|
_ = os.Remove("test.db")
|
||||||
|
}
|
@@ -79,7 +79,7 @@ func serveIndexHtml(c fiber.Ctx) error {
|
|||||||
idStr := strings.TrimPrefix(path, "/resources/")
|
idStr := strings.TrimPrefix(path, "/resources/")
|
||||||
id, err := strconv.Atoi(idStr)
|
id, err := strconv.Atoi(idStr)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
r, err := service.GetResource(uint(id), c.Hostname())
|
r, err := service.GetResource(uint(id), c.Hostname(), c)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if len(r.Images) > 0 {
|
if len(r.Images) > 0 {
|
||||||
preview = fmt.Sprintf("%s/api/image/%d", serverBaseURL, r.Images[0].ID)
|
preview = fmt.Sprintf("%s/api/image/%d", serverBaseURL, r.Images[0].ID)
|
||||||
|
17
server/middleware/real_user_middleware.go
Normal file
17
server/middleware/real_user_middleware.go
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package middleware
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/gofiber/fiber/v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RealUserMiddleware(c fiber.Ctx) error {
|
||||||
|
userAgent := c.Get("User-Agent")
|
||||||
|
if strings.Contains(userAgent, "Mozilla") || strings.Contains(userAgent, "AppleWebKit") {
|
||||||
|
c.Locals("real_user", true)
|
||||||
|
} else {
|
||||||
|
c.Locals("real_user", false)
|
||||||
|
}
|
||||||
|
return c.Next()
|
||||||
|
}
|
@@ -18,6 +18,7 @@ type File struct {
|
|||||||
UserID uint
|
UserID uint
|
||||||
User User `gorm:"foreignKey:UserID"`
|
User User `gorm:"foreignKey:UserID"`
|
||||||
Size int64
|
Size int64
|
||||||
|
Hash string `gorm:"default:null"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FileView struct {
|
type FileView struct {
|
||||||
@@ -28,6 +29,7 @@ type FileView struct {
|
|||||||
IsRedirect bool `json:"is_redirect"`
|
IsRedirect bool `json:"is_redirect"`
|
||||||
User UserView `json:"user"`
|
User UserView `json:"user"`
|
||||||
Resource *ResourceView `json:"resource,omitempty"`
|
Resource *ResourceView `json:"resource,omitempty"`
|
||||||
|
Hash string `json:"hash,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *File) ToView() *FileView {
|
func (f *File) ToView() *FileView {
|
||||||
@@ -38,6 +40,7 @@ func (f *File) ToView() *FileView {
|
|||||||
Size: f.Size,
|
Size: f.Size,
|
||||||
IsRedirect: f.RedirectUrl != "",
|
IsRedirect: f.RedirectUrl != "",
|
||||||
User: f.User.ToView(),
|
User: f.User.ToView(),
|
||||||
|
Hash: f.Hash,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,5 +59,6 @@ func (f *File) ToViewWithResource() *FileView {
|
|||||||
IsRedirect: f.RedirectUrl != "",
|
IsRedirect: f.RedirectUrl != "",
|
||||||
User: f.User.ToView(),
|
User: f.User.ToView(),
|
||||||
Resource: resource,
|
Resource: resource,
|
||||||
|
Hash: f.Hash,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,6 +20,7 @@ type Resource struct {
|
|||||||
Views uint
|
Views uint
|
||||||
Downloads uint
|
Downloads uint
|
||||||
Comments uint
|
Comments uint
|
||||||
|
ModifiedTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type Link struct {
|
type Link struct {
|
||||||
|
114
server/search/resource.go
Normal file
114
server/search/resource.go
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
package search
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"nysoure/server/dao"
|
||||||
|
"nysoure/server/model"
|
||||||
|
"nysoure/server/utils"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/blevesearch/bleve"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ResourceParams struct {
|
||||||
|
Id uint
|
||||||
|
Title string
|
||||||
|
Subtitles []string
|
||||||
|
Time time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
var index bleve.Index
|
||||||
|
|
||||||
|
func AddResourceToIndex(r model.Resource) error {
|
||||||
|
return index.Index(fmt.Sprintf("%d", r.ID), ResourceParams{
|
||||||
|
Id: r.ID,
|
||||||
|
Title: r.Title,
|
||||||
|
Subtitles: r.AlternativeTitles,
|
||||||
|
Time: r.CreatedAt,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func RemoveResourceFromIndex(id uint) error {
|
||||||
|
return index.Delete(fmt.Sprintf("%d", id))
|
||||||
|
}
|
||||||
|
|
||||||
|
func createIndex() error {
|
||||||
|
for !dao.IsReady() {
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
}
|
||||||
|
page := 1
|
||||||
|
total := 1
|
||||||
|
for page <= total {
|
||||||
|
res, totalPages, err := dao.GetResourceList(page, 100, model.RSortTimeAsc)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, r := range res {
|
||||||
|
err := AddResourceToIndex(r)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
page++
|
||||||
|
total = totalPages
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
indexPath := utils.GetStoragePath() + "/resource_index.bleve"
|
||||||
|
|
||||||
|
var err error
|
||||||
|
index, err = bleve.Open(indexPath)
|
||||||
|
if errors.Is(err, bleve.ErrorIndexPathDoesNotExist) {
|
||||||
|
mapping := bleve.NewIndexMapping()
|
||||||
|
index, err = bleve.New(indexPath, mapping)
|
||||||
|
if err != nil {
|
||||||
|
panic("Failed to create search index: " + err.Error())
|
||||||
|
}
|
||||||
|
go func() {
|
||||||
|
err := createIndex()
|
||||||
|
if err != nil {
|
||||||
|
panic("Failed to create search index: " + err.Error())
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
} else if err != nil {
|
||||||
|
panic("Failed to open search index: " + err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func SearchResource(keyword string) ([]uint, error) {
|
||||||
|
query := bleve.NewMatchQuery(keyword)
|
||||||
|
searchRequest := bleve.NewSearchRequest(query)
|
||||||
|
searchResults, err := index.Search(searchRequest)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
results := make([]uint, 0)
|
||||||
|
for _, hit := range searchResults.Hits {
|
||||||
|
if hit.Score < 0.2 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
id, err := strconv.ParseUint(hit.ID, 10, 32)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
results = append(results, uint(id))
|
||||||
|
}
|
||||||
|
|
||||||
|
return results, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func IsStopWord(word string) bool {
|
||||||
|
mapping := bleve.NewIndexMapping()
|
||||||
|
analyzerName := mapping.DefaultAnalyzer
|
||||||
|
analyzer := mapping.AnalyzerNamed(analyzerName)
|
||||||
|
if analyzer == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
tokens := analyzer.Analyze([]byte(word))
|
||||||
|
return len(tokens) == 0
|
||||||
|
}
|
185
server/search/search_test.go
Normal file
185
server/search/search_test.go
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
package search
|
||||||
|
|
||||||
|
import (
|
||||||
|
"nysoure/server/dao"
|
||||||
|
"nysoure/server/model"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/blevesearch/bleve"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Init() {
|
||||||
|
err := index.Close()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
_ = os.RemoveAll("search_test.bleve")
|
||||||
|
mapper := bleve.NewIndexMapping()
|
||||||
|
index, err = bleve.New("search_test.bleve", mapper)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TearDown() {
|
||||||
|
err := index.Close()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
dao.Close()
|
||||||
|
os.RemoveAll("search_test.bleve")
|
||||||
|
os.Remove("test.db")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSearchResource(t *testing.T) {
|
||||||
|
Init()
|
||||||
|
defer TearDown()
|
||||||
|
|
||||||
|
resources := []model.Resource{
|
||||||
|
// normal cases
|
||||||
|
{Model: gorm.Model{ID: 1}, Title: "The Great Adventure", AlternativeTitles: []string{"Adventure Time", "The Big Adventure"}},
|
||||||
|
{Model: gorm.Model{ID: 2}, Title: "Mystery of the Lost City", AlternativeTitles: []string{"Lost City Chronicles"}},
|
||||||
|
{Model: gorm.Model{ID: 3}, Title: "Romance in Paris", AlternativeTitles: []string{"Love in Paris", "Parisian Romance"}},
|
||||||
|
{Model: gorm.Model{ID: 4}, Title: "Sci-Fi Extravaganza", AlternativeTitles: []string{"Future World", "Sci-Fi Saga"}},
|
||||||
|
{Model: gorm.Model{ID: 5}, Title: "Comedy Nights", AlternativeTitles: []string{"Laugh Out Loud", "Comedy Central"}},
|
||||||
|
// With special characters
|
||||||
|
{Model: gorm.Model{ID: 6}, Title: "Action & Adventure", AlternativeTitles: []string{"Action-Packed", "Adventure Time!"}},
|
||||||
|
{Model: gorm.Model{ID: 7}, Title: "Horror: The Awakening", AlternativeTitles: []string{"Scary Movie", "Horror Nights"}},
|
||||||
|
{Model: gorm.Model{ID: 8}, Title: "Drama @ Home", AlternativeTitles: []string{"Home Stories", "Dramatic Tales"}},
|
||||||
|
{Model: gorm.Model{ID: 9}, Title: "Fantasy #1", AlternativeTitles: []string{"Fantasy World", "Magical Tales"}},
|
||||||
|
{Model: gorm.Model{ID: 10}, Title: "Thriller ~Uncut~"},
|
||||||
|
{Model: gorm.Model{ID: 11}, Title: "Epic ~ Saga ~"},
|
||||||
|
{Model: gorm.Model{ID: 12}, Title: "Journey - Dawn -", AlternativeTitles: []string{"Dawn Adventures", "Journey Chronicles"}},
|
||||||
|
{Model: gorm.Model{ID: 13}, Title: "Legends -Rise-", AlternativeTitles: []string{"Rise of Legends", "Legendary Tales"}},
|
||||||
|
{Model: gorm.Model{ID: 14}, Title: "Chronicles: Time", AlternativeTitles: []string{"Time Chronicles", "Chronicles of Ages"}},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add resources to index
|
||||||
|
for _, r := range resources {
|
||||||
|
err := AddResourceToIndex(r)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to add resource ID %d to index: %v", r.ID, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tests := []struct {
|
||||||
|
query string
|
||||||
|
expectedIDs []uint
|
||||||
|
unexpectedID uint
|
||||||
|
}{
|
||||||
|
// Basic searches
|
||||||
|
{query: "Adventure", expectedIDs: []uint{1, 6}},
|
||||||
|
{query: "Mystery", expectedIDs: []uint{2}},
|
||||||
|
{query: "Romance", expectedIDs: []uint{3}},
|
||||||
|
{query: "Sci-Fi", expectedIDs: []uint{4}},
|
||||||
|
{query: "Comedy", expectedIDs: []uint{5}},
|
||||||
|
// Exact matches
|
||||||
|
{query: "The Great Adventure", expectedIDs: []uint{1}},
|
||||||
|
{query: "Mystery of the Lost City", expectedIDs: []uint{2}},
|
||||||
|
{query: "Romance in Paris", expectedIDs: []uint{3}},
|
||||||
|
{query: "Sci-Fi Extravaganza", expectedIDs: []uint{4}},
|
||||||
|
{query: "Comedy Nights", expectedIDs: []uint{5}},
|
||||||
|
{query: "Action & Adventure", expectedIDs: []uint{6}},
|
||||||
|
{query: "Horror: The Awakening", expectedIDs: []uint{7}},
|
||||||
|
{query: "Drama @ Home", expectedIDs: []uint{8}},
|
||||||
|
{query: "Fantasy #1", expectedIDs: []uint{9}},
|
||||||
|
{query: "Thriller ~Uncut~", expectedIDs: []uint{10}},
|
||||||
|
{query: "Epic ~ Saga ~", expectedIDs: []uint{11}},
|
||||||
|
{query: "Journey - Dawn -", expectedIDs: []uint{12}},
|
||||||
|
{query: "Legends -Rise-", expectedIDs: []uint{13}},
|
||||||
|
{query: "Chronicles: Time", expectedIDs: []uint{14}},
|
||||||
|
// Searches with special characters
|
||||||
|
{query: "Action & Adventure", expectedIDs: []uint{6}},
|
||||||
|
{query: "Horror: The Awakening", expectedIDs: []uint{7}},
|
||||||
|
{query: "Drama @ Home", expectedIDs: []uint{8}},
|
||||||
|
{query: "Fantasy #1", expectedIDs: []uint{9}},
|
||||||
|
{query: "Thriller ~Uncut~", expectedIDs: []uint{10}},
|
||||||
|
{query: "Epic ~ Saga ~", expectedIDs: []uint{11}},
|
||||||
|
{query: "Journey - Dawn -", expectedIDs: []uint{12}},
|
||||||
|
{query: "Legends -Rise-", expectedIDs: []uint{13}},
|
||||||
|
{query: "Chronicles: Time", expectedIDs: []uint{14}},
|
||||||
|
// Case insensitivity
|
||||||
|
{query: "adventure", expectedIDs: []uint{1, 6}},
|
||||||
|
{query: "MYSTERY", expectedIDs: []uint{2}},
|
||||||
|
{query: "rOmAnCe", expectedIDs: []uint{3}},
|
||||||
|
// Searches using alternative titles
|
||||||
|
{query: "Adventure Time", expectedIDs: []uint{1, 6}},
|
||||||
|
{query: "Lost City Chronicles", expectedIDs: []uint{2}},
|
||||||
|
{query: "Love in Paris", expectedIDs: []uint{3}},
|
||||||
|
{query: "Future World", expectedIDs: []uint{4}},
|
||||||
|
{query: "Laugh Out Loud", expectedIDs: []uint{5}},
|
||||||
|
// Searches with special characters in alternative titles
|
||||||
|
{query: "Action-Packed", expectedIDs: []uint{6}},
|
||||||
|
{query: "Scary Movie", expectedIDs: []uint{7}},
|
||||||
|
{query: "Home Stories", expectedIDs: []uint{8}},
|
||||||
|
{query: "Fantasy World", expectedIDs: []uint{9}},
|
||||||
|
{query: "Epic Tales", expectedIDs: []uint{11}},
|
||||||
|
{query: "Dawn Adventures", expectedIDs: []uint{12}},
|
||||||
|
{query: "Rise of Legends", expectedIDs: []uint{13}},
|
||||||
|
{query: "Time Chronicles", expectedIDs: []uint{14}},
|
||||||
|
// Searches with special characters in queries
|
||||||
|
{query: "Horror:", expectedIDs: []uint{7}},
|
||||||
|
{query: "@ Home", expectedIDs: []uint{8}},
|
||||||
|
{query: "#1", expectedIDs: []uint{9}},
|
||||||
|
{query: "~Uncut~", expectedIDs: []uint{10}},
|
||||||
|
{query: "Uncut", expectedIDs: []uint{10}},
|
||||||
|
{query: "~ Saga ~", expectedIDs: []uint{11}},
|
||||||
|
{query: "Saga", expectedIDs: []uint{11}},
|
||||||
|
{query: "- Dawn -", expectedIDs: []uint{12}},
|
||||||
|
{query: "-Rise-", expectedIDs: []uint{13}},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
t.Run(test.query, func(t *testing.T) {
|
||||||
|
resultIDs, err := SearchResource(test.query)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Search failed for query '%s': %v", test.query, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for expected IDs
|
||||||
|
for _, expectedID := range test.expectedIDs {
|
||||||
|
found := false
|
||||||
|
for _, resultID := range resultIDs {
|
||||||
|
if resultID == expectedID {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
t.Errorf("Expected ID %d not found in results for query '%s'", expectedID, test.query)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for unexpected ID
|
||||||
|
if test.unexpectedID != 0 {
|
||||||
|
for _, resultID := range resultIDs {
|
||||||
|
if resultID == test.unexpectedID {
|
||||||
|
t.Errorf("Unexpected ID %d found in results for query '%s'", test.unexpectedID, test.query)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestIsStopWord(t *testing.T) {
|
||||||
|
Init()
|
||||||
|
defer TearDown()
|
||||||
|
|
||||||
|
stopWords := []string{"the", "is", "at", "which", "on", "and", "a", "an", "in", "to", "of"}
|
||||||
|
nonStopWords := []string{"adventure", "mystery", "romance", "sci-fi", "comedy", "action", "horror"}
|
||||||
|
|
||||||
|
for _, word := range stopWords {
|
||||||
|
if !IsStopWord(word) {
|
||||||
|
t.Errorf("Expected '%s' to be identified as a stop word", word)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, word := range nonStopWords {
|
||||||
|
if IsStopWord(word) {
|
||||||
|
t.Errorf("Expected '%s' to not be identified as a stop word", word)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,6 +1,7 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"context"
|
"context"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
@@ -235,7 +236,7 @@ func FinishUploadingFile(uid uint, fid uint, md5Str string) (*model.FileView, er
|
|||||||
return nil, model.NewInternalServerError("failed to finish uploading file. please re-upload")
|
return nil, model.NewInternalServerError("failed to finish uploading file. please re-upload")
|
||||||
}
|
}
|
||||||
|
|
||||||
dbFile, err := dao.CreateFile(uploadingFile.Filename, uploadingFile.Description, uploadingFile.TargetResourceID, &uploadingFile.TargetStorageID, storageKeyUnavailable, "", uploadingFile.TotalSize, uid)
|
dbFile, err := dao.CreateFile(uploadingFile.Filename, uploadingFile.Description, uploadingFile.TargetResourceID, &uploadingFile.TargetStorageID, storageKeyUnavailable, "", uploadingFile.TotalSize, uid, sumStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("failed to create file in db: ", err)
|
log.Error("failed to create file in db: ", err)
|
||||||
_ = os.Remove(resultFilePath)
|
_ = os.Remove(resultFilePath)
|
||||||
@@ -309,7 +310,7 @@ func CreateRedirectFile(uid uint, filename string, description string, resourceI
|
|||||||
return nil, model.NewUnAuthorizedError("user cannot upload file")
|
return nil, model.NewUnAuthorizedError("user cannot upload file")
|
||||||
}
|
}
|
||||||
|
|
||||||
file, err := dao.CreateFile(filename, description, resourceID, nil, "", redirectUrl, 0, uid)
|
file, err := dao.CreateFile(filename, description, resourceID, nil, "", redirectUrl, 0, uid, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("failed to create file in db: ", err)
|
log.Error("failed to create file in db: ", err)
|
||||||
return nil, model.NewInternalServerError("failed to create file in db")
|
return nil, model.NewInternalServerError("failed to create file in db")
|
||||||
@@ -389,7 +390,7 @@ func GetFile(fid string) (*model.FileView, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DownloadFile handles the file download request. Return a presigned URL or a direct file path.
|
// DownloadFile handles the file download request. Return a presigned URL or a direct file path.
|
||||||
func DownloadFile(fid, cfToken string) (string, string, error) {
|
func DownloadFile(fid, cfToken string, isRealUser bool) (string, string, error) {
|
||||||
file, err := dao.GetFile(fid)
|
file, err := dao.GetFile(fid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("failed to get file: ", err)
|
log.Error("failed to get file: ", err)
|
||||||
@@ -436,9 +437,11 @@ func DownloadFile(fid, cfToken string) (string, string, error) {
|
|||||||
return "", "", model.NewInternalServerError("failed to download file from storage")
|
return "", "", model.NewInternalServerError("failed to download file from storage")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = dao.AddResourceDownloadCount(file.ResourceID)
|
if isRealUser {
|
||||||
if err != nil {
|
err = dao.AddResourceDownloadCount(file.ResourceID)
|
||||||
log.Errorf("failed to add resource download count: %v", err)
|
if err != nil {
|
||||||
|
log.Errorf("failed to add resource download count: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return path, file.Filename, nil
|
return path, file.Filename, nil
|
||||||
@@ -493,53 +496,61 @@ func testFileUrl(url string) (int64, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// downloadFile return nil if the download is successful or the context is cancelled
|
// downloadFile return nil if the download is successful or the context is cancelled
|
||||||
func downloadFile(ctx context.Context, url string, path string) error {
|
func downloadFile(ctx context.Context, url string, path string) (string, error) {
|
||||||
if _, err := os.Stat(path); err == nil {
|
if _, err := os.Stat(path); err == nil {
|
||||||
_ = os.Remove(path) // Remove the file if it already exists
|
_ = os.Remove(path) // Remove the file if it already exists
|
||||||
}
|
}
|
||||||
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
|
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return model.NewRequestError("failed to create HTTP request")
|
return "", model.NewRequestError("failed to create HTTP request")
|
||||||
}
|
}
|
||||||
client := http.Client{}
|
client := http.Client{}
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Check if the error is due to context cancellation
|
// Check if the error is due to context cancellation
|
||||||
if ctx.Err() != nil {
|
if ctx.Err() != nil {
|
||||||
return nil
|
return "", nil
|
||||||
}
|
}
|
||||||
return model.NewRequestError("failed to send HTTP request")
|
return "", model.NewRequestError("failed to send HTTP request")
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return model.NewRequestError("URL is not accessible, status code: " + resp.Status)
|
return "", model.NewRequestError("URL is not accessible, status code: " + resp.Status)
|
||||||
}
|
}
|
||||||
file, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY, os.ModePerm)
|
file, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY, os.ModePerm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return model.NewInternalServerError("failed to open file for writing")
|
return "", model.NewInternalServerError("failed to open file for writing")
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
writer := bufio.NewWriter(file)
|
||||||
|
|
||||||
|
h := md5.New()
|
||||||
|
|
||||||
buf := make([]byte, 64*1024)
|
buf := make([]byte, 64*1024)
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return nil
|
return "", nil
|
||||||
default:
|
default:
|
||||||
n, readErr := resp.Body.Read(buf)
|
n, readErr := resp.Body.Read(buf)
|
||||||
if n > 0 {
|
if n > 0 {
|
||||||
if _, writeErr := file.Write(buf[:n]); writeErr != nil {
|
if _, writeErr := writer.Write(buf[:n]); writeErr != nil {
|
||||||
return model.NewInternalServerError("failed to write to file")
|
return "", model.NewInternalServerError("failed to write to file")
|
||||||
}
|
}
|
||||||
|
h.Write(buf[:n])
|
||||||
}
|
}
|
||||||
if readErr != nil {
|
if readErr != nil {
|
||||||
if readErr == io.EOF {
|
if readErr == io.EOF {
|
||||||
return nil // Download completed successfully
|
if err := writer.Flush(); err != nil {
|
||||||
|
return "", model.NewInternalServerError("failed to flush writer")
|
||||||
|
}
|
||||||
|
md5Sum := hex.EncodeToString(h.Sum(nil))
|
||||||
|
return md5Sum, nil // Download completed successfully
|
||||||
}
|
}
|
||||||
if ctx.Err() != nil {
|
if ctx.Err() != nil {
|
||||||
return nil // Context cancelled, return nil
|
return "", nil // Context cancelled, return nil
|
||||||
}
|
}
|
||||||
return model.NewInternalServerError("failed to read response body")
|
return "", model.NewInternalServerError("failed to read response body")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -566,7 +577,7 @@ func CreateServerDownloadTask(uid uint, url, filename, description string, resou
|
|||||||
return nil, model.NewRequestError("server is busy, please try again later")
|
return nil, model.NewRequestError("server is busy, please try again later")
|
||||||
}
|
}
|
||||||
|
|
||||||
file, err := dao.CreateFile(filename, description, resourceID, &storageID, storageKeyUnavailable, "", 0, uid)
|
file, err := dao.CreateFile(filename, description, resourceID, &storageID, storageKeyUnavailable, "", 0, uid, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("failed to create file in db: ", err)
|
log.Error("failed to create file in db: ", err)
|
||||||
return nil, model.NewInternalServerError("failed to create file in db")
|
return nil, model.NewInternalServerError("failed to create file in db")
|
||||||
@@ -617,11 +628,14 @@ func CreateServerDownloadTask(uid uint, url, filename, description string, resou
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
hash := ""
|
||||||
|
|
||||||
for i := range 3 {
|
for i := range 3 {
|
||||||
if done.Load() {
|
if done.Load() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := downloadFile(ctx, url, tempPath); err != nil {
|
hash, err = downloadFile(ctx, url, tempPath)
|
||||||
|
if err != nil {
|
||||||
log.Error("failed to download file: ", err)
|
log.Error("failed to download file: ", err)
|
||||||
if i == 2 {
|
if i == 2 {
|
||||||
_ = dao.DeleteFile(file.UUID)
|
_ = dao.DeleteFile(file.UUID)
|
||||||
@@ -682,7 +696,7 @@ func CreateServerDownloadTask(uid uint, url, filename, description string, resou
|
|||||||
_ = os.Remove(tempPath)
|
_ = os.Remove(tempPath)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := dao.SetFileStorageKeyAndSize(file.UUID, storageKey, size); err != nil {
|
if err := dao.SetFileStorageKeyAndSize(file.UUID, storageKey, size, hash); err != nil {
|
||||||
log.Error("failed to set file storage key: ", err)
|
log.Error("failed to set file storage key: ", err)
|
||||||
_ = dao.DeleteFile(file.UUID)
|
_ = dao.DeleteFile(file.UUID)
|
||||||
_ = iStorage.Delete(storageKey)
|
_ = iStorage.Delete(storageKey)
|
||||||
|
@@ -5,14 +5,21 @@ import (
|
|||||||
"nysoure/server/config"
|
"nysoure/server/config"
|
||||||
"nysoure/server/dao"
|
"nysoure/server/dao"
|
||||||
"nysoure/server/model"
|
"nysoure/server/model"
|
||||||
|
"nysoure/server/search"
|
||||||
|
"nysoure/server/utils"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/gofiber/fiber/v3"
|
||||||
"github.com/gofiber/fiber/v3/log"
|
"github.com/gofiber/fiber/v3/log"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
maxSearchQueryLength = 100
|
||||||
|
)
|
||||||
|
|
||||||
type ResourceParams struct {
|
type ResourceParams struct {
|
||||||
Title string `json:"title" binding:"required"`
|
Title string `json:"title" binding:"required"`
|
||||||
AlternativeTitles []string `json:"alternative_titles"`
|
AlternativeTitles []string `json:"alternative_titles"`
|
||||||
@@ -67,6 +74,9 @@ func CreateResource(uid uint, params *ResourceParams) (uint, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("AddNewResourceActivity error: ", err)
|
log.Error("AddNewResourceActivity error: ", err)
|
||||||
}
|
}
|
||||||
|
if err := search.AddResourceToIndex(r); err != nil {
|
||||||
|
log.Error("AddResourceToIndex error: ", err)
|
||||||
|
}
|
||||||
return r.ID, nil
|
return r.ID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,14 +132,16 @@ func parseResourceIfPresent(line string, host string) *model.ResourceView {
|
|||||||
return &v
|
return &v
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetResource(id uint, host string) (*model.ResourceDetailView, error) {
|
func GetResource(id uint, host string, ctx fiber.Ctx) (*model.ResourceDetailView, error) {
|
||||||
r, err := dao.GetResourceByID(id)
|
r, err := dao.GetResourceByID(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
err = dao.AddResourceViewCount(id)
|
if ctx != nil && ctx.Locals("real_user") == true {
|
||||||
if err != nil {
|
err = dao.AddResourceViewCount(id)
|
||||||
log.Error("AddResourceViewCount error: ", err)
|
if err != nil {
|
||||||
|
log.Error("AddResourceViewCount error: ", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
v := r.ToDetailView()
|
v := r.ToDetailView()
|
||||||
if host != "" {
|
if host != "" {
|
||||||
@@ -151,13 +163,209 @@ func GetResourceList(page int, sort model.RSort) ([]model.ResourceView, int, err
|
|||||||
return views, totalPages, nil
|
return views, totalPages, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func SearchResource(keyword string, page int) ([]model.ResourceView, int, error) {
|
// splitQuery splits the input query string into keywords, treating quoted substrings (single or double quotes)
|
||||||
resources, totalPages, err := dao.Search(keyword, page, pageSize)
|
// as single keywords and supporting escape characters for quotes. Spaces outside quotes are used as separators.
|
||||||
|
func splitQuery(query string) []string {
|
||||||
|
var keywords []string
|
||||||
|
|
||||||
|
query = strings.TrimSpace(query)
|
||||||
|
if query == "" {
|
||||||
|
return keywords
|
||||||
|
}
|
||||||
|
|
||||||
|
l, r := 0, 0
|
||||||
|
inQuote := false
|
||||||
|
quoteChar := byte(0)
|
||||||
|
|
||||||
|
for r < len(query) {
|
||||||
|
if (query[r] == '"' || query[r] == '\'') && (r == 0 || query[r-1] != '\\') {
|
||||||
|
if !inQuote {
|
||||||
|
inQuote = true
|
||||||
|
quoteChar = query[r]
|
||||||
|
l = r + 1
|
||||||
|
} else if query[r] == quoteChar {
|
||||||
|
if r > l {
|
||||||
|
keywords = append(keywords, strings.TrimSpace(query[l:r]))
|
||||||
|
}
|
||||||
|
inQuote = false
|
||||||
|
r++
|
||||||
|
l = r
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
} else if !inQuote && query[r] == ' ' {
|
||||||
|
if r > l {
|
||||||
|
keywords = append(keywords, strings.TrimSpace(query[l:r]))
|
||||||
|
}
|
||||||
|
for r < len(query) && query[r] == ' ' {
|
||||||
|
r++
|
||||||
|
}
|
||||||
|
l = r
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
r++
|
||||||
|
}
|
||||||
|
|
||||||
|
if l < len(query) {
|
||||||
|
keywords = append(keywords, strings.TrimSpace(query[l:r]))
|
||||||
|
}
|
||||||
|
|
||||||
|
return keywords
|
||||||
|
}
|
||||||
|
|
||||||
|
func searchWithKeyword(keyword string) ([]uint, error) {
|
||||||
|
resources := make([]uint, 0)
|
||||||
|
|
||||||
|
if len([]rune(keyword)) <= maxTagLength {
|
||||||
|
exists, err := dao.ExistsTag(keyword)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if exists {
|
||||||
|
t, err := dao.GetTagByName(keyword)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
res, err := dao.GetResourcesIdWithTag(t.ID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
resources = append(resources, res...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
searchResult, err := search.SearchResource(keyword)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
resources = append(resources, searchResult...)
|
||||||
|
|
||||||
|
return resources, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func SearchResource(query string, page int) ([]model.ResourceView, int, error) {
|
||||||
|
if len([]rune(query)) > maxSearchQueryLength {
|
||||||
|
return nil, 0, model.NewRequestError("Search query is too long")
|
||||||
|
}
|
||||||
|
|
||||||
|
start := (page - 1) * pageSize
|
||||||
|
end := start + pageSize
|
||||||
|
resources := make([]uint, 0)
|
||||||
|
|
||||||
|
checkTag := func(tag string) error {
|
||||||
|
if len([]rune(tag)) > maxTagLength {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
exists, err := dao.ExistsTag(tag)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if exists {
|
||||||
|
t, err := dao.GetTagByName(tag)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
res, err := dao.GetResourcesIdWithTag(t.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
resources = append(resources, res...)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// check tag
|
||||||
|
if err := checkTag(query); err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// check tag after removing spaces
|
||||||
|
trimmed := utils.RemoveSpaces(query)
|
||||||
|
if trimmed != query {
|
||||||
|
if err := checkTag(trimmed); err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// split query to search
|
||||||
|
keywords := splitQuery(query)
|
||||||
|
var temp []uint
|
||||||
|
haveTag := false
|
||||||
|
for _, keyword := range keywords {
|
||||||
|
if len([]rune(keyword)) <= maxTagLength {
|
||||||
|
exists, err := dao.ExistsTag(keyword)
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
if exists {
|
||||||
|
haveTag = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if haveTag {
|
||||||
|
first := true
|
||||||
|
for _, keyword := range keywords {
|
||||||
|
if keyword == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if utils.OnlyPunctuation(keyword) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := searchWithKeyword(keyword)
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
if len(res) == 0 && search.IsStopWord(keyword) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if first {
|
||||||
|
temp = utils.RemoveDuplicate(res)
|
||||||
|
first = false
|
||||||
|
} else {
|
||||||
|
temp1 := make([]uint, 0)
|
||||||
|
for _, id := range temp {
|
||||||
|
for _, id2 := range res {
|
||||||
|
if id == id2 {
|
||||||
|
temp1 = append(temp1, id)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
temp = temp1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
res, err := searchWithKeyword(query)
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
temp = res
|
||||||
|
}
|
||||||
|
resources = append(resources, temp...)
|
||||||
|
resources = utils.RemoveDuplicate(resources)
|
||||||
|
|
||||||
|
if start >= len(resources) {
|
||||||
|
return []model.ResourceView{}, 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
total := len(resources)
|
||||||
|
totalPages := (total + pageSize - 1) / pageSize
|
||||||
|
if start >= total {
|
||||||
|
return []model.ResourceView{}, totalPages, nil
|
||||||
|
}
|
||||||
|
if end > total {
|
||||||
|
end = total
|
||||||
|
}
|
||||||
|
idsPage := resources[start:end]
|
||||||
|
|
||||||
|
resourcesPage, err := dao.BatchGetResources(idsPage)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
var views []model.ResourceView
|
var views []model.ResourceView
|
||||||
for _, r := range resources {
|
for _, r := range resourcesPage {
|
||||||
views = append(views, r.ToView())
|
views = append(views, r.ToView())
|
||||||
}
|
}
|
||||||
return views, totalPages, nil
|
return views, totalPages, nil
|
||||||
@@ -177,7 +385,7 @@ func DeleteResource(uid, id uint) error {
|
|||||||
return model.NewUnAuthorizedError("You have not permission to delete this resource")
|
return model.NewUnAuthorizedError("You have not permission to delete this resource")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
r, err := GetResource(id, "")
|
r, err := GetResource(id, "", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -191,6 +399,9 @@ func DeleteResource(uid, id uint) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error updating cached tag list:", err)
|
log.Error("Error updating cached tag list:", err)
|
||||||
}
|
}
|
||||||
|
if err := search.RemoveResourceFromIndex(id); err != nil {
|
||||||
|
log.Error("RemoveResourceFromIndex error: ", err)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,6 +483,9 @@ func EditResource(uid, rid uint, params *ResourceParams) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("AddUpdateResourceActivity error: ", err)
|
log.Error("AddUpdateResourceActivity error: ", err)
|
||||||
}
|
}
|
||||||
|
if err := search.AddResourceToIndex(r); err != nil {
|
||||||
|
log.Error("AddResourceToIndex error: ", err)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,6 +9,10 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
maxTagLength = 20
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// Start a goroutine to delete unused tags every hour
|
// Start a goroutine to delete unused tags every hour
|
||||||
go func() {
|
go func() {
|
||||||
@@ -25,6 +29,9 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func CreateTag(uid uint, name string) (*model.TagView, error) {
|
func CreateTag(uid uint, name string) (*model.TagView, error) {
|
||||||
|
if len([]rune(name)) > maxTagLength {
|
||||||
|
return nil, model.NewRequestError("Tag name too long")
|
||||||
|
}
|
||||||
canUpload, err := checkUserCanUpload(uid)
|
canUpload, err := checkUserCanUpload(uid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error checking user permissions:", err)
|
log.Error("Error checking user permissions:", err)
|
||||||
|
13
server/utils/slice.go
Normal file
13
server/utils/slice.go
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
func RemoveDuplicate[T comparable](slice []T) []T {
|
||||||
|
seen := make(map[T]struct{})
|
||||||
|
var result []T
|
||||||
|
for _, v := range slice {
|
||||||
|
if _, ok := seen[v]; !ok {
|
||||||
|
seen[v] = struct{}{}
|
||||||
|
result = append(result, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
21
server/utils/string.go
Normal file
21
server/utils/string.go
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"regexp"
|
||||||
|
"unicode"
|
||||||
|
)
|
||||||
|
|
||||||
|
func RemoveSpaces(s string) string {
|
||||||
|
reg := regexp.MustCompile(`\s+`)
|
||||||
|
return reg.ReplaceAllString(s, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
func OnlyPunctuation(s string) bool {
|
||||||
|
for _, r := range s {
|
||||||
|
if unicode.IsPunct(r) || unicode.IsSpace(r) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
Reference in New Issue
Block a user