├── .github └── workflows │ └── build.yml ├── .gitignore ├── Gemfile ├── LICENSE ├── README.md ├── _config.yml ├── index.md └── script └── deploy.sh /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | - uses: actions/setup-ruby@v1 13 | with: 14 | ruby-version: 2.7 15 | - name: Setup cache for Bundler 16 | id: cache 17 | uses: actions/cache@v2 18 | with: 19 | path: vendor/bundle 20 | key: ${{ runner.os }}-bundler-2.7-${{ hashFiles('Gemfile') }} 21 | - name: Install dependencies 22 | run: bundle install --path=vendor/bundle 23 | - name: Build site 24 | run: bundle exec jekyll build --trace 25 | env: 26 | JEKYLL_ENV: production 27 | - name: Deploy 28 | run: | 29 | sudo apt-get -y install lftp 30 | bash script/deploy.sh 31 | env: 32 | EMAIL: ${{ secrets.EMAIL }} 33 | PASSWORD: ${{ secrets.PASSWORD }} 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Apache Subversion 2 | .svn 3 | 4 | # Bundler 5 | Gemfile.lock 6 | vendor/ 7 | .bundle/ 8 | 9 | # Jekyll 10 | .git-metadata 11 | .jekyll-cache 12 | .jekyll-metadata 13 | .sass-cache 14 | _site 15 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org/" 2 | 3 | gem 'github-pages', group: :jekyll_plugins 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 iBug (ibugone.com) 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # USTC-home-jekyll 2 | 3 | 想要快速在 [home.ustc.edu.cn](http://home.ustc.edu.cn) 或者 [staff.ustc.edu.cn](http://staff.ustc.edu.cn) 创建一个好看的主页?这个仓库就是你在找的资源! 4 | 5 | ## 如何使用 6 | 7 | 首先,[Fork](https://github.com/iBug/USTC-home-jekyll/fork) 这个仓库到你自己的账号下。 8 | 9 | 进入仓库的设置,Settings → Secrets,通过右上角的 New repository secret 按钮添加两个值: 10 | 11 | | 名称 (Name) | 内容 (Value) | 12 | | ----------- | ----------------------------------------------------------- | 13 | | `EMAIL` | 你的科大邮箱,以 `@mail.ustc.edu.cn` 或 `@ustc.edu.cn` 结尾 | 14 | | `PASSWORD` | 你的邮箱密码,用来通过 FTP 传输你的主页 | 15 | 16 | 然后,在你 Fork 的仓库中编辑 `_config.yml` 文件,找到 `baseurl:` 这一行,把它的值改成 `/~` 加上你的邮箱用户名部分。例如,如果你的邮箱是 `example@mail.ustc.edu.cn`,那么 `baseurl:` 后面就是 `/~example`。如果你的邮箱是以 `@ustc.edu.cn` 结尾的,那么你还应该把 `url:` 这一行改成 `http://staff.ustc.edu.cn`。 17 | 18 | 点击下面绿色的 Commit changes 按钮,等待 2~3 分钟(第一次推送时间会比较长),你就可以在 `http://home.ustc.edu.cn/~username` 这里看到你的新主页了,[就像这样](http://home.ustc.edu.cn/~ibug): 19 | 20 | ![Preview](https://image.ibugone.com/USTC-home-jekyll/preview.png) 21 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | url: http://home.ustc.edu.cn # Change to "http://staff.ustc.edu.cn" if you're a staff 2 | baseurl: /~ibug # Change to "/~" plus your email username 3 | 4 | theme: minima 5 | title: "My awesome home page" # Your home page name 6 | description: "Blah blah" # Your description 7 | 8 | exclude: 9 | - '.*' 10 | - '*.yml' 11 | - Dockerfile 12 | - Gemfile 13 | - Gemfile.lock 14 | - LICENSE 15 | - node_modules 16 | - package.json 17 | - package-lock.json 18 | - README.md 19 | - /script 20 | - vendor/bundle 21 | - vendor/cache 22 | - vendor/gems 23 | - vendor/ruby 24 | -------------------------------------------------------------------------------- /index.md: -------------------------------------------------------------------------------- 1 | # 我的科大主页 2 | 3 | 这里空空如也,快来写点东西吧! 4 | -------------------------------------------------------------------------------- /script/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # USTC-home-jekyll deploy script 4 | 5 | # Copyright (c) 2019 iBug (ibugone.com) 6 | # 7 | # Permission is hereby granted, free of charge, to any person obtaining a copy 8 | # of this software and associated documentation files (the "Software"), to deal 9 | # in the Software without restriction, including without limitation the rights 10 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | # copies of the Software, and to permit persons to whom the Software is 12 | # furnished to do so, subject to the following conditions: 13 | # 14 | # The above copyright notice and this permission notice shall be included in all 15 | # copies or substantial portions of the Software. 16 | # 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | # SOFTWARE. 24 | 25 | error() { 26 | echo "$@" >&2 27 | } 28 | 29 | check_env() { 30 | MISSING=() 31 | while [ $# -ne 0 ]; do 32 | if [ -z "${!1}" ]; then 33 | MISSING=("${MISSING[@]}" "$1") 34 | fi 35 | shift 36 | done 37 | if [ ${#MISSING} -ne 0 ]; then 38 | error -e "The following environment variables are missing:\n${MISSING[@]}" 39 | exit 1 40 | fi 41 | } 42 | 43 | parse_env() { 44 | USERNAME="${EMAIL%@*}" 45 | MAILHOST="${EMAIL##*@}" 46 | 47 | case "$MAILHOST" in 48 | mail.ustc.edu.cn) 49 | FTPHOST=home.ustc.edu.cn;; 50 | ustc.edu.cn) 51 | FTPHOST=staff.ustc.edu.cn;; 52 | *) 53 | error "Unknown email host: $MAILHOST" 54 | error -e "Only \e[1m@mail.ustc.edu.cn\e[0m and \e[1m@ustc.edu.cn\e[0m are recognized." 55 | exit 1;; 56 | esac 57 | } 58 | 59 | deploy() { 60 | lftp -c " 61 | set dns:order \"inet inet6\" 62 | set ftp:list-options -a 63 | open $1 64 | user $2 $3 65 | mirror --reverse --delete --verbose \"$4\" \"$5\" 66 | bye 67 | " 68 | } 69 | 70 | check_env EMAIL PASSWORD 71 | parse_env 72 | deploy "$FTPHOST" "$USERNAME" "$PASSWORD" "_site" "/public_html" 73 | --------------------------------------------------------------------------------