Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrected a typo #156

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ staticfiles
.env
db.sqlite3
.DS_Store
.idea
56 changes: 33 additions & 23 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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.
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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!

4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions resources/fixtures/films.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion resources/fixtures/people.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 5 additions & 4 deletions resources/fixtures/species.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
"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",
Expand Down
4 changes: 4 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
python manage.py migrate
make load_data
python manage.py runserver 0.0.0.0:8000
2 changes: 1 addition & 1 deletion swapi/static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
}

.subscribe_btn {
margin-left: -100px!;
margin-left: -100px;
}
14 changes: 0 additions & 14 deletions swapi/templates/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,6 @@ <h4>Statistics</h4>
{% endmarkdown %}
</div>
<div class="col-sm-2 col-lg-2 col-md-2">
<h4>Donate</h4>
<p>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!</p>
<p><form action="/stripe/donation" method="POST">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="{{stripe_key}}"
data-image="http://i.imgur.com/PqkJzx4s.png"
data-name="swapi.co"
data-description="Donate and keep swapi alive!"
data-amount="1000"
data-panel-label="Donate">
</script>
</form></p>
<p>We truly appreciate your support</p>
</div>
</div>
{% endblock mainbody %}
18 changes: 10 additions & 8 deletions swapi/templates/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 a branch 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)
Expand Down Expand Up @@ -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?

Expand All @@ -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)
29 changes: 14 additions & 15 deletions swapi/templates/base.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<!-- Designed and built by Paul Hallett - http://phalt.co -->
<!-- Created by Paul Hallett - http://phalt.co Maintained by Juriy Bura - https://github.com/juriy -->
<head>
<meta charset="utf-8">
<title>
Expand All @@ -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>
Expand All @@ -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">
Expand All @@ -43,29 +50,21 @@
<div class="jumbotron">
<h1>SWAPI</h1>
<p class="lead">The Star Wars API</p>
<p class="lead"><a href="/about">(what happened to swapi.co?)</a></p>
</div>
</div>
{% block mainbody %}
{% 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">&copy; Paul Hallett <script type="text/javascript">
document.write(new Date().getFullYear());
</script></a>
Created by Paul Hallett
Maintained by Juriy Bura &copy;<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>
Expand Down
Loading