diff --git a/app/__init__.py b/app/__init__.py index 95f8c6c..f814d28 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -6,6 +6,7 @@ from flask_sqlalchemy import SQLAlchemy from flask_migrate import Migrate from flask_login import LoginManager from flask_mail import Mail +from flask_bootstrap import Bootstrap from config import Config app = Flask(__name__) @@ -15,6 +16,7 @@ migrate = Migrate(app, db) login = LoginManager(app) login.login_view = 'login' mail = Mail(app) +bootstrap = Bootstrap(app) if not app.debug: if app.config['MAIL_SERVER']: diff --git a/app/templates/404.html b/app/templates/404.html index 2308820..f2e1cee 100644 --- a/app/templates/404.html +++ b/app/templates/404.html @@ -1,6 +1,6 @@ {% extends "base.html" %} -{% block content %} +{% block app_content %}

Not Found

Back

{% endblock %} diff --git a/app/templates/500.html b/app/templates/500.html index 660c3a1..2e8a06e 100644 --- a/app/templates/500.html +++ b/app/templates/500.html @@ -1,6 +1,6 @@ {% extends "base.html" %} -{% block content %} +{% block app_content %}

An unexpected error has occurred

The administrator has been notified. Sorry for the inconvenience!

Back

diff --git a/app/templates/_post.html b/app/templates/_post.html index a705b31..29caf6f 100644 --- a/app/templates/_post.html +++ b/app/templates/_post.html @@ -1,6 +1,17 @@ - - - - +
{{ post.author.username }} says:
{{ post.body }}
+ + +
+ + + + + + {{ post.author.username }} + + says: +
+ {{ post.body }} +
diff --git a/app/templates/base.html b/app/templates/base.html index bd9f6e1..053e93b 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -1,34 +1,50 @@ - - - - {% if title %} - {{ title }} - Microblog - {% else %} - Welcome to Microblog - {% endif %} - - -
- Microblog: - Home - Explore - {% if current_user.is_anonymous %} - Login - {% else %} - Profile - Logout - {% endif %} +{% extends 'bootstrap/base.html' %} + +{% block title %} + {% if title %}{{ title }} - Microblog{% else %}Welcome to Microblog{% endif %} +{% endblock %} + +{% block navbar %} + +{% endblock %} + +{% block content %} +
{% with messages = get_flashed_messages() %} {% if messages %} - {% endif %} {% endwith %} - {% block content %}{% endblock %} - - + + {# application content needs to be provided in the app_content block #} + {% block app_content %}{% endblock %} +
+{% endblock %} diff --git a/app/templates/edit_profile.html b/app/templates/edit_profile.html index e2471ac..72cacda 100644 --- a/app/templates/edit_profile.html +++ b/app/templates/edit_profile.html @@ -1,23 +1,11 @@ {% extends "base.html" %} +{% import 'bootstrap/wtf.html' as wtf %} -{% block content %} +{% block app_content %}

Edit Profile

-
- {{ form.hidden_tag() }} -

- {{ form.username.label }}
- {{ form.username(size=32) }}
- {% for error in form.username.errors %} - [{{ error }}] - {% endfor %} -

-

- {{ form.about_me.label }}
- {{ form.about_me(cols=50, rows=4) }}
- {% for error in form.about_me.errors %} - [{{ error }}] - {% endfor %} -

-

{{ form.submit() }}

-
+
+
+ {{ wtf.quick_form(form) }} +
+
{% endblock %} diff --git a/app/templates/index.html b/app/templates/index.html index eb3f876..baf91d8 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -1,27 +1,27 @@ {% extends "base.html" %} +{% import 'bootstrap/wtf.html' as wtf %} -{% block content %} +{% block app_content %}

Hi, {{ current_user.username }}!

{% if form %} -
- {{ form.hidden_tag() }} -

- {{ form.post.label }}
- {{ form.post(cols=32, rows=4) }}
- {% for error in form.post.errors %} - [{{ error }}] - {% endfor %} -

-

{{ form.submit() }}

-
+ {{ wtf.quick_form(form) }} +
{% endif %} {% for post in posts %} {% include '_post.html' %} {% endfor %} - {% if prev_url %} - Newer posts - {% endif %} - {% if next_url %} - Older posts - {% endif %} + {% endblock %} diff --git a/app/templates/login.html b/app/templates/login.html index 2a54187..5b8d1b8 100644 --- a/app/templates/login.html +++ b/app/templates/login.html @@ -1,26 +1,14 @@ -{% extends "base.html" %} +{% extends 'base.html' %} +{% import 'bootstrap/wtf.html' as wtf %} -{% block content %} +{% block app_content %}

Sign In

-
- {{ form.hidden_tag() }} -

- {{ form.username.label }}
- {{ form.username(size=32) }}
- {% for error in form.username.errors %} - [{{ error }}] - {% endfor %} -

-

- {{ form.password.label }}
- {{ form.password(size=32) }}
- {% for error in form.password.errors %} - [{{ error }}] - {% endfor %} -

-

{{ form.remember_me() }} {{ form.remember_me.label }}

-

{{ form.submit() }}

-
+
+
+ {{ wtf.quick_form(form) }} +
+
+

New User? Click to Register!

Forgot Your Password? diff --git a/app/templates/register.html b/app/templates/register.html index 37b7ac5..c87955c 100644 --- a/app/templates/register.html +++ b/app/templates/register.html @@ -1,37 +1,11 @@ {% extends "base.html" %} +{% import 'bootstrap/wtf.html' as wtf %} -{% block content %} +{% block app_content %}

Register

-
- {{ form.hidden_tag() }} -

- {{ form.username.label }}
- {{ form.username(size=32) }}
- {% for error in form.username.errors %} - [{{ error }}] - {% endfor %} -

-

- {{ form.email.label }}
- {{ form.email(size=64) }}
- {% for error in form.email.errors %} - [{{ error }}] - {% endfor %} -

-

- {{ form.password.label }}
- {{ form.password(size=32) }}
- {% for error in form.password.errors %} - [{{ error }}] - {% endfor %} -

-

- {{ form.password2.label }}
- {{ form.password2(size=32) }}
- {% for error in form.password2.errors %} - [{{ error }}] - {% endfor %} -

-

{{ form.submit() }}

-
+
+
+ {{ wtf.quick_form(form) }} +
+
{% endblock %} diff --git a/app/templates/reset_password.html b/app/templates/reset_password.html index 92f0c8e..19d5bbf 100644 --- a/app/templates/reset_password.html +++ b/app/templates/reset_password.html @@ -1,23 +1,11 @@ {% extends "base.html" %} +{% import 'bootstrap/wtf.html' as wtf %} -{% block content %} +{% block app_content %}

Reset Your Password

-
- {{ form.hidden_tag() }} -

- {{ form.password.label }}
- {{ form.password(size=32) }}
- {% for error in form.password.errors %} - [{{ error }}] - {% endfor %} -

-

- {{ form.password2.label }}
- {{ form.password2(size=32) }}
- {% for error in form.password2.errors %} - [{{ error }}] - {% endfor %} -

-

{{ form.submit() }}

-
+
+
+ {{ wtf.quick_form(form) }} +
+
{% endblock %} diff --git a/app/templates/reset_password_request.html b/app/templates/reset_password_request.html index 18bb0ae..a5f7d22 100644 --- a/app/templates/reset_password_request.html +++ b/app/templates/reset_password_request.html @@ -1,16 +1,11 @@ {% extends "base.html" %} +{% import 'bootstrap/wtf.html' as wtf %} -{% block content %} +{% block app_content %}

Reset Password

-
- {{ form.hidden_tag() }} -

- {{ form.email.label }}
- {{ form.email(size=64) }}
- {% for error in form.email.errors %} - [{{ error }}] - {% endfor %} -

-

{{ form.submit() }}

-
+
+
+ {{ wtf.quick_form(form) }} +
+
{% endblock %} diff --git a/app/templates/user.html b/app/templates/user.html index aedf50a..b039db2 100644 --- a/app/templates/user.html +++ b/app/templates/user.html @@ -1,9 +1,9 @@ {% extends "base.html" %} -{% block content %} - - - +{% block app_content %} +
+ +

User: {{ user.username }}

{% if user.about_me %}

{{ user.about_me }}

{% endif %} @@ -15,28 +15,35 @@

{{ form.hidden_tag() }} - {{ form.submit(value='Follow') }} + {{ form.submit(value='Follow', class_='btn btn-default') }}

{% else %}

{{ form.hidden_tag() }} - {{ form.submit(value='Unfollow') }} + {{ form.submit(value='Unfollow', class_='btn btn-default') }}

{% endif %}
-
{% for post in posts %} {% include '_post.html' %} {% endfor %} - {% if prev_url %} - Newer posts - {% endif %} - {% if next_url %} - Older posts - {% endif %} + {% endblock %}