From 6f7d9f5769e8a2baa8a2842308c13d66f1a5becc Mon Sep 17 00:00:00 2001 From: Juriy Bura Date: Mon, 13 Apr 2020 16:45:33 +0200 Subject: [PATCH 01/16] Updated index with new info about the branch --- swapi/templates/index.html | 42 +++++++++++++++----------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/swapi/templates/index.html b/swapi/templates/index.html index ffbe3763..94c477b8 100644 --- a/swapi/templates/index.html +++ b/swapi/templates/index.html @@ -40,28 +40,28 @@

"eye_color": "blue", "birth_year": "19BBY", "gender": "male", - "homeworld": "https://swapi.co/api/planets/1/", + "homeworld": "https://swapi.dev/api/planets/1/", "films": [ - "https://swapi.co/api/films/2/", - "https://swapi.co/api/films/6/", - "https://swapi.co/api/films/3/", - "https://swapi.co/api/films/1/", - "https://swapi.co/api/films/7/" + "https://swapi.dev/api/films/2/", + "https://swapi.dev/api/films/6/", + "https://swapi.dev/api/films/3/", + "https://swapi.dev/api/films/1/", + "https://swapi.dev/api/films/7/" ], "species": [ - "https://swapi.co/api/species/1/" + "https://swapi.dev/api/species/1/" ], "vehicles": [ - "https://swapi.co/api/vehicles/14/", - "https://swapi.co/api/vehicles/30/" + "https://swapi.dev/api/vehicles/14/", + "https://swapi.dev/api/vehicles/30/" ], "starships": [ - "https://swapi.co/api/starships/12/", - "https://swapi.co/api/starships/22/" + "https://swapi.dev/api/starships/12/", + "https://swapi.dev/api/starships/22/" ], "created": "2014-12-09T13:50:51.644000Z", "edited": "2014-12-20T21:17:56.891000Z", - "url": "https://swapi.co/api/people/1/" + "url": "https://swapi.dev/api/people/1/" } @@ -83,20 +83,10 @@

How can I use it?

Helper libraries for popular programming languages are also provided so you can consume swapi in your favourite programming language, in a style that suits you.

-

How can I support this?

-

With small donations we can keep swapi running for free, please consider throwing us some beer money to say thank you. With every $10 we can keep the site up for another month!

-

- -

-

This project is open source and you can contribute on GitHub.

+

What happened with old swapi.co?

+

swapi.co is not supported and maintained anymode. But since so many projects and tutorials used it as their educational + playground, this is an "unofficial" branch

+

This project is open source and you can contribute on GitHub.

From 1a313b3fd3b8d63967ee59d26d248d60020a3381 Mon Sep 17 00:00:00 2001 From: Juriy Bura Date: Mon, 13 Apr 2020 21:13:36 +0200 Subject: [PATCH 02/16] Updated README and links in HTML --- README.md | 16 ++++++++++++---- swapi/templates/base.html | 1 + swapi/templates/index.html | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6fd690aa..e5cec846 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,16 @@ # SWAPI -## The Star Wars API +## The Star Wars API -## NO LONGER MAINTAINED! +Source code for [swapi.dev](https://swapi.dev) -If you rely on this project for your own tools - then please fork and spin up your own instance. It's a pretty simple project, and the Makefile will take you a long way. -If you are looking for an API to play with to learn about APIs, then I recommend [https://pokeapi.co](https://pokeapi.co). +## What happened to swapi.co? +Unfortunately swapi.co is not maintained anymore. + +## What is swapi.dev? +An "unofficial" branch of "swapi", supported by @juriy + + +## Will it be updated? +Original swapi project is built on Python/Django stack that is quite outdated by now. It would be a great exercise to rewrite it in cloud-native manner, but this requires time and effort. I'm looking into doing that. There's no timelines yet, since "swapi" stopped its existence quite suddenly. Suggestions and help are always welcome! + diff --git a/swapi/templates/base.html b/swapi/templates/base.html index 3ad96858..992859f2 100644 --- a/swapi/templates/base.html +++ b/swapi/templates/base.html @@ -43,6 +43,7 @@

SWAPI

The Star Wars API

+

(what happened to swapi.co?)

{% block mainbody %} diff --git a/swapi/templates/index.html b/swapi/templates/index.html index 94c477b8..db75440c 100644 --- a/swapi/templates/index.html +++ b/swapi/templates/index.html @@ -23,7 +23,7 @@

Try it now!

- https://swapi.co/api/ + https://swapi.dev/api/
From 6ee1c1dce95c3b9e6e8dd92f7673243ced77a1bf Mon Sep 17 00:00:00 2001 From: Juriy Bura Date: Mon, 13 Apr 2020 21:27:05 +0200 Subject: [PATCH 03/16] updated about and readme with some info on official version --- swapi/templates/about.html | 14 ------ swapi/templates/about.md | 18 ++++---- swapi/templates/docs.md | 88 +++++++++++++++++++------------------- 3 files changed, 54 insertions(+), 66 deletions(-) diff --git a/swapi/templates/about.html b/swapi/templates/about.html index 516ecca7..a3dce70b 100644 --- a/swapi/templates/about.html +++ b/swapi/templates/about.html @@ -17,20 +17,6 @@

Statistics

{% endmarkdown %}
-

Donate

-

With small donations we can keep swapi running for free, please consider throwing us some beer money to say thank you. With every $10 we can keep the site up for another month!

-

- -

-

We truly appreciate your support

{% endblock mainbody %} diff --git a/swapi/templates/about.md b/swapi/templates/about.md index 070e102c..e8e1382a 100644 --- a/swapi/templates/about.md +++ b/swapi/templates/about.md @@ -8,6 +8,10 @@ We've formatted this data in [**JSON**](https://json.org) and exposed it to you [Check out the documentation to get started consuming swapi data](/documentation) +## What happened to swapi.co? +Unfortulately swapi.co is not maintained anymore, and the service is currently down. This is an "unofficial" for of SWAPI that will be supported going forward. + + ## What can you use this for? Comparing the data from Star Wars has never been easier. Here are some examples using the [Python helper library](/documentation#python) @@ -40,20 +44,17 @@ Comparing the data from Star Wars has never been easier. Here are some examples ## What are the features? We're using [Django](https://djangoproject.com) and [Django REST Framework](https://django-rest-framework.org) to serve a [RESTish](https://en.wikipedia.org/wiki/REST) API to you. - The data is all formatted in [JSON](http://json.org) and we also support [JSON Schema](http://jsonschema.net) for programmatically understanding the attributes of each resource. -We're using [stripe](https://stripe.com) to process our donations. - -## Why did you build this? - -I built the [Pokémon API](https://pokeapi.co) before I built this. I realised that *if you provide data easily, someone will consume it*. I got bored around Christmas 2014 and decided that I'd take what I learned from PokéAPI and build an API for Star Wars data. - Seeing the release trailer for Episode VII also made me stupidly enthusiastic for Star Wars again. ## Who are you? -I am [Paul Hallett](http://phalt.co), a senior software engineer and an infinitely protean machine. +I am [Juriy Bura](https://github.com/juriy), Solution Architect and author of JavaScript game development book and online React courses. + +## Original author? + +This project was originally built and maintained by [Paul Hallett](http://phalt.co). ## Copyright and stuff? @@ -72,3 +73,4 @@ SWAPI would not be possible without contributions from the following people: - [Owen Hallett](https://github.com/Videocard) - [Carvilsi](https://github.com/carvilsi) - [Andrea Stagi](https://github.com/astagi) +- [Juriy Bura](https://github.com/juriy) diff --git a/swapi/templates/docs.md b/swapi/templates/docs.md index 9018626c..a09390bf 100644 --- a/swapi/templates/docs.md +++ b/swapi/templates/docs.md @@ -15,7 +15,7 @@ Let's make our first API request to the Star Wars API! Open up a terminal and use [curl](http://curl.haxx.se) or [httpie](http://httpie.org) to make an API request for a resource. In the example below, we're trying to get the first planet, Tatooine: - http swapi.co/api/planets/1/ + http swapi.dev/api/planets/1/ We'll use [httpie](http://httpie.org) for our examples as it displays responses nicely and gives us a whole lot more useful information. If you don't want to download httpie, just use the *curl* command instead. @@ -31,14 +31,14 @@ Here is the response we get: "orbital_period": "304", "population": "200000", "residents": [ - "https://swapi.co/api/people/1/", - "https://swapi.co/api/people/2/", + "https://swapi.dev/api/people/1/", + "https://swapi.dev/api/people/2/", ... ], "rotation_period": "23", "surface_water": "1", "terrain": "Dessert", - "url": "https://swapi.co/api/planets/1/" + "url": "https://swapi.dev/api/planets/1/" } If your response looks slightly different don't panic. This is probably because more data has been added to swapi since we made this documentation. @@ -50,7 +50,7 @@ The **Base URL** is the root URL for all of the API, if you ever make a request The Base URL for swapi is: - https://swapi.co/api/ + https://swapi.dev/api/ The documentation below assumes you are prepending the Base URL to the endpoints in order to make requests. @@ -75,7 +75,7 @@ All resources support [JSON Schema](https://jsonschema.net). Making a request to All resources support a `search` parameter that filters the set of resources returned. This allows you to make queries like: ``` -https://swapi.co/api/people/?search=r2 +https://swapi.dev/api/people/?search=r2 ``` All searches will use case-insensitive partial matches on the set of search fields. To see the set of search fields for each resource, check out the individual resource documentation. For more information on advanced search terms see [here](http://www.django-rest-framework.org/api-guide/filtering/#searchfilter). @@ -98,7 +98,7 @@ Wookiee is for our tall hairy allies who speak Wookiee, this encoding is identic Using the wookiee renderer is easy, just append `?format=wookiee` to your urls: ``` -https://swapi.co/api/planets/1/?format=wookiee +https://swapi.dev/api/planets/1/?format=wookiee ``` #Resources @@ -111,19 +111,19 @@ The Root resource provides information on all available resources within the API **Example request:** - http https://swapi.co/api/ + http https://swapi.dev/api/ **Example response:** HTTP/1.0 200 OK Content-Type: application/json { - "films": "https://swapi.co/api/films/", - "people": "https://swapi.co/api/people/", - "planets": "https://swapi.co/api/planets/", - "species": "https://swapi.co/api/species/", - "starships": "https://swapi.co/api/starships/", - "vehicles": "https://swapi.co/api/vehicles/" + "films": "https://swapi.dev/api/films/", + "people": "https://swapi.dev/api/people/", + "planets": "https://swapi.dev/api/planets/", + "species": "https://swapi.dev/api/species/", + "starships": "https://swapi.dev/api/starships/", + "vehicles": "https://swapi.dev/api/vehicles/" } **Attributes:** @@ -156,7 +156,7 @@ A People resource is an individual person or character within the Star Wars univ **Example request:** - http https://swapi.co/api/people/1/ + http https://swapi.dev/api/people/1/ **Example response:** @@ -166,28 +166,28 @@ A People resource is an individual person or character within the Star Wars univ "birth_year": "19 BBY", "eye_color": "Blue", "films": [ - "https://swapi.co/api/films/1/", + "https://swapi.dev/api/films/1/", ... ], "gender": "Male", "hair_color": "Blond", "height": "172", - "homeworld": "https://swapi.co/api/planets/1/", + "homeworld": "https://swapi.dev/api/planets/1/", "mass": "77", "name": "Luke Skywalker", "skin_color": "Fair", "created": "2014-12-09T13:50:51.644000Z", "edited": "2014-12-10T13:52:43.172000Z", "species": [ - "https://swapi.co/api/species/1/" + "https://swapi.dev/api/species/1/" ], "starships": [ - "https://swapi.co/api/starships/12/", + "https://swapi.dev/api/starships/12/", ... ], - "url": "https://swapi.co/api/people/1/", + "url": "https://swapi.dev/api/people/1/", "vehicles": [ - "https://swapi.co/api/vehicles/14/" + "https://swapi.dev/api/vehicles/14/" ... ] } @@ -245,7 +245,7 @@ A Film resource is a single film. **Example request:** - http https://swapi.co/api/films/1/ + http https://swapi.dev/api/films/1/ **Example response:** @@ -253,7 +253,7 @@ A Film resource is a single film. Content-Type: application/json { "characters": [ - "https://swapi.co/api/people/1/", + "https://swapi.dev/api/people/1/", ... ], "created": "2014-12-10T14:23:31.880000Z", @@ -262,23 +262,23 @@ A Film resource is a single film. "episode_id": 4, "opening_crawl": "It is a period of civil war.\n\nRebel spaceships, striking\n\nfrom a hidden base, have won\n\ntheir first victory against\n\nthe evil Galactic Empire.\n\n\n\nDuring the battle, Rebel\n\nspies managed to steal secret\r\nplans to the Empire's\n\nultimate weapon, the DEATH\n\nSTAR, an armored space\n\nstation with enough power\n\nto destroy an entire planet.\n\n\n\nPursued by the Empire's\n\nsinister agents, Princess\n\nLeia races home aboard her\n\nstarship, custodian of the\n\nstolen plans that can save her\n\npeople and restore\n\nfreedom to the galaxy....", "planets": [ - "https://swapi.co/api/planets/1/", + "https://swapi.dev/api/planets/1/", ... ], "producer": "Gary Kurtz, Rick McCallum", "release_date": "1977-05-25", "species": [ - "https://swapi.co/api/species/1/", + "https://swapi.dev/api/species/1/", ... ], "starships": [ - "https://swapi.co/api/starships/2/", + "https://swapi.dev/api/starships/2/", ... ], "title": "A New Hope", - "url": "https://swapi.co/api/films/1/", + "url": "https://swapi.dev/api/films/1/", "vehicles": [ - "https://swapi.co/api/vehicles/4/", + "https://swapi.dev/api/vehicles/4/", ... ] } @@ -332,7 +332,7 @@ A Starship resource is a single transport craft that has hyperdrive capability. **Example request:** - http https://swapi.co/api/starships/9/ + http https://swapi.dev/api/starships/9/ **Example response:** @@ -354,11 +354,11 @@ A Starship resource is a single transport craft that has hyperdrive capability. "name": "Death Star", "passengers": "843342", "films": [ - "https://swapi.co/api/films/1/" + "https://swapi.dev/api/films/1/" ], "pilots": [], "starship_class": "Deep Space Mobile Battlestation", - "url": "https://swapi.co/api/starships/9/" + "url": "https://swapi.dev/api/starships/9/" } **Attributes:** @@ -419,7 +419,7 @@ A Vehicle resource is a single transport craft that **does not have** hyperdrive **Example request:** - http https://swapi.co/api/vehicles/4/ + http https://swapi.dev/api/vehicles/4/ **Example response:** @@ -441,9 +441,9 @@ A Vehicle resource is a single transport craft that **does not have** hyperdrive "passengers": "30", "pilots": [], "films": [ - "https://swapi.co/api/films/1/" + "https://swapi.dev/api/films/1/" ], - "url": "https://swapi.co/api/vehicles/4/", + "url": "https://swapi.dev/api/vehicles/4/", "vehicle_class": "wheeled" } @@ -501,7 +501,7 @@ A Species resource is a type of person or character within the Star Wars Univers **Example request:** - http https://swapi.co/api/species/3/ + http https://swapi.dev/api/species/3/ **Example response:** @@ -517,18 +517,18 @@ A Species resource is a type of person or character within the Star Wars Univers "edited": "2014-12-10T16:44:31.486000Z", "eye_colors": "blue, green, yellow, brown, golden, red", "hair_colors": "black, brown", - "homeworld": "https://swapi.co/api/planets/14/", + "homeworld": "https://swapi.dev/api/planets/14/", "language": "Shyriiwook", "name": "Wookie", "people": [ - "https://swapi.co/api/people/13/" + "https://swapi.dev/api/people/13/" ], "films": [ - "https://swapi.co/api/films/1/", - "https://swapi.co/api/films/2/" + "https://swapi.dev/api/films/1/", + "https://swapi.dev/api/films/2/" ], "skin_colors": "gray", - "url": "https://swapi.co/api/species/3/" + "url": "https://swapi.dev/api/species/3/" } **Attributes:** @@ -582,7 +582,7 @@ A Planet resource is a large mass, planet or planetoid in the Star Wars Universe **Example request:** - http https://swapi.co/api/planets/1/ + http https://swapi.dev/api/planets/1/ **Example response:** @@ -595,7 +595,7 @@ A Planet resource is a large mass, planet or planetoid in the Star Wars Universe "diameter": "10465", "edited": "2014-12-15T13:48:16.167217Z", "films": [ - "https://swapi.co/api/films/1/", + "https://swapi.dev/api/films/1/", ... ], "gravity": "1", @@ -603,13 +603,13 @@ A Planet resource is a large mass, planet or planetoid in the Star Wars Universe "orbital_period": "304", "population": "120000", "residents": [ - "https://swapi.co/api/people/1/", + "https://swapi.dev/api/people/1/", ... ], "rotation_period": "23", "surface_water": "1", "terrain": "Dessert", - "url": "https://swapi.co/api/planets/1/" + "url": "https://swapi.dev/api/planets/1/" } **Attributes:** From e3f3c250c12d3fb4450066a66216d7e42442edbe Mon Sep 17 00:00:00 2001 From: Juriy Bura Date: Tue, 14 Apr 2020 12:33:16 +0200 Subject: [PATCH 04/16] Updated google analytics code and names --- swapi/templates/base.html | 28 ++++++++++++------------- swapi/templates/rest_framework/api.html | 2 +- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/swapi/templates/base.html b/swapi/templates/base.html index 992859f2..458e541f 100644 --- a/swapi/templates/base.html +++ b/swapi/templates/base.html @@ -1,6 +1,6 @@ - + @@ -14,6 +14,13 @@ </style> <script src="//code.jquery.com/jquery-2.1.0.min.js"></script> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> + <!-- Global site tag (gtag.js) - Google Analytics --> + <script async src="https://www.googletagmanager.com/gtag/js?id=UA-163610532-1"></script> + <script> + window.dataLayer = window.dataLayer || []; + function gtag(){dataLayer.push(arguments);} + gtag('js', new Date()); + gtag('config', 'UA-163610532-1'); </script> </head> <body> @@ -26,7 +33,7 @@ <span class="icon-bar"></span> <span class="icon-bar"></span> </button> - <div class="navbar-brand" href="#"><a href="https://twitter.com/share" class="twitter-share-button" data-url="https://swapi.co" data-text="SWAPI - the Star Wars API " data-via="phalt_" data-related="phalt_">Tweet</a> + <div class="navbar-brand" href="#"><a href="https://twitter.com/share" class="twitter-share-button" data-url="https://swapi.co" data-text="swapi.dev - the Star Wars API " data-via="juriy" data-related="juriy">Tweet</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script></div> </div> <div class="collapse navbar-collapse"> @@ -50,23 +57,14 @@ <h1>SWAPI</h1> {% endblock mainbody %} {% block scripts %} {% endblock scripts %} - <script> - (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) - })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); - ga('create', 'UA-53299289-3', 'auto'); - ga('send', 'pageview'); - </script> <div class="row"> <div class="col-lg-12 footer"> - <a href="//phalt.co?ref=swapi" target="_blank">© Paul Hallett <script type="text/javascript"> - document.write(new Date().getFullYear()); -</script></a> + Created by Paul Hallett + Maintained by Juriy Bura ©<script type="text/javascript">document.write(new Date().getFullYear());</script> <span class="pull-right"> - <a href="//twitter.com/phalt_" class="twitter-follow-button" data-show-count="false" data-show-screen-name="false" data-dnt="true">Follow me on twitter</a> + <a href="//twitter.com/juriy" class="twitter-follow-button" data-show-count="false" data-show-screen-name="false" data-dnt="true">Follow me on twitter</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script> - <iframe src="//ghbtns.com/github-btn.html?user=phalt&type=follow" + <iframe src="//ghbtns.com/github-btn.html?user=juriy&type=follow" allowtransparency="false" frameborder="0" scrolling="0" width="132" height="20"></iframe></span></p> </div> </div> diff --git a/swapi/templates/rest_framework/api.html b/swapi/templates/rest_framework/api.html index 70713d3c..51da42b4 100644 --- a/swapi/templates/rest_framework/api.html +++ b/swapi/templates/rest_framework/api.html @@ -12,7 +12,7 @@ <span class="icon-bar"></span> <span class="icon-bar"></span> </button> -<div class="navbar-brand" href="#"><a href="https://twitter.com/share" class="twitter-share-button" data-url="https://swapi.co" data-text="SWAPI - the Star Wars API " data-via="phalt_" data-related="phalt_">Tweet</a> +<div class="navbar-brand" href="#"><a href="https://twitter.com/share" class="twitter-share-button" data-url="https://swapi.co" data-text="SWAPI - the Star Wars API " data-via="juriy" data-related="juriy">Tweet</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script></div> </div> <div class="collapse navbar-collapse"> From c465fd11165b1c8c5524d33a1fad830264f2b27c Mon Sep 17 00:00:00 2001 From: Juriy Bura <juriy.bura@gmail.com> Date: Tue, 14 Apr 2020 12:45:14 +0200 Subject: [PATCH 05/16] updated wording in about --- swapi/templates/about.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swapi/templates/about.md b/swapi/templates/about.md index e8e1382a..5401b226 100644 --- a/swapi/templates/about.md +++ b/swapi/templates/about.md @@ -9,7 +9,7 @@ We've formatted this data in [**JSON**](https://json.org) and exposed it to you [Check out the documentation to get started consuming swapi data](/documentation) ## What happened to swapi.co? -Unfortulately swapi.co is not maintained anymore, and the service is currently down. This is an "unofficial" for of SWAPI that will be supported going forward. +Unfortulately swapi.co is not maintained anymore, and the service is currently down. This is an branch of SWAPI that will be supported going forward. ## What can you use this for? From 22fd615b1759d9609d95cd08567204366f68f455 Mon Sep 17 00:00:00 2001 From: Gabriel Maia <gabrielmaia@protonmail.com> Date: Mon, 13 Jul 2020 14:25:01 -0300 Subject: [PATCH 06/16] Changed return in human species This PR is concerning some issues: Juriy#4 Juriy#5 --- resources/fixtures/species.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/resources/fixtures/species.json b/resources/fixtures/species.json index d96695c4..4402d8e6 100644 --- a/resources/fixtures/species.json +++ b/resources/fixtures/species.json @@ -8,10 +8,7 @@ "created": "2014-12-10T13:52:11.567Z", "eye_colors": "brown, blue, green, hazel, grey, amber", "people": [ - 66, - 67, - 68, - 74 + 1, 4, 5, 6, 7, 9, 10, 11, 12, 14, 18, 19, 21, 22, 25, 26, 28, 29, 32, 34, 35, 39, 42, 43, 51, 60, 61, 62, 66, 67, 68, 69, 74, 81, 82 ], "skin_colors": "caucasian, black, asian, hispanic", "language": "Galactic Basic", From 4cd584e5adc9fe050c2d6072b3b1097e806a8b8b Mon Sep 17 00:00:00 2001 From: lmat <dartme18@gmail.com> Date: Sat, 31 Oct 2020 09:47:45 -0400 Subject: [PATCH 07/16] Corrected typo --- swapi/templates/about.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swapi/templates/about.md b/swapi/templates/about.md index 5401b226..4f178e74 100644 --- a/swapi/templates/about.md +++ b/swapi/templates/about.md @@ -9,7 +9,7 @@ We've formatted this data in [**JSON**](https://json.org) and exposed it to you [Check out the documentation to get started consuming swapi data](/documentation) ## What happened to swapi.co? -Unfortulately swapi.co is not maintained anymore, and the service is currently down. This is an branch of SWAPI that will be supported going forward. +Unfortulately swapi.co is not maintained anymore, and the service is currently down. This is a branch of SWAPI that will be supported going forward. ## What can you use this for? From 04b116ea3cf7b9b2462027668dba14190b384fe9 Mon Sep 17 00:00:00 2001 From: Amit Choukroun <amit@mtrn.co.il> Date: Wed, 13 Jan 2021 09:22:58 +0200 Subject: [PATCH 08/16] chore: add typescript helper to the docs --- swapi/templates/docs.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/swapi/templates/docs.md b/swapi/templates/docs.md index a09390bf..aa9eb5f6 100644 --- a/swapi/templates/docs.md +++ b/swapi/templates/docs.md @@ -665,6 +665,11 @@ There are a bunch of helper libraries available for consuming the Star Wars API - [SWAPI-Wrapper](https://github.com/cfjedimaster/SWAPI-Wrapper) By [Raymond Camden](https://github.com/cfjedimaster). - [swapi-node](https://www.npmjs.com/package/swapi-node) by [Lucas Holmquist](https://github.com/lholmquist). +<a name="typescript"></a> +##Typescript + +- [swapi-ts](https://github.com/amitmtrn/swapi-ts) by [Amit Choukroun](https://github.com/amitmtrn) + <a name="android"></a> ##Android From 5b87ec5d3721158a44fcf63ab264c9dd42ee8e65 Mon Sep 17 00:00:00 2001 From: Sangam Kumar Shrestha <2shrestha22@gmail.com> Date: Sun, 31 Jan 2021 10:07:52 +0545 Subject: [PATCH 09/16] updated index.html for spell correction. --- swapi/templates/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/swapi/templates/index.html b/swapi/templates/index.html index db75440c..4cb5e9e6 100644 --- a/swapi/templates/index.html +++ b/swapi/templates/index.html @@ -84,8 +84,8 @@ <h4 class="center">How can I use it?</h4> </div> <div class="col-sm-3 col-lg-3 col-md-3"> <h4 class="center">What happened with old swapi.co?</h4> - <p>swapi.co is not supported and maintained anymode. But since so many projects and tutorials used it as their educational - playground, this is an "unofficial" branch</p> + <p>swapi.co is not supported and maintained anymore. But since so many projects and tutorials used it as their educational + playground, this is an "unofficial" branch.</p> <p>This project is open source and you can contribute <a href="https://github.com/Juriy/swapi">on GitHub</a>.</p> </div> <div class="col-sm-1 col-lg-1 col-md-1"> From 1e61de9ae04b63efc7aa37b20f6915e34cfe428c Mon Sep 17 00:00:00 2001 From: Bhavesh Sharma <34792643+iBhavesh@users.noreply.github.com> Date: Thu, 6 May 2021 02:22:06 +0530 Subject: [PATCH 10/16] Update wording in about.md --- swapi/templates/about.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swapi/templates/about.md b/swapi/templates/about.md index 5401b226..4f178e74 100644 --- a/swapi/templates/about.md +++ b/swapi/templates/about.md @@ -9,7 +9,7 @@ We've formatted this data in [**JSON**](https://json.org) and exposed it to you [Check out the documentation to get started consuming swapi data](/documentation) ## What happened to swapi.co? -Unfortulately swapi.co is not maintained anymore, and the service is currently down. This is an branch of SWAPI that will be supported going forward. +Unfortulately swapi.co is not maintained anymore, and the service is currently down. This is a branch of SWAPI that will be supported going forward. ## What can you use this for? From f9350736cb4f66032dfd10a9e5245a4acfdca05b Mon Sep 17 00:00:00 2001 From: Juriy Bura <juriy.bura@gmail.com> Date: Wed, 16 Jun 2021 16:28:59 +0200 Subject: [PATCH 11/16] Basic dockerization of swapi --- .gitignore | 1 + Dockerfile | 8 +++++++ requirements.txt | 4 ++-- run.sh | 8 +++++++ swapi-dev.yml | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 Dockerfile create mode 100755 run.sh create mode 100644 swapi-dev.yml diff --git a/.gitignore b/.gitignore index 8e1bef19..b90e6c56 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ staticfiles .env db.sqlite3 .DS_Store +.idea diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..b41f9f54 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +# syntax=docker/dockerfile:1 +FROM python:2 +ENV PYTHONUNBUFFERED=1 +RUN apt-get update && apt-get install -y libmemcached-dev +WORKDIR /code +COPY . /code/ +RUN pip install -r requirements.txt +CMD ["sh", "-c", "./run.sh"] diff --git a/requirements.txt b/requirements.txt index c389e7bd..8d690102 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,9 +16,9 @@ django-pylibmc==0.5.0 djangorestframework==3.0.0 drf-json-api==0.1.0 gunicorn==19.1.1 -keen==0.3.7 +keen==0.3.0 markdown2==2.3.0 -psycopg2==2.5.4 +psycopg2==2.7.3.2 pycrypto==2.6.1 pylibmc==1.4.1 requests==2.5.1 diff --git a/run.sh b/run.sh new file mode 100755 index 00000000..d2ec53f5 --- /dev/null +++ b/run.sh @@ -0,0 +1,8 @@ +#!/bin/sh +sleep 5 +# python manage.py createsuperuser +# python manage.py createsuperuser --noinput --username root --email info@swapi.dev + +python manage.py migrate +make load_data +python manage.py runserver 0.0.0.0:8000 diff --git a/swapi-dev.yml b/swapi-dev.yml new file mode 100644 index 00000000..309885a3 --- /dev/null +++ b/swapi-dev.yml @@ -0,0 +1,57 @@ +version: '3.8' + +services: + + # Database + db: + image: postgres:9.6 + restart: always + networks: + - db_net + ports: + - target: 5432 + published: 5432 + protocol: tcp + mode: host + environment: + POSTGRES_USER: myswapiuser + POSTGRES_PASSWORD: myswapipass + POSTGRES_DB: myswapi + + adminer: + image: adminer + restart: always + networks: + - db_net + ports: + - target: 8080 + published: 8080 + protocol: tcp + mode: host + environment: + ADMINER_DESIGN: mvt + ADMINER_DEFAULT_SERVER: db + + swapi-server: + image: swapi-test + restart: always + networks: + - db_net + ports: + - target: 8000 + published: 9090 + protocol: tcp + mode: host + environment: + DEBUG: "" + DATABASE_URL: postgres://myswapiuser:myswapipass@db/myswapi + depends_on: + - db + +networks: + db_net: + name: db_net + driver: overlay + ipam: + config: + - subnet: 172.74.3.0/24 \ No newline at end of file From d71cb4118fd7503b9971f5590acf6f421517b880 Mon Sep 17 00:00:00 2001 From: Juriy Bura <juriy.bura@gmail.com> Date: Wed, 16 Jun 2021 16:48:03 +0200 Subject: [PATCH 12/16] removed unused lines in run script --- run.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/run.sh b/run.sh index d2ec53f5..434d5af3 100755 --- a/run.sh +++ b/run.sh @@ -1,8 +1,4 @@ #!/bin/sh -sleep 5 -# python manage.py createsuperuser -# python manage.py createsuperuser --noinput --username root --email info@swapi.dev - python manage.py migrate make load_data python manage.py runserver 0.0.0.0:8000 From c48a8c54d5d430a1787749a79576b12ce12e8b61 Mon Sep 17 00:00:00 2001 From: Juriy Bura <juriy.bura@gmail.com> Date: Fri, 18 Jun 2021 09:28:05 +0200 Subject: [PATCH 13/16] updated formatting for fixtures json --- resources/fixtures/species.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/fixtures/species.json b/resources/fixtures/species.json index 4402d8e6..3a9e3f39 100644 --- a/resources/fixtures/species.json +++ b/resources/fixtures/species.json @@ -8,7 +8,11 @@ "created": "2014-12-10T13:52:11.567Z", "eye_colors": "brown, blue, green, hazel, grey, amber", "people": [ - 1, 4, 5, 6, 7, 9, 10, 11, 12, 14, 18, 19, 21, 22, 25, 26, 28, 29, 32, 34, 35, 39, 42, 43, 51, 60, 61, 62, 66, 67, 68, 69, 74, 81, 82 + 1, 4, 5, 6, 7, 9, 10, 11, 12, + 14, 18, 19, 21, 22, 25, 26, 28, + 29, 32, 34, 35, 39, 42, 43, 51, + 60, 61, 62, 66, 67, 68, 69, 74, + 81, 82 ], "skin_colors": "caucasian, black, asian, hispanic", "language": "Galactic Basic", From d9ca6cabb63434e187cd4ae5c8c8cfc5aff939cf Mon Sep 17 00:00:00 2001 From: Juriy Bura <juriy.bura@gmail.com> Date: Fri, 18 Jun 2021 09:28:59 +0200 Subject: [PATCH 14/16] Fixed a name for Beru Sunlight Lars --- resources/fixtures/people.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/fixtures/people.json b/resources/fixtures/people.json index b020814e..33bb3336 100644 --- a/resources/fixtures/people.json +++ b/resources/fixtures/people.json @@ -104,7 +104,7 @@ { "fields": { "edited": "2014-12-20T21:17:50.319Z", - "name": "Beru Whitesun lars", + "name": "Beru Whitesun Lars", "created": "2014-12-10T15:53:41.121Z", "gender": "female", "skin_color": "light", From a5cd732340451c38fd58c66e1caf2d9d2edaa4b8 Mon Sep 17 00:00:00 2001 From: Juriy Bura <juriy.bura@gmail.com> Date: Fri, 18 Jun 2021 09:54:50 +0200 Subject: [PATCH 15/16] Updated contribution instructions and minor code formatting --- CONTRIBUTING.md | 56 +++++++++++++++++++++-------------- resources/fixtures/films.json | 12 ++++---- swapi/static/css/custom.css | 2 +- 3 files changed, 40 insertions(+), 30 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 556ea8e9..301c8c38 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,34 +1,49 @@ ## Contributing -Make sure your contribution isn't already a planned feature or has already been fixed by checking the issues first. +Make sure your contribution isn't already a planned feature or has already +been fixed by checking the issues first. 1. Fork this project. -2. Find an issue to fix or create a new issue if you want to propose a feature. Generally speaking, everyone wants features. I'm only going to merge features that have 2 or more +1, otherwise this project will fill up with lots of random stuff. +2. Find an issue to fix or create a new issue if you want to propose a feature. For + the new features - check out on GitHub issues first before starting to code it. + +3. **No changes in the current API** are accepted. Even backward-compatible ones. + The only exception is extending database and fixing data issues. These are OK. For + all other changes - please submit a request and we'll review the feature for v2 of API. + Current version will remain the same for the sake of compatibility with all the + example code that API enthusiasts created. -3. Write your codez, make sure you add tests. Check out the "development" section below. +## Development -4. Submit a descriptive pull request that is *up to date with the master branch*. +An application was originally built with Python 2.7 and Django 1.x. This stack is outdated hence +continuing with this code base is not adviced. The next version of SWAPI will likely be +cloud native and serverless. -5. We'll accept it and add it to production! +If you insist, best use Docker for building and running the project (Dockerfile is included +in the root folder) +```shell +docker build -t myswapi . +docker run -p 8000:8000 myswapi +``` -## Development +The same image is available as `juriy/swapi` from DockerHub. -Once you have downloaded the project, look at the Makefile to see a list of useful shortcut commands. +# Django commands -In order to get started run: +The commands below are already executed in Docker image, if you need to work with Django +directly or from inside the docker image, the following commands may be useful -``` -make install -make build -make load_data -``` +```shell +# run DB migrations +python manage.py migrate -To run the server locally run: +# load data from fixtures +make load_data -``` -make serve +# run the server +python manage.py runserver 0.0.0.0:8000 ``` If you add new data then you can dump it out using the following command: @@ -43,15 +58,10 @@ To run tests: make test ``` -*NOTE:* pull requests will not be accepted if they do not pass tests or have no new tests for new features. - - ## File structure -- resources - +### /resources All API resource models, serializers and schemas are found here. -- swapi - +### /swapi All Django configuration, templates and static files are found here. diff --git a/resources/fixtures/films.json b/resources/fixtures/films.json index 60cb7188..4215f231 100644 --- a/resources/fixtures/films.json +++ b/resources/fixtures/films.json @@ -28,7 +28,7 @@ "created": "2014-12-10T14:23:31.880Z", "episode_id": 4, "director": "George Lucas", - "release_date": "1977-05-25", + "release_date": "1977-05-25", "opening_crawl": "It is a period of civil war.\r\nRebel spaceships, striking\r\nfrom a hidden base, have won\r\ntheir first victory against\r\nthe evil Galactic Empire.\r\n\r\nDuring the battle, Rebel\r\nspies managed to steal secret\r\nplans to the Empire's\r\nultimate weapon, the DEATH\r\nSTAR, an armored space\r\nstation with enough power\r\nto destroy an entire planet.\r\n\r\nPursued by the Empire's\r\nsinister agents, Princess\r\nLeia races home aboard her\r\nstarship, custodian of the\r\nstolen plans that can save her\r\npeople and restore\r\nfreedom to the galaxy....", "characters": [ 1, @@ -94,7 +94,7 @@ "created": "2014-12-12T11:26:24.656Z", "episode_id": 5, "director": "Irvin Kershner", - "release_date": "1980-05-17", + "release_date": "1980-05-17", "opening_crawl": "It is a dark time for the\r\nRebellion. Although the Death\r\nStar has been destroyed,\r\nImperial troops have driven the\r\nRebel forces from their hidden\r\nbase and pursued them across\r\nthe galaxy.\r\n\r\nEvading the dreaded Imperial\r\nStarfleet, a group of freedom\r\nfighters led by Luke Skywalker\r\nhas established a new secret\r\nbase on the remote ice world\r\nof Hoth.\r\n\r\nThe evil lord Darth Vader,\r\nobsessed with finding young\r\nSkywalker, has dispatched\r\nthousands of remote probes into\r\nthe far reaches of space....", "characters": [ 1, @@ -164,7 +164,7 @@ "created": "2014-12-18T10:39:33.255Z", "episode_id": 6, "director": "Richard Marquand", - "release_date": "1983-05-25", + "release_date": "1983-05-25", "opening_crawl": "Luke Skywalker has returned to\r\nhis home planet of Tatooine in\r\nan attempt to rescue his\r\nfriend Han Solo from the\r\nclutches of the vile gangster\r\nJabba the Hutt.\r\n\r\nLittle does Luke know that the\r\nGALACTIC EMPIRE has secretly\r\nbegun construction on a new\r\narmored space station even\r\nmore powerful than the first\r\ndreaded Death Star.\r\n\r\nWhen completed, this ultimate\r\nweapon will spell certain doom\r\nfor the small band of rebels\r\nstruggling to restore freedom\r\nto the galaxy...", "characters": [ 1, @@ -232,7 +232,7 @@ "created": "2014-12-19T16:52:55.740Z", "episode_id": 1, "director": "George Lucas", - "release_date": "1999-05-19", + "release_date": "1999-05-19", "opening_crawl": "Turmoil has engulfed the\r\nGalactic Republic. The taxation\r\nof trade routes to outlying star\r\nsystems is in dispute.\r\n\r\nHoping to resolve the matter\r\nwith a blockade of deadly\r\nbattleships, the greedy Trade\r\nFederation has stopped all\r\nshipping to the small planet\r\nof Naboo.\r\n\r\nWhile the Congress of the\r\nRepublic endlessly debates\r\nthis alarming chain of events,\r\nthe Supreme Chancellor has\r\nsecretly dispatched two Jedi\r\nKnights, the guardians of\r\npeace and justice in the\r\ngalaxy, to settle the conflict....", "characters": [ 2, @@ -335,7 +335,7 @@ "created": "2014-12-20T10:57:57.886Z", "episode_id": 2, "director": "George Lucas", - "release_date": "2002-05-16", + "release_date": "2002-05-16", "opening_crawl": "There is unrest in the Galactic\r\nSenate. Several thousand solar\r\nsystems have declared their\r\nintentions to leave the Republic.\r\n\r\nThis separatist movement,\r\nunder the leadership of the\r\nmysterious Count Dooku, has\r\nmade it difficult for the limited\r\nnumber of Jedi Knights to maintain \r\npeace and order in the galaxy.\r\n\r\nSenator Amidala, the former\r\nQueen of Naboo, is returning\r\nto the Galactic Senate to vote\r\non the critical issue of creating\r\nan ARMY OF THE REPUBLIC\r\nto assist the overwhelmed\r\nJedi....", "characters": [ 2, @@ -451,7 +451,7 @@ "created": "2014-12-20T18:49:38.403Z", "episode_id": 3, "director": "George Lucas", - "release_date": "2005-05-19", + "release_date": "2005-05-19", "opening_crawl": "War! The Republic is crumbling\r\nunder attacks by the ruthless\r\nSith Lord, Count Dooku.\r\nThere are heroes on both sides.\r\nEvil is everywhere.\r\n\r\nIn a stunning move, the\r\nfiendish droid leader, General\r\nGrievous, has swept into the\r\nRepublic capital and kidnapped\r\nChancellor Palpatine, leader of\r\nthe Galactic Senate.\r\n\r\nAs the Separatist Droid Army\r\nattempts to flee the besieged\r\ncapital with their valuable\r\nhostage, two Jedi Knights lead a\r\ndesperate mission to rescue the\r\ncaptive Chancellor....", "characters": [ 1, diff --git a/swapi/static/css/custom.css b/swapi/static/css/custom.css index 34f844d1..80fa2f48 100644 --- a/swapi/static/css/custom.css +++ b/swapi/static/css/custom.css @@ -16,5 +16,5 @@ } .subscribe_btn { - margin-left: -100px!; + margin-left: -100px; } From 5413ffe76ccd449fbcd9b2379b18a6c2a14ff1a5 Mon Sep 17 00:00:00 2001 From: Juriy Bura <juriy.bura@gmail.com> Date: Fri, 18 Jun 2021 09:58:49 +0200 Subject: [PATCH 16/16] Removed Docker Swarm config from master as it is WIP --- swapi-dev.yml | 57 --------------------------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 swapi-dev.yml diff --git a/swapi-dev.yml b/swapi-dev.yml deleted file mode 100644 index 309885a3..00000000 --- a/swapi-dev.yml +++ /dev/null @@ -1,57 +0,0 @@ -version: '3.8' - -services: - - # Database - db: - image: postgres:9.6 - restart: always - networks: - - db_net - ports: - - target: 5432 - published: 5432 - protocol: tcp - mode: host - environment: - POSTGRES_USER: myswapiuser - POSTGRES_PASSWORD: myswapipass - POSTGRES_DB: myswapi - - adminer: - image: adminer - restart: always - networks: - - db_net - ports: - - target: 8080 - published: 8080 - protocol: tcp - mode: host - environment: - ADMINER_DESIGN: mvt - ADMINER_DEFAULT_SERVER: db - - swapi-server: - image: swapi-test - restart: always - networks: - - db_net - ports: - - target: 8000 - published: 9090 - protocol: tcp - mode: host - environment: - DEBUG: "" - DATABASE_URL: postgres://myswapiuser:myswapipass@db/myswapi - depends_on: - - db - -networks: - db_net: - name: db_net - driver: overlay - ipam: - config: - - subnet: 172.74.3.0/24 \ No newline at end of file