Skip to main content

MkDocs plugin to display Codeforces user statistics as beautiful cards

Project description

mkdocs-codeforces-plugin

一个 MkDocs 插件,用于在文档网站上以美观的卡片形式展示 Codeforces 用户的统计信息。

功能特点

  • 显示用户的用户名、等级、积分等基本信息
  • 展示最近的提交记录及其状态
  • 展示最近参加的比赛及积分变化
  • 可自定义卡片宽度和主题(浅色/深色)
  • 内置缓存系统,避免频繁调用 API
  • 响应式设计,适配各种设备屏幕

安装方式

使用 pip 安装插件:

pip install mkdocs-codeforces-plugin

或者将其添加到你的 requirements.txt 文件中:

mkdocs-codeforces-plugin==0.1.2

配置说明

在你的 mkdocs.yml 文件中添加插件配置:

plugins:
  - codeforces:
      cache_dir: '.cache/codeforces'  # 缓存目录
      cache_ttl: 3600                 # 缓存有效期(秒)
      default_username: ''            # 默认 Codeforces 用户名
      default_width: '100%'           # 默认卡片宽度
      default_theme: 'light'          # 默认主题('light' 或 'dark')

CSS 文件已内置到插件中,无需手动添加到 extra_css。插件会自动管理样式,确保卡片显示正常。

使用方法

在你的 Markdown 文件中,使用 codeforces 标签来显示用户的统计信息:

{% codeforces username="你的_codeforces用户名" width="80%" theme="light" %}

参数说明:

  • username: Codeforces 用户名(必需)
  • width: 卡片宽度(可选,默认为配置中的值)
  • theme: 卡片主题,'light' 或 'dark'(可选,默认为配置中的值)

示例

# 我的 Codeforces 个人资料

这是我的 Codeforces 个人资料:

{% codeforces username="Eurekaimer" width="100%" theme="light" %}

缓存管理

插件会缓存 API 响应以减少对 Codeforces 的请求次数。你可以:

  • 通过 cache_ttl 调整缓存持续时间
  • 通过删除 cache_dir 中的文件手动清除缓存
  • 插件会在每次构建后自动清理过期的缓存文件

修改用户名

要修改插件中显示的用户名,您需要在 mkdocs.yml 配置文件中更新插件的配置:

plugins:
  - codeforces:
      username: Your_Codeforces_Username  # 在这里修改为您的用户名
      cache_dir: .cache/codeforces
      cache_ttl: 3600

或者,您也可以在使用 codeforces 标签时直接指定用户名参数:

<codeforces username="Your_Codeforces_Username" width="100%" theme="light"/>

许可证

本项目采用 MIT 许可证 - 详见 LICENSE 文件。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mkdocs_codeforces_plugin-0.1.2.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mkdocs_codeforces_plugin-0.1.2-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs_codeforces_plugin-0.1.2.tar.gz.

File metadata

File hashes

Hashes for mkdocs_codeforces_plugin-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3439dc5c8fe744056f8bcd2220642f4b9b61ce857e1e25c5c81acb8553840d73
MD5 4e7d850e112ac1c82ddae253b55ba0eb
BLAKE2b-256 b5211856c8c7203c0315ccaacc345dc3621cffe2b25b574a38ad1a4a5961d207

See more details on using hashes here.

File details

Details for the file mkdocs_codeforces_plugin-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocs_codeforces_plugin-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d538e11b0900b485eb855e83e54b18426f6c1b6dc6df4c07edd305b603ac4d51
MD5 651b82714d9b1c3e9c5a827432975bd7
BLAKE2b-256 fc27da5ca91612866d941b9b22ed7e27c5fb0b1b2375065a6c9f85977a6461a6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page