2 Star 43 Fork 4

yadong.zhang / gitee-stargazers

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

gitee-stargazers

将 Gitee 项目的 Star 数显示到统计图上。

官方示例:https://www.whnb.wang

:exclamation: :exclamation: 因用户量的剧增,导致官网服务器资源达到瓶颈。因此暂时暂停本服务,近期将会更新服务器资源后重新启用,感谢您的支持!由此带来的不便,敬请谅解!建议您直接使用 gitee-stargazers 本项目搭建一套专用服务。 :exclamation: :exclamation:

开发背景

目前开发者最常用的查看 star 趋势的工具一般都是 starchart.cc,比如:

Stargazers over time

但是这个工具不支持 Gitee 中的仓库,那怎么行!必须安排上!

使用方式

Npm

需要先修改配置 config/config.js

将标记为 '本地启动时需要修改该参数' 的部分替换为自己的实际内容

npm run start

Docker

# 1. 拉取镜像
docker pull justauth/gitee-stargazers:v1.11

# 2. 自建 redis,可使用 docker 或者使用本地安装(需要保证可被容器访问)

# 3. 运行容器
docker run \ 
  -d \ 
  -p 3000:3000 \ 
  -e GITEE_USERNAME={your gitee username} \ 
  -e GITEE_PASSWORD={your gitee password} \ 
  -e GITEE_CLIENT_ID={your gitee oauth app clientId} \ 
  -e GITEE_CLIENT_SECRET={your gitee oauth app clientSecret} \ 
  -e REDIS_HOST={redis host, default is 127.0.0.1} \ 
  -e REDIS_PORT={redis port, default is 6379} \ 
  -e REDIS_PASSWORD={redis password, required} \ 
  -e REDIS_DB_INDEX={default is 1} \ 
  -e REDIS_EXPIRE={redis cache expire time, default is 3600s} \ 
  -e REDIS_CONNECT_TIMEOUT={redis connect timeout, default is 3000} \ 
  -e CONTRIBUTORS_DIR={Directory for storing contributors' avatars} \  
  -e PROD=true \ 
  -v /var/log/gitee-stargazers/:/usr/src/app/log/ \ 
  -v /var/gs/contributors/:/usr/src/gs/contributors/ \ 
  --name gitee-stargazers \ 
  justauth/gitee-stargazers:v1.11
  • GITEE_USERNAME: 你的 Gitee 账号名
  • GITEE_PASSWORD: 你的 Gitee 账号密码
  • GITEE_CLIENT_ID: 你的 Gitee OAuth 应用的 clientId
  • GITEE_CLIENT_SECRET: 你的 Gitee OAuth 应用的 clientSecret
  • REDIS_HOST: redis host,默认 127.0.0.1
  • REDIS_PORT: redis 端口号,默认 6379
  • REDIS_PASSWORD: redis 密码,必须
  • REDIS_DB_INDEX: redis 数据库索引,默认 1
  • REDIS_EXPIRE: redis 缓存的过期时间,可选,默认 3600, 单位 秒
  • REDIS_CONNECT_TIMEOUT: redis 连接过期时间,可选,默认 3000, 单位秒
  • CONTRIBUTORS_DIR: 存放贡献者头像文件的路径
  • PROD: 是否为线上环境,字符串类型,当为 'true' 时, 会将 console 日志写入文件

启动 docker 后,可以通过以下命令查看日志:

  • 查看控制台业务日志:tail -f /var/log/gitee-stargazers/console-xxx.log
  • 查看请求访问日志:tail -f /var/log/gitee-stargazers/access-xxx.log

Docker Compose

新建 docker-compose.yml

version: '3.3'
services:
  app:
    image: "justauth/gitee-stargazers:v1.11"
    container_name: "gitee-stargazers"
    volumes:
      - /var/log/gitee-stargazers/:/usr/src/app/log/
    environment:
      # 是否为线上环境,字符串类型,当为 'true' 时, 会将 console 日志写入文件
      PROD: "true"
      # 你的 Gitee 账号名
      GITEE_USERNAME: "xx"
      # 你的 Gitee 账号密码
      GITEE_PASSWORD: "xx"
      # 你的 Gitee OAuth 应用的 clientId
      GITEE_CLIENT_ID: "xx"
      # 你的 Gitee OAuth 应用的 clientSecret
      GITEE_CLIENT_SECRET: "xx"
      # redis 连接 host,默认 127.0.0.1
      REDIS_HOST: 'redis'
      # redis 端口,默认 6379
      REDIS_PORT: 6379
      # redis 密码,必须,此处的密码为下方 redis 容器启动时指定的密码(--requirepass)
      REDIS_PASSWORD: "gs123456"
      # redis 连接超时时间,单位秒
      REDIS_CONNECT_TIMEOUT: 3
      # redis 缓存过期时间,单位秒
      REDIS_EXPIRE: 3600
      # redis 数据库索引,默认 1
      REDIS_DB_INDEX: 2
      # 存放贡献者头像文件的路径
      CONTRIBUTORS_DIR: /usr/src/gs/contributors
    ports:
      - "3000:3000"
    depends_on:
      - redis
    links:
      - redis
  redis:
    image: redis
    container_name: "gs_redis"
    command: redis-server --appendonly yes --requirepass gs123456
    ports:
      - "6379:6379"
    volumes:
      - /var/redis/:/data/

将上方 yml 文件中的 environment ,按照注释说明,修改为真实内容后通过 docker-compose 运行项目

docker-compose up -d

访问

浏览器访问:http://localhost:3000/{owner}/{repo} .

  • owner: 项目所有者,支持组织名、用户名、企业名
  • repo:仓库名

例如:http://localhost:3000/fujieid/jap

示例:

关于配置项

  • 项目中使用的密码模式获取 token, 所以需要配置 gitee 的账号密码,如果开发者介意此点,可以单独申请一个 gitee 账号。

  • OAuth 应用申请的时候 回调地址可以随便填,主要的是应用创建完成后的 clientIdclientSecret

  • expire 参数不建议太低(默认 3600 秒),太低的话容易触发 Gitee 限流,谨记谨记谨记,程序中已经限制了不可低于 3600。

  • 可以通过在 url 后面追加参数(e)的形式指定某一项目的缓存时间(不低于 3600 s),如:http://localhost:3000/{owner}/{repo}?e=10000,此种方式可以针对那种 star 数比较多的项目,因为短期的 star 增长趋势已经对整体不构成明显影响,为了提高访问速度,可以使用该方式。

  • 注意:如果已经通过http://localhost:3000/{owner}/{repo} 方式获取过数据,则?e=xx不会重置缓存,在缓存有效期内(1小时)不会重置缓存,只能等原缓存过期后才可使用?e=xx参数启用新的缓存时间

  • **console-xxx.log 中会打印出 redis 和 gitee 的账号密码!**请勿公开该文件!

特别说明

由于受 Gitee 接口限制,目前此项目暂时只能获取到两个月内的 star 数据,获取更多数据的方式,正在和 Gitee 技术沟通。

该问题已经得到解决,再次感谢官方大大的大力支持!

参考资料

index.htmlstyle.css 文件参考并改造自 caarlos0/starcharts项目

资源

参考命令

通过 Dockerfile 构建镜像

docker build -t justauth/gitee-stargazers:v1.11 .

push

docker push justauth/gitee-stargazers:v1.11

MIT License Copyright (c) 2021 yadong.zhang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

通过chart图表显示gitee项目的 star 趋势 展开 收起
NodeJS 等 4 种语言
MIT
取消

发行版 (2)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
NodeJS
1
https://gitee.com/yadong.zhang/gitee-stargazers.git
git@gitee.com:yadong.zhang/gitee-stargazers.git
yadong.zhang
gitee-stargazers
gitee-stargazers
master

搜索帮助