-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:piterator-org/luogu-discussion-archive
- Loading branch information
Showing
6 changed files
with
292 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# 许可证 | ||
|
||
版权所有 © 2023 Piterator。 | ||
|
||
## 引言 | ||
|
||
「洛谷讨论存档」(Luogu Discussion Archive)是由 Piterator 开发的软件,该软件中包含的所有文本、图形图像和源代码的版权在没有额外条款明确指明的情况下均属于 Piterator。 | ||
|
||
Piterator 保留对「洛谷讨论存档」及其中包含的所有 Piterator 拥有的文本、图形图像和软件的所有权利。 | ||
|
||
「洛谷讨论存档」公开的源代码仅可作为参考与学习之用途。 | ||
|
||
## 贡献者许可协议(CLA) | ||
|
||
贡献源代码即代表您同意将所撰写的相关源代码的著作权按本许可证不可撤销地授予 Piterator。 | ||
|
||
## 第三方资源 | ||
|
||
EXLG 徽标:由 [haraki](https://github.com/haraki-argon)<!-- @haraki-argon --> 设计,其著作权归 [EXLG 团队](https://github.com/extend-luogu) 所有。 | ||
|
||
## 第三方软件许可证 | ||
|
||
以下列举了部分该软件使用到的第三方软件的许可证。完整软件列表请参阅 [pnpm-lock.yaml](./pnpm-lock.yaml)。 | ||
|
||
### [Bootstrap](https://github.com/twbs/bootstrap/blob/main/LICENSE) | ||
|
||
```plaintext | ||
The MIT License (MIT) | ||
Copyright (c) 2011-2023 The Bootstrap Authors | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
``` | ||
|
||
### [Next.js](https://github.com/vercel/next.js/blob/canary/license.md) | ||
|
||
```plaintext | ||
The MIT License (MIT) | ||
Copyright (c) 2023 Vercel, Inc. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
``` | ||
|
||
### [React](https://github.com/facebook/react/blob/main/LICENSE) | ||
|
||
```plaintext | ||
MIT License | ||
Copyright (c) Meta Platforms, Inc. and affiliates. | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
``` | ||
|
||
### 洛谷 3 | ||
|
||
该软件引用了洛谷 3 用户名颜色的样式表。 | ||
|
||
合理使用,著作权归[上海洛谷网络科技有限公司](https://www.luogu.com.cn/)所有。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,124 @@ | ||
import prisma from "@/lib/prisma"; | ||
import { notFound, redirect } from "next/navigation"; | ||
import { notFound } from "next/navigation"; | ||
import Link from "next/link"; | ||
import Image from "next/image"; | ||
import Content from "@/components/replies/Content"; | ||
import UserInfo from "@/components/UserInfo"; | ||
import serializeReply from "@/lib/serialize-reply"; | ||
import { getUserAvatarUrl, getUserUrl } from "@/lib/luogu"; | ||
|
||
export const metadata = { title: "金玉良言 - 洛谷帖子保存站" }; | ||
|
||
const REPLIES_PER_PAGE = parseInt(process.env.REPLIES_PER_PAGE ?? "10", 10); | ||
|
||
export default async function Page({ params }: { params: { rid: string } }) { | ||
const id = parseInt(params.rid, 10); | ||
if (Number.isNaN(id)) notFound(); | ||
const { discussionId } = | ||
const replyRaw = | ||
(await prisma.reply.findUnique({ | ||
select: { discussionId: true }, | ||
select: { | ||
id: true, | ||
author: true, | ||
time: true, | ||
content: true, | ||
discussion: { | ||
select: { | ||
id: true, | ||
snapshots: { | ||
select: { title: true, authorId: true }, | ||
orderBy: { time: "desc" }, | ||
take: 1, | ||
}, | ||
}, | ||
}, | ||
}, | ||
where: { id }, | ||
})) ?? notFound(); | ||
const reply = { | ||
...replyRaw, | ||
...(await serializeReply(replyRaw.discussion.id, replyRaw)), | ||
}; | ||
const pages = Math.ceil( | ||
(await prisma.reply.count({ | ||
where: { id: { lte: id }, discussionId }, | ||
where: { id: { lte: id }, discussionId: reply.discussion.id }, | ||
})) / REPLIES_PER_PAGE | ||
); | ||
return redirect(`/${discussionId}/${pages}#${params.rid}`); | ||
// return redirect(`/${discussionId}/${pages}#${params.rid}`); | ||
return ( | ||
<div className="row px-2 px-md-0"> | ||
<div className="col-xl-9 col-lg-10 col-md-11 col-12 mt-3 mb-3x mx-auto"> | ||
<div className="pb-3 mb-4x position-relative"> | ||
<div className="bg-white rounded-4 shadow"> | ||
<div className="px-4 pt-2 pb-4 position-relative"> | ||
<Content | ||
discussionAuthor={reply.discussion.snapshots[0].authorId} | ||
content={reply.content} | ||
usersMetioned={reply.usersMetioned} | ||
/> | ||
<span | ||
className="text-end text-body-tertiary d-block d-md-none" | ||
style={{ fontSize: ".8rem" }} | ||
> | ||
{reply.time} | ||
</span> | ||
</div> | ||
</div> | ||
<div | ||
className="position-absolute" | ||
style={{ bottom: "-1.6em", left: ".8em" }} | ||
> | ||
<a | ||
href={getUserUrl(reply.author.id)} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
<Image | ||
src={getUserAvatarUrl(reply.author.id)} | ||
className="rounded-circle shadow" | ||
width={72} | ||
height={72} | ||
alt={reply.author.id.toString()} | ||
/> | ||
</a> | ||
</div> | ||
<div | ||
className="ps-6 position-absolute reply-meta-bottom" | ||
style={{ left: 0, right: 0 }} | ||
> | ||
<div> | ||
<UserInfo user={reply.author} /> | ||
<span | ||
className="float-end text-body-tertiary d-none d-md-inline" | ||
style={{ marginRight: ".8em" }} | ||
> | ||
{reply.time} | ||
</span> | ||
</div> | ||
<div className="fw-medium text-body-tertiary d-none d-md-block"> | ||
于帖子{" "} | ||
<Link | ||
className="text-decoration-none" | ||
href={`/${reply.discussion.id}/${pages}#${params.rid}`} | ||
> | ||
{reply.discussion.snapshots[0].title} | ||
<span className="fw-normal">(第 {pages} 页)</span> | ||
</Link> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="mt-5 bg-white rounded-4 shadow d-md-none px-4 py-3"> | ||
<div className="fw-medium text-body-tertiary"> | ||
于帖子{" "} | ||
<Link | ||
className="text-decoration-none" | ||
href={`/${reply.discussion.id}/${pages}#${params.rid}`} | ||
> | ||
{reply.discussion.snapshots[0].title} | ||
<span className="fw-normal">(第 {pages} 页)</span> | ||
</Link> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters