├── .env ├── .gitignore ├── LICENSE ├── blog ├── .dockerignore ├── Dockerfile ├── Dockerfile_cn ├── accounts │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── forms.py │ ├── migrations │ │ └── __init__.py │ ├── models.py │ ├── tests.py │ ├── urls.py │ └── views.py ├── api │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── migrations │ │ ├── .gitignore..git │ │ └── __init__.py │ ├── models.py │ ├── tests.py │ └── views.py ├── api_specification.md ├── blog │ ├── __init__.py │ ├── settings │ │ ├── __init__.py │ │ ├── base.py │ │ ├── dev.py │ │ └── docker.py │ ├── urls.py │ └── wsgi.py ├── init.sh ├── main │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── feeds.py │ ├── forms.py │ ├── migrations │ │ └── __init__.py │ ├── misc.py │ ├── models.py │ ├── preblog.py │ ├── sitemaps.py │ ├── tests.py │ ├── urls.py │ └── views.py ├── manage.py ├── mayblog_nginx.conf ├── mayblog_uwsgi.ini ├── media │ └── .gitignore ├── pip.conf ├── prod_pip.txt ├── readme.md ├── requirements.txt ├── sources.list ├── static │ ├── css │ │ ├── _clean-blog.min.css │ │ ├── clean-blog.css │ │ └── mayblog.css │ ├── img │ │ ├── about-bg.jpg │ │ ├── contact-bg.jpg │ │ ├── favicon-16x16.png │ │ ├── favicon-32x32.png │ │ ├── favicon-96x96.png │ │ ├── home-bg.jpg │ │ ├── post-bg.jpg │ │ └── post-sample-image.jpg │ └── js │ │ ├── bootstrap-select.min.js │ │ └── bootstrap-tagsinput.min.js ├── supervisord.conf ├── templates │ ├── 403.html │ ├── accounts │ │ ├── group.html │ │ ├── groups.html │ │ ├── login.html │ │ ├── settings_profile.html │ │ ├── simple_form.html │ │ ├── user.html │ │ ├── user_edit.html │ │ └── users.html │ ├── admin_base.html │ ├── base.html │ ├── blog_admin │ │ ├── category.html │ │ ├── index.html │ │ ├── page.html │ │ ├── pages.html │ │ ├── post.html │ │ ├── posts.html │ │ └── tags.html │ └── main │ │ ├── about.html │ │ ├── archive.html │ │ ├── author.html │ │ ├── contact.html │ │ ├── index.html │ │ ├── misc │ │ ├── duoshuo.html │ │ └── jiathis_share.html │ │ ├── page.html │ │ ├── post.html │ │ └── simple_form.html ├── test.py └── uwsgi_params ├── docker-compose.yml ├── preview.md └── readme.md /.env: -------------------------------------------------------------------------------- 1 | # Add Environment Variables 2 | 3 | DEBUG=True 4 | DJANGO_SETTINGS_MODULE=blog.settings.docker 5 | ALLOWED_HOSTS=127.0.0.1, localhost 6 | 7 | DB_NAME=postgres 8 | DB_USER=postgres 9 | DB_PASS=postgres 10 | DB_SERVICE=postgres 11 | DB_PORT=5432 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.sqlite3 3 | *.pyc 4 | .DS_Store 5 | startbootstrap-clean-blog-1.0.3/ 6 | migrations/ 7 | !__init__.py 8 | !*/ 9 | venv/ 10 | py3venv/ 11 | __pycache__/ 12 | static2/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., [http://fsf.org/] 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) 2015 gevin 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. -------------------------------------------------------------------------------- /blog/.dockerignore: -------------------------------------------------------------------------------- 1 | *.sqlite3 2 | *.pyc 3 | */migrations/* 4 | !*/migrations/__init__.py -------------------------------------------------------------------------------- /blog/Dockerfile: -------------------------------------------------------------------------------- 1 | # MAINTAINER Gevin 2 | # DOCKER-VERSION 1.6.2 3 | # 4 | # Dockerizing Ubuntu: Dockerfile for building Ubuntu images 5 | 6 | 7 | FROM ubuntu:14.04 8 | MAINTAINER Gevin 9 | 10 | RUN apt-get update && apt-get install -y curl vim && \ 11 | apt-get install -y nginx git python-dev python-pip libpq-dev postgresql-client && \ 12 | apt-get clean all 13 | 14 | 15 | RUN echo "daemon off;" >> /etc/nginx/nginx.conf 16 | 17 | RUN pip install supervisor uwsgi 18 | 19 | ADD supervisord.conf /etc/supervisord.conf 20 | 21 | RUN mkdir -p /etc/supervisor.conf.d && \ 22 | mkdir -p /var/log/supervisor 23 | 24 | RUN mkdir -p /usr/src/app && mkdir -p /var/log/uwsgi 25 | WORKDIR /usr/src/app 26 | 27 | ADD requirements.txt /usr/src/app/requirements.txt 28 | RUN pip install -r /usr/src/app/requirements.txt 29 | 30 | COPY . /usr/src/app 31 | 32 | RUN ln -s /usr/src/app/mayblog_nginx.conf /etc/nginx/sites-enabled 33 | 34 | 35 | RUN /usr/bin/python2.7 manage.py collectstatic --noinput 36 | 37 | 38 | EXPOSE 8000 39 | 40 | 41 | CMD ["/bin/bash", "/usr/src/app/init.sh"] 42 | -------------------------------------------------------------------------------- /blog/Dockerfile_cn: -------------------------------------------------------------------------------- 1 | # MAINTAINER Gevin 2 | # DOCKER-VERSION 1.6.2 3 | # 4 | # Dockerizing Ubuntu: Dockerfile for building Ubuntu images 5 | 6 | 7 | FROM ubuntu:14.04 8 | MAINTAINER Gevin 9 | 10 | ADD sources.list /etc/apt/sources.list 11 | RUN apt-get update && apt-get install -y curl vim && \ 12 | apt-get install -y nginx git python-dev python-pip libpq-dev postgresql-client && \ 13 | apt-get clean all 14 | 15 | 16 | RUN echo "daemon off;" >> /etc/nginx/nginx.conf 17 | 18 | COPY pip.conf /root/.pip/pip.conf 19 | RUN pip install supervisor uwsgi 20 | 21 | ADD supervisord.conf /etc/supervisord.conf 22 | 23 | RUN mkdir -p /etc/supervisor.conf.d && \ 24 | mkdir -p /var/log/supervisor 25 | 26 | RUN mkdir -p /usr/src/app && mkdir -p /var/log/uwsgi 27 | WORKDIR /usr/src/app 28 | 29 | ADD requirements.txt /usr/src/app/requirements.txt 30 | RUN pip install -r /usr/src/app/requirements.txt 31 | 32 | COPY . /usr/src/app 33 | 34 | RUN ln -s /usr/src/app/mayblog_nginx.conf /etc/nginx/sites-enabled 35 | 36 | 37 | RUN /usr/bin/python2.7 manage.py collectstatic --noinput 38 | 39 | 40 | EXPOSE 8000 41 | 42 | 43 | CMD ["/bin/bash", "/usr/src/app/init.sh"] 44 | -------------------------------------------------------------------------------- /blog/accounts/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flyhigher139/mayblog/d4434059291fc4a4d584d093c99d5f7ecb2f3598/blog/accounts/__init__.py -------------------------------------------------------------------------------- /blog/accounts/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from . import models 3 | 4 | # Register your models here. 5 | 6 | admin.site.register(models.Account) 7 | admin.site.register(models.SocialInfo) -------------------------------------------------------------------------------- /blog/accounts/apps.py: -------------------------------------------------------------------------------- 1 | from __future__ import unicode_literals 2 | 3 | from django.apps import AppConfig 4 | 5 | 6 | class AccountsConfig(AppConfig): 7 | name = 'accounts' 8 | -------------------------------------------------------------------------------- /blog/accounts/forms.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | from django import forms 5 | from django.contrib.auth.models import User, Group 6 | from django.contrib.auth import authenticate 7 | 8 | def group_values(): 9 | groups = Group.objects.all() 10 | choices = [(group.id, group.name) for group in groups ] 11 | return choices 12 | 13 | class LoginForm(forms.Form): 14 | username = forms.CharField(max_length=256) 15 | password = forms.CharField(max_length=256, widget=forms.PasswordInput) 16 | 17 | class RegisterForm(forms.Form): 18 | username = forms.CharField(max_length=256) 19 | email = forms.EmailField(max_length=256, required=False) 20 | password = forms.CharField(max_length=256, widget=forms.PasswordInput) 21 | password_confirm = forms.CharField(max_length=256, widget=forms.PasswordInput) 22 | 23 | def clean(self): 24 | cleaned_data = super(RegisterForm, self).clean() 25 | password = cleaned_data.get('password') 26 | password_confirm = cleaned_data.get('password_confirm') 27 | if password != password_confirm: 28 | raise forms.ValidationError('Two passwords are not the same') 29 | 30 | class UserForm(forms.Form): 31 | username = forms.CharField(max_length=256) 32 | email = forms.EmailField(max_length=256, required=False) 33 | # password = forms.CharField(max_length=256, widget=forms.PasswordInput(attrs={'placeholder': 'password'}), required=False) 34 | # password_confirm = forms.CharField(max_length=256, widget=forms.PasswordInput) 35 | # is_staff = forms.BooleanField(required=False) 36 | # is_superuser = forms.BooleanField(required=False) 37 | 38 | # def clean(self): 39 | # cleaned_data = super(RegisterForm, self).clean() 40 | # password = cleaned_data.get('password') 41 | # password_confirm = cleaned_data.get('password_confirm') 42 | # if password != password_confirm: 43 | # raise forms.ValidationError('Two passwords are not the same') 44 | 45 | class UserGroupForm(forms.Form): 46 | # GROUP_CHOICES = group_values() 47 | GROUP_CHOICES = () 48 | groups = forms.MultipleChoiceField(choices=GROUP_CHOICES, widget=forms.SelectMultiple(attrs={'size':len(GROUP_CHOICES)})) 49 | 50 | def __init__(self, *args, **kwargs): 51 | super(UserGroupForm, self).__init__(*args, **kwargs) 52 | groups = [(group.id, group.name) for group in Group.objects.all() ] 53 | # self.fields['groups'].choices = groups 54 | # self.fields['groups'].widget = forms.SelectMultiple(attrs={'size':len(groups)}) 55 | self.fields['groups'] = forms.MultipleChoiceField(choices=groups, widget=forms.SelectMultiple(attrs={'size':len(groups)})) 56 | 57 | class ProfileForm(forms.Form): 58 | display_name = forms.CharField(max_length='128') 59 | biography = forms.CharField(required=False, widget=forms.Textarea) 60 | homepage = forms.URLField(required=False) 61 | weixin = forms.URLField(required=False) 62 | douban = forms.URLField(required=False) 63 | weibo = forms.URLField(required=False) 64 | twitter = forms.URLField(required=False) 65 | github = forms.URLField(required=False) 66 | 67 | class ChangePasswordForm(forms.Form): 68 | username = forms.CharField(max_length=256, widget=forms.HiddenInput) 69 | old_password = forms.CharField(max_length=256, widget=forms.PasswordInput) 70 | new_password = forms.CharField(max_length=256, widget=forms.PasswordInput) 71 | confirm_password = forms.CharField(max_length=256, widget=forms.PasswordInput) 72 | 73 | def clean(self): 74 | cleaned_data = super(ChangePasswordForm, self).clean() 75 | new_password = cleaned_data.get('new_password') 76 | confirm_password = cleaned_data.get('confirm_password') 77 | if new_password != confirm_password: 78 | raise forms.ValidationError('Two passwords are not the same') 79 | 80 | username = cleaned_data.get('username') 81 | password = cleaned_data.get('old_password') 82 | user = authenticate(username=username, password=password) 83 | if user is None: 84 | raise forms.ValidationError('username and password does not match') 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /blog/accounts/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flyhigher139/mayblog/d4434059291fc4a4d584d093c99d5f7ecb2f3598/blog/accounts/migrations/__init__.py -------------------------------------------------------------------------------- /blog/accounts/models.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | from __future__ import unicode_literals 5 | 6 | from django.db import models 7 | from django.db.models.signals import post_save 8 | from django.contrib.auth.models import User 9 | from django.dispatch import receiver 10 | from django.utils.encoding import python_2_unicode_compatible 11 | 12 | # Create your models here. 13 | 14 | @python_2_unicode_compatible 15 | class Account(models.Model): 16 | display_name = models.CharField(max_length=128) 17 | biography = models.TextField(null=True, blank=True) 18 | homepage = models.URLField(null=True, blank=True) 19 | weixin = models.URLField(null=True, blank=True) 20 | douban = models.URLField(null=True, blank=True) 21 | weibo = models.URLField(null=True, blank=True) 22 | twitter = models.URLField(null=True, blank=True) 23 | github = models.URLField(null=True, blank=True) 24 | user = models.OneToOneField(User) 25 | 26 | 27 | @receiver(post_save, sender=User) 28 | def create_user_account(sender, instance=None, created=False, **kwargs): 29 | if created: 30 | Account.objects.get_or_create(user=instance, defaults={'display_name':instance.username}) 31 | 32 | def __str__(self): 33 | return self.display_name 34 | 35 | @python_2_unicode_compatible 36 | class SocialInfo(models.Model): 37 | SOCIAL_CHOICES = ( 38 | ('fa-facebook', 'Facebook'), 39 | ('fa-github', 'Github'), 40 | ('fa-twitter', 'Twitter'), 41 | ('fa-google-plus', 'Google Plus'), 42 | ('fa-weibo', 'Weibo'),) 43 | ('fa-bookmark', 'Other'), 44 | 45 | user = models.ForeignKey(User) 46 | social = models.CharField(choices=SOCIAL_CHOICES, max_length=128) 47 | url = models.URLField() 48 | 49 | def __str__(self): 50 | return self.user.name + '-' + self.social 51 | -------------------------------------------------------------------------------- /blog/accounts/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /blog/accounts/urls.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | from django.conf.urls import url 5 | from . import views 6 | 7 | urlpatterns = [ 8 | url(r'^login/$', views.LoginView.as_view(), name='login'), 9 | url(r'^logout/$', views.LogoutView.as_view(), name='logout'), 10 | url(r'^register/$', views.RegisterView.as_view(), name='register'), 11 | url(r'^profile/$', views.ProfileView.as_view(), name='profile'), 12 | url(r'^profile/password/$', views.ChangePasswordView.as_view(), name='change_password'), 13 | url(r'^users/$', views.UsersView.as_view(), name='users'), 14 | url(r'^users/(?P(-)?[0-9]+)/$', views.UserView.as_view(), name='user'), 15 | url(r'^users/(?P(-)?[0-9]+)/edit/$', views.UserEditView.as_view(), name='user_edit'), 16 | url(r'^groups/(?P[0-9]+)/users/$', views.UsersView.as_view(), name='group_users'), 17 | url(r'^groups/$', views.GroupsView.as_view(), name='groups'), 18 | url(r'^groups/(?P(-)?[0-9]+)/$', views.GroupView.as_view(), name='group'), 19 | ] -------------------------------------------------------------------------------- /blog/accounts/views.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | from django.http import HttpResponse, Http404 5 | from django.shortcuts import render, redirect 6 | from django.core.urlresolvers import reverse 7 | from django.contrib.auth import authenticate, login, logout 8 | from django.contrib.auth.models import User, Group 9 | from django.contrib import messages 10 | from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger 11 | from django.views.generic import View 12 | from django.conf import settings 13 | from django.contrib.auth.decorators import login_required 14 | from django.utils.decorators import method_decorator 15 | 16 | from guardian.decorators import permission_required 17 | 18 | from . import forms 19 | 20 | PER_PAGE = settings.MAY_BLOG['PER_PAGE_ADMIN'] 21 | 22 | # Create your views here. 23 | class LoginView(View): 24 | template_name = 'accounts/simple_form.html' 25 | def get(self, request, form=None): 26 | data = {} 27 | if not form: 28 | form = forms.LoginForm() 29 | data['form'] = form 30 | data['title'] = 'Login' 31 | data['btn_name'] = 'Login' 32 | return render(request, self.template_name, data) 33 | def post(self, request, form=None): 34 | data = {} 35 | form = forms.LoginForm(request.POST) 36 | if form.is_valid(): 37 | username = form.cleaned_data['username'] 38 | password = form.cleaned_data['password'] 39 | 40 | user = authenticate(username=username, password=password) 41 | if user is not None: 42 | if user.is_active: 43 | login(request, user) 44 | # Redirect to a success page. 45 | url = request.GET.get('next', None) 46 | if not url: 47 | url = reverse('main:admin_index') 48 | return redirect(url) 49 | else: 50 | # Return a 'disabled account' error message 51 | msg = 'The user is disabled' 52 | messages.add_message(request, messages.WARNING, msg) 53 | return self.get(request, form) 54 | else: 55 | # Return an 'invalid login' error message. 56 | msg = 'Invalid login, user does not exist' 57 | messages.add_message(request, messages.ERROR, msg) 58 | return self.get(request, form) 59 | 60 | else: 61 | return self.get(request, form) 62 | 63 | class LogoutView(View): 64 | def get(self, request): 65 | logout(request) 66 | msg = 'Succeed to logout' 67 | url = reverse('accounts:login') 68 | return redirect(url) 69 | 70 | class RegisterView(View): 71 | template_name = 'accounts/simple_form.html' 72 | def get(self, request, form=None): 73 | if not form: 74 | form = forms.RegisterForm() 75 | 76 | data = {'title':'Register', 'form':form, 'btn_name':'Register'} 77 | 78 | return render(request, self.template_name, data) 79 | 80 | def post(self, request): 81 | form = forms.RegisterForm(request.POST) 82 | if form.is_valid(): 83 | username = form.cleaned_data['username'] 84 | email = form.cleaned_data['email'] 85 | password = form.cleaned_data['password'] 86 | 87 | user = User.objects.create_user(username, email, password) 88 | 89 | user.save() 90 | 91 | msg = 'Successfully Registered' 92 | messages.add_message(request, messages.SUCCESS, msg) 93 | url = reverse('accounts:login') 94 | return redirect(url) 95 | 96 | else: 97 | return self.get(request, form) 98 | 99 | class UsersView(View): 100 | template_name = 'accounts/users.html' 101 | 102 | @method_decorator(permission_required('main.change_user', accept_global_perms=True)) 103 | def get(self, request, group_id=0): 104 | data = {} 105 | 106 | if group_id: 107 | group = Group.objects.get(pk=group_id) 108 | users = group.user_set.all() 109 | data['group_id'] = int(group_id) 110 | else: 111 | users = User.objects.all() 112 | data['all'] = True 113 | 114 | key = request.GET.get('key') 115 | if key: 116 | users = users.filter(username__icontains=key) 117 | 118 | paginator = Paginator(users, PER_PAGE) 119 | page = request.GET.get('page') 120 | try: 121 | users = paginator.page(page) 122 | except PageNotAnInteger: 123 | users = paginator.page(1) 124 | except EmptyPage: 125 | users = paginator.page(paginator.num_pages) 126 | 127 | groups = Group.objects.all() 128 | # data = {'users':users, 'groups':groups} 129 | data['users'] = users 130 | data['groups'] = groups 131 | 132 | data['allow_search'] = True 133 | 134 | return render(request, self.template_name, data) 135 | 136 | class UserView(View): 137 | template_name = 'accounts/user.html' 138 | 139 | @method_decorator(permission_required('main.change_user', accept_global_perms=True)) 140 | def get(self, request, pk): 141 | pk = int(pk) 142 | data = {} 143 | try: 144 | user = User.objects.get(pk=pk) 145 | except User.DoesNotExist: 146 | raise Http404 147 | data['user'] = user 148 | 149 | groups = user.groups.all() 150 | data['groups'] = groups 151 | 152 | # permissions = user.get_all_permissions() 153 | # data['permissions'] = permissions 154 | permissions = user.user_permissions.all() 155 | data['permissions'] = permissions 156 | 157 | return render(request, self.template_name, data) 158 | 159 | class GroupView(View): 160 | template_name = 'accounts/group.html' 161 | 162 | @method_decorator(permission_required('main.change_user', accept_global_perms=True)) 163 | def get(self, request, pk): 164 | pk = int(pk) 165 | data = {} 166 | try: 167 | group = Group.objects.get(pk=pk) 168 | except group.DoesNotExist: 169 | raise Http404 170 | data['group'] = group 171 | 172 | permissions = group.permissions.all() 173 | data['permissions'] = permissions 174 | 175 | users = group.user_set.all() 176 | data['users'] = users 177 | 178 | return render(request, self.template_name, data) 179 | 180 | class UserEditView(View): 181 | template_name = 'accounts/user_edit.html' 182 | 183 | @method_decorator(permission_required('main.change_user', accept_global_perms=True)) 184 | def get(self, request, pk, user_form=None): 185 | pk = int(pk) 186 | data = {} 187 | try: 188 | user = User.objects.get(pk=pk) 189 | except User.DoesNotExist: 190 | raise Http404 191 | 192 | data['user_edited'] = user 193 | 194 | user_dict = {'username':user.username, 'email': user.email} 195 | if not user_form: 196 | user_form = forms.UserForm(initial=user_dict) 197 | data['user_form'] = user_form 198 | 199 | groups = user.groups.all() 200 | user_groups = [group.id for group in groups ] 201 | group_dict = {'groups':user_groups} 202 | user_group_form = forms.UserGroupForm(initial=group_dict) 203 | data['user_group_form'] = user_group_form 204 | 205 | return render(request, self.template_name, data) 206 | 207 | @method_decorator(permission_required('main.change_user', accept_global_perms=True)) 208 | def post(self, request, pk): 209 | pk = int(pk) 210 | try: 211 | user = User.objects.get(pk=pk) 212 | except User.DoesNotExist: 213 | raise Http404 214 | if request.POST.get('user'): 215 | form = forms.UserForm(request.POST) 216 | if form.is_valid(): 217 | user.username = form.cleaned_data['username'] 218 | user.email = form.cleaned_data['email'] 219 | if request.user.is_superuser: 220 | user.is_superuser = request.POST.get('is_superuser', False) 221 | user.is_staff = request.POST.get('is_staff', False) 222 | user.save() 223 | 224 | url = reverse('accounts:user_edit', args=(pk,)) 225 | msg = 'Succeed to update user details' 226 | messages.add_message(request, messages.SUCCESS, msg) 227 | return redirect(url) 228 | 229 | return self.get(request, pk, user_form=form) 230 | else: 231 | group_ids = request.POST.getlist('groups') 232 | # user.groups.add(*group_ids) 233 | user.groups = group_ids 234 | # return HttpResponse(group_ids) 235 | url = reverse('accounts:user_edit', args=(pk,)) 236 | msg = 'Succeed to update user groups' 237 | messages.add_message(request, messages.SUCCESS, msg) 238 | return redirect(url) 239 | 240 | 241 | class GroupsView(View): 242 | template_name = 'accounts/groups.html' 243 | 244 | @method_decorator(permission_required('main.change_user', accept_global_perms=True)) 245 | def get(self, request): 246 | groups = Group.objects.all() 247 | data = {'groups':groups} 248 | 249 | return render(request, self.template_name, data) 250 | 251 | class ProfileView(View): 252 | template_name = 'accounts/settings_profile.html' 253 | 254 | @method_decorator(login_required) 255 | def get(self, request, form=None): 256 | data = {} 257 | form_data = { 258 | 'display_name' : request.user.account.display_name, 259 | 'biography' : request.user.account.biography, 260 | 'homepage' : request.user.account.homepage, 261 | 'weixin' : request.user.account.weixin, 262 | 'douban' : request.user.account.douban, 263 | 'weibo' : request.user.account.weibo, 264 | 'twitter' : request.user.account.twitter, 265 | 'github' : request.user.account.github 266 | } 267 | 268 | if not form: 269 | form = forms.ProfileForm(initial=form_data) 270 | 271 | data['form'] = form 272 | data['is_profile'] = True 273 | 274 | return render(request, self.template_name, data) 275 | 276 | @method_decorator(login_required) 277 | def post(self, request): 278 | form = forms.ProfileForm(request.POST) 279 | if form.is_valid(): 280 | account = request.user.account 281 | 282 | account.display_name = form.cleaned_data['display_name'] 283 | account.biography = form.cleaned_data['biography'] 284 | account.homepage = form.cleaned_data['homepage'] 285 | account.weixin = form.cleaned_data['weixin'] 286 | account.douban = form.cleaned_data['douban'] 287 | account.weibo = form.cleaned_data['weibo'] 288 | account.twitter = form.cleaned_data['twitter'] 289 | account.github = form.cleaned_data['github'] 290 | 291 | account.save() 292 | 293 | msg = 'Succeed to update profile' 294 | url = reverse('accounts:profile') 295 | messages.add_message(request, messages.SUCCESS, msg) 296 | return redirect(url) 297 | 298 | return self.get(request, form) 299 | 300 | class ChangePasswordView(View): 301 | template_name = 'accounts/settings_profile.html' 302 | 303 | @method_decorator(login_required) 304 | def get(self, request, form=None): 305 | data = {} 306 | if not form: 307 | form = forms.ChangePasswordForm(initial={'username':request.user.username}) 308 | 309 | data['form'] = form 310 | data['is_password'] = True 311 | 312 | return render(request, self.template_name, data) 313 | 314 | @method_decorator(login_required) 315 | def post(self, request): 316 | form = forms.ChangePasswordForm(request.POST) 317 | if form.is_valid(): 318 | password = form.cleaned_data['new_password'] 319 | user = request.user 320 | user.set_password(password) 321 | 322 | user.save() 323 | 324 | msg = 'Succeed to update profile' 325 | url = reverse('accounts:change_password') 326 | messages.add_message(request, messages.SUCCESS, msg) 327 | return redirect(url) 328 | 329 | return self.get(request, form) 330 | 331 | 332 | 333 | 334 | 335 | -------------------------------------------------------------------------------- /blog/api/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flyhigher139/mayblog/d4434059291fc4a4d584d093c99d5f7ecb2f3598/blog/api/__init__.py -------------------------------------------------------------------------------- /blog/api/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /blog/api/apps.py: -------------------------------------------------------------------------------- 1 | from __future__ import unicode_literals 2 | 3 | from django.apps import AppConfig 4 | 5 | 6 | class ApiConfig(AppConfig): 7 | name = 'api' 8 | -------------------------------------------------------------------------------- /blog/api/migrations/.gitignore..git: -------------------------------------------------------------------------------- 1 | * 2 | !__init__.py -------------------------------------------------------------------------------- /blog/api/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flyhigher139/mayblog/d4434059291fc4a4d584d093c99d5f7ecb2f3598/blog/api/migrations/__init__.py -------------------------------------------------------------------------------- /blog/api/models.py: -------------------------------------------------------------------------------- 1 | from __future__ import unicode_literals 2 | 3 | from django.db import models 4 | 5 | # Create your models here. 6 | -------------------------------------------------------------------------------- /blog/api/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /blog/api/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | 3 | # Create your views here. 4 | -------------------------------------------------------------------------------- /blog/api_specification.md: -------------------------------------------------------------------------------- 1 | MayBlog RESTful API Specification(To Do) 2 | ========================================= 3 | 4 | ## Blog 5 | 6 | ### Listing Blogs 7 | 8 | List current user's blog 9 | 10 | List all blogs 11 | filter by user, category, or tag 12 | 13 | ### Creating Blog 14 | 15 | ### Updating Blog 16 | 17 | ### Deleting Blog 18 | 19 | ## Tag 20 | 21 | ### Creating Tag 22 | 23 | ### Listing Tag 24 | 25 | ### Updating Tag 26 | 27 | ### Deleting Tag 28 | 29 | 30 | ## Category 31 | 32 | ### Creating Category 33 | 34 | ### Listing Category 35 | 36 | ### Updating Category 37 | 38 | ### Deleting Category 39 | 40 | -------------------------------------------------------------------------------- /blog/blog/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flyhigher139/mayblog/d4434059291fc4a4d584d093c99d5f7ecb2f3598/blog/blog/__init__.py -------------------------------------------------------------------------------- /blog/blog/settings/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flyhigher139/mayblog/d4434059291fc4a4d584d093c99d5f7ecb2f3598/blog/blog/settings/__init__.py -------------------------------------------------------------------------------- /blog/blog/settings/base.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for blog project. 3 | 4 | Generated by 'django-admin startproject' using Django 1.10.1. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/1.10/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/1.10/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.dirname(os.path.abspath(__file__)))) 17 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = '5rn849^cm(!hlot=rczb#0id2&wsx0+do%k#z1*#t-!v819tm2' 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 | 'django.contrib.admin', 35 | 'django.contrib.auth', 36 | 'django.contrib.contenttypes', 37 | 'django.contrib.sessions', 38 | 'django.contrib.messages', 39 | 'django.contrib.staticfiles', 40 | 'django.contrib.sitemaps', 41 | # 'rest_framework', 42 | 'import_export', 43 | 'bootstrap3', 44 | 'guardian', 45 | 'main', 46 | 'accounts', 47 | # 'api', 48 | ] 49 | 50 | MIDDLEWARE = [ 51 | 'django.middleware.security.SecurityMiddleware', 52 | 'django.contrib.sessions.middleware.SessionMiddleware', 53 | 'django.middleware.common.CommonMiddleware', 54 | 'django.middleware.csrf.CsrfViewMiddleware', 55 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 56 | 'django.contrib.messages.middleware.MessageMiddleware', 57 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 58 | ] 59 | 60 | ROOT_URLCONF = 'blog.urls' 61 | 62 | TEMPLATES = [ 63 | { 64 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 65 | 'DIRS': [ 66 | os.path.join(BASE_DIR, 'templates').replace('\\', '/'), 67 | ], 68 | 'APP_DIRS': True, 69 | 'OPTIONS': { 70 | 'context_processors': [ 71 | 'django.template.context_processors.debug', 72 | 'django.template.context_processors.request', 73 | 'django.contrib.auth.context_processors.auth', 74 | 'django.contrib.messages.context_processors.messages', 75 | ], 76 | }, 77 | }, 78 | ] 79 | 80 | STATICFILES_DIRS = [ 81 | os.path.join(BASE_DIR, 'static').replace('\\', '/'), 82 | ] 83 | 84 | WSGI_APPLICATION = 'blog.wsgi.application' 85 | 86 | 87 | # Database 88 | # https://docs.djangoproject.com/en/1.10/ref/settings/#databases 89 | 90 | DATABASES = { 91 | 'default': { 92 | 'ENGINE': 'django.db.backends.sqlite3', 93 | 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), 94 | } 95 | } 96 | 97 | 98 | # Password validation 99 | # https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators 100 | 101 | AUTH_PASSWORD_VALIDATORS = [ 102 | { 103 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 104 | }, 105 | { 106 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 107 | }, 108 | { 109 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 110 | }, 111 | { 112 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 113 | }, 114 | ] 115 | 116 | 117 | # Internationalization 118 | # https://docs.djangoproject.com/en/1.10/topics/i18n/ 119 | 120 | LANGUAGE_CODE = 'en-us' 121 | 122 | TIME_ZONE = 'UTC' 123 | 124 | USE_I18N = True 125 | 126 | USE_L10N = True 127 | 128 | USE_TZ = True 129 | 130 | 131 | # Static files (CSS, JavaScript, Images) 132 | # https://docs.djangoproject.com/en/1.10/howto/static-files/ 133 | 134 | STATIC_URL = '/static/' 135 | 136 | #For deployment 137 | STATIC_ROOT = os.path.join(BASE_DIR, "static2/") 138 | 139 | ################################# 140 | # guardian settings 141 | ################################# 142 | 143 | AUTHENTICATION_BACKENDS = ( 144 | 'django.contrib.auth.backends.ModelBackend', # this is default 145 | 'guardian.backends.ObjectPermissionBackend', 146 | ) 147 | 148 | ANONYMOUS_USER_ID = -1 149 | 150 | ################################# 151 | # Django REST framework settings 152 | ################################# 153 | 154 | # REST_FRAMEWORK = { 155 | # 'DEFAULT_AUTHENTICATION_CLASSES': ( 156 | # 'rest_framework.authentication.SessionAuthentication', 157 | # 'rest_framework.authentication.BasicAuthentication', 158 | # ), 159 | # 'DEFAULT_PERMISSION_CLASSES': ( 160 | # 'rest_framework.permissions.IsAdminUser', 161 | # ), 162 | # # 'DEFAULT_PAGINATION_CLASS': 'apps.core.pagination.StandardResultsSetPagination' 163 | # } 164 | 165 | ################################# 166 | # MayBlog settings 167 | ################################# 168 | 169 | MAY_BLOG = { 170 | 'PER_PAGE': 5, 171 | 'PER_PAGE_ADMIN': 10, 172 | 'COMMENT_TYPE': 'duoshuo', 173 | 'COMMENT_OPT':{ 174 | 'duoshuo':'mayblog', 175 | }, 176 | 'ALLOW_DONATE': True, 177 | 'RSS_NUM': 30, 178 | } 179 | -------------------------------------------------------------------------------- /blog/blog/settings/dev.py: -------------------------------------------------------------------------------- 1 | from .base import * 2 | 3 | DATABASES = { 4 | 'default': { 5 | 'ENGINE': 'django.db.backends.sqlite3', 6 | 'NAME': os.path.join(BASE_DIR, 'db_dev.sqlite3'), 7 | } 8 | } -------------------------------------------------------------------------------- /blog/blog/settings/docker.py: -------------------------------------------------------------------------------- 1 | import os 2 | from base import * 3 | 4 | DEBUG = (os.environ['DEBUG'].lower() == 'true') 5 | # DEBUG = False 6 | 7 | ALLOWED_HOSTS = [host.strip() for host in os.environ['ALLOWED_HOSTS'].split(',')] 8 | 9 | 10 | DATABASES = { 11 | 'default': { 12 | 'ENGINE': 'django.db.backends.postgresql_psycopg2', 13 | 'NAME': os.environ['DB_NAME'], 14 | 'USER': os.environ['DB_USER'], 15 | 'PASSWORD': os.environ['DB_PASS'], 16 | 'HOST': os.environ['DB_SERVICE'], 17 | 'PORT': os.environ['DB_PORT'] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /blog/blog/urls.py: -------------------------------------------------------------------------------- 1 | """blog URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/1.10/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: url(r'^$', 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: url(r'^$', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.conf.urls import url, include 14 | 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) 15 | """ 16 | from django.conf.urls import url, include 17 | from django.contrib import admin 18 | 19 | # urlpatterns = [ 20 | # url(r'^admin/', admin.site.urls), 21 | # ] 22 | 23 | urlpatterns = [ 24 | url(r'^admin2/', include(admin.site.urls)), 25 | url(r'^', include('main.urls', namespace='main')), 26 | url(r'^accounts/', include('accounts.urls', namespace='accounts')), 27 | ] 28 | -------------------------------------------------------------------------------- /blog/blog/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for 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/1.10/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", "blog.settings.dev") 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /blog/init.sh: -------------------------------------------------------------------------------- 1 | while true; do 2 | if (/usr/bin/python2.7 /usr/src/app/manage.py makemigrations); then 3 | if (/usr/bin/python2.7 /usr/src/app/manage.py migrate); then 4 | echo "succeed to migrate database" 5 | break 6 | fi 7 | fi 8 | sleep 2 9 | done 10 | 11 | # if (/usr/bin/python2.7 /usr/src/app/manage.py makemigrations); then 12 | # if (/usr/bin/python2.7 /usr/src/app/manage.py migrate); then 13 | # echo "succeed to migrate database" 14 | # break 15 | # fi 16 | # fi 17 | 18 | 19 | /usr/local/bin/supervisord -n -------------------------------------------------------------------------------- /blog/main/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flyhigher139/mayblog/d4434059291fc4a4d584d093c99d5f7ecb2f3598/blog/main/__init__.py -------------------------------------------------------------------------------- /blog/main/admin.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | from django.contrib import admin 5 | from django.contrib.auth.models import Permission 6 | 7 | from guardian.admin import GuardedModelAdmin 8 | 9 | from import_export import resources 10 | from import_export.admin import ImportExportModelAdmin, ImportExportMixin 11 | 12 | from . import models 13 | 14 | 15 | 16 | 17 | class PostResource(resources.ModelResource): 18 | 19 | class Meta: 20 | model = models.Post 21 | 22 | class TagResource(resources.ModelResource): 23 | 24 | class Meta: 25 | model = models.Tag 26 | 27 | class CategoryResource(resources.ModelResource): 28 | 29 | class Meta: 30 | model = models.Category 31 | 32 | class PageResource(resources.ModelResource): 33 | 34 | class Meta: 35 | model = models.Page 36 | 37 | class BlogMetaResource(resources.ModelResource): 38 | 39 | class Meta: 40 | model = models.BlogMeta 41 | 42 | class PermissionResource(resources.ModelResource): 43 | 44 | class Meta: 45 | model = Permission 46 | 47 | 48 | class PostAdmin(ImportExportModelAdmin): 49 | resource_class = PostResource 50 | 51 | class TagAdmin(ImportExportModelAdmin): 52 | resource_class = TagResource 53 | 54 | class CategoryAdmin(ImportExportModelAdmin): 55 | resource_class = CategoryResource 56 | 57 | class PageAdmin(ImportExportModelAdmin): 58 | resource_class = PageResource 59 | 60 | class BlogMetaAdmin(ImportExportModelAdmin): 61 | resource_class = BlogMetaResource 62 | 63 | class PermissionAdmin(ImportExportModelAdmin): 64 | resource_class = Permission 65 | 66 | 67 | 68 | admin.site.register(models.Post, PostAdmin) 69 | admin.site.register(models.Tag, TagAdmin) 70 | admin.site.register(models.Category, CategoryAdmin) 71 | admin.site.register(models.Page, PageAdmin) 72 | admin.site.register(models.BlogMeta, BlogMetaAdmin) 73 | admin.site.register(Permission, PermissionAdmin) -------------------------------------------------------------------------------- /blog/main/apps.py: -------------------------------------------------------------------------------- 1 | from __future__ import unicode_literals 2 | 3 | from django.apps import AppConfig 4 | 5 | 6 | class MainConfig(AppConfig): 7 | name = 'main' 8 | -------------------------------------------------------------------------------- /blog/main/feeds.py: -------------------------------------------------------------------------------- 1 | from django.contrib.syndication.views import Feed 2 | from django.core.urlresolvers import reverse 3 | from django.utils.feedgenerator import Atom1Feed 4 | from django.shortcuts import get_object_or_404 5 | from django.conf import settings 6 | 7 | from .models import Post, BlogMeta 8 | from .views import get_site_meta 9 | 10 | # def get_site_meta(): 11 | # seo = {} 12 | # try: 13 | # record = BlogMeta.objects.get(key='blog_name') 14 | # seo['title'] = record.value 15 | # except BlogMeta.DoesNotExist: 16 | # pass 17 | 18 | # try: 19 | # record = BlogMeta.objects.get(key='blog_desc') 20 | # seo['desc'] = record.value 21 | # except BlogMeta.DoesNotExist: 22 | # pass 23 | 24 | # try: 25 | # record = BlogMeta.objects.get(key='owner') 26 | # seo['author'] = record.value 27 | # except BlogMeta.DoesNotExist: 28 | # pass 29 | 30 | # try: 31 | # record = BlogMeta.objects.get(key='keywords') 32 | # seo['keywords'] = record.value 33 | # except BlogMeta.DoesNotExist: 34 | # pass 35 | 36 | # try: 37 | # record = BlogMeta.objects.get(key='blog_subtitle') 38 | # seo['subtitle'] = record.value 39 | # except BlogMeta.DoesNotExist: 40 | # pass 41 | 42 | # try: 43 | # record = BlogMeta.objects.get(key='google_verify') 44 | # seo['google_verify'] = record.value 45 | # except BlogMeta.DoesNotExist: 46 | # pass 47 | 48 | # try: 49 | # record = BlogMeta.objects.get(key='baidu_verify') 50 | # seo['baidu_verify'] = record.value 51 | # except BlogMeta.DoesNotExist: 52 | # pass 53 | 54 | # return seo 55 | 56 | # META_DATA = get_site_meta() 57 | FEED_NUM = settings.MAY_BLOG['RSS_NUM'] 58 | 59 | 60 | # class LatestEntriesFeed(Feed): 61 | # feed_type = Atom1Feed 62 | 63 | # # title = "MayBlog" 64 | # # link = "/" 65 | # description = "MayBlog Rss" 66 | 67 | # def get_object(self, request, pk): 68 | # # return get_object_or_404(Post, pk=id) 69 | # return Post.objects.get(pk=pk) 70 | 71 | # def title(self, obj): 72 | # return "MayBlog: %s posts" % obj.title 73 | 74 | # def link(self, item): 75 | # return reverse('main:post', args=[item.pk]) 76 | # # return '/' 77 | 78 | # def items(self): 79 | # return Post.objects.filter(is_draft=False) 80 | 81 | # def item_title(self, item): 82 | # return item.title 83 | 84 | # def item_description(self, item): 85 | # return item.content_html 86 | 87 | # # item_link is only needed if Post has no get_absolute_url method. 88 | # def item_link(self, item): 89 | # return reverse('main:post', args=[item.pk]) 90 | # # return '/' 91 | 92 | class LatestEntriesFeed2(Feed): 93 | 94 | 95 | def title(self): 96 | META_DATA = get_site_meta() 97 | return META_DATA.get('title') 98 | 99 | def link(self, item): 100 | return reverse('main:rss') 101 | # return '/rss/' 102 | 103 | def description(self): 104 | META_DATA = get_site_meta() 105 | return META_DATA.get('subtitle') 106 | 107 | def items(self): 108 | return Post.objects.filter(is_draft=False).order_by('-update_time')[:FEED_NUM] 109 | 110 | def item_title(self, item): 111 | return item.title 112 | 113 | def item_description(self, item): 114 | return item.content_html 115 | 116 | # item_link is only needed if Post has no get_absolute_url method. 117 | def item_link(self, item): 118 | return reverse('main:post', args=[item.pk]) 119 | 120 | -------------------------------------------------------------------------------- /blog/main/forms.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | from django import forms 5 | 6 | class NewPost(forms.Form): 7 | title = forms.CharField(max_length=256) 8 | content = forms.CharField(widget=forms.Textarea(attrs={'rows':20})) 9 | abstract = forms.CharField(widget=forms.Textarea(attrs={'rows':4}), required=False) 10 | author_id = forms.IntegerField(required=False, widget=forms.HiddenInput) 11 | # tag = forms.CharField(max_length=256, required=False) 12 | # category = forms.CharField(max_length=256, required=False) 13 | 14 | class NewPage(forms.Form): 15 | title = forms.CharField(max_length=256) 16 | slug = forms.CharField(max_length=64) 17 | content = forms.CharField(widget=forms.Textarea(attrs={'rows':20})) 18 | author_id = forms.IntegerField(required=False, widget=forms.HiddenInput) 19 | 20 | class CategoryForm(forms.Form): 21 | name = forms.CharField(max_length=256, label='Category Name') 22 | 23 | class TagForm(forms.Form): 24 | tags = forms.CharField(max_length=256, label='Tags') 25 | 26 | class BlogMetaForm(forms.Form): 27 | title = forms.CharField(max_length=256, label='Title') 28 | subtitle = forms.CharField(max_length=256, label='SubTitle') 29 | desc = forms.CharField(max_length=256, label='Description') 30 | author = forms.CharField(max_length=256, label='Owner') 31 | keywords = forms.CharField(max_length=256, label='Keywords') 32 | google_verify = forms.CharField(max_length=256, label='Google Site Verification', required=False) 33 | baidu_verify = forms.CharField(max_length=256, label='Baidu Site Verification', required=False) -------------------------------------------------------------------------------- /blog/main/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flyhigher139/mayblog/d4434059291fc4a4d584d093c99d5f7ecb2f3598/blog/main/migrations/__init__.py -------------------------------------------------------------------------------- /blog/main/misc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | from django.template import RequestContext, loader 5 | 6 | def get_comment_func(comment_type): 7 | if comment_type == 'duoshuo': 8 | return duoshuo_comment 9 | else: 10 | return None 11 | 12 | def duoshuo_comment(request, duoshuo_id, post_id, post_title, post_url): 13 | ''' 14 | Create duoshuo script by params 15 | ''' 16 | template_name = 'main/misc/duoshuo.html' 17 | 18 | template = loader.get_template(template_name) 19 | data = { 20 | 'duoshuo_id': duoshuo_id, 21 | 'post_id': post_id, 22 | 'post_title': post_title, 23 | 'post_url': post_url, 24 | } 25 | context = RequestContext(request, data) 26 | return template.render(context) 27 | 28 | def jiathis_share(request): 29 | ''' 30 | Create duoshuo script by params 31 | ''' 32 | template_name = 'main/misc/jiathis_share.html' 33 | 34 | template = loader.get_template(template_name) 35 | data = {} 36 | context = RequestContext(request, data) 37 | return template.render(context) -------------------------------------------------------------------------------- /blog/main/models.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | from __future__ import unicode_literals 5 | 6 | from django.db import models 7 | from django.contrib.auth.models import User 8 | from django.core.urlresolvers import reverse 9 | from django.utils.encoding import python_2_unicode_compatible 10 | import markdown2 11 | 12 | # Create your models here. 13 | 14 | @python_2_unicode_compatible 15 | class Post(models.Model): 16 | title = models.CharField(max_length=256, default='new blog') 17 | abstract = models.TextField(null=True, blank=True) 18 | raw = models.TextField() 19 | pub_time = models.DateTimeField(auto_now_add=True) 20 | update_time = models.DateTimeField(auto_now=True) 21 | content_html = models.TextField(null=True, blank=True) 22 | author = models.ForeignKey(User) 23 | tags = models.ManyToManyField('Tag', blank=True) 24 | category = models.ForeignKey('Category', null=True, blank=True) 25 | is_draft = models.BooleanField(default=False) 26 | 27 | def save(self, *args, **kwargs): 28 | self.content_html = markdown2.markdown(self.raw, extras=['code-friendly', 'fenced-code-blocks']).encode('utf-8') 29 | super(Post, self).save(*args, **kwargs) 30 | 31 | def __str__(self): 32 | return self.title 33 | 34 | def get_absolute_url(self): 35 | return reverse('main:post', kwargs={ 'pk': self.id }) 36 | 37 | @python_2_unicode_compatible 38 | class Tag(models.Model): 39 | name = models.CharField(max_length=256) 40 | 41 | def __str__(self): 42 | return self.name 43 | 44 | @python_2_unicode_compatible 45 | class Category(models.Model): 46 | name = models.CharField(max_length=256) 47 | 48 | def __str__(self): 49 | return self.name 50 | 51 | @python_2_unicode_compatible 52 | class Page(models.Model): 53 | title = models.CharField(max_length=256, default='new page') 54 | slug = models.CharField(max_length=256, default='slug') 55 | raw = models.TextField() 56 | pub_time = models.DateTimeField(auto_now_add=True) 57 | update_time = models.DateTimeField(auto_now=True) 58 | content_html = models.TextField() 59 | author = models.ForeignKey(User) 60 | is_draft = models.BooleanField(default=False) 61 | 62 | def save(self, *args, **kwargs): 63 | self.content_html = markdown2.markdown(self.raw, extras=['code-friendly', 'fenced-code-blocks']).encode('utf-8') 64 | super(Page, self).save(*args, **kwargs) 65 | 66 | def __str__(self): 67 | return self.title 68 | 69 | def get_absolute_url(self): 70 | return reverse('main:page', kwargs={ 'pk': self.id }) 71 | 72 | @python_2_unicode_compatible 73 | class BlogMeta(models.Model): 74 | key = models.CharField(max_length=256) 75 | value = models.CharField(max_length=256, null=True, blank=True) 76 | flag = models.BooleanField(default=False) 77 | misc = models.CharField(max_length=256, null=True, blank=True) 78 | 79 | def __str__(self): 80 | return self.key 81 | 82 | -------------------------------------------------------------------------------- /blog/main/preblog.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # from django.db import models 5 | from django.contrib.auth.models import User, Group, Permission 6 | from django.contrib.auth import get_user_model 7 | from django.http import HttpResponse 8 | from django.views.generic import View 9 | from django.shortcuts import render, redirect 10 | from django.core.urlresolvers import reverse 11 | from django.contrib import messages 12 | 13 | from accounts import forms 14 | from . import models 15 | 16 | # def init_blog(request): 17 | # # Create superuser 18 | # # get_user_model().objects.create_superuser(username='su', email='su@email.com', password='su') 19 | # try: 20 | # su = User.objects.get(username='su') 21 | # except User.DoesNotExist: 22 | # User.objects.create_superuser(username='su', email='su@email.com', password='su') 23 | # # Create admin group 24 | # group = create_admin_group() 25 | 26 | # # Create editor group 27 | # group = create_editor_group() 28 | 29 | # # Create writer group 30 | # group = create_writer_group() 31 | 32 | # # Create contributor group 33 | # group = create_contributor_group() 34 | 35 | # # Create reader group 36 | # group = create_reader_group() 37 | 38 | 39 | # # Create default category 40 | # default_category, created = models.Category.objects.get_or_create(name='default') 41 | 42 | # return HttpResponse('succeed to init blog') 43 | 44 | class BlogInitView(View): 45 | template_name = 'main/simple_form.html' 46 | def get(self, request, form=None): 47 | initialized = False 48 | 49 | try: 50 | initialization = models.BlogMeta.objects.get(key='initialization') 51 | initialized = initialization.flag 52 | except models.BlogMeta.DoesNotExist: 53 | initialized = False 54 | 55 | if initialized: 56 | url = reverse('main:admin_index') 57 | return redirect(url) 58 | 59 | 60 | if not form: 61 | form = forms.RegisterForm() 62 | data = {'form':form} 63 | data['title'] = 'System Initialization' 64 | data['heading'] = 'Create Superuser' 65 | return render(request, self.template_name, data) 66 | 67 | def post(self, request): 68 | form = forms.RegisterForm(request.POST) 69 | if form.is_valid(): 70 | username = form.cleaned_data['username'] 71 | email = form.cleaned_data['email'] 72 | password = form.cleaned_data['password'] 73 | 74 | user = User.objects.create_superuser(username, email, password) 75 | 76 | 77 | # Create admin group 78 | group = create_admin_group() 79 | 80 | # Create editor group 81 | group = create_editor_group() 82 | 83 | # Create writer group 84 | group = create_writer_group() 85 | 86 | # Create contributor group 87 | group = create_contributor_group() 88 | 89 | # Create reader group 90 | group = create_reader_group() 91 | 92 | # Create default category 93 | default_category, created = models.Category.objects.get_or_create(name='default') 94 | 95 | initialization, created = models.BlogMeta.objects.get_or_create(key='initialization') 96 | initialization.flag = True 97 | initialization.save() 98 | 99 | 100 | # Blog meta data 101 | # obj, created = models.BlogMeta.objects.get_or_create(key='blog_name', defaults={'value':'MayBlog'}) 102 | # obj, created = models.BlogMeta.objects.get_or_create(key='blog_subtitle', defaults={'value':'Welcome to MayBlog'}) 103 | # obj, created = models.BlogMeta.objects.get_or_create(key='blog_desc', defaults={'value':'desc'}) 104 | # obj, created = models.BlogMeta.objects.get_or_create(key='owner', defaults={'value':'MayBlog'}) 105 | # obj, created = models.BlogMeta.objects.get_or_create(key='keywords', defaults={'value':'MayBlog'}) 106 | # obj, created = models.BlogMeta.objects.get_or_create(key='google_verify', defaults={'value':''}) 107 | # obj, created = models.BlogMeta.objects.get_or_create(key='baidu_verify', defaults={'value':''}) 108 | init_blog_meta() 109 | 110 | 111 | msg = 'Successfully Initialized' 112 | messages.add_message(request, messages.SUCCESS, msg) 113 | url = reverse('main:admin_index') 114 | return redirect(url) 115 | 116 | else: 117 | return self.get(request, form) 118 | 119 | class ReInitBlogMetaView(View): 120 | def get(self, request): 121 | init_blog_meta() 122 | 123 | msg = 'Successfully reinitialized blog meta' 124 | messages.add_message(request, messages.SUCCESS, msg) 125 | url = reverse('main:admin_index') 126 | return redirect(url) 127 | 128 | def init_blog_meta(): 129 | obj, created = models.BlogMeta.objects.get_or_create(key='blog_name', defaults={'value':'MayBlog'}) 130 | obj, created = models.BlogMeta.objects.get_or_create(key='blog_subtitle', defaults={'value':'Welcome to MayBlog'}) 131 | obj, created = models.BlogMeta.objects.get_or_create(key='blog_desc', defaults={'value':'desc'}) 132 | obj, created = models.BlogMeta.objects.get_or_create(key='owner', defaults={'value':'MayBlog'}) 133 | obj, created = models.BlogMeta.objects.get_or_create(key='keywords', defaults={'value':'MayBlog'}) 134 | obj, created = models.BlogMeta.objects.get_or_create(key='google_verify', defaults={'value':''}) 135 | obj, created = models.BlogMeta.objects.get_or_create(key='baidu_verify', defaults={'value':''}) 136 | 137 | def create_admin_group(): 138 | group, created = Group.objects.get_or_create(name='administrator') 139 | codenames = [ 140 | 'add_user', 'change_user', 'delete_user', 141 | 'add_blogmeta', 'change_blogmeta', 'delete_blogmeta', 142 | 'add_post', 'change_post', 'delete_post', 143 | 'add_page', 'change_page', 'delete_page', 144 | 'add_category', 'change_category', 'delete_category', 145 | 'add_tag', 'change_tag', 'delete_tag', 146 | ] 147 | 148 | permissions = Permission.objects.filter(codename__in=codenames) 149 | group.permissions = permissions 150 | 151 | 152 | return group 153 | 154 | def create_editor_group(): 155 | group, created = Group.objects.get_or_create(name='editor') 156 | codenames = [ 157 | 'add_post', 'change_post', 'delete_post', 158 | 'add_page', 'change_page', 'delete_page', 159 | 'add_category', 'change_category', 'delete_category', 160 | 'add_tag', 'change_tag', 'delete_tag', 161 | 162 | ] 163 | 164 | permissions = Permission.objects.filter(codename__in=codenames) 165 | group.permissions = permissions 166 | 167 | 168 | return group 169 | 170 | def create_writer_group(): 171 | group, created = Group.objects.get_or_create(name='writer') 172 | codenames = [ 173 | 'add_post', #'change_post', 'delete_post', 174 | #'add_page', 'change_page', 'delete_page', 175 | #'add_category', 'change_category', 'delete_category', 176 | 'add_tag', #'change_tag', 'delete_tag', 177 | 178 | ] 179 | 180 | permissions = Permission.objects.filter(codename__in=codenames) 181 | group.permissions = permissions 182 | 183 | 184 | return group 185 | 186 | def create_contributor_group(): 187 | group, created = Group.objects.get_or_create(name='contributor') 188 | codenames = [ 189 | 'add_post', #'change_post', 'delete_post', 190 | #'add_page', 'change_page', 'delete_page', 191 | #'add_category', 'change_category', 'delete_category', 192 | #'add_tag', 'change_tag', 'delete_tag', 193 | 194 | ] 195 | 196 | permissions = Permission.objects.filter(codename__in=codenames) 197 | group.permissions = permissions 198 | 199 | 200 | return group 201 | 202 | def create_reader_group(): 203 | group, created = Group.objects.get_or_create(name='reader') 204 | codenames = [ 205 | # 'add_post', 'change_post', 'delete_post', 206 | # 'add_page', 'change_page', 'delete_page', 207 | # 'add_category', 'change_category', 'delete_category', 208 | # 'add_tag', 'change_tag', 'delete_tag', 209 | 210 | ] 211 | 212 | permissions = Permission.objects.filter(codename__in=codenames) 213 | group.permissions = permissions 214 | 215 | 216 | return group 217 | 218 | -------------------------------------------------------------------------------- /blog/main/sitemaps.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | from django.contrib.sitemaps import Sitemap 5 | 6 | from . import models 7 | 8 | class BlogSitemap(Sitemap): 9 | changefreq = "daily" 10 | priority = 0.5 11 | 12 | def items(self): 13 | return models.Post.objects.filter(is_draft=False) 14 | 15 | def lastmod(self, obj): 16 | return obj.update_time 17 | 18 | class PageSitemap(Sitemap): 19 | changefreq = "monthly" 20 | priority = 0.5 21 | 22 | def items(self): 23 | return models.Page.objects.filter(is_draft=False) 24 | 25 | def lastmod(self, obj): 26 | return obj.update_time 27 | 28 | # class CategorySitemap(Sitemap): 29 | # changefreq = "weekly" 30 | # priority = 0.6 31 | 32 | # def items(self): 33 | # return models.Category.objects.all() 34 | 35 | # class TagSitemap(Sitemap): 36 | # changefreq = "weekly" 37 | # priority = 0.6 38 | 39 | # def items(self): 40 | # return models.Tag.objects.all() 41 | 42 | sitemaps = { 43 | 'blog': BlogSitemap, 44 | 'page': PageSitemap, 45 | # 'category': CategorySitemap, 46 | # 'tag': TagSitemap, 47 | } 48 | 49 | -------------------------------------------------------------------------------- /blog/main/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /blog/main/urls.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | from django.conf.urls import url 5 | from django.contrib.sitemaps.views import sitemap 6 | 7 | from . import views, preblog, feeds, sitemaps 8 | 9 | 10 | urlpatterns = [ 11 | url(r'^$', views.Index.as_view(), name='index'), 12 | url(r'^post/(?P[0-9]+)/$', views.Post.as_view(), name='post'), 13 | url(r'^page/(?P[0-9]+)/$', views.Page.as_view(), name='page'), 14 | url(r'^archive$', views.Archive.as_view(), name='archive'), 15 | url(r'^authors/(?P[0-9]+)/$', views.Author.as_view(), name='author'), 16 | ] 17 | 18 | urlpatterns += [ 19 | url(r'^admin/$', views.AdminIndex.as_view(), name='admin_index'), 20 | url(r'^admin/meta$', views.AdminBlogMeta.as_view(), name='admin_blog_meta'), 21 | url(r'^admin/posts$', views.AdminPosts.as_view(), name='admin_posts'), 22 | url(r'^admin/pages$', views.AdminPosts.as_view(), {'is_blog_page':True}, name='admin_pages'), 23 | url(r'^admin/post$', views.AdminPost.as_view(), name='admin_post'), 24 | url(r'^admin/page$', views.AdminPage.as_view(), name='admin_page'), 25 | url(r'^admin/posts/(?P[0-9]+)$', views.AdminPost.as_view(), name='admin_edit_post'), 26 | url(r'^admin/pages/(?P[0-9]+)$', views.AdminPage.as_view(), name='admin_edit_page'), 27 | url(r'^admin/posts/delete/(?P[0-9]+)$', views.DeletePost.as_view(), name='admin_delete_post'), 28 | url(r'^admin/pages/delete/(?P[0-9]+)$', views.DeletePage.as_view(), name='admin_delete_page'), 29 | url(r'^admin/tags/$', views.AdminTags.as_view(), name='admin_tags'), 30 | url(r'^admin/category/$', views.AdminCategory.as_view(), name='admin_category'), 31 | url(r'^admin/filter-posts$', views.AdminFilterPosts.as_view(), name='admin_filter_posts'), 32 | url(r'^admin/tags/delete/(?P[0-9]+)$', views.simple_delete, {'flag':'tag'}, name='admin_delete_tag'), 33 | url(r'^admin/categories/delete/(?P[0-9]+)$', views.simple_delete, {'flag':'category'}, name='admin_delete_category'), 34 | url(r'^admin/tags/edit/(?P[0-9]+)$', views.simple_update, {'flag':'tag'}, name='admin_edit_tag'), 35 | url(r'^admin/categories/edit/(?P[0-9]+)$', views.simple_update, {'flag':'category'}, name='admin_edit_category'), 36 | ] 37 | 38 | urlpatterns += [ 39 | url(r'^init$', preblog.BlogInitView.as_view()), 40 | url(r'^reinit-meta$', preblog.ReInitBlogMetaView.as_view()), 41 | url(r'^rss/$', feeds.LatestEntriesFeed2(), name='rss'), 42 | url(r'^sitemap\.xml$', sitemap, {'sitemaps': sitemaps.sitemaps}, name='django.contrib.sitemaps.views.sitemap') 43 | ] 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /blog/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "blog.settings.dev") 7 | try: 8 | from django.core.management import execute_from_command_line 9 | except ImportError: 10 | # The above import may fail for some other reason. Ensure that the 11 | # issue is really that Django is missing to avoid masking other 12 | # exceptions on Python 2. 13 | try: 14 | import django 15 | except ImportError: 16 | raise ImportError( 17 | "Couldn't import Django. Are you sure it's installed and " 18 | "available on your PYTHONPATH environment variable? Did you " 19 | "forget to activate a virtual environment?" 20 | ) 21 | raise 22 | execute_from_command_line(sys.argv) 23 | -------------------------------------------------------------------------------- /blog/mayblog_nginx.conf: -------------------------------------------------------------------------------- 1 | # mysite_nginx.conf 2 | 3 | # the upstream component nginx needs to connect to 4 | upstream django { 5 | server unix:///tmp/mayblog.sock; # for a file socket 6 | # server 127.0.0.1:8001; # for a web port socket (we'll use this first) 7 | } 8 | # configuration of the server 9 | server { 10 | # the port your site will be served on 11 | listen 8000; 12 | # the domain name it will serve for 13 | server_name localhost; # substitute your machine's IP address or FQDN 14 | charset utf-8; 15 | 16 | # max upload size 17 | client_max_body_size 75M; # adjust to taste 18 | 19 | # Django media 20 | location /media { 21 | alias /usr/src/app/media; # your Django project's media files - amend as required 22 | } 23 | 24 | location /static { 25 | alias /usr/src/app/static2; # your Django project's static files - amend as required 26 | } 27 | 28 | # Finally, send all non-media requests to the Django server. 29 | location / { 30 | uwsgi_pass django; 31 | include /usr/src/app/uwsgi_params; # the uwsgi_params file you installed 32 | } 33 | } -------------------------------------------------------------------------------- /blog/mayblog_uwsgi.ini: -------------------------------------------------------------------------------- 1 | # mysite_uwsgi.ini file 2 | [uwsgi] 3 | 4 | # Django-related settings 5 | # the base directory (full path) 6 | chdir = /usr/src/app 7 | # Django's wsgi file 8 | module = blog.wsgi:application 9 | # the virtualenv (full path) 10 | # home = /vagrant/mayblog/venv 11 | 12 | # process-related settings 13 | # master 14 | master = true 15 | # maximum number of worker processes 16 | processes = 10 17 | # the socket (use the full path to be safe 18 | socket = /tmp/mayblog.sock 19 | # ... with appropriate permissions - may be needed 20 | chmod-socket = 666 21 | # clear environment on exit 22 | vacuum = true 23 | 24 | # pythonpath = /usr/bin/python 25 | # env = DJANGO_SETTINGS_MODULE=blog.settings.dev # set an environment variable 26 | # pidfile = /tmp/mayblog-master.pid # create a pidfile 27 | # harakiri = 20 # respawn processes taking more than 20 seconds 28 | # limit-as = 128 # limit the project to 128 MB 29 | # max-requests = 5000 # respawn processes after serving 5000 requests 30 | # daemonize = /var/log/uwsgi/mayblog.log # background the process & log -------------------------------------------------------------------------------- /blog/media/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /blog/pip.conf: -------------------------------------------------------------------------------- 1 | [global] 2 | index-url = http://mirrors.aliyun.com/pypi/simple/ 3 | 4 | [install] 5 | trusted-host=mirrors.aliyun.com -------------------------------------------------------------------------------- /blog/prod_pip.txt: -------------------------------------------------------------------------------- 1 | -r base.txt 2 | mysqlclient -------------------------------------------------------------------------------- /blog/readme.md: -------------------------------------------------------------------------------- 1 | Welcome to May Blog 2 | ==================== 3 | 4 | >MayBlog is powered by django, here are some instruction on how to run it. 5 | 6 | ## How to run it ? 7 | 8 | ### Install requirements 9 | 10 | ``` 11 | (sudo) pip install -r requirements.txt 12 | ``` 13 | 14 | ### Create/update datebase 15 | 16 | For the first time, before you start the application, you need to initialize the datebase which is configured in the `settings file` and designed in `main.models.py` 17 | 18 | ```bash 19 | python manage.py migrate 20 | ``` 21 | 22 | If the models are changed after the datebase is created, you need to run the following commands: 23 | 24 | ```bash 25 | python manage.py makemigrations #create migration script 26 | python manage.py migrate #migrate datebase 27 | ``` 28 | 29 | 30 | #### ps: 31 | 32 | I use sqlite in dev settings and mysql in prod settings, if you would like to use postgres, mongodb, etc, install relevant python prerequisite first. 33 | 34 | ### Run MayBlog 35 | 36 | After the datebase is established, you can run the blog with command: 37 | 38 | ```bash 39 | python manage.py runserver 0.0.0.0:8000 40 | ``` 41 | 42 | Then you can visit the blog with url: http://127.0.0.1:8000 43 | 44 | ### Initialize MayBlog 45 | 46 | When the blog is run, checkout `http://127.0.0.1:8000/init` to initialize the system 47 | 48 | It will create the superuser, user groups(administrator, editor, writer, contributor, and reader), and assign permissions for each group. 49 | 50 | ### Admin MayBlog 51 | 52 | You can create a superuser to administer MayBlog in its admin interface: 53 | 54 | ```bash 55 | python manage.py createsuperuser 56 | ``` 57 | 58 | Then, you can administer MayBlog with following admin interface: 59 | 60 | - MayBlog admin: http://127.0.0.1:8000/admin/ 61 | - Django's default admin: http://127.0.0.1:8000/admin2/ 62 | 63 | - Login page: http://127.0.0.1:8000/accounts/login/ 64 | - Register page: http://127.0.0.1:8000/accounts/register/ (if `REGISTER_IS_ALLOWED` is set to True in settings) 65 | 66 | ### MayBlog settings 67 | 68 | By default, MayBlog uses dev settings(`blog.settings.dev`) in `blog/settings/dev.py` in development environment. 69 | 70 | `blog.settings.prod` is used in product environment and `blog.settings.stage` is in test environment. You can overwrite these settings or create your custom settings and switch to it. 71 | 72 | #### How to switch settings 73 | 74 | Just set your settings in bash with `export` command. For example, if you want to run MayBlog in product environment, you can switch to prod settings like this: 75 | 76 | ``` 77 | export DJANGO_SETTINGS_MODULE="blog.settings.prod" 78 | ``` 79 | 80 | ## Deploy MayBlog 81 | 82 | I recommend you to deploy MayBlog by `Ubuntu + nginx + uwsgi`. 83 | 84 | [Here](http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html) is an instruction. 85 | 86 | *Using [MayBlog's docker image](https://registry.hub.docker.com/u/gevin/mayblog/) is another recommended option* 87 | 88 | ### What's more 89 | 90 | If you find a bug or want to add a new feature, just issue me. 91 | Want to contribute? Please fork MayBlog and pull request to me. 92 | 93 | I'm not good at frontend development, so I used a free bootstrap blog theme. If you can redesign the blog theme and admin interface, I'll appriciate your work very much! 94 | 95 | -------------------------------------------------------------------------------- /blog/requirements.txt: -------------------------------------------------------------------------------- 1 | Django 2 | django-bootstrap3 3 | markdown2 4 | djangorestframework 5 | psycopg2 6 | django-import-export 7 | django-guardian -------------------------------------------------------------------------------- /blog/sources.list: -------------------------------------------------------------------------------- 1 | deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse 2 | deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse 3 | deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse 4 | deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse 5 | deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse 6 | deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse 7 | deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse 8 | deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse 9 | deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse 10 | deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse -------------------------------------------------------------------------------- /blog/static/css/_clean-blog.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Clean Blog v1.0.0 (http://startbootstrap.com) 3 | * Copyright 2014 Start Bootstrap 4 | * Licensed under Apache 2.0 (https://github.com/IronSummitMedia/startbootstrap/blob/gh-pages/LICENSE) 5 | */ 6 | 7 | body{font-family:Lora,'Times New Roman',serif;font-size:20px;color:#404040}p{line-height:1.5;margin:30px 0}p a{text-decoration:underline}h1,h2,h3,h4,h5,h6{font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;font-weight:800}a{color:#404040}a:hover,a:focus{color:#0085a1}a img:hover,a img:focus{cursor:zoom-in}blockquote{color:gray;font-style:italic}hr.small{max-width:100px;margin:15px auto;border-width:4px;border-color:#fff}.navbar-custom{position:absolute;top:0;left:0;width:100%;z-index:3;font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif}.navbar-custom .navbar-brand{font-weight:800}.navbar-custom .nav li a{text-transform:uppercase;font-size:12px;font-weight:800;letter-spacing:1px}@media only screen and (min-width:768px){.navbar-custom{background:0 0;border-bottom:1px solid transparent}.navbar-custom .navbar-brand{color:#fff;padding:20px}.navbar-custom .navbar-brand:hover,.navbar-custom .navbar-brand:focus{color:rgba(255,255,255,.8)}.navbar-custom .nav li a{color:#fff;padding:20px}.navbar-custom .nav li a:hover,.navbar-custom .nav li a:focus{color:rgba(255,255,255,.8)}}@media only screen and (min-width:1170px){.navbar-custom{-webkit-transition:background-color .3s;-moz-transition:background-color .3s;transition:background-color .3s;-webkit-transform:translate3d(0,0,0);-moz-transform:translate3d(0,0,0);-ms-transform:translate3d(0,0,0);-o-transform:translate3d(0,0,0);transform:translate3d(0,0,0);-webkit-backface-visibility:hidden;backface-visibility:hidden}.navbar-custom.is-fixed{position:fixed;top:-61px;background-color:rgba(255,255,255,.9);border-bottom:1px solid #f2f2f2;-webkit-transition:-webkit-transform .3s;-moz-transition:-moz-transform .3s;transition:transform .3s}.navbar-custom.is-fixed .navbar-brand{color:#404040}.navbar-custom.is-fixed .navbar-brand:hover,.navbar-custom.is-fixed .navbar-brand:focus{color:#0085a1}.navbar-custom.is-fixed .nav li a{color:#404040}.navbar-custom.is-fixed .nav li a:hover,.navbar-custom.is-fixed .nav li a:focus{color:#0085a1}.navbar-custom.is-visible{-webkit-transform:translate3d(0,100%,0);-moz-transform:translate3d(0,100%,0);-ms-transform:translate3d(0,100%,0);-o-transform:translate3d(0,100%,0);transform:translate3d(0,100%,0)}}.intro-header{background-color:gray;background:no-repeat center center;background-attachment:scroll;-webkit-background-size:cover;-moz-background-size:cover;background-size:cover;-o-background-size:cover;margin-bottom:50px}.intro-header .site-heading,.intro-header .post-heading,.intro-header .page-heading{padding:100px 0 50px;color:#fff}@media only screen and (min-width:768px){.intro-header .site-heading,.intro-header .post-heading,.intro-header .page-heading{padding:150px 0}}.intro-header .site-heading,.intro-header .page-heading{text-align:center}.intro-header .site-heading h1,.intro-header .page-heading h1{margin-top:0;font-size:50px}.intro-header .site-heading .subheading,.intro-header .page-heading .subheading{font-size:24px;line-height:1.1;display:block;font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;font-weight:300;margin:10px 0 0}@media only screen and (min-width:768px){.intro-header .site-heading h1,.intro-header .page-heading h1{font-size:80px}}.intro-header .post-heading h1{font-size:35px}.intro-header .post-heading .subheading,.intro-header .post-heading .meta{line-height:1.1;display:block}.intro-header .post-heading .subheading{font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;font-size:24px;margin:10px 0 30px;font-weight:600}.intro-header .post-heading .meta{font-family:Lora,'Times New Roman',serif;font-style:italic;font-weight:300;font-size:20px}.intro-header .post-heading .meta a{color:#fff}@media only screen and (min-width:768px){.intro-header .post-heading h1{font-size:55px}.intro-header .post-heading .subheading{font-size:30px}}.post-preview>a{color:#404040}.post-preview>a:hover,.post-preview>a:focus{text-decoration:none;color:#0085a1}.post-preview>a>.post-title{font-size:30px;margin-top:30px;margin-bottom:10px}.post-preview>a>.post-subtitle{margin:0;font-weight:300;margin-bottom:10px}.post-preview>.post-meta{color:gray;font-size:18px;font-style:italic;margin-top:0}.post-preview>.post-meta>a{text-decoration:none;color:#404040}.post-preview>.post-meta>a:hover,.post-preview>.post-meta>a:focus{color:#0085a1;text-decoration:underline}@media only screen and (min-width:768px){.post-preview>a>.post-title{font-size:36px}}.section-heading{font-size:36px;margin-top:60px;font-weight:700}.caption{font-size:14px;padding:10px;margin:0;display:block;border-bottom-right-radius:5px;border-bottom-left-radius:5px}footer{padding:50px 0 65px}footer .list-inline{margin:0;padding:0}footer .copyright{font-size:14px;text-align:center;margin-bottom:0}.floating-label-form-group{font-size:14px;position:relative;margin-bottom:0;padding-bottom:.5em;border-bottom:1px solid #eee}.floating-label-form-group input,.floating-label-form-group textarea{z-index:1;position:relative;padding-right:0;padding-left:0;border:none;border-radius:0;font-size:1.5em;background:0 0;box-shadow:none!important;resize:none}.floating-label-form-group label{display:block;z-index:0;position:relative;top:2em;margin:0;font-size:.85em;line-height:1.764705882em;vertical-align:middle;vertical-align:baseline;opacity:0;-webkit-transition:top .3s ease,opacity .3s ease;-moz-transition:top .3s ease,opacity .3s ease;-ms-transition:top .3s ease,opacity .3s ease;transition:top .3s ease,opacity .3s ease}.floating-label-form-group::not(:first-child){padding-left:14px;border-left:1px solid #eee}.floating-label-form-group-with-value label{top:0;opacity:1}.floating-label-form-group-with-focus label{color:#0085a1}form .row:first-child .floating-label-form-group{border-top:1px solid #eee}.btn{font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;text-transform:uppercase;font-size:14px;font-weight:800;letter-spacing:1px;border-radius:0;padding:15px 25px}.btn-lg{font-size:16px;padding:25px 35px}.btn-default:hover,.btn-default:focus{background-color:#0085a1;border:1px solid #0085a1;color:#fff}.pager{margin:20px 0 0}.pager li>a,.pager li>span{font-family:'Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;text-transform:uppercase;font-size:14px;font-weight:800;letter-spacing:1px;padding:15px 25px;background-color:#fff;border-radius:0}.pager li>a:hover,.pager li>a:focus{color:#fff;background-color:#0085a1;border:1px solid #0085a1}.pager .disabled>a,.pager .disabled>a:hover,.pager .disabled>a:focus,.pager .disabled>span{color:gray;background-color:#404040;cursor:not-allowed}::-moz-selection{color:#fff;text-shadow:none;background:#0085a1}::selection{color:#fff;text-shadow:none;background:#0085a1}img::selection{color:#fff;background:0 0}img::-moz-selection{color:#fff;background:0 0}body{webkit-tap-highlight-color:#0085a1} 8 | -------------------------------------------------------------------------------- /blog/static/css/clean-blog.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Clean Blog v1.0.0 (http://startbootstrap.com) 3 | * Copyright 2014 Start Bootstrap 4 | * Licensed under Apache 2.0 (https://github.com/IronSummitMedia/startbootstrap/blob/gh-pages/LICENSE) 5 | */ 6 | 7 | body { 8 | /*font-family: 'Lora', 'Times New Roman', serif;*/ 9 | font-family: "lucida grande", "lucida sans unicode", lucida, helvetica, "STHeiti Light", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; 10 | font-size: 18px; 11 | color: #404040; 12 | } 13 | p { 14 | line-height: 1.7; 15 | margin: 30px 0; 16 | } 17 | p a { 18 | text-decoration: underline; 19 | } 20 | h1, 21 | h2, 22 | h3, 23 | h4, 24 | h5, 25 | h6 { 26 | /*font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;*/ 27 | font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, "STHeiti Light", "Microsoft YaHei", 'Hiragino Sans GB', 'SimHei', sans-serif; 28 | font-weight: 800; 29 | } 30 | a { 31 | color: #404040; 32 | } 33 | a:hover, 34 | a:focus { 35 | color: #0085a1; 36 | } 37 | a img:hover, 38 | a img:focus { 39 | cursor: zoom-in; 40 | } 41 | blockquote { 42 | color: #808080; 43 | font-style: italic; 44 | } 45 | hr.small { 46 | max-width: 100px; 47 | margin: 15px auto; 48 | border-width: 4px; 49 | border-color: white; 50 | } 51 | .navbar-custom { 52 | position: absolute; 53 | top: 0; 54 | left: 0; 55 | width: 100%; 56 | z-index: 3; 57 | font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, "STHeiti Light", "Microsoft YaHei", 'Hiragino Sans GB', 'SimHei', sans-serif; 58 | } 59 | .navbar-custom .navbar-brand { 60 | font-weight: 800; 61 | } 62 | .navbar-custom .nav li a { 63 | text-transform: uppercase; 64 | font-size: 12px; 65 | font-weight: 800; 66 | letter-spacing: 1px; 67 | } 68 | @media only screen and (min-width: 768px) { 69 | .navbar-custom { 70 | background: transparent; 71 | border-bottom: 1px solid transparent; 72 | } 73 | .navbar-custom .navbar-brand { 74 | color: white; 75 | padding: 20px; 76 | } 77 | .navbar-custom .navbar-brand:hover, 78 | .navbar-custom .navbar-brand:focus { 79 | color: rgba(255, 255, 255, 0.8); 80 | } 81 | .navbar-custom .nav li a { 82 | color: white; 83 | padding: 20px; 84 | } 85 | .navbar-custom .nav li a:hover, 86 | .navbar-custom .nav li a:focus { 87 | color: rgba(255, 255, 255, 0.8); 88 | } 89 | } 90 | @media only screen and (min-width: 1170px) { 91 | .navbar-custom { 92 | -webkit-transition: background-color 0.3s; 93 | -moz-transition: background-color 0.3s; 94 | transition: background-color 0.3s; 95 | /* Force Hardware Acceleration in WebKit */ 96 | -webkit-transform: translate3d(0, 0, 0); 97 | -moz-transform: translate3d(0, 0, 0); 98 | -ms-transform: translate3d(0, 0, 0); 99 | -o-transform: translate3d(0, 0, 0); 100 | transform: translate3d(0, 0, 0); 101 | -webkit-backface-visibility: hidden; 102 | backface-visibility: hidden; 103 | } 104 | .navbar-custom.is-fixed { 105 | /* when the user scrolls down, we hide the header right above the viewport */ 106 | position: fixed; 107 | top: -61px; 108 | background-color: rgba(255, 255, 255, 0.9); 109 | border-bottom: 1px solid #f2f2f2; 110 | -webkit-transition: -webkit-transform 0.3s; 111 | -moz-transition: -moz-transform 0.3s; 112 | transition: transform 0.3s; 113 | } 114 | .navbar-custom.is-fixed .navbar-brand { 115 | color: #404040; 116 | } 117 | .navbar-custom.is-fixed .navbar-brand:hover, 118 | .navbar-custom.is-fixed .navbar-brand:focus { 119 | color: #0085a1; 120 | } 121 | .navbar-custom.is-fixed .nav li a { 122 | color: #404040; 123 | } 124 | .navbar-custom.is-fixed .nav li a:hover, 125 | .navbar-custom.is-fixed .nav li a:focus { 126 | color: #0085a1; 127 | } 128 | .navbar-custom.is-visible { 129 | /* if the user changes the scrolling direction, we show the header */ 130 | -webkit-transform: translate3d(0, 100%, 0); 131 | -moz-transform: translate3d(0, 100%, 0); 132 | -ms-transform: translate3d(0, 100%, 0); 133 | -o-transform: translate3d(0, 100%, 0); 134 | transform: translate3d(0, 100%, 0); 135 | } 136 | } 137 | .intro-header { 138 | background-color: #808080; 139 | background: no-repeat center center; 140 | background-attachment: scroll; 141 | -webkit-background-size: cover; 142 | -moz-background-size: cover; 143 | background-size: cover; 144 | -o-background-size: cover; 145 | margin-bottom: 50px; 146 | } 147 | .intro-header .site-heading, 148 | .intro-header .post-heading, 149 | .intro-header .page-heading { 150 | padding: 100px 0 50px; 151 | color: white; 152 | } 153 | @media only screen and (min-width: 768px) { 154 | .intro-header .site-heading, 155 | .intro-header .post-heading, 156 | .intro-header .page-heading { 157 | padding: 150px 0; 158 | } 159 | } 160 | .intro-header .site-heading, 161 | .intro-header .page-heading { 162 | text-align: center; 163 | } 164 | .intro-header .site-heading h1, 165 | .intro-header .page-heading h1 { 166 | margin-top: 0; 167 | font-size: 50px; 168 | } 169 | .intro-header .site-heading .subheading, 170 | .intro-header .page-heading .subheading { 171 | font-size: 24px; 172 | line-height: 1.1; 173 | display: block; 174 | font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, "STHeiti Light", "Microsoft YaHei", 'Hiragino Sans GB', 'SimHei', sans-serif; 175 | font-weight: 300; 176 | margin: 10px 0 0; 177 | } 178 | @media only screen and (min-width: 768px) { 179 | .intro-header .site-heading h1, 180 | .intro-header .page-heading h1 { 181 | font-size: 80px; 182 | } 183 | } 184 | .intro-header .post-heading h1 { 185 | font-size: 35px; 186 | } 187 | .intro-header .post-heading .subheading, 188 | .intro-header .post-heading .meta { 189 | line-height: 1.1; 190 | display: block; 191 | } 192 | .intro-header .post-heading .subheading { 193 | font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, "STHeiti Light", "Microsoft YaHei", 'Hiragino Sans GB', 'SimHei', sans-serif; 194 | font-size: 24px; 195 | margin: 10px 0 30px; 196 | font-weight: 600; 197 | } 198 | .intro-header .post-heading .meta { 199 | font-family: "lucida grande", "lucida sans unicode", lucida, helvetica, "STHeiti Light", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; 200 | font-style: italic; 201 | font-weight: 300; 202 | font-size: 16px; 203 | } 204 | .intro-header .post-heading .meta a { 205 | color: white; 206 | } 207 | @media only screen and (min-width: 768px) { 208 | .intro-header .post-heading h1 { 209 | font-size: 55px; 210 | } 211 | .intro-header .post-heading .subheading { 212 | font-size: 30px; 213 | } 214 | } 215 | .post-preview > a { 216 | color: #404040; 217 | } 218 | .post-preview > a:hover, 219 | .post-preview > a:focus { 220 | text-decoration: none; 221 | color: #0085a1; 222 | } 223 | .post-preview > a > .post-title { 224 | font-size: 30px; 225 | margin-top: 30px; 226 | margin-bottom: 10px; 227 | } 228 | .post-preview > a > .post-subtitle { 229 | margin: 0; 230 | font-weight: 300; 231 | margin-bottom: 10px; 232 | } 233 | .post-preview > .post-meta { 234 | color: #808080; 235 | font-size: 18px; 236 | font-style: italic; 237 | margin-top: 0; 238 | } 239 | .post-preview > .post-meta > a { 240 | text-decoration: none; 241 | color: #404040; 242 | } 243 | .post-preview > .post-meta > a:hover, 244 | .post-preview > .post-meta > a:focus { 245 | color: #0085a1; 246 | text-decoration: underline; 247 | } 248 | @media only screen and (min-width: 768px) { 249 | .post-preview > a > .post-title { 250 | font-size: 36px; 251 | } 252 | } 253 | .section-heading { 254 | font-size: 36px; 255 | margin-top: 60px; 256 | font-weight: 700; 257 | } 258 | .caption { 259 | /*text-align: center;*/ 260 | font-size: 14px; 261 | padding: 10px; 262 | /*font-style: italic;*/ 263 | margin: 0; 264 | display: block; 265 | border-bottom-right-radius: 5px; 266 | border-bottom-left-radius: 5px; 267 | } 268 | .caption p { 269 | margin: 5px 0; 270 | } 271 | footer { 272 | padding: 50px 0 65px; 273 | } 274 | footer .list-inline { 275 | margin: 0; 276 | padding: 0; 277 | } 278 | footer .copyright { 279 | font-size: 14px; 280 | text-align: center; 281 | margin-bottom: 0; 282 | } 283 | .floating-label-form-group { 284 | font-size: 14px; 285 | position: relative; 286 | margin-bottom: 0; 287 | padding-bottom: 0.5em; 288 | border-bottom: 1px solid #eeeeee; 289 | } 290 | .floating-label-form-group input, 291 | .floating-label-form-group textarea { 292 | z-index: 1; 293 | position: relative; 294 | padding-right: 0; 295 | padding-left: 0; 296 | border: none; 297 | border-radius: 0; 298 | font-size: 1.5em; 299 | background: none; 300 | box-shadow: none !important; 301 | resize: none; 302 | } 303 | .floating-label-form-group label { 304 | display: block; 305 | z-index: 0; 306 | position: relative; 307 | top: 2em; 308 | margin: 0; 309 | font-size: 0.85em; 310 | line-height: 1.764705882em; 311 | vertical-align: middle; 312 | vertical-align: baseline; 313 | opacity: 0; 314 | -webkit-transition: top 0.3s ease,opacity 0.3s ease; 315 | -moz-transition: top 0.3s ease,opacity 0.3s ease; 316 | -ms-transition: top 0.3s ease,opacity 0.3s ease; 317 | transition: top 0.3s ease,opacity 0.3s ease; 318 | } 319 | .floating-label-form-group::not(:first-child) { 320 | padding-left: 14px; 321 | border-left: 1px solid #eeeeee; 322 | } 323 | .floating-label-form-group-with-value label { 324 | top: 0; 325 | opacity: 1; 326 | } 327 | .floating-label-form-group-with-focus label { 328 | color: #0085a1; 329 | } 330 | form .row:first-child .floating-label-form-group { 331 | border-top: 1px solid #eeeeee; 332 | } 333 | .btn { 334 | font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, "STHeiti Light", "Microsoft YaHei", 'Hiragino Sans GB', 'SimHei', sans-serif; 335 | text-transform: uppercase; 336 | font-size: 14px; 337 | font-weight: 800; 338 | letter-spacing: 1px; 339 | border-radius: 0; 340 | padding: 15px 25px; 341 | } 342 | .btn-lg { 343 | font-size: 16px; 344 | padding: 25px 35px; 345 | } 346 | .btn-default:hover, 347 | .btn-default:focus { 348 | background-color: #0085a1; 349 | border: 1px solid #0085a1; 350 | color: white; 351 | } 352 | .pager { 353 | margin: 20px 0 0; 354 | } 355 | .pager li > a, 356 | .pager li > span { 357 | font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, "STHeiti Light", "Microsoft YaHei", 'Hiragino Sans GB', 'SimHei', sans-serif; 358 | text-transform: uppercase; 359 | font-size: 14px; 360 | font-weight: 800; 361 | letter-spacing: 1px; 362 | padding: 15px 25px; 363 | background-color: white; 364 | border-radius: 0; 365 | } 366 | .pager li > a:hover, 367 | .pager li > a:focus { 368 | color: white; 369 | background-color: #0085a1; 370 | border: 1px solid #0085a1; 371 | } 372 | .pager .disabled > a, 373 | .pager .disabled > a:hover, 374 | .pager .disabled > a:focus, 375 | .pager .disabled > span { 376 | color: #808080; 377 | background-color: #404040; 378 | cursor: not-allowed; 379 | } 380 | ::-moz-selection { 381 | color: white; 382 | text-shadow: none; 383 | background: #0085a1; 384 | } 385 | ::selection { 386 | color: white; 387 | text-shadow: none; 388 | background: #0085a1; 389 | } 390 | img { 391 | max-width:100%; 392 | max-height:100%; 393 | } 394 | img::selection { 395 | color: white; 396 | background: transparent; 397 | } 398 | img::-moz-selection { 399 | color: white; 400 | background: transparent; 401 | } 402 | body { 403 | webkit-tap-highlight-color: #0085a1; 404 | line-height:1.8; 405 | } 406 | -------------------------------------------------------------------------------- /blog/static/css/mayblog.css: -------------------------------------------------------------------------------- 1 | .category-list{ 2 | border: 0px; 3 | } 4 | 5 | .group-list{ 6 | border: 0px; 7 | } -------------------------------------------------------------------------------- /blog/static/img/about-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flyhigher139/mayblog/d4434059291fc4a4d584d093c99d5f7ecb2f3598/blog/static/img/about-bg.jpg -------------------------------------------------------------------------------- /blog/static/img/contact-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flyhigher139/mayblog/d4434059291fc4a4d584d093c99d5f7ecb2f3598/blog/static/img/contact-bg.jpg -------------------------------------------------------------------------------- /blog/static/img/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flyhigher139/mayblog/d4434059291fc4a4d584d093c99d5f7ecb2f3598/blog/static/img/favicon-16x16.png -------------------------------------------------------------------------------- /blog/static/img/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flyhigher139/mayblog/d4434059291fc4a4d584d093c99d5f7ecb2f3598/blog/static/img/favicon-32x32.png -------------------------------------------------------------------------------- /blog/static/img/favicon-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flyhigher139/mayblog/d4434059291fc4a4d584d093c99d5f7ecb2f3598/blog/static/img/favicon-96x96.png -------------------------------------------------------------------------------- /blog/static/img/home-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flyhigher139/mayblog/d4434059291fc4a4d584d093c99d5f7ecb2f3598/blog/static/img/home-bg.jpg -------------------------------------------------------------------------------- /blog/static/img/post-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flyhigher139/mayblog/d4434059291fc4a4d584d093c99d5f7ecb2f3598/blog/static/img/post-bg.jpg -------------------------------------------------------------------------------- /blog/static/img/post-sample-image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/flyhigher139/mayblog/d4434059291fc4a4d584d093c99d5f7ecb2f3598/blog/static/img/post-sample-image.jpg -------------------------------------------------------------------------------- /blog/static/js/bootstrap-tagsinput.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | * bootstrap-tagsinput v0.4.2 by Tim Schlechter 3 | * 4 | */ 5 | 6 | !function(a){"use strict";function b(b,c){this.itemsArray=[],this.$element=a(b),this.$element.hide(),this.isSelect="SELECT"===b.tagName,this.multiple=this.isSelect&&b.hasAttribute("multiple"),this.objectItems=c&&c.itemValue,this.placeholderText=b.hasAttribute("placeholder")?this.$element.attr("placeholder"):"",this.inputSize=Math.max(1,this.placeholderText.length),this.$container=a('
'),this.$input=a('').appendTo(this.$container),this.$element.after(this.$container);var d=(this.inputSize<3?3:this.inputSize)+"em";this.$input.get(0).style.cssText="width: "+d+" !important;",this.build(c)}function c(a,b){if("function"!=typeof a[b]){var c=a[b];a[b]=function(a){return a[c]}}}function d(a,b){if("function"!=typeof a[b]){var c=a[b];a[b]=function(){return c}}}function e(a){return a?i.text(a).html():""}function f(a){var b=0;if(document.selection){a.focus();var c=document.selection.createRange();c.moveStart("character",-a.value.length),b=c.text.length}else(a.selectionStart||"0"==a.selectionStart)&&(b=a.selectionStart);return b}function g(b,c){var d=!1;return a.each(c,function(a,c){if("number"==typeof c&&b.which===c)return d=!0,!1;if(b.which===c.which){var e=!c.hasOwnProperty("altKey")||b.altKey===c.altKey,f=!c.hasOwnProperty("shiftKey")||b.shiftKey===c.shiftKey,g=!c.hasOwnProperty("ctrlKey")||b.ctrlKey===c.ctrlKey;if(e&&f&&g)return d=!0,!1}}),d}var h={tagClass:function(){return"label label-info"},itemValue:function(a){return a?a.toString():a},itemText:function(a){return this.itemValue(a)},freeInput:!0,addOnBlur:!0,maxTags:void 0,maxChars:void 0,confirmKeys:[13,44],onTagExists:function(a,b){b.hide().fadeIn()},trimValue:!1,allowDuplicates:!1};b.prototype={constructor:b,add:function(b,c){var d=this;if(!(d.options.maxTags&&d.itemsArray.length>=d.options.maxTags||b!==!1&&!b)){if("string"==typeof b&&d.options.trimValue&&(b=a.trim(b)),"object"==typeof b&&!d.objectItems)throw"Can't add objects when itemValue option is not set";if(!b.toString().match(/^\s*$/)){if(d.isSelect&&!d.multiple&&d.itemsArray.length>0&&d.remove(d.itemsArray[0]),"string"==typeof b&&"INPUT"===this.$element[0].tagName){var f=b.split(",");if(f.length>1){for(var g=0;gd.options.maxInputLength)){var l=a.Event("beforeItemAdd",{item:b,cancel:!1});if(d.$element.trigger(l),!l.cancel){d.itemsArray.push(b);var m=a(''+e(i)+'');if(m.data("item",b),d.findInputWrapper().before(m),m.after(" "),d.isSelect&&!a('option[value="'+encodeURIComponent(h)+'"]',d.$element)[0]){var n=a("");n.data("item",b),n.attr("value",h),d.$element.append(n)}c||d.pushVal(),(d.options.maxTags===d.itemsArray.length||d.items().toString().length===d.options.maxInputLength)&&d.$container.addClass("bootstrap-tagsinput-max"),d.$element.trigger(a.Event("itemAdded",{item:b}))}}}else if(d.options.onTagExists){var o=a(".tag",d.$container).filter(function(){return a(this).data("item")===k});d.options.onTagExists(b,o)}}}},remove:function(b,c){var d=this;if(d.objectItems&&(b="object"==typeof b?a.grep(d.itemsArray,function(a){return d.options.itemValue(a)==d.options.itemValue(b)}):a.grep(d.itemsArray,function(a){return d.options.itemValue(a)==b}),b=b[b.length-1]),b){var e=a.Event("beforeItemRemove",{item:b,cancel:!1});if(d.$element.trigger(e),e.cancel)return;a(".tag",d.$container).filter(function(){return a(this).data("item")===b}).remove(),a("option",d.$element).filter(function(){return a(this).data("item")===b}).remove(),-1!==a.inArray(b,d.itemsArray)&&d.itemsArray.splice(a.inArray(b,d.itemsArray),1)}c||d.pushVal(),d.options.maxTags>d.itemsArray.length&&d.$container.removeClass("bootstrap-tagsinput-max"),d.$element.trigger(a.Event("itemRemoved",{item:b}))},removeAll:function(){var b=this;for(a(".tag",b.$container).remove(),a("option",b.$element).remove();b.itemsArray.length>0;)b.itemsArray.pop();b.pushVal()},refresh:function(){var b=this;a(".tag",b.$container).each(function(){var c=a(this),d=c.data("item"),f=b.options.itemValue(d),g=b.options.itemText(d),h=b.options.tagClass(d);if(c.attr("class",null),c.addClass("tag "+e(h)),c.contents().filter(function(){return 3==this.nodeType})[0].nodeValue=e(g),b.isSelect){var i=a("option",b.$element).filter(function(){return a(this).data("item")===d});i.attr("value",f)}})},items:function(){return this.itemsArray},pushVal:function(){var b=this,c=a.map(b.items(),function(a){return b.options.itemValue(a).toString()});b.$element.val(c,!0).trigger("change")},build:function(b){var e=this;if(e.options=a.extend({},h,b),e.objectItems&&(e.options.freeInput=!1),c(e.options,"itemValue"),c(e.options,"itemText"),d(e.options,"tagClass"),e.options.typeahead){var i=e.options.typeahead||{};d(i,"source"),e.$input.typeahead(a.extend({},i,{source:function(b,c){function d(a){for(var b=[],d=0;d$1")}}))}if(e.options.typeaheadjs){var j=e.options.typeaheadjs||{};e.$input.typeahead(null,j).on("typeahead:selected",a.proxy(function(a,b){e.add(j.valueKey?b[j.valueKey]:b),e.$input.typeahead("val","")},e))}e.$container.on("click",a.proxy(function(){e.$element.attr("disabled")||e.$input.removeAttr("disabled"),e.$input.focus()},e)),e.options.addOnBlur&&e.options.freeInput&&e.$input.on("focusout",a.proxy(function(){0===a(".typeahead, .twitter-typeahead",e.$container).length&&(e.add(e.$input.val()),e.$input.val(""))},e)),e.$container.on("keydown","input",a.proxy(function(b){var c=a(b.target),d=e.findInputWrapper();if(e.$element.attr("disabled"))return void e.$input.attr("disabled","disabled");switch(b.which){case 8:if(0===f(c[0])){var g=d.prev();g&&e.remove(g.data("item"))}break;case 46:if(0===f(c[0])){var h=d.next();h&&e.remove(h.data("item"))}break;case 37:var i=d.prev();0===c.val().length&&i[0]&&(i.before(d),c.focus());break;case 39:var j=d.next();0===c.val().length&&j[0]&&(j.after(d),c.focus())}{var k=c.val().length;Math.ceil(k/5)}c.attr("size",Math.max(this.inputSize,c.val().length))},e)),e.$container.on("keypress","input",a.proxy(function(b){var c=a(b.target);if(e.$element.attr("disabled"))return void e.$input.attr("disabled","disabled");var d=c.val(),f=e.options.maxChars&&d.length>=e.options.maxChars;e.options.freeInput&&(g(b,e.options.confirmKeys)||f)&&(e.add(f?d.substr(0,e.options.maxChars):d),c.val(""),b.preventDefault());{var h=c.val().length;Math.ceil(h/5)}c.attr("size",Math.max(this.inputSize,c.val().length))},e)),e.$container.on("click","[data-role=remove]",a.proxy(function(b){e.$element.attr("disabled")||e.remove(a(b.target).closest(".tag").data("item"))},e)),e.options.itemValue===h.itemValue&&("INPUT"===e.$element[0].tagName?e.add(e.$element.val()):a("option",e.$element).each(function(){e.add(a(this).attr("value"),!0)}))},destroy:function(){var a=this;a.$container.off("keypress","input"),a.$container.off("click","[role=remove]"),a.$container.remove(),a.$element.removeData("tagsinput"),a.$element.show()},focus:function(){this.$input.focus()},input:function(){return this.$input},findInputWrapper:function(){for(var b=this.$input[0],c=this.$container[0];b&&b.parentNode!==c;)b=b.parentNode;return a(b)}},a.fn.tagsinput=function(c,d){var e=[];return this.each(function(){var f=a(this).data("tagsinput");if(f)if(c||d){if(void 0!==f[c]){var g=f[c](d);void 0!==g&&e.push(g)}}else e.push(f);else f=new b(this,c),a(this).data("tagsinput",f),e.push(f),"SELECT"===this.tagName&&a("option",a(this)).attr("selected","selected"),a(this).val(a(this).val())}),"string"==typeof c?e.length>1?e:e[0]:e},a.fn.tagsinput.Constructor=b;var i=a("
");a(function(){a("input[data-role=tagsinput], select[multiple][data-role=tagsinput]").tagsinput()})}(window.jQuery); 7 | //# sourceMappingURL=bootstrap-tagsinput.min.js.map -------------------------------------------------------------------------------- /blog/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | logfile = /tmp/supervisord.log 3 | logfile_maxbytes = 50MB 4 | logfile_backups=10 5 | loglevel = info 6 | pidfile = /tmp/supervisord.pid 7 | nodaemon = false 8 | minfds = 1024 9 | minprocs = 200 10 | umask = 022 11 | user = root 12 | identifier = supervisor 13 | directory = /tmp 14 | nocleanup = true 15 | childlogdir = /tmp 16 | strip_ansi = false 17 | 18 | # [program:app-migration] 19 | # command = /usr/bin/python2.7 /usr/src/app/manage.py makemigrations 20 | # autostart=true 21 | # autorestart=false 22 | 23 | # [program:app-migrate] 24 | # command = /usr/bin/python2.7 /usr/src/app/manage.py migrate 25 | # autostart=true 26 | # autorestart=false 27 | 28 | [program:app-uwsgi] 29 | command = /usr/local/bin/uwsgi --ini /usr/src/app/mayblog_uwsgi.ini 30 | autostart=true 31 | autorestart=true 32 | stdout_logfile=/var/log/supervisor/%(program_name)s.log 33 | stderr_logfile=/var/log/supervisor/%(program_name)s.log 34 | 35 | [program:nginx-app] 36 | command = service nginx start 37 | autostart=true 38 | autorestart=true 39 | stdout_logfile=/var/log/supervisor/%(program_name)s.log 40 | stderr_logfile=/var/log/supervisor/%(program_name)s.log 41 | 42 | -------------------------------------------------------------------------------- /blog/templates/403.html: -------------------------------------------------------------------------------- 1 | {% extends admin_base.html %} 2 | {% block title %}403 forbidden{% endblock %} 3 | 4 | {% block main %} 5 |

You are forbidden to visit the page.

6 | {% endblock %} -------------------------------------------------------------------------------- /blog/templates/accounts/group.html: -------------------------------------------------------------------------------- 1 | {% extends 'admin_base.html' %} 2 | 3 | {% block main %} 4 |
5 |
6 |
7 |

Group Details   8 | 9 |

10 |
11 |

: {{ group.name }}

12 |
13 |
14 |

Users

15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | {% for user in users %} 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 42 | 43 | {% empty %} 44 | 45 | {% endfor %} 46 | 47 |
No.UsernameEmailIs ActiveLast LoginCreate DateRemove out
{{ forloop.counter }}{{ user.username }}{{ user.email }}{{ user.is_active }}{{ user.last_login|date:"M d, Y" }}{{ user.date_joined|date:"M d, Y" }} 38 | 40 | 41 |
No user yet
48 |
49 |
50 |
51 |

Permissions

52 |
53 |
    54 | {% for permission in permissions %} 55 |
  • {{ permission.name }}
  • 56 | {% empty %} 57 |

    No permission yet!

    58 | {% endfor %} 59 |
60 |
61 | 62 |
63 | {% endblock %} -------------------------------------------------------------------------------- /blog/templates/accounts/groups.html: -------------------------------------------------------------------------------- 1 | {% extends "admin_base.html" %} 2 | {% block title %}Groups{% endblock %} 3 | 4 | {% block main %} 5 | 6 |
7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | {% for group in groups %} 18 | 19 | 20 | 21 | 24 | 25 | {% empty %} 26 | 27 | {% endfor %} 28 | 29 |
No.Group NameActions
{{ forloop.counter }}{{ group.name }} 22 | 23 |
No group yet
30 | 31 | 32 | 33 | 34 |
35 | {% endblock %} 36 | 37 | -------------------------------------------------------------------------------- /blog/templates/accounts/login.html: -------------------------------------------------------------------------------- 1 | {% extends "admin_base.html" %} 2 | 3 | {% block title %}Login{% endblock %} 4 | 5 | 6 | {% block main %} 7 | {% load bootstrap3 %} 8 |
9 |
10 |
11 |
12 | {% csrf_token %} 13 | {% bootstrap_form form %} 14 | 15 |
16 |
17 |
18 |
19 | 20 | {% endblock %} -------------------------------------------------------------------------------- /blog/templates/accounts/settings_profile.html: -------------------------------------------------------------------------------- 1 | {% extends 'admin_base.html' %} 2 | 3 | {% block title %}Profile{% endblock %} 4 | 5 | {% block main %} 6 | {% load bootstrap3 %} 7 | 8 |
9 |
10 | 14 | 15 |
16 | 17 |
18 |
19 | {% csrf_token %} 20 | {% bootstrap_form form %} 21 | 22 |
23 |
24 | 25 |
26 |
27 | {% endblock %} -------------------------------------------------------------------------------- /blog/templates/accounts/simple_form.html: -------------------------------------------------------------------------------- 1 | {% extends "admin_base.html" %} 2 | 3 | {% block title %}{{ title }}{% endblock %} 4 | 5 | 6 | {% block main %} 7 | {% load bootstrap3 %} 8 |
9 |
10 |
11 |
12 | {% csrf_token %} 13 | {% bootstrap_form form %} 14 | 21 |
22 |
23 |
24 |
25 | 26 | {% endblock %} -------------------------------------------------------------------------------- /blog/templates/accounts/user.html: -------------------------------------------------------------------------------- 1 | {% extends 'admin_base.html' %} 2 | 3 | {% block main %} 4 |
5 |
6 |

User Details   7 | 8 |

9 |
10 |

: {{ user.username }}

11 |

{{ user.email }}

12 |

{{ user.is_active}}

13 |

{{ user.is_staff}}

14 |

{{ user.is_superuser}}

15 |

{{ user.last_login}}

16 |

{{ user.date_joined }}

17 |
18 |
19 |

User Groups

20 |
21 |
    22 | {% for group in groups %} 23 |
  • {{ group.name }}
  • 24 | {% empty %} 25 |

    No group yet!

    26 | {% endfor %} 27 |
28 |
29 |
30 |

User Permissions

31 |
32 |
    33 | {% for permission in permissions %} 34 |
  • {{ permission.name }}
  • 35 | {% empty %} 36 |

    No permission yet!

    37 | {% endfor %} 38 |
39 |
40 | 41 |
{% endblock %} -------------------------------------------------------------------------------- /blog/templates/accounts/user_edit.html: -------------------------------------------------------------------------------- 1 | {% extends 'admin_base.html' %} 2 | {% block title %} Edit User {% endblock %} 3 | 4 | {% load bootstrap3 %} 5 | 6 | {% block main %} 7 |
8 |
9 |

User Details

10 |
11 |
12 | {% csrf_token %} 13 | {% bootstrap_form user_form %} 14 | {% if user.is_superuser %} 15 |
16 | 19 |
20 |
21 | 24 |
25 | {% endif %} 26 | 27 |
28 |
29 |
30 |

Groups

31 |
32 |
33 | {% csrf_token %} 34 | {% bootstrap_form user_group_form %}{{groups}} 35 | 36 |
37 |
38 | 39 |
40 | 41 | {% endblock %} -------------------------------------------------------------------------------- /blog/templates/accounts/users.html: -------------------------------------------------------------------------------- 1 | {% extends "admin_base.html" %} 2 | {% block title %}Users{% endblock %} 3 | 4 | {% block main %} 5 | {% load bootstrap3 %} 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | {% for user in users %} 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 34 | 35 | {% empty %} 36 | 37 | {% endfor %} 38 | 39 |
No.UsernameEmailIs ActiveLast LoginCreate DateActions
{{ forloop.counter }}{{ user.username }}{{ user.email }}{{ user.is_active }}{{ user.last_login|date:"M d, Y" }}{{ user.date_joined|date:"M d, Y" }} 30 | 31 |   32 | 33 |
No user yet
40 | 41 | {% bootstrap_pagination users %} 42 | 43 |
44 |
45 | 46 |

Filter By Group

47 |
48 |
49 | All 50 | {% for group in groups %} 51 | {{ group.name }} 52 | {% endfor %} 53 |
54 |
55 |
56 | {% endblock %} 57 | 58 | {% block js %} 59 | 76 | {% endblock %} 77 | -------------------------------------------------------------------------------- /blog/templates/admin_base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | {% block title %}May Blog Admin{% endblock %} 13 | 14 | {% load static %} 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | {# Load the tag library #} 25 | {% load bootstrap3 %} 26 | 27 | 28 | 29 | {# Display django.contrib.messages as Bootstrap alerts #} 30 | {% bootstrap_messages FIXTHIS %} 31 | 32 | 33 | 34 | {% block css %}{% endblock %} 35 | 36 | 37 | 38 | 39 | 40 | 41 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 146 | 147 | 148 | 149 | {%block header %}{% endblock %} 150 | 151 |
152 | 153 | 154 | 155 | {%block main %}{% endblock %} 156 | 157 |
158 | 159 |
160 | 161 | 162 | 163 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | {% block js %} 209 | {% endblock %} 210 | 211 | 212 | 213 | 214 | 215 | -------------------------------------------------------------------------------- /blog/templates/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | {% block title %}May Blog{% endblock %} 19 | 20 | {% load static %} 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 95 | 96 | 97 | 98 | {%block header %}{% endblock %} 99 | 100 | 101 | {%block main %}{% endblock %} 102 | 103 | 104 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | {% block js %} 153 | {% endblock %} 154 | 155 | 156 | 157 | 158 | -------------------------------------------------------------------------------- /blog/templates/blog_admin/category.html: -------------------------------------------------------------------------------- 1 | {% extends "admin_base.html" %} 2 | {% block title %}Admin Category{% endblock %} 3 | 4 | {% block main %} 5 | 6 | {% load bootstrap3 %} 7 | 8 |
9 | 10 |
11 | {% csrf_token %} 12 | 13 | {% bootstrap_form form %} 14 | 15 | 16 |
17 | 18 | 19 | 20 |
21 | 22 |
23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | {% for category in catagories %} 37 | 38 | 39 | 40 | 45 | 46 | {% endfor %} 47 | 48 |
No.nameActions
{{ forloop.counter }}{{ category.name }} 41 | 42 |   43 | 44 |
49 | 50 | {% bootstrap_pagination catagories %} 51 | 52 | 53 | 54 |
55 | {% endblock %} 56 | 57 | {% block js %} 58 | 102 | {% endblock %} 103 | -------------------------------------------------------------------------------- /blog/templates/blog_admin/index.html: -------------------------------------------------------------------------------- 1 | {% extends 'admin_base.html' %} 2 | {% block title %}May Blog Admin {% endblock %} 3 | 4 | {%block main %} 5 | 6 |
7 |
8 |

9 | Blog Meta Data   10 | {% if perms.main.change_blogmeta %} 11 | 12 | {% endif %} 13 |

14 |
15 |
16 |
Blog Name:
17 |
{{ site_info.title }}
18 |
19 |
20 |
Blog Subtitle:
21 |
{{ site_info.subtitle }}
22 |
23 |
24 |
Blog Description:
25 |
{{ site_info.desc }}
26 |
27 |
28 |
Blog Owner:
29 |
{{ site_info.author }}
30 |
31 |
32 |
Blog Keywords:
33 |
{{ site_info.keywords }}
34 |
35 |
36 |
37 |

38 | About User   39 | 40 |

41 |
42 |
43 |
Username Name:
44 |
{{account_info.username}}
45 |
46 |
47 |
Display Name:
48 |
{{account_info.display_name}}
49 |
50 |
51 |
Biography:
52 |
{{account_info.biography}}
53 |
54 |
55 |
Social Network:
56 |
57 | {% if account_info.github %} 58 | 59 | {% endif %} 60 | 61 | {% if account_info.twitter %} 62 | 63 | {% endif %} 64 | 65 | {% if account_info.weibo %} 66 | 67 | {% endif %} 68 | 69 |
70 |
71 |
72 |
Homepage:
73 |
74 | {% if account_info.homepage %} 75 | {{ account_info.homepage }} 76 | {% endif %} 77 |
78 |
79 |
80 |
81 | 82 | {% endblock %} -------------------------------------------------------------------------------- /blog/templates/blog_admin/page.html: -------------------------------------------------------------------------------- 1 | {% extends "admin_base.html" %} 2 | {% load static %} 3 | 4 | {% block title %} 5 | {% if edit_flag %} 6 | Edit Post 7 | {% else %} 8 | New Post 9 | {% endif %} 10 | {% endblock %} 11 | 12 | {% block css %} 13 | 14 | {% endblock %} 15 | 16 | 17 | {% block main %} 18 | {% load bootstrap3 %} 19 |
20 | {% csrf_token %} 21 |
22 |
23 |
24 | 25 | {% bootstrap_form form %} 26 | 27 | 28 | 29 | 30 | 31 |
32 |
33 |
34 |
35 | {% endblock %} 36 | 37 | 38 | {% block js %} 39 | 40 | {% endblock %} -------------------------------------------------------------------------------- /blog/templates/blog_admin/pages.html: -------------------------------------------------------------------------------- 1 | {% extends "admin_base.html" %} 2 | {% block title %}Posts{% endblock %} 3 | 4 | {% block main %} 5 | {% load bootstrap3 %} 6 |
7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | {% for post in posts %} 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 36 | 37 | {% empty %} 38 | 39 | {% endfor %} 40 | 41 | 42 |
No.TitleSlugAuthorPublish DateUpdate DateActions
{{ forloop.counter }}{{ post.title }}{{ post.slug }}{{ post.author }}{{ post.pub_time }}{{ post.update_time }} 32 | 33 |   34 | 35 |
No pages yet
43 | 44 | {% bootstrap_pagination posts %} 45 | 46 | 47 | 48 |
49 | {% endblock %} 50 | 51 | {% block js %} 52 | 69 | {% endblock %} 70 | -------------------------------------------------------------------------------- /blog/templates/blog_admin/post.html: -------------------------------------------------------------------------------- 1 | {% extends "admin_base.html" %} 2 | {% load static %} 3 | 4 | {% block title %} 5 | {% if edit_flag %} 6 | Edit Post 7 | {% else %} 8 | New Post 9 | {% endif %} 10 | {% endblock %} 11 | 12 | {% block css %} 13 | 14 | {% endblock %} 15 | 16 | 17 | {% block main %} 18 | {% load bootstrap3 %} 19 |
20 | {% csrf_token %} 21 |
22 |
23 |
24 | {% bootstrap_form form %} 25 |
26 | 27 |
28 |
29 |

Tags

30 |
31 | 37 |
38 | 39 | 40 |
41 |

Category

42 |
43 | 49 |
50 |
51 |



52 |
53 | {% if perms.main.add_tag %} 54 | 55 | 56 | {% endif %} 57 | 58 | 59 |
60 | 61 |
62 |
63 | 64 | 65 | 66 | 67 | 68 |
69 | {% endblock %} 70 | 71 | 72 | {% block js %} 73 | 74 | 138 | {% endblock %} -------------------------------------------------------------------------------- /blog/templates/blog_admin/posts.html: -------------------------------------------------------------------------------- 1 | {% extends "admin_base.html" %} 2 | {% block title %}Posts{% endblock %} 3 | 4 | {% block main %} 5 | {% load bootstrap3 %} 6 |
7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | {% for post in posts %} 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 36 | 37 | {% empty %} 38 | 39 | {% endfor %} 40 | 41 |
No.TitleAbstractAuthorPublish DateUpdate DateActions
{{ forloop.counter }}{{ post.title }}{{ post.abstract }}{{ post.author.account.display_name }}{{ post.pub_time }}{{ post.update_time }} 32 | 33 |   34 | 35 |
No posts yet
42 | 43 | {% bootstrap_pagination posts %} 44 | 45 | 46 | 47 |
48 | {% endblock %} 49 | 50 | {% block js %} 51 | 68 | {% endblock %} 69 | -------------------------------------------------------------------------------- /blog/templates/blog_admin/tags.html: -------------------------------------------------------------------------------- 1 | {% extends "admin_base.html" %} 2 | {% block title %}Admin Tags{% endblock %} 3 | 4 | {% block main %} 5 | {% load bootstrap3 %} 6 | 7 |
8 | 9 |
10 | {% csrf_token %} 11 | 12 | {% bootstrap_form form %} 13 | 14 | 15 | (Seperate tags with ",") 16 |
17 | 18 | 19 | 20 | 21 |
22 | 23 |
24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | {% for tag in tags %} 39 | 40 | 41 | 42 | 47 | 48 | {% endfor %} 49 | 50 |
No.nameActions
{{ forloop.counter }}{{ tag.name }} 43 | 44 |   45 | 46 |
51 | 52 | {% bootstrap_pagination tags %} 53 | 54 | 55 | 56 |
57 | {% endblock %} 58 | 59 | {% block js %} 60 | 119 | {% endblock %} 120 | -------------------------------------------------------------------------------- /blog/templates/main/about.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Clean Blog - About 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 71 | 72 | 73 | 74 |
75 |
76 |
77 |
78 |
79 |

About Me

80 |
81 | This is what I do. 82 |
83 |
84 |
85 |
86 |
87 | 88 | 89 |
90 |
91 |
92 |

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Saepe nostrum ullam eveniet pariatur voluptates odit, fuga atque ea nobis sit soluta odio, adipisci quas excepturi maxime quae totam ducimus consectetur?

93 |

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eius praesentium recusandae illo eaque architecto error, repellendus iusto reprehenderit, doloribus, minus sunt. Numquam at quae voluptatum in officia voluptas voluptatibus, minus!

94 |

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nostrum molestiae debitis nobis, quod sapiente qui voluptatum, placeat magni repudiandae accusantium fugit quas labore non rerum possimus, corrupti enim modi! Et.

95 |
96 |
97 |
98 | 99 |
100 | 101 | 102 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /blog/templates/main/archive.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | {% block title %} {{ seo.title }} | Archive {% endblock %} 3 | 4 | {% load static %} 5 | {% load bootstrap3 %} 6 | {% block header %} 7 |
8 |
9 |
10 |
11 |
12 |

{{ seo.title }}

13 |
14 | {{ seo.subtitle }} 15 |
16 |
17 |
18 |
19 |
20 | {% endblock %} 21 | 22 | {% block main %} 23 |
24 |
25 |
26 | {% for post in posts %} 27 |
28 |
29 | 30 |
31 |

{{ post.title }}


32 |

Abstract: {{ post.abstract }}

33 |

Author: {{ post.author }}

34 |

Date: {{ post.pub_time|date:'m/d/Y' }}

35 | 36 |
37 |
38 |
39 | {% endfor %} 40 |
41 |
{% bootstrap_pagination posts %}
42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 |
52 | 53 | 54 | 55 |
56 | 57 | {% endblock %} 58 | 59 | {% block js %} 60 | {% endblock %} 61 | -------------------------------------------------------------------------------- /blog/templates/main/author.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | {% block title %} Author | {{ user.account.display_name }} {% endblock %} 3 | 4 | {% load static %} 5 | {% block header %} 6 |
7 |
8 |
9 | 10 |
11 |
12 |

{{ seo.title }}

13 |
14 | {{ seo.subtitle }} 15 |
16 |
17 |
18 |
19 |
20 | 21 | {% endblock %} 22 | 23 | {% block main %} 24 |
25 |
26 |
27 |
28 |
29 |

About Author

30 |
31 |
32 |
Display Name:
33 |
{{account_info.display_name}}
34 |
35 |
36 |
Biography:
37 |
{{account_info.biography}}
38 |
39 |
40 |
Social Network:
41 |
42 | {% if account_info.github %} 43 | 44 | {% endif %} 45 | 46 | {% if account_info.twitter %} 47 | 48 | {% endif %} 49 | 50 | {% if account_info.weibo %} 51 | 52 | {% endif %} 53 | 54 |
55 |
56 |
57 |
Homepage:
58 |
59 | {% if account_info.homepage %} 60 | {{ account_info.homepage }} 61 | {% endif %} 62 |
63 |
64 |
65 | 66 |
67 |
68 | 69 |
70 | 71 |
72 |

Articles


73 |
    74 | {% for post in posts %} 75 |
  • 76 | {{ post.title }} 77 | 78 |
  • 79 | {% empty %} 80 |

    81 | No articles found here 82 |

    83 | {% endfor %} 84 |
85 | 86 |
    87 | {% if posts.has_next %} 88 | 91 | {% endif %} 92 | {% if posts.has_previous %} 93 | 94 | {% endif %} 95 |
96 |
97 |
98 |
99 |
100 | 101 |
102 | 103 | {% endblock %} 104 | -------------------------------------------------------------------------------- /blog/templates/main/contact.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Clean Blog - Contact 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 71 | 72 | 73 | 74 |
75 |
76 |
77 |
78 |
79 |

Contact Me

80 |
81 | Have questions? I have answers (maybe). 82 |
83 |
84 |
85 |
86 |
87 | 88 | 89 |
90 |
91 |
92 |

Want to get in touch with me? Fill out the form below to send me a message and I will try to get back to you within 24 hours!

93 | 94 | 95 | 96 |
97 |
98 |
99 | 100 | 101 |

102 |
103 |
104 |
105 |
106 | 107 | 108 |

109 |
110 |
111 |
112 |
113 | 114 | 115 |

116 |
117 |
118 |
119 |
120 | 121 | 122 |

123 |
124 |
125 |
126 |
127 |
128 |
129 | 130 |
131 |
132 |
133 |
134 |
135 |
136 | 137 |
138 | 139 | 140 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | -------------------------------------------------------------------------------- /blog/templates/main/index.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% load static %} 4 | 5 | {% block title %}{{ seo.title }}{% endblock %} 6 | {% block header %} 7 |
8 |
9 |
10 |
11 |
12 |

{{ seo.title }}

13 |
14 | {{ seo.subtitle }} 15 |
16 |
17 |
18 |
19 |
20 | {% endblock %} 21 | 22 | {% block main %} 23 |
24 |
25 |
26 | {% for post in posts %} 27 |
28 | 29 |

30 | {{post.title}} 31 |

32 |
33 |

34 | {{post.abstract}} 35 |

36 | 37 | 38 |
39 | {% if not forloop.last %} 40 |
41 | {% endif %} 42 | {% empty %} 43 |

44 | No articles found here 45 |

46 | {% endfor %} 47 | 48 |
    49 | {% if posts.has_next %} 50 | 53 | {% endif %} 54 | {% if posts.has_previous %} 55 | 56 | {% endif %} 57 |
58 |
59 |
60 |

Search


61 |
62 |
63 | 64 |
65 |
66 | 67 | 68 |
69 |
70 | 71 |
72 | 73 |
74 | 75 |

Tags


76 | {% for tag in tags %} 77 | 92 |   93 | {% endfor %} 94 | 95 |

Category


96 |
97 | {% for category in catagories %} 98 | {% if category_id == category.id %} 99 | {{ category.name }} 100 | 101 |  {{category.num_posts}}  102 | {% else %} 103 | {{ category.name }} 104 |  {{category.num_posts}}  105 | {% endif %} 106 | 107 | {% endfor %} 108 |
109 | 110 | 127 | 128 |
129 |
130 |
131 | 132 |
133 | {% endblock %} 134 | 135 | {% block js %} 136 | 148 | {% endblock %} -------------------------------------------------------------------------------- /blog/templates/main/misc/duoshuo.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 16 | -------------------------------------------------------------------------------- /blog/templates/main/misc/jiathis_share.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 13 | 14 | -------------------------------------------------------------------------------- /blog/templates/main/page.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | {% block title %} 文章 {% endblock %} 3 | 4 | {% load static %} 5 | {% block header %} 6 |
7 |
8 |
9 |
10 |
11 |

{{page.title}}

12 | Posted by {{page.author.account.display_name}} on {{page.pub_time}} 13 |
14 |
15 |
16 |
17 |
18 | {% endblock %} 19 | 20 | {% block main %} 21 |
22 |
23 |
24 |
25 | {{page.content_html|safe}} 26 |
27 |
28 |
29 |
30 | 31 |
32 | 33 | {% endblock %} 34 | -------------------------------------------------------------------------------- /blog/templates/main/post.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | {% block title %} {{post.title}} {% endblock %} 3 | 4 | {% load static %} 5 | {% block header %} 6 |
7 |
8 |
9 |
10 |
11 |

{{post.title}}

12 | 13 | Posted by {{post.author.account.display_name}} on {{post.pub_time}} 14 | 15 | Category: 16 | {% if post.category %} 17 | {{post.category.name}} 18 | {% else %} 19 | None 20 | {% endif %} 21 | 22 | 23 | Tags: 24 | {% for tag in tags %} 25 | {{tag.name}}{% if not forloop.last%}, {% else %}{% endif %} 26 | {% empty %} 27 | None 28 | {% endfor %} 29 | 30 |
31 |
32 |
33 |
34 |
35 | {% endblock %} 36 | 37 | {% block main %} 38 |
39 |
40 | 41 |
42 |
43 | {{post.content_html|safe}} 44 |
45 |
46 | 47 |
48 |
49 | {{ jiathis_share }} 50 |
51 |
52 | 53 |
54 | 55 | {% if allow_donate %} 56 |
57 | 58 |
59 | 60 | | 61 | 62 |
63 | 64 | 67 |
68 | 69 | 70 |
71 | 72 | {% endif %} 73 | 74 | 75 |
76 | 77 |
78 | 79 | 80 |
81 | 82 | 83 | 84 |
85 | 86 |
87 |
88 | {{ comment_script }} 89 |
90 |
91 | 92 |
93 | 94 |
95 | 96 | {% endblock %} 97 | 98 | {% block js %} 99 | 116 | {% endblock %} 117 | -------------------------------------------------------------------------------- /blog/templates/main/simple_form.html: -------------------------------------------------------------------------------- 1 | {% extends "admin_base.html" %} 2 | 3 | {% block title %}{{ title }}{% endblock %} 4 | 5 | {% load static %} 6 | 7 | 8 | {% block main %} 9 | {% load bootstrap3 %} 10 |
11 |
12 |
13 |

{{ heading }}

14 |
15 |
16 | {% csrf_token %} 17 | {% bootstrap_form form %} 18 | 25 |
26 |
27 |
28 |
29 | 30 | {% endblock %} -------------------------------------------------------------------------------- /blog/test.py: -------------------------------------------------------------------------------- 1 | # test.py 2 | def application(env, start_response): 3 | start_response('200 OK', [('Content-Type','text/html')]) 4 | return ["Hello World"] # python2 5 | #return [b"Hello World"] # python3 -------------------------------------------------------------------------------- /blog/uwsgi_params: -------------------------------------------------------------------------------- 1 | uwsgi_param QUERY_STRING $query_string; 2 | uwsgi_param REQUEST_METHOD $request_method; 3 | uwsgi_param CONTENT_TYPE $content_type; 4 | uwsgi_param CONTENT_LENGTH $content_length; 5 | 6 | uwsgi_param REQUEST_URI $request_uri; 7 | uwsgi_param PATH_INFO $document_uri; 8 | uwsgi_param DOCUMENT_ROOT $document_root; 9 | uwsgi_param SERVER_PROTOCOL $server_protocol; 10 | uwsgi_param UWSGI_SCHEME $scheme; 11 | 12 | uwsgi_param REMOTE_ADDR $remote_addr; 13 | uwsgi_param REMOTE_PORT $remote_port; 14 | uwsgi_param SERVER_PORT $server_port; 15 | uwsgi_param SERVER_NAME $server_name; 16 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | blog: 4 | # restart: always 5 | image: gevin/mayblog:0.1.1 6 | ports: 7 | - "8000:8000" 8 | links: 9 | - postgres:postgres 10 | # volumes: 11 | # - /usr/src/app/static 12 | env_file: .env 13 | 14 | 15 | postgres: 16 | # restart: always 17 | image: postgres:9.5 18 | env_file: .env 19 | volumes: 20 | - /var/lib/postgres 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /preview.md: -------------------------------------------------------------------------------- 1 | MayBlog Preview 2 | =============== 3 | 4 | ## Frontend Website 5 | 6 | Click [here](http://blog.gevinzone.com) to view MayBlog's frontend. 7 | 8 | ## Backend System 9 | 10 | ### Home 11 | 12 | ![mayblog_home](http://7tsygu.com1.z0.glb.clouddn.com/mayblog_home.png) 13 | 14 | ### Posts 15 | 16 | ![mayblog_posts](http://7tsygu.com1.z0.glb.clouddn.com/mayblog_posts.png) 17 | 18 | ### New post 19 | 20 | ![mayblog_new_post](http://7tsygu.com1.z0.glb.clouddn.com/mayblog_new_post.png) 21 | 22 | ### Edit post 23 | 24 | ![mayblog_post_edit](http://7tsygu.com1.z0.glb.clouddn.com/mayblog_post_edit.png) 25 | 26 | ### Tags admin 27 | 28 | ![mayblog_tags](http://7tsygu.com1.z0.glb.clouddn.com/mayblog_tags.png) 29 | 30 | ### Category admin 31 | 32 | ![mayblog_categories](http://7tsygu.com1.z0.glb.clouddn.com/mayblog_categories.png) 33 | 34 | ### User admin 35 | 36 | ![mayblog_user_admin](http://7tsygu.com1.z0.glb.clouddn.com/mayblog_user_admin.png) 37 | 38 | ### User details 39 | 40 | ![mayblog_user_detail](http://7tsygu.com1.z0.glb.clouddn.com/mayblog_user_detail.png) 41 | 42 | ### User edit 43 | 44 | ![mayblog_user_edit](http://7tsygu.com1.z0.glb.clouddn.com/mayblog_user_edit.png) 45 | 46 | ### User group admin 47 | 48 | ![mayblog_user_group](http://7tsygu.com1.z0.glb.clouddn.com/mayblog_user_group.png) 49 | 50 | ### User group details 51 | 52 | ![mayblog_group_details](http://7tsygu.com1.z0.glb.clouddn.com/mayblog_group_details.png) 53 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | Welcome to May Blog 2 | ==================== 3 | [![](https://images.microbadger.com/badges/image/gevin/mayblog.svg)](http://microbadger.com/images/gevin/mayblog "Get your own image badge on microbadger.com") [![](https://images.microbadger.com/badges/version/gevin/mayblog.svg)](http://microbadger.com/images/gevin/mayblog "Get your own version badge on microbadger.com") 4 | 5 | > Notice: MayBlog is not deprecated, but currently I pay more attention to [OctBlog](https://github.com/flyhigher139/OctBlog) 6 | 7 | ## Why it named MayBlog? 8 | 9 | Just because it is a blog system started in May, 2015. MayBlog is vivid. 10 | 11 | :stuck_out_tongue: :stuck_out_tongue: :stuck_out_tongue: 12 | 13 | ## Features 14 | 15 | MayBlog is a blog system with following features: 16 | 17 | - Powered by django and bootstrap 18 | - Deployed by docker 19 | - Multiple deployment setting files 20 | - Search engine optimized 21 | - Blog features: 22 | - multi-user 23 | - multi-role 24 | - posts, pages, tags, and categories 25 | - markdown support 26 | - admin interface 27 | - RESTful API (under development) 28 | 29 | 30 | ## Preview MayBlog 31 | 32 | - [Frontend Website](http://blog.igevin.info/) 33 | - [Backend Admin Screenshot](preview.md) 34 | 35 | ## How to run it ? 36 | 37 | ### Run from source code 38 | 39 | If you want to see more about the source code, checkout the [source code readme](blog) 40 | 41 | 42 | ### Run by docker(recommended) 43 | 44 | Run MayBlog by docker is recommended, here are some instruction: 45 | 46 | #### First Run 47 | 48 | 1\. Use MayBlog image 49 | 50 | ```bash 51 | (sudo) docker pull gevin/mayblog 52 | ``` 53 | 54 | Or you can build your own MayBlog image 55 | ```bash 56 | (sudo) docker build -t mayblog . 57 | 58 | # Now you can take a cup of coffee and wait for a few minutes :) 59 | ``` 60 | 61 | 2\. Run MayBlog 62 | 63 | ```bash 64 | (sudo) docker-compose up -d 65 | ``` 66 | 67 | 3\. Get into MayBlog container and migrate database 68 | 69 | ```bash 70 | # Specify MayBlog container ID, eg:12345678 71 | (sudo) docker ps 72 | 73 | # Get into MayBlog container 74 | (sudo) docker exec -it 12345678 bash 75 | 76 | # Migrate datebase 77 | python manage.py migrate 78 | ``` 79 | 80 | #### After first run 81 | 82 | - Start MayBlog 83 | 84 | ```bash 85 | (sudo) docker-compose start 86 | ``` 87 | 88 | - Stop MayBlog 89 | 90 | ```bash 91 | (sudo) docker-compose stop 92 | ``` 93 | 94 | 95 | ### Initialize MayBlog 96 | 97 | When the blog is run, checkout `http://host:port/init` to initialize the system 98 | 99 | It will create the superuser, user groups(administrator, editor, writer, contributor, and reader), and assign permissions for each group. 100 | 101 | ## License 102 | 103 | MayBlog is under [GPL2](LICENSE) 104 | 105 | ## What's more 106 | 107 | If you find a bug or want to add a new feature, just issue me. 108 | Want to contribute? Please fork MayBlog and pull request to me. 109 | 110 | I'm not good at frontend development, so I used a free bootstrap blog theme. If you can redesign the blog theme and admin interface, I'll appriciate your work very much! 111 | 112 | --------------------------------------------------------------------------------