Skip to content

Commit

Permalink
feat: support legacy API and new API
Browse files Browse the repository at this point in the history
  • Loading branch information
eallion committed Aug 23, 2024
1 parent ece55e4 commit 67ea7f1
Show file tree
Hide file tree
Showing 11 changed files with 462 additions and 597 deletions.
150 changes: 74 additions & 76 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<p align="center"><a href="https://usememos.com"><img height="64px" src="https://raw.githubusercontent.com/eallion/memos.top/main/assets/img/logo-full.webp" alt="✍️ memos" /></a></p>

<p align="center">Memos Top. A static page rendered with the Memos API.</p>
<p align="center">Simple HTML, Pure CSS, Vanilla JS.</p>
<p align="center">Memos Top. 通过 Memos API 渲染的静态网页。</p>
<p align="center">简单的 HTML、纯净的 CSS、原生的 JS。</p>

<p align="center">
<img src="https://img.shields.io/badge/Memos-Top-orange" />
Expand All @@ -17,136 +17,139 @@
<a href="https://memos.top/" target="_blank"><img alt="Memos Top" src="https://raw.githubusercontent.com/eallion/memos.top/main/screenshot.png"></a>
</p>

English | [中文](./README_cn.md)
中文 | [English](./README_en.md)

> [!TIP]
> 已支持老版(< `v0.22.0`) 和新版(>= `v0.22.0`)两种 API,请配置 `APIVersion`
> [!NOTE]
> If you're looking to embed your Mastodon toots on your website, you might want to check out this project.
> <https://github.com/eallion/mastodon-embed-feed-timeline>
> 如果你想把你的 Mastodon (长毛象)的嘟文嵌入到自己的网页中,你可以参考这个项目。
> <https://github.com/eallion/mastodon-embed-timeline>
### WebStack
### 前端框架

> Darkmode Support
> Mobile Friendly
> 暗黑模式适配
> 移动端自适应
- [**Memos**](https://github.com/usememos/memos)
- [Highlight.js](https://github.com/highlightjs/highlight.js)
- [Markedjs](https://github.com/markedjs/marked)
- [Moment](https://github.com/moment/moment)
- [Vanilla-lazyload](https://github.com/verlok/vanilla-lazyload)
- [ViewImage.js](https://github.com/Tokinx/ViewImage)

### Usage
### 使用方法

1. Clone this repo or Download [Release](https://github.com/eallion/memos.top/archive/refs/heads/main.zip) to self-hosted.
1. `clone`本仓库或[下载](https://github.com/eallion/memos.top/archive/refs/heads/main.zip)后部署 :

```bash
git clone https://github.com/eallion/memos.top
```

2. Setting
2. 设置

Replace the default value in `index.html`:
`index.html` 文件中调整以下设置:

```html
<script type="text/javascript">
var memos = {
host: 'https://demo.usememos.com/', // Your Memos, with '/' end.
limit: '10', // Pagination to show.
creatorId: '1', // The old instance is 101, and the new instance is 1.
domId: '#memos', // Default #memos.
username: 'memos', // You can customize the display ID that is not related to memos.
name: 'Official Demo', // You can customize the displayed full name, that is not related to memos.
}
</script>
<script type="text/javascript">
var memos = {
host: 'https://demo.usememos.com/', // 修改为自己部署 Memos 的网址,末尾有 / 斜杠。
limit: '10', // 每页显示的条数,默认显示 10 条。
creatorId: '1', // 老的实例是 101,新的实例是1。 https://demo.usememos.com/u/1
domId: '#memos', // 默认为 #memos ,一般不用修改。
username: 'memos', // 自定义显示在前端的 ID。
name: 'Official Demo', // 自定义显示在前端的全名。
language: 'zh-CN', // `en` `zh-CN` 等,用于显示相对时间。
APIVersion: 'new', // `new` 或者 `legacy`,Memos API 版本, 小于 `v0.22.0`: 填写:`legacy`,大于等于 `v0.22.0`:填写`new`。
}
</script>
```

3. Logo & Avatar(*Option*)
3. 网站图标和头像(*可选*)

Replace the Logo and Avatar in the `assets/img` folder.
`assets/img` 目录中,替换成自己的图标和头像。

- `logo.webp` is favicon
- `avatar.jpg` is your icon
- `logo.webp` 是网站图标,显示在浏览器标签上。
- `avatar.jpg` 是头像,显示在每条 Memos 的左侧。

4. Upload
[ ] 待办:获取 Memos 的默认头像:https://memos.apidocumentation.com/reference#tag/userservice/GET/file/{name}/avatar

Upload file `index.html` and folder `assets` to your web server. Enjoy!
4. 上传

### Hosted by GitHub Pages
上传 `index.html` 文件 `assets` 目录及目录中的所有文件到网站根目录。

### 部署到 GitHub Pages

> Demo: <https://www.memos.top>
1. Fork this
2. Setting as #[Usage.2]()
3. Go to your own `memos.top` repo - `Setting` - `Pages` - `Deploy from a branch` - `Branch(main/root)`
1. Fork 本仓库
2. 按照 #[使用方法.2]() 设置自己的 API
3. 转到自己的 `memos.top` 仓库的设置 - `Setting` - `Pages` - `Deploy from a branch` - `Branch(main/root)`

### Hosted by Vercel
### 部署到 Vercel

> Demo: <https://memos.top>
1. Fork this
2. Setting as #[Usage.2]()
3. Go to your Vercel dash
4. Import GitHub repo
5. Configure Project default
6. Deploy
1. Fork 本仓库
2. 按照 #[使用方法.2]() 设置自己的 API
3. 进入自己的 Vercel 面板
4. 新建一个 Project ,导入 GitHub 上的仓库
5. 按默认设置不用改动,直接点`Deploy`
6. 中国大陆可能需要绑定一个自定义域名才能访问 Vercel

### Other
### 其他平台

Yes! You can deploy to Cloudflare Pages or Netlify and so on.
你也可以把这个静态页面部署到 Cloudflare Pages 或者 Netlify 等平台。

### Tips
### 使用技巧

<details>
<summary>
How to post your memos: 👇👇👇
<details><summary>
发布 Memos 时的格式: 👈👈👈
</summary>

1. Bilibili. Just URL. `BV/AV` support. `b23.tv` not support.
1. Bilibili 视频。分享的视频链接。支持`BV/AV`号。暂不支持`b23.tv`链接。

```
https://www.bilibili.com/video/BV1Sd4y1b7yg/
```

2. Youtube. Just URL.
2. Youtube 视频。分享的视频链接。

```
https://www.youtube.com/watch?v=mNK6h1dfy2o
```

3. Youku. Just URL.
3. Youku 视频。分享的视频链接。

```
https://v.youku.com/v_show/id_XNTkyMjkxNTEyOA==.html
```

4. QQ Video. Just URL.
4. 腾讯视频。分享的视频链接。

```
https://v.qq.com/x/cover/mzc00200z47sdeu/m0044zpag6c.html
```

5. Spotify. Share URL. `track/album` support.
5. Spotify 音乐。分享的链接。支持`track/album`

```
https://open.spotify.com/track/6Uq8BnOxvXJsQiJ2XqfO5P
```

6. Netease music. Just URL.
6. 网易云音乐。链接即可。

```
https://music.163.com/#/song?id=4153490
```

7. QQ music. Support `sondmid` only, not `songid`.
7. QQ 音乐。只支持 `sondmid` 不支持 `songid`

```
https://y.qq.com/n/ryqq/songDetail/004W3BfK46dMXk
```

8. Douban. Just URL. Need your own API.
8. 豆瓣。链接即可。需要自己的 API

> If enable. You need to uncomment [`// fetchDB()`](https://github.com/eallion/memos.top/blob/main/assets/js/main.js#L208) and replace api [`var dbAPI = "https://api.example.com/"`](https://github.com/eallion/memos.top/blob/main/assets/js/main.js#L218) in [`assets/js/main.js`](https://github.com/eallion/memos.top/blob/main/assets/js/main.js)
> 如果要启动解析豆瓣功能,需要取消注释 [`// fetchDB()`](https://github.com/eallion/memos.top/blob/main/assets/js/main.js#L208) 然后替换成可用的 API [`var dbAPI = "https://api.example.com/"`](https://github.com/eallion/memos.top/blob/main/assets/js/main.js#L218),这两行位于: [`assets/js/main.js`](https://github.com/eallion/memos.top/blob/main/assets/js/main.js)
```
https://book.douban.com/subject/2567698/
Expand All @@ -155,32 +158,27 @@ https://movie.douban.com/subject/1889243/

</details>

### [LICENSE GLWTPL](https://github.com/me-shaon/GLWTPL)
### [许可证 GLWTPL](https://github.com/me-shaon/GLWTPL)

```
GLWT(Good Luck With That) Public License
Copyright (c) Everyone, except Author
Everyone is permitted to copy, distribute, modify, merge, sell, publish,
sublicense or whatever they want with this software but at their OWN RISK.
GLWT(Good Luck With That,祝你好运)公共许可证
版权所有© 每个人,除了作者
Preamble
任何人都被允许复制、分发、修改、合并、销售、出版、再授权或
任何其它操作,但风险自负。
The author has absolutely no clue what the code in this project does.
It might just work or not, there is no third option.
作者对这个项目中的代码一无所知。
代码处于可用或不可用状态,没有第三种情况。
GOOD LUCK WITH THAT PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION, AND MODIFICATION
祝你好运公共许可证
复制、分发和修改的条款和条件
0. You just DO WHATEVER YOU WANT TO as long as you NEVER LEAVE A
TRACE TO TRACK THE AUTHOR of the original product to blame for or hold
responsible.
0 :在不导致作者被指责或承担责任的情况下,你可以做任何你想
要做的事情。
IN NO EVENT SHALL THE AUTHORS 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.
无论是在合同行为、侵权行为或其它因使用本软件产生的情形,作
者不对任何索赔、损害承担责任。
Good luck and Godspeed.
祖宗保佑。
```
Loading

0 comments on commit 67ea7f1

Please sign in to comment.