Skip to content
Permalink
Browse files

Update github flash messages and views

  • Loading branch information...
nlaz committed Feb 9, 2019
1 parent 125d9f2 commit b8be3bc44e9d11c671af9a1976ef9b4e5c322c3a
@@ -1,5 +1,5 @@
{% for message in get_flashed_messages() %}
<div class="alert alert-danger mb-0 rounded-0">
{% for category, message in get_flashed_messages(with_categories=true) %}
<div class="alert alert-{{ category if category != None else 'danger' }} mb-0 rounded-0">
<div class="container">
{{ message }}
</div>
@@ -1,6 +1,6 @@
<footer>
<footer class='bg-light py-2 border-top'>
{% block footer %}
<div class='container text-muted my-2'>
<div class='container text-secondary my-2'>
<div class='d-flex flex-column flex-sm-row justify-content-between align-items-center'>
<small>Project Name © 2019</small>
<span>
@@ -0,0 +1,19 @@
{% extends 'layout.html' %}

{% block header %}
<div class='bg-dark text-light py-5'>
<div class='container py-5 my-4'>
<h1 class='h1 text-white mb-1'>GitHub API Example</h1>
<h2 class='h6 text-secondary'>Simple example of fetching and managing GitHub data.</h2>
<a href="{{ url_for('public.user_guide', _anchor='github-oauth') }}" class='btn btn-primary mt-2'>Learn More</a>
</div>
</div>
{% endblock %}

{% block content %}
<div class='container py-5 my-3'>
{% if body %}
<div class='content markdown'>{{ body|safe }}</div>
{% endif %}
</div>
{% endblock %}
@@ -1,11 +1,11 @@
{% extends 'layout.html' %}

{% block header %}
<div class='bg-dark text-light'>
<div class='container py-5'>
<h1 class='h3 mb-1'>GitHub API Example</h1>
<h2 class='h6 text-secondary'>Simple method to fetch and manage GitHub data.</h2>
<a href='#' class='btn btn-sm btn-primary mt-1'>Learn more</a>
<div class='bg-dark text-light py-5'>
<div class='container py-5 my-4'>
<h1 class='h1 text-white mb-1'>GitHub API Example</h1>
<h2 class='h6 text-secondary'>Simple example of fetching and managing GitHub data.</h2>
<a href="{{ url_for('public.user_guide', _anchor='github-oauth') }}" class='btn btn-primary mt-2'>Learn More</a>
</div>
</div>
{% endblock %}
@@ -1,16 +1,16 @@
{% extends 'layout.html' %}

{% block header %}
<div class='bg-dark text-light'>
<div class='bg-dark text-light py-5'>
<div class='container py-5 my-4'>
<h1 class='h3 mb-1'>Hackathon Flask Starter Kit</h1>
<h1 class='h1 mb-1 text-white'>Hackathon Flask Starter</h1>
<h2 class='h6 text-secondary'>Presented by GitHub & MLH</h2>
</div>
</div>
{% endblock %}

{% block content %}
<div class='container my-5'>
<div class='container py-5 my-3'>
{% if body %}
<div class='content markdown'>{{ body|safe }}</div>
{% endif %}
@@ -1,32 +1,34 @@
<nav class="navigation container">
<div class="d-flex flex-column flex-sm-row justify-content-between align-items-center">
<div class="d-flex align-items-center">
<a href="/" class="text-decoration-none text-dark">
<h1 class="h5 m-0">{Project Name}</h1>
</a>
<a class="nav-item p-2 m-1" href="{{ url_for('github.index') }}">
GitHub API
</a>
</div>
<div class="d-flex align-items-center">
{% if g.user %}
<span class="nav-item p-2 text-secondary d-flex align-items-center">
<img src="{{ g.user['avatar_url'] }}" class='rounded mr-2' style='width:24px; height:24px;'/>
{{ g.user['username'] }}
</span>
{% endif %}
<span class="nav-item p-2 m-1">
<a href="{{ url_for('public.user_guide') }}">User Guide</a>
</span>
{% if g.user %}
<span class="nav-item p-2 m-1">
<a href="{{ url_for('auth.logout') }}">Log out</a>
</span>
{% else %}
<nav class="navigation border-bottom">
<div class="container">
<div class="d-flex flex-column flex-sm-row justify-content-between align-items-center">
<div class="d-flex align-items-center justify-content-between justify-content-sm-start w-100">
<a href="/" class="text-decoration-none text-dark">
<h1 class="h5 m-0">{Project Name}</h1>
</a>
<a class="nav-item p-2 m-1" href="{{ url_for('github.index') }}">
GitHub API
</a>
</div>
<div class="d-flex align-items-center justify-content-between justify-content-sm-end w-100">
{% if g.user %}
<span class="nav-item p-2 text-secondary d-flex align-items-center">
<img src="{{ g.user['avatar_url'] }}" class='rounded mr-2' style='width:24px; height:24px;'/>
{{ g.user['username'] }}
</span>
{% endif %}
<span class="nav-item p-2 m-1">
<a href="{{ url_for('auth.githubLogin') }}">Login with GitHub</a>
<a href="{{ url_for('public.user_guide') }}">User Guide</a>
</span>
{% endif %}
{% if g.user %}
<span class="nav-item p-2 m-1">
<a href="{{ url_for('auth.logout') }}">Log out</a>
</span>
{% else %}
<span class="nav-item p-2 m-1">
<a href="{{ url_for('auth.githubLogin') }}">Login with GitHub</a>
</span>
{% endif %}
</div>
</div>
</div>
</nav>
@@ -3,14 +3,18 @@

from app.views.auth import login_required
from app.services.github import GitHub
from app.extensions import markdown

blueprint = Blueprint('github', __name__, url_prefix='/github')

@blueprint.route('/')
def index():
if not 'access_token' in session:
flash('Please sign in with your GitHub account.', 'info')
return render_template('github/index.html')
flash('This page needs an authenticated user. Please sign in with your GitHub account.', 'warning')
with open('docs/USER_GUIDE.md', 'r') as input_file:
text = input_file.read()
content = markdown.render(text)
return render_template('github/guide.html', body=content)

github = GitHub(access_token=session['access_token'])

@@ -22,10 +26,10 @@ def search():
search = request.args.get('query')

if search is None or search == '':
flash('Please include a repo name you want to search for.')
flash('Please include a repo name you want to search for.', 'danger')
return redirect(url_for('github.index'))
if not 'access_token' in session:
flash('Please sign in with your GitHub account.', 'error')
flash('Please sign in with your GitHub account.', 'danger')
return redirect(url_for('github.index'))

github = GitHub(access_token=session['access_token'])
@@ -38,7 +42,7 @@ def star():
repo = request.form['full_name']

if not 'access_token' in session:
flash('Please sign in with your GitHub account.', 'error')
flash('Please sign in with your GitHub account.', 'danger')
return redirect(url_for('github.index'))

github = GitHub(access_token=session['access_token'])

0 comments on commit b8be3bc

Please sign in to comment.
You can’t perform that action at this time.