Skip to content

Commit 8692933

Browse files
committed
finish release 0.3.0
2 parents 83bcedb + 8473f4b commit 8692933

File tree

260 files changed

+6926
-908
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

260 files changed

+6926
-908
lines changed

LICENSE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
MIT License
22

3-
Copyright (c) 2017 open Summer of code 2017
3+
Copyright (c) 2017 Open Knowledge Belgium
4+
Copyright (c) 2017 Digipolis Ghent
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy
67
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,47 @@
1-
# CODE9000
2-
Urban Data Birds: Providing a new haven for urban biodiversity.
1+
\#Code9000
2+
===================
3+
----------
4+
5+
\#Code9000 is a project in which Digipolis Ghent and the City of Ghent experiment with open data to create new open source proof-of-concepts. The project was developed by oSoc17. This organisation collaborates with students to create IT-related projects. Students get real cases to work on and move beyond the theoretical and we get new learnings and code to test and iterate upon.
6+
7+
<div align="center">
8+
<img src="https://raw.githubusercontent.com/oSoc17/code9000/develop/web-app/src/theme/crest.png" width=300px />
9+
</div>
10+
11+
For this project, we wanted to observe the common tern, a bird living near the "Houtdok" in Ghent. tbc
12+
#### Status
13+
<a href="https://travis-ci.org/oSoc17/code9000.svg?branch=master" >
14+
<img src="https://camo.githubusercontent.com/3700a6394b649fb2e3620c649ae29f8ccce97be8/68747470733a2f2f7472617669732d63692e6f72672f6f536f6331372f6f617369732d66726f6e74656e642e706e67" alt="Build Status" data-canonical-src="https://travis-ci.org/oSoc17/oasis-frontend.png" style="max-width:100%;">
15+
</a>
16+
17+
18+
#### Technologies
19+
##### API
20+
The API handles the pictures taken by the IoT-device. We use it to collect our pictures, save it and make it accessible for other services. Since we don't have another way of validating what creature triggered the infraredsensor, we are using a human voting system. Votes are send to the API, and when an image reaches a certain treshhold, the API will assume it's validated and send it forward.
21+
22+
The API is made in PHP, using the Laravel framework. We chose to include user accounts as it's the only way to know for sure one person can only vote once on a picture.
23+
24+
##### Webapplication
25+
To do the validation of our pictures, human validation looked like the best way (given the time we had). As a simple yes-maybe-no validation onepager seemed a little dull and unappealing, we tried to gamify it.
26+
27+
We made a ReactJS webapp where you can do all the account-related stuff like logging in or making an account. We made an voting page as well, and tried to implement fun features like scores, badges and a monthly leaderboard.
28+
29+
##### Hardware
30+
We developed an IoT-device which takes pictures of everything that moves and send it to the API. The IoT works asynchronously to simultaneous send the pictures to the API and take pictures of the birds.
31+
32+
The device consists of a Raspberry Pi A+, a Raspberry Pi Camera V2 and a PIR sensor. To keep it self-sustainable we use a solar panel and a battery while a 4G router takes care of the Internet connection.
33+
#### Contributers
34+
35+
##### Students
36+
- [Demian Dekoninck](https://github.com/DemianD)
37+
- [Diëgo De Wilde](https://github.com/diegodewilde)
38+
- [Dylan Van Assche](https://github.com/DylanVanAssche)
39+
- [Bert Commeine](https://github.com/BertCommeine)
40+
- [Cynthia Vanoirbeek](https://github.com/cynthiav11)
41+
42+
##### Coaches
43+
- [Miet Claes](https://miet.be)
44+
- [Xavier Bertels](https://mono.company)
45+
46+
#### MIT License
47+
This project is released as an open-source project under the <a href="https://github.com/oSoc17/code9000/blob/develop/LICENSE"> MIT License </a>

api/.env.example

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
APP_NAME=Laravel
1+
APP_NAME=birds.today
22
APP_ENV=local
33
APP_KEY=
44
APP_DEBUG=true
@@ -16,7 +16,7 @@ DB_PASSWORD=secret
1616
BROADCAST_DRIVER=log
1717
CACHE_DRIVER=file
1818
SESSION_DRIVER=file
19-
QUEUE_DRIVER=sync
19+
QUEUE_DRIVER=database
2020

2121
REDIS_HOST=127.0.0.1
2222
REDIS_PASSWORD=null
@@ -29,11 +29,35 @@ MAIL_USERNAME=null
2929
MAIL_PASSWORD=null
3030
MAIL_ENCRYPTION=null
3131

32+
MAILGUN_DOMAIN=
33+
MAILGUN_SECRET=
34+
35+
MAIL_FROM_ADDRESS=
36+
MAIL_FROM_NAME=
37+
3238
PUSHER_APP_ID=
3339
PUSHER_APP_KEY=
3440
PUSHER_APP_SECRET=
3541

42+
VALID_OBSERVATION_THRESHOLD=5
43+
UNVALID_OBSERVATION_THRESHOLD=-5
44+
45+
PASSWORD_RESET_MINUTES=30
46+
3647
DEPLOY_BRANCH_WEBHOOK=master
3748

3849
FACEBOOK_CLIENT_ID=
39-
FACEBOOK_CLIENT_SECRET=
50+
FACEBOOK_CLIENT_SECRET=
51+
FACEBOOK_PAGE_ID=
52+
FACEBOOK_PAGE_TOKEN=
53+
54+
TWITTER_CONSUMER_KEY=
55+
TWITTER_CONSUMER_SECRET=
56+
TWITTER_ACCESS_TOKEN=
57+
TWITTER_ACCESS_TOKEN_SECRET=
58+
59+
IMGUR_CLIENT_ID
60+
61+
DATAHUBGENT_API_URL=
62+
DATAHUBGENT_PUBLIC_HASH=
63+
DATAHUBGENT_PRIVATE_HASH=

api/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ Homestead.json
99
Homestead.yaml
1010
npm-debug.log
1111
.env
12+
/public/build

api/app/Events/ObservationIsValid.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace App\Events;
4+
5+
use App\Observation;
6+
use Illuminate\Queue\SerializesModels;
7+
8+
class ObservationIsValid
9+
{
10+
use SerializesModels;
11+
12+
/**
13+
* @var \App\Observation
14+
*/
15+
public $observation;
16+
17+
/**
18+
* Create a new event instance.
19+
*
20+
* @param \App\Observation $observation
21+
*/
22+
public function __construct(Observation $observation)
23+
{
24+
$this->observation = $observation;
25+
}
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace App\Events;
4+
5+
use App\Observation;
6+
use Illuminate\Queue\SerializesModels;
7+
8+
class ObservationUploadedToImgur
9+
{
10+
use SerializesModels;
11+
12+
/**
13+
* @var \App\Observation
14+
*/
15+
public $observation;
16+
17+
/**
18+
* Create a new event instance.
19+
*
20+
* @param \App\Observation $observation
21+
*/
22+
public function __construct(Observation $observation)
23+
{
24+
$this->observation = $observation;
25+
}
26+
}

api/app/Exceptions/Handler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function render($request, Exception $exception)
5454
if ($exception instanceof NotFoundHttpException && ! strpos($request->url(), '/api')) {
5555
Log::info('NotFoundHttpException, Route not found, serving index.html of build folder');
5656

57-
return new Response(File::get(public_path().'/build/index.html'), Response::HTTP_OK);
57+
return new Response(File::get(public_path().'/index.html'), Response::HTTP_OK);
5858
}
5959

6060
return parent::render($request, $exception);

api/app/Http/Controllers/Api/AuthController.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,20 @@
66
use Illuminate\Http\Request;
77
use Tymon\JWTAuth\Facades\JWTAuth;
88
use App\Http\Controllers\Controller;
9+
use App\Http\Requests\Api\UserLogin;
910
use App\Http\Requests\Api\UserRegistrationModel;
11+
use Tymon\JWTAuth\Exceptions\TokenBlacklistedException;
1012

1113
class AuthController extends Controller
1214
{
1315
/**
1416
* Authenticate the user and create a token.
1517
*
16-
* @param \Illuminate\Http\Request $request
18+
* @param $request
1719
*
1820
* @return \Illuminate\Http\JsonResponse
1921
*/
20-
public function auth(Request $request)
22+
public function auth(UserLogin $request)
2123
{
2224
$credentials = $request->only('email', 'password');
2325

@@ -49,10 +51,14 @@ public function me(Request $request)
4951
*/
5052
public function refresh()
5153
{
52-
$token = JWTAuth::getToken();
53-
$newToken = JWTAuth::refresh($token);
54+
try {
55+
$token = JWTAuth::getToken();
56+
$newToken = JWTAuth::refresh($token);
5457

55-
return response()->json(compact('newToken'));
58+
return response()->json(compact('newToken'));
59+
} catch (TokenBlacklistedException $exception) {
60+
return response()->json(['error' => 'token_blacklisted'], $exception->getStatusCode());
61+
}
5662
}
5763

5864
public function logout()
@@ -69,12 +75,14 @@ public function logout()
6975
*/
7076
public function register(UserRegistrationModel $request)
7177
{
72-
$account = [
78+
$user = User::create([
7379
'name' => $request->name,
7480
'email' => $request->email,
7581
'password' => bcrypt($request->password),
76-
];
82+
]);
7783

78-
User::create($account);
84+
$token = JWTAuth::fromUser($user);
85+
86+
return response()->json(compact('token'));
7987
}
8088
}

api/app/Http/Controllers/Api/AuthSocialiteController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function handleProviderCallback()
3333

3434
private function firstOrCreateUser($facebookUser)
3535
{
36-
return User::firstOrCreate(['email' => $facebookUser->email], ['name' => $facebookUser->name]);
36+
return User::updateOrCreate(['email' => $facebookUser->email], ['name' => $facebookUser->name, 'avatar_url' => $facebookUser->avatar]);
3737
}
3838

3939
private function firstOrCreateProvider($user, $facebookUser)

api/app/Http/Controllers/Api/GithubWebhookController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function deploy(Request $request)
1616

1717
abort_unless($ref === $payload->ref, 403);
1818

19-
$response = Artisan::call('deploy');
19+
Artisan::queue('deploy');
2020

2121
return response(['success' => true]);
2222
}

0 commit comments

Comments
 (0)