Rough UI
Things don't work very well. It looks crappy. But it's something.
This commit is contained in:
		
						commit
						496634f613
					
				
					 4 changed files with 92 additions and 0 deletions
				
			
		
							
								
								
									
										21
									
								
								templates/base.html
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								templates/base.html
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,21 @@ | |||
| {# vim: set ft=djangohtml #} | ||||
| <!DOCTYPE html> | ||||
| <html lang="en"> | ||||
|   <head> | ||||
|     <title>{{ title }}</title> | ||||
|     <!-- css --> | ||||
|     <link rel="stylesheet" type="text/css" href="/static/bootstrap/css/bootstrap.css" /> | ||||
|     {% block head_css %}{% endblock %} | ||||
|     <!-- js --> | ||||
|     {% block head_js %}{% endblock %} | ||||
|   </head> | ||||
|   <body> | ||||
|     {% block container %} | ||||
|     <div class="container-fluid"> | ||||
|       {% block body %}{% endblock %} | ||||
|     </div> | ||||
|     {% endblock %} | ||||
|     {% block body_js %}{% endblock %} | ||||
|   </body> | ||||
| </html> | ||||
| 
 | ||||
							
								
								
									
										34
									
								
								templates/login.html
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								templates/login.html
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,34 @@ | |||
| {# vim: set ft=djangohtml #} | ||||
| {% extends "base.html" %} | ||||
| 
 | ||||
| {% block head_css %} | ||||
| <style type="text/css"> | ||||
|   .container { | ||||
|     margin-top: 120px; | ||||
|   } | ||||
| </style> | ||||
| 
 | ||||
| {% endblock %} | ||||
| 
 | ||||
| {% block container %} | ||||
| <div class="container"> | ||||
|   <div class="row"> | ||||
|     <div class="span8 offset2"> | ||||
|       <div class="hero-unit"> | ||||
|         <a class="btn btn-large btn-primary" href="{% url login %}">Login with | ||||
|           GitHub</a> | ||||
|       </div> | ||||
|     </div> | ||||
|   </div> | ||||
| 
 | ||||
|   {% if error %} | ||||
|   <div class="row"> | ||||
|     <div class="span8 offset2"> | ||||
|       <div class="alert alert-error"> | ||||
|         <i class="icon-exclamation-point"></i> {{ error }} | ||||
|       </div> | ||||
|     </div> | ||||
|   </div> | ||||
|   {% endif %} | ||||
| </div> | ||||
| {% endblock container %} | ||||
							
								
								
									
										4
									
								
								urls.py
									
										
									
									
									
								
							
							
						
						
									
										4
									
								
								urls.py
									
										
									
									
									
								
							|  | @ -4,10 +4,14 @@ from django.conf.urls import patterns, url, include | |||
| from django.contrib import admin | ||||
| import re | ||||
| 
 | ||||
| import views | ||||
| 
 | ||||
| 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'^login/$', views.login, name='login'), | ||||
|     url(r'^$', views.index, name='index'), | ||||
|     url(r'', include('social_auth.urls')), | ||||
| ) | ||||
|  |  | |||
							
								
								
									
										33
									
								
								views.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								views.py
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,33 @@ | |||
| from django.contrib.auth.decorators import login_required | ||||
| from django.shortcuts import redirect, render_to_response | ||||
| from django.template import RequestContext | ||||
| 
 | ||||
| 
 | ||||
| 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) | ||||
|     # 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') | ||||
| 
 | ||||
| 
 | ||||
| def login(request): | ||||
|     '''Do a quick check to make sure cookies are enabled. If so, redirect to | ||||
|     GitHub so the user can login.''' | ||||
|     # Make sure the user can accept cookies. | ||||
|     if request.session.test_cookie_worked(): | ||||
|         request.session.delete_test_cookie() | ||||
|         return redirect('/login/github/') | ||||
|     else: | ||||
|         # Render an error -- fix your damn cookies! | ||||
|         return render_to_response('login.html', | ||||
|                                   { 'error': "Fix your damn cookies!" }) | ||||
| 
 | ||||
| 
 | ||||
| @login_required | ||||
| def follower_graph(request): | ||||
|     return 'Hello!' | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue