Commits

benoitc  committed c921299

better homepage for example

  • Participants
  • Parent commits 4a90f39

Comments (0)

Files changed (6)

File example/static/css/base.css

+body { 
+    background-color: #fff; 
+    color: #333; 
+}
+ 
+body, p, ol, ul, td {
+  font-family: verdana, arial, helvetica, sans-serif;
+  font-size:   13px;
+  line-height: 18px;
+}
+ 
+pre {
+  background-color: #eee;
+  padding: 10px;
+  font-size: 11px;
+}
+ 
+a { color: #000; }
+a:visited { color: #666; }
+a:hover { color: #fff; background-color:#000; }
+ 
+.fieldWithErrors {
+  padding: 2px;
+  background-color: red;
+  display: table;
+}
+ 
+#errorExplanation {
+  width: 400px;
+  border: 2px solid red;
+  padding: 7px;
+  padding-bottom: 12px;
+  margin-bottom: 20px;
+  background-color: #f0f0f0;
+}
+ 
+#errorExplanation h2 {
+  text-align: left;
+  font-weight: bold;
+  padding: 5px 5px 5px 15px;
+  font-size: 12px;
+  margin: -7px;
+  background-color: #c00;
+  color: #fff;
+}
+ 
+#errorExplanation p {
+  color: #333;
+  margin-bottom: 0;
+  padding: 5px;
+}
+ 
+#errorExplanation ul li {
+  font-size: 12px;
+  list-style: square;
+}
+
+.login {
+    width: 750px;
+    clear: both;
+}

File example/static/css/openid.css

+
+#auth_form {
+    display: block;
+    width: 250px;
+    float: left;
+    margin-right: 20px;
+}
+
 #openid_form {
-	width: 470px;	
+    display: block;
+    width: 470px;
+    float: left;
 }
-	#openid_form legend {
-		font-weight: bold;
-	}
+#openid_form legend,
+#auth_form legend {
+    font-weight: bold;
+}
 #openid_choice {
-	display: none;
+    display: none;
 }
 #openid_input_area {
-	clear: both;
-	padding: 10px;
+    clear: both;
+    padding: 10px;
 }
 #openid_btns, #openid_btns br {
-	clear: both;
+    clear: both;
 }
-	#openid_highlight {
-		padding: 3px;
-		background-color: #FFFCC9;
-		float: left;
-	}
-	.openid_large_btn {
-		width: 100px;
-		height: 60px;
-		border: 1px solid #DDD;
-		margin: 3px;
-		float: left;
-	}
-	.openid_small_btn {
-		width: 24px;
-		height: 24px;
-		border: 1px solid #DDD;
-		margin: 3px;
-		float: left;
-	}	
-	a.openid_large_btn:focus {
-		outline: none;
-	}
-	a.openid_large_btn:focus
-	{
-	-moz-outline-style: none;
-	}
-	.openid_selected {
-		border: 4px solid #DDD;
-	}	
+#openid_highlight {
+    padding: 3px;
+    background-color: #FFFCC9;
+    float: left;
+}
+.openid_large_btn {
+    width: 100px;
+    height: 60px;
+    border: 1px solid #DDD;
+    margin: 3px;
+    float: left;
+}
+.openid_small_btn {
+    width: 24px;
+    height: 24px;
+    border: 1px solid #DDD;
+    margin: 3px;
+    float: left;
+}
+a.openid_large_btn:focus {
+    outline: none;
+}
+a.openid_large_btn:focus {
+    -moz-outline-style: none;
+}
+.openid_selected {
+    border: 4px solid #DDD;
+}
+

File example/templates/base.html

 
 <html lang="en">
     <head>
-        <title>django_authopenid example </title>
+        <title>django-authopenid Example App</title>
 
         <meta http-equiv="content-type" content="text/html; charset=utf-8">
-        
+        <link rel="stylesheet" href="{{ MEDIA_URL }}/css/base.css" />
         <link rel="stylesheet" href="{{ MEDIA_URL }}/css/openid.css" />
         {% block head %}
         {% endblock %}

File example/templates/home.html

 {% extends "base.html" %}
+{% load i18n %}
 
 {% block content %}
-<h1>Django AuthOpenID test</h1>
+<h1>django-authopenid Example App</h1>
 
 <p>Welcome {{ user }}</p>
 
 	<li><a href="{% url auth_password_change %}">Change password</a></li>
   	<li><a href="{% url user_signout %}">signout</a></li>
 </ul>
-{% else%}    
-<p> <a href="{% url user_signin %}">signin</a></p>
+{% else %}
+<h2>Make a choice:</h2>
+<p> <a href="{% url registration_register %}">Register</a> | <a href="{% url user_signin %}">Log-In</a></p>
+<div class="login">
+
+    <form id="auth_form" name="auth_form" action="{% url user_signin %}" method="post">
+    <input type="hidden" name="next" value="{{ next }}" />
+	<fieldset>
+	    
+	    
+		<legend>{% trans "Sign In Using Your Account ID" %}</legend>
+		<div class="form-row"><label for="id_username">{% trans "Username:" %}</label><br />{{ form2.username }}</div>
+		<div class="form-row"><label for="id_password">{% trans "Password" %}</label><br />{{ form2.password }}</div>
+		
+        <div class="submit-row"><input type="submit" name="blogin" value="{% trans "Sign in" %}"> </div>
+	</fieldset>	
+</form>
+
+<form id="openid_form" name="openid_form" action="{% url user_signin %}" method="post">
+    <input type="hidden" name="action" value="verify" />
+    <input type="hidden" name="next" value="{{ next }}" />
+	<fieldset>
+		<legend>{% trans "Sign In Using Your OpenID URL" %}</legend>
+		<div id="openid_choice">
+    		<p>Please click your account provider:</p>
+    		<div id="openid_btns"></div>
+    	</div>
+    	    <div id="openid_input_area">
+                <label for="id_openid_ul">{% trans "OpenId URL :" %}</label>{{ form1.openid_url }}
+                <input name="openid_submit" type="submit" value="{% trans "Sign in with OpenID" %}">
+            </div>
+		
+	</fieldset>
+</form>	
+</div>
+
 {% endif %}
 
-{% endblock %}
+{% endblock %}
+
+{% block extra_scripts %}
+{% if not has_openids %}
+<script type="text/javascript" src="{{ MEDIA_URL }}/js/openid-jquery.js"></script>
+<script type="text/javascript">
+$(document).ready(function() {
+    openid.init('id_openid_url');
+});
+</script>
+<!-- /Simple OpenID Selector -->
+{% endif %}
+{% endblock %}

File example/urls.py

 admin.autodiscover()
 
 urlpatterns = patterns('',
-    (r'^$', 'django.views.generic.simple.direct_to_template', {'template': 'home.html'}),
+    (r'^$', 'example.views.home'),
     (r'^account/', include('django_authopenid.urls')),
     (r'^admin/(.*)', admin.site.root),
 )

File example/views.py

+# -*- coding: utf-8 -*-
+from django.contrib.auth.forms import *
+from django.shortcuts import render_to_response as render
+from django.template import RequestContext, loader, Context
+
+from django_authopenid.forms import *
+
+
+def home(request):
+    form1 = OpenidSigninForm()
+    form2 = AuthenticationForm()
+    return render("home.html", {
+        'form1': form1,
+        'form2': form2
+    }, context_instance=RequestContext(request))