#1 gogs1s 产品原型

Open
opened 1 year ago by lyq · 3 comments
天问 commented 1 year ago

前言

最近在 github 看到 github1s 项目,只需要在github.com域名后加1s: https://github1s.com 就可以通过 vscode 在线预览代码,很方便。

查看 github1s 源码可以发现无需后台服务,这样小公司都可自己部署。

https://git.yoqi.me 基于 gogs 开发而来,为此可以结合 github1s 灵感,开发 gogs1s 功能,将 vscode 带入 gogs 系统中来。

构想

git.yoqi.me:

https://git.yoqi.me/lyq/gogs1s

gogs1s:

https://code.git.yoqi.me/lyq/gogs1s

## 前言 最近在 github 看到 github1s 项目,只需要在github.com域名后加1s: https://github1s.com 就可以通过 vscode 在线预览代码,很方便。 查看 github1s 源码可以发现无需后台服务,这样小公司都可自己部署。 https://git.yoqi.me 基于 gogs 开发而来,为此可以结合 github1s 灵感,开发 gogs1s 功能,将 vscode 带入 gogs 系统中来。 ## 构想 git.yoqi.me: https://git.yoqi.me/lyq/gogs1s gogs1s: https://code.git.yoqi.me/lyq/gogs1s ![](https://git.yoqi.me/attachments/e37670d3-b5b5-4c40-bc5c-4bc315fe7540)
天问 commented 1 year ago
Owner
There is no content yet.
天问 commented 1 year ago
Owner

API-docs

1、后台手动生成token,防止安全问题,新注册一个账户,不新建任何项目。只生成token来使用。

https://git.yoqi.me/api/v1/users/lyq/tokens

生成token之后,请求中加入 token=xxx。此外接口路径全部为: /api/v1 路径。

2、token加载请求参数中,或者请求头中。

code content接口:

https://git.yoqi.me/lyq/SkypeDemo/raw/main/SkypeDemo.sln

https://git.yoqi.me/api/v1/repos/lyq/SkypeDemo/raw/main/SkypeDemo.sln
https://git.yoqi.me/api/v1/repos/lyq/SkypeDemo/raw/main/SkypeDemo.sln?token=8bc0feea4ad91b28a9df5645c00f4235b77b4afa

目录树tree接口:

https://git.yoqi.me/api/v1/repos/lyq/SkypeDemo/contents/  # 根目录

https://git.yoqi.me/api/v1/repos/lyq/SkypeDemo/contents/SkypeDemo/UserControls  # SkypeDemo/UserControls目录

3、具体各个接口

用户

https://git.yoqi.me/api/v1/users/lyq/

https://git.yoqi.me/api/v1/users/MiniStar/

repo

  • 1、查看 repo 信息:

请求:GET /repos/:owner/:repo

https://try.gogs.io/api/v1/repos/s2fdg232/legado

返回结果:

{"id":31126,"owner":{"id":69388,"username":"s2fdg232","login":"s2fdg232","full_name":"","email":"fikic95453@mmgaklan.com","avatar_url":"https://secure.gravatar.com/avatar/39d3ee561697d071d96ebe69a08ed00c?d=identicon"},"name":"legado","full_name":"s2fdg232/legado","description":"","private":false,"fork":false,"parent":null,"empty":false,"mirror":true,"size":36544512,"html_url":"https://try.gogs.io/s2fdg232/legado","ssh_url":"git@try.gogs.io:s2fdg232/legado.git","clone_url":"https://try.gogs.io/s2fdg232/legado.git","website":"","stars_count":0,"forks_count":0,"watchers_count":1,"open_issues_count":0,"default_branch":"master","created_at":"2020-12-22T06:16:53Z","updated_at":"2021-08-01T08:09:59Z","permissions":{"admin":false,"push":false,"pull":true}}
  • 2、查看所有分支:

请求:GET /repos/:owner/:repo/branches

https://try.gogs.io/api/v1/repos/s2fdg232/legado/branches?token=e4262108ee9374301d1fa36079772b79f1abb6e6

返回结果:

[{"name":"master","commit":{"id":"ad71cfac7a70c789020fd78bf9ac4087afc8b1a8","message":"优化\n","url":"Not implemented","author":{"name":"gedoor","email":"gekunfei@live.com","username":""},"committer":{"name":"gedoor","email":"gekunfei@live.com","username":""},"added":null,"removed":null,"modified":null,"timestamp":"2021-08-01T08:09:59Z"}},{"name":"revert-1121-master","commit":{"id":"f36d3a894926f0771f5bb44681fb6c567c7f858a","message":"Revert \"修复与优化\"\n","url":"Not implemented","author":{"name":"kunfei","email":"gekunfei@live.com","username":""},"committer":{"name":"GitHub","email":"noreply@github.com","username":""},"added":null,"removed":null,"modified":null,"timestamp":"2021-07-16T09:27:12Z"}}]

3、查看指定分支:

https://try.gogs.io/api/v1/repos/s2fdg232/legado/branches/master?token=e4262108ee9374301d1fa36079772b79f1abb6e6

返回结果:

{
    "name": "master",
    "commit": {
        "id": "ad71cfac7a70c789020fd78bf9ac4087afc8b1a8",
        "message": "优化\n",
        "url": "Not implemented",
        "author": {
            "name": "gedoor",
            "email": "gekunfei@live.com",
            "username": ""
        },
        "committer": {
            "name": "gedoor",
            "email": "gekunfei@live.com",
            "username": ""
        },
        "added": null,
        "removed": null,
        "modified": null,
        "timestamp": "2021-08-01T08:09:59Z"
    }
}
  • 4、查看代码内容(raw源码格式),这个用来下载使用

GET /repos/:username/:reponame/raw/:ref/:path

https://try.gogs.io/api/v1/repos/s2fdg232/legado/raw/master/gradle/wrapper/gradle-wrapper.properties?token=e4262108ee9374301d1fa36079772b79f1abb6e6

上面的 :ref 还可以填 commit 的hash,查看指定提交的版本库内容:

https://try.gogs.io/api/v1/repos/s2fdg232/legado/raw/5da100a09c5edcaa576c9f99aeec8fd8f4f0f219/gradle/wrapper/gradle-wrapper.properties?token=e4262108ee9374301d1fa36079772b79f1abb6e6

  • 5、查看代码内容(json格式,content内容,base64编码),这个用来接口使用

GET /repos/:username/:reponame/contents/:path

参数: ref=master/HEAD 等

https://git.yoqi.me/api/v1/repos/Night-King/free/contents/README.md?ref=HEAD&token=8bc0feea4ad91b28a9df5645c00f4235b77b4afa

  • Git Trees

GET /repos/:owner/:repo/git/trees/:sha

https://try.gogs.io/api/v1/repos/s2fdg232/legado/git/trees/5da100a09c5edcaa576c9f99aeec8fd8f4f0f219?token=e4262108ee9374301d1fa36079772b79f1abb6e6

账号激活

https://git.yoqi.me/user/activate?code=2021080112540001802907ba44bcee1bf600eb9993bdcd3412466ee269746573743232323232

# API-docs ## 1、后台手动生成token,防止安全问题,新注册一个账户,不新建任何项目。只生成token来使用。 https://git.yoqi.me/api/v1/users/lyq/tokens 生成token之后,请求中加入 token=xxx。此外接口路径全部为: **/api/v1** 路径。 ## 2、token加载请求参数中,或者请求头中。 ### code content接口: ``` https://git.yoqi.me/lyq/SkypeDemo/raw/main/SkypeDemo.sln https://git.yoqi.me/api/v1/repos/lyq/SkypeDemo/raw/main/SkypeDemo.sln https://git.yoqi.me/api/v1/repos/lyq/SkypeDemo/raw/main/SkypeDemo.sln?token=8bc0feea4ad91b28a9df5645c00f4235b77b4afa ``` ### 目录树tree接口: ``` https://git.yoqi.me/api/v1/repos/lyq/SkypeDemo/contents/ # 根目录 https://git.yoqi.me/api/v1/repos/lyq/SkypeDemo/contents/SkypeDemo/UserControls # SkypeDemo/UserControls目录 ``` ## 3、具体各个接口 ### 用户 https://git.yoqi.me/api/v1/users/lyq/ https://git.yoqi.me/api/v1/users/MiniStar/ ### repo * 1、查看 repo 信息: 请求:GET /repos/:owner/:repo https://try.gogs.io/api/v1/repos/s2fdg232/legado 返回结果: ``` {"id":31126,"owner":{"id":69388,"username":"s2fdg232","login":"s2fdg232","full_name":"","email":"fikic95453@mmgaklan.com","avatar_url":"https://secure.gravatar.com/avatar/39d3ee561697d071d96ebe69a08ed00c?d=identicon"},"name":"legado","full_name":"s2fdg232/legado","description":"","private":false,"fork":false,"parent":null,"empty":false,"mirror":true,"size":36544512,"html_url":"https://try.gogs.io/s2fdg232/legado","ssh_url":"git@try.gogs.io:s2fdg232/legado.git","clone_url":"https://try.gogs.io/s2fdg232/legado.git","website":"","stars_count":0,"forks_count":0,"watchers_count":1,"open_issues_count":0,"default_branch":"master","created_at":"2020-12-22T06:16:53Z","updated_at":"2021-08-01T08:09:59Z","permissions":{"admin":false,"push":false,"pull":true}} ``` * 2、查看所有分支: 请求:GET /repos/:owner/:repo/branches https://try.gogs.io/api/v1/repos/s2fdg232/legado/branches?token=e4262108ee9374301d1fa36079772b79f1abb6e6 返回结果: ``` [{"name":"master","commit":{"id":"ad71cfac7a70c789020fd78bf9ac4087afc8b1a8","message":"优化\n","url":"Not implemented","author":{"name":"gedoor","email":"gekunfei@live.com","username":""},"committer":{"name":"gedoor","email":"gekunfei@live.com","username":""},"added":null,"removed":null,"modified":null,"timestamp":"2021-08-01T08:09:59Z"}},{"name":"revert-1121-master","commit":{"id":"f36d3a894926f0771f5bb44681fb6c567c7f858a","message":"Revert \"修复与优化\"\n","url":"Not implemented","author":{"name":"kunfei","email":"gekunfei@live.com","username":""},"committer":{"name":"GitHub","email":"noreply@github.com","username":""},"added":null,"removed":null,"modified":null,"timestamp":"2021-07-16T09:27:12Z"}}] ``` 3、查看指定分支: https://try.gogs.io/api/v1/repos/s2fdg232/legado/branches/master?token=e4262108ee9374301d1fa36079772b79f1abb6e6 返回结果: ``` { "name": "master", "commit": { "id": "ad71cfac7a70c789020fd78bf9ac4087afc8b1a8", "message": "优化\n", "url": "Not implemented", "author": { "name": "gedoor", "email": "gekunfei@live.com", "username": "" }, "committer": { "name": "gedoor", "email": "gekunfei@live.com", "username": "" }, "added": null, "removed": null, "modified": null, "timestamp": "2021-08-01T08:09:59Z" } } ``` * 4、查看代码内容(raw源码格式),这个用来下载使用 GET /repos/:username/:reponame/raw/:ref/:path https://try.gogs.io/api/v1/repos/s2fdg232/legado/raw/master/gradle/wrapper/gradle-wrapper.properties?token=e4262108ee9374301d1fa36079772b79f1abb6e6 上面的 :ref 还可以填 commit 的hash,查看指定提交的版本库内容: https://try.gogs.io/api/v1/repos/s2fdg232/legado/raw/5da100a09c5edcaa576c9f99aeec8fd8f4f0f219/gradle/wrapper/gradle-wrapper.properties?token=e4262108ee9374301d1fa36079772b79f1abb6e6 * 5、查看代码内容(json格式,content内容,base64编码),这个用来接口使用 GET /repos/:username/:reponame/contents/:path 参数: ref=master/HEAD 等 https://git.yoqi.me/api/v1/repos/Night-King/free/contents/README.md?ref=HEAD&token=8bc0feea4ad91b28a9df5645c00f4235b77b4afa * Git Trees GET /repos/:owner/:repo/git/trees/:sha https://try.gogs.io/api/v1/repos/s2fdg232/legado/git/trees/5da100a09c5edcaa576c9f99aeec8fd8f4f0f219?token=e4262108ee9374301d1fa36079772b79f1abb6e6 ### 账号激活 https://git.yoqi.me/user/activate?code=2021080112540001802907ba44bcee1bf600eb9993bdcd3412466ee269746573743232323232
天问 commented 1 year ago
Owner

部署问题

和 vue 等单入口项目一样,直接访问下面连接:

http://code.git.yoqi.me/conwnet/github1s/blob/HEAD/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts

会去找 titlebarPart.ts 文件,而不是把后面的路由作为参数传递。一种方法就是在后面如有中加入 # 号。

http://code.git.yoqi.me/#conwnet/github1s/blob/HEAD/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts

这样访问后面都作为参数进行处理,请求到 http://code.git.yoqi.me/index.html 位置,这样就可以前端路由处理。

在VUE项目中,通过在router ---->index 中 添加代码 mode:'history'(去除路由地址中的#)

.htaccess

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>

## 部署问题 和 vue 等单入口项目一样,直接访问下面连接: ``` http://code.git.yoqi.me/conwnet/github1s/blob/HEAD/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts ``` 会去找 titlebarPart.ts 文件,而不是把后面的路由作为参数传递。一种方法就是在后面如有中加入 # 号。 ``` http://code.git.yoqi.me/#conwnet/github1s/blob/HEAD/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts ``` 这样访问后面都作为参数进行处理,请求到 http://code.git.yoqi.me/index.html 位置,这样就可以前端路由处理。 在VUE项目中,通过在router ---->index 中 添加代码 mode:'history'(去除路由地址中的#) **.htaccess** ``` <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.html$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.html [L] </IfModule> ```
Sign in to join this conversation.
No Milestone
No assignee
1 Participants
Loading...
Cancel
Save
There is no content yet.