commit
						4bb36f6129
					
				
					 7 changed files with 87 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,7 +11,11 @@ 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'^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')), | ||||
| ) | ||||
|  |  | |||
							
								
								
									
										24
									
								
								views.py
									
										
									
									
									
								
							
							
						
						
									
										24
									
								
								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): | ||||
|  | @ -28,10 +29,21 @@ def login(request): | |||
|         # 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
	
	 Jonas Obrist
						Jonas Obrist