+ A powerful, elegant, and modern blog system.
+
+ English • 简体中文
+
+
+---
+
+DjangoBlog is a high-performance blog platform built with Python 3.10 and Django 4.0. It not only provides all the core functionalities of a traditional blog but also features a flexible plugin system, allowing you to easily extend and customize your website. Whether you are a personal blogger, a tech enthusiast, or a content creator, DjangoBlog aims to provide a stable, efficient, and easy-to-maintain environment for writing and publishing.
+
+## ✨ Features
+
+- **Powerful Content Management**: Full support for managing articles, standalone pages, categories, and tags. Comes with a powerful built-in Markdown editor with syntax highlighting.
+- **Full-Text Search**: Integrated search engine for fast and accurate content searching.
+- **Interactive Comment System**: Supports replies, email notifications, and Markdown formatting in comments.
+- **Flexible Sidebar**: Customizable modules for displaying recent articles, most viewed posts, tag cloud, and more.
+- **Social Login**: Built-in OAuth support, with integrations for Google, GitHub, Facebook, Weibo, QQ, and other major platforms.
+- **High-Performance Caching**: Native support for Redis caching with an automatic refresh mechanism to ensure high-speed website responses.
+- **SEO Friendly**: Basic SEO features are included, with automatic notifications to Google and Baidu upon new content publication.
+- **Extensible Plugin System**: Extend blog functionalities by creating standalone plugins, ensuring decoupled and maintainable code. We have already implemented features like view counting and SEO optimization through plugins!
+- **Integrated Image Hosting**: A simple, built-in image hosting feature for easy uploads and management.
+- **Automated Frontend**: Integrated with `django-compressor` to automatically compress and optimize CSS and JavaScript files.
+- **Robust Operations**: Built-in email notifications for website exceptions and management capabilities through a WeChat Official Account.
+
+## 🛠️ Tech Stack
+
+- **Backend**: Python 3.10, Django 4.0
+- **Database**: MySQL, SQLite (configurable)
+- **Cache**: Redis
+- **Frontend**: HTML5, CSS3, JavaScript
+- **Search**: Whoosh, Elasticsearch (configurable)
+- **Editor**: Markdown (mdeditor)
+
+## 🚀 Getting Started
+
+### 1. Prerequisites
+
+Ensure you have Python 3.10+ and MySQL/MariaDB installed on your system.
+
+### 2. Clone & Installation
+
+```bash
+# Clone the project to your local machine
+git clone https://github.com/liangliangyy/DjangoBlog.git
+cd DjangoBlog
+
+# Install dependencies
+pip install -r requirements.txt
+```
+
+### 3. Project Configuration
+
+- **Database**:
+ Open `djangoblog/settings.py`, locate the `DATABASES` section, and update it with your MySQL connection details.
+
+ ```python
+ DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.mysql',
+ 'NAME': 'djangoblog',
+ 'USER': 'root',
+ 'PASSWORD': 'your_password',
+ 'HOST': '127.0.0.1',
+ 'PORT': 3306,
+ }
+ }
+ ```
+ Create the database in MySQL:
+ ```sql
+ CREATE DATABASE `djangoblog` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
+ ```
+
+- **More Configurations**:
+ For advanced settings such as email, OAuth, caching, and more, please refer to our [Detailed Configuration Guide](/docs/config-en.md).
+
+### 4. Database Initialization
+
+```bash
+python manage.py makemigrations
+python manage.py migrate
+
+# Create a superuser account
+python manage.py createsuperuser
+```
+
+### 5. Running the Project
+
+```bash
+# (Optional) Generate some test data
+python manage.py create_testdata
+
+# (Optional) Collect and compress static files
+python manage.py collectstatic --noinput
+python manage.py compress --force
+
+# Start the development server
+python manage.py runserver
+```
+
+Now, open your browser and navigate to `http://127.0.0.1:8000/`. You should see the DjangoBlog homepage!
+
+## Deployment
+
+- **Traditional Deployment**: A detailed guide for server deployment is available here: [Deployment Tutorial](https://www.lylinux.net/article/2019/8/5/58.html) (in Chinese).
+- **Docker Deployment**: This project fully supports Docker. If you are familiar with containerization, please refer to the [Docker Deployment Guide](/docs/docker-en.md) for a quick start.
+- **Kubernetes Deployment**: We also provide a complete [Kubernetes Deployment Guide](/docs/k8s-en.md) to help you go cloud-native easily.
+
+## 🧩 Plugin System
+
+The plugin system is a core feature of DjangoBlog. It allows you to add new functionalities to your blog without modifying the core codebase by writing standalone plugins.
+
+- **How it Works**: Plugins operate by registering callback functions to predefined "hooks". For instance, when an article is rendered, the `after_article_body_get` hook is triggered, and all functions registered to this hook are executed.
+- **Existing Plugins**: Features like `view_count` and `seo_optimizer` are implemented through this plugin system.
+- **Develop Your Own Plugin**: Simply create a new folder under the `plugins` directory and write your `plugin.py`. We welcome you to explore and contribute your creative ideas to the DjangoBlog community!
+
+## 🤝 Contributing
+
+We warmly welcome contributions of any kind! If you have great ideas or have found a bug, please feel free to open an issue or submit a pull request.
+
+## 📄 License
+
+This project is open-sourced under the [MIT License](LICENSE).
+
+---
+
+## ❤️ Support & Sponsorship
+
+If you find this project helpful and wish to support its continued maintenance and development, please consider buying me a coffee! Your support is my greatest motivation.
+
+
+
+
+
+
+ (Left) Alipay / (Right) WeChat
+
+
+## 🙏 Acknowledgements
+
+A special thanks to **JetBrains** for providing a free open-source license for this project.
+
+
+
+---
+> If this project has helped you, please leave your website URL [here](https://github.com/liangliangyy/DjangoBlog/issues/214) to let more people see it. Your feedback is the driving force for my continued updates and maintenance.
diff --git a/src/docs/config-en.md b/src/docs/config-en.md
new file mode 100644
index 0000000..b877efb
--- /dev/null
+++ b/src/docs/config-en.md
@@ -0,0 +1,64 @@
+# Introduction to main features settings
+
+## Cache:
+Cache using `memcache` for default. If you don't have `memcache` environment, you can remove the `default` setting in `CACHES` and change `locmemcache` to `default`.
+```python
+CACHES = {
+ 'default': {
+ 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
+ 'LOCATION': '127.0.0.1:11211',
+ 'KEY_PREFIX': 'django_test' if TESTING else 'djangoblog',
+ 'TIMEOUT': 60 * 60 * 10
+ },
+ 'locmemcache': {
+ 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
+ 'TIMEOUT': 10800,
+ 'LOCATION': 'unique-snowflake',
+ }
+}
+```
+
+## OAuth Login:
+QQ, Weibo, Google, GitHub and Facebook are now supported for OAuth login. Fetch OAuth login permissions from the corresponding open platform, and save them with `appkey`, `appsecret` and callback address in **Backend->OAuth** configuration.
+
+### Callback address examples:
+QQ: http://your-domain-name/oauth/authorize?type=qq
+Weibo: http://your-domain-name/oauth/authorize?type=weibo
+type is in the type field of `oauthmanager`.
+
+## owntracks:
+owntracks is a location tracking application. It will send your locaiton to the server by timing.Simple support owntracks features. Just install owntracks app and set api address as `your-domain-name/owntracks/logtracks`. Visit `your-domain-name/owntracks/show_dates` and you will see the date with latitude and langitude, click it and see the motion track. The map is drawn by AMap.
+
+## Email feature:
+Same as before, Configure your own error msg recvie email information with`ADMINS = [('liangliang', 'liangliangyy@gmail.com')]` in `settings.py`. And modify:
+```python
+EMAIL_HOST = 'smtp.zoho.com'
+EMAIL_PORT = 587
+EMAIL_HOST_USER = os.environ.get('DJANGO_EMAIL_USER')
+EMAIL_HOST_PASSWORD = os.environ.get('DJANGO_EMAIL_PASSWORD')
+DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
+SERVER_EMAIL = os.environ.get('DJANGO_EMAIL_USER')
+```
+with your email account information.
+
+## WeChat Official Account
+Simple wechat official account features integrated. Set token as `your-domain-name/robot` in wechat backend. Default token is `lylinux`, you can change it to your own in `servermanager/robot.py`. Add a new command in `Backend->Servermanager->command`, in this way, you can manage the system through wechat official account.
+
+## Introduction to website configuration
+You can add website configuration in **Backend->BLOG->WebSiteConfiguration**. Such as: keywords, description, Google Ad, website stats code, case number, etc.
+OAuth user avatar path is saved in *StaticFileSavedAddress*. Please input absolute path, code directory for default.
+
+## Source code highlighting
+If the code block in your article didn't show hightlight, please write the code blocks as following:
+
+
+
+That is, you should add the corresponding language name before the code block.
+
+## Update
+If you get errors as following while executing database migrations:
+```python
+django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table ((1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(6) NOT NULL)' at line 1"))
+```
+This problem may cause by the mysql version under 5.6, a new version( >= 5.6 ) mysql is needed.
+
diff --git a/src/docs/config.md b/src/docs/config.md
new file mode 100644
index 0000000..24673a3
--- /dev/null
+++ b/src/docs/config.md
@@ -0,0 +1,58 @@
+# 主要功能配置介绍:
+
+## 缓存:
+缓存默认使用`localmem`缓存,如果你有`redis`环境,可以设置`DJANGO_REDIS_URL`环境变量,则会自动使用该redis来作为缓存,或者你也可以直接修改如下代码来使用。
+https://github.com/liangliangyy/DjangoBlog/blob/ffcb2c3711de805f2067dd3c1c57449cd24d84ee/djangoblog/settings.py#L185-L199
+
+
+## oauth登录:
+
+现在已经支持QQ,微博,Google,GitHub,Facebook登录,需要在其对应的开放平台申请oauth登录权限,然后在
+**后台->Oauth** 配置中新增配置,填写对应的`appkey`和`appsecret`以及回调地址。
+### 回调地址示例:
+qq:http://你的域名/oauth/authorize?type=qq
+微博:http://你的域名/oauth/authorize?type=weibo
+type对应在`oauthmanager`中的type字段。
+
+## owntracks:
+owntracks是一个位置追踪软件,可以定时的将你的坐标提交到你的服务器上,现在简单的支持owntracks功能,需要安装owntracks的app,然后将api地址设置为:
+`你的域名/owntracks/logtracks`就可以了。然后访问`你的域名/owntracks/show_dates`就可以看到有经纬度记录的日期,点击之后就可以看到运动轨迹了。地图是使用高德地图绘制。
+
+## 邮件功能:
+同样,将`settings.py`中的`ADMINS = [('liangliang', 'liangliangyy@gmail.com')]`配置为你自己的错误接收邮箱,另外修改:
+```python
+EMAIL_HOST = 'smtp.zoho.com'
+EMAIL_PORT = 587
+EMAIL_HOST_USER = os.environ.get('DJANGO_EMAIL_USER')
+EMAIL_HOST_PASSWORD = os.environ.get('DJANGO_EMAIL_PASSWORD')
+DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
+SERVER_EMAIL = os.environ.get('DJANGO_EMAIL_USER')
+```
+为你自己的邮箱配置。
+
+## 微信公众号
+集成了简单的微信公众号功能,在微信后台将token地址设置为:`你的域名/robot` 即可,默认token为`lylinux`,当然你可以修改为你自己的,在`servermanager/robot.py`中。
+然后在**后台->Servermanager->命令**中新增命令,这样就可以使用微信公众号来管理了。
+## 网站配置介绍
+在**后台->BLOG->网站配置**中,可以新增网站配置,比如关键字,描述等,以及谷歌广告,网站统计代码及备案号等等。
+其中的*静态文件保存地址*是保存oauth用户登录的头像路径,填写绝对路径,默认是代码目录。
+## 代码高亮
+如果你发现你文章的代码没有高亮,请这样书写代码块:
+
+
+
+
+也就是说,需要在代码块开始位置加入这段代码对应的语言。
+
+## update
+如果你发现执行数据库迁移的时候出现如下报错:
+```python
+django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table ((1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(6) NOT NULL)' at line 1"))
+```
+可能是因为你的mysql版本低于5.6,需要升级mysql版本>=5.6即可。
+
+
+django 4.0登录可能会报错CSRF,需要配置下`settings.py`中的`CSRF_TRUSTED_ORIGINS`
+
+https://github.com/liangliangyy/DjangoBlog/blob/master/djangoblog/settings.py#L39
+
diff --git a/src/docs/docker-en.md b/src/docs/docker-en.md
new file mode 100644
index 0000000..8d5d59e
--- /dev/null
+++ b/src/docs/docker-en.md
@@ -0,0 +1,114 @@
+# Deploying DjangoBlog with Docker
+
+
+
+
+
+This project fully supports containerized deployment using Docker, providing you with a fast, consistent, and isolated runtime environment. We recommend using `docker-compose` to launch the entire blog service stack with a single command.
+
+## 1. Prerequisites
+
+Before you begin, please ensure you have the following software installed on your system:
+- [Docker Engine](https://docs.docker.com/engine/install/)
+- [Docker Compose](https://docs.docker.com/compose/install/) (Included with Docker Desktop for Mac and Windows)
+
+## 2. Recommended Method: Using `docker-compose` (One-Click Deployment)
+
+This is the simplest and most recommended way to deploy. It automatically creates and manages the Django application, a MySQL database, and an optional Elasticsearch service for you.
+
+### Step 1: Start the Basic Services
+
+From the project's root directory, run the following command:
+
+```bash
+# Build and start the containers in detached mode (includes Django app and MySQL)
+docker-compose up -d --build
+```
+
+`docker-compose` will read the `docker-compose.yml` file, pull the necessary images, build the project image, and start all services.
+
+- **Access Your Blog**: Once the services are up, you can access the blog by navigating to `http://127.0.0.1` in your browser.
+- **Data Persistence**: MySQL data files will be stored in the `data/mysql` directory within the project root, ensuring that your data persists across container restarts.
+
+### Step 2: (Optional) Enable Elasticsearch for Full-Text Search
+
+If you want to use Elasticsearch for more powerful full-text search capabilities, you can include the `docker-compose.es.yml` configuration file:
+
+```bash
+# Build and start all services in detached mode (Django, MySQL, Elasticsearch)
+docker-compose -f docker-compose.yml -f deploy/docker-compose/docker-compose.es.yml up -d --build
+```
+- **Data Persistence**: Elasticsearch data will be stored in the `data/elasticsearch` directory.
+
+### Step 3: First-Time Initialization
+
+After the containers start for the first time, you'll need to execute some initialization commands inside the application container.
+
+```bash
+# Get a shell inside the djangoblog application container (named 'web')
+docker-compose exec web bash
+
+# Inside the container, run the following commands:
+# Create a superuser account (follow the prompts to set username, email, and password)
+python manage.py createsuperuser
+
+# (Optional) Create some test data
+python manage.py create_testdata
+
+# (Optional, if ES is enabled) Create the search index
+python manage.py rebuild_index
+
+# Exit the container
+exit
+```
+
+## 3. Alternative Method: Using the Standalone Docker Image
+
+If you already have an external MySQL database running, you can run the DjangoBlog application image by itself.
+
+```bash
+# Pull the latest image from Docker Hub
+docker pull liangliangyy/djangoblog:latest
+
+# Run the container and connect it to your external database
+docker run -d \
+ -p 8000:8000 \
+ -e DJANGO_SECRET_KEY='your-strong-secret-key' \
+ -e DJANGO_MYSQL_HOST='your-mysql-host' \
+ -e DJANGO_MYSQL_USER='your-mysql-user' \
+ -e DJANGO_MYSQL_PASSWORD='your-mysql-password' \
+ -e DJANGO_MYSQL_DATABASE='djangoblog' \
+ --name djangoblog \
+ liangliangyy/djangoblog:latest
+```
+
+- **Access Your Blog**: After startup, visit `http://127.0.0.1:8000`.
+- **Create Superuser**: `docker exec -it djangoblog python manage.py createsuperuser`
+
+## 4. Configuration (Environment Variables)
+
+Most of the project's configuration is managed through environment variables. You can modify them in the `docker-compose.yml` file or pass them using the `-e` flag with the `docker run` command.
+
+| Environment Variable | Default/Example Value | Notes |
+|---------------------------|--------------------------------------------------------------------------|---------------------------------------------------------------------|
+| `DJANGO_SECRET_KEY` | `your-strong-secret-key` | **Must be changed to a random, complex string!** |
+| `DJANGO_DEBUG` | `False` | Toggles Django's debug mode. |
+| `DJANGO_MYSQL_HOST` | `mysql` | Database hostname. |
+| `DJANGO_MYSQL_PORT` | `3306` | Database port. |
+| `DJANGO_MYSQL_DATABASE` | `djangoblog` | Database name. |
+| `DJANGO_MYSQL_USER` | `root` | Database username. |
+| `DJANGO_MYSQL_PASSWORD` | `djangoblog_123` | Database password. |
+| `DJANGO_REDIS_URL` | `redis:6379/0` | Redis connection URL (for caching). |
+| `DJANGO_ELASTICSEARCH_HOST`| `elasticsearch:9200` | Elasticsearch host address. |
+| `DJANGO_EMAIL_HOST` | `smtp.example.org` | Email server address. |
+| `DJANGO_EMAIL_PORT` | `465` | Email server port. |
+| `DJANGO_EMAIL_USER` | `user@example.org` | Email account username. |
+| `DJANGO_EMAIL_PASSWORD` | `your-email-password` | Email account password. |
+| `DJANGO_EMAIL_USE_SSL` | `True` | Whether to use SSL. |
+| `DJANGO_EMAIL_USE_TLS` | `False` | Whether to use TLS. |
+| `DJANGO_ADMIN_EMAIL` | `admin@example.org` | Admin email for receiving error reports. |
+| `DJANGO_BAIDU_NOTIFY_URL` | `http://data.zz.baidu.com/...` | Push API from [Baidu Webmaster Tools](https://ziyuan.baidu.com/linksubmit/index). |
+
+---
+
+After deployment, please review and adjust these environment variables according to your needs, especially `DJANGO_SECRET_KEY` and the database and email settings.
\ No newline at end of file
diff --git a/src/docs/docker.md b/src/docs/docker.md
new file mode 100644
index 0000000..e7c255a
--- /dev/null
+++ b/src/docs/docker.md
@@ -0,0 +1,114 @@
+# 使用 Docker 部署 DjangoBlog
+
+
+
+
+
+本项目全面支持使用 Docker 进行容器化部署,为您提供了快速、一致且隔离的运行环境。我们推荐使用 `docker-compose` 来一键启动整个博客服务栈。
+
+## 1. 环境准备
+
+在开始之前,请确保您的系统中已经安装了以下软件:
+- [Docker Engine](https://docs.docker.com/engine/install/)
+- [Docker Compose](https://docs.docker.com/compose/install/) (对于 Docker Desktop 用户,它已内置)
+
+## 2. 推荐方式:使用 `docker-compose` (一键部署)
+
+这是最简单、最推荐的部署方式。它会自动为您创建并管理 Django 应用、MySQL 数据库,以及可选的 Elasticsearch 服务。
+
+### 步骤 1: 启动基础服务
+
+在项目根目录下,执行以下命令:
+
+```bash
+# 构建并以后台模式启动容器 (包含 Django 应用和 MySQL)
+docker-compose up -d --build
+```
+
+`docker-compose` 会读取 `docker-compose.yml` 文件,自动拉取所需镜像、构建项目镜像,并启动所有服务。
+
+- **访问您的博客**: 服务启动后,在浏览器中访问 `http://127.0.0.1` 即可看到博客首页。
+- **数据持久化**: MySQL 的数据文件将存储在项目根目录下的 `data/mysql` 文件夹中,确保数据在容器重启后不丢失。
+
+### 步骤 2: (可选) 启用 Elasticsearch 全文搜索
+
+如果您希望使用 Elasticsearch 提供更强大的全文搜索功能,可以额外加载 `docker-compose.es.yml` 配置文件:
+
+```bash
+# 构建并以后台模式启动所有服务 (Django, MySQL, Elasticsearch)
+docker-compose -f docker-compose.yml -f deploy/docker-compose/docker-compose.es.yml up -d --build
+```
+- **数据持久化**: Elasticsearch 的数据将存储在 `data/elasticsearch` 文件夹中。
+
+### 步骤 3: 首次运行的初始化操作
+
+当容器首次启动后,您需要进入容器来执行一些初始化命令。
+
+```bash
+# 进入 djangoblog 应用容器
+docker-compose exec web bash
+
+# 在容器内执行以下命令:
+# 创建超级管理员账户 (请按照提示设置用户名、邮箱和密码)
+python manage.py createsuperuser
+
+# (可选) 创建一些测试数据
+python manage.py create_testdata
+
+# (可选,如果启用了 ES) 创建索引
+python manage.py rebuild_index
+
+# 退出容器
+exit
+```
+
+## 3. 备选方式:使用独立的 Docker 镜像
+
+如果您已经拥有一个正在运行的外部 MySQL 数据库,您也可以只运行 DjangoBlog 的应用镜像。
+
+```bash
+# 从 Docker Hub 拉取最新镜像
+docker pull liangliangyy/djangoblog:latest
+
+# 运行容器,并链接到您的外部数据库
+docker run -d \
+ -p 8000:8000 \
+ -e DJANGO_SECRET_KEY='your-strong-secret-key' \
+ -e DJANGO_MYSQL_HOST='your-mysql-host' \
+ -e DJANGO_MYSQL_USER='your-mysql-user' \
+ -e DJANGO_MYSQL_PASSWORD='your-mysql-password' \
+ -e DJANGO_MYSQL_DATABASE='djangoblog' \
+ --name djangoblog \
+ liangliangyy/djangoblog:latest
+```
+
+- **访问您的博客**: 启动完成后,访问 `http://127.0.0.1:8000`。
+- **创建管理员**: `docker exec -it djangoblog python manage.py createsuperuser`
+
+## 4. 配置说明 (环境变量)
+
+本项目的大部分配置都通过环境变量来管理。您可以在 `docker-compose.yml` 文件中修改它们,或者在使用 `docker run` 命令时通过 `-e` 参数传入。
+
+| 环境变量名称 | 默认值/示例 | 备注 |
+|-------------------------|--------------------------------------------------------------------------|---------------------------------------------------------------------|
+| `DJANGO_SECRET_KEY` | `your-strong-secret-key` | **请务必修改为一个随机且复杂的字符串!** |
+| `DJANGO_DEBUG` | `False` | 是否开启 Django 的调试模式 |
+| `DJANGO_MYSQL_HOST` | `mysql` | 数据库主机名 |
+| `DJANGO_MYSQL_PORT` | `3306` | 数据库端口 |
+| `DJANGO_MYSQL_DATABASE` | `djangoblog` | 数据库名称 |
+| `DJANGO_MYSQL_USER` | `root` | 数据库用户名 |
+| `DJANGO_MYSQL_PASSWORD` | `djangoblog_123` | 数据库密码 |
+| `DJANGO_REDIS_URL` | `redis:6379/0` | Redis 连接地址 (用于缓存) |
+| `DJANGO_ELASTICSEARCH_HOST` | `elasticsearch:9200` | Elasticsearch 主机地址 |
+| `DJANGO_EMAIL_HOST` | `smtp.example.org` | 邮件服务器地址 |
+| `DJANGO_EMAIL_PORT` | `465` | 邮件服务器端口 |
+| `DJANGO_EMAIL_USER` | `user@example.org` | 邮件账户 |
+| `DJANGO_EMAIL_PASSWORD` | `your-email-password` | 邮件密码 |
+| `DJANGO_EMAIL_USE_SSL` | `True` | 是否使用 SSL |
+| `DJANGO_EMAIL_USE_TLS` | `False` | 是否使用 TLS |
+| `DJANGO_ADMIN_EMAIL` | `admin@example.org` | 接收异常报告的管理员邮箱 |
+| `DJANGO_BAIDU_NOTIFY_URL` | `http://data.zz.baidu.com/...` | [百度站长平台](https://ziyuan.baidu.com/linksubmit/index) 的推送接口 |
+
+---
+
+部署完成后,请务必检查并根据您的实际需求调整这些环境变量,特别是 `DJANGO_SECRET_KEY` 和数据库、邮件相关的配置。
diff --git a/src/docs/es.md b/src/docs/es.md
new file mode 100644
index 0000000..97226c5
--- /dev/null
+++ b/src/docs/es.md
@@ -0,0 +1,28 @@
+# 集成Elasticsearch
+如果你已经有了`Elasticsearch`环境,那么可以将搜索从`Whoosh`换成`Elasticsearch`,集成方式也很简单,
+首先需要注意如下几点:
+1. 你的`Elasticsearch`支持`ik`中文分词
+2. 你的`Elasticsearch`版本>=7.3.0
+
+接下来在`settings.py`做如下改动即可:
+- 增加es链接,如下所示:
+```python
+ELASTICSEARCH_DSL = {
+ 'default': {
+ 'hosts': '127.0.0.1:9200'
+ },
+}
+```
+- 修改`HAYSTACK`配置:
+```python
+HAYSTACK_CONNECTIONS = {
+ 'default': {
+ 'ENGINE': 'djangoblog.elasticsearch_backend.ElasticSearchEngine',
+ },
+}
+```
+然后终端执行:
+```shell script
+./manage.py build_index
+```
+这将会在你的es中创建两个索引,分别是`blog`和`performance`,其中`blog`索引就是搜索所使用的,而`performance`会记录每个请求的响应时间,以供将来优化使用。
\ No newline at end of file
diff --git a/src/docs/imgs/alipay.jpg b/src/docs/imgs/alipay.jpg
new file mode 100644
index 0000000..424d70a
Binary files /dev/null and b/src/docs/imgs/alipay.jpg differ
diff --git a/src/docs/imgs/pycharm_logo.png b/src/docs/imgs/pycharm_logo.png
new file mode 100644
index 0000000..7f2a4b0
Binary files /dev/null and b/src/docs/imgs/pycharm_logo.png differ
diff --git a/src/docs/imgs/wechat.jpg b/src/docs/imgs/wechat.jpg
new file mode 100644
index 0000000..7edf525
Binary files /dev/null and b/src/docs/imgs/wechat.jpg differ
diff --git a/src/docs/k8s-en.md b/src/docs/k8s-en.md
new file mode 100644
index 0000000..20e9527
--- /dev/null
+++ b/src/docs/k8s-en.md
@@ -0,0 +1,141 @@
+# Deploying DjangoBlog with Kubernetes
+
+This document guides you through deploying the DjangoBlog application on a Kubernetes (K8s) cluster. We provide a complete set of `.yaml` configuration files in the `deploy/k8s` directory to deploy a full service stack, including the DjangoBlog application, Nginx, MySQL, Redis, and Elasticsearch.
+
+## Architecture Overview
+
+This deployment utilizes a microservices-based, cloud-native architecture:
+
+- **Core Components**: Each core service (DjangoBlog, Nginx, MySQL, Redis, Elasticsearch) runs as a separate `Deployment`.
+- **Configuration Management**: Nginx configurations and Django application environment variables are managed via `ConfigMap`. **Note: For sensitive information like passwords, using `Secret` is highly recommended.**
+- **Service Discovery**: All services are exposed internally within the cluster as `ClusterIP` type `Service`, enabling communication via service names.
+- **External Access**: An `Ingress` resource is used to route external HTTP traffic to the Nginx service, which acts as the single entry point for the entire blog application.
+- **Data Persistence**: A `local-storage` solution based on node-local paths is used. This requires you to manually create storage directories on a specific K8s node and statically bind them using `PersistentVolume` (PV) and `PersistentVolumeClaim` (PVC).
+
+## 1. Prerequisites
+
+Before you begin, please ensure you have the following:
+
+- A running Kubernetes cluster.
+- The `kubectl` command-line tool configured to connect to your cluster.
+- An [Nginx Ingress Controller](https://kubernetes.github.io/ingress-nginx/deploy/) installed and configured in your cluster.
+- Filesystem access to one of the nodes in your cluster (defaulted to `master` in the configs) to create local storage directories.
+
+## 2. Deployment Steps
+
+### Step 1: Create a Namespace
+
+We recommend deploying all DjangoBlog-related resources in a dedicated namespace for better management.
+
+```bash
+# Create a namespace named 'djangoblog'
+kubectl create namespace djangoblog
+```
+
+### Step 2: Configure Persistent Storage
+
+This setup uses Local Persistent Volumes. You need to create the data storage directories on a node within your cluster (the default is the `master` node in `pv.yaml`).
+
+```bash
+# Log in to your master node
+ssh user@master-node
+
+# Create the required storage directories
+sudo mkdir -p /mnt/local-storage-db
+sudo mkdir -p /mnt/local-storage-djangoblog
+sudo mkdir -p /mnt/resource/
+sudo mkdir -p /mnt/local-storage-elasticsearch
+
+# Log out from the node
+exit
+```
+**Note**: If you wish to store data on a different node or use different paths, you must modify the `nodeAffinity` and `local.path` settings in the `deploy/k8s/pv.yaml` file.
+
+After creating the directories, apply the storage-related configurations:
+
+```bash
+# Apply the StorageClass
+kubectl apply -f deploy/k8s/storageclass.yaml
+
+# Apply the PersistentVolumes (PVs)
+kubectl apply -f deploy/k8s/pv.yaml
+
+# Apply the PersistentVolumeClaims (PVCs)
+kubectl apply -f deploy/k8s/pvc.yaml
+```
+
+### Step 3: Configure the Application
+
+Before deploying the application, you need to edit the `deploy/k8s/configmap.yaml` file to modify sensitive information and custom settings.
+
+**It is strongly recommended to change the following fields:**
+- `DJANGO_SECRET_KEY`: Change to a random, complex string.
+- `DJANGO_MYSQL_PASSWORD` and `MYSQL_ROOT_PASSWORD`: Change to your own secure database password.
+
+```bash
+# Edit the ConfigMap file
+vim deploy/k8s/configmap.yaml
+
+# Apply the configuration
+kubectl apply -f deploy/k8s/configmap.yaml
+```
+
+### Step 4: Deploy the Application Stack
+
+Now, we can deploy all the core services.
+
+```bash
+# Deploy the Deployments (DjangoBlog, MySQL, Redis, Nginx, ES)
+kubectl apply -f deploy/k8s/deployment.yaml
+
+# Deploy the Services (to create internal endpoints for the Deployments)
+kubectl apply -f deploy/k8s/service.yaml
+```
+
+The deployment may take some time. You can run the following command to check if all Pods are running successfully (STATUS should be `Running`):
+
+```bash
+kubectl get pods -n djangoblog -w
+```
+
+### Step 5: Expose the Application Externally
+
+Finally, expose the Nginx service to external traffic by applying the `Ingress` rule.
+
+```bash
+# Apply the Ingress rule
+kubectl apply -f deploy/k8s/gateway.yaml
+```
+
+Once deployed, you can access your blog via the external IP address of your Ingress Controller. Use the following command to find the address:
+
+```bash
+kubectl get ingress -n djangoblog
+```
+
+### Step 6: First-Time Initialization
+
+Similar to the Docker deployment, you need to get a shell into the DjangoBlog application Pod to perform database initialization and create a superuser on the first run.
+
+```bash
+# First, get the name of a djangoblog pod
+kubectl get pods -n djangoblog | grep djangoblog
+
+# Exec into one of the Pods (replace [pod-name] with the name from the previous step)
+kubectl exec -it [pod-name] -n djangoblog -- bash
+
+# Inside the Pod, run the following commands:
+# Create a superuser account (follow the prompts)
+python manage.py createsuperuser
+
+# (Optional) Create some test data
+python manage.py create_testdata
+
+# (Optional, if ES is enabled) Create the search index
+python manage.py rebuild_index
+
+# Exit the Pod
+exit
+```
+
+Congratulations! You have successfully deployed DjangoBlog on your Kubernetes cluster.
\ No newline at end of file
diff --git a/src/docs/k8s.md b/src/docs/k8s.md
new file mode 100644
index 0000000..9da3c28
--- /dev/null
+++ b/src/docs/k8s.md
@@ -0,0 +1,141 @@
+# 使用 Kubernetes 部署 DjangoBlog
+
+本文档将指导您如何在 Kubernetes (K8s) 集群上部署 DjangoBlog 应用。我们提供了一套完整的 `.yaml` 配置文件,位于 `deploy/k8s` 目录下,用于部署一个包含 DjangoBlog 应用、Nginx、MySQL、Redis 和 Elasticsearch 的完整服务栈。
+
+## 架构概览
+
+本次部署采用的是微服务化的云原生架构:
+
+- **核心组件**: 每个核心服务 (DjangoBlog, Nginx, MySQL, Redis, Elasticsearch) 都将作为独立的 `Deployment` 运行。
+- **配置管理**: Nginx 的配置文件和 Django 应用的环境变量通过 `ConfigMap` 进行管理。**注意:敏感信息(如密码)建议使用 `Secret` 进行管理。**
+- **服务发现**: 所有服务都通过 `ClusterIP` 类型的 `Service` 在集群内部暴露,并通过服务名相互通信。
+- **外部访问**: 使用 `Ingress` 资源将外部的 HTTP 流量路由到 Nginx 服务,作为整个博客应用的统一入口。
+- **数据持久化**: 采用基于节点本地路径的 `local-storage` 方案。这需要您在指定的 K8s 节点上手动创建存储目录,并通过 `PersistentVolume` (PV) 和 `PersistentVolumeClaim` (PVC) 进行静态绑定。
+
+## 1. 环境准备
+
+在开始之前,请确保您已具备以下环境:
+
+- 一个正在运行的 Kubernetes 集群。
+- `kubectl` 命令行工具已配置并能够连接到您的集群。
+- 集群中已安装并配置好 [Nginx Ingress Controller](https://kubernetes.github.io/ingress-nginx/deploy/)。
+- 对集群中的一个节点(默认为 `master`)拥有文件系统访问权限,用于创建本地存储目录。
+
+## 2. 部署步骤
+
+### 步骤 1: 创建命名空间
+
+我们建议将 DjangoBlog 相关的所有资源都部署在一个独立的命名空间中,便于管理。
+
+```bash
+# 创建一个名为 djangoblog 的命名空间
+kubectl create namespace djangoblog
+```
+
+### 步骤 2: 配置持久化存储
+
+此方案使用本地持久卷 (Local Persistent Volume)。您需要在集群的一个节点上(在 `pv.yaml` 文件中默认为 `master` 节点)创建用于数据存储的目录。
+
+```bash
+# 登录到您的 master 节点
+ssh user@master-node
+
+# 创建所需的存储目录
+sudo mkdir -p /mnt/local-storage-db
+sudo mkdir -p /mnt/local-storage-djangoblog
+sudo mkdir -p /mnt/resource/
+sudo mkdir -p /mnt/local-storage-elasticsearch
+
+# 退出节点
+exit
+```
+**注意**: 如果您希望将数据存储在其他节点或使用不同的路径,请务必修改 `deploy/k8s/pv.yaml` 文件中 `nodeAffinity` 和 `local.path` 的配置。
+
+创建目录后,应用存储相关的配置文件:
+
+```bash
+# 应用 StorageClass
+kubectl apply -f deploy/k8s/storageclass.yaml
+
+# 应用 PersistentVolume (PV)
+kubectl apply -f deploy/k8s/pv.yaml
+
+# 应用 PersistentVolumeClaim (PVC)
+kubectl apply -f deploy/k8s/pvc.yaml
+```
+
+### 步骤 3: 配置应用
+
+在部署应用之前,您需要编辑 `deploy/k8s/configmap.yaml` 文件,修改其中的敏感信息和个性化配置。
+
+**强烈建议修改以下字段:**
+- `DJANGO_SECRET_KEY`: 修改为一个随机且复杂的字符串。
+- `DJANGO_MYSQL_PASSWORD` 和 `MYSQL_ROOT_PASSWORD`: 修改为您自己的数据库密码。
+
+```bash
+# 编辑 ConfigMap 文件
+vim deploy/k8s/configmap.yaml
+
+# 应用配置
+kubectl apply -f deploy/k8s/configmap.yaml
+```
+
+### 步骤 4: 部署应用服务栈
+
+现在,我们可以部署所有的核心服务了。
+
+```bash
+# 部署 Deployments (DjangoBlog, MySQL, Redis, Nginx, ES)
+kubectl apply -f deploy/k8s/deployment.yaml
+
+# 部署 Services (为 Deployments 创建内部访问端点)
+kubectl apply -f deploy/k8s/service.yaml
+```
+
+部署需要一些时间,您可以运行以下命令检查所有 Pod 是否都已成功运行 (STATUS 为 `Running`):
+
+```bash
+kubectl get pods -n djangoblog -w
+```
+
+### 步骤 5: 暴露应用到外部
+
+最后,通过应用 `Ingress` 规则来将外部流量引导至我们的 Nginx 服务。
+
+```bash
+# 应用 Ingress 规则
+kubectl apply -f deploy/k8s/gateway.yaml
+```
+
+部署完成后,您可以通过 Ingress Controller 的外部 IP 地址来访问您的博客。执行以下命令获取地址:
+
+```bash
+kubectl get ingress -n djangoblog
+```
+
+### 步骤 6: 首次运行的初始化操作
+
+与 Docker 部署类似,首次运行时,您需要进入 DjangoBlog 应用的 Pod 来执行数据库初始化和创建管理员账户。
+
+```bash
+# 首先,获取 djangoblog pod 的名称
+kubectl get pods -n djangoblog | grep djangoblog
+
+# 进入其中一个 Pod (将 [pod-name] 替换为上一步获取到的名称)
+kubectl exec -it [pod-name] -n djangoblog -- bash
+
+# 在 Pod 内部执行以下命令:
+# 创建超级管理员账户 (请按照提示操作)
+python manage.py createsuperuser
+
+# (可选) 创建测试数据
+python manage.py create_testdata
+
+# (可选,如果启用了 ES) 创建索引
+python manage.py rebuild_index
+
+# 退出 Pod
+exit
+```
+
+至此,您已成功在 Kubernetes 集群上完成了 DjangoBlog 的部署!
\ No newline at end of file
diff --git a/src/locale/en/LC_MESSAGES/django.mo b/src/locale/en/LC_MESSAGES/django.mo
new file mode 100644
index 0000000..f63669f
Binary files /dev/null and b/src/locale/en/LC_MESSAGES/django.mo differ
diff --git a/src/locale/en/LC_MESSAGES/django.po b/src/locale/en/LC_MESSAGES/django.po
new file mode 100644
index 0000000..c80b30a
--- /dev/null
+++ b/src/locale/en/LC_MESSAGES/django.po
@@ -0,0 +1,685 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR , YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2023-09-13 16:02+0800\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME \n"
+"Language-Team: LANGUAGE \n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: .\accounts\admin.py:12
+msgid "password"
+msgstr "password"
+
+#: .\accounts\admin.py:13
+msgid "Enter password again"
+msgstr "Enter password again"
+
+#: .\accounts\admin.py:24 .\accounts\forms.py:89
+msgid "passwords do not match"
+msgstr "passwords do not match"
+
+#: .\accounts\forms.py:36
+msgid "email already exists"
+msgstr "email already exists"
+
+#: .\accounts\forms.py:46 .\accounts\forms.py:50
+msgid "New password"
+msgstr "New password"
+
+#: .\accounts\forms.py:60
+msgid "Confirm password"
+msgstr "Confirm password"
+
+#: .\accounts\forms.py:70 .\accounts\forms.py:116
+msgid "Email"
+msgstr "Email"
+
+#: .\accounts\forms.py:76 .\accounts\forms.py:80
+msgid "Code"
+msgstr "Code"
+
+#: .\accounts\forms.py:100 .\accounts\tests.py:194
+msgid "email does not exist"
+msgstr "email does not exist"
+
+#: .\accounts\models.py:12 .\oauth\models.py:17
+msgid "nick name"
+msgstr "nick name"
+
+#: .\accounts\models.py:13 .\blog\models.py:29 .\blog\models.py:266
+#: .\blog\models.py:284 .\comments\models.py:13 .\oauth\models.py:23
+#: .\oauth\models.py:53
+msgid "creation time"
+msgstr "creation time"
+
+#: .\accounts\models.py:14 .\comments\models.py:14 .\oauth\models.py:24
+#: .\oauth\models.py:54
+msgid "last modify time"
+msgstr "last modify time"
+
+#: .\accounts\models.py:15
+msgid "create source"
+msgstr "create source"
+
+#: .\accounts\models.py:33 .\djangoblog\logentryadmin.py:81
+msgid "user"
+msgstr "user"
+
+#: .\accounts\tests.py:216 .\accounts\utils.py:39
+msgid "Verification code error"
+msgstr "Verification code error"
+
+#: .\accounts\utils.py:13
+msgid "Verify Email"
+msgstr "Verify Email"
+
+#: .\accounts\utils.py:21
+#, python-format
+msgid ""
+"You are resetting the password, the verification code is:%(code)s, valid "
+"within 5 minutes, please keep it properly"
+msgstr ""
+"You are resetting the password, the verification code is:%(code)s, valid "
+"within 5 minutes, please keep it properly"
+
+#: .\blog\admin.py:13 .\blog\models.py:92 .\comments\models.py:17
+#: .\oauth\models.py:12
+msgid "author"
+msgstr "author"
+
+#: .\blog\admin.py:53
+msgid "Publish selected articles"
+msgstr "Publish selected articles"
+
+#: .\blog\admin.py:54
+msgid "Draft selected articles"
+msgstr "Draft selected articles"
+
+#: .\blog\admin.py:55
+msgid "Close article comments"
+msgstr "Close article comments"
+
+#: .\blog\admin.py:56
+msgid "Open article comments"
+msgstr "Open article comments"
+
+#: .\blog\admin.py:89 .\blog\models.py:101 .\blog\models.py:183
+#: .\templates\blog\tags\sidebar.html:40
+msgid "category"
+msgstr "category"
+
+#: .\blog\models.py:20 .\blog\models.py:179 .\templates\share_layout\nav.html:8
+msgid "index"
+msgstr "index"
+
+#: .\blog\models.py:21
+msgid "list"
+msgstr "list"
+
+#: .\blog\models.py:22
+msgid "post"
+msgstr "post"
+
+#: .\blog\models.py:23
+msgid "all"
+msgstr "all"
+
+#: .\blog\models.py:24
+msgid "slide"
+msgstr "slide"
+
+#: .\blog\models.py:30 .\blog\models.py:267 .\blog\models.py:285
+msgid "modify time"
+msgstr "modify time"
+
+#: .\blog\models.py:63
+msgid "Draft"
+msgstr "Draft"
+
+#: .\blog\models.py:64
+msgid "Published"
+msgstr "Published"
+
+#: .\blog\models.py:67
+msgid "Open"
+msgstr "Open"
+
+#: .\blog\models.py:68
+msgid "Close"
+msgstr "Close"
+
+#: .\blog\models.py:71 .\comments\admin.py:47
+msgid "Article"
+msgstr "Article"
+
+#: .\blog\models.py:72
+msgid "Page"
+msgstr "Page"
+
+#: .\blog\models.py:74 .\blog\models.py:280
+msgid "title"
+msgstr "title"
+
+#: .\blog\models.py:75
+msgid "body"
+msgstr "body"
+
+#: .\blog\models.py:77
+msgid "publish time"
+msgstr "publish time"
+
+#: .\blog\models.py:79
+msgid "status"
+msgstr "status"
+
+#: .\blog\models.py:84
+msgid "comment status"
+msgstr "comment status"
+
+#: .\blog\models.py:88 .\oauth\models.py:43
+msgid "type"
+msgstr "type"
+
+#: .\blog\models.py:89
+msgid "views"
+msgstr "views"
+
+#: .\blog\models.py:97 .\blog\models.py:258 .\blog\models.py:282
+msgid "order"
+msgstr "order"
+
+#: .\blog\models.py:98
+msgid "show toc"
+msgstr "show toc"
+
+#: .\blog\models.py:105 .\blog\models.py:249
+msgid "tag"
+msgstr "tag"
+
+#: .\blog\models.py:115 .\comments\models.py:21
+msgid "article"
+msgstr "article"
+
+#: .\blog\models.py:171
+msgid "category name"
+msgstr "category name"
+
+#: .\blog\models.py:174
+msgid "parent category"
+msgstr "parent category"
+
+#: .\blog\models.py:234
+msgid "tag name"
+msgstr "tag name"
+
+#: .\blog\models.py:256
+msgid "link name"
+msgstr "link name"
+
+#: .\blog\models.py:257 .\blog\models.py:271
+msgid "link"
+msgstr "link"
+
+#: .\blog\models.py:260
+msgid "is show"
+msgstr "is show"
+
+#: .\blog\models.py:262
+msgid "show type"
+msgstr "show type"
+
+#: .\blog\models.py:281
+msgid "content"
+msgstr "content"
+
+#: .\blog\models.py:283 .\oauth\models.py:52
+msgid "is enable"
+msgstr "is enable"
+
+#: .\blog\models.py:289
+msgid "sidebar"
+msgstr "sidebar"
+
+#: .\blog\models.py:299
+msgid "site name"
+msgstr "site name"
+
+#: .\blog\models.py:305
+msgid "site description"
+msgstr "site description"
+
+#: .\blog\models.py:311
+msgid "site seo description"
+msgstr "site seo description"
+
+#: .\blog\models.py:313
+msgid "site keywords"
+msgstr "site keywords"
+
+#: .\blog\models.py:318
+msgid "article sub length"
+msgstr "article sub length"
+
+#: .\blog\models.py:319
+msgid "sidebar article count"
+msgstr "sidebar article count"
+
+#: .\blog\models.py:320
+msgid "sidebar comment count"
+msgstr "sidebar comment count"
+
+#: .\blog\models.py:321
+msgid "article comment count"
+msgstr "article comment count"
+
+#: .\blog\models.py:322
+msgid "show adsense"
+msgstr "show adsense"
+
+#: .\blog\models.py:324
+msgid "adsense code"
+msgstr "adsense code"
+
+#: .\blog\models.py:325
+msgid "open site comment"
+msgstr "open site comment"
+
+#: .\blog\models.py:352
+msgid "Website configuration"
+msgstr "Website configuration"
+
+#: .\blog\models.py:360
+msgid "There can only be one configuration"
+msgstr "There can only be one configuration"
+
+#: .\blog\views.py:348
+msgid ""
+"Sorry, the page you requested is not found, please click the home page to "
+"see other?"
+msgstr ""
+"Sorry, the page you requested is not found, please click the home page to "
+"see other?"
+
+#: .\blog\views.py:356
+msgid "Sorry, the server is busy, please click the home page to see other?"
+msgstr "Sorry, the server is busy, please click the home page to see other?"
+
+#: .\blog\views.py:369
+msgid "Sorry, you do not have permission to access this page?"
+msgstr "Sorry, you do not have permission to access this page?"
+
+#: .\comments\admin.py:15
+msgid "Disable comments"
+msgstr "Disable comments"
+
+#: .\comments\admin.py:16
+msgid "Enable comments"
+msgstr "Enable comments"
+
+#: .\comments\admin.py:46
+msgid "User"
+msgstr "User"
+
+#: .\comments\models.py:25
+msgid "parent comment"
+msgstr "parent comment"
+
+#: .\comments\models.py:29
+msgid "enable"
+msgstr "enable"
+
+#: .\comments\models.py:34 .\templates\blog\tags\article_info.html:30
+msgid "comment"
+msgstr "comment"
+
+#: .\comments\utils.py:13
+msgid "Thanks for your comment"
+msgstr "Thanks for your comment"
+
+#: .\comments\utils.py:15
+#, python-format
+msgid ""
+"
Thank you very much for your comments on this site
\n"
+" You can visit %(article_title)s\n"
+" to review your comments,\n"
+" Thank you again!\n"
+" \n"
+" If the link above cannot be opened, please copy this "
+"link to your browser.\n"
+" %(article_url)s"
+msgstr ""
+"
Thank you very much for your comments on this site
\n"
+" You can visit %(article_title)s\n"
+" to review your comments,\n"
+" Thank you again!\n"
+" \n"
+" If the link above cannot be opened, please copy this "
+"link to your browser.\n"
+" %(article_url)s"
+
+#: .\comments\utils.py:26
+#, python-format
+msgid ""
+"Your comment on "
+"%(article_title)s has \n"
+" received a reply. %(comment_body)s\n"
+" \n"
+" go check it out!\n"
+" \n"
+" If the link above cannot be opened, please copy this "
+"link to your browser.\n"
+" %(article_url)s\n"
+" "
+msgstr ""
+"Your comment on "
+"%(article_title)s has \n"
+" received a reply. %(comment_body)s\n"
+" \n"
+" go check it out!\n"
+" \n"
+" If the link above cannot be opened, please copy this "
+"link to your browser.\n"
+" %(article_url)s\n"
+" "
+
+#: .\djangoblog\logentryadmin.py:63
+msgid "object"
+msgstr "object"
+
+#: .\djangoblog\settings.py:140
+msgid "English"
+msgstr "English"
+
+#: .\djangoblog\settings.py:141
+msgid "Simplified Chinese"
+msgstr "Simplified Chinese"
+
+#: .\djangoblog\settings.py:142
+msgid "Traditional Chinese"
+msgstr "Traditional Chinese"
+
+#: .\oauth\models.py:30
+msgid "oauth user"
+msgstr "oauth user"
+
+#: .\oauth\models.py:37
+msgid "weibo"
+msgstr "weibo"
+
+#: .\oauth\models.py:38
+msgid "google"
+msgstr "google"
+
+#: .\oauth\models.py:48
+msgid "callback url"
+msgstr "callback url"
+
+#: .\oauth\models.py:59
+msgid "already exists"
+msgstr "already exists"
+
+#: .\oauth\views.py:154
+#, python-format
+msgid ""
+"\n"
+"
Congratulations, you have successfully bound your email address. You "
+"can use\n"
+" %(oauthuser_type)s to directly log in to this website without a "
+"password.
\n"
+" You are welcome to continue to follow this site, the address is\n"
+" %(site)s\n"
+" Thank you again!\n"
+" \n"
+" If the link above cannot be opened, please copy this link to your "
+"browser.\n"
+" %(site)s\n"
+" "
+msgstr ""
+"\n"
+"
Congratulations, you have successfully bound your email address. You "
+"can use\n"
+" %(oauthuser_type)s to directly log in to this website without a "
+"password.
\n"
+" You are welcome to continue to follow this site, the address is\n"
+" %(site)s\n"
+" Thank you again!\n"
+" \n"
+" If the link above cannot be opened, please copy this link to your "
+"browser.\n"
+" %(site)s\n"
+" "
+
+#: .\oauth\views.py:165
+msgid "Congratulations on your successful binding!"
+msgstr "Congratulations on your successful binding!"
+
+#: .\oauth\views.py:217
+#, python-format
+msgid ""
+"\n"
+"
Please click the link below to bind your email
\n"
+"\n"
+" %(url)s\n"
+"\n"
+" Thank you again!\n"
+" \n"
+" If the link above cannot be opened, please copy this link "
+"to your browser.\n"
+" \n"
+" %(url)s\n"
+" "
+msgstr ""
+"\n"
+"
Please click the link below to bind your email
\n"
+"\n"
+" %(url)s\n"
+"\n"
+" Thank you again!\n"
+" \n"
+" If the link above cannot be opened, please copy this link "
+"to your browser.\n"
+" \n"
+" %(url)s\n"
+" "
+
+#: .\oauth\views.py:228 .\oauth\views.py:240
+msgid "Bind your email"
+msgstr "Bind your email"
+
+#: .\oauth\views.py:242
+msgid ""
+"Congratulations, the binding is just one step away. Please log in to your "
+"email to check the email to complete the binding. Thank you."
+msgstr ""
+"Congratulations, the binding is just one step away. Please log in to your "
+"email to check the email to complete the binding. Thank you."
+
+#: .\oauth\views.py:245
+msgid "Binding successful"
+msgstr "Binding successful"
+
+#: .\oauth\views.py:247
+#, python-format
+msgid ""
+"Congratulations, you have successfully bound your email address. You can use "
+"%(oauthuser_type)s to directly log in to this website without a password. "
+"You are welcome to continue to follow this site."
+msgstr ""
+"Congratulations, you have successfully bound your email address. You can use "
+"%(oauthuser_type)s to directly log in to this website without a password. "
+"You are welcome to continue to follow this site."
+
+#: .\templates\account\forget_password.html:7
+msgid "forget the password"
+msgstr "forget the password"
+
+#: .\templates\account\forget_password.html:18
+msgid "get verification code"
+msgstr "get verification code"
+
+#: .\templates\account\forget_password.html:19
+msgid "submit"
+msgstr "submit"
+
+#: .\templates\account\login.html:36
+msgid "Create Account"
+msgstr "Create Account"
+
+#: .\templates\account\login.html:42
+#, fuzzy
+#| msgid "forget the password"
+msgid "Forget Password"
+msgstr "forget the password"
+
+#: .\templates\account\result.html:18 .\templates\blog\tags\sidebar.html:126
+msgid "login"
+msgstr "login"
+
+#: .\templates\account\result.html:22
+msgid "back to the homepage"
+msgstr "back to the homepage"
+
+#: .\templates\blog\article_archives.html:7
+#: .\templates\blog\article_archives.html:24
+msgid "article archive"
+msgstr "article archive"
+
+#: .\templates\blog\article_archives.html:32
+msgid "year"
+msgstr "year"
+
+#: .\templates\blog\article_archives.html:36
+msgid "month"
+msgstr "month"
+
+#: .\templates\blog\tags\article_info.html:12
+msgid "pin to top"
+msgstr "pin to top"
+
+#: .\templates\blog\tags\article_info.html:28
+msgid "comments"
+msgstr "comments"
+
+#: .\templates\blog\tags\article_info.html:58
+msgid "toc"
+msgstr "toc"
+
+#: .\templates\blog\tags\article_meta_info.html:6
+msgid "posted in"
+msgstr "posted in"
+
+#: .\templates\blog\tags\article_meta_info.html:14
+msgid "and tagged"
+msgstr "and tagged"
+
+#: .\templates\blog\tags\article_meta_info.html:25
+msgid "by "
+msgstr "by"
+
+#: .\templates\blog\tags\article_meta_info.html:29
+#, python-format
+msgid ""
+"\n"
+" title=\"View all articles published by "
+"%(article.author.username)s\"\n"
+" "
+msgstr ""
+"\n"
+" title=\"View all articles published by "
+"%(article.author.username)s\"\n"
+" "
+
+#: .\templates\blog\tags\article_meta_info.html:44
+msgid "on"
+msgstr "on"
+
+#: .\templates\blog\tags\article_meta_info.html:54
+msgid "edit"
+msgstr "edit"
+
+#: .\templates\blog\tags\article_pagination.html:4
+msgid "article navigation"
+msgstr "article navigation"
+
+#: .\templates\blog\tags\article_pagination.html:9
+msgid "earlier articles"
+msgstr "earlier articles"
+
+#: .\templates\blog\tags\article_pagination.html:12
+msgid "newer articles"
+msgstr "newer articles"
+
+#: .\templates\blog\tags\article_tag_list.html:5
+msgid "tags"
+msgstr "tags"
+
+#: .\templates\blog\tags\sidebar.html:7
+msgid "search"
+msgstr "search"
+
+#: .\templates\blog\tags\sidebar.html:50
+msgid "recent comments"
+msgstr "recent comments"
+
+#: .\templates\blog\tags\sidebar.html:57
+msgid "published on"
+msgstr "published on"
+
+#: .\templates\blog\tags\sidebar.html:65
+msgid "recent articles"
+msgstr "recent articles"
+
+#: .\templates\blog\tags\sidebar.html:77
+msgid "bookmark"
+msgstr "bookmark"
+
+#: .\templates\blog\tags\sidebar.html:96
+msgid "Tag Cloud"
+msgstr "Tag Cloud"
+
+#: .\templates\blog\tags\sidebar.html:107
+msgid "Welcome to star or fork the source code of this site"
+msgstr "Welcome to star or fork the source code of this site"
+
+#: .\templates\blog\tags\sidebar.html:118
+msgid "Function"
+msgstr "Function"
+
+#: .\templates\blog\tags\sidebar.html:120
+msgid "management site"
+msgstr "management site"
+
+#: .\templates\blog\tags\sidebar.html:122
+msgid "logout"
+msgstr "logout"
+
+#: .\templates\blog\tags\sidebar.html:129
+msgid "Track record"
+msgstr "Track record"
+
+#: .\templates\blog\tags\sidebar.html:135
+msgid "Click me to return to the top"
+msgstr "Click me to return to the top"
+
+#: .\templates\oauth\oauth_applications.html:5
+#| msgid "login"
+msgid "quick login"
+msgstr "quick login"
+
+#: .\templates\share_layout\nav.html:26
+msgid "Article archive"
+msgstr "Article archive"
diff --git a/src/locale/zh_Hans/LC_MESSAGES/django.mo b/src/locale/zh_Hans/LC_MESSAGES/django.mo
new file mode 100644
index 0000000..a2d36e9
Binary files /dev/null and b/src/locale/zh_Hans/LC_MESSAGES/django.mo differ
diff --git a/src/locale/zh_Hans/LC_MESSAGES/django.po b/src/locale/zh_Hans/LC_MESSAGES/django.po
new file mode 100644
index 0000000..200b7e6
--- /dev/null
+++ b/src/locale/zh_Hans/LC_MESSAGES/django.po
@@ -0,0 +1,667 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR , YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2023-09-13 16:02+0800\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME \n"
+"Language-Team: LANGUAGE \n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=1; plural=0;\n"
+
+#: .\accounts\admin.py:12
+msgid "password"
+msgstr "密码"
+
+#: .\accounts\admin.py:13
+msgid "Enter password again"
+msgstr "再次输入密码"
+
+#: .\accounts\admin.py:24 .\accounts\forms.py:89
+msgid "passwords do not match"
+msgstr "密码不匹配"
+
+#: .\accounts\forms.py:36
+msgid "email already exists"
+msgstr "邮箱已存在"
+
+#: .\accounts\forms.py:46 .\accounts\forms.py:50
+msgid "New password"
+msgstr "新密码"
+
+#: .\accounts\forms.py:60
+msgid "Confirm password"
+msgstr "确认密码"
+
+#: .\accounts\forms.py:70 .\accounts\forms.py:116
+msgid "Email"
+msgstr "邮箱"
+
+#: .\accounts\forms.py:76 .\accounts\forms.py:80
+msgid "Code"
+msgstr "验证码"
+
+#: .\accounts\forms.py:100 .\accounts\tests.py:194
+msgid "email does not exist"
+msgstr "邮箱不存在"
+
+#: .\accounts\models.py:12 .\oauth\models.py:17
+msgid "nick name"
+msgstr "昵称"
+
+#: .\accounts\models.py:13 .\blog\models.py:29 .\blog\models.py:266
+#: .\blog\models.py:284 .\comments\models.py:13 .\oauth\models.py:23
+#: .\oauth\models.py:53
+msgid "creation time"
+msgstr "创建时间"
+
+#: .\accounts\models.py:14 .\comments\models.py:14 .\oauth\models.py:24
+#: .\oauth\models.py:54
+msgid "last modify time"
+msgstr "最后修改时间"
+
+#: .\accounts\models.py:15
+msgid "create source"
+msgstr "来源"
+
+#: .\accounts\models.py:33 .\djangoblog\logentryadmin.py:81
+msgid "user"
+msgstr "用户"
+
+#: .\accounts\tests.py:216 .\accounts\utils.py:39
+msgid "Verification code error"
+msgstr "验证码错误"
+
+#: .\accounts\utils.py:13
+msgid "Verify Email"
+msgstr "验证邮箱"
+
+#: .\accounts\utils.py:21
+#, python-format
+msgid ""
+"You are resetting the password, the verification code is:%(code)s, valid "
+"within 5 minutes, please keep it properly"
+msgstr "您正在重置密码,验证码为:%(code)s,5分钟内有效 请妥善保管."
+
+#: .\blog\admin.py:13 .\blog\models.py:92 .\comments\models.py:17
+#: .\oauth\models.py:12
+msgid "author"
+msgstr "作者"
+
+#: .\blog\admin.py:53
+msgid "Publish selected articles"
+msgstr "发布选中的文章"
+
+#: .\blog\admin.py:54
+msgid "Draft selected articles"
+msgstr "选中文章设为草稿"
+
+#: .\blog\admin.py:55
+msgid "Close article comments"
+msgstr "关闭文章评论"
+
+#: .\blog\admin.py:56
+msgid "Open article comments"
+msgstr "打开文章评论"
+
+#: .\blog\admin.py:89 .\blog\models.py:101 .\blog\models.py:183
+#: .\templates\blog\tags\sidebar.html:40
+msgid "category"
+msgstr "分类目录"
+
+#: .\blog\models.py:20 .\blog\models.py:179 .\templates\share_layout\nav.html:8
+msgid "index"
+msgstr "首页"
+
+#: .\blog\models.py:21
+msgid "list"
+msgstr "列表"
+
+#: .\blog\models.py:22
+msgid "post"
+msgstr "文章"
+
+#: .\blog\models.py:23
+msgid "all"
+msgstr "所有"
+
+#: .\blog\models.py:24
+msgid "slide"
+msgstr "侧边栏"
+
+#: .\blog\models.py:30 .\blog\models.py:267 .\blog\models.py:285
+msgid "modify time"
+msgstr "修改时间"
+
+#: .\blog\models.py:63
+msgid "Draft"
+msgstr "草稿"
+
+#: .\blog\models.py:64
+msgid "Published"
+msgstr "发布"
+
+#: .\blog\models.py:67
+msgid "Open"
+msgstr "打开"
+
+#: .\blog\models.py:68
+msgid "Close"
+msgstr "关闭"
+
+#: .\blog\models.py:71 .\comments\admin.py:47
+msgid "Article"
+msgstr "文章"
+
+#: .\blog\models.py:72
+msgid "Page"
+msgstr "页面"
+
+#: .\blog\models.py:74 .\blog\models.py:280
+msgid "title"
+msgstr "标题"
+
+#: .\blog\models.py:75
+msgid "body"
+msgstr "内容"
+
+#: .\blog\models.py:77
+msgid "publish time"
+msgstr "发布时间"
+
+#: .\blog\models.py:79
+msgid "status"
+msgstr "状态"
+
+#: .\blog\models.py:84
+msgid "comment status"
+msgstr "评论状态"
+
+#: .\blog\models.py:88 .\oauth\models.py:43
+msgid "type"
+msgstr "类型"
+
+#: .\blog\models.py:89
+msgid "views"
+msgstr "阅读量"
+
+#: .\blog\models.py:97 .\blog\models.py:258 .\blog\models.py:282
+msgid "order"
+msgstr "排序"
+
+#: .\blog\models.py:98
+msgid "show toc"
+msgstr "显示目录"
+
+#: .\blog\models.py:105 .\blog\models.py:249
+msgid "tag"
+msgstr "标签"
+
+#: .\blog\models.py:115 .\comments\models.py:21
+msgid "article"
+msgstr "文章"
+
+#: .\blog\models.py:171
+msgid "category name"
+msgstr "分类名"
+
+#: .\blog\models.py:174
+msgid "parent category"
+msgstr "上级分类"
+
+#: .\blog\models.py:234
+msgid "tag name"
+msgstr "标签名"
+
+#: .\blog\models.py:256
+msgid "link name"
+msgstr "链接名"
+
+#: .\blog\models.py:257 .\blog\models.py:271
+msgid "link"
+msgstr "链接"
+
+#: .\blog\models.py:260
+msgid "is show"
+msgstr "是否显示"
+
+#: .\blog\models.py:262
+msgid "show type"
+msgstr "显示类型"
+
+#: .\blog\models.py:281
+msgid "content"
+msgstr "内容"
+
+#: .\blog\models.py:283 .\oauth\models.py:52
+msgid "is enable"
+msgstr "是否启用"
+
+#: .\blog\models.py:289
+msgid "sidebar"
+msgstr "侧边栏"
+
+#: .\blog\models.py:299
+msgid "site name"
+msgstr "站点名称"
+
+#: .\blog\models.py:305
+msgid "site description"
+msgstr "站点描述"
+
+#: .\blog\models.py:311
+msgid "site seo description"
+msgstr "站点SEO描述"
+
+#: .\blog\models.py:313
+msgid "site keywords"
+msgstr "关键字"
+
+#: .\blog\models.py:318
+msgid "article sub length"
+msgstr "文章摘要长度"
+
+#: .\blog\models.py:319
+msgid "sidebar article count"
+msgstr "侧边栏文章数目"
+
+#: .\blog\models.py:320
+msgid "sidebar comment count"
+msgstr "侧边栏评论数目"
+
+#: .\blog\models.py:321
+msgid "article comment count"
+msgstr "文章页面默认显示评论数目"
+
+#: .\blog\models.py:322
+msgid "show adsense"
+msgstr "是否显示广告"
+
+#: .\blog\models.py:324
+msgid "adsense code"
+msgstr "广告内容"
+
+#: .\blog\models.py:325
+msgid "open site comment"
+msgstr "公共头部"
+
+#: .\blog\models.py:352
+msgid "Website configuration"
+msgstr "网站配置"
+
+#: .\blog\models.py:360
+msgid "There can only be one configuration"
+msgstr "只能有一个配置"
+
+#: .\blog\views.py:348
+msgid ""
+"Sorry, the page you requested is not found, please click the home page to "
+"see other?"
+msgstr "抱歉,你所访问的页面找不到,请点击首页看看别的?"
+
+#: .\blog\views.py:356
+msgid "Sorry, the server is busy, please click the home page to see other?"
+msgstr "抱歉,服务出错了,请点击首页看看别的?"
+
+#: .\blog\views.py:369
+msgid "Sorry, you do not have permission to access this page?"
+msgstr "抱歉,你没用权限访问此页面。"
+
+#: .\comments\admin.py:15
+msgid "Disable comments"
+msgstr "禁用评论"
+
+#: .\comments\admin.py:16
+msgid "Enable comments"
+msgstr "启用评论"
+
+#: .\comments\admin.py:46
+msgid "User"
+msgstr "用户"
+
+#: .\comments\models.py:25
+msgid "parent comment"
+msgstr "上级评论"
+
+#: .\comments\models.py:29
+msgid "enable"
+msgstr "启用"
+
+#: .\comments\models.py:34 .\templates\blog\tags\article_info.html:30
+msgid "comment"
+msgstr "评论"
+
+#: .\comments\utils.py:13
+msgid "Thanks for your comment"
+msgstr "感谢你的评论"
+
+#: .\comments\utils.py:15
+#, python-format
+msgid ""
+"
Thank you very much for your comments on this site
\n"
+" You can visit %(article_title)s\n"
+" to review your comments,\n"
+" Thank you again!\n"
+" \n"
+" If the link above cannot be opened, please copy this "
+"link to your browser.\n"
+" %(article_url)s"
+msgstr ""
+"
Congratulations, you have successfully bound your email address. You "
+"can use\n"
+" %(oauthuser_type)s to directly log in to this website without a "
+"password.
\n"
+" You are welcome to continue to follow this site, the address is\n"
+" %(site)s\n"
+" Thank you again!\n"
+" \n"
+" If the link above cannot be opened, please copy this link to your "
+"browser.\n"
+" %(site)s\n"
+" "
+msgstr ""
+"\n"
+"
\n"
+"\n"
+" %(url)s\n"
+"\n"
+" Thank you again!\n"
+" \n"
+" If the link above cannot be opened, please copy this link "
+"to your browser.\n"
+" \n"
+" %(url)s\n"
+" "
+msgstr ""
+"\n"
+"
Thank you very much for your comments on this site
\n"
+" You can visit %(article_title)s\n"
+" to review your comments,\n"
+" Thank you again!\n"
+" \n"
+" If the link above cannot be opened, please copy this "
+"link to your browser.\n"
+" %(article_url)s"
+msgstr ""
+"
Congratulations, you have successfully bound your email address. You "
+"can use\n"
+" %(oauthuser_type)s to directly log in to this website without a "
+"password.
\n"
+" You are welcome to continue to follow this site, the address is\n"
+" %(site)s\n"
+" Thank you again!\n"
+" \n"
+" If the link above cannot be opened, please copy this link to your "
+"browser.\n"
+" %(site)s\n"
+" "
+msgstr ""
+"\n"
+"
\n"
+"\n"
+" %(url)s\n"
+"\n"
+" Thank you again!\n"
+" \n"
+" If the link above cannot be opened, please copy this link "
+"to your browser.\n"
+" \n"
+" %(url)s\n"
+" "
+msgstr ""
+"\n"
+"
請點擊下面的鏈接綁定您的郵箱
\n"
+"\n"
+" %(url)s\n"
+"\n"
+"再次感謝您!\n"
+" \n"
+"如果上面的鏈接打不開,請復製此鏈接到您的瀏覽器。\n"
+"%(url)s\n"
+" "
+
+#: .\oauth\views.py:228 .\oauth\views.py:240
+msgid "Bind your email"
+msgstr "綁定郵箱"
+
+#: .\oauth\views.py:242
+msgid ""
+"Congratulations, the binding is just one step away. Please log in to your "
+"email to check the email to complete the binding. Thank you."
+msgstr "恭喜您,還差一步就綁定成功了,請登錄您的郵箱查看郵件完成綁定,謝謝。"
+
+#: .\oauth\views.py:245
+msgid "Binding successful"
+msgstr "綁定成功"
+
+#: .\oauth\views.py:247
+#, python-format
+msgid ""
+"Congratulations, you have successfully bound your email address. You can use "
+"%(oauthuser_type)s to directly log in to this website without a password. "
+"You are welcome to continue to follow this site."
+msgstr ""
+"恭喜您綁定成功,您以後可以使用%(oauthuser_type)s來直接免密碼登錄本站啦,感謝"
+"您對本站對關註。"
+
+#: .\templates\account\forget_password.html:7
+msgid "forget the password"
+msgstr "忘記密碼"
+
+#: .\templates\account\forget_password.html:18
+msgid "get verification code"
+msgstr "獲取驗證碼"
+
+#: .\templates\account\forget_password.html:19
+msgid "submit"
+msgstr "提交"
+
+#: .\templates\account\login.html:36
+msgid "Create Account"
+msgstr "創建賬號"
+
+#: .\templates\account\login.html:42
+#, fuzzy
+#| msgid "forget the password"
+msgid "Forget Password"
+msgstr "忘記密碼"
+
+#: .\templates\account\result.html:18 .\templates\blog\tags\sidebar.html:126
+msgid "login"
+msgstr "登錄"
+
+#: .\templates\account\result.html:22
+msgid "back to the homepage"
+msgstr "返回首頁吧"
+
+#: .\templates\blog\article_archives.html:7
+#: .\templates\blog\article_archives.html:24
+msgid "article archive"
+msgstr "文章歸檔"
+
+#: .\templates\blog\article_archives.html:32
+msgid "year"
+msgstr "年"
+
+#: .\templates\blog\article_archives.html:36
+msgid "month"
+msgstr "月"
+
+#: .\templates\blog\tags\article_info.html:12
+msgid "pin to top"
+msgstr "置頂"
+
+#: .\templates\blog\tags\article_info.html:28
+msgid "comments"
+msgstr "評論"
+
+#: .\templates\blog\tags\article_info.html:58
+msgid "toc"
+msgstr "目錄"
+
+#: .\templates\blog\tags\article_meta_info.html:6
+msgid "posted in"
+msgstr "發布於"
+
+#: .\templates\blog\tags\article_meta_info.html:14
+msgid "and tagged"
+msgstr "並標記為"
+
+#: .\templates\blog\tags\article_meta_info.html:25
+msgid "by "
+msgstr "由"
+
+#: .\templates\blog\tags\article_meta_info.html:29
+#, python-format
+msgid ""
+"\n"
+" title=\"View all articles published by "
+"%(article.author.username)s\"\n"
+" "
+msgstr ""
+"\n"
+" title=\"查看所有由 %(article.author.username)s\"發布的文章\n"
+" "
+
+#: .\templates\blog\tags\article_meta_info.html:44
+msgid "on"
+msgstr "在"
+
+#: .\templates\blog\tags\article_meta_info.html:54
+msgid "edit"
+msgstr "編輯"
+
+#: .\templates\blog\tags\article_pagination.html:4
+msgid "article navigation"
+msgstr "文章導航"
+
+#: .\templates\blog\tags\article_pagination.html:9
+msgid "earlier articles"
+msgstr "早期文章"
+
+#: .\templates\blog\tags\article_pagination.html:12
+msgid "newer articles"
+msgstr "較新文章"
+
+#: .\templates\blog\tags\article_tag_list.html:5
+msgid "tags"
+msgstr "標簽"
+
+#: .\templates\blog\tags\sidebar.html:7
+msgid "search"
+msgstr "搜索"
+
+#: .\templates\blog\tags\sidebar.html:50
+msgid "recent comments"
+msgstr "近期評論"
+
+#: .\templates\blog\tags\sidebar.html:57
+msgid "published on"
+msgstr "發表於"
+
+#: .\templates\blog\tags\sidebar.html:65
+msgid "recent articles"
+msgstr "近期文章"
+
+#: .\templates\blog\tags\sidebar.html:77
+msgid "bookmark"
+msgstr "書簽"
+
+#: .\templates\blog\tags\sidebar.html:96
+msgid "Tag Cloud"
+msgstr "標簽雲"
+
+#: .\templates\blog\tags\sidebar.html:107
+msgid "Welcome to star or fork the source code of this site"
+msgstr "歡迎您STAR或者FORK本站源代碼"
+
+#: .\templates\blog\tags\sidebar.html:118
+msgid "Function"
+msgstr "功能"
+
+#: .\templates\blog\tags\sidebar.html:120
+msgid "management site"
+msgstr "管理站點"
+
+#: .\templates\blog\tags\sidebar.html:122
+msgid "logout"
+msgstr "登出"
+
+#: .\templates\blog\tags\sidebar.html:129
+msgid "Track record"
+msgstr "運動軌跡記錄"
+
+#: .\templates\blog\tags\sidebar.html:135
+msgid "Click me to return to the top"
+msgstr "點我返回頂部"
+
+#: .\templates\oauth\oauth_applications.html:5
+#| msgid "login"
+msgid "quick login"
+msgstr "快捷登錄"
+
+#: .\templates\share_layout\nav.html:26
+msgid "Article archive"
+msgstr "文章歸檔"
diff --git a/src/manage.py b/src/manage.py
new file mode 100644
index 0000000..919ba74
--- /dev/null
+++ b/src/manage.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+import os
+import sys
+
+if __name__ == "__main__":
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "djangoblog.settings")
+ try:
+ from django.core.management import execute_from_command_line
+ except ImportError:
+ # The above import may fail for some other reason. Ensure that the
+ # issue is really that Django is missing to avoid masking other
+ # exceptions on Python 2.
+ try:
+ import django
+ except ImportError:
+ raise ImportError(
+ "Couldn't import Django. Are you sure it's installed and "
+ "available on your PYTHONPATH environment variable? Did you "
+ "forget to activate a virtual environment?"
+ )
+ raise
+ execute_from_command_line(sys.argv)
diff --git a/src/myenv/Scripts/Activate.ps1 b/src/myenv/Scripts/Activate.ps1
new file mode 100644
index 0000000..5e49b7e
--- /dev/null
+++ b/src/myenv/Scripts/Activate.ps1
@@ -0,0 +1,502 @@
+<#
+.Synopsis
+Activate a Python virtual environment for the current PowerShell session.
+
+.Description
+Pushes the python executable for a virtual environment to the front of the
+$Env:PATH environment variable and sets the prompt to signify that you are
+in a Python virtual environment. Makes use of the command line switches as
+well as the `pyvenv.cfg` file values present in the virtual environment.
+
+.Parameter VenvDir
+Path to the directory that contains the virtual environment to activate. The
+default value for this is the parent of the directory that the Activate.ps1
+script is located within.
+
+.Parameter Prompt
+The prompt prefix to display when this virtual environment is activated. By
+default, this prompt is the name of the virtual environment folder (VenvDir)
+surrounded by parentheses and followed by a single space (ie. '(.venv) ').
+
+.Example
+Activate.ps1
+Activates the Python virtual environment that contains the Activate.ps1 script.
+
+.Example
+Activate.ps1 -Verbose
+Activates the Python virtual environment that contains the Activate.ps1 script,
+and shows extra information about the activation as it executes.
+
+.Example
+Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv
+Activates the Python virtual environment located in the specified location.
+
+.Example
+Activate.ps1 -Prompt "MyPython"
+Activates the Python virtual environment that contains the Activate.ps1 script,
+and prefixes the current prompt with the specified string (surrounded in
+parentheses) while the virtual environment is active.
+
+.Notes
+On Windows, it may be required to enable this Activate.ps1 script by setting the
+execution policy for the user. You can do this by issuing the following PowerShell
+command:
+
+PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
+
+For more information on Execution Policies:
+https://go.microsoft.com/fwlink/?LinkID=135170
+
+#>
+Param(
+ [Parameter(Mandatory = $false)]
+ [String]
+ $VenvDir,
+ [Parameter(Mandatory = $false)]
+ [String]
+ $Prompt
+)
+
+<# Function declarations --------------------------------------------------- #>
+
+<#
+.Synopsis
+Remove all shell session elements added by the Activate script, including the
+addition of the virtual environment's Python executable from the beginning of
+the PATH variable.
+
+.Parameter NonDestructive
+If present, do not remove this function from the global namespace for the
+session.
+
+#>
+function global:deactivate ([switch]$NonDestructive) {
+ # Revert to original values
+
+ # The prior prompt:
+ if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) {
+ Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt
+ Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT
+ }
+
+ # The prior PYTHONHOME:
+ if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) {
+ Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME
+ Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME
+ }
+
+ # The prior PATH:
+ if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) {
+ Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH
+ Remove-Item -Path Env:_OLD_VIRTUAL_PATH
+ }
+
+ # Just remove the VIRTUAL_ENV altogether:
+ if (Test-Path -Path Env:VIRTUAL_ENV) {
+ Remove-Item -Path env:VIRTUAL_ENV
+ }
+
+ # Just remove VIRTUAL_ENV_PROMPT altogether.
+ if (Test-Path -Path Env:VIRTUAL_ENV_PROMPT) {
+ Remove-Item -Path env:VIRTUAL_ENV_PROMPT
+ }
+
+ # Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether:
+ if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) {
+ Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force
+ }
+
+ # Leave deactivate function in the global namespace if requested:
+ if (-not $NonDestructive) {
+ Remove-Item -Path function:deactivate
+ }
+}
+
+<#
+.Description
+Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the
+given folder, and returns them in a map.
+
+For each line in the pyvenv.cfg file, if that line can be parsed into exactly
+two strings separated by `=` (with any amount of whitespace surrounding the =)
+then it is considered a `key = value` line. The left hand string is the key,
+the right hand is the value.
+
+If the value starts with a `'` or a `"` then the first and last character is
+stripped from the value before being captured.
+
+.Parameter ConfigDir
+Path to the directory that contains the `pyvenv.cfg` file.
+#>
+function Get-PyVenvConfig(
+ [String]
+ $ConfigDir
+) {
+ Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg"
+
+ # Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue).
+ $pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue
+
+ # An empty map will be returned if no config file is found.
+ $pyvenvConfig = @{ }
+
+ if ($pyvenvConfigPath) {
+
+ Write-Verbose "File exists, parse `key = value` lines"
+ $pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath
+
+ $pyvenvConfigContent | ForEach-Object {
+ $keyval = $PSItem -split "\s*=\s*", 2
+ if ($keyval[0] -and $keyval[1]) {
+ $val = $keyval[1]
+
+ # Remove extraneous quotations around a string value.
+ if ("'""".Contains($val.Substring(0, 1))) {
+ $val = $val.Substring(1, $val.Length - 2)
+ }
+
+ $pyvenvConfig[$keyval[0]] = $val
+ Write-Verbose "Adding Key: '$($keyval[0])'='$val'"
+ }
+ }
+ }
+ return $pyvenvConfig
+}
+
+
+<# Begin Activate script --------------------------------------------------- #>
+
+# Determine the containing directory of this script
+$VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
+$VenvExecDir = Get-Item -Path $VenvExecPath
+
+Write-Verbose "Activation script is located in path: '$VenvExecPath'"
+Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)"
+Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)"
+
+# Set values required in priority: CmdLine, ConfigFile, Default
+# First, get the location of the virtual environment, it might not be
+# VenvExecDir if specified on the command line.
+if ($VenvDir) {
+ Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values"
+}
+else {
+ Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir."
+ $VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/")
+ Write-Verbose "VenvDir=$VenvDir"
+}
+
+# Next, read the `pyvenv.cfg` file to determine any required value such
+# as `prompt`.
+$pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir
+
+# Next, set the prompt from the command line, or the config file, or
+# just use the name of the virtual environment folder.
+if ($Prompt) {
+ Write-Verbose "Prompt specified as argument, using '$Prompt'"
+}
+else {
+ Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value"
+ if ($pyvenvCfg -and $pyvenvCfg['prompt']) {
+ Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'"
+ $Prompt = $pyvenvCfg['prompt'];
+ }
+ else {
+ Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virtual environment)"
+ Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'"
+ $Prompt = Split-Path -Path $venvDir -Leaf
+ }
+}
+
+Write-Verbose "Prompt = '$Prompt'"
+Write-Verbose "VenvDir='$VenvDir'"
+
+# Deactivate any currently active virtual environment, but leave the
+# deactivate function in place.
+deactivate -nondestructive
+
+# Now set the environment variable VIRTUAL_ENV, used by many tools to determine
+# that there is an activated venv.
+$env:VIRTUAL_ENV = $VenvDir
+
+if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {
+
+ Write-Verbose "Setting prompt to '$Prompt'"
+
+ # Set the prompt to include the env name
+ # Make sure _OLD_VIRTUAL_PROMPT is global
+ function global:_OLD_VIRTUAL_PROMPT { "" }
+ Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT
+ New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt
+
+ function global:prompt {
+ Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) "
+ _OLD_VIRTUAL_PROMPT
+ }
+ $env:VIRTUAL_ENV_PROMPT = $Prompt
+}
+
+# Clear PYTHONHOME
+if (Test-Path -Path Env:PYTHONHOME) {
+ Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME
+ Remove-Item -Path Env:PYTHONHOME
+}
+
+# Add the venv to the PATH
+Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH
+$Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH"
+
+# SIG # Begin signature block
+# MIIvIwYJKoZIhvcNAQcCoIIvFDCCLxACAQExDzANBglghkgBZQMEAgEFADB5Bgor
+# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
+# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCBnL745ElCYk8vk
+# dBtMuQhLeWJ3ZGfzKW4DHCYzAn+QB6CCE8MwggWQMIIDeKADAgECAhAFmxtXno4h
+# MuI5B72nd3VcMA0GCSqGSIb3DQEBDAUAMGIxCzAJBgNVBAYTAlVTMRUwEwYDVQQK
+# EwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xITAfBgNV
+# BAMTGERpZ2lDZXJ0IFRydXN0ZWQgUm9vdCBHNDAeFw0xMzA4MDExMjAwMDBaFw0z
+# ODAxMTUxMjAwM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ZBX/jc++OHFLkTEp
+# hB9Z1SyLC3TJa3x+ze7p84q/eYs1xqjRIoy3mkQ9gAndWCktfaOp1wAwP4oySENY
+# 0Ztionj+H/iydIQNKscWZ95uj/ZTm79OW67X2hLmGOv0ukNck+FE7tHN8I4Lh6VX
+# TvjYh8p2SbGHd5v60wqYgrBm5k/r9cacjaptbfl0iP4lY4jqYKnpD3gAvegh5tA4
+# xCmikLbNT99M080eLf2ES/UGqF8THAfLHZXlrFFcJQ3WvwgoiRCTv2ifVlxUXwxB
+# lMOfJY3zIEnrxag0ZMJciZX21rKW4ZFoU50q7Nd9+T830tfjwaJWfSNE9Sisr4id
+# UvBU/gsB/5d1HPBlxQfXvxm/TMUDeT4=
+# SIG # End signature block
diff --git a/src/myenv/Scripts/activate b/src/myenv/Scripts/activate
new file mode 100644
index 0000000..6359cec
--- /dev/null
+++ b/src/myenv/Scripts/activate
@@ -0,0 +1,69 @@
+# This file must be used with "source bin/activate" *from bash*
+# you cannot run it directly
+
+deactivate () {
+ # reset old environment variables
+ if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
+ PATH="${_OLD_VIRTUAL_PATH:-}"
+ export PATH
+ unset _OLD_VIRTUAL_PATH
+ fi
+ if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
+ PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
+ export PYTHONHOME
+ unset _OLD_VIRTUAL_PYTHONHOME
+ fi
+
+ # This should detect bash and zsh, which have a hash command that must
+ # be called to get it to forget past commands. Without forgetting
+ # past commands the $PATH changes we made may not be respected
+ if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
+ hash -r 2> /dev/null
+ fi
+
+ if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
+ PS1="${_OLD_VIRTUAL_PS1:-}"
+ export PS1
+ unset _OLD_VIRTUAL_PS1
+ fi
+
+ unset VIRTUAL_ENV
+ unset VIRTUAL_ENV_PROMPT
+ if [ ! "${1:-}" = "nondestructive" ] ; then
+ # Self destruct!
+ unset -f deactivate
+ fi
+}
+
+# unset irrelevant variables
+deactivate nondestructive
+
+VIRTUAL_ENV="C:\Users\ITkan\DjangoBlog\myenv"
+export VIRTUAL_ENV
+
+_OLD_VIRTUAL_PATH="$PATH"
+PATH="$VIRTUAL_ENV/Scripts:$PATH"
+export PATH
+
+# unset PYTHONHOME if set
+# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
+# could use `if (set -u; : $PYTHONHOME) ;` in bash
+if [ -n "${PYTHONHOME:-}" ] ; then
+ _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
+ unset PYTHONHOME
+fi
+
+if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
+ _OLD_VIRTUAL_PS1="${PS1:-}"
+ PS1="(myenv) ${PS1:-}"
+ export PS1
+ VIRTUAL_ENV_PROMPT="(myenv) "
+ export VIRTUAL_ENV_PROMPT
+fi
+
+# This should detect bash and zsh, which have a hash command that must
+# be called to get it to forget past commands. Without forgetting
+# past commands the $PATH changes we made may not be respected
+if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
+ hash -r 2> /dev/null
+fi
diff --git a/src/myenv/Scripts/activate.bat b/src/myenv/Scripts/activate.bat
new file mode 100644
index 0000000..0b54583
--- /dev/null
+++ b/src/myenv/Scripts/activate.bat
@@ -0,0 +1,34 @@
+@echo off
+
+rem This file is UTF-8 encoded, so we need to update the current code page while executing it
+for /f "tokens=2 delims=:." %%a in ('"%SystemRoot%\System32\chcp.com"') do (
+ set _OLD_CODEPAGE=%%a
+)
+if defined _OLD_CODEPAGE (
+ "%SystemRoot%\System32\chcp.com" 65001 > nul
+)
+
+set VIRTUAL_ENV=C:\Users\ITkan\DjangoBlog\myenv
+
+if not defined PROMPT set PROMPT=$P$G
+
+if defined _OLD_VIRTUAL_PROMPT set PROMPT=%_OLD_VIRTUAL_PROMPT%
+if defined _OLD_VIRTUAL_PYTHONHOME set PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%
+
+set _OLD_VIRTUAL_PROMPT=%PROMPT%
+set PROMPT=(myenv) %PROMPT%
+
+if defined PYTHONHOME set _OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%
+set PYTHONHOME=
+
+if defined _OLD_VIRTUAL_PATH set PATH=%_OLD_VIRTUAL_PATH%
+if not defined _OLD_VIRTUAL_PATH set _OLD_VIRTUAL_PATH=%PATH%
+
+set PATH=%VIRTUAL_ENV%\Scripts;%PATH%
+set VIRTUAL_ENV_PROMPT=(myenv)
+
+:END
+if defined _OLD_CODEPAGE (
+ "%SystemRoot%\System32\chcp.com" %_OLD_CODEPAGE% > nul
+ set _OLD_CODEPAGE=
+)
diff --git a/src/myenv/Scripts/deactivate.bat b/src/myenv/Scripts/deactivate.bat
new file mode 100644
index 0000000..62a39a7
--- /dev/null
+++ b/src/myenv/Scripts/deactivate.bat
@@ -0,0 +1,22 @@
+@echo off
+
+if defined _OLD_VIRTUAL_PROMPT (
+ set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
+)
+set _OLD_VIRTUAL_PROMPT=
+
+if defined _OLD_VIRTUAL_PYTHONHOME (
+ set "PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%"
+ set _OLD_VIRTUAL_PYTHONHOME=
+)
+
+if defined _OLD_VIRTUAL_PATH (
+ set "PATH=%_OLD_VIRTUAL_PATH%"
+)
+
+set _OLD_VIRTUAL_PATH=
+
+set VIRTUAL_ENV=
+set VIRTUAL_ENV_PROMPT=
+
+:END
diff --git a/src/myenv/Scripts/pip.exe b/src/myenv/Scripts/pip.exe
new file mode 100644
index 0000000..c79d48f
Binary files /dev/null and b/src/myenv/Scripts/pip.exe differ
diff --git a/src/myenv/Scripts/pip3.10.exe b/src/myenv/Scripts/pip3.10.exe
new file mode 100644
index 0000000..c79d48f
Binary files /dev/null and b/src/myenv/Scripts/pip3.10.exe differ
diff --git a/src/myenv/Scripts/pip3.exe b/src/myenv/Scripts/pip3.exe
new file mode 100644
index 0000000..c79d48f
Binary files /dev/null and b/src/myenv/Scripts/pip3.exe differ
diff --git a/src/myenv/Scripts/python.exe b/src/myenv/Scripts/python.exe
new file mode 100644
index 0000000..8655d9d
Binary files /dev/null and b/src/myenv/Scripts/python.exe differ
diff --git a/src/myenv/Scripts/pythonw.exe b/src/myenv/Scripts/pythonw.exe
new file mode 100644
index 0000000..b19f1fd
Binary files /dev/null and b/src/myenv/Scripts/pythonw.exe differ
diff --git a/src/myenv/pyvenv.cfg b/src/myenv/pyvenv.cfg
new file mode 100644
index 0000000..fa76393
--- /dev/null
+++ b/src/myenv/pyvenv.cfg
@@ -0,0 +1,3 @@
+home = C:\Users\ITkan\AppData\Local\Programs\Python\Python310
+include-system-site-packages = false
+version = 3.10.11
diff --git a/src/oauth/__init__.py b/src/oauth/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/src/oauth/admin.py b/src/oauth/admin.py
new file mode 100644
index 0000000..57eab5f
--- /dev/null
+++ b/src/oauth/admin.py
@@ -0,0 +1,54 @@
+import logging
+
+from django.contrib import admin
+# Register your models here.
+from django.urls import reverse
+from django.utils.html import format_html
+
+logger = logging.getLogger(__name__)
+
+
+class OAuthUserAdmin(admin.ModelAdmin):
+ search_fields = ('nickname', 'email')
+ list_per_page = 20
+ list_display = (
+ 'id',
+ 'nickname',
+ 'link_to_usermodel',
+ 'show_user_image',
+ 'type',
+ 'email',
+ )
+ list_display_links = ('id', 'nickname')
+ list_filter = ('author', 'type',)
+ readonly_fields = []
+
+ def get_readonly_fields(self, request, obj=None):
+ return list(self.readonly_fields) + \
+ [field.name for field in obj._meta.fields] + \
+ [field.name for field in obj._meta.many_to_many]
+
+ def has_add_permission(self, request):
+ return False
+
+ def link_to_usermodel(self, obj):
+ if obj.author:
+ info = (obj.author._meta.app_label, obj.author._meta.model_name)
+ link = reverse('admin:%s_%s_change' % info, args=(obj.author.id,))
+ return format_html(
+ u'%s' %
+ (link, obj.author.nickname if obj.author.nickname else obj.author.email))
+
+ def show_user_image(self, obj):
+ img = obj.picture
+ return format_html(
+ u'' %
+ (img))
+
+ link_to_usermodel.short_description = '用户'
+ show_user_image.short_description = '用户头像'
+
+
+class OAuthConfigAdmin(admin.ModelAdmin):
+ list_display = ('type', 'appkey', 'appsecret', 'is_enable')
+ list_filter = ('type',)
diff --git a/src/oauth/apps.py b/src/oauth/apps.py
new file mode 100644
index 0000000..17fcea2
--- /dev/null
+++ b/src/oauth/apps.py
@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class OauthConfig(AppConfig):
+ name = 'oauth'
diff --git a/src/oauth/forms.py b/src/oauth/forms.py
new file mode 100644
index 0000000..0e4ede3
--- /dev/null
+++ b/src/oauth/forms.py
@@ -0,0 +1,12 @@
+from django.contrib.auth.forms import forms
+from django.forms import widgets
+
+
+class RequireEmailForm(forms.Form):
+ email = forms.EmailField(label='电子邮箱', required=True)
+ oauthid = forms.IntegerField(widget=forms.HiddenInput, required=False)
+
+ def __init__(self, *args, **kwargs):
+ super(RequireEmailForm, self).__init__(*args, **kwargs)
+ self.fields['email'].widget = widgets.EmailInput(
+ attrs={'placeholder': "email", "class": "form-control"})
diff --git a/src/oauth/migrations/0001_initial.py b/src/oauth/migrations/0001_initial.py
new file mode 100644
index 0000000..3aa3e03
--- /dev/null
+++ b/src/oauth/migrations/0001_initial.py
@@ -0,0 +1,57 @@
+# Generated by Django 4.1.7 on 2023-03-07 09:53
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+import django.utils.timezone
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='OAuthConfig',
+ fields=[
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('type', models.CharField(choices=[('weibo', '微博'), ('google', '谷歌'), ('github', 'GitHub'), ('facebook', 'FaceBook'), ('qq', 'QQ')], default='a', max_length=10, verbose_name='类型')),
+ ('appkey', models.CharField(max_length=200, verbose_name='AppKey')),
+ ('appsecret', models.CharField(max_length=200, verbose_name='AppSecret')),
+ ('callback_url', models.CharField(default='http://www.baidu.com', max_length=200, verbose_name='回调地址')),
+ ('is_enable', models.BooleanField(default=True, verbose_name='是否显示')),
+ ('created_time', models.DateTimeField(default=django.utils.timezone.now, verbose_name='创建时间')),
+ ('last_mod_time', models.DateTimeField(default=django.utils.timezone.now, verbose_name='修改时间')),
+ ],
+ options={
+ 'verbose_name': 'oauth配置',
+ 'verbose_name_plural': 'oauth配置',
+ 'ordering': ['-created_time'],
+ },
+ ),
+ migrations.CreateModel(
+ name='OAuthUser',
+ fields=[
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('openid', models.CharField(max_length=50)),
+ ('nickname', models.CharField(max_length=50, verbose_name='昵称')),
+ ('token', models.CharField(blank=True, max_length=150, null=True)),
+ ('picture', models.CharField(blank=True, max_length=350, null=True)),
+ ('type', models.CharField(max_length=50)),
+ ('email', models.CharField(blank=True, max_length=50, null=True)),
+ ('metadata', models.TextField(blank=True, null=True)),
+ ('created_time', models.DateTimeField(default=django.utils.timezone.now, verbose_name='创建时间')),
+ ('last_mod_time', models.DateTimeField(default=django.utils.timezone.now, verbose_name='修改时间')),
+ ('author', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='用户')),
+ ],
+ options={
+ 'verbose_name': 'oauth用户',
+ 'verbose_name_plural': 'oauth用户',
+ 'ordering': ['-created_time'],
+ },
+ ),
+ ]
diff --git a/src/oauth/migrations/0002_alter_oauthconfig_options_alter_oauthuser_options_and_more.py b/src/oauth/migrations/0002_alter_oauthconfig_options_alter_oauthuser_options_and_more.py
new file mode 100644
index 0000000..d5cc70e
--- /dev/null
+++ b/src/oauth/migrations/0002_alter_oauthconfig_options_alter_oauthuser_options_and_more.py
@@ -0,0 +1,86 @@
+# Generated by Django 4.2.5 on 2023-09-06 13:13
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+import django.utils.timezone
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ('oauth', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AlterModelOptions(
+ name='oauthconfig',
+ options={'ordering': ['-creation_time'], 'verbose_name': 'oauth配置', 'verbose_name_plural': 'oauth配置'},
+ ),
+ migrations.AlterModelOptions(
+ name='oauthuser',
+ options={'ordering': ['-creation_time'], 'verbose_name': 'oauth user', 'verbose_name_plural': 'oauth user'},
+ ),
+ migrations.RemoveField(
+ model_name='oauthconfig',
+ name='created_time',
+ ),
+ migrations.RemoveField(
+ model_name='oauthconfig',
+ name='last_mod_time',
+ ),
+ migrations.RemoveField(
+ model_name='oauthuser',
+ name='created_time',
+ ),
+ migrations.RemoveField(
+ model_name='oauthuser',
+ name='last_mod_time',
+ ),
+ migrations.AddField(
+ model_name='oauthconfig',
+ name='creation_time',
+ field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='creation time'),
+ ),
+ migrations.AddField(
+ model_name='oauthconfig',
+ name='last_modify_time',
+ field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='last modify time'),
+ ),
+ migrations.AddField(
+ model_name='oauthuser',
+ name='creation_time',
+ field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='creation time'),
+ ),
+ migrations.AddField(
+ model_name='oauthuser',
+ name='last_modify_time',
+ field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='last modify time'),
+ ),
+ migrations.AlterField(
+ model_name='oauthconfig',
+ name='callback_url',
+ field=models.CharField(default='', max_length=200, verbose_name='callback url'),
+ ),
+ migrations.AlterField(
+ model_name='oauthconfig',
+ name='is_enable',
+ field=models.BooleanField(default=True, verbose_name='is enable'),
+ ),
+ migrations.AlterField(
+ model_name='oauthconfig',
+ name='type',
+ field=models.CharField(choices=[('weibo', 'weibo'), ('google', 'google'), ('github', 'GitHub'), ('facebook', 'FaceBook'), ('qq', 'QQ')], default='a', max_length=10, verbose_name='type'),
+ ),
+ migrations.AlterField(
+ model_name='oauthuser',
+ name='author',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='author'),
+ ),
+ migrations.AlterField(
+ model_name='oauthuser',
+ name='nickname',
+ field=models.CharField(max_length=50, verbose_name='nickname'),
+ ),
+ ]
diff --git a/src/oauth/migrations/0003_alter_oauthuser_nickname.py b/src/oauth/migrations/0003_alter_oauthuser_nickname.py
new file mode 100644
index 0000000..6af08eb
--- /dev/null
+++ b/src/oauth/migrations/0003_alter_oauthuser_nickname.py
@@ -0,0 +1,18 @@
+# Generated by Django 4.2.7 on 2024-01-26 02:41
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('oauth', '0002_alter_oauthconfig_options_alter_oauthuser_options_and_more'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='oauthuser',
+ name='nickname',
+ field=models.CharField(max_length=50, verbose_name='nick name'),
+ ),
+ ]
diff --git a/src/oauth/migrations/__init__.py b/src/oauth/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/src/oauth/models.py b/src/oauth/models.py
new file mode 100644
index 0000000..be838ed
--- /dev/null
+++ b/src/oauth/models.py
@@ -0,0 +1,67 @@
+# Create your models here.
+from django.conf import settings
+from django.core.exceptions import ValidationError
+from django.db import models
+from django.utils.timezone import now
+from django.utils.translation import gettext_lazy as _
+
+
+class OAuthUser(models.Model):
+ author = models.ForeignKey(
+ settings.AUTH_USER_MODEL,
+ verbose_name=_('author'),
+ blank=True,
+ null=True,
+ on_delete=models.CASCADE)
+ openid = models.CharField(max_length=50)
+ nickname = models.CharField(max_length=50, verbose_name=_('nick name'))
+ token = models.CharField(max_length=150, null=True, blank=True)
+ picture = models.CharField(max_length=350, blank=True, null=True)
+ type = models.CharField(blank=False, null=False, max_length=50)
+ email = models.CharField(max_length=50, null=True, blank=True)
+ metadata = models.TextField(null=True, blank=True)
+ creation_time = models.DateTimeField(_('creation time'), default=now)
+ last_modify_time = models.DateTimeField(_('last modify time'), default=now)
+
+ def __str__(self):
+ return self.nickname
+
+ class Meta:
+ verbose_name = _('oauth user')
+ verbose_name_plural = verbose_name
+ ordering = ['-creation_time']
+
+
+class OAuthConfig(models.Model):
+ TYPE = (
+ ('weibo', _('weibo')),
+ ('google', _('google')),
+ ('github', 'GitHub'),
+ ('facebook', 'FaceBook'),
+ ('qq', 'QQ'),
+ )
+ type = models.CharField(_('type'), max_length=10, choices=TYPE, default='a')
+ appkey = models.CharField(max_length=200, verbose_name='AppKey')
+ appsecret = models.CharField(max_length=200, verbose_name='AppSecret')
+ callback_url = models.CharField(
+ max_length=200,
+ verbose_name=_('callback url'),
+ blank=False,
+ default='')
+ is_enable = models.BooleanField(
+ _('is enable'), default=True, blank=False, null=False)
+ creation_time = models.DateTimeField(_('creation time'), default=now)
+ last_modify_time = models.DateTimeField(_('last modify time'), default=now)
+
+ def clean(self):
+ if OAuthConfig.objects.filter(
+ type=self.type).exclude(id=self.id).count():
+ raise ValidationError(_(self.type + _('already exists')))
+
+ def __str__(self):
+ return self.type
+
+ class Meta:
+ verbose_name = 'oauth配置'
+ verbose_name_plural = verbose_name
+ ordering = ['-creation_time']
diff --git a/src/oauth/oauthmanager.py b/src/oauth/oauthmanager.py
new file mode 100644
index 0000000..2e7ceef
--- /dev/null
+++ b/src/oauth/oauthmanager.py
@@ -0,0 +1,504 @@
+import json
+import logging
+import os
+import urllib.parse
+from abc import ABCMeta, abstractmethod
+
+import requests
+
+from djangoblog.utils import cache_decorator
+from oauth.models import OAuthUser, OAuthConfig
+
+logger = logging.getLogger(__name__)
+
+
+class OAuthAccessTokenException(Exception):
+ '''
+ oauth授权失败异常
+ '''
+
+
+class BaseOauthManager(metaclass=ABCMeta):
+ """获取用户授权"""
+ AUTH_URL = None
+ """获取token"""
+ TOKEN_URL = None
+ """获取用户信息"""
+ API_URL = None
+ '''icon图标名'''
+ ICON_NAME = None
+
+ def __init__(self, access_token=None, openid=None):
+ self.access_token = access_token
+ self.openid = openid
+
+ @property
+ def is_access_token_set(self):
+ return self.access_token is not None
+
+ @property
+ def is_authorized(self):
+ return self.is_access_token_set and self.access_token is not None and self.openid is not None
+
+ @abstractmethod
+ def get_authorization_url(self, nexturl='/'):
+ pass
+
+ @abstractmethod
+ def get_access_token_by_code(self, code):
+ pass
+
+ @abstractmethod
+ def get_oauth_userinfo(self):
+ pass
+
+ @abstractmethod
+ def get_picture(self, metadata):
+ pass
+
+ def do_get(self, url, params, headers=None):
+ rsp = requests.get(url=url, params=params, headers=headers)
+ logger.info(rsp.text)
+ return rsp.text
+
+ def do_post(self, url, params, headers=None):
+ rsp = requests.post(url, params, headers=headers)
+ logger.info(rsp.text)
+ return rsp.text
+
+ def get_config(self):
+ value = OAuthConfig.objects.filter(type=self.ICON_NAME)
+ return value[0] if value else None
+
+
+class WBOauthManager(BaseOauthManager):
+ AUTH_URL = 'https://api.weibo.com/oauth2/authorize'
+ TOKEN_URL = 'https://api.weibo.com/oauth2/access_token'
+ API_URL = 'https://api.weibo.com/2/users/show.json'
+ ICON_NAME = 'weibo'
+
+ def __init__(self, access_token=None, openid=None):
+ config = self.get_config()
+ self.client_id = config.appkey if config else ''
+ self.client_secret = config.appsecret if config else ''
+ self.callback_url = config.callback_url if config else ''
+ super(
+ WBOauthManager,
+ self).__init__(
+ access_token=access_token,
+ openid=openid)
+
+ def get_authorization_url(self, nexturl='/'):
+ params = {
+ 'client_id': self.client_id,
+ 'response_type': 'code',
+ 'redirect_uri': self.callback_url + '&next_url=' + nexturl
+ }
+ url = self.AUTH_URL + "?" + urllib.parse.urlencode(params)
+ return url
+
+ def get_access_token_by_code(self, code):
+
+ params = {
+ 'client_id': self.client_id,
+ 'client_secret': self.client_secret,
+ 'grant_type': 'authorization_code',
+ 'code': code,
+ 'redirect_uri': self.callback_url
+ }
+ rsp = self.do_post(self.TOKEN_URL, params)
+
+ obj = json.loads(rsp)
+ if 'access_token' in obj:
+ self.access_token = str(obj['access_token'])
+ self.openid = str(obj['uid'])
+ return self.get_oauth_userinfo()
+ else:
+ raise OAuthAccessTokenException(rsp)
+
+ def get_oauth_userinfo(self):
+ if not self.is_authorized:
+ return None
+ params = {
+ 'uid': self.openid,
+ 'access_token': self.access_token
+ }
+ rsp = self.do_get(self.API_URL, params)
+ try:
+ datas = json.loads(rsp)
+ user = OAuthUser()
+ user.metadata = rsp
+ user.picture = datas['avatar_large']
+ user.nickname = datas['screen_name']
+ user.openid = datas['id']
+ user.type = 'weibo'
+ user.token = self.access_token
+ if 'email' in datas and datas['email']:
+ user.email = datas['email']
+ return user
+ except Exception as e:
+ logger.error(e)
+ logger.error('weibo oauth error.rsp:' + rsp)
+ return None
+
+ def get_picture(self, metadata):
+ datas = json.loads(metadata)
+ return datas['avatar_large']
+
+
+class ProxyManagerMixin:
+ def __init__(self, *args, **kwargs):
+ if os.environ.get("HTTP_PROXY"):
+ self.proxies = {
+ "http": os.environ.get("HTTP_PROXY"),
+ "https": os.environ.get("HTTP_PROXY")
+ }
+ else:
+ self.proxies = None
+
+ def do_get(self, url, params, headers=None):
+ rsp = requests.get(url=url, params=params, headers=headers, proxies=self.proxies)
+ logger.info(rsp.text)
+ return rsp.text
+
+ def do_post(self, url, params, headers=None):
+ rsp = requests.post(url, params, headers=headers, proxies=self.proxies)
+ logger.info(rsp.text)
+ return rsp.text
+
+
+class GoogleOauthManager(ProxyManagerMixin, BaseOauthManager):
+ AUTH_URL = 'https://accounts.google.com/o/oauth2/v2/auth'
+ TOKEN_URL = 'https://www.googleapis.com/oauth2/v4/token'
+ API_URL = 'https://www.googleapis.com/oauth2/v3/userinfo'
+ ICON_NAME = 'google'
+
+ def __init__(self, access_token=None, openid=None):
+ config = self.get_config()
+ self.client_id = config.appkey if config else ''
+ self.client_secret = config.appsecret if config else ''
+ self.callback_url = config.callback_url if config else ''
+ super(
+ GoogleOauthManager,
+ self).__init__(
+ access_token=access_token,
+ openid=openid)
+
+ def get_authorization_url(self, nexturl='/'):
+ params = {
+ 'client_id': self.client_id,
+ 'response_type': 'code',
+ 'redirect_uri': self.callback_url,
+ 'scope': 'openid email',
+ }
+ url = self.AUTH_URL + "?" + urllib.parse.urlencode(params)
+ return url
+
+ def get_access_token_by_code(self, code):
+ params = {
+ 'client_id': self.client_id,
+ 'client_secret': self.client_secret,
+ 'grant_type': 'authorization_code',
+ 'code': code,
+
+ 'redirect_uri': self.callback_url
+ }
+ rsp = self.do_post(self.TOKEN_URL, params)
+
+ obj = json.loads(rsp)
+
+ if 'access_token' in obj:
+ self.access_token = str(obj['access_token'])
+ self.openid = str(obj['id_token'])
+ logger.info(self.ICON_NAME + ' oauth ' + rsp)
+ return self.access_token
+ else:
+ raise OAuthAccessTokenException(rsp)
+
+ def get_oauth_userinfo(self):
+ if not self.is_authorized:
+ return None
+ params = {
+ 'access_token': self.access_token
+ }
+ rsp = self.do_get(self.API_URL, params)
+ try:
+
+ datas = json.loads(rsp)
+ user = OAuthUser()
+ user.metadata = rsp
+ user.picture = datas['picture']
+ user.nickname = datas['name']
+ user.openid = datas['sub']
+ user.token = self.access_token
+ user.type = 'google'
+ if datas['email']:
+ user.email = datas['email']
+ return user
+ except Exception as e:
+ logger.error(e)
+ logger.error('google oauth error.rsp:' + rsp)
+ return None
+
+ def get_picture(self, metadata):
+ datas = json.loads(metadata)
+ return datas['picture']
+
+
+class GitHubOauthManager(ProxyManagerMixin, BaseOauthManager):
+ AUTH_URL = 'https://github.com/login/oauth/authorize'
+ TOKEN_URL = 'https://github.com/login/oauth/access_token'
+ API_URL = 'https://api.github.com/user'
+ ICON_NAME = 'github'
+
+ def __init__(self, access_token=None, openid=None):
+ config = self.get_config()
+ self.client_id = config.appkey if config else ''
+ self.client_secret = config.appsecret if config else ''
+ self.callback_url = config.callback_url if config else ''
+ super(
+ GitHubOauthManager,
+ self).__init__(
+ access_token=access_token,
+ openid=openid)
+
+ def get_authorization_url(self, next_url='/'):
+ params = {
+ 'client_id': self.client_id,
+ 'response_type': 'code',
+ 'redirect_uri': f'{self.callback_url}&next_url={next_url}',
+ 'scope': 'user'
+ }
+ url = self.AUTH_URL + "?" + urllib.parse.urlencode(params)
+ return url
+
+ def get_access_token_by_code(self, code):
+ params = {
+ 'client_id': self.client_id,
+ 'client_secret': self.client_secret,
+ 'grant_type': 'authorization_code',
+ 'code': code,
+
+ 'redirect_uri': self.callback_url
+ }
+ rsp = self.do_post(self.TOKEN_URL, params)
+
+ from urllib import parse
+ r = parse.parse_qs(rsp)
+ if 'access_token' in r:
+ self.access_token = (r['access_token'][0])
+ return self.access_token
+ else:
+ raise OAuthAccessTokenException(rsp)
+
+ def get_oauth_userinfo(self):
+
+ rsp = self.do_get(self.API_URL, params={}, headers={
+ "Authorization": "token " + self.access_token
+ })
+ try:
+ datas = json.loads(rsp)
+ user = OAuthUser()
+ user.picture = datas['avatar_url']
+ user.nickname = datas['name']
+ user.openid = datas['id']
+ user.type = 'github'
+ user.token = self.access_token
+ user.metadata = rsp
+ if 'email' in datas and datas['email']:
+ user.email = datas['email']
+ return user
+ except Exception as e:
+ logger.error(e)
+ logger.error('github oauth error.rsp:' + rsp)
+ return None
+
+ def get_picture(self, metadata):
+ datas = json.loads(metadata)
+ return datas['avatar_url']
+
+
+class FaceBookOauthManager(ProxyManagerMixin, BaseOauthManager):
+ AUTH_URL = 'https://www.facebook.com/v16.0/dialog/oauth'
+ TOKEN_URL = 'https://graph.facebook.com/v16.0/oauth/access_token'
+ API_URL = 'https://graph.facebook.com/me'
+ ICON_NAME = 'facebook'
+
+ def __init__(self, access_token=None, openid=None):
+ config = self.get_config()
+ self.client_id = config.appkey if config else ''
+ self.client_secret = config.appsecret if config else ''
+ self.callback_url = config.callback_url if config else ''
+ super(
+ FaceBookOauthManager,
+ self).__init__(
+ access_token=access_token,
+ openid=openid)
+
+ def get_authorization_url(self, next_url='/'):
+ params = {
+ 'client_id': self.client_id,
+ 'response_type': 'code',
+ 'redirect_uri': self.callback_url,
+ 'scope': 'email,public_profile'
+ }
+ url = self.AUTH_URL + "?" + urllib.parse.urlencode(params)
+ return url
+
+ def get_access_token_by_code(self, code):
+ params = {
+ 'client_id': self.client_id,
+ 'client_secret': self.client_secret,
+ # 'grant_type': 'authorization_code',
+ 'code': code,
+
+ 'redirect_uri': self.callback_url
+ }
+ rsp = self.do_post(self.TOKEN_URL, params)
+
+ obj = json.loads(rsp)
+ if 'access_token' in obj:
+ token = str(obj['access_token'])
+ self.access_token = token
+ return self.access_token
+ else:
+ raise OAuthAccessTokenException(rsp)
+
+ def get_oauth_userinfo(self):
+ params = {
+ 'access_token': self.access_token,
+ 'fields': 'id,name,picture,email'
+ }
+ try:
+ rsp = self.do_get(self.API_URL, params)
+ datas = json.loads(rsp)
+ user = OAuthUser()
+ user.nickname = datas['name']
+ user.openid = datas['id']
+ user.type = 'facebook'
+ user.token = self.access_token
+ user.metadata = rsp
+ if 'email' in datas and datas['email']:
+ user.email = datas['email']
+ if 'picture' in datas and datas['picture'] and datas['picture']['data'] and datas['picture']['data']['url']:
+ user.picture = str(datas['picture']['data']['url'])
+ return user
+ except Exception as e:
+ logger.error(e)
+ return None
+
+ def get_picture(self, metadata):
+ datas = json.loads(metadata)
+ return str(datas['picture']['data']['url'])
+
+
+class QQOauthManager(BaseOauthManager):
+ AUTH_URL = 'https://graph.qq.com/oauth2.0/authorize'
+ TOKEN_URL = 'https://graph.qq.com/oauth2.0/token'
+ API_URL = 'https://graph.qq.com/user/get_user_info'
+ OPEN_ID_URL = 'https://graph.qq.com/oauth2.0/me'
+ ICON_NAME = 'qq'
+
+ def __init__(self, access_token=None, openid=None):
+ config = self.get_config()
+ self.client_id = config.appkey if config else ''
+ self.client_secret = config.appsecret if config else ''
+ self.callback_url = config.callback_url if config else ''
+ super(
+ QQOauthManager,
+ self).__init__(
+ access_token=access_token,
+ openid=openid)
+
+ def get_authorization_url(self, next_url='/'):
+ params = {
+ 'response_type': 'code',
+ 'client_id': self.client_id,
+ 'redirect_uri': self.callback_url + '&next_url=' + next_url,
+ }
+ url = self.AUTH_URL + "?" + urllib.parse.urlencode(params)
+ return url
+
+ def get_access_token_by_code(self, code):
+ params = {
+ 'grant_type': 'authorization_code',
+ 'client_id': self.client_id,
+ 'client_secret': self.client_secret,
+ 'code': code,
+ 'redirect_uri': self.callback_url
+ }
+ rsp = self.do_get(self.TOKEN_URL, params)
+ if rsp:
+ d = urllib.parse.parse_qs(rsp)
+ if 'access_token' in d:
+ token = d['access_token']
+ self.access_token = token[0]
+ return token
+ else:
+ raise OAuthAccessTokenException(rsp)
+
+ def get_open_id(self):
+ if self.is_access_token_set:
+ params = {
+ 'access_token': self.access_token
+ }
+ rsp = self.do_get(self.OPEN_ID_URL, params)
+ if rsp:
+ rsp = rsp.replace(
+ 'callback(', '').replace(
+ ')', '').replace(
+ ';', '')
+ obj = json.loads(rsp)
+ openid = str(obj['openid'])
+ self.openid = openid
+ return openid
+
+ def get_oauth_userinfo(self):
+ openid = self.get_open_id()
+ if openid:
+ params = {
+ 'access_token': self.access_token,
+ 'oauth_consumer_key': self.client_id,
+ 'openid': self.openid
+ }
+ rsp = self.do_get(self.API_URL, params)
+ logger.info(rsp)
+ obj = json.loads(rsp)
+ user = OAuthUser()
+ user.nickname = obj['nickname']
+ user.openid = openid
+ user.type = 'qq'
+ user.token = self.access_token
+ user.metadata = rsp
+ if 'email' in obj:
+ user.email = obj['email']
+ if 'figureurl' in obj:
+ user.picture = str(obj['figureurl'])
+ return user
+
+ def get_picture(self, metadata):
+ datas = json.loads(metadata)
+ return str(datas['figureurl'])
+
+
+@cache_decorator(expiration=100 * 60)
+def get_oauth_apps():
+ configs = OAuthConfig.objects.filter(is_enable=True).all()
+ if not configs:
+ return []
+ configtypes = [x.type for x in configs]
+ applications = BaseOauthManager.__subclasses__()
+ apps = [x() for x in applications if x().ICON_NAME.lower() in configtypes]
+ return apps
+
+
+def get_manager_by_type(type):
+ applications = get_oauth_apps()
+ if applications:
+ finds = list(
+ filter(
+ lambda x: x.ICON_NAME.lower() == type.lower(),
+ applications))
+ if finds:
+ return finds[0]
+ return None
diff --git a/src/oauth/templatetags/__init__.py b/src/oauth/templatetags/__init__.py
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/src/oauth/templatetags/__init__.py
@@ -0,0 +1 @@
+
diff --git a/src/oauth/templatetags/oauth_tags.py b/src/oauth/templatetags/oauth_tags.py
new file mode 100644
index 0000000..7b687d5
--- /dev/null
+++ b/src/oauth/templatetags/oauth_tags.py
@@ -0,0 +1,22 @@
+from django import template
+from django.urls import reverse
+
+from oauth.oauthmanager import get_oauth_apps
+
+register = template.Library()
+
+
+@register.inclusion_tag('oauth/oauth_applications.html')
+def load_oauth_applications(request):
+ applications = get_oauth_apps()
+ if applications:
+ baseurl = reverse('oauth:oauthlogin')
+ path = request.get_full_path()
+
+ apps = list(map(lambda x: (x.ICON_NAME, '{baseurl}?type={type}&next_url={next}'.format(
+ baseurl=baseurl, type=x.ICON_NAME, next=path)), applications))
+ else:
+ apps = []
+ return {
+ 'apps': apps
+ }
diff --git a/src/oauth/tests.py b/src/oauth/tests.py
new file mode 100644
index 0000000..bb23b9b
--- /dev/null
+++ b/src/oauth/tests.py
@@ -0,0 +1,249 @@
+import json
+from unittest.mock import patch
+
+from django.conf import settings
+from django.contrib import auth
+from django.test import Client, RequestFactory, TestCase
+from django.urls import reverse
+
+from djangoblog.utils import get_sha256
+from oauth.models import OAuthConfig
+from oauth.oauthmanager import BaseOauthManager
+
+
+# Create your tests here.
+class OAuthConfigTest(TestCase):
+ def setUp(self):
+ self.client = Client()
+ self.factory = RequestFactory()
+
+ def test_oauth_login_test(self):
+ c = OAuthConfig()
+ c.type = 'weibo'
+ c.appkey = 'appkey'
+ c.appsecret = 'appsecret'
+ c.save()
+
+ response = self.client.get('/oauth/oauthlogin?type=weibo')
+ self.assertEqual(response.status_code, 302)
+ self.assertTrue("api.weibo.com" in response.url)
+
+ response = self.client.get('/oauth/authorize?type=weibo&code=code')
+ self.assertEqual(response.status_code, 302)
+ self.assertEqual(response.url, '/')
+
+
+class OauthLoginTest(TestCase):
+ def setUp(self) -> None:
+ self.client = Client()
+ self.factory = RequestFactory()
+ self.apps = self.init_apps()
+
+ def init_apps(self):
+ applications = [p() for p in BaseOauthManager.__subclasses__()]
+ for application in applications:
+ c = OAuthConfig()
+ c.type = application.ICON_NAME.lower()
+ c.appkey = 'appkey'
+ c.appsecret = 'appsecret'
+ c.save()
+ return applications
+
+ def get_app_by_type(self, type):
+ for app in self.apps:
+ if app.ICON_NAME.lower() == type:
+ return app
+
+ @patch("oauth.oauthmanager.WBOauthManager.do_post")
+ @patch("oauth.oauthmanager.WBOauthManager.do_get")
+ def test_weibo_login(self, mock_do_get, mock_do_post):
+ weibo_app = self.get_app_by_type('weibo')
+ assert weibo_app
+ url = weibo_app.get_authorization_url()
+ mock_do_post.return_value = json.dumps({"access_token": "access_token",
+ "uid": "uid"
+ })
+ mock_do_get.return_value = json.dumps({
+ "avatar_large": "avatar_large",
+ "screen_name": "screen_name",
+ "id": "id",
+ "email": "email",
+ })
+ userinfo = weibo_app.get_access_token_by_code('code')
+ self.assertEqual(userinfo.token, 'access_token')
+ self.assertEqual(userinfo.openid, 'id')
+
+ @patch("oauth.oauthmanager.GoogleOauthManager.do_post")
+ @patch("oauth.oauthmanager.GoogleOauthManager.do_get")
+ def test_google_login(self, mock_do_get, mock_do_post):
+ google_app = self.get_app_by_type('google')
+ assert google_app
+ url = google_app.get_authorization_url()
+ mock_do_post.return_value = json.dumps({
+ "access_token": "access_token",
+ "id_token": "id_token",
+ })
+ mock_do_get.return_value = json.dumps({
+ "picture": "picture",
+ "name": "name",
+ "sub": "sub",
+ "email": "email",
+ })
+ token = google_app.get_access_token_by_code('code')
+ userinfo = google_app.get_oauth_userinfo()
+ self.assertEqual(userinfo.token, 'access_token')
+ self.assertEqual(userinfo.openid, 'sub')
+
+ @patch("oauth.oauthmanager.GitHubOauthManager.do_post")
+ @patch("oauth.oauthmanager.GitHubOauthManager.do_get")
+ def test_github_login(self, mock_do_get, mock_do_post):
+ github_app = self.get_app_by_type('github')
+ assert github_app
+ url = github_app.get_authorization_url()
+ self.assertTrue("github.com" in url)
+ self.assertTrue("client_id" in url)
+ mock_do_post.return_value = "access_token=gho_16C7e42F292c6912E7710c838347Ae178B4a&scope=repo%2Cgist&token_type=bearer"
+ mock_do_get.return_value = json.dumps({
+ "avatar_url": "avatar_url",
+ "name": "name",
+ "id": "id",
+ "email": "email",
+ })
+ token = github_app.get_access_token_by_code('code')
+ userinfo = github_app.get_oauth_userinfo()
+ self.assertEqual(userinfo.token, 'gho_16C7e42F292c6912E7710c838347Ae178B4a')
+ self.assertEqual(userinfo.openid, 'id')
+
+ @patch("oauth.oauthmanager.FaceBookOauthManager.do_post")
+ @patch("oauth.oauthmanager.FaceBookOauthManager.do_get")
+ def test_facebook_login(self, mock_do_get, mock_do_post):
+ facebook_app = self.get_app_by_type('facebook')
+ assert facebook_app
+ url = facebook_app.get_authorization_url()
+ self.assertTrue("facebook.com" in url)
+ mock_do_post.return_value = json.dumps({
+ "access_token": "access_token",
+ })
+ mock_do_get.return_value = json.dumps({
+ "name": "name",
+ "id": "id",
+ "email": "email",
+ "picture": {
+ "data": {
+ "url": "url"
+ }
+ }
+ })
+ token = facebook_app.get_access_token_by_code('code')
+ userinfo = facebook_app.get_oauth_userinfo()
+ self.assertEqual(userinfo.token, 'access_token')
+
+ @patch("oauth.oauthmanager.QQOauthManager.do_get", side_effect=[
+ 'access_token=access_token&expires_in=3600',
+ 'callback({"client_id":"appid","openid":"openid"} );',
+ json.dumps({
+ "nickname": "nickname",
+ "email": "email",
+ "figureurl": "figureurl",
+ "openid": "openid",
+ })
+ ])
+ def test_qq_login(self, mock_do_get):
+ qq_app = self.get_app_by_type('qq')
+ assert qq_app
+ url = qq_app.get_authorization_url()
+ self.assertTrue("qq.com" in url)
+ token = qq_app.get_access_token_by_code('code')
+ userinfo = qq_app.get_oauth_userinfo()
+ self.assertEqual(userinfo.token, 'access_token')
+
+ @patch("oauth.oauthmanager.WBOauthManager.do_post")
+ @patch("oauth.oauthmanager.WBOauthManager.do_get")
+ def test_weibo_authoriz_login_with_email(self, mock_do_get, mock_do_post):
+
+ mock_do_post.return_value = json.dumps({"access_token": "access_token",
+ "uid": "uid"
+ })
+ mock_user_info = {
+ "avatar_large": "avatar_large",
+ "screen_name": "screen_name1",
+ "id": "id",
+ "email": "email",
+ }
+ mock_do_get.return_value = json.dumps(mock_user_info)
+
+ response = self.client.get('/oauth/oauthlogin?type=weibo')
+ self.assertEqual(response.status_code, 302)
+ self.assertTrue("api.weibo.com" in response.url)
+
+ response = self.client.get('/oauth/authorize?type=weibo&code=code')
+ self.assertEqual(response.status_code, 302)
+ self.assertEqual(response.url, '/')
+
+ user = auth.get_user(self.client)
+ assert user.is_authenticated
+ self.assertTrue(user.is_authenticated)
+ self.assertEqual(user.username, mock_user_info['screen_name'])
+ self.assertEqual(user.email, mock_user_info['email'])
+ self.client.logout()
+
+ response = self.client.get('/oauth/authorize?type=weibo&code=code')
+ self.assertEqual(response.status_code, 302)
+ self.assertEqual(response.url, '/')
+
+ user = auth.get_user(self.client)
+ assert user.is_authenticated
+ self.assertTrue(user.is_authenticated)
+ self.assertEqual(user.username, mock_user_info['screen_name'])
+ self.assertEqual(user.email, mock_user_info['email'])
+
+ @patch("oauth.oauthmanager.WBOauthManager.do_post")
+ @patch("oauth.oauthmanager.WBOauthManager.do_get")
+ def test_weibo_authoriz_login_without_email(self, mock_do_get, mock_do_post):
+
+ mock_do_post.return_value = json.dumps({"access_token": "access_token",
+ "uid": "uid"
+ })
+ mock_user_info = {
+ "avatar_large": "avatar_large",
+ "screen_name": "screen_name1",
+ "id": "id",
+ }
+ mock_do_get.return_value = json.dumps(mock_user_info)
+
+ response = self.client.get('/oauth/oauthlogin?type=weibo')
+ self.assertEqual(response.status_code, 302)
+ self.assertTrue("api.weibo.com" in response.url)
+
+ response = self.client.get('/oauth/authorize?type=weibo&code=code')
+
+ self.assertEqual(response.status_code, 302)
+
+ oauth_user_id = int(response.url.split('/')[-1].split('.')[0])
+ self.assertEqual(response.url, f'/oauth/requireemail/{oauth_user_id}.html')
+
+ response = self.client.post(response.url, {'email': 'test@gmail.com', 'oauthid': oauth_user_id})
+
+ self.assertEqual(response.status_code, 302)
+ sign = get_sha256(settings.SECRET_KEY +
+ str(oauth_user_id) + settings.SECRET_KEY)
+
+ url = reverse('oauth:bindsuccess', kwargs={
+ 'oauthid': oauth_user_id,
+ })
+ self.assertEqual(response.url, f'{url}?type=email')
+
+ path = reverse('oauth:email_confirm', kwargs={
+ 'id': oauth_user_id,
+ 'sign': sign
+ })
+ response = self.client.get(path)
+ self.assertEqual(response.status_code, 302)
+ self.assertEqual(response.url, f'/oauth/bindsuccess/{oauth_user_id}.html?type=success')
+ user = auth.get_user(self.client)
+ from oauth.models import OAuthUser
+ oauth_user = OAuthUser.objects.get(author=user)
+ self.assertTrue(user.is_authenticated)
+ self.assertEqual(user.username, mock_user_info['screen_name'])
+ self.assertEqual(user.email, 'test@gmail.com')
+ self.assertEqual(oauth_user.pk, oauth_user_id)
diff --git a/src/oauth/urls.py b/src/oauth/urls.py
new file mode 100644
index 0000000..c4a12a0
--- /dev/null
+++ b/src/oauth/urls.py
@@ -0,0 +1,25 @@
+from django.urls import path
+
+from . import views
+
+app_name = "oauth"
+urlpatterns = [
+ path(
+ r'oauth/authorize',
+ views.authorize),
+ path(
+ r'oauth/requireemail/.html',
+ views.RequireEmailView.as_view(),
+ name='require_email'),
+ path(
+ r'oauth/emailconfirm//.html',
+ views.emailconfirm,
+ name='email_confirm'),
+ path(
+ r'oauth/bindsuccess/.html',
+ views.bindsuccess,
+ name='bindsuccess'),
+ path(
+ r'oauth/oauthlogin',
+ views.oauthlogin,
+ name='oauthlogin')]
diff --git a/src/oauth/views.py b/src/oauth/views.py
new file mode 100644
index 0000000..12e3a6e
--- /dev/null
+++ b/src/oauth/views.py
@@ -0,0 +1,253 @@
+import logging
+# Create your views here.
+from urllib.parse import urlparse
+
+from django.conf import settings
+from django.contrib.auth import get_user_model
+from django.contrib.auth import login
+from django.core.exceptions import ObjectDoesNotExist
+from django.db import transaction
+from django.http import HttpResponseForbidden
+from django.http import HttpResponseRedirect
+from django.shortcuts import get_object_or_404
+from django.shortcuts import render
+from django.urls import reverse
+from django.utils import timezone
+from django.utils.translation import gettext_lazy as _
+from django.views.generic import FormView
+
+from djangoblog.blog_signals import oauth_user_login_signal
+from djangoblog.utils import get_current_site
+from djangoblog.utils import send_email, get_sha256
+from oauth.forms import RequireEmailForm
+from .models import OAuthUser
+from .oauthmanager import get_manager_by_type, OAuthAccessTokenException
+
+logger = logging.getLogger(__name__)
+
+
+def get_redirecturl(request):
+ nexturl = request.GET.get('next_url', None)
+ if not nexturl or nexturl == '/login/' or nexturl == '/login':
+ nexturl = '/'
+ return nexturl
+ p = urlparse(nexturl)
+ if p.netloc:
+ site = get_current_site().domain
+ if not p.netloc.replace('www.', '') == site.replace('www.', ''):
+ logger.info('非法url:' + nexturl)
+ return "/"
+ return nexturl
+
+
+def oauthlogin(request):
+ type = request.GET.get('type', None)
+ if not type:
+ return HttpResponseRedirect('/')
+ manager = get_manager_by_type(type)
+ if not manager:
+ return HttpResponseRedirect('/')
+ nexturl = get_redirecturl(request)
+ authorizeurl = manager.get_authorization_url(nexturl)
+ return HttpResponseRedirect(authorizeurl)
+
+
+def authorize(request):
+ type = request.GET.get('type', None)
+ if not type:
+ return HttpResponseRedirect('/')
+ manager = get_manager_by_type(type)
+ if not manager:
+ return HttpResponseRedirect('/')
+ code = request.GET.get('code', None)
+ try:
+ rsp = manager.get_access_token_by_code(code)
+ except OAuthAccessTokenException as e:
+ logger.warning("OAuthAccessTokenException:" + str(e))
+ return HttpResponseRedirect('/')
+ except Exception as e:
+ logger.error(e)
+ rsp = None
+ nexturl = get_redirecturl(request)
+ if not rsp:
+ return HttpResponseRedirect(manager.get_authorization_url(nexturl))
+ user = manager.get_oauth_userinfo()
+ if user:
+ if not user.nickname or not user.nickname.strip():
+ user.nickname = "djangoblog" + timezone.now().strftime('%y%m%d%I%M%S')
+ try:
+ temp = OAuthUser.objects.get(type=type, openid=user.openid)
+ temp.picture = user.picture
+ temp.metadata = user.metadata
+ temp.nickname = user.nickname
+ user = temp
+ except ObjectDoesNotExist:
+ pass
+ # facebook的token过长
+ if type == 'facebook':
+ user.token = ''
+ if user.email:
+ with transaction.atomic():
+ author = None
+ try:
+ author = get_user_model().objects.get(id=user.author_id)
+ except ObjectDoesNotExist:
+ pass
+ if not author:
+ result = get_user_model().objects.get_or_create(email=user.email)
+ author = result[0]
+ if result[1]:
+ try:
+ get_user_model().objects.get(username=user.nickname)
+ except ObjectDoesNotExist:
+ author.username = user.nickname
+ else:
+ author.username = "djangoblog" + timezone.now().strftime('%y%m%d%I%M%S')
+ author.source = 'authorize'
+ author.save()
+
+ user.author = author
+ user.save()
+
+ oauth_user_login_signal.send(
+ sender=authorize.__class__, id=user.id)
+ login(request, author)
+ return HttpResponseRedirect(nexturl)
+ else:
+ user.save()
+ url = reverse('oauth:require_email', kwargs={
+ 'oauthid': user.id
+ })
+
+ return HttpResponseRedirect(url)
+ else:
+ return HttpResponseRedirect(nexturl)
+
+
+def emailconfirm(request, id, sign):
+ if not sign:
+ return HttpResponseForbidden()
+ if not get_sha256(settings.SECRET_KEY +
+ str(id) +
+ settings.SECRET_KEY).upper() == sign.upper():
+ return HttpResponseForbidden()
+ oauthuser = get_object_or_404(OAuthUser, pk=id)
+ with transaction.atomic():
+ if oauthuser.author:
+ author = get_user_model().objects.get(pk=oauthuser.author_id)
+ else:
+ result = get_user_model().objects.get_or_create(email=oauthuser.email)
+ author = result[0]
+ if result[1]:
+ author.source = 'emailconfirm'
+ author.username = oauthuser.nickname.strip() if oauthuser.nickname.strip(
+ ) else "djangoblog" + timezone.now().strftime('%y%m%d%I%M%S')
+ author.save()
+ oauthuser.author = author
+ oauthuser.save()
+ oauth_user_login_signal.send(
+ sender=emailconfirm.__class__,
+ id=oauthuser.id)
+ login(request, author)
+
+ site = 'http://' + get_current_site().domain
+ content = _('''
+
Congratulations, you have successfully bound your email address. You can use
+ %(oauthuser_type)s to directly log in to this website without a password.
+ You are welcome to continue to follow this site, the address is
+ %(site)s
+ Thank you again!
+
+ If the link above cannot be opened, please copy this link to your browser.
+ %(site)s
+ ''') % {'oauthuser_type': oauthuser.type, 'site': site}
+
+ send_email(emailto=[oauthuser.email, ], title=_('Congratulations on your successful binding!'), content=content)
+ url = reverse('oauth:bindsuccess', kwargs={
+ 'oauthid': id
+ })
+ url = url + '?type=success'
+ return HttpResponseRedirect(url)
+
+
+class RequireEmailView(FormView):
+ form_class = RequireEmailForm
+ template_name = 'oauth/require_email.html'
+
+ def get(self, request, *args, **kwargs):
+ oauthid = self.kwargs['oauthid']
+ oauthuser = get_object_or_404(OAuthUser, pk=oauthid)
+ if oauthuser.email:
+ pass
+ # return HttpResponseRedirect('/')
+
+ return super(RequireEmailView, self).get(request, *args, **kwargs)
+
+ def get_initial(self):
+ oauthid = self.kwargs['oauthid']
+ return {
+ 'email': '',
+ 'oauthid': oauthid
+ }
+
+ def get_context_data(self, **kwargs):
+ oauthid = self.kwargs['oauthid']
+ oauthuser = get_object_or_404(OAuthUser, pk=oauthid)
+ if oauthuser.picture:
+ kwargs['picture'] = oauthuser.picture
+ return super(RequireEmailView, self).get_context_data(**kwargs)
+
+ def form_valid(self, form):
+ email = form.cleaned_data['email']
+ oauthid = form.cleaned_data['oauthid']
+ oauthuser = get_object_or_404(OAuthUser, pk=oauthid)
+ oauthuser.email = email
+ oauthuser.save()
+ sign = get_sha256(settings.SECRET_KEY +
+ str(oauthuser.id) + settings.SECRET_KEY)
+ site = get_current_site().domain
+ if settings.DEBUG:
+ site = '127.0.0.1:8000'
+ path = reverse('oauth:email_confirm', kwargs={
+ 'id': oauthid,
+ 'sign': sign
+ })
+ url = "http://{site}{path}".format(site=site, path=path)
+
+ content = _("""
+
\ No newline at end of file
diff --git a/src/templates/comments/tags/comment_item_tree.html b/src/templates/comments/tags/comment_item_tree.html
new file mode 100644
index 0000000..a9decd1
--- /dev/null
+++ b/src/templates/comments/tags/comment_item_tree.html
@@ -0,0 +1,54 @@
+{% load blog_tags %}
+
+ {# {% query article_comments parent_comment=None as parent_comments %}#} + {% for comment_item in p_comments %} + + {% with 0 as depth %} + {% include "comments/tags/comment_item_tree.html" %} + {% endwith %} + {% endfor %} + +
++