优化github首页

手拉手定制GitHub个人首页

白日不到处,青春恰自来。
苔花如米小,也学牡丹开。

xkloveme

前情提要

GitHub 最近被收购之后变得异常活跃各种优化不断

  • 基于python爬些自己想要的数据
  • 拥有自己的Action开启定时任务
  • 以自己命名的特殊库会展示到个人首页
    xkloveme/xkloveme is a special repository. Its README.md will appear on your public profile!

实施

方案清晰后可以,着手开发
md文件支持图片和svg,首页每日自动替换bing图片

新建GitHub同名库

当新建一个同名库的时候README.md文件内容会展示到个人首页

使用徽章

  1. shields.io/的徽章
    GitHub 徽标的官方网站是 shields.io/,我萌可以在官网预览绝大部分的徽标样式,然后选择自己喜欢的(当然首先需要适用于自己的目标项目)徽标,添加到自己的项目文档中去
  2. forthebadge.com/的徽章
    forthebadge
  3. 项目的徽章
    xkloveme

每日图片爬虫

  1. 人生苦短我用python
  2. 基于python3,爬https://cn.bing.com/的背景图
  • 导入对应的库
import bs4
import tools
from bs4 import BeautifulSoup
  • 爬背景图获取URL
    def getSource(self):
        img = ''
        url = 'https://cn.bing.com'
        req = [
            'user-agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Mobile Safari/537.36',
        ]
        res = self.T.getPage(url, req)
        if res['code'] == 200:
            soup = BeautifulSoup(res['body'], 'html.parser')
            img = url + soup.find(id='sh_url').get('value')
            return img
  • 生成md文件
if __name__ == '__main__':
    obj = Source()
    img = '[![每日壁纸](' + obj.getSource() + ')](https://www.jixiaokang.com)'
    readme = root / "README.md"
    readme_contents = open(readme, 'w')
    md = "\n".join(
        [
          '[![xkloveme](https://raw.githubusercontent.com/xkloveme/xkloveme/master/logo.svg)](https://www.jixiaokang.com)',
          '[![forthebadge](https://forthebadge.com/images/badges/ages-20-30.svg)](https://www.jixiaokang.com)  '
          '[![forthebadge](https://forthebadge.com/images/badges/for-you.svg)](https://www.jixiaokang.com)  '
          '[![forthebadge](https://forthebadge.com/images/badges/made-with-python.svg)](https://www.jixiaokang.com)',
          '[![xkloveme](https://raw.githubusercontent.com/xkloveme/xkloveme/master/slogan.svg)](https://www.jixiaokang.com)',
          "# 每日壁纸",
          img,
          '# 推荐链接🔗',
          '> [项目说明](https://github.com/xkloveme/xkloveme/blob/master/PROJECT.md)如果想展示您的主页🔗请`pr`,如有喜欢请关注\n',
        ]
    )
    link = root / "LINK.md"
    link_contents = open(link, 'r')
    link_list = link_contents.readlines()
    readme_contents.write(md)
    readme_contents.writelines(link_list)
    readme_contents.close()
  1. 配置CI,这里选用官方Action,速度快稳定性高,配置简单
  • 在项目新建Token
SIMONW_TOKEN:  ${{ secrets.SIMONW_TOKEN }} // 为了自动推送到库
  • 最重要的三个job
    - name: Install Python dependencies
      run: |
        python -m pip install -r requirements.txt
    - name: Update README
      env:
        SIMONW_TOKEN: ${{ secrets.SIMONW_TOKEN }}
      run: |-
        python main.py
        cat README.md
    - name: Commit and push if changed
      run: |-
        git diff
        git config --global user.email "readme-bot@example.com"
        git config --global user.name "README-bot"
        git add -A
        git commit -m "AUTO:👷‍♀️Updated content" || exit 0
        git push
  • 开启定时

    每小时32分会自动运行

schedule:
-  cron:  '32 * * * *'

大功告成

GitHub

参与进来

如果您也喜欢折腾的话,我在这里发起一个项目,以便展示您个人主页.

希望您可以fork此项目

git clone https://github.com/xkloveme/xkloveme.git --depth 1

定制您个人想要的主页

- [xkloveme 的主页](https://github.com/xkloveme)

各位姥爷请放心,每小时同步一次数据

项目地址


文章作者: xkloveme
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 xkloveme !
评论
 上一篇
属于你自己的云桌面 属于你自己的云桌面
云桌面 📝🎨 云桌面 地址 项目源码 反馈 云桌面 插件 全平台支持. windows, mac, linux. 说明online 国内 This project is a web page emulation of a part
2021-07-28 xkloveme
下一篇 
框架优化 框架优化
Ant 若依前端框架 文档:http://doc.rycloud.zmrit.com 预览: http://ruoyi.ant.zmrit.com v3 测试版: http://v3.ant.zmrit.com 下载和运行 安装依赖
2020-06-23 xkloveme
  目录