├── .gitignore
├── .vscode
├── launch.json
└── settings.json
├── LICENSE
├── README.md
├── docker
├── Dockerfile
├── conf
│ ├── nginx
│ │ ├── myblog.conf
│ │ └── nginx.conf
│ ├── start.sh
│ └── uwsgi
│ │ └── uwsgi.ini
└── requirements.txt
├── era_blog
├── __init__.py
├── admin.py
├── apps.py
├── migrations
│ ├── 0001_initial.py
│ └── __init__.py
├── models.py
├── static
│ ├── codeBlock
│ │ ├── codeBlockFuction.js
│ │ ├── codeCopy.js
│ │ ├── codeLang.js
│ │ └── codeShrink.js
│ ├── css
│ │ ├── all.css
│ │ ├── animate.min.css
│ │ ├── aos.css
│ │ ├── gitment.css
│ │ ├── jqcloud.css
│ │ ├── lightgallery.min.css
│ │ ├── materialize.min.css
│ │ ├── matery.css
│ │ ├── monokai.css
│ │ ├── my-gitalk.css
│ │ ├── my.css
│ │ ├── prism-a11y-dark.css
│ │ ├── share.min.css
│ │ └── tocbot.css
│ ├── fonts
│ │ ├── iconfont.eot
│ │ ├── iconfont.svg
│ │ ├── iconfont.ttf
│ │ └── iconfont.woff
│ ├── image
│ │ ├── blog-1.png
│ │ ├── blog-2.png
│ │ ├── blog-3.png
│ │ ├── blog-4.png
│ │ ├── blog-5.png
│ │ └── blog-6.png
│ ├── js
│ │ ├── Valine.min.js
│ │ ├── aos.js
│ │ ├── clicklove.js
│ │ ├── echarts.min.js
│ │ ├── instantpage.js
│ │ ├── jqcloud-1.0.4.min.js
│ │ ├── jquery-2.2.0.min.js
│ │ ├── lightgallery-all.min.js
│ │ ├── masonry.pkgd.min.js
│ │ ├── materialize.min.js
│ │ ├── matery.js
│ │ ├── prism.js
│ │ ├── scrollProgress.min.js
│ │ ├── search.js
│ │ ├── social-share.min.js
│ │ └── tocbot.min.js
│ ├── medias
│ │ ├── comment_bg.png
│ │ └── icp.png
│ └── webfonts
│ │ ├── fa-brands-400.eot
│ │ ├── fa-brands-400.svg
│ │ ├── fa-brands-400.ttf
│ │ ├── fa-brands-400.woff
│ │ ├── fa-brands-400.woff2
│ │ ├── fa-regular-400.eot
│ │ ├── fa-regular-400.svg
│ │ ├── fa-regular-400.ttf
│ │ ├── fa-regular-400.woff
│ │ ├── fa-regular-400.woff2
│ │ ├── fa-solid-900.eot
│ │ ├── fa-solid-900.svg
│ │ ├── fa-solid-900.ttf
│ │ ├── fa-solid-900.woff
│ │ └── fa-solid-900.woff2
├── templates
│ ├── about.html
│ ├── archive.html
│ ├── article_category.html
│ ├── article_tag.html
│ ├── banner.html
│ ├── base.html
│ ├── category.html
│ ├── detail.html
│ ├── friends.html
│ ├── index.html
│ └── tag.html
├── templatetags
│ └── custom_tag.py
├── tests.py
├── urls.py
└── views.py
├── logs
└── erablog.log
├── manage.py
├── my_blog
├── __init__.py
├── asgi.py
├── settings.py
├── urls.py
└── wsgi.py
└── uploads
├── article
└── 2020
│ └── 06
│ ├── redis-1.jpg
│ ├── redis-2.jpg
│ ├── redis-3.jpg
│ ├── springboot-1.jpg
│ ├── springboot-2.jpg
│ ├── springboot-3.jpg
│ ├── springboot-4.jpg
│ ├── springboot-5.jpg
│ ├── springboot-6.jpg
│ └── springboot-7.jpg
└── editor
├── 10_20200616134632284905.png
├── 11_20200616134717228777.png
├── 12_20200616134816739711.png
├── 13_20200616135754965695.png
├── 14_20200616135858054073.png
├── 15_20200616135919544637.png
├── 16_20200616135953372215.png
├── 17_20200616141227921615.png
├── 1_20200615212409393721.png
├── 1_20200616114738209450.png
├── 2_20200615212444162345.png
├── 2_20200616114754184473.png
├── 3_20200615212458218775.png
├── 3_20200616115150788760.png
├── 4_20200615212526004507.png
├── 4_20200616115212770007.png
├── 5_20200615212622375867.png
├── 5_20200616115233644213.png
├── 6_20200616115251003814.png
├── 7_20200616115305401820.png
├── 8_20200616135051757889.png
└── 9_20200616134548163771.png
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | pip-wheel-metadata/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .nox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | *.py,cover
51 | .hypothesis/
52 | .pytest_cache/
53 |
54 | # Translations
55 | *.mo
56 | *.pot
57 |
58 | # Django stuff:
59 | local_settings.py
60 | db.sqlite3
61 | db.sqlite3-journal
62 |
63 | # Flask stuff:
64 | instance/
65 | .webassets-cache
66 |
67 | # Scrapy stuff:
68 | .scrapy
69 |
70 | # Sphinx documentation
71 | docs/_build/
72 |
73 | # PyBuilder
74 | target/
75 |
76 | # Jupyter Notebook
77 | .ipynb_checkpoints
78 |
79 | # IPython
80 | profile_default/
81 | ipython_config.py
82 |
83 | # pyenv
84 | .python-version
85 |
86 | # pipenv
87 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
88 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
89 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
90 | # install all needed dependencies.
91 | #Pipfile.lock
92 |
93 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow
94 | __pypackages__/
95 |
96 | # Celery stuff
97 | celerybeat-schedule
98 | celerybeat.pid
99 |
100 | # SageMath parsed files
101 | *.sage.py
102 |
103 | # Environments
104 | .env
105 | .venv
106 | env/
107 | venv/
108 | ENV/
109 | env.bak/
110 | venv.bak/
111 |
112 | # Spyder project settings
113 | .spyderproject
114 | .spyproject
115 |
116 | # Rope project settings
117 | .ropeproject
118 |
119 | # mkdocs documentation
120 | /site
121 |
122 | # mypy
123 | .mypy_cache/
124 | .dmypy.json
125 | dmypy.json
126 |
127 | # Pyre type checker
128 | .pyre/
129 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 |
8 | {
9 | "name": "Python: Django",
10 | "type": "python",
11 | "request": "launch",
12 | "program": "${workspaceFolder}/manage.py",
13 | "args": [
14 | "runserver"
15 | ],
16 | "django": true
17 | }
18 | ]
19 | }
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "python.defaultInterpreterPath": "/Users/apple/opt/anaconda3/envs/myblog/bin/python",
3 | //"python.defaultInterpreterPath": "F:\\python\\Anaconda3\\envs\\blog\\python.exe",
4 | "python.linting.pylintArgs": [
5 | "--load-plugins",
6 | "pylint_django"
7 | ],
8 | "python.linting.pylintEnabled": true,
9 | "python.linting.enabled": true
10 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # my_blog
2 | ## 我的个人博客
3 | - 在[Django-Hexo-Matery](https://github.com/sqlsec/Django-Hexo-Matery)项目的基础上开发
4 | - 基于python django框架的个人博客模版;
5 |
6 | # 项目地址
7 | - [my_blog](http://time.pings.fun)
8 |
9 | # 安装
10 | ## 安装运行环境
11 | pip install -r my_blog/docker/requirements.txt
12 | ## 正式环境部署
13 | - 通过docker方式部署;
14 | ```
15 | docker build -t pings/my_blog -f my_blog/docker/Dockerfile .
16 | docker run -p 80:80 -p 8088:8088 -v /root/uploads/myblog:/opt/project/product/my_blog/uploads --name my_blog pings/my_blog
17 | ```
18 |
19 | # 界面
20 | - github图片好像无法展示,这里展示链接;
21 | ## 首页
22 | 
23 | ## 分类
24 | 
25 | ## 文章
26 | 
27 | ## 分类(移动端)
28 | 
29 | ## 文章(移动端)
30 | 
31 | ## 搜索(移动端)
32 | 
33 |
34 | # 更新记录
35 | - 2020-06-17 项目开发完成
36 | - 2020-06-19 完善
37 | - 2020-06-20 静态资源改为cdn加速
--------------------------------------------------------------------------------
/docker/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM python:3.7.7
2 |
3 | #**维护者
4 | MAINTAINER Pings 275598139@qq.com
5 |
6 | #**环境变量
7 | ENV LANG en_US.UTF-8
8 | #**设置时区
9 | RUN ln -s -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
10 |
11 | WORKDIR /opt/project/product
12 | COPY requirements.txt .
13 | RUN pip install -r requirements.txt
14 |
15 | # nginx
16 | # 安装
17 | RUN apt-get update
18 | RUN apt -y install nginx
19 | # 配置
20 | WORKDIR /etc/nginx/conf.d
21 | COPY conf/nginx/myblog.conf myblog.conf
22 | # 替换nginx.conf
23 | COPY conf/nginx/nginx.conf /etc/nginx/nginx.conf
24 | RUN rm -f default.conf
25 |
26 | # uwsgi
27 | RUN pip3 install uwsgi
28 | WORKDIR /opt/project/product/script
29 | COPY conf/uwsgi/uwsgi.ini uwsgi.ini
30 |
31 | # 启动脚本
32 | COPY conf/start.sh /opt/project/product/start.sh
33 |
34 | # 添加项目
35 | WORKDIR /opt/project/product
36 | RUN apt -y install git
37 | RUN git clone https://github.com/pingszi/my_blog.git
38 |
39 | # 正式模式配置settings
40 | WORKDIR /opt/project/product/my_blog/my_blog
41 | RUN sed -i "s/^DEBUG = True/DEBUG = False/" settings.py
42 | # 提取静态文件
43 | RUN python3 /opt/project/product/my_blog/manage.py collectstatic
44 |
45 | # 启动
46 | WORKDIR /opt/project/product
47 | CMD bash start.sh
48 |
49 | # docker build -t pings/my_blog -f my_blog/docker/Dockerfile .
50 | # docker run -p 80:80 -p 8088:8088 -v /root/uploads/myblog:/opt/project/product/my_blog/uploads --name my_blog pings/my_blog
--------------------------------------------------------------------------------
/docker/conf/nginx/myblog.conf:
--------------------------------------------------------------------------------
1 | server {
2 | listen 80;
3 | server_name localhost;
4 |
5 | #charset koi8-r;
6 | access_log /var/log/nginx/my_blog.access.log main;
7 |
8 | location / {
9 | include uwsgi_params;
10 | uwsgi_connect_timeout 30;
11 | uwsgi_pass unix:///opt/project/product/script/uwsgi.sock;
12 | }
13 |
14 | location /static {
15 | alias /opt/project/product/my_blog/static;
16 | }
17 |
18 | location /media {
19 | alias /opt/project/product/my_blog/uploads;
20 | }
21 |
22 | #error_page 404 /404.html;
23 |
24 | # redirect server error pages to the static page /50x.html
25 | #
26 | error_page 500 502 503 504 /50x.html;
27 | location = /50x.html {
28 | root /usr/share/nginx/html;
29 | }
30 |
31 | # proxy the PHP scripts to Apache listening on 127.0.0.1:80
32 | #
33 | #location ~ \.php$ {
34 | # proxy_pass http://127.0.0.1;
35 | #}
36 |
37 | # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
38 | #
39 | #location ~ \.php$ {
40 | # root html;
41 | # fastcgi_pass 127.0.0.1:9000;
42 | # fastcgi_index index.php;
43 | # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
44 | # include fastcgi_params;
45 | #}
46 |
47 | # deny access to .htaccess files, if Apache's document root
48 | # concurs with nginx's one
49 | #
50 | #location ~ /\.ht {
51 | # deny all;
52 | #}
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/docker/conf/nginx/nginx.conf:
--------------------------------------------------------------------------------
1 | user root;
2 | worker_processes 2;
3 |
4 | error_log /var/log/nginx/error.log warn;
5 | pid /var/run/nginx.pid;
6 | worker_rlimit_nofile 30000;
7 |
8 | events {
9 | worker_connections 2048;
10 | }
11 |
12 |
13 | http {
14 | include /etc/nginx/mime.types;
15 | default_type application/octet-stream;
16 |
17 | log_format main '$remote_addr - $remote_user [$time_local] "$request" '
18 | '$status $body_bytes_sent "$http_referer" '
19 | '"$http_user_agent" "$http_x_forwarded_for"';
20 |
21 | access_log /var/log/nginx/access.log main;
22 |
23 | sendfile on;
24 | #tcp_nopush on;
25 |
26 | keepalive_timeout 65;
27 |
28 | #gzip on;
29 |
30 | limit_req_zone $binary_remote_addr zone=promote_req_limit:50m rate=120r/m;
31 |
32 | include /etc/nginx/conf.d/*.conf;
33 | }
34 |
--------------------------------------------------------------------------------
/docker/conf/start.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | nginx
3 | uwsgi --ini /opt/project/product/script/uwsgi.ini
4 | tail -f /var/log/nginx/error.log
--------------------------------------------------------------------------------
/docker/conf/uwsgi/uwsgi.ini:
--------------------------------------------------------------------------------
1 | # uwsig使用配置文件启动
2 | [uwsgi]
3 | # 项目目录
4 | chdir=/opt/project/product/my_blog/
5 | # 指定项目的application
6 | module=my_blog.wsgi:application
7 | # 指定sock的文件路径
8 | socket=/opt/project/product/script/uwsgi.sock
9 | # 进程个数
10 | workers=5
11 | pidfile=/opt/project/product/script/uwsgi.pid
12 | # 指定IP端口
13 | http=0.0.0.0:8088
14 | # 指定静态文件
15 | static-map=/static=/opt/project/product/my_blog/static
16 | # 启用主进程
17 | master=true
18 | # 自动移除unix Socket和pid文件当服务停止的时候
19 | vacuum=true
20 | # 序列化接受的内容,如果可能的话
21 | thunder-lock=true
22 | # 启用线程
23 | enable-threads=true
24 | # 设置自中断时间
25 | harakiri=30
26 | # 设置缓冲
27 | post-buffering=4096
28 | # 设置日志目录
29 | daemonize=/opt/project/product/script/uwsgi.log
30 | # 权限
31 | chmod-socket=666
32 |
--------------------------------------------------------------------------------
/docker/requirements.txt:
--------------------------------------------------------------------------------
1 | asgiref==3.2.7
2 | astroid==2.4.2
3 | certifi==2020.4.5.1
4 | colorama==0.4.3
5 | defusedxml==0.6.0
6 | diff-match-patch==20181111
7 | Django==2.2.27
8 | django-import-export==2.2.0
9 | django-mdeditor==0.1.18
10 | django-pure-pagination==0.3.0
11 | django-simpleui==4.0.2
12 | et-xmlfile==1.0.1
13 | isort==4.3.21
14 | jdcal==1.4.1
15 | lazy-object-proxy==1.4.3
16 | MarkupPy==1.14
17 | mccabe==0.6.1
18 | mistune==0.8.4
19 | PyMySQL==1.0.2
20 | odfpy==1.4.1
21 | openpyxl==3.0.3
22 | Pillow==9.0.0
23 | pylint==2.5.3
24 | pytz==2020.1
25 | PyYAML==5.4
26 | six==1.15.0
27 | sqlparse==0.3.1
28 | tablib==2.0.0
29 | toml==0.10.1
30 | typed-ast==1.4.1
31 | wincertstore==0.2
32 | wrapt==1.12.1
33 | xlrd==1.2.0
34 | xlwt==1.3.0
35 |
--------------------------------------------------------------------------------
/era_blog/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/era_blog/__init__.py
--------------------------------------------------------------------------------
/era_blog/admin.py:
--------------------------------------------------------------------------------
1 | from django.contrib import admin
2 | from django.forms import TextInput, Textarea
3 | from django.db import models
4 |
5 | from .models import Links, Article, Category, Tag
6 |
7 |
8 | admin.site.site_header="Pings博客后台"
9 | admin.site.site_title="Pings博客"
10 | admin.site.index_title="Pings博客"
11 |
12 |
13 | # 文章
14 | @admin.register(Article)
15 | class ArticleAdmin(admin.ModelAdmin):
16 | list_display = ('id', 'title', 'category', 'cover_data', 'is_recommend', 'add_time', 'update_time')
17 | search_fields = ('title', 'desc', 'content')
18 | list_filter = ('category', 'tag', 'add_time')
19 | list_editable = ('category', 'is_recommend')
20 | list_per_page = 20
21 |
22 | fieldsets = (
23 | ('编辑文章', {
24 | 'fields': ('title', 'content')
25 | }),
26 | ('其他设置', {
27 | 'classes': ('collapse', ),
28 | 'fields': ('cover', 'desc', 'is_recommend', 'click_count', 'tag', 'category', 'add_time'),
29 | }),
30 | )
31 |
32 | formfield_overrides = {
33 | models.CharField: {'widget': TextInput(attrs={'size': '59'})},
34 | models.TextField: {'widget': Textarea(attrs={'rows': 4, 'cols': 59})},
35 | }
36 |
37 |
38 | # 分类
39 | @admin.register(Category)
40 | class CategoryAdmin(admin.ModelAdmin):
41 | list_display = ('id', 'name', 'index', 'active', 'get_items', 'icon', 'icon_data')
42 | search_fields = ('name', )
43 | list_editable = ('active', 'index', 'icon')
44 |
45 |
46 | # 标签
47 | @admin.register(Tag)
48 | class TagAdmin(admin.ModelAdmin):
49 | list_display = ('id', 'name', 'get_items')
50 | search_fields = ('name', )
51 | list_per_page = 20
52 |
53 |
54 | # 友链
55 | @admin.register(Links)
56 | class LinksAdmin(admin.ModelAdmin):
57 | list_display = ('id', 'title', 'url', 'avatar_data', 'desc')
58 | search_fields = ('title', 'url', 'desc')
59 | readonly_fields = ('avatar_admin', )
60 | list_editable = ('url',)
61 |
62 | fieldsets = (
63 | (None, {
64 | 'fields': ('title', 'url', 'desc', 'avatar_admin', 'image', )
65 | }),
66 | )
67 |
68 | formfield_overrides = {
69 | models.CharField: {'widget': TextInput(attrs={'size': '59'})},
70 | models.TextField: {'widget': Textarea(attrs={'rows': 4, 'cols': 59})},
71 | }
72 |
73 |
--------------------------------------------------------------------------------
/era_blog/apps.py:
--------------------------------------------------------------------------------
1 | import logging
2 |
3 | from django.apps import AppConfig
4 |
5 |
6 | class EraBlogConfig(AppConfig):
7 | name = 'era_blog'
8 |
9 | # **app名称
10 | verbose_name = "Pings博客后台"
11 |
12 | logger = logging.getLogger("erablog")
13 |
--------------------------------------------------------------------------------
/era_blog/migrations/0001_initial.py:
--------------------------------------------------------------------------------
1 | # Generated by Django 3.0.7 on 2020-06-13 08:50
2 |
3 | import datetime
4 | from django.db import migrations, models
5 | import django.db.models.deletion
6 | import mdeditor.fields
7 |
8 |
9 | class Migration(migrations.Migration):
10 |
11 | initial = True
12 |
13 | dependencies = [
14 | ]
15 |
16 | operations = [
17 | migrations.CreateModel(
18 | name='Category',
19 | fields=[
20 | ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='编号')),
21 | ('name', models.CharField(max_length=30, verbose_name='分类名称')),
22 | ('index', models.IntegerField(default=99, verbose_name='分类排序')),
23 | ('active', models.BooleanField(default=True, verbose_name='是否添加到菜单')),
24 | ('icon', models.CharField(default='fa fa-home', max_length=30, verbose_name='菜单图标')),
25 | ],
26 | options={
27 | 'verbose_name': '文章分类',
28 | 'verbose_name_plural': '文章分类',
29 | 'db_table': 'blog_category',
30 | },
31 | ),
32 | migrations.CreateModel(
33 | name='Links',
34 | fields=[
35 | ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='编号')),
36 | ('title', models.CharField(max_length=50, verbose_name='标题')),
37 | ('url', models.URLField(verbose_name='地址')),
38 | ('desc', models.TextField(max_length=250, verbose_name='描述')),
39 | ('image', models.URLField(default='https://image.3001.net/images/20190330/1553875722169.jpg', verbose_name='头像')),
40 | ],
41 | options={
42 | 'verbose_name': '友链',
43 | 'verbose_name_plural': '友链',
44 | 'db_table': 'blog_links',
45 | },
46 | ),
47 | migrations.CreateModel(
48 | name='Tag',
49 | fields=[
50 | ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='编号')),
51 | ('name', models.CharField(max_length=30, verbose_name='标签名称')),
52 | ],
53 | options={
54 | 'verbose_name': '文章标签',
55 | 'verbose_name_plural': '文章标签',
56 | 'db_table': 'blog_tag',
57 | },
58 | ),
59 | migrations.CreateModel(
60 | name='Article',
61 | fields=[
62 | ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='编号')),
63 | ('title', models.CharField(max_length=50, verbose_name='文章标题')),
64 | ('desc', models.TextField(max_length=100, verbose_name='文章描述')),
65 | ('cover', models.CharField(default='https://image.3001.net/images/20200304/15832956271308.jpg', max_length=200, verbose_name='文章封面')),
66 | ('content', mdeditor.fields.MDTextField(verbose_name='文章内容')),
67 | ('click_count', models.IntegerField(default=0, verbose_name='点击次数')),
68 | ('is_recommend', models.BooleanField(default=False, verbose_name='是否推荐')),
69 | ('add_time', models.DateTimeField(default=datetime.datetime.now, verbose_name='发布时间')),
70 | ('update_time', models.DateTimeField(auto_now=True, verbose_name='更新时间')),
71 | ('category', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='articles', to='era_blog.Category', verbose_name='文章分类')),
72 | ('tag', models.ManyToManyField(related_name='articles', to='era_blog.Tag', verbose_name='文章标签')),
73 | ],
74 | options={
75 | 'verbose_name': '文章',
76 | 'verbose_name_plural': '文章',
77 | 'db_table': 'blog_article',
78 | },
79 | ),
80 | ]
81 |
--------------------------------------------------------------------------------
/era_blog/migrations/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/era_blog/migrations/__init__.py
--------------------------------------------------------------------------------
/era_blog/models.py:
--------------------------------------------------------------------------------
1 | from datetime import datetime
2 | from django.db import models
3 | from django.utils.html import format_html
4 | from mdeditor.fields import MDTextField
5 |
6 |
7 | class Tag(models.Model):
8 | """
9 | 文章标签
10 | """
11 |
12 | class Meta:
13 | # **表名
14 | db_table = "blog_tag"
15 | # **菜单名
16 | verbose_name = "文章标签"
17 | verbose_name_plural = "文章标签"
18 |
19 | def __str__(self):
20 | return str(self.name)
21 |
22 | id = models.AutoField(primary_key=True, verbose_name="编号")
23 | name = models.CharField(max_length=30, verbose_name='标签名称')
24 |
25 | # 统计文章数 并放入后台
26 | def get_items(self):
27 | return self.article_set.all().count()
28 | get_items.short_description = '文章数'
29 |
30 |
31 | class Category(models.Model):
32 | """
33 | 文章分类
34 | """
35 |
36 | class Meta:
37 | # **表名
38 | db_table = "blog_category"
39 | # **菜单名
40 | verbose_name = "文章分类"
41 | verbose_name_plural = "文章分类"
42 |
43 | def __str__(self):
44 | return self.name
45 |
46 | id = models.AutoField(primary_key=True, verbose_name="编号")
47 | name = models.CharField(max_length=30, verbose_name='分类名称')
48 | index = models.IntegerField(default=99, verbose_name='分类排序')
49 | active = models.BooleanField(default=True, verbose_name='是否添加到菜单')
50 | icon = models.CharField(max_length=30, default='fa fa-home', verbose_name='菜单图标')
51 |
52 | # 统计文章数 并放入后台
53 | def get_items(self):
54 | return self.article_set.all().count()
55 | get_items.short_description = '文章数'
56 |
57 | def icon_data(self):
58 | return format_html(
59 | '',
60 | self.icon,
61 | )
62 | icon_data.short_description = '图标预览'
63 |
64 |
65 | class Article(models.Model):
66 | """
67 | 文章
68 | """
69 |
70 | class Meta:
71 | # **表名
72 | db_table = "blog_article"
73 | # **菜单名
74 | verbose_name = '文章'
75 | verbose_name_plural = '文章'
76 |
77 | def __str__(self):
78 | return self.title
79 |
80 | id = models.AutoField(primary_key=True, verbose_name="编号")
81 | title = models.CharField(max_length=50, verbose_name='文章标题')
82 | desc = models.TextField(max_length=100, verbose_name='文章描述')
83 | cover = models.ImageField(upload_to='article/%Y/%m/',verbose_name='文章封面')
84 | content = MDTextField(verbose_name='文章内容')
85 | click_count = models.IntegerField(default=0, verbose_name='点击次数')
86 | is_recommend = models.BooleanField(default=False, verbose_name='是否推荐')
87 | add_time = models.DateTimeField(default=datetime.now, verbose_name='发布时间')
88 | update_time = models.DateTimeField(auto_now=True, verbose_name='更新时间')
89 | category = models.ForeignKey(Category, blank=True, null=True, verbose_name='文章分类', on_delete=models.DO_NOTHING)
90 | tag = models.ManyToManyField(Tag, verbose_name='文章标签')
91 |
92 | def cover_data(self):
93 | return format_html(
94 | '',
95 | self.cover.url,
96 | )
97 | cover_data.short_description = '文章封面'
98 |
99 | def viewed(self):
100 | """
101 | 增加阅读数
102 | """
103 | self.click_count += 1
104 | self.save(update_fields=['click_count'])
105 |
106 |
107 | class Links(models.Model):
108 | """
109 | 友情链接
110 | """
111 |
112 | class Meta:
113 | # **表名
114 | db_table = "blog_links"
115 | # **菜单名
116 | verbose_name = '友链'
117 | verbose_name_plural = '友链'
118 |
119 | def __str__(self):
120 | return self.url
121 |
122 | id = models.AutoField(primary_key=True, verbose_name="编号")
123 | title = models.CharField(max_length=50, verbose_name='标题')
124 | url = models.URLField(verbose_name='地址')
125 | desc = models.TextField(verbose_name='描述', max_length=250)
126 | image = models.URLField(default='https://image.3001.net/images/20190330/1553875722169.jpg', verbose_name='头像')
127 |
128 | def avatar_data(self):
129 | return format_html(
130 | '
',
131 | self.image,
132 | )
133 | avatar_data.short_description = '头像'
134 |
135 | def avatar_admin(self):
136 | return format_html(
137 | '
',
138 | self.image,
139 | )
140 | avatar_admin.short_description = '头像预览'
141 |
--------------------------------------------------------------------------------
/era_blog/static/codeBlock/codeBlockFuction.js:
--------------------------------------------------------------------------------
1 | // 代码块功能依赖
2 |
3 | $(function () {
4 | $('pre').wrap('
" + match_content + "...
" 70 | } 71 | str += "70 | {{ i.desc }} 71 |
72 | 75 | 阅读更多 76 | 77 |', content, re.M)
19 | for code in code_list:
20 | content = re.sub(r'',
21 | ''.format(code=code.lower()), content,
22 | 1)
23 | return content
--------------------------------------------------------------------------------
/era_blog/tests.py:
--------------------------------------------------------------------------------
1 | from django.test import TestCase
2 |
3 | # Create your tests here.
4 |
--------------------------------------------------------------------------------
/era_blog/urls.py:
--------------------------------------------------------------------------------
1 | from django.conf.urls import url
2 | from django.conf import settings
3 | from django.urls import path, re_path, include
4 | from django.conf.urls.static import static
5 |
6 | from era_blog.views import Index, Friends, Detail, Archive, CategoryList, CategoryView, TagList, TagView, About, AllArticle
7 |
8 |
9 | urlpatterns = [
10 | # 首页
11 | path('', Index.as_view(), name='index'),
12 |
13 | # 友情链接
14 | path('friends/', Friends.as_view(), name='friends'),
15 |
16 | # 文章详情
17 | re_path('article/av(?P\d+)', Detail.as_view(), name='detail'),
18 |
19 | # 文章归档
20 | path('article/', Archive.as_view(), name='archive'),
21 |
22 | # 分类统计
23 | path('category/', CategoryList.as_view(), name='category'),
24 |
25 | # 文章分类
26 | re_path('category/cg(?P\d+)', CategoryView.as_view(), name='article_category'),
27 |
28 | # 标签统计
29 | path('tag/', TagList.as_view(), name='tag'),
30 |
31 | # 文章标签
32 | re_path('tag/tg(?P\d+)', TagView.as_view(), name='article_tag'),
33 |
34 | # 关于本站
35 | path('about/', About.as_view(),name='about'),
36 |
37 | # 关于本站
38 | path('allArchive/', AllArticle.as_view(), name='allArchive'),
39 |
40 | ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
--------------------------------------------------------------------------------
/era_blog/views.py:
--------------------------------------------------------------------------------
1 | import random
2 | import datetime
3 | import mistune
4 | import json
5 |
6 | from operator import itemgetter
7 | from django.shortcuts import render
8 | from django.views.generic.base import View
9 | from django.conf import settings
10 | from django.http import HttpResponse
11 | from django.core import serializers
12 | from pure_pagination import Paginator, EmptyPage, PageNotAnInteger
13 |
14 | from .models import Links, Article, Category, Tag
15 |
16 |
17 | def global_setting(request):
18 | """
19 | 将settings里面的变量 注册为全局变量
20 | """
21 | active_categories = Category.objects.filter(active=True).order_by('index')
22 | return {
23 | 'SITE_NAME': settings.SITE_NAME,
24 | 'SITE_DESC': settings.SITE_DESCRIPTION,
25 | 'SITE_KEY': settings.SECRET_KEY,
26 | 'SITE_MAIL': settings.SITE_MAIL,
27 | 'SITE_ICP': settings.SITE_ICP,
28 | 'SITE_ICP_URL': settings.SITE_ICP_URL,
29 | 'SITE_TITLE': settings.SITE_TITLE,
30 | 'SITE_TYPE_CHINESE': settings.SITE_TYPE_CHINESE,
31 | 'SITE_TYPE_ENGLISH': settings.SITE_TYPE_ENGLISH,
32 | 'active_categories': active_categories
33 | }
34 |
35 |
36 | class Index(View):
37 | """
38 | 首页展示
39 | """
40 | def get(self, request):
41 | all_articles = Article.objects.all().defer('content').order_by('-add_time')
42 | top_articles = Article.objects.filter(is_recommend=1).defer('content')
43 | # 首页分页功能
44 | try:
45 | page = request.GET.get('page', 1)
46 | except PageNotAnInteger:
47 | page = 1
48 |
49 | p = Paginator(all_articles, 9, request=request)
50 | articles = p.page(page)
51 |
52 | return render(request, 'index.html', {
53 | 'all_articles': articles,
54 | 'top_articles': top_articles,
55 | })
56 |
57 |
58 | class Friends(View):
59 | """
60 | 友链链接展示
61 | """
62 | def get(self, request):
63 | links = Links.objects.all()
64 | card_num = random.randint(1, 10)
65 | return render(request, 'friends.html', {
66 | 'links': links,
67 | 'card_num': card_num,
68 | })
69 |
70 |
71 | class Detail(View):
72 | """
73 | 文章详情页
74 | """
75 | def get(self, request, pk):
76 | article = Article.objects.get(id=int(pk))
77 | article.viewed()
78 | mk = mistune.Markdown()
79 | output = mk(article.content)
80 |
81 | #**查找上一篇
82 | previous_article = Article.objects.filter(category=article.category, id__lt=pk).defer('content').order_by('-id')[:1]
83 | previous_article = previous_article[0] if len(previous_article) else None
84 | #**查找下一篇
85 | next_article = Article.objects.filter(category=article.category, id__gt=pk).defer('content').order_by('id')[:1]
86 | next_article = next_article[0] if len(next_article) else None
87 |
88 | return render(request, 'detail.html', {
89 | 'article': article,
90 | 'previous_article': previous_article,
91 | 'next_article': next_article,
92 | 'detail_html': output,
93 | })
94 |
95 |
96 | class Archive(View):
97 | """
98 | 文章归档
99 | """
100 | def get(self, request):
101 | all_articles = Article.objects.all().defer('content').order_by('-add_time')
102 | all_date = all_articles.values('add_time')
103 | latest_date = all_date[0]['add_time']
104 | all_date_list = []
105 | for i in all_date:
106 | all_date_list.append(i['add_time'].strftime("%Y-%m-%d"))
107 |
108 | # 遍历1年的日期
109 | end = datetime.date(latest_date.year, latest_date.month, latest_date.day)
110 | begin = datetime.date(latest_date.year-1, latest_date.month, latest_date.day)
111 | d = begin
112 | date_list = []
113 | temp_list = []
114 |
115 | delta = datetime.timedelta(days=1)
116 | while d <= end:
117 | day = d.strftime("%Y-%m-%d")
118 | if day in all_date_list:
119 | temp_list.append(day)
120 | temp_list.append(all_date_list.count(day))
121 | else:
122 | temp_list.append(day)
123 | temp_list.append(0)
124 | d += delta
125 | date_list.append(temp_list)
126 | temp_list = []
127 |
128 | # 文章归档分页
129 | try:
130 | page = request.GET.get('page', 1)
131 | except PageNotAnInteger:
132 | page = 1
133 |
134 | p = Paginator(all_articles, 10, request=request)
135 | articles = p.page(page)
136 |
137 | return render(request, 'archive.html', {
138 | 'all_articles': articles,
139 | 'date_list': date_list,
140 | 'end': str(end),
141 | 'begin': str(begin),
142 | })
143 |
144 |
145 | class CategoryList(View):
146 | def get(self, request):
147 | categories = Category.objects.all()
148 |
149 | return render(request, 'category.html', {
150 | 'categories': categories,
151 | })
152 |
153 |
154 | class CategoryView(View):
155 | def get(self, request, pk):
156 | categories = Category.objects.all()
157 | articles = Category.objects.get(id=int(pk)).article_set.all().defer('content')
158 |
159 | try:
160 | page = request.GET.get('page', 1)
161 | except PageNotAnInteger:
162 | page = 1
163 |
164 | p = Paginator(articles, 9, request=request)
165 | articles = p.page(page)
166 |
167 | return render(request, 'article_category.html', {
168 | 'categories': categories,
169 | 'pk': int(pk),
170 | 'articles': articles
171 | })
172 |
173 |
174 | class TagList(View):
175 | def get(self, request):
176 | tags = Tag.objects.all()
177 | return render(request, 'tag.html', {
178 | 'tags': tags,
179 | })
180 |
181 |
182 | class TagView(View):
183 | def get(self, request, pk):
184 | tags = Tag.objects.all()
185 | articles = Tag.objects.get(id=int(pk)).article_set.all().defer('content')
186 |
187 | try:
188 | page = request.GET.get('page', 1)
189 | except PageNotAnInteger:
190 | page = 1
191 |
192 | p = Paginator(articles, 9, request=request)
193 | articles = p.page(page)
194 |
195 | return render(request, 'article_tag.html', {
196 | 'tags': tags,
197 | 'pk': int(pk),
198 | 'articles': articles,
199 | })
200 |
201 |
202 | class About(View):
203 | def get(self, request):
204 | articles = Article.objects.all().defer('content').order_by('-add_time')
205 | categories = Category.objects.all()
206 | tags = Tag.objects.all()
207 |
208 | all_date = articles.values('add_time')
209 |
210 | latest_date = all_date[0]['add_time']
211 | end_year = latest_date.strftime("%Y")
212 | end_month = latest_date.strftime("%m")
213 | date_list = []
214 | for i in range(int(end_month), 13):
215 | date = str(int(end_year)-1)+'-'+str(i).zfill(2)
216 | date_list.append(date)
217 |
218 | for j in range(1, int(end_month)+1):
219 | date = end_year + '-' + str(j).zfill(2)
220 | date_list.append(date)
221 |
222 | value_list = []
223 | all_date_list = []
224 | for i in all_date:
225 | all_date_list.append(i['add_time'].strftime("%Y-%m"))
226 |
227 | for i in date_list:
228 | value_list.append(all_date_list.count(i))
229 |
230 | temp_list = [] # 临时集合
231 | tags_list = [] # 存放每个标签对应的文章数
232 | tags = Tag.objects.all()
233 | for tag in tags:
234 | temp_list.append(tag.name)
235 | temp_list.append(len(tag.article_set.all()))
236 | tags_list.append(temp_list)
237 | temp_list = []
238 |
239 | tags_list.sort(key=lambda x: x[1], reverse=True) # 根据文章数排序
240 |
241 | top10_tags = []
242 | top10_tags_values = []
243 | for i in tags_list[:10]:
244 | top10_tags.append(i[0])
245 | top10_tags_values.append(i[1])
246 |
247 | return render(request, 'about.html', {
248 | 'articles': articles,
249 | 'categories': categories,
250 | 'tags': tags,
251 | 'date_list': date_list,
252 | 'value_list': value_list,
253 | 'top10_tags': top10_tags,
254 | 'top10_tags_values': top10_tags_values
255 | })
256 |
257 |
258 | class AllArticle(View):
259 | def get(self, request):
260 | articles = Article.objects.order_by('-add_time').values('id', 'title', 'desc')
261 | rst = [{'id': d['id'], 'title': d['title'], 'content': d['desc']} for d in articles]
262 | return HttpResponse(json.dumps(rst, ensure_ascii=False))
--------------------------------------------------------------------------------
/logs/erablog.log:
--------------------------------------------------------------------------------
1 | WARNING 18/Jun/2020 10:20:04 django.request log_response 228 Not Found: /favicon.ico
2 |
--------------------------------------------------------------------------------
/manage.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | """Django's command-line utility for administrative tasks."""
3 | import os
4 | import sys
5 |
6 |
7 | def main():
8 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'my_blog.settings')
9 | try:
10 | from django.core.management import execute_from_command_line
11 | except ImportError as exc:
12 | raise ImportError(
13 | "Couldn't import Django. Are you sure it's installed and "
14 | "available on your PYTHONPATH environment variable? Did you "
15 | "forget to activate a virtual environment?"
16 | ) from exc
17 | execute_from_command_line(sys.argv)
18 |
19 |
20 | if __name__ == '__main__':
21 | main()
22 |
--------------------------------------------------------------------------------
/my_blog/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/my_blog/__init__.py
--------------------------------------------------------------------------------
/my_blog/asgi.py:
--------------------------------------------------------------------------------
1 | """
2 | ASGI config for my_blog project.
3 |
4 | It exposes the ASGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.asgi import get_asgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'my_blog.settings')
15 |
16 | application = get_asgi_application()
17 |
--------------------------------------------------------------------------------
/my_blog/settings.py:
--------------------------------------------------------------------------------
1 | """
2 | Django settings for my_blog project.
3 |
4 | Generated by 'django-admin startproject' using Django 3.0.7.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.0/topics/settings/
8 |
9 | For the full list of settings and their values, see
10 | https://docs.djangoproject.com/en/3.0/ref/settings/
11 | """
12 |
13 | import os
14 |
15 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16 | BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17 |
18 |
19 | # Quick-start development settings - unsuitable for production
20 | # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
21 |
22 | # SECURITY WARNING: keep the secret key used in production secret!
23 | SECRET_KEY = 'dbo1#dz$g%w(wo*7uw$h3$-&mj0qt1txns!y!rjd$-r)7_xy+l'
24 |
25 | # SECURITY WARNING: don't run with debug turned on in production!
26 | DEBUG = True
27 |
28 | ALLOWED_HOSTS = ['*']
29 |
30 |
31 | # Application definition
32 |
33 | INSTALLED_APPS = [
34 | 'simpleui',
35 | 'era_blog.apps.EraBlogConfig',
36 | 'import_export',
37 | 'mdeditor',
38 | 'pure_pagination',
39 |
40 | 'django.contrib.admin',
41 | 'django.contrib.auth',
42 | 'django.contrib.contenttypes',
43 | 'django.contrib.sessions',
44 | 'django.contrib.messages',
45 | 'django.contrib.staticfiles'
46 | ]
47 |
48 | MIDDLEWARE = [
49 | 'django.middleware.security.SecurityMiddleware',
50 | 'django.contrib.sessions.middleware.SessionMiddleware',
51 | 'django.middleware.common.CommonMiddleware',
52 | 'django.middleware.csrf.CsrfViewMiddleware',
53 | 'django.contrib.auth.middleware.AuthenticationMiddleware',
54 | 'django.contrib.messages.middleware.MessageMiddleware',
55 | 'django.middleware.clickjacking.XFrameOptionsMiddleware',
56 | ]
57 |
58 | ROOT_URLCONF = 'my_blog.urls'
59 |
60 | TEMPLATES = [
61 | {
62 | 'BACKEND': 'django.template.backends.django.DjangoTemplates',
63 | 'DIRS': [],
64 | 'APP_DIRS': True,
65 | 'OPTIONS': {
66 | 'context_processors': [
67 | 'django.template.context_processors.debug',
68 | 'django.template.context_processors.request',
69 | 'django.contrib.auth.context_processors.auth',
70 | 'django.contrib.messages.context_processors.messages',
71 | 'era_blog.views.global_setting',
72 | ],
73 | },
74 | },
75 | ]
76 |
77 | WSGI_APPLICATION = 'my_blog.wsgi.application'
78 |
79 |
80 | # Database
81 | # https://docs.djangoproject.com/en/3.0/ref/settings/#databases
82 |
83 | # 数据库配置
84 | DATABASES = {
85 | 'default': {
86 | 'ENGINE': 'django.db.backends.mysql',
87 | 'NAME': 'myblog',
88 | 'HOST': 'www.pingswms.com',
89 | 'PORT': '31001',
90 | 'USER': 'root',
91 | 'PASSWORD': 'Zhou1182969',
92 | }
93 | }
94 |
95 |
96 | # Password validation
97 | # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
98 |
99 | AUTH_PASSWORD_VALIDATORS = [
100 | {
101 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
102 | },
103 | {
104 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
105 | },
106 | {
107 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
108 | },
109 | {
110 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
111 | },
112 | ]
113 |
114 |
115 | # Internationalization
116 | # https://docs.djangoproject.com/en/3.0/topics/i18n/
117 |
118 | # 语言时区
119 | LANGUAGE_CODE = 'zh-hans'
120 |
121 | TIME_ZONE = 'Asia/Shanghai'
122 |
123 | USE_I18N = True
124 |
125 | USE_L10N = True
126 |
127 | USE_TZ = True
128 |
129 |
130 | # Static files (CSS, JavaScript, Images)
131 | # https://docs.djangoproject.com/en/3.0/howto/static-files/
132 |
133 | # 日志记录
134 | LOGGING = {
135 | 'version': 1,
136 | 'disable_existing_loggers': False,
137 | 'formatters': {
138 | 'standard': {
139 | 'format': '%(levelname)s %(asctime)s %(name)s %(funcName)s %(lineno)d %(message)s',
140 | 'datefmt' :"%d/%b/%Y %H:%M:%S"
141 | },
142 | },
143 | 'handlers': {
144 | 'console': {
145 | 'level': 'DEBUG',
146 | 'class': 'logging.StreamHandler',
147 | 'formatter': 'standard',
148 | },
149 | 'file': {
150 | 'level': 'INFO',
151 | 'class': 'logging.FileHandler',
152 | 'filename': os.path.join(BASE_DIR + '/logs/', 'erablog.log'),
153 | 'formatter': 'standard'
154 | },
155 | },
156 | 'loggers': {
157 | 'django.request': {
158 | 'handlers': ['console', 'file'],
159 | 'level': 'DEBUG' if DEBUG else "INFO",
160 | },
161 | 'django.db.backends': {
162 | 'handlers': ['console', 'file'],
163 | 'level': 'DEBUG' if DEBUG else "INFO",
164 | },
165 | 'erablog': {
166 | 'handlers': ['console', 'file'],
167 | 'level': 'DEBUG' if DEBUG else "INFO",
168 | },
169 | }
170 | }
171 |
172 | # 静态文件配置
173 | STATIC_URL = '/static/'
174 | STATIC_ROOT = os.path.join(BASE_DIR, 'static')
175 |
176 | MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads')
177 | MEDIA_URL = '/media/'
178 |
179 | # 网站的基本信息配置
180 | SITE_NAME = 'Pings博客' # 站点名称
181 | SITE_DESCRIPTION = 'Pings博客' # 站点描述
182 | SITE_KEYWORDS = 'Pings,博客' # 站点关键词
183 | SITE_TITLE = 'Pings博客' # 博客标题
184 | SITE_TYPE_CHINESE = '时代廊桥(增城)博客' # 打字效果 中文内容
185 | SITE_TYPE_ENGLISH = 'Times langqiao (Zengcheng) blog' # 打字效果 英文内容
186 | SITE_MAIL = '275598139@qq.com' # 我的邮箱
187 | SITE_ICP = '粤ICP备18148895号' # 网站备案号
188 | SITE_ICP_URL = 'http://beian.miit.gov.cn' # 备案号超链接地址
189 |
190 | # Simple Ui 相关设置
191 | SIMPLEUI_LOGIN_PARTICLES = False
192 | SIMPLEUI_ANALYSIS = False
193 | SIMPLEUI_STATIC_OFFLINE = True
194 | SIMPLEUI_LOADING = False
195 | SIMPLEUI_LOGO = 'https://image.3001.net/images/20191031/15724874583730.png'
196 | # **菜单图标
197 | SIMPLEUI_ICON = {
198 | '文章分类': 'fa fa-folder',
199 | '文章标签': 'fa fa-tag'
200 | }
201 |
202 | #**django mysql客户端默认为mysqlclient,比较难安装。使用pymysql替换mysqlclient
203 | import pymysql
204 | pymysql.install_as_MySQLdb()
--------------------------------------------------------------------------------
/my_blog/urls.py:
--------------------------------------------------------------------------------
1 | """my_blog URL Configuration
2 |
3 | The `urlpatterns` list routes URLs to views. For more information please see:
4 | https://docs.djangoproject.com/en/3.0/topics/http/urls/
5 | Examples:
6 | Function views
7 | 1. Add an import: from my_app import views
8 | 2. Add a URL to urlpatterns: path('', views.home, name='home')
9 | Class-based views
10 | 1. Add an import: from other_app.views import Home
11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12 | Including another URLconf
13 | 1. Import the include() function: from django.urls import include, path
14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15 | """
16 | from django.contrib import admin
17 | from django.urls import path
18 | from django.urls.conf import include
19 | from django.conf.urls.static import static
20 | from django.conf import settings
21 |
22 | urlpatterns = [
23 | path('admin/', admin.site.urls),
24 | path('mdeditor/', include('mdeditor.urls')),
25 |
26 | # **ear_blog
27 | path('', include('era_blog.urls')),
28 | ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
29 |
--------------------------------------------------------------------------------
/my_blog/wsgi.py:
--------------------------------------------------------------------------------
1 | """
2 | WSGI config for my_blog project.
3 |
4 | It exposes the WSGI callable as a module-level variable named ``application``.
5 |
6 | For more information on this file, see
7 | https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
8 | """
9 |
10 | import os
11 |
12 | from django.core.wsgi import get_wsgi_application
13 |
14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'my_blog.settings')
15 |
16 | application = get_wsgi_application()
17 |
--------------------------------------------------------------------------------
/uploads/article/2020/06/redis-1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/article/2020/06/redis-1.jpg
--------------------------------------------------------------------------------
/uploads/article/2020/06/redis-2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/article/2020/06/redis-2.jpg
--------------------------------------------------------------------------------
/uploads/article/2020/06/redis-3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/article/2020/06/redis-3.jpg
--------------------------------------------------------------------------------
/uploads/article/2020/06/springboot-1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/article/2020/06/springboot-1.jpg
--------------------------------------------------------------------------------
/uploads/article/2020/06/springboot-2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/article/2020/06/springboot-2.jpg
--------------------------------------------------------------------------------
/uploads/article/2020/06/springboot-3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/article/2020/06/springboot-3.jpg
--------------------------------------------------------------------------------
/uploads/article/2020/06/springboot-4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/article/2020/06/springboot-4.jpg
--------------------------------------------------------------------------------
/uploads/article/2020/06/springboot-5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/article/2020/06/springboot-5.jpg
--------------------------------------------------------------------------------
/uploads/article/2020/06/springboot-6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/article/2020/06/springboot-6.jpg
--------------------------------------------------------------------------------
/uploads/article/2020/06/springboot-7.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/article/2020/06/springboot-7.jpg
--------------------------------------------------------------------------------
/uploads/editor/10_20200616134632284905.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/editor/10_20200616134632284905.png
--------------------------------------------------------------------------------
/uploads/editor/11_20200616134717228777.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/editor/11_20200616134717228777.png
--------------------------------------------------------------------------------
/uploads/editor/12_20200616134816739711.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/editor/12_20200616134816739711.png
--------------------------------------------------------------------------------
/uploads/editor/13_20200616135754965695.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/editor/13_20200616135754965695.png
--------------------------------------------------------------------------------
/uploads/editor/14_20200616135858054073.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/editor/14_20200616135858054073.png
--------------------------------------------------------------------------------
/uploads/editor/15_20200616135919544637.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/editor/15_20200616135919544637.png
--------------------------------------------------------------------------------
/uploads/editor/16_20200616135953372215.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/editor/16_20200616135953372215.png
--------------------------------------------------------------------------------
/uploads/editor/17_20200616141227921615.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/editor/17_20200616141227921615.png
--------------------------------------------------------------------------------
/uploads/editor/1_20200615212409393721.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/editor/1_20200615212409393721.png
--------------------------------------------------------------------------------
/uploads/editor/1_20200616114738209450.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/editor/1_20200616114738209450.png
--------------------------------------------------------------------------------
/uploads/editor/2_20200615212444162345.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/editor/2_20200615212444162345.png
--------------------------------------------------------------------------------
/uploads/editor/2_20200616114754184473.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/editor/2_20200616114754184473.png
--------------------------------------------------------------------------------
/uploads/editor/3_20200615212458218775.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/editor/3_20200615212458218775.png
--------------------------------------------------------------------------------
/uploads/editor/3_20200616115150788760.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/editor/3_20200616115150788760.png
--------------------------------------------------------------------------------
/uploads/editor/4_20200615212526004507.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/editor/4_20200615212526004507.png
--------------------------------------------------------------------------------
/uploads/editor/4_20200616115212770007.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/editor/4_20200616115212770007.png
--------------------------------------------------------------------------------
/uploads/editor/5_20200615212622375867.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/editor/5_20200615212622375867.png
--------------------------------------------------------------------------------
/uploads/editor/5_20200616115233644213.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/editor/5_20200616115233644213.png
--------------------------------------------------------------------------------
/uploads/editor/6_20200616115251003814.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/editor/6_20200616115251003814.png
--------------------------------------------------------------------------------
/uploads/editor/7_20200616115305401820.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/editor/7_20200616115305401820.png
--------------------------------------------------------------------------------
/uploads/editor/8_20200616135051757889.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/editor/8_20200616135051757889.png
--------------------------------------------------------------------------------
/uploads/editor/9_20200616134548163771.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pingszi/my_blog/80396d21e8ca8fead70a32bdc18692074dd65ce4/uploads/editor/9_20200616134548163771.png
--------------------------------------------------------------------------------