├── config.py
├── picture
├── blog.png
└── welcome.png
├── requirements.txt
├── app
├── models.py
├── templates
│ ├── archive.html
│ ├── read_more.html
│ ├── welcome.html
│ ├── post.html
│ ├── duo_shuo.html
│ └── base.html
├── __init__.py
├── views.py
└── static
│ ├── welcome.css
│ └── base.css
├── manage.py
├── LISENCE
├── README.md
└── .gitignore
/config.py:
--------------------------------------------------------------------------------
1 | MONGO_SETTINGS = {'DB' : 'pure_todo'}
--------------------------------------------------------------------------------
/picture/blog.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Andrew-liu/flask_pure/HEAD/picture/blog.png
--------------------------------------------------------------------------------
/picture/welcome.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Andrew-liu/flask_pure/HEAD/picture/welcome.png
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | Flask==0.10.1
2 | Flask-Markdown==0.3
3 | Flask-PyMongo==0.3.1
4 | Flask-Script==2.0.5
5 | Flask-WTF==0.11
6 | Jinja2==2.7.3
7 | Markdown==2.6.2
8 | MarkupSafe==0.23
9 | WTForms==2.0.2
10 | Werkzeug==0.10.4
11 | flask-mongoengine==0.7.1
12 | itsdangerous==0.24
13 | mongoengine==0.9.0
14 | pymongo==2.8
15 |
--------------------------------------------------------------------------------
/app/models.py:
--------------------------------------------------------------------------------
1 | from app import db
2 | import datetime
3 |
4 | class Post(db.Document):
5 | author = db.StringField(max_length=50)
6 | title = db.StringField(max_length=120, required=True)
7 | tags = db.ListField(db.StringField(max_length=30))
8 | time = db.DateTimeField(default=datetime.datetime.now())
9 | content = db.StringField()
10 |
--------------------------------------------------------------------------------
/app/templates/archive.html:
--------------------------------------------------------------------------------
1 |
2 | {% extends "base.html" %}
3 |
4 | {% block content %}
5 |
6 | {% for post in posts %}
7 |
8 |
9 | {{ post.time }}
10 |
11 | {% for tag in post.tags %}
12 | {{ tag }}
13 | {% endfor %}
14 |
15 |
16 |
17 | {% endfor %}
18 |
19 |
20 | {% endblock %}
--------------------------------------------------------------------------------
/manage.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | #!/usr/bin/env python
3 |
4 | from flask.ext.script import Manager, Server
5 | from app import app
6 | from app.models import Post
7 |
8 | manager = Manager(app)
9 | manager.add_command("runserver",
10 | Server(host="127.0.0.1", port=5000, use_debugger=True))
11 |
12 | @manager.command
13 | def save_post():
14 | post = Post(author="Andrew liu",
15 | title="Hello World",
16 | tags="test",
17 | content="This is the First Post")
18 | post.save()
19 |
20 | if __name__ == '__main__':
21 | manager.run()
22 |
--------------------------------------------------------------------------------
/app/templates/read_more.html:
--------------------------------------------------------------------------------
1 |
2 | {% extends "base.html" %}
3 |
4 | {% block content %}
5 |
6 | {% if post %}
7 |
8 |
9 | Posted by {{ post.author }}
10 |
11 | {{ post.time }}
12 |
13 |

14 |
{{ post.title }}
15 |
16 |
17 | {{ post.content|markdown }}
18 |
19 |
20 | {% include 'duo_shuo.html' %}
21 | {% endif %}
22 |
23 | {% endblock %}
--------------------------------------------------------------------------------
/app/__init__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | #!/usr/bin/env python
3 |
4 | from flask import Flask
5 | from flask.ext.mongoengine import MongoEngine
6 | from flaskext.markdown import Markdown
7 |
8 | app = Flask(__name__) #创建Flask类的实例
9 | app.config.from_object("config") #从config.py读入配置
10 | md = Markdown(app,
11 | extensions=['footnotes'],
12 | entension_configs={'footnotes':('PLACE_MARKER', '```')},
13 | safe_mode=True,
14 | output_format='html4')
15 | db = MongoEngine(app) #实例化数据库
16 |
17 | #这个import语句放在这里, 防止views, models import发生循环import
18 | from app import views, models
19 |
20 |
--------------------------------------------------------------------------------
/app/templates/welcome.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | {% if title %}
4 |
6 | {% for post in posts %}
7 |
8 |
9 | Posted by {{ post.author }}
10 |
11 | {{ post.time }}
12 |
13 |

14 |
15 |
16 |
17 | {{ post.content|markdown}}
18 |
19 |
Read more →
20 |
21 | {% endfor %}
22 |
23 |
24 | {% endblock %}
--------------------------------------------------------------------------------
/app/templates/duo_shuo.html:
--------------------------------------------------------------------------------
1 |
2 |