diff --git a/assets/pokemon_v2/css/app.min.css b/assets/pokemon_v2/css/app.min.css index 21f33e58..314afbb8 100644 --- a/assets/pokemon_v2/css/app.min.css +++ b/assets/pokemon_v2/css/app.min.css @@ -1,8 +1,8 @@ -body{font-family:Lato,Sans-Serif;color:#212121;padding-top:53px}h1,h2,h3,h4,h5,h6{margin-top:0}ul{list-style:none}ul li{padding:0}pre.scroll{max-height:360px;overflow:scroll}.standard-pad{padding-top:40px}.hero{text-align:center}.center-block{float:none;margin:0 auto}.btn,.input-group-addon{border-radius:0} +body{font-family:Lato,Sans-Serif;color:#212121;padding-top:53px}h1,h2,h3,h4,h5,h6{margin-top:0}ul{list-style:none}ul li{padding:0}pre.scroll{max-height:360px;overflow:scroll}.standard-pad{padding-top:40px}.hero{text-align:center;padding-bottom:40px}.center-block{float:none;margin:0 auto}.btn,.input-group-addon{border-radius:0} ul[side-nav]{padding:0}ul[side-nav] ul{padding-left:10px} .pokespinner{height:80px;width:80px;border-radius:50%;border:4px solid #00838f;background-color:#fff;overflow:hidden;position:relative;box-sizing:border-box;-webkit-animation:a 1.5s infinite linear;animation:a 1.5s infinite linear}.pokespinner:after,.pokespinner:before{display:block;content:""}.pokespinner:before{width:100%;height:40px;margin-top:-6px;background-color:#26c6da;border-bottom:4px solid #00838f}.pokespinner:after{width:10px;height:10px;background-color:#fff;position:absolute;top:40px;left:40px;margin:-10px 0 0 -10px;border-radius:50%;border:1px solid #00838f;box-shadow:0 0 0 2px #fff,0 0 0 6px #00838f}@-webkit-keyframes a{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes a{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}} #contributors .contributor{position:relative;margin-bottom:30px}#contributors .contributor .avatar{width:100%;height:auto} -header{background-color:#d9d9d9}header .title{font-size:2em;padding-top:6px;display:inline-block;font-weight:900}header .pokenav{float:right;padding:16px 0;margin:0}header .pokenav li{display:inline-block;margin-left:30px;font-size:1.1em}header .pokenav li a{cursor:pointer;color:#212121;font-weight:600}header .pokenav li a:hover{text-decoration:none} #docs{padding-top:40px}#docs table{width:100%;margin-bottom:20px}#docs table td,#docs table th{border:1px solid #ccc;padding:10px}#docs section{margin-bottom:60px}#docs h2{font-weight:900}#docs .request{font-size:1.4em;font-weight:300}#docs .models-tag,#docs .response-tag{font-style:italic;margin-bottom:3px;font-weight:300}#docs .models-tag:before,#docs .response-tag:before{display:inline-block;content:"example response"}#docs .models-tag:before{content:"response models"} +header{background-color:#d9d9d9}header .title{font-size:2em;padding-top:6px;display:inline-block;font-weight:900}header .pokenav{float:right;padding:16px 0;margin:0}header .pokenav li{display:inline-block;margin-left:30px;font-size:1.1em}header .pokenav li a{cursor:pointer;color:#212121;font-weight:600}header .pokenav li a:hover{text-decoration:none} #home .title{font-weight:900}#home .v{font-size:.5em;font-weight:300}#home .try{font-weight:600}#home .request{width:100%;margin-bottom:30px}#home .request .endpoint button{border-right-style:none}#home .json-body{border:1px solid #d9d9d9;padding:20px;min-height:360px;max-height:360px;overflow:scroll} \ No newline at end of file diff --git a/assets/pokemon_v2/js/app.min.js b/assets/pokemon_v2/js/app.min.js index 3b27fd44..bb70243e 100644 --- a/assets/pokemon_v2/js/app.min.js +++ b/assets/pokemon_v2/js/app.min.js @@ -1,9 +1,9 @@ -!function(){"use strict";angular.module("pokeapi_v2",["pokeapi-core","pokeapi-header","pokeapi-home","pokeapi-about","pokeapi-docs","pokeapi-contributors"]).config(["$locationProvider","$httpProvider",function(o,e){o.html5Mode(!0),e.defaults.xsrfCookieName="csrftoken",e.defaults.xsrfHeaderName="X-CSRFToken"}])}(); +!function(){"use strict";angular.module("pokeapi_v2",["pokeapi-core","pokeapi-header","pokeapi-home","pokeapi-about","pokeapi-docs","pokeapi-contributors"]).config(["$locationProvider","$stateProvider",function(o,e){o.html5Mode(!0),e.state("v1",{url:"v1/",controller:function(){window.location.reload(!0)}})}])}(); !function(){"use strict";angular.module("pokeapi-about",["pokeapi-core"])}(); !function(){"use strict";angular.module("pokeapi-contributors",["pokeapi-core"])}(); !function(){"use strict";angular.module("pokeapi-core",["ui.router","jsonFormatter"])}(); -!function(){"use strict";angular.module("pokeapi-docs",["pokeapi-core"])}(); !function(){"use strict";angular.module("pokeapi-header",[])}(); +!function(){"use strict";angular.module("pokeapi-docs",["pokeapi-core"])}(); !function(){"use strict";angular.module("pokeapi-home",["pokeapi-core"])}(); !function(){"use strict";angular.module("pokeapi-about").config(["$stateProvider",function(t){t.state("about",{url:"/about",templateUrl:"static/pokemon_v2/partials/about.html"})}])}(); !function(){"use strict";angular.module("pokeapi-contributors").config(["$stateProvider",function(t){t.state("contributors",{url:"/contributors",templateUrl:"static/pokemon_v2/partials/contributors.html",controller:"ContributorsController"})}])}(); @@ -11,8 +11,8 @@ !function(){"use strict";angular.module("pokeapi-home").config(["$stateProvider",function(o){o.state("home",{url:"/",templateUrl:"static/pokemon_v2/partials/home.html",controller:"HomeController"})}])}(); "use strict";angular.module("pokeapi-core").factory("APIService",["$http",function(e){var r="api/v2/",t={};return t.getResource=function(t,n){var u=e.get(r+t+n).then(function(e){return e});return u},t}]); "use strict";angular.module("pokeapi-core").factory("RepoService",["$http",function(t){var r="http://api.github.com/repos/phalt/pokeapi/",e=r+"contributors",o={};return o.getContributors=function(){var r=t.get(e).then(function(t){return t});return r},o}]); -angular.module("pokeapi-core").directive("sideNav",["$window",function(n){return{restrict:"EA",templateUrl:"static/pokemon_v2/partials/side-nav.html",replace:!0,link:function(e,t,r){function a(n){return n.getAttribute("side-nav-title")||anchor.textContent}function o(){console.log("scroll")}e.nav=[];var l=null,c=angular.element(document.querySelectorAll("[side-nav-parent], [side-nav-child]"));for(i=0;iPokéapi v2

The Pokémon RESTful API

+ Looking for V1? diff --git a/config/urls.py b/config/urls.py index 50e2d2f6..820e1974 100755 --- a/config/urls.py +++ b/config/urls.py @@ -8,11 +8,10 @@ from django.contrib import admin from pokemon import urls as pokemon_urls from pokemon_v2 import urls as pokemon_v2_urls -urlpatterns = [ - - url(r'^', include(pokemon_urls)), +# need to make sure v2 urls resolve last so angular routes have control +v2 = [ url(r'^', include(pokemon_v2_urls)) ] - url(r'^', include(pokemon_v2_urls)), +urlpatterns = [ url(r'^admin/', include(admin.site.urls)), @@ -24,4 +23,6 @@ urlpatterns = [ 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}), -] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ No newline at end of file + url(r'^', include(pokemon_urls)), + +] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + v2 \ No newline at end of file diff --git a/pokemon/urls.py b/pokemon/urls.py index 3cd19b8b..21d10f46 100644 --- a/pokemon/urls.py +++ b/pokemon/urls.py @@ -34,8 +34,10 @@ api_resources.register(MoveResource()) api_resources.register(PokedexResource()) urlpatterns = [ + + # url(r'^v1$', 'pokemon.views.home'), - url(r'^v1/$', 'pokemon.views.home'), + url(r'^v1/?$', 'pokemon.views.home'), url(r'^v1/docs/$', TemplateView.as_view(template_name='docs-v1.html'), diff --git a/pokemon_v2/client/app.js b/pokemon_v2/client/app.js index d97a321a..4a138207 100644 --- a/pokemon_v2/client/app.js +++ b/pokemon_v2/client/app.js @@ -12,14 +12,21 @@ 'pokeapi-contributors' ]) - .config(['$locationProvider', '$httpProvider', + .config(['$locationProvider', '$stateProvider', - function ($locationProvider, $httpProvider) { + function ($locationProvider, $stateProvider) { $locationProvider.html5Mode(true); - $httpProvider.defaults.xsrfCookieName = 'csrftoken'; - $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken'; + // Allow navigation to V1. Leaves the single page app. + $stateProvider.state('v1', { + + url : 'v1/', + controller : function () { + + window.location.reload(true); + } + }); } ]); diff --git a/pokemon_v2/client/components/contributors/scripts/contributors-controller.js b/pokemon_v2/client/components/contributors/scripts/contributors-controller.js index b32ab7a1..1e50b8a0 100644 --- a/pokemon_v2/client/components/contributors/scripts/contributors-controller.js +++ b/pokemon_v2/client/components/contributors/scripts/contributors-controller.js @@ -12,7 +12,7 @@ angular.module('pokeapi-contributors') Repo.getContributors().then( function (response) { - if (response.status == 200) { + if (response.status === 200) { $scope.contributors = response.data; console.log(response); diff --git a/pokemon_v2/client/components/core/scripts/api-service.js b/pokemon_v2/client/components/core/scripts/api-service.js index 90ef28a6..8f6dc9be 100644 --- a/pokemon_v2/client/components/core/scripts/api-service.js +++ b/pokemon_v2/client/components/core/scripts/api-service.js @@ -7,12 +7,7 @@ angular.module('pokeapi-core') function ($http) { - var BASE_URL = "api/v2/"; - var ID = '/{id}'; - - // var ABILITY = BASE_URL + "ability"; - // var ABILITY_DETAIL = ABILITY + ID - + var BASE_URL = 'api/v2/'; var service = {}; service.getResource = function (endpoint, id) { @@ -24,7 +19,7 @@ angular.module('pokeapi-core') }); return cb; - } + }; return service; } diff --git a/pokemon_v2/client/components/core/scripts/repo-service.js b/pokemon_v2/client/components/core/scripts/repo-service.js index f83fc7ce..fad10c8e 100644 --- a/pokemon_v2/client/components/core/scripts/repo-service.js +++ b/pokemon_v2/client/components/core/scripts/repo-service.js @@ -7,8 +7,8 @@ angular.module('pokeapi-core') function ($http) { - var BASE_URL = "http://api.github.com/repos/phalt/pokeapi/" - var CONTRIBUTORS_PATH = BASE_URL + "contributors"; + var BASE_URL = 'http://api.github.com/repos/phalt/pokeapi/'; + var CONTRIBUTORS_PATH = BASE_URL + 'contributors'; var service = {}; @@ -21,7 +21,7 @@ angular.module('pokeapi-core') }); return cb; - } + }; return service; } diff --git a/pokemon_v2/client/components/core/scripts/side-nav-directive.js b/pokemon_v2/client/components/core/scripts/side-nav-directive.js index 958a7f71..2723030c 100644 --- a/pokemon_v2/client/components/core/scripts/side-nav-directive.js +++ b/pokemon_v2/client/components/core/scripts/side-nav-directive.js @@ -1,4 +1,6 @@ +'use strict'; + angular.module('pokeapi-core') .directive('sideNav', ['$window', function ($window) { @@ -11,23 +13,31 @@ angular.module('pokeapi-core') replace: true, - link: function (scope, element, attrs) { + link: function (scope) { + + function calculate () { + + console.log('scroll'); + } + + function getAnchorText (el) { + + return el.getAttribute('side-nav-title') || el.textContent; + } scope.nav = []; var parent = null; var anchors = angular.element(document.querySelectorAll('[side-nav-parent], [side-nav-child]')); - for (i = 0; i < anchors.length; i++) { + for (var i = 0; i < anchors.length; i++) { - anchor = anchors[i]; - - console.log(anchor); + var anchor = anchors[i]; if (anchor.hasAttribute('side-nav-parent')) { parent = {}; parent.anchorText = getAnchorText(anchor); - parent.children = [] + parent.children = []; scope.nav.push(parent); } else { @@ -40,20 +50,8 @@ angular.module('pokeapi-core') } } - console.log(scope.nav); - - function getAnchorText (el) { - - return el.getAttribute('side-nav-title') || anchor.textContent; - } - angular.element($window).bind('scroll', calculate); - - function calculate () { - - console.log('scroll'); - } } - } + }; }]); \ No newline at end of file diff --git a/pokemon_v2/client/components/core/styles/core.scss b/pokemon_v2/client/components/core/styles/core.scss index 6a5fd8b6..308968d7 100644 --- a/pokemon_v2/client/components/core/styles/core.scss +++ b/pokemon_v2/client/components/core/styles/core.scss @@ -37,6 +37,7 @@ pre.scroll { .hero { text-align: center; + padding-bottom: 40px; } .center-block { diff --git a/pokemon_v2/client/components/home/scripts/home-controller.js b/pokemon_v2/client/components/home/scripts/home-controller.js index 0aaa184a..8cd23125 100644 --- a/pokemon_v2/client/components/home/scripts/home-controller.js +++ b/pokemon_v2/client/components/home/scripts/home-controller.js @@ -44,7 +44,7 @@ angular.module('pokeapi-home') if (response.status === 200) { $scope.resource = response.data; - intercept(); + // intercept(); } else { @@ -53,17 +53,17 @@ angular.module('pokeapi-home') $scope.loading = false; } - ) + ); }; $scope.getResource(); - function intercept () { + // function intercept () { - var links = document.querySelector('.json-body a'); + // var links = document.querySelector('.json-body a'); - } + // } } ]); diff --git a/pokemon_v2/urls.py b/pokemon_v2/urls.py index 6a3c778e..00a582fe 100644 --- a/pokemon_v2/urls.py +++ b/pokemon_v2/urls.py @@ -71,11 +71,11 @@ router.register(r"version-group", VersionGroupResource) ########################### urlpatterns = [ + + url(r'^api/v2/', include(router.urls)), - url(r'^$', + url(r'^.*$', TemplateView.as_view(template_name='home.html'), name="home" - ), - - url(r'^api/v2/', include(router.urls)), + ) ]