Explorar el Código

bower.json: include bootstrap-social, base.html: included bootstrap-social and font-awesome css, and made prettify login page

mk200789 hace 10 años
padre
commit
79cd690d9a

+ 2 - 1
bower.json

@@ -14,6 +14,7 @@
   "license": "MIT",
   "dependencies": {
     "bootstrap": "~3.3.4",
-    "jquery": "~2.1.3"
+    "jquery": "~2.1.3",
+    "bootstrap-social":"~4"
   }
 }

+ 0 - 37
hackathon_starter/hackathon/scripts/tumblr.py

@@ -1,37 +0,0 @@
-import requests
-import simplejson as json
-import time 
-import collections
-import urllib
-
-blog_uri		= "http://api.tumblr.com/v2/blog/"
-user_uri		= "api.tumblr.com/v2/user/"
-consumer_key    = "KrSbAc9cYLmIgVAn1D21FjRR97QWsutNMxkPDFBxo8CMWtMk4M"
-consumer_secret = "lKWMtL2Lj8zr5pY51PVqT8ugeoG0DjrdgoFewM0QTSyJ12jP8d"
-oauth_token		= "b2osMdhLljOo5aVBjd47kU7gm08NSTqZnZa1b6gC8MmpZX8h0H"
-oauth_secret	= "jHsrI4qM5h4CbUre90SZRAG6snguY22tB1NdujgAZwFh8VD1B1"
-
-def getUserInfo():
-	return "getUserInfo()"
-
-def getBlogInfo(user):
-	blog_info = blog_uri + user +".tumblr.com/info?api_key="+consumer_key
-	req = requests.get(blog_info)
-	jsonlist = json.loads(req.content)
-	
-	meta = jsonlist['meta']
-	response = jsonlist['response']
-	blog = response['blog']
-	blog['updated'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(blog['updated']))
-
-	return meta, response, blog
-
-def getTaggedInfo(tag):
-	tagged_uri = "http://api.tumblr.com/v2/tagged?tag="+tag+"&api_key="+consumer_key+"&limit=2"
-	req = requests.get(tagged_uri)
-	jsonlist = json.loads(req.content)
-	
-	meta = jsonlist['meta']
-	response = jsonlist['response'][0]
-	
-	return response

+ 3 - 0
hackathon_starter/hackathon/templates/hackathon/base.html

@@ -8,6 +8,9 @@
     
     <link rel="stylesheet" href="/static/bower_components/bootstrap/dist/css/bootstrap.min.css">
     <link rel="stylesheet" href="/static/bower_components/bootstrap/dist/css/bootstrap-theme.min.css">
+    <link rel="stylesheet" href="/static/bower_components/bootstrap-social/bootstrap-social.css">
+    <link rel="stylesheet" href="/static/bower_components/font-awesome/css/font-awesome.min.css">
+
   </head>
     
   <body>

+ 39 - 23
hackathon_starter/hackathon/templates/hackathon/login.html

@@ -1,31 +1,47 @@
 <!DOCTYPE html>
 <html>
     {% include 'hackathon/base.html' %}
+    <style>
+      .form-signin {
+        max-width: 550px;
+        padding: 15px;
+        margin: 0 auto;
+      }    
+    </style>
 
     <body>
+      <div class="container text-center">
+        <form class="form-signin" id="login_form" method="post" action="/hackathon/login/">
+          {% csrf_token %}
+          {% load bootstrap %}
+          <h2 class="form-signin-heading">Login</h2>
+          <br>
+          <input type="text" name="username" class="form-control" placeholder="Username" value="" required autofocus>
+          <br>
+          <input type="password" name="password" class="form-control" placeholder="Password" value=""required>
+          <br>
+          <button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
+          <input type="hidden" name="submit" value="submit" />
+        </form>
+      </div>
 
-        <div class='container text-center'>
-              <h2 class="form-signin-heading">Login</h2>
-              <br>
-              <form class="form-horizontal" id="login_form" method="post" action="/hackathon/login/">
-                {% csrf_token %}
-                {% load bootstrap %} 
-
-                <table>
-                  <tr>
-                     
-                      <td class="container text-center">Username: <input type="text" name="username" value="" size="50" /></td>
-                  </tr>
-
-                  <tr>
-                     
-                      <td class="container text-center">Password: <input type="password" name="password" value="" size="50" /></td>
-                  </tr>
-
-                </table>
-                <button class="btn btn-lg btn-primary" type="submit">Login</button>
-                <input type="hidden" name="submit" value="submit" />
-              </form>
-        </div>
+      <div class="form-signin">
+        <a class="btn btn-block btn-social btn-facebook">
+          <i class="fa fa-facebook"></i>
+          Sign in with Facebook
+        </a>          
+        <a class="btn btn-block btn-social btn-twitter">
+          <i class="fa fa-twitter"></i>
+          Sign in with Twitter
+        </a>
+        <a class="btn btn-block btn-social btn-instagram">
+          <i class="fa fa-instagram"></i>
+          Sign in with Instagram
+        </a>
+        <a class="btn btn-block btn-social btn-google-plus">
+          <i class="fa fa-google-plus"></i>
+          Sign in with Google
+        </a>          
+      </div>
     </body>
 </html>

+ 0 - 44
hackathon_starter/hackathon/templates/hackathon/tumblr.html

@@ -1,44 +0,0 @@
-<!DOCTYPE html>
-<html>
-<body>
-	{% include 'hackathon/base.html' %}
-	<div class="col-md-6">
-		<h1 class="text-center"> {{ title }}</h1> 
-		<br>
-		<div class="table-responsive">
-			<table class="table table-bordered">
-				<tr>
-					<th>Name</th>
-					<td>{{blogData.name}}</td>
-				</tr>
-				<tr>
-					<th>Posts</th>
-					<td>{{blogData.posts}}</td>				
-				</tr>
-				<tr>
-					<th>Blog title</th>
-					<td>{{blogData.title}}</td>				
-				</tr>
-				<tr>
-					<th>Last updated</th>
-					<td>{{blogData.updated}}</td>				
-				</tr>
-				<tr>
-					<th>Description</th>
-					<td>{{blogData.description}}</td>				
-				</tr>				
-			</table>
-			{{blogTag}}
-			<!--<table class="table">
-				{% for i,v in blogData.items %}
-				<tr>
-					<th>{{i}}</th>
-					<td>{{v}}</td>
-				</tr>
-				{% endfor %}		
-			</table>-->
-		</div>
-	</div>
-</body>
-
-</html>

+ 0 - 156
hackathon_starter/hackathon/views.py

@@ -1,156 +0,0 @@
-from django.shortcuts import render
-from hackathon.forms import UserForm
-from django.contrib.auth import logout
-from django.template import RequestContext, loader
-from django.contrib.auth import authenticate, login
-from django.http import HttpResponse, HttpResponseRedirect
-from scripts.steam import gamesPulling, steamIDPulling 
-from scripts.github import *
-from scripts.tumblr import *
-
-
-
-def index(request):
-	context = {'hello': 'world'}
-	return render(request, 'hackathon/index.html', context)
-
-def test(request):
-	return HttpResponse('meow')
-
-def api_examples(request):
-    context = {'title': 'API Examples Page'}
-    return render(request, 'hackathon/api_examples.html', context)
-
-def register(request):
-
-    # A boolean value for telling the template whether the registration was successful.
-    # Set to False initially. Code changes value to True when registration succeeds.
-    registered = False
-
-    # If it's a HTTP POST, we're interested in processing form data.
-    if request.method == 'POST':
-        # Attempt to grab information from the raw form information.
-        # Note that we make use of both UserForm and UserProfileForm.
-        user_form = UserForm(data=request.POST)
-
-        # If the two forms are valid...
-        if user_form.is_valid():
-            # Save the user's form data to the database.
-            user = user_form.save()
-
-            # Now we hash the password with the set_password method.
-            # Once hashed, we can update the user object.
-            user.set_password(user.password)
-            user.save()
-
-            # Update our variable to tell the template registration was successful.
-            registered = True
-
-        # Invalid form or forms - mistakes or something else?
-        # Print problems to the terminal.
-        # They'll also be shown to the user.
-        else:
-            print user_form.errors
-
-    # Not a HTTP POST, so we render our form using two ModelForm instances.
-    # These forms will be blank, ready for user input.
-    else:
-        user_form = UserForm()
-
-    # Render the template depending on the context.
-    return render(request,
-            'hackathon/register.html',
-            {'user_form': user_form, 'registered': registered} )
-
-def user_login(request):
-
-    # If the request is a HTTP POST, try to pull out the relevant information.
-    if request.method == 'POST':
-        # Gather the username and password provided by the user.
-        # This information is obtained from the login form.
-                # We use request.POST.get('<variable>') as opposed to request.POST['<variable>'],
-                # because the request.POST.get('<variable>') returns None, if the value does not exist,
-                # while the request.POST['<variable>'] will raise key error exception
-        username = request.POST.get('username')
-        password = request.POST.get('password')
-
-        # Use Django's machinery to attempt to see if the username/password
-        # combination is valid - a User object is returned if it is.
-        user = authenticate(username=username, password=password)
-
-        # If we have a User object, the details are correct.
-        # If None (Python's way of representing the absence of a value), no user
-        # with matching credentials was found.
-        if user:
-            # Is the account active? It could have been disabled.
-            if user.is_active:
-                # If the account is valid and active, we can log the user in.
-                # We'll send the user back to the homepage.
-                login(request, user)
-                return HttpResponseRedirect('/hackathon/')
-            else:
-                # An inactive account was used - no logging in!
-                return HttpResponse("Your Django Hackathon account is disabled.")
-        else:
-            # Bad login details were provided. So we can't log the user in.
-            print "Invalid login details: {0}, {1}".format(username, password)
-            return HttpResponse("Invalid login details supplied.")
-
-    # The request is not a HTTP POST, so display the login form.
-    # This scenario would most likely be a HTTP GET.
-    else:
-        # No context variables to pass to the template system, hence the
-        # blank dictionary object...
-        return render(request, 'hackathon/login.html', {})
-
-def user_logout(request):
-    # Since we know the user is logged in, we can now just log them out.
-    logout(request)
-
-    # Take the user back to the homepage.
-    return HttpResponseRedirect('/hackathon/')
-
-def steam(request):
-    #Should link to test of Steam API example.
-    key = '231E98D442E52B87110816C3D5114A1D'
-    SteamUN = "Marorin"
-    steamID = steamIDPulling(SteamUN, key)
-    game = gamesPulling(steamID, key)
-    return render(request,'hackathon/steam.html', {"game": game })
-
-def github(request):
-    allData = {}
-    # Get generic user data
-    userData = getUserData()
-    # Get a list of all the user's repositories
-    repositories = getUserRepositories()
-    # Get a list of all commit statistics for all repositories
-    list = getTopContributedRepositories(repositories)
-    # Get a list of the top 10 most committed repositories
-    filtered = filterCommits(list)
-    # Get list of all stargazer counts for all repositories
-    stargazers = getStarGazerCount()
-    # Return list of top 10 stargazed repositories
-    filteredStargazers = filterStarGazerCount(stargazers)
-    # Get list of forked repositories
-    forkedRepos = getForkedRepositories()
-    
-    # Store data into a dictionary for rendering
-    allData['userData'] = userData
-    allData['filteredData'] = filtered
-    allData['filteredStargazers'] = filteredStargazers
-    allData['forkedRepos'] = forkedRepos
-
-    return render(request, 'hackathon/github.html', { 'data': allData })
-
-def tumblr(request):
-    meta, response, blog = getBlogInfo('twitterthecomic')
-    tagged_blog = getTaggedInfo("obama")
-    context = {'title': 'Tumblr Example', 'blogData': blog, 'blogTag': tagged_blog}
-    return render(request, 'hackathon/tumblr.html', context)
-
-def linkedin(request):
-    userinfo = getUserInfo()
-    context = {'title': 'linkedin Example','userdata': userinfo}
-    return render(request, 'hackathon/linkedin.html', context)
-