Browse Source

Writing method for grabbing all stargazer count data

David Leonard 10 năm trước cách đây
commit
1364283e09
37 tập tin đã thay đổi với 1097 bổ sung0 xóa
  1. 9 0
      .hgignore
  2. 243 0
      README.md
  3. 19 0
      bower.json
  4. 0 0
      hackathon_starter/hackathon/__init__.py
  5. 5 0
      hackathon_starter/hackathon/admin.py
  6. 11 0
      hackathon_starter/hackathon/forms.py
  7. 0 0
      hackathon_starter/hackathon/migrations/__init__.py
  8. 11 0
      hackathon_starter/hackathon/models.py
  9. 0 0
      hackathon_starter/hackathon/scripts/__init__.py
  10. 130 0
      hackathon_starter/hackathon/scripts/github.py
  11. 10 0
      hackathon_starter/hackathon/scripts/samplescript.py
  12. 29 0
      hackathon_starter/hackathon/scripts/steam.py
  13. 26 0
      hackathon_starter/hackathon/static/css/form.css
  14. BIN
      hackathon_starter/hackathon/static/img/github.png
  15. BIN
      hackathon_starter/hackathon/static/img/linkedin.jpg
  16. BIN
      hackathon_starter/hackathon/static/img/steam.png
  17. BIN
      hackathon_starter/hackathon/static/img/tumblr.png
  18. 16 0
      hackathon_starter/hackathon/templates/hackathon/api_examples.html
  19. 58 0
      hackathon_starter/hackathon/templates/hackathon/base.html
  20. 64 0
      hackathon_starter/hackathon/templates/hackathon/github.html
  21. 14 0
      hackathon_starter/hackathon/templates/hackathon/index.html
  22. 8 0
      hackathon_starter/hackathon/templates/hackathon/linkedin.html
  23. 31 0
      hackathon_starter/hackathon/templates/hackathon/login.html
  24. 40 0
      hackathon_starter/hackathon/templates/hackathon/navbar.html
  25. 42 0
      hackathon_starter/hackathon/templates/hackathon/register.html
  26. 12 0
      hackathon_starter/hackathon/templates/hackathon/steam.html
  27. 9 0
      hackathon_starter/hackathon/templates/hackathon/tumblr.html
  28. 3 0
      hackathon_starter/hackathon/tests.py
  29. 8 0
      hackathon_starter/hackathon/unittests/testcase.py
  30. 16 0
      hackathon_starter/hackathon/urls.py
  31. 144 0
      hackathon_starter/hackathon/views.py
  32. 0 0
      hackathon_starter/hackathon_starter/__init__.py
  33. 90 0
      hackathon_starter/hackathon_starter/settings.py
  34. 8 0
      hackathon_starter/hackathon_starter/urls.py
  35. 14 0
      hackathon_starter/hackathon_starter/wsgi.py
  36. 10 0
      hackathon_starter/manage.py
  37. 17 0
      requirements.txt

+ 9 - 0
.hgignore

@@ -0,0 +1,9 @@
+syntax: glob
+
+.DS_Store
+db.sqlite3
+*.pyc
+bower_components/
+migrations/
+*.coverage
+Thumbs.db

+ 243 - 0
README.md

@@ -0,0 +1,243 @@
+Django Hackathon Starter
+------------------------
+
+## What is Django Hackathon Starter
+
+> Django Hackathon Starter aims to be a project which will aggegrate data from several APIs, producing a RESTful API which can be consumed by a client (also intended to be built). 
+
+Our deployment can be found [here](http://django-hackathon-starter.herokuapp.com/hackathon/).
+
+## Running this project
+
+In order to run this project, do the following:
+
+    # Install the requirements
+    pip install -r requirements.txt
+
+    # Perform database migrations
+    python manage.py migrate
+
+    # Run the server
+    python manage.py runserver
+
+## Front End dependencies
+
+This project relies on Bower for all front end libraries, to avoid pushing up large libraries such as `jQuery` and `Bootstrap`. To install `bower`, you will need to install `npm`, which now comes bundled with `node.js`. To install `npm`, simply install [node as follows](https://github.com/joyent/node/wiki/installing-node.js-via-package-manager). 
+
+First, install `bower`:
+
+    npm install -g bower
+
+Then:
+
+    bower install
+
+This will download and extract all the packages listed within `bower.json`. **Under no circumstance should any front-end libraries manually be pushed up to the repository.**
+
+Two routes have currently been set up, which are located at:
+
+    # First test route
+    http://127.0.0.1:8000/hackathon/
+
+    # Second test route
+    http://127.0.0.1:8000/hackathon/test
+
+
+## Testing
+
+This project aims to be as close to 100% tested as possible. For a good guide to testing using Python and `Mock`, `Nosetests` and `Unittests` libraries, please [read here](http://docs.python-guide.org/en/latest/writing/tests/).
+
+To run the tests:
+
+    hackthon-starter $ nosetests --with-coverage --cover-package=hackathon/
+
+You will see an output as shown below:
+
+    Name                                   Stmts   Miss  Cover   Missing
+    --------------------------------------------------------------------
+    hackathon/__init__.py                      0      0   100%
+    hackathon/admin.py                         3      3     0%   1-5
+    hackathon/forms.py                         9      9     0%   1-11
+    hackathon/migrations/0001_initial.py       6      6     0%   2-14
+    hackathon/migrations/__init__.py           0      0   100%
+    hackathon/models.py                        6      6     0%   1-11
+    hackathon/scripts/__init__.py              0      0   100%
+    hackathon/scripts/samplescript.py          5      5     0%   3-10
+    hackathon/scripts/steam.py                17     17     0%   1-24
+    hackathon/tests.py                         1      0   100%
+    hackathon/urls.py                          3      3     0%   1-5
+    hackathon/views.py                        52     52     0%   1-120
+    --------------------------------------------------------------------
+    TOTAL                                    102    101     1%
+    ----------------------------------------------------------------------
+    Ran 0 tests in 0.194s
+
+## Code evaluation
+
+In order to write clean code with a consistent style guide, we'll be using `Pylint` to maintain our code. Pylint will display a ton of messages regarding things that should be fixed. A sample output from running `pylint views.py` is shown below:
+
+    (web)λ pylint views.py
+    No config file found, using default configuration
+    ************* Module hackathon.views
+    C:  7, 0: Trailing whitespace (trailing-whitespace)
+    W: 11, 0: Found indentation with tabs instead of spaces (mixed-indentation)
+    W: 12, 0: Found indentation with tabs instead of spaces (mixed-indentation)
+    W: 15, 0: Found indentation with tabs instead of spaces (mixed-indentation)
+    C: 59, 0: Wrong continued indentation.
+                'hackathon/register.html',
+                ^     | (bad-continuation)
+    C: 60, 0: Wrong continued indentation.
+                {'user_form': user_form, 'registered': registered} )
+                ^     | (bad-continuation)
+    C: 60, 0: No space allowed before bracket
+                {'user_form': user_form, 'registered': registered} )
+                                                                   ^ (bad-whitespace)
+    C: 69, 0: Line too long (103/100) (line-too-long)
+    C:116, 0: Exactly one space required after comma
+        return render(request,'hackathon/steam.html', {"game": game })
+                             ^ (bad-whitespace)
+    C:116, 0: No space allowed before bracket
+        return render(request,'hackathon/steam.html', {"game": game })
+                                                                    ^ (bad-whitespace)
+    C:  1, 0: Missing module docstring (missing-docstring)
+    W:  7, 0: Relative import 'scripts.steam', should be 'hackathon.scripts.steam' (relative-import)
+    C: 10, 0: Missing function docstring (missing-docstring)
+    C: 14, 0: Missing function docstring (missing-docstring)
+    W: 14, 9: Unused argument 'request' (unused-argument)
+    C: 17, 0: Missing function docstring (missing-docstring)
+    C: 21, 0: Missing function docstring (missing-docstring)
+    C: 62, 0: Missing function docstring (missing-docstring)
+    C:103, 0: Missing function docstring (missing-docstring)
+    C:110, 0: Missing function docstring (missing-docstring)
+    C:113, 4: Invalid variable name "SteamUN" (invalid-name)
+    C:114, 4: Invalid variable name "steamID" (invalid-name)
+    C:118, 0: Missing function docstring (missing-docstring)
+    W:  4, 0: Unused RequestContext imported from django.template (unused-import)
+    W:  4, 0: Unused loader imported from django.template (unused-import)
+
+
+    Report
+    ======
+    53 statements analysed.
+
+    Statistics by type
+    ------------------
+
+    +---------+-------+-----------+-----------+------------+---------+
+    |type     |number |old number |difference |%documented |%badname |
+    +=========+=======+===========+===========+============+=========+
+    |module   |1      |NC         |NC         |0.00        |0.00     |
+    +---------+-------+-----------+-----------+------------+---------+
+    |class    |0      |NC         |NC         |0           |0        |
+    +---------+-------+-----------+-----------+------------+---------+
+    |method   |0      |NC         |NC         |0           |0        |
+    +---------+-------+-----------+-----------+------------+---------+
+    |function |8      |NC         |NC         |0.00        |0.00     |
+    +---------+-------+-----------+-----------+------------+---------+
+
+
+
+    External dependencies
+    ---------------------
+    ::
+
+        django
+          \-contrib
+          | \-auth (hackathon.views)
+          \-http (hackathon.views)
+          \-shortcuts (hackathon.views)
+          \-template (hackathon.views)
+            \-loader (hackathon.views)
+        hackathon
+          \-forms (hackathon.views)
+          \-scripts
+            \-steam (hackathon.views)
+
+
+
+    Raw metrics
+    -----------
+
+    +----------+-------+------+---------+-----------+
+    |type      |number |%     |previous |difference |
+    +==========+=======+======+=========+===========+
+    |code      |59     |59.00 |NC       |NC         |
+    +----------+-------+------+---------+-----------+
+    |docstring |1      |1.00  |NC       |NC         |
+    +----------+-------+------+---------+-----------+
+    |comment   |29     |29.00 |NC       |NC         |
+    +----------+-------+------+---------+-----------+
+    |empty     |11     |11.00 |NC       |NC         |
+    +----------+-------+------+---------+-----------+
+
+
+
+    Duplication
+    -----------
+
+    +-------------------------+------+---------+-----------+
+    |                         |now   |previous |difference |
+    +=========================+======+=========+===========+
+    |nb duplicated lines      |0     |NC       |NC         |
+    +-------------------------+------+---------+-----------+
+    |percent duplicated lines |0.000 |NC       |NC         |
+    +-------------------------+------+---------+-----------+
+
+
+
+    Messages by category
+    --------------------
+
+    +-----------+-------+---------+-----------+
+    |type       |number |previous |difference |
+    +===========+=======+=========+===========+
+    |convention |18     |NC       |NC         |
+    +-----------+-------+---------+-----------+
+    |refactor   |0      |NC       |NC         |
+    +-----------+-------+---------+-----------+
+    |warning    |7      |NC       |NC         |
+    +-----------+-------+---------+-----------+
+    |error      |0      |NC       |NC         |
+    +-----------+-------+---------+-----------+
+
+
+
+    Messages
+    --------
+
+    +--------------------+------------+
+    |message id          |occurrences |
+    +====================+============+
+    |missing-docstring   |9           |
+    +--------------------+------------+
+    |mixed-indentation   |3           |
+    +--------------------+------------+
+    |bad-whitespace      |3           |
+    +--------------------+------------+
+    |unused-import       |2           |
+    +--------------------+------------+
+    |invalid-name        |2           |
+    +--------------------+------------+
+    |bad-continuation    |2           |
+    +--------------------+------------+
+    |unused-argument     |1           |
+    +--------------------+------------+
+    |trailing-whitespace |1           |
+    +--------------------+------------+
+    |relative-import     |1           |
+    +--------------------+------------+
+    |line-too-long       |1           |
+    +--------------------+------------+
+
+
+
+    Global evaluation
+    -----------------
+    Your code has been rated at 5.28/10
+
+## Contributors
+
+* David Leonard
+* Eswari Swarna
+* Marco Quezada 
+* Wan Kim Mok

+ 19 - 0
bower.json

@@ -0,0 +1,19 @@
+{
+  "name": "django-hackathon-starter",
+  "version": "0.0.0",
+  "authors": [
+    "David Leonard <sephirothcloud1025@yahoo.com>"
+  ],
+  "description": "Django boilerplate project for hackathons",
+  "keywords": [
+    "Django",
+    "Python",
+    "API",
+    "RESTful"
+  ],
+  "license": "MIT",
+  "dependencies": {
+    "bootstrap": "~3.3.4",
+    "jquery": "~2.1.3"
+  }
+}

+ 0 - 0
hackathon_starter/hackathon/__init__.py


+ 5 - 0
hackathon_starter/hackathon/admin.py

@@ -0,0 +1,5 @@
+from django.contrib import admin
+from hackathon.models import UserProfile
+
+# Register your models here.
+admin.site.register(UserProfile)

+ 11 - 0
hackathon_starter/hackathon/forms.py

@@ -0,0 +1,11 @@
+from django.contrib.auth.forms import UserCreationForm
+from django.contrib.auth.models import User
+from django import forms
+from hackathon.models import UserProfile
+
+class UserForm(forms.ModelForm):
+    password = forms.CharField(widget=forms.PasswordInput())
+
+    class Meta:
+        model = User
+        fields = ('username', 'email', 'password')

+ 0 - 0
hackathon_starter/hackathon/migrations/__init__.py


+ 11 - 0
hackathon_starter/hackathon/models.py

@@ -0,0 +1,11 @@
+from django.db import models
+from django.contrib.auth.models import User
+
+# Create your models here.
+class UserProfile(models.Model):
+    # This line is required. Links UserProfile to a User model instance.
+    user = models.OneToOneField(User)
+
+    # Override the __unicode__() method to return out something meaningful!
+    def __unicode__(self):
+        return self.user.username

+ 0 - 0
hackathon_starter/hackathon/scripts/__init__.py


+ 130 - 0
hackathon_starter/hackathon/scripts/github.py

@@ -0,0 +1,130 @@
+'''
+Module github.py contains a handful of methods
+for interacting with Github data.
+'''
+
+import requests
+import simplejson as json
+
+########################
+# GITHUB API CONSTANTS #
+########################
+
+API_BASE_URL = 'https://api.github.com/'
+API_USERS_URL = API_BASE_URL + 'users/DrkSephy' + '?client_id=2404a1e21aebd902f6db' + '&client_secret=3da44769d4b7c9465fa4c812669148a163607c23'
+
+def getUserData():
+	req = requests.get(API_USERS_URL)
+	jsonList = []
+	jsonList.append(json.loads(req.content))
+	parsedData = []
+	userData = {}
+	for data in jsonList: 
+		userData['name'] = data['name']
+		userData['blog'] = data['blog']
+		userData['email'] = data['email']
+		userData['public_gists'] = data['public_gists']
+		userData['public_repos'] = data['public_repos']
+		userData['avatar_url'] = data['avatar_url']
+		userData['followers'] = data['followers']
+		userData['following'] = data['following']
+	parsedData.append(userData)
+
+	return parsedData
+	
+
+def getUserRepositories():
+	# Which page number of data are we looking at?
+	pageNumber = 1
+
+	# List of all our json
+	jsonList = []
+
+	# List of all repositories
+	repositories = []
+
+	# IDEA: Repeatedly loop over urls and check if the content has less than 30 entries.
+	# 		If it does, then we have iterated over all the data. Time to parse it. 
+	while True:
+		req = requests.get('https://api.github.com/users/DrkSephy/repos?page=' + str(pageNumber) + '&client_id=2404a1e21aebd902f6db&client_secret=3da44769d4b7c9465fa4c812669148a163607c23')
+		jsonList.append(json.loads(req.content))
+		if len(json.loads(req.content)) < 30:
+			break
+		elif len(json.loads(req.content)) >= 30:
+			pageNumber += 1
+
+	# Loop over our data and extract all of the repository names
+	for data in jsonList:
+		for datum in data:
+			repositories.append(datum['name'])
+
+	return repositories
+
+def getTopContributedRepositories(repos):
+	jsonList = []
+	for repo in repos:
+		# print repo
+		req = requests.get('https://api.github.com/repos/DrkSephy/' + repo + '/stats/contributors' + '?client_id=2404a1e21aebd902f6db' + '&client_secret=3da44769d4b7c9465fa4c812669148a163607c23')
+		jsonList.append(json.loads(req.content))
+
+	parsedData = []
+	# Keep track of which JSON set we are processing to get the repo name
+	indexNumber = -1
+	for item in jsonList:
+		indexNumber += 1
+		commits = {}
+		for data in item:
+			if data['author']['login'] == 'DrkSephy':
+				commits['author'] = data['author']['login']
+				commits['total'] = data['total']
+				commits['repo_name'] = repos[indexNumber]
+				parsedData.append(commits)
+
+	return parsedData
+
+def filterCommits(data):
+	maxCommits = []
+	for i in range(1, 10):
+		maxCommitedRepo = max(data, key=lambda x:x['total'])
+		maxCommits.append(maxCommitedRepo)
+		index = data.index(maxCommitedRepo)
+		data.pop(index)
+	return maxCommits
+	
+	
+def getStarGazerCount():
+	# Which page number of data are we looking at?
+	pageNumber = 1
+
+	# List of all our json
+	jsonList = []
+
+	# List of all repositories
+	stargazers = []
+
+	# IDEA: Repeatedly loop over urls and check if the content has less than 30 entries.
+	# 		If it does, then we have iterated over all the data. Time to parse it. 
+	while True:
+		req = requests.get('https://api.github.com/users/DrkSephy/repos?page=' + str(pageNumber) + '&client_id=2404a1e21aebd902f6db&client_secret=3da44769d4b7c9465fa4c812669148a163607c23')
+		jsonList.append(json.loads(req.content))
+		if len(json.loads(req.content)) < 30:
+			break
+		elif len(json.loads(req.content)) >= 30:
+			pageNumber += 1
+
+	# Loop over our data and extract all of the repository names
+	for data in jsonList:
+		for datum in data:
+			starData = {}
+			starData['stargazers_count'] = datum['stargazers_count']
+			starData['name'] = datum['name']
+			stargazers.append(starData)
+
+	return stargazers
+	
+
+
+
+
+
+

+ 10 - 0
hackathon_starter/hackathon/scripts/samplescript.py

@@ -0,0 +1,10 @@
+# Sample dummy script
+# This script is just to create this directory
+import requests
+
+def getSomeData(url):
+	# Get some data
+	req = requests.get(url) 
+	# Print the JSON
+	print req.json
+	return req

+ 29 - 0
hackathon_starter/hackathon/scripts/steam.py

@@ -0,0 +1,29 @@
+# pylint: disable=C0303
+
+import requests
+import json
+
+SteamUN = "Marorin"
+key = '231E98D442E52B87110816C3D5114A1D'
+
+def gamesPulling(steamID,key):
+    # Returns the JSON data from the Steam API based of one's 
+    # Steam ID number and returns a dictionary of gameids and minutes played.
+    steaminfo = {
+        'key': key, 
+        'steamid': steamID,
+        'format':'JSON',
+        'include_appinfo':'1'
+    }
+    r = requests.get('http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/', params=steaminfo)
+    d = json.loads(r.content)
+    return d['response']['games']
+ 
+def steamIDPulling(SteamUN,key):
+    #Pulls out and returns the steam id number for use in steam queries.
+    steaminfo = {'key': key,'vanityurl': SteamUN}
+    a = requests.get('http://api.steampowered.com/ISteamUser/ResolveVanityURL/v0001/', params=steaminfo)
+    k = json.loads(a.content)
+    SteamID = k['response']['steamid']
+    
+    return SteamID

+ 26 - 0
hackathon_starter/hackathon/static/css/form.css

@@ -0,0 +1,26 @@
+
+div.well{
+  height: 250px;
+} 
+
+.Absolute-Center {
+  margin: auto;
+  position: absolute;
+  top: 0; left: 0; bottom: 0; right: 0;
+}
+
+.Absolute-Center.is-Responsive {
+  width: 50%; 
+  height: 50%;
+  min-width: 200px;
+  max-width: 400px;
+  padding: 40px;
+}
+
+#logo-container{
+  margin: auto;
+  margin-bottom: 10px;
+  width:200px;
+  height:30px;
+  background-image:url('http://placehold.it/200x30/000000/ffffff/&text=Django+Hackathon+Starter');
+}

BIN
hackathon_starter/hackathon/static/img/github.png


BIN
hackathon_starter/hackathon/static/img/linkedin.jpg


BIN
hackathon_starter/hackathon/static/img/steam.png


BIN
hackathon_starter/hackathon/static/img/tumblr.png


+ 16 - 0
hackathon_starter/hackathon/templates/hackathon/api_examples.html

@@ -0,0 +1,16 @@
+<html>
+{% include 'hackathon/base.html' %}
+<body>
+
+
+	<div class="row text-center">
+	    <div class="col-sm-4"><a href="http://127.0.0.1:8000/hackathon/github/"><img src="/static/img/github.png"></a></div>
+	    <div class="col-sm-4"><a href="http://127.0.0.1:8000/hackathon/steam/"><img src="/static/img/steam.png"></a></div>
+	    <div class="col-sm-4"><img src="/static/img/github.png"></div>
+	    <div class="col-sm-4"><a href="http://127.0.0.1:8000/hackathon/tumblr/"><img src="/static/img/tumblr.png"></a></div>
+		<div class="col-sm-4"><a href="http://127.0.0.1:8000/hackathon/linkedin/"><img src="/static/img/linkedin.jpg"></a></div>
+
+  	</div>
+
+</body>
+</html>

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

@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <title> Django Hackathon Starter </title>
+    <script src="/static/bower_components/jquery/dist/jquery.js"></script>
+    <script type="text/javascript" src="/static/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
+    
+    
+    <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">
+  </head>
+    
+  <body>
+    <nav class="navbar navbar-default" role="navigation">
+      <div class="container-fluid">
+        <!-- Brand and toggle get grouped for better mobile display -->
+        <div class="navbar-header">
+          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+            <span class="sr-only">Toggle navigation</span>
+            <span class="icon-bar"></span>
+            <span class="icon-bar"></span>
+            <span class="icon-bar"></span>
+          </button>
+          <a class="navbar-brand" href="/hackathon">Django Hackathon Starter</a>
+      </div>
+
+      <!-- Collect the nav links, forms, and other content for toggling -->
+      <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+        <ul class="nav navbar-nav navbar-left">
+          {% if user.is_authenticated %}
+          <li><a href="/hackathon/api">API</a></li>
+          {% endif %}
+        </ul>
+        <ul class="nav navbar-nav navbar-right">
+          {% if not user.is_authenticated %}
+            <li class="active"><a href="/hackathon/register">Register <span class="sr-only">(current)</span></a></li>
+            
+            <li><a href="/hackathon/login">Login</a></li>
+          {% endif %}
+            
+        </ul>
+        
+        <ul  class="nav navbar-nav navbar-right">
+          {% if user.is_authenticated %}
+    
+            <li><a>Hello {{user}}</a></li>
+            <li><a href="/hackathon/logout/">Logout</a></li>
+          {% endif %}
+        </ul>
+          
+          
+          </li>
+         </ul>
+        </div><!-- /.navbar-collapse -->
+      </div><!-- /.container-fluid -->
+    </nav>
+  </body>
+</html>

+ 64 - 0
hackathon_starter/hackathon/templates/hackathon/github.html

@@ -0,0 +1,64 @@
+<!DOCTYPE html>
+<html>
+<body>
+	{% include 'hackathon/base.html' %}
+
+    <h2> Generic Information </h2>
+	<div class="col-lg-12">
+        <div class="table-responsive">
+            <table class="table table-bordered table-hover table-striped tablesorter">
+                <thead>
+                <tr>
+                <th class="header"> Username <i class="icon-sort"></i></th>
+                <th class="header"> Blog <i class="icon-sort"></i></th>
+                <th class="header"> Public Repos <i class="icon-sort"></i></th>
+                <th class="header"> Public Gists <i class="icon-sort"></i></th>
+                <th class="header"> Email <i class="icon-sort"></i></th>
+                <th class="header"> Followers <i class="icon-sort"></i></th>
+                <th class="header"> Following <i class="icon-sort"></i></th>
+                </tr>
+            </thead>
+            <tbody>
+
+            {% for key in data.userData %}
+                <tr>
+                    <td>{{ key.name }}</td>
+                    <td>{{ key.blog }}</td>
+                    <td>{{ key.public_repos }}</td>
+                    <td>{{ key.public_gists }}</td>
+                    <td>{{ key.email }}</td>
+                    <td>{{ key.followers }}</td>
+                    <td>{{ key.following }}</td>
+    			</tr>
+            {% endfor %}
+
+            </tbody>
+            </table>
+        </div>
+    </div>
+
+    <h2> Top Contributed Repositories </h2>
+    <div class="col-lg-3">
+        <div class="table-responsive">
+            <table class="table table-bordered table-hover table-striped tablesorter">
+                <thead>
+                <tr>
+                <th class="header"> Repository <i class="icon-sort"></i></th>
+                <th class="header"> Total <i class="icon-sort"></i></th>
+                </tr>
+            </thead>
+            <tbody>
+
+            {% for key in data.filteredData %}
+                <tr>
+                    <td>{{ key.repo_name }}</td>
+                    <td>{{ key.total }}</td>
+                </tr>
+            {% endfor %}
+
+            </tbody>
+            </table>
+        </div>
+    </div>
+</body>
+</html>

+ 14 - 0
hackathon_starter/hackathon/templates/hackathon/index.html

@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+
+<html>
+    {% include 'hackathon/base.html' %}
+
+    <body>
+    	{% if user.is_authenticated %}
+        	<h1>Api Example</h1>
+        	<strong>{{ boldmessage }}</strong><br />
+        {% else %}
+        	<h1> Please register/login! </h1>
+        {% endif %}
+    </body>
+</html>

+ 8 - 0
hackathon_starter/hackathon/templates/hackathon/linkedin.html

@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+<body>
+	{% include 'hackathon/base.html' %}
+	<h1> {{ title }} </h1> 
+</body>
+</html>
+

+ 31 - 0
hackathon_starter/hackathon/templates/hackathon/login.html

@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+    {% include 'hackathon/base.html' %}
+
+    <body>
+
+        <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>
+    </body>
+</html>

+ 40 - 0
hackathon_starter/hackathon/templates/hackathon/navbar.html

@@ -0,0 +1,40 @@
+<body>
+  <nav class="navbar navbar-default" role="navigation">
+      <div class="container-fluid">
+        <!-- Brand and toggle get grouped for better mobile display -->
+        <div class="navbar-header">
+          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
+            <span class="sr-only">Toggle navigation</span>
+            <span class="icon-bar"></span>
+            <span class="icon-bar"></span>
+            <span class="icon-bar"></span>
+          </button>
+          <a class="navbar-brand" href="#">Django Hackathon Starter</a>
+      </div>
+
+      <!-- Collect the nav links, forms, and other content for toggling -->
+      <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
+        <ul class="nav navbar-nav navbar-right">
+          {% if not user.is_authenticated %}
+            <li class="active"><a href="/hackathon/register">Register <span class="sr-only">(current)</span></a></li>
+            
+            <li><a href="/hackathon/login">Login</a></li>
+          {% endif %}
+            
+        </ul>
+        
+        <ul  class="nav navbar-nav navbar-right">
+          {% if user.is_authenticated %}
+    
+            <li><a>Hello {{user}}</a></li>
+            <li><a href="/hackathon/logout/">Logout</a></li>
+          {% endif %}
+        </ul>
+          
+          
+          </li>
+        </ul>
+      </div><!-- /.navbar-collapse -->
+    </div><!-- /.container-fluid -->
+  </nav>
+</body>

+ 42 - 0
hackathon_starter/hackathon/templates/hackathon/register.html

@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+    {% include 'hackathon/base.html' %}
+    <link rel="stylesheet" href="/static/css/form.css">
+    <body>
+        {% if registered %}
+          <strong>Thank you for registering!</strong>
+          <a href="/hackathon/">Return to the homepage.</a><br />
+        
+        {% else %}
+          <div class='container text-center'>
+              <h2 class="form-signin-heading">Sign Up</h2>
+              <br>
+              <form class="form-horizontal" id="user_form" method="post" action="/hackathon/register/"
+                enctype="multipart/form-data">
+                {% csrf_token %}
+                {% load bootstrap %} 
+
+                <table>
+                  <tr>
+                     
+                      <td class="container text-center">{{ user_form.username | bootstrap_horizontal}}</td>
+                  </tr>
+
+                  <tr>
+                     
+                      <td class="container text-center">{{ user_form.email | bootstrap_horizontal}}</td>
+                  </tr>
+
+                  <tr>
+                     
+                      <td class="container text-center">{{ user_form.password | bootstrap_horizontal}}</td>
+                  </tr>
+                </table>
+                <button class="btn btn-lg btn-primary" type="submit">Register</button>
+                <input type="hidden" name="submit" value="Register" />
+              </form>
+            </div>
+          {% endif %}
+    </body>
+</html>
+

+ 12 - 0
hackathon_starter/hackathon/templates/hackathon/steam.html

@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<body>
+<table>
+  <tr><th>Game ID</th><th>Game Name</th><th>Minutes Played</th></tr>
+  {% for game in game %}
+    {% comment %}  each game object is a dictionary with "appid", "name " and "playtime_forever" keys {% endcomment %}
+    <tr><td>{{ game.appid }}</td><td>{{game.name}} </td><td>{{ game.playtime_forever }}</td></tr>
+{% endfor %}
+</table>
+</body>
+</html>

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

@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+
+<body>
+	{% include 'hackathon/base.html' %}
+	<h1> {{ title }} </h1> 
+</body>
+
+</html>

+ 3 - 0
hackathon_starter/hackathon/tests.py

@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.

+ 8 - 0
hackathon_starter/hackathon/unittests/testcase.py

@@ -0,0 +1,8 @@
+import unittest
+
+def fun(x):
+    return x + 1
+
+class MyTest(unittest.TestCase):
+    def test(self):
+        self.assertEqual(fun(3), 4)

+ 16 - 0
hackathon_starter/hackathon/urls.py

@@ -0,0 +1,16 @@
+from django.conf.urls import patterns, url
+
+from hackathon import views
+
+urlpatterns = patterns('',
+    url(r'^$', views.index, name='index'),
+    url(r'^test/$', views.test, name='test'),
+    url(r'^register/$', views.register, name='register'),
+    url(r'^login/$', views.user_login, name='login'),
+    url(r'^logout/$', views.user_logout, name='logout'),
+    url(r'^api/$', views.api_examples, name='api'),
+    url(r'^steam/$', views.steam, name='steam'),
+    url(r'^github/$', views.github, name='github'),
+    url(r'^tumblr/$', views.tumblr, name='tumblr'),
+    url(r'^linkedin/$', views.linkedin, name='linkedin')
+)

+ 144 - 0
hackathon_starter/hackathon/views.py

@@ -0,0 +1,144 @@
+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 getUserData, getUserRepositories, getTopContributedRepositories, filterCommits, getStarGazerCount
+
+
+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)
+    stargazers = getStarGazerCount()
+    print stargazers
+    # Store data into a dictionary for rendering
+    allData['userData'] = userData
+    allData['filteredData'] = filtered
+
+    return render(request, 'hackathon/github.html', { 'data': allData })
+
+def tumblr(request):
+    context = {'title': 'Tumblr Example'}
+    return render(request, 'hackathon/tumblr.html', context)
+
+def linkedin(request):
+    context = {'title': 'linkedin Example'}
+    return render(request, 'hackathon/linkedin.html', context)
+

+ 0 - 0
hackathon_starter/hackathon_starter/__init__.py


+ 90 - 0
hackathon_starter/hackathon_starter/settings.py

@@ -0,0 +1,90 @@
+"""
+Django settings for hackathon_starter project.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/1.7/topics/settings/
+
+For the full list of settings and their values, see
+https://docs.djangoproject.com/en/1.7/ref/settings/
+"""
+
+# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
+import os
+BASE_DIR = os.path.dirname(os.path.dirname(__file__))
+
+
+# Quick-start development settings - unsuitable for production
+# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
+
+# SECURITY WARNING: keep the secret key used in production secret!
+SECRET_KEY = 'keuhh=0*%do-ayvy*m2k=vss*$7)j8q!@u0+d^na7mi2(^!l!d'
+
+# SECURITY WARNING: don't run with debug turned on in production!
+DEBUG = True
+
+TEMPLATE_DEBUG = True
+
+ALLOWED_HOSTS = []
+
+
+# Application definition
+
+INSTALLED_APPS = (
+    'django.contrib.admin',
+    'django.contrib.auth',
+    'django.contrib.contenttypes',
+    'django.contrib.sessions',
+    'django.contrib.messages',
+    'django.contrib.staticfiles',
+    'hackathon',
+    'bootstrapform',
+    # 'django_openid',
+)
+
+MIDDLEWARE_CLASSES = (
+    'django.contrib.sessions.middleware.SessionMiddleware',
+    'django.middleware.common.CommonMiddleware',
+    'django.middleware.csrf.CsrfViewMiddleware',
+    'django.contrib.auth.middleware.AuthenticationMiddleware',
+    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
+    'django.contrib.messages.middleware.MessageMiddleware',
+    'django.middleware.clickjacking.XFrameOptionsMiddleware',
+    #'django_openid_consumer.SessionConsumer',
+)
+
+ROOT_URLCONF = 'hackathon_starter.urls'
+
+WSGI_APPLICATION = 'hackathon_starter.wsgi.application'
+
+
+# Database
+# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
+
+DATABASES = {
+    'default': {
+        'ENGINE': 'django.db.backends.sqlite3',
+        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
+    }
+}
+
+# Internationalization
+# https://docs.djangoproject.com/en/1.7/topics/i18n/
+
+LANGUAGE_CODE = 'en-us'
+
+TIME_ZONE = 'UTC'
+
+USE_I18N = True
+
+USE_L10N = True
+
+USE_TZ = True
+
+
+# Static files (CSS, JavaScript, Images)
+# https://docs.djangoproject.com/en/1.7/howto/static-files/
+
+STATIC_URL = '/static/'
+
+TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
+

+ 8 - 0
hackathon_starter/hackathon_starter/urls.py

@@ -0,0 +1,8 @@
+from django.conf.urls import patterns, include, url
+from django.contrib import admin
+
+urlpatterns = patterns('',
+    url(r'^hackathon/', include('hackathon.urls')),
+    url(r'^admin/', include(admin.site.urls)),
+    # url(r'^openid/(.*)', SessionConsumer()),
+)

+ 14 - 0
hackathon_starter/hackathon_starter/wsgi.py

@@ -0,0 +1,14 @@
+"""
+WSGI config for hackathon_starter project.
+
+It exposes the WSGI callable as a module-level variable named ``application``.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/
+"""
+
+import os
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hackathon_starter.settings")
+
+from django.core.wsgi import get_wsgi_application
+application = get_wsgi_application()

+ 10 - 0
hackathon_starter/manage.py

@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+import os
+import sys
+
+if __name__ == "__main__":
+    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hackathon_starter.settings")
+
+    from django.core.management import execute_from_command_line
+
+    execute_from_command_line(sys.argv)

+ 17 - 0
requirements.txt

@@ -0,0 +1,17 @@
+Django==1.7.6
+astroid==1.3.6
+coverage==4.0a5
+django-bootstrap-form==3.2
+django-bootstrap-forms==0.1
+django-bower==5.0.2
+django-openid==0.3a1
+logilab-common==0.63.2
+mock==1.0.1
+nose==1.3.4
+pylint==1.4.3
+python-openid==2.2.5
+requests==2.6.0
+simplejson==3.6.5
+six==1.9.0
+wsgiref==0.1.2
+pytumblr==0.0.6