Merge branch 'master' of github.com:econchick/rogueojiiofwales into crazy
Conflicts: urls.py
This commit is contained in:
commit
0ab9f790fe
7 changed files with 91 additions and 6 deletions
24
templates/graph_base.html
Normal file
24
templates/graph_base.html
Normal file
|
@ -0,0 +1,24 @@
|
|||
{# vim: set ft=htmldjango #}
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block head_css %}
|
||||
<style text="text/css">
|
||||
h1.placeholder {
|
||||
margin-top: 80px;
|
||||
text-align: center;
|
||||
color: #ccc;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block container %}
|
||||
{% include "navbar.html" %}
|
||||
<div class="container-fluid">
|
||||
{% block graph %}<h1 class="placeholder">PUT A GRAPH HERE</h1>{% endblock %}
|
||||
</div>
|
||||
{% endblock container %}
|
||||
|
||||
{% block body_js %}
|
||||
<script src="{{ STATIC_URL }}js/jquery.js"></script>
|
||||
<script src="{{ STATIC_URL }}bootstrap/js/bootstrap-dropdown.js"></script>
|
||||
{% endblock %}
|
2
templates/graph_followers.html
Normal file
2
templates/graph_followers.html
Normal file
|
@ -0,0 +1,2 @@
|
|||
{# vim: set ft=htmldjango #}
|
||||
{% extends "graph_base.html" %}
|
6
templates/graph_repo.html
Normal file
6
templates/graph_repo.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
{# vim: set ft=htmldjango #}
|
||||
{% extends "graph_base.html" %}
|
||||
|
||||
{% block graph %}
|
||||
<h1 class="placeholder">PUT A GRAPH OF<br/>{{ username }}'s<br/>{{ repo }} REPO<br/>HERE</h1>
|
||||
{% endblock %}
|
33
templates/navbar.html
Normal file
33
templates/navbar.html
Normal file
|
@ -0,0 +1,33 @@
|
|||
{# vim: set ft=htmldjango #}
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container-fluid">
|
||||
<a class="brand" href="">Cool name</a>
|
||||
<ul class="nav">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">My Repos</a>
|
||||
<ul class="dropdown-menu">
|
||||
{% for r in repos %}
|
||||
<li><a href="#">{{ r.name }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="{% url index %}">Followers</a></li>
|
||||
</ul>
|
||||
<ul class="nav pull-right">
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
|
||||
{{ request.user.username }}
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="#">Logout</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="{% url index %}">Followers</a></li>
|
||||
</ul>
|
||||
<ul class="nav pull-right">
|
||||
<li><a href="">Logout</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
4
urls.py
4
urls.py
|
@ -11,9 +11,13 @@ admin.autodiscover()
|
|||
urlpatterns = patterns('',
|
||||
url(r'^%s(?P<path>.*)$' % re.escape(settings.STATIC_URL.lstrip('/')), 'django.contrib.staticfiles.views.serve', {'insecure': True}),
|
||||
url(r'^admin/', include(admin.site.urls)),
|
||||
url(r'^followers/', views.graph_followers,
|
||||
name='graph_followers'),
|
||||
url(r'^login/$', views.login, name='login'),
|
||||
url(r'^me/$', 'githubnetwork.views.me', name='me'),
|
||||
url(r'^ajax/$', 'githubnetwork.views.get_user_followers', name='get_user_followers'),
|
||||
url(r'^repo/(?P<user>\w+)/(?P<repo>\w+)/', views.graph_repo,
|
||||
name='graph_repo'),
|
||||
url(r'^$', views.index, name='index'),
|
||||
url(r'', include('social_auth.urls')),
|
||||
)
|
||||
|
|
28
views.py
28
views.py
|
@ -1,4 +1,5 @@
|
|||
from django.contrib.auth.decorators import login_required
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import redirect, render_to_response
|
||||
from django.template import RequestContext
|
||||
|
||||
|
@ -7,12 +8,12 @@ def index(request):
|
|||
'''Index page. Everyone starts here. If the user is logged in (that is, they
|
||||
have a session id) return the follower_graph view. Otherwise, render the
|
||||
index page.'''
|
||||
if request.session.get('sessionid', False):
|
||||
return follower_graph(request)
|
||||
if request.user.is_authenticated():
|
||||
return redirect('graph_followers')
|
||||
# Set a test cookie. When the user clicks the 'Login' button, test and make
|
||||
# sure this cookie was set properly.
|
||||
request.session.set_test_cookie()
|
||||
return render_to_response('login.html', RequestContext(request))
|
||||
return render_to_response('index.html', RequestContext(request))
|
||||
|
||||
|
||||
def login(request):
|
||||
|
@ -23,11 +24,26 @@ def login(request):
|
|||
request.session.delete_test_cookie()
|
||||
return redirect('/login/github/')
|
||||
else:
|
||||
# During development, I've landed here a lot, despite having cookies
|
||||
# enabled. So, set the test cookie so that trying to login from here
|
||||
# actually works.
|
||||
request.session.set_test_cookie()
|
||||
# Render an error -- fix your damn cookies!
|
||||
return render_to_response('login.html',
|
||||
return render_to_response('index.html',
|
||||
{ 'error': "Fix your damn cookies!" })
|
||||
|
||||
|
||||
@login_required
|
||||
def follower_graph(request):
|
||||
return 'Hello!'
|
||||
def graph_followers(request):
|
||||
return render_to_response('graph_followers.html', {
|
||||
'repos': request.github.get_iter('users/%s/repos' % request.user.username)
|
||||
}, RequestContext(request))
|
||||
|
||||
|
||||
@login_required
|
||||
def graph_repo(request, user=None, repo=None):
|
||||
return render_to_response('graph_repo.html', {
|
||||
'graph_user': user,
|
||||
'graph_repo': repo,
|
||||
'repos': request.github.get_iter('users/%s/repos' % request.user.username)
|
||||
}, RequestContext(request))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue