-
Notifications
You must be signed in to change notification settings - Fork 104
feat: Fast PR #901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
wangyantong2000
merged 14 commits into
hypertrons:master
from
wangyantong2000:feat/fast-pr
Nov 9, 2024
Merged
feat: Fast PR #901
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
456ca9c
add url parser and view
wangyantong2000 30011cf
add autoPR
wangyantong2000 2058c15
improve code
wangyantong2000 c74d79b
Change function name
wangyantong2000 60200d5
improve the automatic GitHub PR process
wangyantong2000 b343578
add language switch
wangyantong2000 8400172
add gitee
wangyantong2000 7036db4
Merge branch 'master' into feat/fast-pr
wangyantong2000 b4f5284
add oss rule
wangyantong2000 ccd690a
improve
wangyantong2000 02319d4
improve stackedit
wangyantong2000 efae66f
change oss url
wangyantong2000 0645022
add prompt and DOC
wangyantong2000 d1e41a0
add interval
wangyantong2000 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,24 @@ | ||
| const baseUrl = 'https://www.x-lab.info/oss101-bok/textbook/'; // Document URL prefix | ||
| const repoName = 'X-lab2017/oss101-bok'; // repository name | ||
| const branch = 'master'; // repository branch | ||
| const platform = 'Github'; // repository platform | ||
| export function OSS101TextbooksUrlParser(url: string) { | ||
| // Determine if the URL starts with the specified open finger path | ||
| console.log(url.startsWith(baseUrl)); | ||
| if (url.startsWith(baseUrl)) { | ||
| // Extract the remaining path | ||
| const docPath = url.replace(baseUrl, '').split('#')[0]; | ||
|
|
||
| // Splicing together the corresponding file path for repository | ||
| const filePath = `docs/textbook/${docPath.slice(0, -1)}.md`; | ||
|
|
||
| return { | ||
| filePath: filePath, | ||
| repoName: repoName, | ||
| branch: branch, | ||
| platform: platform, | ||
| }; | ||
| } | ||
| //If there is no match, return null | ||
| return null; | ||
| } |
This file contains hidden or 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,23 @@ | ||
| const baseUrl = 'https://www.x-lab.info/digital-textbooks/textbooks/'; // Document URL prefix | ||
| const repoName = 'X-lab2017/digital-textbooks'; // repository name | ||
| const branch = 'main'; // repository branch | ||
| const platform = 'Github'; // repository platform | ||
| export function digitalTextbooksUrlParser(url: string) { | ||
| // Determine if the URL starts with the specified open finger path | ||
| if (url.startsWith(baseUrl)) { | ||
| // Extract the remaining path | ||
| const docPath = url.replace(baseUrl, '').split('#')[0]; | ||
|
|
||
| // Splicing together the corresponding file path for repository | ||
| const filePath = `docs/textbooks/${docPath}index.md`; | ||
|
|
||
| return { | ||
| filePath: filePath, | ||
| repoName: repoName, | ||
| branch: branch, | ||
| platform: platform, | ||
| }; | ||
| } | ||
| //If there is no match, return null | ||
| return null; | ||
| } |
This file contains hidden or 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,32 @@ | ||
| import { digitalTextbooksUrlParser } from './digitalTextbooks-url-parser'; | ||
| import { openDiggerUrlParser } from './openDigger-url-parser'; | ||
| import { OSS101TextbooksUrlParser } from './OSS101Textbooks-url-parser'; | ||
|
|
||
| type UrlRule = { | ||
| domains: string[]; | ||
| ruleFunction: (url: string) => { filePath: string; repoName: string; branch: string; platform: string } | null; | ||
| }; | ||
| const urlRules: UrlRule[] = [ | ||
| { | ||
| domains: ['open-digger.cn', 'open-digger'], | ||
| ruleFunction: openDiggerUrlParser, | ||
| }, | ||
| { | ||
| domains: ['digital-textbooks', 'x-lab.info/digital-textbooks'], | ||
| ruleFunction: digitalTextbooksUrlParser, | ||
| }, | ||
| { | ||
| domains: ['x-lab.info/oss101-bok'], | ||
| ruleFunction: OSS101TextbooksUrlParser, | ||
| }, | ||
| ]; | ||
| export function matchFastPrUrl(url: string) { | ||
| for (const rule of urlRules) { | ||
| const isMatch = rule.domains.some((domain) => url.includes(domain)); | ||
| if (isMatch) { | ||
| const result = rule.ruleFunction(url); | ||
| return result; | ||
| } | ||
| } | ||
| return null; | ||
| } | ||
This file contains hidden or 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,7 +1,11 @@ | ||
| export const saveToken = (token: string) => { | ||
| localStorage.setItem('github_token', token); | ||
| export const saveGithubToken = (token: string) => { | ||
| chrome.storage.sync.set({ github_token: token }); | ||
| }; | ||
|
|
||
| export const getToken = (): string => { | ||
| return localStorage.getItem('github_token') || ''; | ||
| export const getGithubToken = (): Promise<string | null> => { | ||
| return new Promise((resolve) => { | ||
| chrome.storage.sync.get('github_token', (result) => { | ||
| resolve(result.github_token || null); | ||
| }); | ||
| }); | ||
| }; |
This file contains hidden or 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,23 @@ | ||
| const baseUrl = 'https://open-digger.cn/docs/'; // Document URL prefix | ||
| const repoName = 'X-lab2017/open-digger-website'; // repository name | ||
| const branch = 'master'; // repository branch | ||
| const platform = 'Github'; // repository platform | ||
| export function openDiggerUrlParser(url: string) { | ||
| // Determine if the URL starts with the specified open finger path | ||
| if (url.startsWith(baseUrl)) { | ||
| // Extract the remaining path | ||
| const docPath = url.replace(baseUrl, '').split('#')[0]; | ||
|
|
||
| // Splicing together the corresponding file path for repository | ||
| const filePath = `docs/${docPath}.md`; | ||
|
|
||
| return { | ||
| filePath: filePath, | ||
| repoName: repoName, | ||
| branch: branch, | ||
| platform: platform, | ||
| }; | ||
| } | ||
| //If there is no match, return null | ||
| return null; | ||
| } |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.