Skip to content

Commit

Permalink
Merge pull request #2 from jianboy/gogs1s
Browse files Browse the repository at this point in the history
Gogs1s v1.0
  • Loading branch information
jianboy authored Aug 6, 2021
2 parents 9b4de60 + 0b7151a commit 7aa37d8
Show file tree
Hide file tree
Showing 68 changed files with 838 additions and 5,263 deletions.
44 changes: 32 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ name: Node.js CI

on:
push:
branches:
- master
branches: [ master, gogs1s ]
pull_request:
branches:
- master
branches: [ master, gogs1s ]

jobs:
build:
Expand All @@ -18,11 +16,33 @@ jobs:
node-version: [14.x, 15.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn --frozen-lockfile
- run: yarn eslint
- run: yarn build
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-${{ matrix.node-version }}
- name: build
run: |
yarn --frozen-lockfile
yarn build
- name: artifact
uses: actions/upload-artifact@v2
with:
name: ${{runner.OS}}-artifact
path: |
dist
!*.map
48 changes: 24 additions & 24 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
name: Deploy on tags
# name: Deploy on tags

on:
push:
tags:
- v*
# on:
# push:
# tags:
# - v*

jobs:
deploy:
# jobs:
# deploy:

runs-on: ubuntu-latest
# runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: '14.x'
# steps:
# - uses: actions/checkout@v2
# - name: Setup Node
# uses: actions/setup-node@v1
# with:
# node-version: '14.x'

- run: yarn --frozen-lockfile
- run: yarn build
- run: yarn hash
# - run: yarn --frozen-lockfile
# - run: yarn build
# - run: yarn hash

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
cname: github1s.com
keep_files: true
# - name: Deploy
# uses: peaceiris/actions-gh-pages@v3
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: ./dist
# cname: github1s.com
# keep_files: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ lib
dist
out
node_modules
*.tar.gz
6 changes: 6 additions & 0 deletions .gitpod.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM gitpod/workspace-full

RUN sudo apt-get update \
&& sudo apt-get install -y \
g++ gcc make python2.7 pkg-config libx11-dev libxkbfile-dev libsecret-1-dev python-is-python3 rsync \
&& sudo rm -rf /var/lib/apt/lists/*
35 changes: 35 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
image:
file: .gitpod.Dockerfile
tasks:
- init: |
yarn
yarn build
command: |
echo "======================="
echo "Please run 'yarn watch'"
echo "======================="
- command: |
echo "==========================================================================="
echo "Please wait for 'yarn watch' to complete compilation, then run 'yarn serve'"
echo "==========================================================================="
ports:
- port: 5000
onOpen: open-browser
github:
prebuilds:
# enable for the master/default branch (defaults to true)
master: true
# enable for all branches in this repo (defaults to false)
branches: true
# enable for pull requests coming from this repo (defaults to true)
pullRequests: true
# enable for pull requests coming from forks (defaults to false)
pullRequestsFromForks: true
# add a check to pull requests (defaults to true)
addCheck: true
# add a "Review in Gitpod" button as a comment to pull requests (defaults to false)
addComment: true
# add a "Review in Gitpod" button to the pull request's description (defaults to false)
addBadge: false
# add a label once the prebuild is ready to pull requests (defaults to false)
addLabel: false
2 changes: 1 addition & 1 deletion .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
_
_
78 changes: 4 additions & 74 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,78 +1,8 @@
![GitHub1s](https://raw.githubusercontent.com/conwnet/github1s/master/resources/images/logo.png)
# github1s
![Gogs1s](resources/images/logo.png)
# Gogs1s

One second to read GitHub code with VS Code.

## Usage

Just add `1s` after `github` and press `Enter` in the browser address bar for any repository you want to read.

For example, try it on the VS Code repo:

[https://github1s.com/microsoft/vscode](https://github1s.com/microsoft/vscode)

![VS Code - GitHub1s](https://raw.githubusercontent.com/conwnet/github1s/master/resources/images/vs-code-github1s.png)

For browser extensions, see [Third-party Related Projects](https://github.com/conwnet/github1s#third-party-related-projects).

Or save the following code snippet as a bookmarklet (GitHub markdown doesn't allow js links, so just copy it into a bookmark).

```
javascript: window.location.href = window.location.href.replace('github.com', 'github1s.com')
```

## Documentation

- [How it works](https://github.com/conwnet/github1s/blob/master/docs/guide.md)
VSCode web online preview code for gogs.

## Screenshots

![VS Code - GitHub1s](https://raw.githubusercontent.com/mohitjaisal/github1s/master/resources/images/Github1sDemo1.gif)

![VS Code - GitHub1s](https://raw.githubusercontent.com/conwnet/github1s/master/resources/images/demo.png)

## Development

You need [these prerequisites (the same ones as for VS Code)](https://github.com/microsoft/vscode/wiki/How-to-Contribute#prerequisites) for development.

```bash
$ git clone [email protected]:conwnet/github1s.git
$ cd github1s
$ yarn
$ yarn watch
$ yarn serve # in another shell
$ # Then visit http://localhost:5000 or http://localhost:5000/conwnet/github1s once the build is completed.
```

## Build

```bash
$ yarn
$ yarn build
```

## Third-party Related Projects

### Chrome Extensions

- [zulhfreelancer](https://github.com/zulhfreelancer)/[Open in VS Code](https://chrome.google.com/webstore/detail/open-in-vs-code-github1sc/neloiopjjeflfnecdlajhopdlojlkhll)

- [fhefh2015/GitHub1s_chrome_extension](https://github.com/fhefh2015/GitHub1s_chrome_extension) - [Chrome Web Store](https://chrome.google.com/webstore/detail/github1s/lodjfmkfbfkpdhnhkcdcoonghhghbkhe)

- [febaoshan/edge-extensions-github-code-viewer](https://github.com/febaoshan/edge-extensions-github-code-viewer) - [Chrome Web Store](https://chrome.google.com/webstore/detail/github-code-viewer/ecddapgifccgblebfibdgkagfbdagjfn)

- [Darkempire78/Github1s-Extension](https://github.com/Darkempire78/Github1s-Extension)
- [zvizvi/Github Web IDE](https://github.com/zvizvi/github-web-ide) - [Chrome Web Store](https://chrome.google.com/webstore/detail/adjiklnjodbiaioggfpbpkhbfcnhgkfe)
- [katsuhisa91/github1s-shortcut](https://github.com/katsuhisa91/github1s-shortcut) - [Chrome Web Store](https://chrome.google.com/webstore/detail/shortcut-to-github1s/gfcdbodapcbfckbfpmgeldfkkgjknceo)

### Firefox Extensions

- [Darkempire78/Github1s-Extension](https://github.com/Darkempire78/Github1s-Extension) - [Firefox Browser Addons](https://addons.mozilla.org/firefox/addon/github1s-extension)
- [mcherifi/github1s-firefox-addon](https://github.com/mcherifi/github1s-firefox-addon) - [Firefox Browser Addons](https://addons.mozilla.org/firefox/addon/github1s/)
- [zvizvi/Github Web IDE](https://github.com/zvizvi/github-web-ide) - [Firefox Browser Addons](https://addons.mozilla.org/firefox/addon/github-web-ide/)


### Microsoft Edge Extensions

- [febaoshan/edge-extensions-github-code-viewer](https://github.com/febaoshan/edge-extensions-github-code-viewer)
- [zvizvi/Github Web IDE](https://github.com/zvizvi/github-web-ide)
![VS Code - Gogs1s](resources/images/4.gif)
8 changes: 8 additions & 0 deletions deploy/apache/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
34 changes: 34 additions & 0 deletions deploy/apache/code.git.yoqi.me.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<VirtualHost 115.28.243.165>
ServerAdmin [email protected]
DocumentRoot "/home/twtech/www/code.git.yoqi.me"
ServerName code.git.yoqi.me
ServerAlias ide.git.yoqi.me
php_admin_value open_basedir "/home/twtech/www/:/tmp/"

ErrorLog "/home/twtech/www/wwwlogs/code.git.yoqi.me_error_apache.log"
#CustomLog "/home/twtech/www/wwwlogs/code.git.yoqi.me_access_apache.log" common

<IfModule alias_module>
Alias /.well-known/acme-challenge "/home/twtech/tools/acme-tiny/challenges"
<Directory /home/twtech/tools/acme-tiny/challenges>
Options FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</IfModule>

<Directory "/home/twtech/www/code.git.yoqi.me">
SetOutputFilter DEFLATE
Options FollowSymLinks ExecCGI
#Require all granted
AllowOverride All
Order allow,deny
Allow from all
DirectoryIndex index.html index.php
</Directory>
#<Directory ~ ".*\.svn|.git|_svn/.*">
# Order allow,deny
# Deny from all
#</Directory>
</VirtualHost>
3 changes: 3 additions & 0 deletions deploy/nginx/code.git.yoqi.me.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
loation /{
try_files $uri $uri/ /index.html;
}
27 changes: 27 additions & 0 deletions deploy/nginx/git.yoqi.me.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
location /api/v1 {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
#
# Custom headers and headers various browsers *should* be OK with but aren't
#
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
#
# Tell client that this pre-flight info is valid for 20 days
#
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
}
22 changes: 14 additions & 8 deletions docs/guide.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# How it works

gogs1s 灵感来源于 Github1s,基于 gogs 版本管理系统开发,实现 gogs 系统预览代码功能。

Github1s is based on [VS Code 1.52.1](https://github.com/microsoft/vscode/tree/1.52.1) now. VS Code can be built for a browser version officially. I also used the code and got inspired by [Code Server](https://github.com/cdr/code-server).

Thanks to the very powerful and flexible extensibility of VS Code, we can easily implement a VS Code extension that provides the custom File IO ability using [FileSystemProvider API](https://code.visualstudio.com/api/references/vscode-api#FileSystemProvider). There is an official demo named [vscode-web-playground](https://github.com/microsoft/vscode-web-playground) which shows how it is used.
Expand All @@ -12,21 +14,25 @@ According to the above, obviously, the core concept of GitHub1s is to implement

GitHub1s is a purely static web app (because it really doesn't need a backend service, does it?). So we just deploy it on [GitHub Pages](https://pages.github.com/) now (the `gh-pages` branch of this repository), and it is free. The service of GitHub1s could be reliable (GitHub is very reliable) because nobody needs to pay the web hosting bills.

# Rate Limit

Another thing that needs attention is [Rate Limit](https://docs.github.com/en/rest/reference/rate-limit):
# Development

先安装:
```
sudo apt update
sudo apt install -y rsync
sudo apt install -y g++ gcc make python2.7 pkg-config libx11-dev libxkbfile-dev libsecret-1-dev
> For unauthenticated requests, the rate limit allows for up to 60 requests per hour. Unauthenticated requests are associated with the originating IP address, and not the user making requests.
sudo apt-get install build-essential
```

> For API requests using Basic Authentication or OAuth, you can make up to 5,000 requests per hour.

So, if you meet some problems when you use GitHub1s, even if you are using newer browsers, you could try to set a [GitHub OAuth Token](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#oauth2-token-sent-in-a-header). Don't worry, we cannot see your token. It is only stored in your browser [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) with [VS Code Extension globalState API](https://code.visualstudio.com/api/references/vscode-api#ExtensionContext) (Actually we don't have a server, do we?).
scripts/postinstall.sh

But this does not mean the token is absolutely safe, **don't forget to clean it while you are using a device that doesn't belong to you**.
git clone --depth 1 -b 1.52.1 https://hub.fastgit.org/microsoft/vscode.git vscode

# Development

As you see, running GitHub1s locally is not difficult. After cloning the repository, just run these commands:
执行:

```shell
$ yarn
Expand Down
Loading

0 comments on commit 7aa37d8

Please sign in to comment.