Explorar o código

Merged DrkSephy/django-hackathon-starter into default

Eswari Pravallika Swarna %!s(int64=10) %!d(string=hai) anos
pai
achega
50dd8742f7
Modificáronse 100 ficheiros con 9826 adicións e 226 borrados
  1. 6 1
      .hgignore
  2. 60 1
      README.md
  3. 22 0
      angular/bower.json
  4. 40 0
      angular/index.html
  5. 24 0
      angular/partials/githubTopContributions.partial.html
  6. 34 0
      angular/partials/githubUser.partial.html
  7. 24 0
      angular/partials/snippets.partial.html
  8. 34 0
      angular/scripts/app.js
  9. 13 0
      angular/scripts/controllers/appController.js
  10. 10 0
      angular/scripts/controllers/githubTopContributionsController.js
  11. 10 0
      angular/scripts/controllers/githubUserController.js
  12. 10 0
      angular/scripts/controllers/restAppController.js
  13. 12 0
      angular/scripts/factories/githubTopContributionsFactory.js
  14. 12 0
      angular/scripts/factories/githubUserFactory.js
  15. 12 0
      angular/scripts/factories/restAppFactory.js
  16. 1 1
      bower.json
  17. 192 0
      hackathon_starter/Makefile
  18. 293 0
      hackathon_starter/conf.py
  19. 3 0
      hackathon_starter/hackathon/models.py
  20. 239 120
      hackathon_starter/hackathon/scripts/github.py
  21. 68 0
      hackathon_starter/hackathon/scripts/instagram.py
  22. 24 27
      hackathon_starter/hackathon/scripts/tumblr.py
  23. 13 0
      hackathon_starter/hackathon/scripts/twilioapi.py
  24. 6 5
      hackathon_starter/hackathon/templates/hackathon/api_examples.html
  25. 17 0
      hackathon_starter/hackathon/templates/hackathon/instagram.html
  26. 6 2
      hackathon_starter/hackathon/templates/hackathon/login.html
  27. 0 1
      hackathon_starter/hackathon/templates/hackathon/tumblr.html
  28. 12 0
      hackathon_starter/hackathon/templates/hackathon/twilio.html
  29. 8 2
      hackathon_starter/hackathon/urls.py
  30. 195 66
      hackathon_starter/hackathon/views.py
  31. 6 0
      hackathon_starter/hackathon_starter/settings.py
  32. 46 0
      hackathon_starter/index.rst
  33. 263 0
      hackathon_starter/make.bat
  34. 3 0
      ionic/.bowerrc
  35. 6 0
      ionic/.gitignore
  36. 26 0
      ionic/README.md
  37. 7 0
      ionic/bower.json
  38. 49 0
      ionic/config.xml
  39. 50 0
      ionic/gulpfile.js
  40. 83 0
      ionic/hooks/README.md
  41. 94 0
      ionic/hooks/after_prepare/010_add_platform_class.js
  42. 4 0
      ionic/ionic.project
  43. 21 0
      ionic/package.json
  44. 11 0
      ionic/plugins/ios.json
  45. BIN=BIN
      ionic/resources/android/icon/drawable-hdpi-icon.png
  46. BIN=BIN
      ionic/resources/android/icon/drawable-ldpi-icon.png
  47. BIN=BIN
      ionic/resources/android/icon/drawable-mdpi-icon.png
  48. BIN=BIN
      ionic/resources/android/icon/drawable-xhdpi-icon.png
  49. BIN=BIN
      ionic/resources/android/icon/drawable-xxhdpi-icon.png
  50. BIN=BIN
      ionic/resources/android/icon/drawable-xxxhdpi-icon.png
  51. BIN=BIN
      ionic/resources/android/splash/drawable-land-hdpi-screen.png
  52. BIN=BIN
      ionic/resources/android/splash/drawable-land-ldpi-screen.png
  53. BIN=BIN
      ionic/resources/android/splash/drawable-land-mdpi-screen.png
  54. BIN=BIN
      ionic/resources/android/splash/drawable-land-xhdpi-screen.png
  55. BIN=BIN
      ionic/resources/android/splash/drawable-land-xxhdpi-screen.png
  56. BIN=BIN
      ionic/resources/android/splash/drawable-land-xxxhdpi-screen.png
  57. BIN=BIN
      ionic/resources/android/splash/drawable-port-hdpi-screen.png
  58. BIN=BIN
      ionic/resources/android/splash/drawable-port-ldpi-screen.png
  59. BIN=BIN
      ionic/resources/android/splash/drawable-port-mdpi-screen.png
  60. BIN=BIN
      ionic/resources/android/splash/drawable-port-xhdpi-screen.png
  61. BIN=BIN
      ionic/resources/android/splash/drawable-port-xxhdpi-screen.png
  62. BIN=BIN
      ionic/resources/android/splash/drawable-port-xxxhdpi-screen.png
  63. BIN=BIN
      ionic/resources/icon.png
  64. BIN=BIN
      ionic/resources/ios/icon/icon-40.png
  65. BIN=BIN
      ionic/resources/ios/icon/icon-40@2x.png
  66. BIN=BIN
      ionic/resources/ios/icon/icon-50.png
  67. BIN=BIN
      ionic/resources/ios/icon/icon-50@2x.png
  68. BIN=BIN
      ionic/resources/ios/icon/icon-60.png
  69. BIN=BIN
      ionic/resources/ios/icon/icon-60@2x.png
  70. BIN=BIN
      ionic/resources/ios/icon/icon-60@3x.png
  71. BIN=BIN
      ionic/resources/ios/icon/icon-72.png
  72. BIN=BIN
      ionic/resources/ios/icon/icon-72@2x.png
  73. BIN=BIN
      ionic/resources/ios/icon/icon-76.png
  74. BIN=BIN
      ionic/resources/ios/icon/icon-76@2x.png
  75. BIN=BIN
      ionic/resources/ios/icon/icon-small.png
  76. BIN=BIN
      ionic/resources/ios/icon/icon-small@2x.png
  77. BIN=BIN
      ionic/resources/ios/icon/icon-small@3x.png
  78. BIN=BIN
      ionic/resources/ios/icon/icon.png
  79. BIN=BIN
      ionic/resources/ios/icon/icon@2x.png
  80. BIN=BIN
      ionic/resources/ios/splash/Default-568h@2x~iphone.png
  81. BIN=BIN
      ionic/resources/ios/splash/Default-667h.png
  82. BIN=BIN
      ionic/resources/ios/splash/Default-736h.png
  83. BIN=BIN
      ionic/resources/ios/splash/Default-Landscape-736h.png
  84. BIN=BIN
      ionic/resources/ios/splash/Default-Landscape@2x~ipad.png
  85. BIN=BIN
      ionic/resources/ios/splash/Default-Landscape~ipad.png
  86. BIN=BIN
      ionic/resources/ios/splash/Default-Portrait@2x~ipad.png
  87. BIN=BIN
      ionic/resources/ios/splash/Default-Portrait~ipad.png
  88. BIN=BIN
      ionic/resources/ios/splash/Default@2x~iphone.png
  89. BIN=BIN
      ionic/resources/ios/splash/Default~iphone.png
  90. BIN=BIN
      ionic/resources/splash.png
  91. 23 0
      ionic/scss/ionic.app.scss
  92. 1 0
      ionic/www/css/style.css
  93. BIN=BIN
      ionic/www/img/ionic.png
  94. 36 0
      ionic/www/index.html
  95. 51 0
      ionic/www/js/app.js
  96. 14 0
      ionic/www/js/controllers.js
  97. 9 0
      ionic/www/js/services.js
  98. 7600 0
      ionic/www/lib/ionic/css/ionic.css
  99. 23 0
      ionic/www/lib/ionic/css/ionic.min.css
  100. 0 0
      ionic/www/lib/ionic/fonts/ionicons.eot

+ 6 - 1
.hgignore

@@ -6,4 +6,9 @@ db.sqlite3
 bower_components/
 migrations/
 *.coverage
-Thumbs.db
+Thumbs.db
+*/vendor
+ionic/platforms
+hackathon_starter/_build
+hackathon_starter/_static
+hackathon_starter/_templates

+ 60 - 1
README.md

@@ -30,10 +30,24 @@ First, install `bower`:
 
 Then:
 
+    # In the same directory as requirements.txt
     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.**
 
+Then:
+
+    # move bower_components into static folder
+    mv bower_components/ hackathon_starter/hackathon/static
+
+To install the front-end dependencies for the AngularJS client, do the following:
+
+    cd public
+    bower install
+    # Rename bower_components folder to vendor
+    mv bower_components/ vendor/
+
+
 ## 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/).
@@ -44,7 +58,7 @@ To run the tests:
 
 ## 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:
+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. 
 
 
 ## RESTful endpoints
@@ -69,6 +83,51 @@ The list will appear empty at first, since the database model `Snippets` will be
 
 The above will open the Django shell, and allow you to create objects and save them to the database. If you then navigate to the URL above, you will see the JSON output of the database model, `Snippet`. 
 
+## AngularJS Client
+
+As of `April 11th, 2015`, there is now a sample AngularJS client which pulls data from the Django sample API endpoint: `http://127.0.0.1:8000/hackathon/snippets/`. To test it, do the following:
+
+* Within the `public/` directory, run `python -m SimpleHTTPServer 80`. You may need `sudo` on your respective Operating System.
+* Navigate to: `http://localhost/#/snippets`. Here you will see whatever content was stored within the database model, `Snippet`. If nothing shows up, go back to the `RESTful endpoints` step to populate your database with some `Snippet` objects. 
+
+## Ionic Client
+
+As of `April 11th, 2015`, there is now a sample Ionic application which works on iOS. This application pulls data from the Django sample API endpoint: `http://127.0.0.1:8000/hackathon/snippets/`. In order to successfully run this project, you must do the following:
+
+    # Make sure django-hackathon-starter is running
+    python manage.py runserver
+
+    # Install cordova and ionic
+    # On a Mac, you'll need to use sudo
+    npm install -g cordova ionic 
+
+    cd ionic
+
+    # Add support for the iOS platform
+    ionic platform add ios
+
+    # Build the project
+    ionic build ios
+
+Running the final command, `ionic build ios` will generate an `.xcodeproj` file within `platforms/ionic`. You can open it and then run it, which you should then see a list of all the `Snippet` objects from the Django Hackathon Starter database. 
+
+You can also test the project in the browser by doing the following:
+
+    cd ionic
+    ionic serve 
+
+Running `ionic serve` will automatically open up your web browser and run the application.
+
+
+## Building the documentation
+
+In order to build the documentation for this project:
+
+    $ cd hackathon_starter
+    $ make html
+
+The output is stored within `_build/html`. Open up `index.html` to view the documentation.
+
 ## Contributors
 
 * David Leonard

+ 22 - 0
angular/bower.json

@@ -0,0 +1,22 @@
+{
+  "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",
+    "bootstrap-social": "~4",
+    "angular": "~1.3.15",
+    "angular-ui-router": "~0.2.13"
+  }
+}

+ 40 - 0
angular/index.html

@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html lang="en-us" data-ng-app="restApp" data-ng-controller="appController">
+    <head>
+        <meta charset="utf-8">
+
+        <title data-ng-bind="pageTitle + ' | RestAPP'">RestAPP</title>
+
+        <!-- AngularJS -->
+        <script src="vendor/angular/angular.js"></script>
+        <script src="vendor/angular-ui-router/release/angular-ui-router.min.js"></script>
+
+        <!-- Bootstrap Core CSS -->
+        <link href="vendor/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
+
+        <!-- jQuery -->
+        <script src="vendor/jquery/dist/jquery.min.js"></script>
+
+        <!-- Bootstrap Core JavaScript -->
+        <script src="vendor/bootstrap/dist/js/bootstrap.min.js"></script>
+
+        <!-- Main application file -->
+        <script src="scripts/app.js"></script>
+
+        <!-- Controllers --> 
+        <script src="scripts/controllers/appController.js"></script>
+        <script src="scripts/controllers/restAppController.js"></script>
+        <script src="scripts/controllers/githubUserController.js"></script>
+        <script src="scripts/controllers/githubTopContributionsController.js"></script>
+
+        <!-- Factories -->
+        <script src="scripts/factories/restAppFactory.js"></script>
+        <script src="scripts/factories/githubUserFactory.js"></script>
+        <script src="scripts/factories/githubTopContributionsFactory.js"></script>
+
+    </head>
+
+    <body>
+        <div data-ui-view></div>
+    </body>
+</html>

+ 24 - 0
angular/partials/githubTopContributions.partial.html

@@ -0,0 +1,24 @@
+<div class="row text-center">
+	<h1> Github Top Contributed Repositories</h1>
+</div>
+
+<div class="col-lg-12">
+    <div class="table-responsive">
+        <table class="table table-bordered table-hover table-striped tablesorter">
+            <thead>
+                <tr>
+                    <th class="header">Repository Name</th>
+                    <th class="header">Total Commits</th>
+                    <th class="header">Author</th>
+                </tr>
+            </thead>
+            <tbody>
+                <tr data-ng-repeat="data in githubTopContributions.data.committed">
+                        <td>{{ data.repo_name }}</td>
+                        <td>{{ data.total }}</td>
+                        <td>{{ data.author }}</td>
+                </tr>
+            </tbody>
+        </table>
+    </div>
+</div>

+ 34 - 0
angular/partials/githubUser.partial.html

@@ -0,0 +1,34 @@
+<div class="row text-center"> <h1> Github User Data </h1>
+</div>
+
+<div class="col-lg-12">
+    <div class="table-responsive">
+        <table class="table table-bordered table-hover table-striped tablesorter">
+            <thead>
+                <tr>
+                    <th class="header">Public Repos</th>
+                    <th class="header">Public Gists</th>
+                    <th class="header">Name</th>
+                    <th class="header">Blog</th>
+                    <th class="header">Followers</th>
+                    <th class="header">Following</th>
+                    <th class="header">E-mail</th>
+                </tr>
+            </thead>
+            <tbody>
+                <tr data-ng-repeat="data in githubUser.data.userData">
+                        <td>{{ data.public_repos }}</td>
+                        <td>{{ data.public_gists }}</td>
+                        <td>{{ data.name }}</td>
+                        <td>{{ data.blog }}</td>
+                        <td>{{ data.followers }}</td>
+                        <td>{{ data.following }}</td>
+                        <td>{{ data.email }}</td>
+                </tr>
+            </tbody>
+        </table>
+    </div>
+</div>
+
+
+

+ 24 - 0
angular/partials/snippets.partial.html

@@ -0,0 +1,24 @@
+<div class="row text-center">
+	<h1> Code Snippets </h1>
+</div>
+
+<div class="col-lg-12">
+    <div class="table-responsive">
+        <table class="table table-bordered table-hover table-striped tablesorter">
+            <thead>
+                <tr>
+                    <th class="header">Code</th>
+                    <th class="header">ID</th>
+                    <th class="header">Line Numbers</th>
+                </tr>
+            </thead>
+            <tbody>
+                <tr data-ng-repeat="data in restData">
+	                    <td>{{ data.code }}</td>
+	                    <td>{{ data.id }}</td>
+	                    <td>{{ data.linenos }}</td>
+                </tr>
+            </tbody>
+        </table>
+    </div>
+</div>

+ 34 - 0
angular/scripts/app.js

@@ -0,0 +1,34 @@
+'use strict';
+
+var restApp = angular.module('restApp', [
+    'ui.router'
+])
+.config(function($stateProvider, $urlRouterProvider) {
+    $stateProvider
+        .state('snippets', {
+            url: '/snippets',
+            templateUrl: 'partials/snippets.partial.html',
+            controller: 'restAppController',
+            data: {
+                pageTitle: 'Sample API Data'
+            }
+        })
+
+        .state('githubUser', {
+            url: '/githubUser',
+            templateUrl: 'partials/githubUser.partial.html',
+            controller: 'githubUserController',
+            data: {
+                pageTitle: 'Github User Data'
+            }
+        })
+
+        .state('githubTopContributions', {
+            url: '/githubTopContributions',
+            templateUrl: 'partials/githubTopContributions.partial.html',
+            controller: 'githubTopContributionsController',
+            data: {
+                pageTitle: 'Top Contributions on Github'
+            }
+        });
+});

+ 13 - 0
angular/scripts/controllers/appController.js

@@ -0,0 +1,13 @@
+'use strict';
+
+restApp.controller('appController', function($scope, $location) {
+    $scope.siteTitle = 'REST App';
+
+    $scope.$on('$stateChangeSuccess', function(event, toState) {
+        $scope.pageTitle = toState.data.pageTitle;
+    });
+
+    $scope.isActive = function(viewLocation) {
+        return viewLocation === $location.path();
+    };
+});

+ 10 - 0
angular/scripts/controllers/githubTopContributionsController.js

@@ -0,0 +1,10 @@
+'use strict';
+
+restApp.controller('githubTopContributionsController', function($scope, githubTopContributionsFactory) {
+    $scope.githubTopContributions = {};
+    
+    $scope.githubTopContributions = githubTopContributionsFactory.get().success(function(data) {
+    	$scope.githubTopContributions = data;
+    	console.log(data);
+    });
+});

+ 10 - 0
angular/scripts/controllers/githubUserController.js

@@ -0,0 +1,10 @@
+'use strict';
+
+restApp.controller('githubUserController', function($scope, githubUserFactory) {
+    $scope.githubUser = {};
+    
+    $scope.githubUser = githubUserFactory.get().success(function(data) {
+    	$scope.githubUser = data;
+    	console.log(data);
+    });
+});

+ 10 - 0
angular/scripts/controllers/restAppController.js

@@ -0,0 +1,10 @@
+'use strict';
+
+restApp.controller('restAppController', function($scope, restAppFactory) {
+    $scope.restData = {};
+    
+    $scope.restData = restAppFactory.get().success(function(data) {
+    	$scope.restData = data;
+    	console.log(data);
+    });
+});

+ 12 - 0
angular/scripts/factories/githubTopContributionsFactory.js

@@ -0,0 +1,12 @@
+'use strict';
+
+restApp.factory('githubTopContributionsFactory', function($http) {
+    return {
+        get: function() {
+            return $http({
+                url: 'http://127.0.0.1:8000/hackathon/githubTopRepositories/',
+                method: 'GET',
+            });
+        }
+    };
+});

+ 12 - 0
angular/scripts/factories/githubUserFactory.js

@@ -0,0 +1,12 @@
+'use strict';
+
+restApp.factory('githubUserFactory', function($http) {
+    return {
+        get: function() {
+            return $http({
+                url: 'http://127.0.0.1:8000/hackathon/githubUser/',
+                method: 'GET',
+            });
+        }
+    };
+});

+ 12 - 0
angular/scripts/factories/restAppFactory.js

@@ -0,0 +1,12 @@
+'use strict';
+
+restApp.factory('restAppFactory', function($http) {
+    return {
+        get: function() {
+            return $http({
+                url: 'http://127.0.0.1:8000/hackathon/snippets/',
+                method: 'GET',
+            });
+        }
+    };
+});

+ 1 - 1
bower.json

@@ -15,6 +15,6 @@
   "dependencies": {
     "bootstrap": "~3.3.4",
     "jquery": "~2.1.3",
-    "bootstrap-social":"~4"
+    "bootstrap-social": "~4"
   }
 }

+ 192 - 0
hackathon_starter/Makefile

@@ -0,0 +1,192 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = sphinx-build
+PAPER         =
+BUILDDIR      = _build
+
+# User-friendly check for sphinx-build
+ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
+$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
+endif
+
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext
+
+help:
+	@echo "Please use \`make <target>' where <target> is one of"
+	@echo "  html       to make standalone HTML files"
+	@echo "  dirhtml    to make HTML files named index.html in directories"
+	@echo "  singlehtml to make a single large HTML file"
+	@echo "  pickle     to make pickle files"
+	@echo "  json       to make JSON files"
+	@echo "  htmlhelp   to make HTML files and a HTML help project"
+	@echo "  qthelp     to make HTML files and a qthelp project"
+	@echo "  applehelp  to make an Apple Help Book"
+	@echo "  devhelp    to make HTML files and a Devhelp project"
+	@echo "  epub       to make an epub"
+	@echo "  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  latexpdf   to make LaTeX files and run them through pdflatex"
+	@echo "  latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
+	@echo "  text       to make text files"
+	@echo "  man        to make manual pages"
+	@echo "  texinfo    to make Texinfo files"
+	@echo "  info       to make Texinfo files and run them through makeinfo"
+	@echo "  gettext    to make PO message catalogs"
+	@echo "  changes    to make an overview of all changed/added/deprecated items"
+	@echo "  xml        to make Docutils-native XML files"
+	@echo "  pseudoxml  to make pseudoxml-XML files for display purposes"
+	@echo "  linkcheck  to check all external links for integrity"
+	@echo "  doctest    to run all doctests embedded in the documentation (if enabled)"
+	@echo "  coverage   to run coverage check of the documentation (if enabled)"
+
+clean:
+	rm -rf $(BUILDDIR)/*
+
+html:
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+	$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+	@echo
+	@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files."
+
+json:
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+	@echo
+	@echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+	@echo
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
+	      ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+	@echo
+	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
+	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/DjangoHackathonStarter.qhcp"
+	@echo "To view the help file:"
+	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/DjangoHackathonStarter.qhc"
+
+applehelp:
+	$(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
+	@echo
+	@echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
+	@echo "N.B. You won't be able to view it unless you put it in" \
+	      "~/Library/Documentation/Help or install it in your application" \
+	      "bundle."
+
+devhelp:
+	$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+	@echo
+	@echo "Build finished."
+	@echo "To view the help file:"
+	@echo "# mkdir -p $$HOME/.local/share/devhelp/DjangoHackathonStarter"
+	@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/DjangoHackathonStarter"
+	@echo "# devhelp"
+
+epub:
+	$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+	@echo
+	@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+	@echo "Run \`make' in that directory to run these through (pdf)latex" \
+	      "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo "Running LaTeX files through pdflatex..."
+	$(MAKE) -C $(BUILDDIR)/latex all-pdf
+	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+latexpdfja:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo "Running LaTeX files through platex and dvipdfmx..."
+	$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
+	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+	$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+	@echo
+	@echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+	@echo
+	@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+texinfo:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo
+	@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+	@echo "Run \`make' in that directory to run these through makeinfo" \
+	      "(use \`make info' here to do that automatically)."
+
+info:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo "Running Texinfo files through makeinfo..."
+	make -C $(BUILDDIR)/texinfo info
+	@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+gettext:
+	$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+	@echo
+	@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+changes:
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+	@echo
+	@echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+	@echo
+	@echo "Link check complete; look for any errors in the above output " \
+	      "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+	@echo "Testing of doctests in the sources finished, look at the " \
+	      "results in $(BUILDDIR)/doctest/output.txt."
+
+coverage:
+	$(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
+	@echo "Testing of coverage in the sources finished, look at the " \
+	      "results in $(BUILDDIR)/coverage/python.txt."
+
+xml:
+	$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
+	@echo
+	@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
+
+pseudoxml:
+	$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
+	@echo
+	@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."

+ 293 - 0
hackathon_starter/conf.py

@@ -0,0 +1,293 @@
+# -*- coding: utf-8 -*-
+#
+# Django Hackathon Starter documentation build configuration file, created by
+# sphinx-quickstart on Sun Apr 12 22:33:44 2015.
+#
+# This file is execfile()d with the current directory set to its
+# containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys
+import os
+import shlex
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.insert(0, os.path.abspath('.'))
+sys.path.insert(0, os.path.abspath("hackathon/scripts/"))
+
+# -- General configuration ------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+# ones.
+extensions = [
+    'sphinx.ext.autodoc',
+    'sphinx.ext.doctest',
+    'sphinx.ext.todo',
+    'sphinx.ext.coverage',
+    'sphinx.ext.mathjax',
+    'sphinx.ext.ifconfig',
+    'sphinx.ext.viewcode',
+]
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix(es) of source filenames.
+# You can specify multiple suffix as a list of string:
+# source_suffix = ['.rst', '.md']
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'Django Hackathon Starter'
+copyright = u'2015, David Leonard, Wan Kim Mok, Marco Quezada, Eswari Pravallika Swarna'
+author = u'David Leonard, Wan Kim Mok, Marco Quezada, Eswari Pravallika Swarna'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '0.0.1'
+# The full version, including alpha/beta/rc tags.
+release = '0.0.1'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#
+# This is also used if you do content translation via gettext catalogs.
+# Usually you set "language" from the command line for these cases.
+language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all
+# documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+# If true, keep warnings as "system message" paragraphs in the built documents.
+#keep_warnings = False
+
+# If true, `todo` and `todoList` produce output, else they produce nothing.
+todo_include_todos = True
+
+
+# -- Options for HTML output ----------------------------------------------
+
+# The theme to use for HTML and HTML Help pages.  See the documentation for
+# a list of builtin themes.
+html_theme = 'alabaster'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further.  For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents.  If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar.  Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# Add any extra paths that contain custom files (such as robots.txt or
+# .htaccess) here, relative to this directory. These files are copied
+# directly to the root of the documentation.
+#html_extra_path = []
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it.  The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Language to be used for generating the HTML full-text search index.
+# Sphinx supports the following languages:
+#   'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
+#   'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
+#html_search_language = 'en'
+
+# A dictionary with options for the search language support, empty by default.
+# Now only 'ja' uses this config value
+#html_search_options = {'type': 'default'}
+
+# The name of a javascript file (relative to the configuration directory) that
+# implements a search results scorer. If empty, the default will be used.
+#html_search_scorer = 'scorer.js'
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'DjangoHackathonStarterdoc'
+
+# -- Options for LaTeX output ---------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+
+# Latex figure (float) alignment
+#'figure_align': 'htbp',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title,
+#  author, documentclass [howto, manual, or own class]).
+latex_documents = [
+  (master_doc, 'DjangoHackathonStarter.tex', u'Django Hackathon Starter Documentation',
+   u'David Leonard, Wan Kim Mok, Marco Quezada, Eswari Pravallika Swarna', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output ---------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+    (master_doc, 'djangohackathonstarter', u'Django Hackathon Starter Documentation',
+     [author], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- Options for Texinfo output -------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+#  dir menu entry, description, category)
+texinfo_documents = [
+  (master_doc, 'DjangoHackathonStarter', u'Django Hackathon Starter Documentation',
+   author, 'DjangoHackathonStarter', 'One line description of project.',
+   'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'
+
+# If true, do not generate a @detailmenu in the "Top" node's menu.
+#texinfo_no_detailmenu = False

+ 3 - 0
hackathon_starter/hackathon/models.py

@@ -15,6 +15,9 @@ class Profile(models.Model):
     oauth_token = models.CharField(max_length=200)
     oauth_secret = models.CharField(max_length=200)
 
+    def __unicode__(self):
+        return unicode(self.user)
+
 class Snippet(models.Model):
     created = models.DateTimeField(auto_now_add=True)
     title = models.CharField(max_length=100, blank=True, default='')

+ 239 - 120
hackathon_starter/hackathon/scripts/github.py

@@ -1,6 +1,6 @@
 '''
-Module github.py contains a handful of methods
-for interacting with Github data.
+github.py contains a handful of methods for interacting 
+with Github data and returning the responses as JSON.
 '''
 
 import requests
@@ -13,149 +13,268 @@ import simplejson as json
 API_BASE_URL = 'https://api.github.com/users/DrkSephy'
 
 def getUserData(clientID, clientSecret):
-	'''Get generic Github User data.'''
-	url = API_BASE_URL + '?' + clientID + '&' + clientSecret
-	req = requests.get(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
-	
+    '''
+    Returns data found on a Github User's public profile. 
+    This includes information such as number of followers,
+    e-mail, number of repositories and more. 
 
-def getUserRepositories(clientID, clientSecret):
-	'''Get a list of all repositories owned by a User.'''
+    Parameters:
+        clientID: String 
+            - The clientID from registering this application
+              on Github.
+        clientSecret: String
+            - The clientSecret from registering this application
+            on Github.
+
+    Returns: 
+        parsedData: Dictionary
+            - A dictionary containing the following data:
+                - userData['name']
+                    - The user's public name on Github
+                - userData['blog']
+                    - Link to the user's blog on Github
+                - userData['email']
+                    - The user's public e-mail on Github
+                - userData['public_gists']
+                    - The number of the user's public gists 
+                - userData['public_repos']
+                    - The number of public repositories owned
+                - userData['avatar_url']
+                    - Link to user's public avatar 
+                - userData['followers']
+                    - Number of followers 
+                - userData['following']
+                    - Number of users being followed
+    '''
+    url = API_BASE_URL + '?' + clientID + '&' + clientSecret
+    req = requests.get(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)
 
-	pageNumber = 1
+    return parsedData
+    
+
+def getUserRepositories(clientID, clientSecret):
+    '''
+    Returns a list of all the public repositories 
+    owned by a User. 
 
+    Parameters:
+        clientID: String 
+            - The clientID from registering this application
+              on Github.
+        clientSecret: String.
+            - The clientSecret from registering this application
+            on Github.
 
-	jsonList = []
-	repositories = []
+    Returns:
+        repositories: List 
+            - A list containing all public repository names 
+              belonging to a user.
+    '''
+    pageNumber = 1
+    jsonList = []
+    repositories = []
 
-	while True:
-		req = requests.get('https://api.github.com/users/DrkSephy/repos?page=' + str(pageNumber) + '&' + clientID + '&' + clientSecret)
-		jsonList.append(json.loads(req.content))
-		if len(json.loads(req.content)) < 30:
-			break
-		elif len(json.loads(req.content)) >= 30:
-			pageNumber += 1
+    while True:
+        req = requests.get('https://api.github.com/users/DrkSephy/repos?page=' + str(pageNumber) + '&' + clientID + '&' + clientSecret)
+        jsonList.append(json.loads(req.content))
+        if len(json.loads(req.content)) < 30:
+            break
+        elif len(json.loads(req.content)) >= 30:
+            pageNumber += 1
 
-	
-	for data in jsonList:
-		for datum in data:
-			repositories.append(datum['name'])
-			
-	return repositories
+    
+    for data in jsonList:
+        for datum in data:
+            repositories.append(datum['name'])
+            
+    return repositories
 
 def getForkedRepositories(clientID, clientSecret):
-	'''Get a list of all forked repositories by a user.'''
-	
-	pageNumber = 1
+    '''
+    Returns a list of all the public forked repositories 
+    owned by a User. 
 
-	
-	jsonList = []
+    Parameters:
+        clientID: String 
+            - The clientID from registering this application
+              on Github.
+        clientSecret: String.
+            - The clientSecret from registering this application
+            on Github.
 
-	
-	forkedRepositories = []
+    Returns:
+        forkedRepositories: List 
+            - A list containing all forked repository names 
+              belonging to a user.
+    '''
+    
+    pageNumber = 1
+    jsonList = []
+    forkedRepositories = []
  
-	while True:
-		req = requests.get('https://api.github.com/users/DrkSephy/repos?page=' + str(pageNumber) + '&' + clientID + '&' + clientSecret)
-		jsonList.append(json.loads(req.content))
-		if len(json.loads(req.content)) < 30:
-			break
-		elif len(json.loads(req.content)) >= 30:
-			pageNumber += 1
+    while True:
+        req = requests.get('https://api.github.com/users/DrkSephy/repos?page=' + str(pageNumber) + '&' + clientID + '&' + clientSecret)
+        jsonList.append(json.loads(req.content))
+        if len(json.loads(req.content)) < 30:
+            break
+        elif len(json.loads(req.content)) >= 30:
+            pageNumber += 1
 
 
-	forkedRepos = {}
-	for data in jsonList:
-		for datum in data:
-			if datum['fork'] == True:
-				forkedRepos['name'] = datum['name']
-				forkedRepositories.append(forkedRepos)
-				forkedRepos = {}
+    forkedRepos = {}
+    for data in jsonList:
+        for datum in data:
+            if datum['fork'] == True:
+                forkedRepos['name'] = datum['name']
+                forkedRepositories.append(forkedRepos)
+                forkedRepos = {}
 
-	return forkedRepositories
+    return forkedRepositories
 
 def getTopContributedRepositories(repos, clientID, clientSecret):
-	'''Get a list of all commits for each repository owned.'''
+    '''
+    Returns a list containing the commit totals for all 
+    repositories owned by a user. 
 
-	jsonList = []
-	for repo in repos:
-		req = requests.get('https://api.github.com/repos/DrkSephy/' + repo + '/stats/contributors' + '?' + clientID + '&' + clientSecret)
-		jsonList.append(json.loads(req.content))
+    Parameters:
+        clientID: String 
+            - The clientID from registering this application
+              on Github.
+        clientSecret: String
+            - The clientSecret from registering this application
+            on Github.
 
-	parsedData = []
+    Returns: 
+        parsedData: Dictionary
+            - A dictionary containing the following data:
+                - commits['author']
+                    - The name of the committer
+                - commits['total']
+                    - Total commit count for a user in a repository
+                - commits['repo_name']
+                    - The name of the repository being tallied
+    '''
+    jsonList = []
+    for repo in repos:
+        req = requests.get('https://api.github.com/repos/DrkSephy/' + repo + '/stats/contributors' + '?' + clientID + '&' + clientSecret)
+        jsonList.append(json.loads(req.content))
 
-	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)
+    parsedData = []
 
-	return parsedData
+    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):
-	'''Returns the top 10 committed repositories.'''
-
-	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
-	
-	
+    '''
+    Returns the top 10 committed repositories.
+
+    Parameters: 
+        data: List
+            - A list containing commit counts for all
+            of a user's public repositories
+
+    Returns:
+        maxCommits: List
+            - A list containing the top ten repositories 
+            with the maximum number of commits by a user
+    '''
+
+    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(clientID, clientSecret):
-	'''Get Stargazer counts for all repositories.'''
-	
-	pageNumber = 1
-	jsonList = []
-	stargazers = []
-	while True:
-		req = requests.get('https://api.github.com/users/DrkSephy/repos?page=' + str(pageNumber) + '&' + clientID + '&' + clientSecret)
-		jsonList.append(json.loads(req.content))
-		if len(json.loads(req.content)) < 30:
-			break
-		elif len(json.loads(req.content)) >= 30:
-			pageNumber += 1
-
-
-	for data in jsonList:
-		for datum in data:
-			starData = {}
-			starData['stargazers_count'] = datum['stargazers_count']
-			starData['name'] = datum['name']
-			stargazers.append(starData)
-			
-	return stargazers
+    '''
+    Returns a list number of stargazers for each
+    of a user's public repositories.  
+
+    Parameters:
+        clientID: String 
+            - The clientID from registering this application
+              on Github.
+        clientSecret: String
+            - The clientSecret from registering this application
+            on Github.
+
+    Returns: 
+        stargazers: Dictionary
+            - A dictionary containing the following data:
+                - starData['stargazers_count']
+                    - The number of stargazers for a given repository
+                - starData['name']
+                    - The name of the repository being observed
+    '''
+    pageNumber = 1
+    jsonList = []
+    stargazers = []
+    while True:
+        req = requests.get('https://api.github.com/users/DrkSephy/repos?page=' + str(pageNumber) + '&' + clientID + '&' + clientSecret)
+        jsonList.append(json.loads(req.content))
+        if len(json.loads(req.content)) < 30:
+            break
+        elif len(json.loads(req.content)) >= 30:
+            pageNumber += 1
+
+
+    for data in jsonList:
+        for datum in data:
+            starData = {}
+            starData['stargazers_count'] = datum['stargazers_count']
+            starData['name'] = datum['name']
+            stargazers.append(starData)
+            
+    return stargazers
 
 def filterStarGazerCount(data):
-	'''Return top 10 starred repositories.'''
-	maxStars= []
-	for i in range(1, 10):
-		maxStarGazers = max(data, key=lambda x:x['stargazers_count'])
-		maxStars.append(maxStarGazers)
-		index = data.index(maxStarGazers)
-		data.pop(index)
-	return maxStars
+    '''
+    Returns the top 10 stargazed repositories.
+
+    Parameters: 
+        data: List
+            - A list containing stargazer counts for all
+            of a user's public repositories
+
+    Returns:
+        maxStars: List
+            - A list containing the top ten repositories 
+            with the maximum number of stargazers
+    '''
+    maxStars= []
+    for i in range(1, 10):
+        maxStarGazers = max(data, key=lambda x:x['stargazers_count'])
+        maxStars.append(maxStarGazers)
+        index = data.index(maxStarGazers)
+        data.pop(index)
+    return maxStars
 
 
 

+ 68 - 0
hackathon_starter/hackathon/scripts/instagram.py

@@ -0,0 +1,68 @@
+import requests
+import urllib
+import urllib2
+import json
+import simplejson as json2
+
+authorization_url = 'https://api.instagram.com/oauth/authorize/?client_id='
+access_token_url = 'https://api.instagram.com/oauth/access_token'
+
+class InstagramOauthClient(object):
+
+	access_token = None
+	user_data = None
+
+	def __init__(self, client_id, client_secret):
+		self.client_id 		= client_id
+		self.client_secret 	= client_secret
+
+
+	def get_authorize_url(self):
+		''' Obtains the authorization url. '''
+		auth_url = authorization_url + self.client_id +'&redirect_uri=http://localhost:8000/hackathon/instagram&response_type=code'
+		return auth_url
+
+	def get_access_token(self, code):
+		''' Obtains access token. '''
+
+		auth_setting = {'client_id': self.client_id,
+						'client_secret': self.client_secret,
+						'grant_type': 'authorization_code',
+						'redirect_uri': 'http://localhost:8000/hackathon/instagram',
+						'code': code
+						}
+
+		auth_setting_url =  urllib.urlencode(auth_setting)
+		req  = urllib2.Request(access_token_url, auth_setting_url)
+		content = urllib2.urlopen(req)
+		jsonlist = json.load(content)
+		self.access_token = jsonlist['access_token']
+		self.user_data = jsonlist['user']
+		print self.user_data
+		#print self.access_token
+
+
+	def get_tagged_media(self, tag):
+		''' Get recent tagged media. '''
+		tagged_media_url = 'https://api.instagram.com/v1/tags/'+tag+'/media/recent?access_token='+self.access_token# +'&count=2'
+		req = requests.get(tagged_media_url)
+		content = json2.loads(req.content)
+		data = content['data']
+
+		while len(data) <= 100:
+			next_url= content['pagination']['next_url']
+			req = requests.get(next_url)
+			content = json2.loads(req.content)
+			for i in content['data']:
+				data.append(i)
+		print len(data)
+		return data
+
+	def get_user_info(self, access_token):
+		user_info = 'https://api.instagram.com/v1/users/32833691/?access_token='+access_token
+		req = requests.get(user_info)
+		content = json2.loads(req.content)
+		data = content['data']
+		return data
+
+

+ 24 - 27
hackathon_starter/hackathon/scripts/tumblr.py

@@ -10,59 +10,54 @@ import oauth2
 request_token_url   = 'http://www.tumblr.com/oauth/request_token'
 authorize_url       = 'http://www.tumblr.com/oauth/authorize'
 access_token_url    = 'http://www.tumblr.com/oauth/access_token'
+
 user_uri			= "http://api.tumblr.com/v2/user/info"
 blog_uri			= "http://api.tumblr.com/v2/blog/"
 
 class TumblrOauthClient(object):
 
 	token = None
-	oauth_token_secret = None
 	oauth_verifier = None
+	oauth_token = None
+	oauth_token_secret = None
+	accessed = False
 
 
-	def __init__(self, consumer_key, consumer_secret, oauth_token =''):
+
+	def __init__(self, consumer_key, consumer_secret):
 		self.consumer_key = consumer_key
 		self.consumer_secret = consumer_secret
 		self.consumer = oauth2.Consumer(consumer_key, consumer_secret)
-		self.oauth_token = oauth_token
+		
 
 
-	def get_authorize_url(self):
+	def authorize_url(self):
 		client = oauth2.Client(self.consumer)
 		resp, content = client.request(request_token_url, "GET")
-
-		#if int(resp['status']) != 200:
-		#	raise Exception("Invalid response %s." % resp['status'])
-
 		#parse content
 		if not self.oauth_token:
 			request_token = dict(urlparse.parse_qsl(content))
-			self.oauth_token = request_token['oauth_token'] #'QBXdeeMKAnLzDbIG7dDNewTzRYyQoHZLbcn3bAFTCEFF5EXurl'
-			self.oauth_token_secret = request_token['oauth_token_secret']#'u10SuRl2nzS8vFK4K7UPQexAvbIFBFrZBjA79XDlgoXFxv9ZhO'
-
+			self.oauth_token = request_token['oauth_token'] #'QBXdeeMKAnLzDbIG7dDNewTzRYyQoHZLbcn3bAFTCEFF5EXurl' #
+			self.oauth_token_secret = request_token['oauth_token_secret']#'u10SuRl2nzS8vFK4K7UPQexAvbIFBFrZBjA79XDlgoXFxv9ZhO' #
 		link = authorize_url+"?oauth_token="+self.oauth_token+"&redirect_uri=http%3A%2F%2Flocalhost%3A8000/hackathon/tumblr"
 		return link
 
-#"""
 
-	def get_access_token_url(self, oauth_verifier):
-		#print "verifier"
-		self.oauth_verifier = oauth_verifier
+	def access_token_url(self, oauth_verifier=''):
+		self.accessed = True
 		token = oauth2.Token(self.oauth_token, self.oauth_token_secret)
+		self.oauth_verifier = oauth_verifier
+		print self.oauth_verifier
 		token.set_verifier(self.oauth_verifier)
-
 		client = oauth2.Client(self.consumer, token)
 		resp, content = client.request(access_token_url,"POST")
-
-		#print resp['status']
-
 		access_token = dict(urlparse.parse_qsl(content))
-		#print access_token
-
 		#set verified token
 		self.token = oauth2.Token(access_token['oauth_token'], access_token['oauth_token_secret'])
+		#print self.token
+			
+
 
-	
 	def getUserInfo(self):
 		''' Returns users information. '''
 		client = oauth2.Client(self.consumer, self.token)
@@ -75,25 +70,27 @@ class TumblrOauthClient(object):
 		jsonlist = json.loads(content)
 		response = jsonlist['response']
 		user_info = response['user']
+		total_blogs = len(user_info['blogs'])
 		#print user_info
-		return user_info
+		return user_info, total_blogs
+
 
 	def getBlogInfo(self, user):
 		''' Returns blogger's blog information '''
 		blog_info = blog_uri + user + ".tumblr.com/info?api_key="+self.consumer_key
 		req = requests.get(blog_info)
 		
-		if int(req.status_code) != 200:
-			raise Exception("Invalid response %s." % resp['status'])
+		#if int(req.status_code) != 200:
+		#	raise Exception("Invalid response %s." % resp['status'])
 		
 
 		jsonlist = json.loads(req.content)
 		response = jsonlist['response']
 		blog 	 = response['blog']
 		blog['updated'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(blog['updated']))
-
 		return blog
 
+
 	def getTaggedInfo(self, tag):
 		''' Return tags related to blog with certain tag. '''
 
@@ -116,6 +113,7 @@ class TumblrOauthClient(object):
 
 		return tags	
 
+
 	def getTaggedBlog(self, tag):
 		''' Return the tagged blogs's captions or post.'''
 		
@@ -147,4 +145,3 @@ class TumblrOauthClient(object):
 						tagtext.append(text)
 		
 		return tagtext
-#"""

+ 13 - 0
hackathon_starter/hackathon/scripts/twilioapi.py

@@ -0,0 +1,13 @@
+import twilio
+import requests
+from twilio.rest import TwilioRestClient
+ 
+account_sid = "AC7889a1889c1833bd7181e45e60372776"
+auth_token  = "1ad0315f3cc7a154aaaef048f1304f71"
+client = TwilioRestClient(account_sid, auth_token)
+ 
+def sendSMS(body, to, sender):
+	'''Sends a message to a given number'''
+	
+	message = client.messages.create(body=body, to=to, from_=sender) 
+	return

+ 6 - 5
hackathon_starter/hackathon/templates/hackathon/api_examples.html

@@ -4,11 +4,12 @@
 
 
 	<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={{tumblr_url}}><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 class="col-sm-4"><a href="http://127.0.0.1:8000/hackathon/githubResume/">Github Example</a></div>
+	    <div class="col-sm-4"><a href="http://127.0.0.1:8000/hackathon/steam/">Steam Example</a></div>
+	    <div class="col-sm-4"><a href={{tumblr_url}}>Tumblr Example</a></div>
+		<div class="col-sm-4"><a href="http://127.0.0.1:8000/hackathon/linkedin/">LinkedIn Example</a></div>
+		<div class="col-sm-4"><a href="http://127.0.0.1:8000/hackathon/twilio/">Twilio Example</a></div>
+		<div class="col-sm-4"><a href="{{instagram_url}}">Instagram Example</a></div>
 
   	</div>
 

+ 17 - 0
hackathon_starter/hackathon/templates/hackathon/instagram.html

@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<body>
+	{% include 'hackathon/base.html' %}
+	<h1 class="text-center"> {{ title }}</h1> 
+	<br>
+	<div class="col-lg-12">
+		<div class="table-responsive">
+			<h2> #{{search_tag}} </h2>
+			<table class="table">
+				{% for i in tagged_media %}
+					<img src="{{i.images.thumbnail.url}}">
+				{% endfor %}		
+			</table>
+		</div>
+	</div>	
+</html>

+ 6 - 2
hackathon_starter/hackathon/templates/hackathon/login.html

@@ -34,14 +34,18 @@
           <i class="fa fa-twitter"></i>
           Sign in with Twitter
         </a>
-        <a class="btn btn-block btn-social btn-instagram">
+        <a class="btn btn-block btn-social btn-instagram" href="http://localhost:8000/hackathon/instagram_login/">
           <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>          
+        </a>
+        <a class="btn btn-block btn-social btn-tumblr" href="http://localhost:8000/hackathon/tumblr_login/">
+          <i class="fa fa-tumblr"></i>
+          Sign in with Tumblr
+        </a>                  
       </div>
     </body>
 </html>

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

@@ -57,5 +57,4 @@
 			</table>
 		</div>
 	</div>
-
 </html>

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

@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<body>
+	{% include 'hackathon/base.html' %}
+
+    <h1 class="text-center"> Twilio Messages </h1>
+    {{ context }}
+    </div>
+    
+
+</body>
+</html>

+ 8 - 2
hackathon_starter/hackathon/urls.py

@@ -4,14 +4,20 @@ 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'^githubResume/$', views.githubResume, name='githubResume'),
+    url(r'^githubUser/$', views.githubUser, name='githubUser'),
+    url(r'^githubTopRepositories/$', views.githubTopRepositories, name='githubTopRepositories'),
     url(r'^tumblr/$', views.tumblr, name='tumblr'),
     url(r'^linkedin/$', views.linkedin, name='linkedin'),
     url(r'^snippets/$', views.snippet_list, name='snippets'),
+    url(r'^twilio/$', views.twilio, name='twilio'),
+    url(r'^instagram/$', views.instagram, name='instagram'),
+    url(r'^instagram_login/$', views.instagram_login, name='instagram_login'),
+    url(r'^instagramUser/$', views.instagramUser, name='instagramUser'),
+    url(r'^tumblr_login/$', views.tumblr_login, name='tumblr_login'),
 )

+ 195 - 66
hackathon_starter/hackathon/views.py

@@ -9,11 +9,14 @@ from django.contrib.auth import authenticate, login, logout
 from django.contrib.auth.models import User
 from django.contrib.auth.decorators import login_required
 from django.views.decorators.csrf import csrf_exempt
+from django.http import JsonResponse
 
 # Scripts
 from scripts.steam import gamesPulling, steamIDPulling 
 from scripts.github import *
-from scripts.tumblr import *
+from scripts.tumblr import TumblrOauthClient
+from scripts.twilioapi import *
+from scripts.instagram import InstagramOauthClient
 
 # Python
 import oauth2 as oauth
@@ -21,71 +24,43 @@ from rest_framework.renderers import JSONRenderer
 from rest_framework.parsers import JSONParser
 
 # Models
-from hackathon.models import Snippet
+from hackathon.models import Snippet, Profile
 from hackathon.serializers import SnippetSerializer
 from hackathon.forms import UserForm
 
 
 getTumblr = TumblrOauthClient(settings.TUMBLR_CONSUMER_KEY, settings.TUMBLR_CONSUMER_SECRET)
+getInstagram = InstagramOauthClient(settings.INSTAGRAM_CLIENT_ID, settings.INSTAGRAM_CLIENT_SECRET)
 
 def index(request):
     context = {'hello': 'world'}
     return render(request, 'hackathon/index.html', context)
 
-def test(request):
-    return HttpResponse('meow')
+##################
+#   Twilio API   #
+##################
 
-def api_examples(request):
-    obtain_oauth_verifier = getTumblr.get_authorize_url()#simpleoauthurl(settings.TUMBLR_CONSUMER_KEY, settings.TUMBLR_CONSUMER_SECRET)
-    context = {'title': 'API Examples Page', 'tumblr_url': obtain_oauth_verifier}
-    return render(request, 'hackathon/api_examples.html', context)
-
-def register(request):
-    registered = False
-    if request.method == 'POST':
-        user_form = UserForm(data=request.POST)
-        if user_form.is_valid():
-            user = user_form.save()
-            user.set_password(user.password)
-            user.save()
-            registered = True
-        else:
-            print user_form.errors
-    else:
-        user_form = UserForm()
-
-    
-    return render(request,
-            'hackathon/register.html',
-            {'user_form': user_form, 'registered': registered} )
-
-def user_login(request):
-
-    
-    if request.method == 'POST':
-        username = request.POST.get('username')
-        password = request.POST.get('password')
-
-
-        user = authenticate(username=username, password=password)
+def twilio(request):
+    sendSMS('Meow', '+13473282978', '+13473781813')
+    return render(request, 'hackathon/twilio.html')
 
+##################
+#  API Examples  #
+##################
 
-        if user:
-            if user.is_active:
-                login(request, user)
-                return HttpResponseRedirect('/hackathon/')
-            else:
-                return HttpResponse("Your Django Hackathon account is disabled.")
-        else:
-            print ("Invalid login details: {0}, {1}".format(username, password))
-            return HttpResponse("Invalid login details supplied.")
-
+def api_examples(request):
+    instagram_url =getInstagram.get_authorize_url()
+    if not getTumblr.accessed:
+        obtain_oauth_verifier = getTumblr.authorize_url()
     else:
-        return render(request, 'hackathon/login.html', {})
+        obtain_oauth_verifier = '/hackathon/tumblr'
+    #obtain_oauth_verifier = getTumblr.authorize_url()
+    context = {'title': 'API Examples Page', 'tumblr_url': obtain_oauth_verifier, 'instagram_url':instagram_url}
+    return render(request, 'hackathon/api_examples.html', context)
 
-def user_logout(request):
-    logout(request)
-    return HttpResponseRedirect('/hackathon/')
+#################
+#   STEAM API   #
+#################
 
 def steam(request):
     #Should link to test of Steam API example.
@@ -95,7 +70,32 @@ def steam(request):
     game = gamesPulling(steamID, key)
     return render(request,'hackathon/steam.html', {"game": game })
 
-def github(request):
+
+#################
+#   GITHUB API  #
+#################
+
+
+def githubUser(request):
+    '''Returns JSON response about a specific Github User'''
+
+    parsedData = {}
+    parsedData['userData'] = getUserData(settings.GITHUB_CLIENT_ID, settings.GITHUB_CLIENT_SECRET)
+    return JsonResponse({ 'data': parsedData })
+
+def githubTopRepositories(request):
+    '''Returns JSON response of a User's Top Committed repositories'''
+
+    parsedData = {}
+    repositories = getUserRepositories(settings.GITHUB_CLIENT_ID, settings.GITHUB_CLIENT_SECRET)
+    list = getTopContributedRepositories(repositories, settings.GITHUB_CLIENT_ID, settings.GITHUB_CLIENT_SECRET)
+    filtered = filterCommits(list)
+    parsedData['committed'] = filtered
+    return JsonResponse({ 'data': parsedData })
+
+def githubResume(request):
+    '''A sample application which pulls various Github data to form a Resume of sorts'''
+    
     allData = {}
     userData = getUserData(settings.GITHUB_CLIENT_ID, settings.GITHUB_CLIENT_SECRET)
     repositories = getUserRepositories(settings.GITHUB_CLIENT_ID, settings.GITHUB_CLIENT_SECRET)
@@ -108,30 +108,103 @@ def github(request):
     allData['filteredData'] = filtered
     allData['filteredStargazers'] = filteredStargazers
     allData['forkedRepos'] = forkedRepos
-
     return render(request, 'hackathon/github.html', { 'data': allData })
 
+
+#################
+#   TUMBLR API  #
+#################
+
 def tumblr(request):
     ''' Tumblr api calls '''
-    #retrieve verifier via url link
-    if not request.GET.items():
-        return HttpResponseRedirect('/hackathon/api/')
-    else:
-        getTumblr.get_access_token_url(request.GET.get('oauth_verifier'))
-        #get blogger twitterthecomic's blog information
-        blog = getTumblr.getBlogInfo('twitterthecomic')
-        #get tags that was tagged along starbucks
-        tagged_blog = getTumblr.getTaggedInfo("starbucks")
-        #get blog information tagged with starbucks
-        blogontag = getTumblr.getTaggedBlog("starbucks")
-        context = {'title': "What's up Starbucks?", 'blogData': blog, 'blogTag': tagged_blog, 'blogontag': blogontag}
-        return render(request, 'hackathon/tumblr.html', context)
+    if not getTumblr.accessed:
+        oauth_verifier = request.GET.get('oauth_verifier')
+        getTumblr.access_token_url(oauth_verifier)
+    if request.user not in User.objects.all():
+        try:
+            user_info, total_blog = getTumblr.getUserInfo()
+            username = str(user_info['name'])+ "2"
+            user = User.objects.get(username=username)
+        except User.DoesNotExist:
+            user_info, total_blog = getTumblr.getUserInfo()
+            username = str(user_info['name'])+ "2"
+            new_user = User.objects.create_user(username, username+'@example.com','password')
+            new_user.save()
+            profile =Profile()
+            profile.user = new_user
+            profile.oauth_token = getTumblr.oauth_token
+            profile.oauth_secret = getTumblr.oauth_token_secret
+            profile.save()
+
+        user = authenticate(username=username, password='password')
+        login(request, user)
+
+    #get blogger twitterthecomic's blog information
+    blog = getTumblr.getBlogInfo('twitterthecomic')
+    #get tags that was tagged along starbucks
+    tagged_blog = getTumblr.getTaggedInfo("starbucks")
+    #get blog information tagged with starbucks
+    blogontag = getTumblr.getTaggedBlog("starbucks")
+
+    context = {'title': "What's up Starbucks?", 'blogData': blog, 'blogTag': tagged_blog, 'blogontag': blogontag}
+    return render(request, 'hackathon/tumblr.html', context)
+
+
+####################
+#   INSTAGRAM API  #
+####################
+
+def instagram(request):
+    code = request.GET['code']
+    getInstagram.get_access_token(code)
+
+    if request.user not in User.objects.all():
+        try:  
+            user = User.objects.get(username=getInstagram.user_data['username'] )
+        except User.DoesNotExist:
+            username = getInstagram.user_data['username']
+            new_user = User.objects.create_user(username, username+'@example.com', 'password')
+            new_user.save()
+            profile = Profile()
+            profile.user = new_user
+            profile.oauth_token = getInstagram.client_id
+            #since instagram doesnt have oauth_secret value, using this field to temp set in access token
+            # for JSON response
+            profile.oauth_secret = getInstagram.access_token 
+            profile.save()
+
+        user = authenticate(username=getInstagram.user_data['username'], password='password')
+        login(request, user)
+
+    search_tag = 'kitten'
+    #return tagged objects
+    tagged_media = getInstagram.get_tagged_media(search_tag)
+    context = {'title': 'Instagram', 'tagged_media': tagged_media, 'search_tag': search_tag}
+    return render(request, 'hackathon/instagram.html', context)
+
+def instagramUser(request):
+    '''Returns JSON response about a specific Instagram'''
+
+    user_id = User.objects.get(username='mk200789').id
+    access_token = Profile.objects.get(user=user_id).oauth_secret
+    parsedData = getInstagram.get_user_info(access_token)
+    return JsonResponse({ 'data': parsedData })
+
+
+##################
+#  LINKED IN API #
+##################
 
 def linkedin(request):
     userinfo = getUserInfo()
     context = {'title': 'linkedin Example','userdata': userinfo}
     return render(request, 'hackathon/linkedin.html', context)
 
+
+#########################
+# Snippet RESTful Model #
+#########################
+
 class JSONResponse(HttpResponse):
     """
     An HttpResponse that renders its content into JSON.
@@ -151,3 +224,59 @@ def snippet_list(request):
         serializer = SnippetSerializer(snippets, many=True)
         return JSONResponse(serializer.data)
 
+
+######################
+# Registration Views #
+######################
+
+def register(request):
+    registered = False
+    if request.method == 'POST':
+        user_form = UserForm(data=request.POST)
+        if user_form.is_valid():
+            user = user_form.save()
+            user.set_password(user.password)
+            user.save()
+            registered = True
+        else:
+            print user_form.errors
+    else:
+        user_form = UserForm()
+
+    
+    return render(request,
+            'hackathon/register.html',
+            {'user_form': user_form, 'registered': registered} )
+
+def user_login(request):
+    if request.method == 'POST':
+        username = request.POST.get('username')
+        password = request.POST.get('password')
+
+        user = authenticate(username=username, password=password)
+
+        if user:
+            if user.is_active:
+                login(request, user)
+                return HttpResponseRedirect('/hackathon/')
+            else:
+                return HttpResponse("Your Django Hackathon account is disabled.")
+        else:
+            print ("Invalid login details: {0}, {1}".format(username, password))
+            return HttpResponse("Invalid login details supplied.")
+
+    else:
+        return render(request, 'hackathon/login.html', {})
+
+def user_logout(request):
+    logout(request)
+    return HttpResponseRedirect('/hackathon/')
+
+
+def instagram_login(request):
+    instagram_url =getInstagram.get_authorize_url()
+    return HttpResponseRedirect(instagram_url)
+
+def tumblr_login(request):
+    tumblr_url = getTumblr.authorize_url()
+    return HttpResponseRedirect(tumblr_url)

+ 6 - 0
hackathon_starter/hackathon_starter/settings.py

@@ -41,10 +41,12 @@ INSTALLED_APPS = (
     # 'django_openid',
     'django_nose',
     'rest_framework',
+    'corsheaders',
 )
 
 MIDDLEWARE_CLASSES = (
     'django.contrib.sessions.middleware.SessionMiddleware',
+    'corsheaders.middleware.CorsMiddleware',
     'django.middleware.common.CommonMiddleware',
     'django.middleware.csrf.CsrfViewMiddleware',
     'django.contrib.auth.middleware.AuthenticationMiddleware',
@@ -99,6 +101,8 @@ NOSE_ARGS = [
     '--cover-package=hackathon/scripts',
 ]
 
+CORS_ORIGIN_ALLOW_ALL = True
+
 ############
 #   KEYS   #
 ############
@@ -109,4 +113,6 @@ TUMBLR_CONSUMER_KEY = 'KrSbAc9cYLmIgVAn1D21FjRR97QWsutNMxkPDFBxo8CMWtMk4M'
 TUMBLR_CONSUMER_SECRET ='lKWMtL2Lj8zr5pY51PVqT8ugeoG0DjrdgoFewM0QTSyJ12jP8d'
 TWITTER_TOKEN = 'F05dgLAzHEOalb4K2xDQ8Umm8'
 TWITTER_SECRET = 'Yy3a74Z7gvyhxRruJsvUtUl8uK8iv6qKkVqbZSijUxK71Z1qTY'
+INSTAGRAM_CLIENT_ID = '77dc10b9e3624e908ce437c0a82da92e'
+INSTAGRAM_CLIENT_SECRET = '8bcf3139857149aaba7acaa61288427f'
 

+ 46 - 0
hackathon_starter/index.rst

@@ -0,0 +1,46 @@
+.. Django Hackathon Starter documentation master file, created by
+   sphinx-quickstart on Sun Apr 12 22:33:44 2015.
+   You can adapt this file completely to your liking, but it should at least
+   contain the root `toctree` directive.
+
+Welcome to Django Hackathon Starter's documentation!
+====================================================
+
+Contents:
+
+.. toctree::
+   :maxdepth: 2
+
+Github
+======
+.. automodule:: github
+	:members:
+
+Instagram
+=========
+.. automodule:: instagram
+	:members:
+
+Steam
+=====
+.. automodule:: steam
+	:members:
+
+Tumblr
+======
+.. automodule:: tumblr
+	:members:
+
+Twilio
+======
+.. automodule:: twilioapi
+	:members:
+
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+

+ 263 - 0
hackathon_starter/make.bat

@@ -0,0 +1,263 @@
+@ECHO OFF
+
+REM Command file for Sphinx documentation
+
+if "%SPHINXBUILD%" == "" (
+	set SPHINXBUILD=sphinx-build
+)
+set BUILDDIR=_build
+set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
+set I18NSPHINXOPTS=%SPHINXOPTS% .
+if NOT "%PAPER%" == "" (
+	set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
+	set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
+)
+
+if "%1" == "" goto help
+
+if "%1" == "help" (
+	:help
+	echo.Please use `make ^<target^>` where ^<target^> is one of
+	echo.  html       to make standalone HTML files
+	echo.  dirhtml    to make HTML files named index.html in directories
+	echo.  singlehtml to make a single large HTML file
+	echo.  pickle     to make pickle files
+	echo.  json       to make JSON files
+	echo.  htmlhelp   to make HTML files and a HTML help project
+	echo.  qthelp     to make HTML files and a qthelp project
+	echo.  devhelp    to make HTML files and a Devhelp project
+	echo.  epub       to make an epub
+	echo.  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter
+	echo.  text       to make text files
+	echo.  man        to make manual pages
+	echo.  texinfo    to make Texinfo files
+	echo.  gettext    to make PO message catalogs
+	echo.  changes    to make an overview over all changed/added/deprecated items
+	echo.  xml        to make Docutils-native XML files
+	echo.  pseudoxml  to make pseudoxml-XML files for display purposes
+	echo.  linkcheck  to check all external links for integrity
+	echo.  doctest    to run all doctests embedded in the documentation if enabled
+	echo.  coverage   to run coverage check of the documentation if enabled
+	goto end
+)
+
+if "%1" == "clean" (
+	for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
+	del /q /s %BUILDDIR%\*
+	goto end
+)
+
+
+REM Check if sphinx-build is available and fallback to Python version if any
+%SPHINXBUILD% 2> nul
+if errorlevel 9009 goto sphinx_python
+goto sphinx_ok
+
+:sphinx_python
+
+set SPHINXBUILD=python -m sphinx.__init__
+%SPHINXBUILD% 2> nul
+if errorlevel 9009 (
+	echo.
+	echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
+	echo.installed, then set the SPHINXBUILD environment variable to point
+	echo.to the full path of the 'sphinx-build' executable. Alternatively you
+	echo.may add the Sphinx directory to PATH.
+	echo.
+	echo.If you don't have Sphinx installed, grab it from
+	echo.http://sphinx-doc.org/
+	exit /b 1
+)
+
+:sphinx_ok
+
+
+if "%1" == "html" (
+	%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/html.
+	goto end
+)
+
+if "%1" == "dirhtml" (
+	%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
+	goto end
+)
+
+if "%1" == "singlehtml" (
+	%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
+	goto end
+)
+
+if "%1" == "pickle" (
+	%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can process the pickle files.
+	goto end
+)
+
+if "%1" == "json" (
+	%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can process the JSON files.
+	goto end
+)
+
+if "%1" == "htmlhelp" (
+	%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can run HTML Help Workshop with the ^
+.hhp project file in %BUILDDIR%/htmlhelp.
+	goto end
+)
+
+if "%1" == "qthelp" (
+	%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; now you can run "qcollectiongenerator" with the ^
+.qhcp project file in %BUILDDIR%/qthelp, like this:
+	echo.^> qcollectiongenerator %BUILDDIR%\qthelp\DjangoHackathonStarter.qhcp
+	echo.To view the help file:
+	echo.^> assistant -collectionFile %BUILDDIR%\qthelp\DjangoHackathonStarter.ghc
+	goto end
+)
+
+if "%1" == "devhelp" (
+	%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished.
+	goto end
+)
+
+if "%1" == "epub" (
+	%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The epub file is in %BUILDDIR%/epub.
+	goto end
+)
+
+if "%1" == "latex" (
+	%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
+	goto end
+)
+
+if "%1" == "latexpdf" (
+	%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+	cd %BUILDDIR%/latex
+	make all-pdf
+	cd %~dp0
+	echo.
+	echo.Build finished; the PDF files are in %BUILDDIR%/latex.
+	goto end
+)
+
+if "%1" == "latexpdfja" (
+	%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+	cd %BUILDDIR%/latex
+	make all-pdf-ja
+	cd %~dp0
+	echo.
+	echo.Build finished; the PDF files are in %BUILDDIR%/latex.
+	goto end
+)
+
+if "%1" == "text" (
+	%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The text files are in %BUILDDIR%/text.
+	goto end
+)
+
+if "%1" == "man" (
+	%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The manual pages are in %BUILDDIR%/man.
+	goto end
+)
+
+if "%1" == "texinfo" (
+	%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
+	goto end
+)
+
+if "%1" == "gettext" (
+	%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
+	goto end
+)
+
+if "%1" == "changes" (
+	%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.The overview file is in %BUILDDIR%/changes.
+	goto end
+)
+
+if "%1" == "linkcheck" (
+	%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Link check complete; look for any errors in the above output ^
+or in %BUILDDIR%/linkcheck/output.txt.
+	goto end
+)
+
+if "%1" == "doctest" (
+	%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Testing of doctests in the sources finished, look at the ^
+results in %BUILDDIR%/doctest/output.txt.
+	goto end
+)
+
+if "%1" == "coverage" (
+	%SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Testing of coverage in the sources finished, look at the ^
+results in %BUILDDIR%/coverage/python.txt.
+	goto end
+)
+
+if "%1" == "xml" (
+	%SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The XML files are in %BUILDDIR%/xml.
+	goto end
+)
+
+if "%1" == "pseudoxml" (
+	%SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml.
+	goto end
+)
+
+:end

+ 3 - 0
ionic/.bowerrc

@@ -0,0 +1,3 @@
+{
+  "directory": "www/lib"
+}

+ 6 - 0
ionic/.gitignore

@@ -0,0 +1,6 @@
+# Specifies intentionally untracked files to ignore when using Git
+# http://git-scm.com/docs/gitignore
+
+node_modules/
+platforms/
+plugins/

+ 26 - 0
ionic/README.md

@@ -0,0 +1,26 @@
+Ionic App Base
+=====================
+
+A starting project for Ionic that optionally supports using custom SCSS.
+
+## Using this project
+
+We recommend using the [Ionic CLI](https://github.com/driftyco/ionic-cli) to create new Ionic projects that are based on this project but use a ready-made starter template.
+
+For example, to start a new Ionic project with the default tabs interface, make sure the `ionic` utility is installed:
+
+```bash
+$ npm install -g ionic
+```
+
+Then run:
+
+```bash
+$ ionic start myProject tabs
+```
+
+More info on this can be found on the Ionic [Getting Started](http://ionicframework.com/getting-started) page and the [Ionic CLI](https://github.com/driftyco/ionic-cli) repo.
+
+## Issues
+Issues have been disabled on this repo, if you do find an issue or have a question consider posting it on the [Ionic Forum](http://forum.ionicframework.com/).  Or else if there is truly an error, follow our guidelines for [submitting an issue](http://ionicframework.com/submit-issue/) to the main Ionic repository.
+

+ 7 - 0
ionic/bower.json

@@ -0,0 +1,7 @@
+{
+  "name": "HelloIonic",
+  "private": "true",
+  "devDependencies": {
+    "ionic": "driftyco/ionic-bower#1.0.0-rc.2"
+  }
+}

+ 49 - 0
ionic/config.xml

@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<widget id="com.ionicframework.starter" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
+  <name>HelloCordova</name>
+  <description>
+        An Ionic Framework and Cordova project.
+    </description>
+  <author email="hi@ionicframework" href="http://ionicframework.com/">
+      Ionic Framework Team
+    </author>
+  <content src="index.html"/>
+  <access origin="*"/>
+  <preference name="webviewbounce" value="false"/>
+  <preference name="UIWebViewBounce" value="false"/>
+  <preference name="DisallowOverscroll" value="true"/>
+  <preference name="BackupWebStorage" value="none"/>
+  <preference name="SplashScreen" value="screen"/>
+  <preference name="SplashScreenDelay" value="3000"/>
+  <feature name="StatusBar">
+    <param name="ios-package" value="CDVStatusBar" onload="true"/>
+  </feature>
+  <platform name="ios">
+    <icon src="resources/ios/icon/icon.png" width="57" height="57"/>
+    <icon src="resources/ios/icon/icon@2x.png" width="114" height="114"/>
+    <icon src="resources/ios/icon/icon-40.png" width="40" height="40"/>
+    <icon src="resources/ios/icon/icon-40@2x.png" width="80" height="80"/>
+    <icon src="resources/ios/icon/icon-50.png" width="50" height="50"/>
+    <icon src="resources/ios/icon/icon-50@2x.png" width="100" height="100"/>
+    <icon src="resources/ios/icon/icon-60.png" width="60" height="60"/>
+    <icon src="resources/ios/icon/icon-60@2x.png" width="120" height="120"/>
+    <icon src="resources/ios/icon/icon-60@3x.png" width="180" height="180"/>
+    <icon src="resources/ios/icon/icon-72.png" width="72" height="72"/>
+    <icon src="resources/ios/icon/icon-72@2x.png" width="144" height="144"/>
+    <icon src="resources/ios/icon/icon-76.png" width="76" height="76"/>
+    <icon src="resources/ios/icon/icon-76@2x.png" width="152" height="152"/>
+    <icon src="resources/ios/icon/icon-small.png" width="29" height="29"/>
+    <icon src="resources/ios/icon/icon-small@2x.png" width="58" height="58"/>
+    <icon src="resources/ios/icon/icon-small@3x.png" width="87" height="87"/>
+    <splash src="resources/ios/splash/Default-568h@2x~iphone.png" height="1136" width="640"/>
+    <splash src="resources/ios/splash/Default-667h.png" height="1334" width="750"/>
+    <splash src="resources/ios/splash/Default-736h.png" height="2208" width="1242"/>
+    <splash src="resources/ios/splash/Default-Landscape-736h.png" height="1242" width="2208"/>
+    <splash src="resources/ios/splash/Default-Landscape@2x~ipad.png" height="1536" width="2048"/>
+    <splash src="resources/ios/splash/Default-Landscape~ipad.png" height="768" width="1024"/>
+    <splash src="resources/ios/splash/Default-Portrait@2x~ipad.png" height="2048" width="1536"/>
+    <splash src="resources/ios/splash/Default-Portrait~ipad.png" height="1024" width="768"/>
+    <splash src="resources/ios/splash/Default@2x~iphone.png" height="960" width="640"/>
+    <splash src="resources/ios/splash/Default~iphone.png" height="480" width="320"/>
+  </platform>
+</widget>

+ 50 - 0
ionic/gulpfile.js

@@ -0,0 +1,50 @@
+var gulp = require('gulp');
+var gutil = require('gulp-util');
+var bower = require('bower');
+var concat = require('gulp-concat');
+var sass = require('gulp-sass');
+var minifyCss = require('gulp-minify-css');
+var rename = require('gulp-rename');
+var sh = require('shelljs');
+
+var paths = {
+  sass: ['./scss/**/*.scss']
+};
+
+gulp.task('default', ['sass']);
+
+gulp.task('sass', function(done) {
+  gulp.src('./scss/ionic.app.scss')
+    .pipe(sass())
+    .pipe(gulp.dest('./www/css/'))
+    .pipe(minifyCss({
+      keepSpecialComments: 0
+    }))
+    .pipe(rename({ extname: '.min.css' }))
+    .pipe(gulp.dest('./www/css/'))
+    .on('end', done);
+});
+
+gulp.task('watch', function() {
+  gulp.watch(paths.sass, ['sass']);
+});
+
+gulp.task('install', ['git-check'], function() {
+  return bower.commands.install()
+    .on('log', function(data) {
+      gutil.log('bower', gutil.colors.cyan(data.id), data.message);
+    });
+});
+
+gulp.task('git-check', function(done) {
+  if (!sh.which('git')) {
+    console.log(
+      '  ' + gutil.colors.red('Git is not installed.'),
+      '\n  Git, the version control system, is required to download Ionic.',
+      '\n  Download git here:', gutil.colors.cyan('http://git-scm.com/downloads') + '.',
+      '\n  Once git is installed, run \'' + gutil.colors.cyan('gulp install') + '\' again.'
+    );
+    process.exit(1);
+  }
+  done();
+});

+ 83 - 0
ionic/hooks/README.md

@@ -0,0 +1,83 @@
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+-->
+# Cordova Hooks
+
+This directory may contain scripts used to customize cordova commands. This
+directory used to exist at `.cordova/hooks`, but has now been moved to the
+project root. Any scripts you add to these directories will be executed before
+and after the commands corresponding to the directory name. Useful for
+integrating your own build systems or integrating with version control systems.
+
+__Remember__: Make your scripts executable.
+
+## Hook Directories
+The following subdirectories will be used for hooks:
+
+    after_build/
+    after_compile/
+    after_docs/
+    after_emulate/
+    after_platform_add/
+    after_platform_rm/
+    after_platform_ls/
+    after_plugin_add/
+    after_plugin_ls/
+    after_plugin_rm/
+    after_plugin_search/
+    after_prepare/
+    after_run/
+    after_serve/
+    before_build/
+    before_compile/
+    before_docs/
+    before_emulate/
+    before_platform_add/
+    before_platform_rm/
+    before_platform_ls/
+    before_plugin_add/
+    before_plugin_ls/
+    before_plugin_rm/
+    before_plugin_search/
+    before_prepare/
+    before_run/
+    before_serve/
+    pre_package/ <-- Windows 8 and Windows Phone only.
+
+## Script Interface
+
+All scripts are run from the project's root directory and have the root directory passes as the first argument. All other options are passed to the script using environment variables:
+
+* CORDOVA_VERSION - The version of the Cordova-CLI.
+* CORDOVA_PLATFORMS - Comma separated list of platforms that the command applies to (e.g.: android, ios).
+* CORDOVA_PLUGINS - Comma separated list of plugin IDs that the command applies to (e.g.: org.apache.cordova.file, org.apache.cordova.file-transfer)
+* CORDOVA_HOOK - Path to the hook that is being executed.
+* CORDOVA_CMDLINE - The exact command-line arguments passed to cordova (e.g.: cordova run ios --emulate)
+
+If a script returns a non-zero exit code, then the parent cordova command will be aborted.
+
+
+## Writing hooks
+
+We highly recommend writting your hooks using Node.js so that they are
+cross-platform. Some good examples are shown here:
+
+[http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/](http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/)
+

+ 94 - 0
ionic/hooks/after_prepare/010_add_platform_class.js

@@ -0,0 +1,94 @@
+#!/usr/bin/env node
+
+// Add Platform Class
+// v1.0
+// Automatically adds the platform class to the body tag
+// after the `prepare` command. By placing the platform CSS classes
+// directly in the HTML built for the platform, it speeds up
+// rendering the correct layout/style for the specific platform
+// instead of waiting for the JS to figure out the correct classes.
+
+var fs = require('fs');
+var path = require('path');
+
+var rootdir = process.argv[2];
+
+function addPlatformBodyTag(indexPath, platform) {
+  // add the platform class to the body tag
+  try {
+    var platformClass = 'platform-' + platform;
+    var cordovaClass = 'platform-cordova platform-webview';
+
+    var html = fs.readFileSync(indexPath, 'utf8');
+
+    var bodyTag = findBodyTag(html);
+    if(!bodyTag) return; // no opening body tag, something's wrong
+
+    if(bodyTag.indexOf(platformClass) > -1) return; // already added
+
+    var newBodyTag = bodyTag;
+
+    var classAttr = findClassAttr(bodyTag);
+    if(classAttr) {
+      // body tag has existing class attribute, add the classname
+      var endingQuote = classAttr.substring(classAttr.length-1);
+      var newClassAttr = classAttr.substring(0, classAttr.length-1);
+      newClassAttr += ' ' + platformClass + ' ' + cordovaClass + endingQuote;
+      newBodyTag = bodyTag.replace(classAttr, newClassAttr);
+
+    } else {
+      // add class attribute to the body tag
+      newBodyTag = bodyTag.replace('>', ' class="' + platformClass + ' ' + cordovaClass + '">');
+    }
+
+    html = html.replace(bodyTag, newBodyTag);
+
+    fs.writeFileSync(indexPath, html, 'utf8');
+
+    process.stdout.write('add to body class: ' + platformClass + '\n');
+  } catch(e) {
+    process.stdout.write(e);
+  }
+}
+
+function findBodyTag(html) {
+  // get the body tag
+  try{
+    return html.match(/<body(?=[\s>])(.*?)>/gi)[0];
+  }catch(e){}
+}
+
+function findClassAttr(bodyTag) {
+  // get the body tag's class attribute
+  try{
+    return bodyTag.match(/ class=["|'](.*?)["|']/gi)[0];
+  }catch(e){}
+}
+
+if (rootdir) {
+
+  // go through each of the platform directories that have been prepared
+  var platforms = (process.env.CORDOVA_PLATFORMS ? process.env.CORDOVA_PLATFORMS.split(',') : []);
+
+  for(var x=0; x<platforms.length; x++) {
+    // open up the index.html file at the www root
+    try {
+      var platform = platforms[x].trim().toLowerCase();
+      var indexPath;
+
+      if(platform == 'android') {
+        indexPath = path.join('platforms', platform, 'assets', 'www', 'index.html');
+      } else {
+        indexPath = path.join('platforms', platform, 'www', 'index.html');
+      }
+
+      if(fs.existsSync(indexPath)) {
+        addPlatformBodyTag(indexPath, platform);
+      }
+
+    } catch(e) {
+      process.stdout.write(e);
+    }
+  }
+
+}

+ 4 - 0
ionic/ionic.project

@@ -0,0 +1,4 @@
+{
+  "name": "ionic",
+  "app_id": ""
+}

+ 21 - 0
ionic/package.json

@@ -0,0 +1,21 @@
+{
+  "name": "ionic-project",
+  "version": "1.0.0",
+  "description": "An Ionic project",
+  "dependencies": {
+    "gulp": "^3.5.6",
+    "gulp-sass": "^1.3.3",
+    "gulp-concat": "^2.2.0",
+    "gulp-minify-css": "^0.3.0",
+    "gulp-rename": "^1.2.0"
+  },
+  "devDependencies": {
+    "bower": "^1.3.3",
+    "gulp-util": "^2.2.14",
+    "shelljs": "^0.3.0"
+  },
+  "cordovaPlugins": [],
+  "cordovaPlatforms": [
+    "ios"
+  ]
+}

+ 11 - 0
ionic/plugins/ios.json

@@ -0,0 +1,11 @@
+{
+    "prepare_queue": {
+        "installed": [],
+        "uninstalled": []
+    },
+    "config_munge": {
+        "files": {}
+    },
+    "installed_plugins": {},
+    "dependent_plugins": {}
+}

BIN=BIN
ionic/resources/android/icon/drawable-hdpi-icon.png


BIN=BIN
ionic/resources/android/icon/drawable-ldpi-icon.png


BIN=BIN
ionic/resources/android/icon/drawable-mdpi-icon.png


BIN=BIN
ionic/resources/android/icon/drawable-xhdpi-icon.png


BIN=BIN
ionic/resources/android/icon/drawable-xxhdpi-icon.png


BIN=BIN
ionic/resources/android/icon/drawable-xxxhdpi-icon.png


BIN=BIN
ionic/resources/android/splash/drawable-land-hdpi-screen.png


BIN=BIN
ionic/resources/android/splash/drawable-land-ldpi-screen.png


BIN=BIN
ionic/resources/android/splash/drawable-land-mdpi-screen.png


BIN=BIN
ionic/resources/android/splash/drawable-land-xhdpi-screen.png


BIN=BIN
ionic/resources/android/splash/drawable-land-xxhdpi-screen.png


BIN=BIN
ionic/resources/android/splash/drawable-land-xxxhdpi-screen.png


BIN=BIN
ionic/resources/android/splash/drawable-port-hdpi-screen.png


BIN=BIN
ionic/resources/android/splash/drawable-port-ldpi-screen.png


BIN=BIN
ionic/resources/android/splash/drawable-port-mdpi-screen.png


BIN=BIN
ionic/resources/android/splash/drawable-port-xhdpi-screen.png


BIN=BIN
ionic/resources/android/splash/drawable-port-xxhdpi-screen.png


BIN=BIN
ionic/resources/android/splash/drawable-port-xxxhdpi-screen.png


BIN=BIN
ionic/resources/icon.png


BIN=BIN
ionic/resources/ios/icon/icon-40.png


BIN=BIN
ionic/resources/ios/icon/icon-40@2x.png


BIN=BIN
ionic/resources/ios/icon/icon-50.png


BIN=BIN
ionic/resources/ios/icon/icon-50@2x.png


BIN=BIN
ionic/resources/ios/icon/icon-60.png


BIN=BIN
ionic/resources/ios/icon/icon-60@2x.png


BIN=BIN
ionic/resources/ios/icon/icon-60@3x.png


BIN=BIN
ionic/resources/ios/icon/icon-72.png


BIN=BIN
ionic/resources/ios/icon/icon-72@2x.png


BIN=BIN
ionic/resources/ios/icon/icon-76.png


BIN=BIN
ionic/resources/ios/icon/icon-76@2x.png


BIN=BIN
ionic/resources/ios/icon/icon-small.png


BIN=BIN
ionic/resources/ios/icon/icon-small@2x.png


BIN=BIN
ionic/resources/ios/icon/icon-small@3x.png


BIN=BIN
ionic/resources/ios/icon/icon.png


BIN=BIN
ionic/resources/ios/icon/icon@2x.png


BIN=BIN
ionic/resources/ios/splash/Default-568h@2x~iphone.png


BIN=BIN
ionic/resources/ios/splash/Default-667h.png


BIN=BIN
ionic/resources/ios/splash/Default-736h.png


BIN=BIN
ionic/resources/ios/splash/Default-Landscape-736h.png


BIN=BIN
ionic/resources/ios/splash/Default-Landscape@2x~ipad.png


BIN=BIN
ionic/resources/ios/splash/Default-Landscape~ipad.png


BIN=BIN
ionic/resources/ios/splash/Default-Portrait@2x~ipad.png


BIN=BIN
ionic/resources/ios/splash/Default-Portrait~ipad.png


BIN=BIN
ionic/resources/ios/splash/Default@2x~iphone.png


BIN=BIN
ionic/resources/ios/splash/Default~iphone.png


BIN=BIN
ionic/resources/splash.png


+ 23 - 0
ionic/scss/ionic.app.scss

@@ -0,0 +1,23 @@
+/*
+To customize the look and feel of Ionic, you can override the variables
+in ionic's _variables.scss file.
+
+For example, you might change some of the default colors:
+
+$light:                           #fff !default;
+$stable:                          #f8f8f8 !default;
+$positive:                        #387ef5 !default;
+$calm:                            #11c1f3 !default;
+$balanced:                        #33cd5f !default;
+$energized:                       #ffc900 !default;
+$assertive:                       #ef473a !default;
+$royal:                           #886aea !default;
+$dark:                            #444 !default;
+*/
+
+// The path for our ionicons font files, relative to the built CSS in www/css
+$ionicons-font-path: "../lib/ionic/fonts" !default;
+
+// Include all of Ionic
+@import "www/lib/ionic/scss/ionic";
+

+ 1 - 0
ionic/www/css/style.css

@@ -0,0 +1 @@
+/* Empty. Add your own CSS if you like */

BIN=BIN
ionic/www/img/ionic.png


+ 36 - 0
ionic/www/index.html

@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
+    <title></title>
+
+    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
+    <link href="css/style.css" rel="stylesheet">
+
+    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
+    <link href="css/ionic.app.css" rel="stylesheet">
+    -->
+
+    <!-- Ionic / Angularjs js -->
+    <script src="lib/ionic/js/ionic.bundle.js"></script>
+    <script src="lib/ionic/js/angular/angular-resource.min.js"></script>
+
+    <!-- Cordova script (this will be a 404 during development) -->
+    <script src="cordova.js"></script>
+
+    <!-- Main application file -->
+    <script src="js/app.js"></script>
+
+    <!-- Controllers -->
+    <script src="js/controllers.js"></script>
+
+    <!-- Services -->
+    <script src="js/services.js"></script>
+    
+  </head>
+
+  <body ng-app="starter">
+    <ion-nav-view></ion-nav-view>
+  </body>
+</html>

+ 51 - 0
ionic/www/js/app.js

@@ -0,0 +1,51 @@
+// 'starter.controllers' is found in controllers.js
+angular.module('starter', ['ionic', 'starter.controllers'])
+
+.run(function($ionicPlatform) {
+  $ionicPlatform.ready(function() {
+    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
+    // for form inputs)
+    if (window.cordova && window.cordova.plugins.Keyboard) {
+      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
+    }
+    if (window.StatusBar) {
+      // org.apache.cordova.statusbar required
+      StatusBar.styleDefault();
+    }
+  });
+})
+
+.config(function($stateProvider, $urlRouterProvider) {
+  $stateProvider
+
+  .state('app', {
+    url: "/app",
+    abstract: true,
+    templateUrl: "templates/menu.html",
+    controller: 'AppCtrl'
+  })
+
+  
+  .state('app.snippets', {
+    url: "/snippets",
+    views: {
+        'menuContent': {
+            templateUrl: "templates/snippets.html",
+            controller: 'SnippetsCtrl'
+        }
+    }
+  })
+
+  .state('app.githubUser', {
+    url: "/githubUser",
+    views: {
+        'menuContent': {
+            templateUrl: "templates/githubUser.html",
+            controller: 'githubUserCtrl'
+        }
+    }
+  })
+
+  // if none of the above states are matched, use this as the fallback
+  $urlRouterProvider.otherwise('/app/snippets');
+});

+ 14 - 0
ionic/www/js/controllers.js

@@ -0,0 +1,14 @@
+angular.module('starter.controllers', ['starter.services'])
+
+.controller('AppCtrl', function($scope, $ionicModal, $timeout) {
+
+})
+
+.controller('SnippetsCtrl', function($scope, Snippets) {
+    $scope.snippets = Snippets.query();
+})
+
+.controller('githubUserCtrl', function($scope, githubUser) {
+    $scope.githubUserData = githubUser.get();
+})
+

+ 9 - 0
ionic/www/js/services.js

@@ -0,0 +1,9 @@
+angular.module('starter.services', ['ngResource'])
+
+.factory('Snippets', function ($resource) {
+    return $resource('http://127.0.0.1:8000/hackathon/snippets/');
+})
+
+.factory('githubUser', function ($resource) {
+    return $resource('http://127.0.0.1:8000/hackathon/githubUser/');
+})

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 7600 - 0
ionic/www/lib/ionic/css/ionic.css


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 23 - 0
ionic/www/lib/ionic/css/ionic.min.css


+ 0 - 0
ionic/www/lib/ionic/fonts/ionicons.eot


Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio