24 |
25 | 
26 |
--------------------------------------------------------------------------------
/src/pages/sponsor/ways.en.mdx:
--------------------------------------------------------------------------------
1 | # Donations and sponsoring
2 |
3 | **Open source is hard. I am the single person maintaining this project.**
4 |
5 | If you consider `onedrive-vercel-index` to be:
6 |
7 | - Good looking
8 | - Comparably performant
9 | - Pleasant community with responses directly from me
10 |
11 | Please donate, it would mean the whole world to me! Thank you. ❤️
12 |
13 | ## 爱发电
14 |
15 | [爱发电 · 连接创作者与粉丝的会员制平台](https://afdian.net/@spencerwoo)
16 |
17 | ## Patreon
18 |
19 | [Spencer Woo is creating open source projects | Patreon](https://patreon.com/spencerwoo)
20 |
21 | ## Alipay and Wechat Pay
22 |
23 | | Alipay | WeChat Pay |
24 | | :-----------------------------: | :------------------------------------: |
25 | |  |  |
26 |
27 | Thanks for all the love and support!
28 |
--------------------------------------------------------------------------------
/src/pages/docs/migration/if-you-deployed-before-2022.zh.mdx:
--------------------------------------------------------------------------------
1 | # 迁移到 2022 年的新版本
2 |
3 | 在 2022 年,此项目有了一个重大更新,你不再需要使用你自己的 `client_id` 、 `client_secret` 等等信息。详情请参考 [这个公告](https://github.com/spencerwooo/onedrive-vercel-index/discussions/215)。
4 |
5 | 你可以从头开始部署,详情请参考 [立即上手](../docs/getting-started),或者通过新的 OAuth 步骤迁移到新版本。
6 |
7 | ## 从旧版本迁移
8 |
9 | - 你需要创建一个 Redis 数据库,并且将它的访问链接填写在 Vercel 的 `REDIS_URL` 环境变量里。我们推荐使用 [Upstash](https://vercel.com/integrations/upstash)。
10 | - 你需要还原你在 `config/api.config.js` 里的一些更改。尤其是 `clientId` 与 `obfuscatedClientSecret` 要和下面相同:
11 |
12 | ```js
13 | clientId: "d87bcc39-1750-4ca0-ad54-f8d0efbb2735",
14 | obfuscatedClientSecret: "U2FsdGVkX1830zo3/pFDqaBCVBb37iLw3WnBDWGF9GIB2f4apzv0roemp8Y+iIxI3Ih5ecyukqELQEGzZlYiWg=="
15 | ```
16 |
17 | - 你还需要填写 `config/site.config.js` 里的 `userPrincipalName` **通常是你的微软账户** 以进行 OAuth 步骤。
18 | - 你可以删除 Vercel 里的旧环境变量了,例如 `CLIENT_SECRET` 、 `ACCESS_TOKEN` 以及 `REFRESH_TOKEN`。
19 |
--------------------------------------------------------------------------------
/src/pages/index.en.mdx:
--------------------------------------------------------------------------------
1 | ---
2 | title: Documentation
3 | search: false
4 | ---
5 |
6 | import Bleed from 'nextra-theme-docs/bleed'
7 | import Callout from 'nextra-theme-docs/callout'
8 | import Features from '../components/features'
9 |
10 |
onedrive-vercel-index
11 |
12 |
13 | OneDrive public directory listing, powered by Vercel and Next.js.
14 |
15 |
16 |
17 |
18 |
19 |
20 | 🍌 Showcase, share, preview, and download files inside your OneDrive with `onedrive-vercel-index`. Simple setup, serverless, and open source. More importantly, we are pretty (●'◡'●)
21 |
22 |
26 |
27 | 
28 |
--------------------------------------------------------------------------------
/src/pages/docs/features/multi-file-folder-download.en.mdx:
--------------------------------------------------------------------------------
1 | import Callout from 'nextra-theme-docs/callout'
2 | import Video from '../../../components/video'
3 |
4 | # Multi-file and folder download
5 |
6 |
7 | This may be slow in reality. I would suggest using it for only downloading a batch of small files in large quantities,
8 | instead of a couple of large files.
9 |
10 |
11 |
12 |
13 | We use JSZip to download all files in-browser and compress them into file blobs, which are then downloaded to your device as a `zip` file.
14 |
15 | This is extremely useful if a series of small files are to be downloaded, but it could be time consuming if used for bulk-downloading a few large files.
16 |
17 | Folders are traversed and recursively fetched into the compressed zip. Multiple files or folders can be selected and downloaded side-by-side.
18 |
19 | Discussed in PR #177 and #169.
20 |
--------------------------------------------------------------------------------
/src/style.css:
--------------------------------------------------------------------------------
1 | @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700;800&display=swap');
2 |
3 | html,
4 | body {
5 | font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
6 | Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
7 | }
8 |
9 | .mt-8 {
10 | margin-top: 2rem;
11 | }
12 |
13 | .dark .invert-on-dark {
14 | filter: invert(1) brightness(1.8);
15 | }
16 |
17 | body {
18 | background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 300px),
19 | fixed 0 0 / 20px 20px radial-gradient(#d1d1d1 1px, transparent 0),
20 | fixed 10px 10px / 20px 20px radial-gradient(#d1d1d1 1px, transparent 0);
21 | }
22 |
23 | .dark body {
24 | background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, #111 300px),
25 | fixed 0 0 / 20px 20px radial-gradient(#313131 1px, transparent 0),
26 | fixed 10px 10px / 20px 20px radial-gradient(#313131 1px, transparent 0);
27 | }
28 |
--------------------------------------------------------------------------------
/src/pages/docs/features/search-for-files-and-folders.en.mdx:
--------------------------------------------------------------------------------
1 | import Callout from 'nextra-theme-docs/callout'
2 |
3 | # Search for files and folders
4 |
5 | Native search is now supported! Use `Ctrl` or `⌘ + K` to open the search box, and `ESC` to close.
6 |
7 | 
8 |
9 | ## Caveats
10 |
11 | - Limited support as the search provided by Microsoft Graph API is not ideal.
12 | - Extremely limited support for CJK search.
13 |
14 | ## Security concerns
15 |
16 | Besides caveats above:
17 |
18 | - **Search results still include your protected directories**
19 | - This means your **file names** (whether inside the protected folder or not) are exposed.
20 | - Visitors still need to enter passwords if they want to access the protected file contents.
21 |
22 |
23 | Discussion here: [Supporting search for all versions of OneDrive
24 | #295](https://github.com/spencerwooo/onedrive-vercel-index/discussions/295)
25 |
26 |
--------------------------------------------------------------------------------
/src/components/features.js:
--------------------------------------------------------------------------------
1 | import { useRouter } from 'next/router'
2 | import styles from './features.module.css'
3 |
4 | const featureTranslations = {
5 | en: {
6 | 'free-to-host': 'Completely free to host 💸',
7 | 'setup-time': 'Setup time < 15 mins ⏱',
8 | 'fast-n-responsive': 'Fast ⚡ and responsive 💦',
9 | 'highly-customisable': 'Highly customisable ⚒',
10 | },
11 | zh: {
12 | 'free-to-host': '部署全程免费 💸',
13 | 'setup-time': '配置时间 < 15 分钟 ⏱',
14 | 'fast-n-responsive': '极快 ⚡ 且支持响应式布局 💦',
15 | 'highly-customisable': '高度定制化 ⚒',
16 | },
17 | }
18 |
19 | export default function Features() {
20 | const { locale, defaultLocale } = useRouter()
21 |
22 | return (
23 |
30 | )
31 | }
32 |
--------------------------------------------------------------------------------
/src/pages/docs/features/customise-direct-link.zh.mdx:
--------------------------------------------------------------------------------
1 | # 自定义文件直链
2 |
3 | ## TL;DR
4 |
5 | 你可以将文件名以及文件扩展名(或者任何名字)附加到文件的直链的末尾。所以,原先默认的:
6 |
7 | ```
8 | https://drive.swo.moe/api?path=/🎻%20Genshin%20playlist/【原神】胡桃:啊对对对对.mp4&raw=true
9 | ```
10 |
11 | ……也可以写成这样:
12 |
13 | ```
14 | https://drive.swo.moe/api/name/【原神】胡桃:啊对对对对.mp4?path=/🎻%20Genshin%20playlist/【原神】胡桃:啊对对对对.mp4&raw=true
15 | ```
16 |
17 | ## 注意
18 |
19 | - URL 参数中的 `name` 可以是任何名字,不会影响直链指向原文件下载链接。
20 | - URL 参数中的 `path` 是文件路径,而 URL 参数中的 `raw` 用于让 API 跳转到文件的直链而不是渲染文件预览。
21 | - 我们只是用 URL 参数中的 `path` 来添加一个有效的文件名和扩展名到 API 请求中,这样 URL 的末尾就会是文件名。(不包括后面的 URL query 参数。)
22 |
23 | 
24 |
25 | ## 为什么?有什么用?
26 |
27 | 为了能够将文件(特别是视频文件资源)嵌入到某些服务(例如:[Notion](https://notion.so)),嵌入的直链 URL 中需要包含文件扩展名,以便服务能够正确识别文件类型。
28 |
29 | 相关讨论:
30 |
31 | - [有没有图床功能? #290](https://github.com/spencerwooo/onedrive-vercel-index/discussions/290)
32 | - [Support custom url final component name for Notion #306](https://github.com/spencerwooo/onedrive-vercel-index/pull/306)
33 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 Spencer Woo
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/pages/docs/features/load-video-subtitles.zh.mdx:
--------------------------------------------------------------------------------
1 | import Callout from 'nextra-theme-docs/callout'
2 |
3 | # 添加视频字幕
4 |
5 | 仅支持 WebVTT 字幕文件(即 `.vtt` 后缀)
6 |
7 | 如果你有某个视频的 [WebVTT](https://www.w3.org/TR/webvtt1/) 字幕文件(即 `.vtt` 后缀),你可以将它放在与视频文件的同一个目录下。
8 |
9 | 
10 |
11 | 例如:
12 |
13 | - 拥有视频和字幕的文件夹: [🍡 Genshin PV / PV - Shenhe - 申鹤](https://drive.swo.moe/%F0%9F%8D%A1%20Genshin%20PV/PV%20-%20Shenhe%20-%20%E7%94%B3%E9%B9%A4)
14 | - 拥有字幕的视频: [Collected Miscellany - Shenhe - Fluttering of Frosty Feathers - Genshin Impact.mp4](https://drive.swo.moe/%F0%9F%8D%A1%20Genshin%20PV/PV%20-%20Shenhe%20-%20%E7%94%B3%E9%B9%A4/Collected%20Miscellany%20-%20Shenhe%20-%20Fluttering%20of%20Frosty%20Feathers%20-%20Genshin%20Impact.mp4)
15 |
16 | 简单来说,你的视频和字幕要放在同一个文件夹下,文件名也要一样:
17 |
18 | ```
19 | .
20 | ├── <视频文件名>.mp4
21 | └── <视频文件名>.vtt
22 | ```
23 |
24 | 例如:
25 |
26 | ```
27 | .
28 | ├── Collected Miscellany - Shenhe - Fluttering of Frosty Feathers - Genshin Impact.mp4
29 | └── Collected Miscellany - Shenhe - Fluttering of Frosty Feathers - Genshin Impact.vtt
30 | ```
31 |
--------------------------------------------------------------------------------
/src/pages/docs/faqs/dont-pretend-to-be-owner.en.mdx:
--------------------------------------------------------------------------------
1 | import Callout from 'nextra-theme-docs/callout'
2 |
3 | # Do not pretend to be the site owner?
4 |
5 | If you see this on the third step during initial setup ...
6 |
7 | 
8 |
9 | It is because we need to verify if **you** are really **you** before saving the actual tokens into your database. If you see this, **then the email you defined in `site.config.js` under `userPrincipalName` is wrong.**
10 |
11 | You must configure this email to be **exactly the same** as the one you use to log into your Microsoft account during the second step of OAuth. Check for typos, domain names, and incorrect capitalisations. **Must be exactly the same!** 😡
12 |
13 |
14 | Related discussions:
15 |
16 | - [Verify identity against site.json defined user during OAuth #241](https://github.com/spencerwooo/onedrive-vercel-index/discussions/241)
17 | - [Do not pretend to be the site owner #250](https://github.com/spencerwooo/onedrive-vercel-index/discussions/250)
18 | - [Google Drive Add #272 - what problem](https://github.com/spencerwooo/onedrive-vercel-index/discussions/272)
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/pages/docs/migration/updating-to-latest-version.en.mdx:
--------------------------------------------------------------------------------
1 | # Updating to the latest version
2 |
3 | Basically, you are syncing a fork of a repository to keep your repository up-to-date with my upstream repository. So, check out [GitHub - Syncing a fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork).
4 |
5 | ## From the Web UI
6 |
7 | - On GitHub, navigate to the main page of the forked repository that you want to sync with the upstream repository.
8 | - Select the Fetch upstream drop-down.
9 | - Review the details about the commits from the upstream repository, then click Fetch and merge.
10 | - If the changes from the upstream repository cause conflicts, GitHub will prompt you to create a pull request to resolve the conflicts.
11 |
12 | ## Command line
13 |
14 | Clone the forked repo locally and:
15 |
16 | ```bash
17 | # Fetch upstream changes
18 | git fetch upstream
19 |
20 | # Checkout your fork's local default branch - main
21 | git checkout main
22 |
23 | # Merge upstream changes into your fork
24 | git merge upstream/main
25 |
26 | # If there are conflicts - manually resolve them locally
27 | # Commit changes and push to GitHub
28 | git commit -m "xxx"
29 | git push
30 | ```
31 |
--------------------------------------------------------------------------------
/src/pages/docs/migration/if-you-deployed-before-2022.en.mdx:
--------------------------------------------------------------------------------
1 | # If you deployed before 2022
2 |
3 | A breaking change was introduced in 2022. Starting from [this announcement](https://github.com/spencerwooo/onedrive-vercel-index/discussions/215), you would not need to generate your own authentication tokens such as `client_id`, `client_secret`, etc.
4 |
5 | You can either start from scratch (which is painstakingly simple) - [Getting started](/docs/getting-started), or migrate to this latest version with a new OAuth process.
6 |
7 | ## Migrating from an old project
8 |
9 | - You need to first create a Redis instance, and define the URL of the instance in the environment variable `REDIS_URL` in Vercel. You can use [Upstash](https://vercel.com/integrations/upstash) for this.
10 | - You need to revert some fields of your customised `config/api.config.js` back, where specifically the `clientId` and `obfuscatedClientSecret` should exactly match:
11 |
12 | ```js
13 | clientId: "d87bcc39-1750-4ca0-ad54-f8d0efbb2735",
14 | obfuscatedClientSecret: "U2FsdGVkX1830zo3/pFDqaBCVBb37iLw3WnBDWGF9GIB2f4apzv0roemp8Y+iIxI3Ih5ecyukqELQEGzZlYiWg=="
15 | ```
16 |
17 | - You also need to define `userPrincipalName` inside `config/site.config.js`, which is used to verify your identity when doing OAuth. **It is usually your Microsoft email address.**
18 | - You can safely delete old environment variables such as your own `CLIENT_SECRET`, `ACCESS_TOKEN`, and `REFRESH_TOKEN`.
19 |
--------------------------------------------------------------------------------
/src/pages/docs/features/load-video-subtitles.en.mdx:
--------------------------------------------------------------------------------
1 | import Callout from 'nextra-theme-docs/callout'
2 |
3 | # Load video subtitles
4 |
5 | Only WebVTT subtitle files (with `.vtt` extensions) are supported.
6 |
7 | If you have a [WebVTT](https://www.w3.org/TR/webvtt1/) subtitle or closed caption file (which ends in `.vtt`) for a certain video, you can use it by putting your subtitle file next to your video.
8 |
9 | 
10 |
11 | See this for an example:
12 |
13 | - Folder holding the video and subtitle: [🍡 Genshin PV / PV - Shenhe - 申鹤](https://drive.swo.moe/%F0%9F%8D%A1%20Genshin%20PV/PV%20-%20Shenhe%20-%20%E7%94%B3%E9%B9%A4)
14 | - The video with subtitles: [Collected Miscellany - Shenhe - Fluttering of Frosty Feathers - Genshin Impact.mp4](https://drive.swo.moe/%F0%9F%8D%A1%20Genshin%20PV/PV%20-%20Shenhe%20-%20%E7%94%B3%E9%B9%A4/Collected%20Miscellany%20-%20Shenhe%20-%20Fluttering%20of%20Frosty%20Feathers%20-%20Genshin%20Impact.mp4).
15 |
16 | Basically, your video and cooresponding subtitle file should be in the same folder, and named as:
17 |
18 | ```
19 | .
20 | ├── .mp4
21 | └── .vtt
22 | ```
23 |
24 | Such as:
25 |
26 | ```
27 | .
28 | ├── Collected Miscellany - Shenhe - Fluttering of Frosty Feathers - Genshin Impact.mp4
29 | └── Collected Miscellany - Shenhe - Fluttering of Frosty Feathers - Genshin Impact.vtt
30 | ```
31 |
--------------------------------------------------------------------------------
/src/components/encryption.js:
--------------------------------------------------------------------------------
1 | import { useState } from 'react'
2 | import CryptoJS from 'crypto-js'
3 |
4 | import styles from './encryption.module.css'
5 |
6 | // This function is identical to the implementation in onedrive-vercel-index
7 | // https://github.com/spencerwooo/onedrive-vercel-index/blob/d8ef0733bfe4d4c9c3e7b71be573d08d1ab88060/utils/oAuthHandler.ts#L6-L13
8 | const obfuscateToken = token => {
9 | const AES_SECRET_KEY = 'onedrive-vercel-index'
10 | const encrypted = CryptoJS.AES.encrypt(token, AES_SECRET_KEY)
11 | return encrypted.toString()
12 | }
13 |
14 | export default function Encryption() {
15 | // An example client secret: `5e07Q~ZCBgtR3MdPUpQcqa~N8pOZo11GJ1MhL`
16 | const [token, setToken] = useState('')
17 | const obfuscatedToken = token && obfuscateToken(token)
18 |
19 | return (
20 |
53 | )
54 | }
55 |
--------------------------------------------------------------------------------
/src/pages/docs/faqs/error-on-deployment.zh.mdx:
--------------------------------------------------------------------------------
1 | import Callout from 'nextra-theme-docs/callout'
2 |
3 | # 部署时出现错误
4 |
5 | ### ItemNotFound
6 |
7 | ```json
8 | {
9 | "error": {
10 | "error": {
11 | "code": "itemNotFound",
12 | "message": "The resource could not be found.",
13 | "innerError": {
14 | "date": "2022-01-14T09:29:32",
15 | "request-id": "7fee4456-abd6-4258-aeb0-4f03ee43bd13",
16 | "client-request-id": "7fee4456-abd6-4258-aeb0-4f03ee43bd13"
17 | }
18 | }
19 | }
20 | }
21 | ```
22 |
23 | 你没有指定一个有效的 OneDrive 进行共享。
24 |
25 | 1. 你分享的文件必须存放在 OneDrive 的一个文件夹里。
26 | 2. 你必须在 `site.config.js` 的 `baseDirectory` 处指定该文件夹的绝对路径。
27 |
28 |
29 | 相关讨论:
30 | - [这是啥问题?#274](https://github.com/spencerwooo/onedrive-vercel-index/discussions/274)
31 | - [部署完后报错 #240](https://github.com/spencerwooo/onedrive-vercel-index/discussions/240)
32 |
33 |
34 | ### Error 504
35 |
36 | ```json
37 | { "error": { "code": "504", "message": "An error occurred with your deployment" } }
38 | ```
39 |
40 | 这可能由多个错误引起,但可以确定的是你填错了 Redis URL 或者 `site.config.js` 里的内容。
41 |
42 | 1. 请检查 `baseDirectory`。如果你在旧版遇到了此问题,解决办法与上面的 `itemNotFound` 一致。
43 | 2. 请检查你在 Vercel 的 `REDIS_URL` 环境变量是否填好了 Redis URL。**如果你使用 Upstash ,请启用 SSL** 该 URL 长得很像 `rediss://:xxx@us1-xxx.upstash.io:xxx` ,请注意是 `rediss` 而非 `redis` ,是 `://:xx` 而非 `://xx`。
44 |
45 |
46 | 相关讨论:
47 | - [这种怎么解决啊 #267](https://github.com/spencerwooo/onedrive-vercel-index/discussions/267)
48 | - [在 Vercel 下部署遇到 504 错误,在本地运行没有问题 #261](https://github.com/spencerwooo/onedrive-vercel-index/discussions/261)
49 | - [Oops, that's a four-oh-four. #238](https://github.com/spencerwooo/onedrive-vercel-index/discussions/238)
50 | - [504 Error #247](https://github.com/spencerwooo/onedrive-vercel-index/discussions/247)
51 |
52 |
--------------------------------------------------------------------------------
/src/pages/docs/features/protected-folders.zh.mdx:
--------------------------------------------------------------------------------
1 | import Callout from 'nextra-theme-docs/callout'
2 | import Video from '../../../components/video'
3 |
4 | # 受密码保护的文件夹
5 |
6 |
7 |
8 | ## 使用密码保护你的文件夹
9 |
10 | 你可以创建一个需要密码才能访问的文件夹。
11 |
12 | ### 步骤
13 |
14 | - 你需要在 `config/site.json` 的 `protectedRoutes` 处添加要保护的文件夹。
15 | - 在要保护的文件夹下创建一个名为 `.password` 的 **空白文件**。
16 | - 使用任意文本编辑器打开这个 `.password` 文件,并在里面填写该文件夹的访问密码。
17 | - 最后,在 Vercel 中重新部署该项目。
18 |
19 | ### 设置受密码保护的文件夹
20 |
21 | 受密码保护的文件夹主要由 `config/site.json` 中的 `protectedRoutes` 属性指定,举个例子 👇
22 |
23 | 假设你有这样一个文件结构:
24 |
25 | ```
26 | .
27 | ├── 📕 Books
28 | │ └── ...
29 | ├── 🌞 Private folder
30 | │ ├── this-is-public
31 | │ └── u-need-a-password <-- 你想要用密码保护这个文件夹
32 | ├── 🍡 Genshin PV
33 | │ └── ...
34 | └── README.md
35 | ```
36 |
37 | 我们想要将 `/u-need-a-password` 设为受密码保护的文件夹,就把它的绝对路径按下列格式填写到 `protectedRoutes` 里:
38 |
39 | ```json
40 | "protectedRoutes": [
41 | "/🌞 Private folder/u-need-a-password",
42 | ],
43 | ```
44 |
45 | 如果你想设置另一个受密码保护的文件夹,那就在下一行按下列格式添加它的绝对路径:
46 |
47 | ```json
48 | "protectedRoutes": [
49 | "/🌞 Private folder/u-need-a-password",
50 | "/another/route/for/me/to/protect",
51 | ],
52 | ```
53 |
54 | 如果你没有任何受密码保护的文件夹,那么就添加一个 `[]` 以关闭此功能:
55 |
56 | ```json
57 | "protectedRoutes": [],
58 | ```
59 |
60 | 在上述添加的受密码保护的路径的根目录下内创建一个 `.password` 文件,该文件内的纯文本内容就是你访问该文件夹时需要的密码。
61 |
62 | 
63 |
64 | ### 注意事项
65 |
66 | 是的,所有看起来安全的保护措施都并非无懈可击。
67 |
68 | 1. 受密码保护的文件夹中的文件直链可以通过 URL 参数 `&odpt=` 分享,如果你真的需要的话:
69 |
70 | ```
71 | https://drive.swo.moe/api/raw/?path=/🌞%20Private%20folder/u-need-a-password/watch%20this.mp4&odpt=c8ebdc273d673d167c238dd25a997bdf9b4ecbf589452697c1a6cb416b2ed11d
72 | ```
73 |
74 | 我们并不知道这是否会暴露你的密码,受密码保护的文件,个人信息等等,所以请谨慎使用。
75 |
76 | 1. 我个人无法保证此保护功能完全安全。所以我不推荐使用此方式存放你的个人隐私信息,这只是个分享的可选项。
77 |
78 |
79 | 详情请参考 [Password protected routes is now supported
80 | #66](https://github.com/spencerwooo/onedrive-vercel-index/discussions/66)。
81 |
82 |
--------------------------------------------------------------------------------
/src/pages/docs/faqs/error-on-deployment.en.mdx:
--------------------------------------------------------------------------------
1 | import Callout from 'nextra-theme-docs/callout'
2 |
3 | # Error on deployment
4 |
5 | ### ItemNotFound
6 |
7 | ```json
8 | {
9 | "error": {
10 | "error": {
11 | "code": "itemNotFound",
12 | "message": "The resource could not be found.",
13 | "innerError": {
14 | "date": "2022-01-14T09:29:32",
15 | "request-id": "7fee4456-abd6-4258-aeb0-4f03ee43bd13",
16 | "client-request-id": "7fee4456-abd6-4258-aeb0-4f03ee43bd13"
17 | }
18 | }
19 | }
20 | }
21 | ```
22 |
23 | You did not specify a valid directory inside your OneDrive for sharing.
24 |
25 | 1. You must have a folder in your OneDrive present.
26 | 2. You must define the absolute path of the folder under `baseDirectory` in `site.config.js`.
27 |
28 |
29 | Related discussions:
30 | - [这是啥问题?#274](https://github.com/spencerwooo/onedrive-vercel-index/discussions/274)
31 | - [部署完后报错 #240](https://github.com/spencerwooo/onedrive-vercel-index/discussions/240)
32 |
33 |
34 | ### Error 504
35 |
36 | ```json
37 | { "error": { "code": "504", "message": "An error occurred with your deployment" } }
38 | ```
39 |
40 | This may happen for a various reasons, but you definitely f\*cked up some config either in `site.config.js` or set the Redis URL incorrectly.
41 |
42 | 1. Check `baseDirectory`, previous versions don't have detailed error handling and if you are using a previous version then you may encounter this issue (same solution as the `itemNotFound` issue above)
43 | 2. Check your Redis URL defined in the environment variable in Vercel, which is `REDIS_URL`. **If you are using Upstash, and you enabled SSL,** then the URL may look similar to `rediss://:xxx@us1-xxx.upstash.io:xxx` - notice the `rediss` instead of `redis` and the `://:xx` instead of `://xx`.
44 |
45 |
46 | Related discussions:
47 | - [这种怎么解决啊 #267](https://github.com/spencerwooo/onedrive-vercel-index/discussions/267)
48 | - [在 Vercel 下部署遇到 504 错误,在本地运行没有问题 #261](https://github.com/spencerwooo/onedrive-vercel-index/discussions/261)
49 | - [Oops, that's a four-oh-four. #238](https://github.com/spencerwooo/onedrive-vercel-index/discussions/238)
50 | - [504 Error #247](https://github.com/spencerwooo/onedrive-vercel-index/discussions/247)
51 |
52 |
--------------------------------------------------------------------------------
/src/pages/docs/showcase/file-preview.zh.mdx:
--------------------------------------------------------------------------------
1 | # 文件预览
2 |
3 | ## Markdown
4 |
5 | 
6 |
7 | Demo - [https://drive.swo.moe/README.md](https://drive.swo.moe/README.md)
8 |
9 | ## PDF
10 |
11 | 
12 |
13 | Demo - [https://drive.swo.moe/🥟 Some test files/ECAM22.110.SB.pdf](https://drive.swo.moe/%F0%9F%A5%9F%20Some%20test%20files/ECAM22.110.SB.pdf)
14 |
15 | ## Office 文档
16 |
17 | 
18 |
19 | Demo - [https://drive.swo.moe/Lecture and Coursework CS (BIT)/2018 - 大三上 - 计算机组成原理/第 6 章中央处理器.ppt]()
20 |
21 | ## 视频
22 |
23 | 
24 |
25 | Demo - [https://drive.swo.moe/🍡 Genshin PV/EP - Extended Play/《原神》EP - 幽蝶留芳之处(胡桃).mp4](https://drive.swo.moe/%F0%9F%8D%A1%20Genshin%20PV/EP%20-%20Extended%20Play/%E3%80%8A%E5%8E%9F%E7%A5%9E%E3%80%8BEP%20-%20%E5%B9%BD%E8%9D%B6%E7%95%99%E8%8A%B3%E4%B9%8B%E5%A4%84%EF%BC%88%E8%83%A1%E6%A1%83%EF%BC%89.mp4)
26 |
27 | ## 音频
28 |
29 | 
30 |
31 | Demo - [https://drive.swo.moe/🥟 Some test files/Videos and music/Dragonspine Battle Theme - Genshin Impact OST.mp3](https://drive.swo.moe/%F0%9F%A5%9F%20Some%20test%20files/Videos%20and%20music/Dragonspine%20Battle%20Theme%20-%20Genshin%20Impact%20OST.mp3)
32 |
33 | ## 纯文本
34 |
35 | 
36 |
37 | Demo - [https://drive.swo.moe/🥟 Some test files/Previews/iso_8859-1.txt](https://drive.swo.moe/%F0%9F%A5%9F%20Some%20test%20files/Previews/iso_8859-1.txt)
38 |
39 | ## 代码
40 |
41 | 
42 |
43 | Demo - [https://drive.swo.moe/🥟 Some test files/Code/pathUtil.js](https://drive.swo.moe/%F0%9F%A5%9F%20Some%20test%20files/Code/pathUtil.js)
44 |
45 | ## URL
46 |
47 | 
48 |
49 | Demo - [https://drive.swo.moe/🥟 Some test files/baidu.url](https://drive.swo.moe/%F0%9F%A5%9F%20Some%20test%20files/baidu.url)
50 |
51 | ## EPUB
52 |
53 | 
54 |
55 | Demo - [https://drive.swo.moe/📕 Books/村上春树《挪威的森林》.epub](https://drive.swo.moe/%F0%9F%93%95%20Books/%E6%9D%91%E4%B8%8A%E6%98%A5%E6%A0%91%E3%80%8A%E6%8C%AA%E5%A8%81%E7%9A%84%E6%A3%AE%E6%9E%97%E3%80%8B.epub)
56 |
--------------------------------------------------------------------------------
/src/pages/docs/showcase/file-preview.en.mdx:
--------------------------------------------------------------------------------
1 | # File previews
2 |
3 | ## Markdown
4 |
5 | 
6 |
7 | Demo - [https://drive.swo.moe/README.md](https://drive.swo.moe/README.md)
8 |
9 | ## PDF
10 |
11 | 
12 |
13 | Demo - [https://drive.swo.moe/🥟 Some test files/ECAM22.110.SB.pdf](https://drive.swo.moe/%F0%9F%A5%9F%20Some%20test%20files/ECAM22.110.SB.pdf)
14 |
15 | ## Office documents
16 |
17 | 
18 |
19 | Demo - [https://drive.swo.moe/Lecture and Coursework CS (BIT)/2018 - 大三上 - 计算机组成原理/第 6 章中央处理器.ppt]()
20 |
21 | ## Video
22 |
23 | 
24 |
25 | Demo - [https://drive.swo.moe/🍡 Genshin PV/EP - Extended Play/《原神》EP - 幽蝶留芳之处(胡桃).mp4](https://drive.swo.moe/%F0%9F%8D%A1%20Genshin%20PV/EP%20-%20Extended%20Play/%E3%80%8A%E5%8E%9F%E7%A5%9E%E3%80%8BEP%20-%20%E5%B9%BD%E8%9D%B6%E7%95%99%E8%8A%B3%E4%B9%8B%E5%A4%84%EF%BC%88%E8%83%A1%E6%A1%83%EF%BC%89.mp4)
26 |
27 | ## Audio
28 |
29 | 
30 |
31 | Demo - [https://drive.swo.moe/🥟 Some test files/Videos and music/Dragonspine Battle Theme - Genshin Impact OST.mp3](https://drive.swo.moe/%F0%9F%A5%9F%20Some%20test%20files/Videos%20and%20music/Dragonspine%20Battle%20Theme%20-%20Genshin%20Impact%20OST.mp3)
32 |
33 | ## Plain text
34 |
35 | 
36 |
37 | Demo - [https://drive.swo.moe/🥟 Some test files/Previews/iso_8859-1.txt](https://drive.swo.moe/%F0%9F%A5%9F%20Some%20test%20files/Previews/iso_8859-1.txt)
38 |
39 | ## Code
40 |
41 | 
42 |
43 | Demo - [https://drive.swo.moe/🥟 Some test files/Code/pathUtil.js](https://drive.swo.moe/%F0%9F%A5%9F%20Some%20test%20files/Code/pathUtil.js)
44 |
45 | ## URL
46 |
47 | 
48 |
49 | Demo - [https://drive.swo.moe/🥟 Some test files/baidu.url](https://drive.swo.moe/%F0%9F%A5%9F%20Some%20test%20files/baidu.url)
50 |
51 | ## EPUB
52 |
53 | 
54 |
55 | Demo - [https://drive.swo.moe/📕 Books/村上春树《挪威的森林》.epub](https://drive.swo.moe/%F0%9F%93%95%20Books/%E6%9D%91%E4%B8%8A%E6%98%A5%E6%A0%91%E3%80%8A%E6%8C%AA%E5%A8%81%E7%9A%84%E6%A3%AE%E6%9E%97%E3%80%8B.epub)
56 |
--------------------------------------------------------------------------------
/src/pages/docs/cache.en.mdx:
--------------------------------------------------------------------------------
1 | # Cache
2 |
3 | ## Super fast?
4 |
5 | Yes! Folder listing, thumbnail, search, etc., are now cached with Vercel's edge function caching. You should experience extremely faster load speed for these routes, especially folder listings. _(Note: the thumbnails themselves are not cached to follow Vercel's fair use policy, only the URL pointing to the thumbnails are cached.)_
6 |
7 | **The cache is valid for 60 seconds on the edge** - This means you won't see your newly added files for at least 60 seconds after your files are done uploading.
8 |
9 | If you want to manually purge the cache of your site, you can do so by triggering a redeployment manually.
10 |
11 | > The cache is automatically purged upon a new deployment being created. If you ever need to invalidate the CDN cache, you can always re-deploy. Further reading: [Caching - Vercel Docs](https://vercel.com/docs/concepts/edge-network/caching).
12 |
13 | ## Technical details
14 |
15 | Relevant headers:
16 |
17 | ```
18 | Cache-Control: max-age=0, s-maxage=60, stale-while-revalidate
19 | ```
20 |
21 | - `max-age=0` - no cache for your browser
22 | - `s-maxage=60` - cache remains fresh for 60 seconds on the edge
23 | - `stale-while-revalidate` - allow serving stale cache after 60 seconds while the edge revalidates the cache
24 |
25 | You can check for response headers `x-vercel-cache` to see whether your request is responsed by a cache hit (fast 🐰), or fresh revalidated data (slow 🐢).
26 |
27 | ### Cache miss
28 |
29 | Most often, no cache is present at the edge when someone first visits a route. This is presented as _cache miss_, where the response header `x-vercel-cache` is set to `MISS`. In this scenario, fresh data is requested from the upstream API, and you will experience a slow load speed (compared to other scenarios).
30 |
31 | 
32 |
33 | ### Cache hit
34 |
35 | After the route is requested, Vercel will cache the function response at the edge. When a second request on the same route is triggered, Vercel will respond with the cache instead of requesting data from the upstream for a second time. This is presented as _cache hit_, where the response header `x-vercel-cache` is set to `HIT`. You will experience an instant response.
36 |
37 | 
38 |
39 | ### Cache stale
40 |
41 | If the cache is present for longer than 60 seconds, on the request triggered, Vercel will respond with the stale cache, setting `x-vercel-cache` to `STALE`, and perform a new request to the upstream API. In this case, the following response is most likely guaranteed to be fresh, and Vercel will update the cache on the edge accordingly. You will experience an instant response for both requests.
42 |
43 | 
44 |
--------------------------------------------------------------------------------
/src/pages/docs/cache.zh.mdx:
--------------------------------------------------------------------------------
1 | # 缓存
2 |
3 | ## Super fast?
4 |
5 | Yes! Folder listing, thumbnail, search, etc., are now cached with Vercel's edge function caching. You should experience extremely faster load speed for these routes, especially folder listings. _(Note: the thumbnails themselves are not cached to follow Vercel's fair use policy, only the URL pointing to the thumbnails are cached.)_
6 |
7 | **The cache is valid for 60 seconds on the edge** - This means you won't see your newly added files for at least 60 seconds after your files are done uploading.
8 |
9 | If you want to manually purge the cache of your site, you can do so by triggering a redeployment manually.
10 |
11 | > The cache is automatically purged upon a new deployment being created. If you ever need to invalidate the CDN cache, you can always re-deploy. Further reading: [Caching - Vercel Docs](https://vercel.com/docs/concepts/edge-network/caching).
12 |
13 | ## Technical details
14 |
15 | Relevant headers:
16 |
17 | ```
18 | Cache-Control: max-age=0, s-maxage=60, stale-while-revalidate
19 | ```
20 |
21 | - `max-age=0` - no cache for your browser
22 | - `s-maxage=60` - cache remains fresh for 60 seconds on the edge
23 | - `stale-while-revalidate` - allow serving stale cache after 60 seconds while the edge revalidates the cache
24 |
25 | You can check for response headers `x-vercel-cache` to see whether your request is responsed by a cache hit (fast 🐰), or fresh revalidated data (slow 🐢).
26 |
27 | ### Cache miss
28 |
29 | Most often, no cache is present at the edge when someone first visits a route. This is presented as _cache miss_, where the response header `x-vercel-cache` is set to `MISS`. In this scenario, fresh data is requested from the upstream API, and you will experience a slow load speed (compared to other scenarios).
30 |
31 | 
32 |
33 | ### Cache hit
34 |
35 | After the route is requested, Vercel will cache the function response at the edge. When a second request on the same route is triggered, Vercel will respond with the cache instead of requesting data from the upstream for a second time. This is presented as _cache hit_, where the response header `x-vercel-cache` is set to `HIT`. You will experience an instant response.
36 |
37 | 
38 |
39 | ### Cache stale
40 |
41 | If the cache is present for longer than 60 seconds, on the request triggered, Vercel will respond with the stale cache, setting `x-vercel-cache` to `STALE`, and perform a new request to the upstream API. In this case, the following response is most likely guaranteed to be fresh, and Vercel will update the cache on the edge accordingly. You will experience an instant response for both requests.
42 |
43 | 
44 |
--------------------------------------------------------------------------------
/src/pages/docs/advanced.zh.mdx:
--------------------------------------------------------------------------------
1 | import Callout from 'nextra-theme-docs/callout'
2 | import Encryption from '../../components/encryption'
3 |
4 | # 高级
5 |
6 | 此页持续更新中。
7 |
8 | 这里有些高级设置,你可能需要了解一下。
9 |
10 | ## 使用你自己的 client id 与 secret
11 |
12 | 如果你的账户没有管理权限,那么你就无法使用项目提供的 `clientId` 与 `clientSecret`。这个情况下,你就要生成你自己的 client id 与 secret 了。
13 |
14 | ### 注册一个应用程序
15 |
16 | 打开以下链接:
17 |
18 | - [Microsoft Azure App registrations](https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade)( OneDrive 国际版、企业版与教育版,E5 订阅专用)
19 | - [Microsoft Azure.cn App registrations](https://portal.azure.cn/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade)(OneDrive 世纪互联专用)
20 |
21 | 创建一个应用程序:
22 |
23 | 1. 登入你的微软账户,点击 _New registration_。
24 | 2. 输入一个名字,例如 my-onedrive-vercel-index。
25 | 3. 将 _Supported account types_ 设置为:
26 |
27 | ```
28 | Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)
29 | ```
30 |
31 | OneDrive 世纪互联用户设置为 - 任何组织目录(任何 Azure AD 目录 - 多租户)中的帐户。
32 |
33 | 4. 将 _Redirect URI (optional)_ 设置为 `Web`(在下拉菜单里)以及 `http://localhost`。
34 | 5. 点击注册。
35 |
36 | 
37 |
38 | ### 获取你的 client id 与 secret
39 |
40 | 你的应用 (client) ID 就是 `api.config.js` 里的 `clientId` ,它应该出现在 _Overview_ > _Essentials_。
41 |
42 | 
43 |
44 | 你的 client secret 需要手动获取
45 |
46 | 1. 点击 _Certificates & secrets_。
47 | 2. 点击 _New client secret_。
48 | 3. 创建一个新 secret ,描述为 `client_secret`。
49 | 4. 将 _Expires_ 设置为 `Custom`。
50 | 5. 将 _Start_ 与 _End_ 设置为能设置的最长时间。
51 |
52 | 
53 |
54 | 最后,点击 _Add_ ,然后复制 client_secret 的值并妥善保管。(只有一次复制机会)
55 |
56 | 
57 |
58 | ### 修改 API 权限
59 |
60 | Microsoft Graph API 可以设置 API 范围,我们只需要以下三个( `api.config.js` 里要求的):
61 |
62 | ```
63 | user.read files.read.all offline_access
64 | ```
65 |
66 | 点击 _API permissions_,再点击 _Microsoft Graph_,再点击 _Delegated permissions_,然后搜索:
67 |
68 | - User.Read(这应该一开始就勾上了)
69 | - Files.Read.All
70 | - offline_access
71 |
72 | 选择全部三个并点击 _Add permissions_。
73 |
74 | 
75 |
76 | 现在,你就准备好你自己的 `clientId` 与 `clientSecret` 了。
77 |
78 | ### 修改 `api.config.js`
79 |
80 | 你可以直接将 `clientId` 修改为你自己的 `clientId`。
81 |
82 | 但是,client secret 需要保密,你需要在下面进行 AES 加密:
83 |
84 |
85 |
86 | 填写 client secret 后,你应该得到一个长得像这样的字符串:
87 |
88 | ```
89 | U2FsdGVkX1830zo3/pFDqaBCVBb37iLw3WnBDWGF9GIB2f4apzv0roemp8Y+iIxI3Ih5ecyukqELQEGzZlYiWg==
90 | ```
91 |
92 | 将它替换到 `obfuscatedClientSecret` 里。
93 |
94 | 如果你修改了 `redirectUri` 为其他值,你也要在 `api.config.js` 里设置好。
95 |
96 |
97 | 详情请参考 [关于使用自己的 secret 进行 AES 加密方式的小白解决办法](https://github.com/spencerwooo/onedrive-vercel-index/discussions/234)。
98 |
99 |
100 | ## 自定义域名
101 |
102 | 详情请参考 [Custom Domains - Vercel](https://vercel.com/docs/concepts/projects/custom-domains)。
103 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .vercel
2 | .next
3 |
4 | # Logs
5 | logs
6 | *.log
7 | npm-debug.log*
8 | yarn-debug.log*
9 | yarn-error.log*
10 | lerna-debug.log*
11 | .pnpm-debug.log*
12 |
13 | # Diagnostic reports (https://nodejs.org/api/report.html)
14 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
15 |
16 | # Runtime data
17 | pids
18 | *.pid
19 | *.seed
20 | *.pid.lock
21 |
22 | # Directory for instrumented libs generated by jscoverage/JSCover
23 | lib-cov
24 |
25 | # Coverage directory used by tools like istanbul
26 | coverage
27 | *.lcov
28 |
29 | # nyc test coverage
30 | .nyc_output
31 |
32 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
33 | .grunt
34 |
35 | # Bower dependency directory (https://bower.io/)
36 | bower_components
37 |
38 | # node-waf configuration
39 | .lock-wscript
40 |
41 | # Compiled binary addons (https://nodejs.org/api/addons.html)
42 | build/Release
43 |
44 | # Dependency directories
45 | node_modules/
46 | jspm_packages/
47 |
48 | # Snowpack dependency directory (https://snowpack.dev/)
49 | web_modules/
50 |
51 | # TypeScript cache
52 | *.tsbuildinfo
53 |
54 | # Optional npm cache directory
55 | .npm
56 |
57 | # Optional eslint cache
58 | .eslintcache
59 |
60 | # Optional stylelint cache
61 | .stylelintcache
62 |
63 | # Microbundle cache
64 | .rpt2_cache/
65 | .rts2_cache_cjs/
66 | .rts2_cache_es/
67 | .rts2_cache_umd/
68 |
69 | # Optional REPL history
70 | .node_repl_history
71 |
72 | # Output of 'npm pack'
73 | *.tgz
74 |
75 | # Yarn Integrity file
76 | .yarn-integrity
77 |
78 | # dotenv environment variable files
79 | .env
80 | .env.development.local
81 | .env.test.local
82 | .env.production.local
83 | .env.local
84 |
85 | # parcel-bundler cache (https://parceljs.org/)
86 | .cache
87 | .parcel-cache
88 |
89 | # Next.js build output
90 | .next
91 | out
92 |
93 | # Nuxt.js build / generate output
94 | .nuxt
95 | dist
96 |
97 | # Gatsby files
98 | .cache/
99 | # Comment in the public line in if your project uses Gatsby and not Next.js
100 | # https://nextjs.org/blog/next-9-1#public-directory-support
101 | # public
102 |
103 | # vuepress build output
104 | .vuepress/dist
105 |
106 | # vuepress v2.x temp and cache directory
107 | .temp
108 | .cache
109 |
110 | # Docusaurus cache and generated files
111 | .docusaurus
112 |
113 | # Serverless directories
114 | .serverless/
115 |
116 | # FuseBox cache
117 | .fusebox/
118 |
119 | # DynamoDB Local files
120 | .dynamodb/
121 |
122 | # TernJS port file
123 | .tern-port
124 |
125 | # Stores VSCode versions used for testing VSCode extensions
126 | .vscode-test
127 |
128 | # yarn v2
129 | .yarn/cache
130 | .yarn/unplugged
131 | .yarn/build-state.yml
132 | .yarn/install-state.gz
133 | .pnp.*
134 |
135 | # General
136 | .DS_Store
137 | .AppleDouble
138 | .LSOverride
139 |
140 | # Icon must end with two \r
141 | Icon
142 |
143 | # Thumbnails
144 | ._*
145 |
146 | # Files that might appear in the root of a volume
147 | .DocumentRevisions-V100
148 | .fseventsd
149 | .Spotlight-V100
150 | .TemporaryItems
151 | .Trashes
152 | .VolumeIcon.icns
153 | .com.apple.timemachine.donotpresent
154 |
155 | # Directories potentially created on remote AFP share
156 | .AppleDB
157 | .AppleDesktop
158 | Network Trash Folder
159 | Temporary Items
160 | .apdisk
161 |
--------------------------------------------------------------------------------
/src/pages/docs/features/protected-folders.en.mdx:
--------------------------------------------------------------------------------
1 | import Callout from 'nextra-theme-docs/callout'
2 | import Video from '../../../components/video'
3 |
4 | # Password protected folders
5 |
6 |
7 |
8 | ## Password protecting a folder/route
9 |
10 | You can now protect a folder or directory with passwords.
11 |
12 | ### Method
13 |
14 | - Declare the protected folder's path under `protectedRoutes` (which is an array) in `config/site.json`.
15 | - Create **a plain text file** that is named `.password` (character for character, must be this name), and move this file under the folder that you wish to password protect.
16 | - Open this `.password` file with a text editor, like VS Code or Notepad, and save the password inside (in plain text format).
17 | - Finally, redeploy your onedrive-vercel-index in Vercel so your website picks up the newest protected folder configs.
18 |
19 | ### Details
20 |
21 | If you are wondering what to define in `protectedRoutes`, here is an example.
22 |
23 | Suppose we have the following folder structure:
24 |
25 | ```
26 | .
27 | ├── 📕 Books
28 | │ └── ...
29 | ├── 🌞 Private folder
30 | │ ├── this-is-public
31 | │ └── u-need-a-password <-- this is the folder to protect
32 | ├── 🍡 Genshin PV
33 | │ └── ...
34 | └── README.md
35 | ```
36 |
37 | We want to password protect the `/u-need-a-password` directory, so we would write inside `protectedRoutes` the absolute path to root.
38 |
39 | ```json
40 | "protectedRoutes": [
41 | "/🌞 Private folder/u-need-a-password",
42 | ],
43 | ```
44 |
45 | If you want to add another route, then add it to the next item in the array.
46 |
47 | ```json
48 | "protectedRoutes": [
49 | "/🌞 Private folder/u-need-a-password",
50 | "/another/route/for/me/to/protect",
51 | ],
52 | ```
53 |
54 | If there is no directory for you to password protect and you want to disable this function, you can simply pass an empty array `[]` to `protectedRoutes`.
55 |
56 | ```json
57 | "protectedRoutes": [],
58 | ```
59 |
60 | If you are confused about whether you need to encrypt your password, don't. Put that plain text inside `.password`. Whatever you save inside `.password`, you are going to use as the password for entering the protected directory.
61 |
62 | 
63 |
64 | ### Caveats
65 |
66 | Yes, all seemingly secure protections come at a cost.
67 |
68 | 1. The direct link of the files under your protected directory can be shared with the URL parameter `&odpt=`, if you really want to:
69 |
70 | ```
71 | https://drive.swo.moe/api/raw/?path=/🌞%20Private%20folder/u-need-a-password/watch%20this.mp4&odpt=c8ebdc273d673d167c238dd25a997bdf9b4ecbf589452697c1a6cb416b2ed11d
72 | ```
73 |
74 | Whether or not this exposes your password, protected files, personal information, etc., is all unknown. Use at your own risk.
75 |
76 | 2. I personally cannot guarantee that this protection is impenetrable and fully secure. Hence, I would not recommend protecting sensitive information with this method. Think of this as an extra layer of annoyance to keep files you want to share with only the people you wish.
77 |
78 |
79 | More on this in [Password protected routes is now supported
80 | #66](https://github.com/spencerwooo/onedrive-vercel-index/discussions/66).
81 |
82 |
--------------------------------------------------------------------------------
/src/pages/docs/custom-configs.zh.mdx:
--------------------------------------------------------------------------------
1 | import Callout from 'nextra-theme-docs/callout'
2 | import Bleed from 'nextra-theme-docs/bleed'
3 | import Video from '../../components/video'
4 |
5 | # 自定义配置
6 |
7 | 有两个配置文件,分别是: `config/api.config.js` 与 `config/site.config.js`。
8 |
9 | - `config/api.config.js` - 是用来定义 API 参数的。 **OneDrive 国际版用户无需更改任何参数**
10 | - `config/site.config.js` - 是用来自定义你的网页的,你可以自定义标题、图标、字体、联系方式等等。
11 |
12 | ## 自定义 API 参数
13 |
14 | **你自己觉得有必要修改时再修改**
15 |
16 | - 如果你的账户没有管理权限,那么你需要使用自己的 `clientId` 与 `obfuscatedClientSecret`。详情请参考 [使用你自己的 clientid 与 secret](./advanced)。
17 | - 如果你是 OneDrive 世纪互联 用户,你需要修改 `authApi` 与 `driveApi` ,你应该已经在 [立即上手](./getting-started) 做过了。
18 |
19 | {/* 如果你需要使用代理下载功能,请修改 `directLinkRegex`。详情请参考 [Proxied download (disabled)](todo). */}
20 |
21 | ## 自定义网页
22 |
23 | 有些设置是为你自定义自己的网页而准备的,它们在 `config/site.config.js` 里:
24 |
25 | ### `userPrincipalName`
26 |
27 | 你应该已经在 [立即上手](./getting-started) 做过了。
28 |
29 | ### `icon` - 图标和 favicons
30 |
31 | 
32 |
33 | `icon` - 是标题栏中标题左边的图标。 **它应该被放置在你的 GitHub 项目的 [`/public`](https://github.com/spencerwooo/onedrive-vercel-index/tree/main/public) 目录,而不是你的 Onedrive 目录** ,并且填上它在 `/public` 目录内的路径。
34 |
35 | 比如说,你的项目的 `/public` 路径长这样:
36 |
37 | ```
38 | .
39 | ├── favicon-16x16.png
40 | ├── favicon-32x32.png
41 | ├── favicon.ico
42 | ├── icons
43 | │ └── 64.png
44 | └── ...
45 | ```
46 |
47 | 然后你想让 `64.png` 作为你的网页图标,那么你应该将 `site.config.js` 里的 `icon` 设置为 `/icons/64.png`。你的网页的 favicons 也应该放置在 `/public` 目录,请访问 [favicon.io](http://favicon.io) 以生成你的 favicons。
48 |
49 | ### `title` - 网页标题
50 |
51 | 标题栏上的网页标题,图标右边那个。
52 |
53 | ### `baseDirectory`
54 |
55 | 你想用 onedrive-vercel-index 分享的 OneDrive 目录,你应该已经在 [立即上手](./getting-started) 做过了。
56 |
57 | ### `maxItems`
58 |
59 | 每页展示的文件数,最大为微软 API 限制的 200。
60 |
61 |
62 | 来看看分页功能 [https://drive.swo.moe/🥟 Some test files/Imagenette](https://drive.swo.moe/%F0%9F%A5%9F%20Some%20test%20files/Imagenette).
63 |
64 |
65 | ### `googleFont` - 自定义字体家族
66 |
67 | 我们使用谷歌字体家族作为界面的默认字体:
68 |
69 | - `googleFontSans` - onedrive-vercel-index 使用的 sans serif 字体。
70 | - `googleFontMono` - onedrive-vercel-index 使用的 monospace 字体。
71 | - `googleFontLinks` - 谷歌字体资源的链接。
72 |
73 | 你可以在 [fonts.google.com](https://fonts.google.com/) 生成你想用的字体家族的名字和链接。
74 |
75 | ### `footer`
76 |
77 | 网页的页脚。你可以在这里写 HTML ,但你要注意双引号 - 你需要将 `"` 替换为 `\"`。你可以在这里写任何东西。如果你喜欢徽章,可以在 [shields.io](http://shields.io) 生成一些。😃
78 |
79 | ### `protectedRoutes`
80 |
81 | 你可以创建一个需要密码才能访问的文件夹,详情请参考 [私密文件夹](./features/protected-folders)。
82 |
83 | ### `email`
84 |
85 | `email` - 这是可选项,如果你不想展示任何邮箱,你可以删到只剩 `""`:
86 |
87 | ```diff
88 | - "email": "mailto:spencer.wushangbo@gmail.com",
89 | + "email": "",
90 | ```
91 |
92 | 我还是建议你放上一些联系方式的。
93 |
94 | ### `links`
95 |
96 | `links` - 你可以添加你想要展示的链接,格式为 `{ "name": "xxx", "link": "xxx" }`。我们已经支持所有来自 Font Awesome 的图标,只要你有 `name`。请查看下面的演示:
97 |
98 |
99 | 演示中出现的所有链接均由 GitHub Copilot 生成,并不一定指向我的相关账号。
100 |
101 |
102 |
103 |
104 | 请到 [Brand Icons | Font Awesome](https://fontawesome.com/icons?s=brands) 查看图标列表。
105 |
106 | ### `datetimeFormat`
107 |
108 | `datetimeFormat` - 是由 [`day.js`](https://day.js.org/) 定义的日期格式。详情请参考 [`day.js` Docs](https://day.js.org/docs/en/display/format)。
109 |
110 | 默认格式为不带时区的完整 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) 格式,并且用空格代替字母 `T` ,就像 `2006-01-02 15:04:05`。如果你懒得查阅文档,想要自己构建的话,这里有一些 `day.js` 格式:
111 |
112 | - `new Date().toLocaleString('en-US')`: `M/D/YYYY, h:mm:ss A` ,效果是 `1/2/2006, 3:04:05 PM`。
113 | - `new Date().toLocaleString('en-GB')`: `DD/MM/YYYY, HH:mm:ss` ,效果是 `02/01/2006, 15:04:05`。
114 | - `new Date().toLocaleString('zh-cn')` 将 上/下午 替换为 A/PM: `YYYY/M/D A h:mm:ss` ,效果是 `2006/1/2 PM 3:04:05`。
115 |
--------------------------------------------------------------------------------
/src/pages/docs/advanced.en.mdx:
--------------------------------------------------------------------------------
1 | import Callout from 'nextra-theme-docs/callout'
2 | import Encryption from '../../components/encryption'
3 |
4 | # Advanced
5 |
6 | Continuously updating here.
7 |
8 | Some of the more advanced configurations here. You may or may not be looking for them.
9 |
10 | ## Using your own `clientId` and `clientSecret`
11 |
12 | If you are not the admin of your OneDrive account, you may not be able to use the project's `clientId` and `clientSecret` provided by me. In this case, you would need to generate your own client id and secret for authentication.
13 |
14 | ### Register a new application
15 |
16 | Open the following link:
17 |
18 | - [Microsoft Azure App registrations](https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade) (for OneDrive international, OneDrive for Business or Education), or...
19 | - [Microsoft Azure.cn App registrations](https://portal.azure.cn/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade) (OneDrive 世纪互联版本)
20 |
21 | Create a new blade app:
22 |
23 | 1. Login with your Microsoft account, select _New registration_.
24 | 2. Enter the _Name_ for your blade app, `my-onedrive-vercel-index` for example.
25 | 3. Set _Supported account types_ to:
26 |
27 | ```
28 | Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)
29 | ```
30 |
31 | OneDrive 世纪互联用户设置为 - 任何组织目录(任何 Azure AD 目录 - 多租户)中的帐户.
32 |
33 | 4. Set _Redirect URI (optional)_ to `Web` (the multiselect dropdown) and `http://localhost` (the URL).
34 | 5. Click Register.
35 |
36 | 
37 |
38 | ### Get your client id and secret
39 |
40 | Your Application (client) ID is the `clientId` to appear in your `api.config.js`. It should be present at _Overview_ > _Essentials_.
41 |
42 | 
43 |
44 | Your client secret needs to be generated manually:
45 |
46 | 1. Open _Certificates & secrets panel_.
47 | 2. Click _New client secret_.
48 | 3. Create a new secret with description `client_secret`.
49 | 4. Set _Expires_ to `Custom`.
50 | 5. Change _Start_ and _End_ to the longest available time duration available.
51 |
52 | 
53 |
54 | Finally, click _Add_, and copy the Value of the client_secret (You only have this one chance to copy it).
55 |
56 | 
57 |
58 | ### Modify API permissions
59 |
60 | Microsoft Graph API comes with API permission scopes. Our project only requires the following (which are defined in `api.config.js`):
61 |
62 | ```
63 | user.read files.read.all offline_access
64 | ```
65 |
66 | Open _API permissions_, select _Microsoft Graph_, select _Delegated permissions_, and search for:
67 |
68 | - User.Read (this should already be available)
69 | - Files.Read.All
70 | - offline_access
71 |
72 | Select all three of them and click _Add permissions_.
73 |
74 | 
75 |
76 | At this point, you should have your `clientId` and `clientSecret` ready.
77 |
78 | ### Modify configs in `api.config.js`
79 |
80 | You can directly replace `clientId` with your generated `clientId`.
81 |
82 | However, client secret is more involved. You need to obfuscate it with AES encryption.
83 |
84 |
85 |
86 | You should get an obfuscated client secret which looks like:
87 |
88 | ```
89 | U2FsdGVkX1830zo3/pFDqaBCVBb37iLw3WnBDWGF9GIB2f4apzv0roemp8Y+iIxI3Ih5ecyukqELQEGzZlYiWg==
90 | ```
91 |
92 | Replace the `obfuscatedClientSecret` with this value.
93 |
94 | If you changed `redirectUri` to something other than `http://localhost`, you need to change that in `api.config.js` as well.
95 |
96 |
97 | Discussed at: [关于使用自己的 secret 进行 AES
98 | 加密方式的小白解决办法](https://github.com/spencerwooo/onedrive-vercel-index/discussions/234).
99 |
100 |
101 | ## Setting up a custom domain
102 |
103 | Check out [Custom Domains - Vercel](https://vercel.com/docs/concepts/projects/custom-domains).
104 |
--------------------------------------------------------------------------------
/src/pages/blog/whats-new.zh.md:
--------------------------------------------------------------------------------
1 | # 更新日志
2 |
3 | 🎉 此项目的更新内容将在此页持续记录,详情请参考 [What's new? #325](https://github.com/spencerwooo/onedrive-vercel-index/discussions/325)。
4 |
5 | #### 2022/2/14 💞
6 |
7 | - 除了受密码保护的文件夹,以及文件直链 API 路径外,其他所有 API 路径均使用 Vercel 边缘缓存(有效期 1 分钟):
8 |
9 | ```
10 | Cache-Control: max-age=0, s-maxage=60, stale-while-revalidate
11 | ```
12 |
13 | - 文件直链 API 由 `/api?path=&raw=true` 更改为 `/api/raw?path=`,无缓存。
14 | - 文件直链 API 接受 URL 参数 `&odpt=` 用于受密码保护文件的鉴权。
15 |
16 | #### 2022/2/10
17 |
18 | - 🚀 性能提升:
19 | - 缩略图现在在文件完成加载后单独进行请求。因为减少了 OneDrive API 的请求量,所以提升了些许文件夹列表加载速度。
20 | - **启用 Vercel 边缘缓存。** 我们使用了 Vercel 的边缘函数缓存以及 `stale-while-revalidate` 功能,你将体验到飞快的文件列表加载速度。 **边缘缓存一分钟内有效。** 参考:[🚀 Edge caching #407](https://github.com/spencerwooo/onedrive-vercel-index/discussions/407)
21 | - 👨💻 代码高亮: 我们不再使用 `Prism.js` 依赖,代码高亮现在由 `react-syntax-highlighter` 处理。(内部使用 `highlight.js`,对不同语言的高亮支持是异步导入的,所以高亮会在代码加载完成后显示。)
22 |
23 | | Light | Dark |
24 | | :-------------------------------------------------------------: | :-----------------------------------------------------------: |
25 | |  |  |
26 |
27 | - 🎸 音频预览(音乐播放器)现在能显示音频封面了!
28 |
29 | 
30 |
31 | #### 2022/2/8
32 |
33 | - 🇨🇳/🇬🇧 - 项目已汉化 🥱
34 | - 🎥 已支持 `.flv` 格式的视频
35 | - 🔗 加强复制的链接的可读性
36 |
37 | ```diff
38 | - before: /api?path=/%F0%9F%8E%BB%20Genshin%20playlist/%E3%80%90%E5%8E%9F%E7%A5%9E%E3%80%91%E8%83%A1%E6%A1%83%EF%BC%9A%E5%95%8A%E5%AF%B9%E5%AF%B9%E5%AF%B9%E5%AF%B9.mp4&raw=true
39 | + after: /api?path=/🎻%20Genshin%20playlist/【原神】胡桃:啊对对对对.mp4&raw=true
40 | ```
41 |
42 | - 📅 你现在可以在 `site.config.js` 的 `datetimeFormat` 自定义日期格式了。
43 |
44 | #### 2022/2/5
45 |
46 | - 💠 正式支持布局切换,新增带缩略图预览的网格布局。
47 |
48 | 
49 |
50 | - 🗑 我们不再使用高性能消耗较高的 `react-viewer`。
51 |
52 | #### 2022/2/2
53 |
54 | - 🎥 我们删除了 `react-player` 而使用可靠的 `react-dplayer` 与 `react-audio-player` 来播放视频与音频。
55 | - 🎇 我们现在还能为视频显示缩略图:
56 |
57 | | Before | After |
58 | | :----------------------------------------------------------------------: | :-----------------------------------------------------------------: |
59 | |  |  |
60 |
61 | - 💬 我们添加了对 WebVTT 字幕的支持,你只需要将 `.vtt` 后缀的与视频文件名相同的字幕文件放置在同一个文件夹下即可。
62 |
63 | | Before | After |
64 | | :---------------------------------------------------------------------: | :--------------------------------------------------------------------------: |
65 | |  |  |
66 |
67 | - ⚡️ 我们将包管理器从 `npm` 更换为 `pnpm` 以减少部署时间。你需要在 Vercel 中修改以下设置:
68 |
69 | 
70 |
71 | - Build command: `pnpm build`
72 | - Install command: `pnpm install`
73 |
74 | #### 2022/1/29
75 |
76 | - ❗**重要** - 配置文件已从 `.json` 更换为 `.config.js` ,并添加了注释。同时为了隐私着想,现在你还可以将 `userPrincipleName` 在 Vercel 的环境变量里定义。
77 | - CORS 头现在出现在 OneDrive 的 ~~`?raw=true`~~ `/api/raw` 文件直链路由中。
78 |
79 | #### 2022/1/22
80 |
81 | - 🔍 [Supporting search for all versions of OneDrive #295](https://github.com/spencerwooo/onedrive-vercel-index/discussions/295)
82 |
83 | #### 2022/1/11
84 |
85 | - 📚 [New documentation site live #264](https://github.com/spencerwooo/onedrive-vercel-index/discussions/264)
86 |
87 | #### 2022/1/10
88 |
89 | - 🚫 为遵循 Vercel 服务条款,代理下载已被移除。 [Proxied download not working - 无法使用代理下载 #251](https://github.com/spencerwooo/onedrive-vercel-index/discussions/251)
90 |
91 | #### 2022/1/1
92 |
93 | - 🚀 我们在部署时不再需要额外的获取 token/secret 的步骤。 [New version update: No extra deployment setup is required anymore! #215](https://github.com/spencerwooo/onedrive-vercel-index/discussions/215)
94 |
--------------------------------------------------------------------------------
/src/pages/blog/whats-new.en.md:
--------------------------------------------------------------------------------
1 | # What's new?
2 |
3 | 🎉 This is a constantly updating page of new updates for this project. Also available at [What's new? #325](https://github.com/spencerwooo/onedrive-vercel-index/discussions/325).
4 |
5 | #### 2022/2/14 💞
6 |
7 | - Other than password protected routes, and raw file link redirect API, all other API routes are using Vercel edge caching mechanisms (fresh for 60 seconds):
8 |
9 | ```
10 | Cache-Control: max-age=0, s-maxage=60, stale-while-revalidate
11 | ```
12 |
13 | - Raw file link redirect API changed from `/api?path=&raw=true` to `/api/raw?path=`, no cache applied.
14 | - Raw file link redirect API accepts the URL parameter `&odpt=` for password authentication.
15 |
16 | #### 2022/2/10
17 |
18 | - 🚀 A few performance boosts:
19 | - Thumbnails are now requested separately after files are initially loaded. This improves file load performance as we are requesting fewer items from OneDrive's API on initial request. (However your thumbnails may load slower for half a second or so.)
20 | - **Edge caching is now in use:** we are now leveraging Vercel's edge function caching and `stale-while-revalidate` options, so you should experience extremely faster load speed for all API routes.) **Cache is valid for 60 seconds on the edge.** Check: [🚀 Edge caching #407](https://github.com/spencerwooo/onedrive-vercel-index/discussions/407).
21 | - 👨💻 Code highlighting: we dropped dependency `Prism.js`, syntax highlighting is now performed by `react-syntax-highlighter` (using `highlight.js` under-the-hood. Support for different languages are imported asynchronous (so you may see a slight delay before the code is actually highlighted).
22 |
23 | | Light | Dark |
24 | | :-------------------------------------------------------------: | :-----------------------------------------------------------: |
25 | |  |  |
26 |
27 | - 🎸 Audio preview (music player) now shows the thumbnail of the album if available.
28 |
29 | 
30 |
31 | #### 2022/2/8
32 |
33 | - 🇨🇳/🇬🇧 - Project is i18n-ed, enjoy. 🥱
34 | - 🎥 `.flv` videos are now supported.
35 | - 🔗 Links copied to your clipboards are now formatted in a human-readable way.
36 |
37 | ```diff
38 | - before: /api?path=/%F0%9F%8E%BB%20Genshin%20playlist/%E3%80%90%E5%8E%9F%E7%A5%9E%E3%80%91%E8%83%A1%E6%A1%83%EF%BC%9A%E5%95%8A%E5%AF%B9%E5%AF%B9%E5%AF%B9%E5%AF%B9.mp4&raw=true
39 | + after: /api?path=/🎻%20Genshin%20playlist/【原神】胡桃:啊对对对对.mp4&raw=true
40 | ```
41 |
42 | - 📅 You can now customise your date formats in `site.config.js` under `datetimeFormat`.
43 |
44 | #### 2022/2/5
45 |
46 | - 💠 Layout switching is now supported! Grid layouts with thumbnail previews are now available.
47 |
48 | 
49 |
50 | - 🗑 We have dropped usage of `react-viewer` which is unperformant and causes high CPU usages.
51 |
52 | #### 2022/2/2
53 |
54 | - 🎥 We have dropped usage of `react-player` and is now using `react-dplayer` and `react-audio-player` as video and audio players respectively.
55 | - 🎇 We added thumbnail rendering for videos, see the difference:
56 |
57 | | Before | After |
58 | | :----------------------------------------------------------------------: | :-----------------------------------------------------------------: |
59 | |  |  |
60 |
61 | - 💬 We added support for subtitles (closed captions), which are auto referenced if a valid subtitle file with the same name as the video and in `.vtt` webvtt format is present.
62 |
63 | | Before | After |
64 | | :---------------------------------------------------------------------: | :--------------------------------------------------------------------------: |
65 | |  |  |
66 |
67 | - ⚡️ We have migrated from `npm` to `pnpm` as project's package manager for faster build speed and more efficient cache usage. You may need to update your Vercel's build commands:
68 |
69 | 
70 |
71 | - Build command: `pnpm build`
72 | - Install command: `pnpm install`
73 |
74 | #### 2022/1/29
75 |
76 | - ❗**Breaking** - Config files changed from `.json` to `.config.js`, relevant comments added. You can now move `userPrincipleName` to Vercel's environment variables (to avoid exposing your email address publicly).
77 | - CORS headers are now present in ~~`?raw=true`~~ `/api/raw` routes for OneDrive raw file links.
78 |
79 | #### 2022/1/22
80 |
81 | - 🔍 [Supporting search for all versions of OneDrive #295](https://github.com/spencerwooo/onedrive-vercel-index/discussions/295)
82 |
83 | #### 2022/1/11
84 |
85 | - 📚 [New documentation site live #264](https://github.com/spencerwooo/onedrive-vercel-index/discussions/264)
86 |
87 | #### 2022/1/10
88 |
89 | - 🚫 Removed support for proxied download because of Vercel restrictions: [Proxied download not working - 无法使用代理下载 #251](https://github.com/spencerwooo/onedrive-vercel-index/discussions/251).
90 |
91 | #### 2022/1/1
92 |
93 | - 🚀 We now no longer need extra deployment tokens/secret setups: [New version update: No extra deployment setup is required anymore! #215](https://github.com/spencerwooo/onedrive-vercel-index/discussions/215)
94 |
--------------------------------------------------------------------------------
/src/pages/docs/custom-configs.en.mdx:
--------------------------------------------------------------------------------
1 | import Callout from 'nextra-theme-docs/callout'
2 | import Bleed from 'nextra-theme-docs/bleed'
3 | import Video from '../../components/video'
4 |
5 | # Custom configurations
6 |
7 | There are two config files: `config/api.config.js` and `config/site.config.js`.
8 |
9 | - `config/api.config.js` - is used to define your API endpoints and tokens. **OneDrive international users don't have to change anything.**
10 | - `config/site.config.js` - is used for customising the website, such as the folder to share, the title, used Google fonts, site icons, contact info, etc.
11 |
12 | ## Configuring custom API settings
13 |
14 | Only make changes here if you think you have to.
15 |
16 | - If you are not the admin of your OneDrive account (which may happen to OneDrive business, educational or E5 subscription accounts), you may need to define your own `clientId` and `obfuscatedClientSecret`. More on this here [Using your own client id and secret](./advanced#using-your-own-clientid-and-clientsecret-1).
17 | - If you are a OneDrive 世纪互联 user, you should change `authApi` and `driveApi` (which you should have already done so in [Getting started - Modify API settings](./getting-started#modify-api-settings-optional-1)).
18 |
19 | {/* you may also need to change `directLinkRegex` to use the proxied download functions. Check here [Proxied download (disabled)](todo). */}
20 |
21 | ## Customising your website
22 |
23 | A couple of configurations are extracted for you to customise your site, these customisations live in `config/site.config.js`.
24 |
25 | ### `userPrincipalName`
26 |
27 | You have already defined this in [Getting started](./getting-started#customise-site-settings) for the OAuth process.
28 |
29 | ### `icon` - Icons and favicons
30 |
31 | 
32 |
33 | `icon` - is the website icon to the left of the title inside the navigation bar. **It should be placed under the [`/public`](https://github.com/spencerwooo/onedrive-vercel-index/tree/main/public) directory of your GitHub project (not your OneDrive folder!)**, and referenced here by its relative path to `/public`.
34 |
35 | For example, if your onedrive-vercel-index's GitHub project's `/public` directory holds:
36 |
37 | ```
38 | .
39 | ├── favicon-16x16.png
40 | ├── favicon-32x32.png
41 | ├── favicon.ico
42 | ├── icons
43 | │ └── 64.png
44 | └── ...
45 | ```
46 |
47 | And say you want to use `64.png` as your website's icon, then you should change `icon` in `site.config.js` to `/icons/64.png`, and you should be good to go. The favicons of your website should also be placed here under `/public` directly, you can use [favicon.io](http://favicon.io) to generate favicons with your image, and replace the favicons set in the main project.
48 |
49 | ### `title` - Site title
50 |
51 | The name of your website. Present alongside your icon.
52 |
53 | ### `baseDirectory`
54 |
55 | The folder that you are to share publicly with onedrive-vercel-index. You should have already defined this.
56 |
57 | ### `maxItems`
58 |
59 | `maxItems` - represents the maximum number of items that one directory lists, pagination supported. This is limited up to 200 items by the upstream OneDrive API.
60 |
61 |
62 | Try pagination here: [https://drive.swo.moe/🥟 Some test
63 | files/Imagenette](https://drive.swo.moe/%F0%9F%A5%9F%20Some%20test%20files/Imagenette).
64 |
65 |
66 | ### `googleFont` - Custom font family
67 |
68 | We use Google Font natively for font customisations.
69 |
70 | - `googleFontSans` - the sans serif font used in onedrive-vercel-index.
71 | - `googleFontMono` - the monospace font used in onedrive-vercel-index.
72 | - `googleFontLinks` - an array of links for referencing the google font assets.
73 |
74 | You can check and generate the required links and names at [fonts.google.com](https://fonts.google.com/).
75 |
76 | ### `footer`
77 |
78 | The footer component of your website. You can write HTML here, but you need to escape double quotes - changing `"` to `\"`. You can write anything here, and if you like badges, generate some with [shields.io](http://shields.io) 😃
79 |
80 | ### `protectedRoutes`
81 |
82 | This is where you specify the folders that are password protected. It is an array of paths pointing to all the directories in which you have `.password` set. More on this in [Password protected folders](./features/protected-folders).
83 |
84 | ### `email`
85 |
86 | `email` - is optional, and can be removed should you wish - by only leaving a `""` here.
87 |
88 | ```diff
89 | - "email": "mailto:spencer.wushangbo@gmail.com",
90 | + "email": "",
91 | ```
92 |
93 | However, I suggest adding some form of contact for your website.
94 |
95 | ### `links`
96 |
97 | `links` - is an array of `{ "name": "xxx", "link": "xxx" }`. In the latest update, all brand icons inside Font Awesome is supported and the icon to render is based on the `name` you provide. See the demo screen recording below.
98 |
99 |
100 | The additional links in the demo video are generated automatically by GitHub Copilot and may not be my personal
101 | account.
102 |
103 |
104 |
105 |
106 | For a full list of supported brand icons, visit: [Brand Icons | Font Awesome](https://fontawesome.com/icons?s=brands).
107 |
108 | ### `datetimeFormat`
109 |
110 | `datetimeFormat` - is a [`day.js`](https://day.js.org/)-style datetime format string to format datetimes in the app. Detailed specification can be found in [`day.js` Docs](https://day.js.org/docs/en/display/format).
111 |
112 | The default value is [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) full datetime without timezone and replacing character `T` with space, which looks like `2006-01-02 15:04:05`. Here are some other provided `day.js` format strings if you do not want to refer to its documentation and build them on your own:
113 |
114 | - `new Date().toLocaleString('en-US')`: `M/D/YYYY, h:mm:ss A`, which looks like `1/2/2006, 3:04:05 PM`.
115 | - `new Date().toLocaleString('en-GB')`: `DD/MM/YYYY, HH:mm:ss`, which looks like `2/1/2006, 15:04:05`.
116 | - `new Date().toLocaleString('zh-cn')` replacing 上/下午 with A/PM: `YYYY/M/D A h:mm:ss`, which looks like `2006/1/2 PM 3:04:05`.
117 |
--------------------------------------------------------------------------------
/src/pages/docs/getting-started.zh.mdx:
--------------------------------------------------------------------------------
1 | import Callout from 'nextra-theme-docs/callout'
2 |
3 | # 立即上手
4 |
5 | ## 太长不看版
6 |
7 | 这是一个简短的构建你自己的 onedrive-vercel-index 的指导。
8 |
9 | 1. Fork [此项目](https://github.com/spencerwooo/onedrive-vercel-index)。
10 | 2. 将 `site.config.js` 里的 `userPrincipleName` 改为你的微软账户邮箱。
11 | 3. 将 `site.config.js` 里的 `baseDirectory` 修改为你要分享的文件夹路径。
12 | 4. 根据你的 OneDrive 版本示情况修改 `api.config.js`。
13 | 5. 将你的项目导入到 Vercel 并 [添加 Upstash 插件](https://vercel.com/integrations/upstash) 以更方便地设置 `REDIS_URL` 环境变量。
14 | 6. 部署,并享受! 🎉
15 |
16 | 部署完成后的项目会引导你进行 OAuth 步骤,并自动将所需的凭证存储到 Redis 数据库里。这就是我们要做的全部事情!
17 |
18 | ## 立即上手(要来真的了!)
19 |
20 | 使用 onedrive-vercel-index 来共享、预览你的 OneDrive 里的文件、视频、音频、文档,并提供下载。
21 |
22 | 
23 |
24 | onedrive-vercel-index 本质上就是由 Next.js 构建的模板,你可以将其免费部署在 Vercel、Netlify 或者其他托管平台上。下面我们将 **完全从头开始** 创建你自己的 onedrive-vercel-index。
25 |
26 |
27 | 如果你在 2022 年之前部署过此项目,请参考 [迁移到 2022 年的新版本](./migration/if-you-deployed-before-2022)。
28 |
29 |
30 | ## Fork 此项目
31 |
32 | 将此项目 Fork 到你自己的 GitHub 账户中,因为你会需要维护一个包含你自己配置的项目。
33 |
34 | 
35 |
36 | ## 修改设置
37 |
38 | 有些设置是需要修改的。项目包括两个配置文件,分别是 `config/site.config.js` 与 `config/api.config.js`。前者是用来定制你的网页的,后者那个是用来定义 API 参数的。
39 |
40 | ### 客制化网站
41 |
42 | 请根据自身情况修改 [`config/site.config.js`](https://github.com/spencerwooo/onedrive-vercel-index/blob/main/config/site.config.js):
43 |
44 | - `userPrincipalName` - 是用来在 OAuth 步骤时认证你的个人信息的。通常是你的 **微软账户邮箱**。
45 | - `baseDirectory` - 是你要分享的 OneDrive 目录。你必须保证此目录有效且与此参数一致。(你可以直接在 OneDrive 内创建一个叫做 `Public` 文件夹,并将此项设置为 `/Public`。)
46 |
47 | 
48 |
49 | 有些设置是为你自定义自己的网页而准备的,详情请参考 [自定义配置](./custom-configs)。
50 |
51 | ### 修改 API 参数(可选项)
52 |
53 | 如果……
54 |
55 | - 你是 **OneDrive 国际版用户**(不是 OneDrive 企业版或教育版,不是 SharePoint 用户,不是 E5 订阅用户),请直接忽略此步骤,不要碰 `config/api.config.js`。
56 |
57 | 如果不是,**或者你自己觉得真的有必要修改**:
58 |
59 | - OneDrive 世纪互联使用了不同的 API 参数,所以我们要修改 `authApi` 和 `driveApi`
60 |
61 | 
62 |
63 | 将它们修改为:
64 |
65 | ```js
66 | authApi: "https://login.partner.microsoftonline.cn/common/oauth2/v2.0/token",
67 | driveApi: "https://microsoftgraph.chinacloudapi.cn/v1.0/me/drive",
68 | ```
69 |
70 | {/* 如果你需要使用代理下载功能,请修改 `directLinkRegex`。详情请参考 [Proxied download (disabled)](). */}
71 |
72 | - OneDrive 企业版、教育版以及 E5 订阅的用户需要注意:先尝试在不修改 `config/api.config.js` 的情况下进行 OAuth **无论你是否有管理权限**。如果你被告知需要管理权限,你就要使用你自己的 `clientId` 与 `clientSecret` 了。详情请参考 [使用你自己的 clientid 与 secret](./advanced)。
73 |
74 | ## 导入到 Vercel 并部署
75 |
76 | 在 Vercel 导入 **你自己的** onedrive-vercel-index GitHub 项目,并进行以下设置:
77 |
78 | - 修改 Build command 为 `pnpm build`.
79 | - 修改 Install command 为 `pnpm install`.
80 |
81 | 默认的也许能正常工作,但最好还是自定义这一项目。
82 |
83 | 
84 |
85 | 然后点击部署,Vercel 将会下载你的项目并进行部署。这次部署有可能会失败,这是因为我们还没有设定 `REDIS_URL` 环境变量。这就是我们接下来要做的。
86 |
87 | ### 连接到 Redis
88 |
89 | 创建一个 Redis 数据库,并且将数据库的访问链接填写到 Vercel 的 `REDIS_URL` 环境变量里。Redis 数据库是用于存储在 OAuth 时获取的 `access_tokens` 与 `refresh_tokens` 的。
90 |
91 | - 我们推荐使用 **Upstash** ,它完全免费,并且与 Vercel 深度合作,详情请参考 [Vercel Integration](https://docs.upstash.com/redis/howto/vercelintegration)。(请忽略最后一步时让你 _Create Your Redis Client_ ,onedrive-vercel-index 已经为你处理好了)。
92 | - 你可以使用你自己的 Redis 数据库,只要有 Vercel 能用的访问链接就行。
93 |
94 | 无论你用什么方式,你应该在 Vercel 的 `REDIS_URL` 环境变量里填好一个类似这样的 Redis URL:
95 |
96 | ```
97 | redis://:xxx...@some-thing-like-35533.upstash.io:35533
98 | ```
99 |
100 | 如果你为 Redis 数据库启用了 [传输加密](https://docs.upstash.com/redis/howto/connectwithtls):
101 |
102 | ```
103 | rediss://:xxx...@some-thing-like-35533.upstash.io:35533
104 | ```
105 |
106 | 
107 |
108 | ### 重新部署
109 |
110 | 最后,重新进行一次部署。并在部署完成后访问 Vercel 提供的链接,`onedrive-vercel-index` 将会引导你进行 OAuth 认证。你也可以在 Vercel 自定义访问链接,详情请参考 [自定义域名](./advanced)。
111 |
112 | 
113 |
114 | ## 进行认证
115 |
116 | 访问你的 `onedrive-vercel-index` ,如果你从未进行认证,OAuth 认证将会自动开始。
117 |
118 | ### 第一步 - 准备工作
119 |
120 | 
121 |
122 | 检查此页面上的参数是否正确,尤其是 `client_id` 与 `client_secret` (加密的),他们应该与你的项目里的一致。你还要检查一下 API 权限,应该只需要这三个:
123 |
124 | - `user.read`: 在进行 OAuth 时认证你的身份,防止某些傻逼通过重新认证雷普你的项目。
125 | - `files.read.all`: 用于访问你的 OneDrive 的文件
126 | - `offline_access`: 就是……用来离线访问 🙃
127 |
128 | 如果一切都准备好了,就来到第二步。如果有些什么差错,检查你的 `config/api.config.js` 然后重新部署。
129 |
130 | ### 第二步 - 获取认证码
131 |
132 | 
133 |
134 | 我们已经基于 `config/api.config.js` 给你准备好认证链接了。点击链接,你将会进入一个新标签页并进行登录。请确保你登陆的账户与你在 `config/site.config.js` 的 `userPrincipalName` 里设置的一致。
135 |
136 |
137 | 如果你的帐户没有管理权限,那么你需要使用你自己的 `client_id` 与 `client_secret`。详情请参考 [使用你自己的 clientid 与
138 | secret](./advanced)。
139 |
140 |
141 |  URL that you would be redirected to](./_images/getting-started/step2-redirect-code-localhost.png)
142 |
143 | 完成登录后,你将会跳转到 `http://localhost` ,尽管它显示无法访问,你只需要复制地址栏中的地址然后粘贴到第二步的输入框里。onedrive-vercel-index 会自动识别用于获取 `access_token` 与 `refresh_token` 的认证码,然后点击 _Get tokens_ 就行。
144 |
145 | ### 第三步 - 获取凭证
146 |
147 | 
148 |
149 | 你只需要等待几秒钟,页面上就会显示成功提示以及几行凭证,请点击 _Store tokens_ ,你的凭证就会保存到 Redis 数据库里。
150 |
151 |
152 | 这个过程中我们一直在检查 **你的身份** ,所以如果出现了 "Don't pretend to be the site owner" 提示,请检查
153 | `config/site.config.js` 里的 `userPrincipalName`是否填写正确。
154 |
155 |
156 | 最后,你将会跳转到你全新的 onedrive-vercel-index ,完成!
157 |
158 |
159 | 如果你认证结束后被重新跳转到步骤一,而你确认一切都没有问题时,**请等待几秒并手动回到主页再刷新**,Redis 数据库存取凭证需要一点儿时间。
160 |
161 |
--------------------------------------------------------------------------------
/src/pages/docs/getting-started.en.mdx:
--------------------------------------------------------------------------------
1 | import Callout from 'nextra-theme-docs/callout'
2 |
3 | # Getting started
4 |
5 | ## TL;DR
6 |
7 | Here's a quick too-long-don't-read guide on how to deploy your own onedrive-vercel-index.
8 |
9 | 1. Fork the repo [spencerwooo/onedrive-vercel-index](https://github.com/spencerwooo/onedrive-vercel-index).
10 | 2. Change `userPrincipleName` in `site.config.js` to your Microsoft account email address.
11 | 3. Change `baseDirectory` in `site.config.js` to a folder under your OneDrive root directory.
12 | 4. Optional - Check if you need to change `api.config.js`.
13 | 5. Import to Vercel and [add an Upstash integration](https://vercel.com/integrations/upstash), which imports `REDIS_URL` env var to Vercel.
14 | 6. Trigger a redeploy, and profit. 🎉
15 |
16 | The deployed onedrive-vercel-index will guide you through an authorisation process, and store the required tokens in the Redis database. That's all there is to do!
17 |
18 | ## Getting started (for real now!)
19 |
20 | onedrive-vercel-index uses your OneDrive as a storage host, and displays the files, images, videos, songs, and documents stored inside your OneDrive for other people to preview and download.
21 |
22 | 
23 |
24 | onedrive-vercel-index is actually a template built with Next.js, which you can host on Vercel, Netlify, or other serverless platforms completely for free. Here's how you would deploy your own onedrive-vercel-index **completely from scratch**.
25 |
26 |
27 | If you are updating from a project deployed before 2022, check out [If you deployed before
28 | 2022](./migration/if-you-deployed-before-2022).
29 |
30 |
31 | ## Fork the repo
32 |
33 | Fork the project to your own GitHub account, as you will be maintaining your custom version of this project with your own configurations.
34 |
35 | 
36 |
37 | ## Modify configs
38 |
39 | Some basic configuration modifications are required. Two config files include `config/site.config.js` and `config/api.config.js`. The former is for customising your website, and the latter is for configuring API routes.
40 |
41 | ### Customise site settings
42 |
43 | Modify [`config/site.config.js`](https://github.com/spencerwooo/onedrive-vercel-index/blob/main/config/site.config.js) according to your configs, where you must change:
44 |
45 | - `userPrincipalName` - used to verify your identity when doing OAuth. It is usually your _Microsoft email address_ when you log into your OneDrive.
46 | - `baseDirectory` - the base folder shared using onedrive-vercel-index. You must make sure that the folder exists inside your OneDrive. (You can also create a folder named `Public` in your OneDrive to keep things same with the main project.)
47 |
48 | 
49 |
50 |
51 | There are other optional configs for customising your site, please refer to [Custom configs](./custom-configs) for
52 | what they do.
53 |
54 |
55 | ### Modify API settings (optional)
56 |
57 | If ...
58 |
59 | - You are a **OneDrive international version user** (not OneDrive Business or Education account, not SharePoint user, not Microsoft 365 E5 user), you can ignore this step and leave `config/api.config.js` untouched.
60 |
61 | otherwise, **and only if you must !!!**
62 |
63 | - OneDrive 世纪互联 users have different API routes than what we usually use, you need to change `authApi` and `driveApi`:
64 |
65 | 
66 |
67 | Change them to:
68 |
69 | ```js
70 | authApi: "https://login.partner.microsoftonline.cn/common/oauth2/v2.0/token",
71 | driveApi: "https://microsoftgraph.chinacloudapi.cn/v1.0/me/drive",
72 | ```
73 |
74 | {/* You also need to change `directLinkRegex` if you want to use proxied download functions. More on this in [Proxied download (disabled)](). */}
75 |
76 | - OneDrive business, education accounts and E5 subscription accounts need to confirm **whether they have admin privileges**, proceed with untouched `config/api.config.js` and try the OAuth, if it does not work (telling you to sign in with an account with admin privileges), you then need to use your own `clientId` and `clientSecret` as the public one generated by me would not work on your account. More on this in [Using your own client id and secret](./advanced#using-your-own-clientid-and-clientsecret-1).
77 |
78 | ## Import and deploy in Vercel
79 |
80 | Import your **forked** onedrive-vercel-index GitHub project to Vercel. Change:
81 |
82 | - Build command to `pnpm build`.
83 | - Install command to `pnpm install`.
84 |
85 | The default commands may work, but it's always better to be explicit.
86 |
87 | 
88 |
89 | Then hit deploy. Vercel will automatically build and deploy your project. However, the deployment is likely to fail as you have not added the environment variable `REDIS_URL` yet, which is what we are going to do now.
90 |
91 | ### Create a Redis connection
92 |
93 | Create a Redis database, and set the URL of the Redis instance to environment variable `REDIS_URL` inside the Vercel project. The Redis database is used for storing the required `access_tokens` and `refresh_tokens` when interfacing with OneDrive's API.
94 |
95 | - You can use **Upstash** for this, completely free, full integration with Vercel, documentation here: [Vercel Integration](https://docs.upstash.com/redis/howto/vercelintegration) (ignore the final step _Create Your Redis Client_, that is already taken care of in onedrive-vercel-index).
96 | - You can also host any Redis server, use AWS, Google Cloud, Azure, etc. As long as you have a Redis URL that Vercel can use.
97 |
98 | Whatever method you use, you should have a `REDIS_URL` present in your environment variable in Vercel which should look like:
99 |
100 | ```
101 | redis://:xxx...@some-thing-like-35533.upstash.io:35533
102 | ```
103 |
104 | or:
105 |
106 | ```
107 | rediss://:xxx...@some-thing-like-35533.upstash.io:35533
108 | ```
109 |
110 | if you [enabled TLS (SSL)](https://docs.upstash.com/redis/howto/connectwithtls) on your upstash database.
111 |
112 | 
113 |
114 | ### Redeploy on Vercel
115 |
116 | Finally, trigger a redeployment on Vercel to use the new environment variable, navigate to the newly deployed page, and perform authorisation as guided by `onedrive-vercel-index`. The domains used by Vercel are listed in your project settings. You can also configure a custom domain here. (More on this in [Custom domain](./advanced#setting-up-a-custom-domain).)
117 |
118 | 
119 |
120 | ## Authenticate your onedrive-vercel-index
121 |
122 | Navigate to your newly deployed onedrive-vercel-index, usually [`https://xxx.vercel.app`](https://xxx.vercel.app) if you have not set a custom domain. As you are not authenticated yet, you will be redirected to the OAuth process.
123 |
124 | ### Step 1 - Preparations
125 |
126 | 
127 |
128 | Check for anything incorrect about your defined configurations. Especially `client_id` and `client_secret` (obfuscated), which should be exactly the same as the main project if you are using the public tokens for authentication. Also check for API scopes, we only require:
129 |
130 | - `user.read`: for checking your email against the account you use for OAuth, so that some random guy cannot f\*ck you up by re-authenticating with his/her account over and over again.
131 | - `files.read.all`: for access to the files inside your OneDrive.
132 | - `offline_access`: for ... offline access 🙃
133 |
134 | If everything seems correct, proceed to step 2. If not, you need to modify `config/api.config.js` and redeploy on Vercel.
135 |
136 | ### Step 2 - Get auth code
137 |
138 | 
139 |
140 | Based on `config/api.config.js` we have generated the OAuth link for you. Click on the link, a new tab will open and prompt you to login into your Microsoft account. Make sure you login with the same account you defined in `userPrincipalName` under `config/site.config.js`.
141 |
142 |
143 | If you are having privilege issues with your account, you may need to use your own `client_id` and `client_secret` for
144 | authentication. This may happen to OneDrive education or business users. More on this here: [Using your own client id
145 | and secret](./advanced#using-your-own-clientid-and-clientsecret-1).
146 |
147 |
148 |  URL that you would be redirected to](./_images/getting-started/step2-redirect-code-localhost.png)
149 |
150 | You will be directed to `http://localhost`, copy the entire URL in your address bar to the input section below. onedrive-vercel-index will extract the `code` from the URL and use that to acquire a pair of `access_token` and `refresh_token`. Click on _Get tokens_ to proceed.
151 |
152 | ### Step 3 - Get access and refresh tokens
153 |
154 | 
155 |
156 | Wait for a bit as the tokens need a bit to return. If all goes well, you would be greeted with this: success screen with a pair of valid tokens for you to store in your Redis database. Click on _Store tokens_ to proceed.
157 |
158 |
159 | Here we will validate that whether **you are actually you**, so if the button says "Don't pretend to be the site
160 | owner", go change the `userPrincipalName` under `config/site.config.js`, which is definitely wrong.
161 |
162 |
163 | Finally, you will be redirected home with your new and fresh onedrive-vercel-index. Enjoy!
164 |
165 |
166 | If you are redirected back to step 1, and you are certain that everything is setup correctly, **wait for a bit and try
167 | navigating home manually and do a hard refresh.** It sometimes take a while for the tokens to propagate through to
168 | Redis.
169 |
170 |
--------------------------------------------------------------------------------