Skip to content

Commit 15f9ac2

Browse files
author
jasdeepkhalsa
committed
Added routes for hymn and page. Added a homepage and moved api version info to /about
1 parent 4ad6908 commit 15f9ac2

File tree

4 files changed

+52
-8
lines changed

4 files changed

+52
-8
lines changed

app/routes.php

+41-8
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,43 @@
1313
|
1414
*/
1515

16-
App::error(function(ModelNotFoundException $e)
16+
// General Routes
17+
18+
Route::get('/', function()
1719
{
18-
return Response::view('404', array(), 404);
20+
return View::make('index');
1921
});
2022

21-
App::missing(function($exception)
23+
Route::get('about', function()
2224
{
23-
return Response::view('404', array(), 404);
25+
return Response::json(Array('name'=>'GurbaniDB','version'=>'1.0.0'));
2426
});
2527

26-
Route::get('/', function()
28+
// App Routes
29+
30+
Route::get('scripture/page/{id?}', function($id = 1)
2731
{
28-
return Response::json(Array('name'=>'GurbaniDB','version'=>'1.0.0'));
32+
// Return the given page in the scripture, with translation and transliteration
33+
$data = Scripture::where('page', '=', $id)->get();
34+
35+
return Response::json($data);
2936
});
3037

31-
Route::get('random', function()
38+
Route::get('scripture/hymn/{id?}', function($id = 1)
3239
{
33-
$data = Scripture::find(800)->melody;
40+
// Return the given hymn in the scripture, with translation and transliteration
41+
$data = Scripture::where('hymn', '=', $id)->get();
42+
foreach($data as $hymn){
43+
$hymn['melody'] = json_decode((String)Scripture::find($hymn->id)->melody);
44+
$hymn['author'] = json_decode((String)Scripture::find($hymn->id)->author);
45+
$hymn['language'] = json_decode((String)Scripture::find($hymn->id)->language);
46+
}
3447
return Response::json($data);
3548
});
3649

3750
Route::get('scripture/{id?}', function($id = 1)
3851
{
52+
// Return the given line in the scripture
3953
$data = Scripture::where('id', '=', $id)->firstOrFail();
4054
$data['melody'] = json_decode((String)Scripture::find($id)->melody);
4155
$data['author'] = json_decode((String)Scripture::find($id)->author);
@@ -53,6 +67,13 @@
5367
return Response::json($data);
5468
});
5569

70+
Route::get('random', function()
71+
{
72+
// Returns a random hymn for the day
73+
// $data = Scripture::find(rand(0,60403));
74+
// return Response::json($data);
75+
});
76+
5677
Route::get('melody', function()
5778
{
5879
$data = Melody::all();
@@ -94,3 +115,15 @@
94115

95116
return Response::json($data);
96117
});
118+
119+
// Error Routes
120+
121+
App::error(function(ModelNotFoundException $e)
122+
{
123+
return Response::view('404', array(), 404);
124+
});
125+
126+
App::missing(function($exception)
127+
{
128+
return Response::view('404', array(), 404);
129+
});

app/views/index.blade.php

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>GurbaniDB</title>
5+
<link rel="stylesheet" href="css/style.css" />
6+
</head>
7+
<body>
8+
<p>Welcome to the GurbaniDB API</p>
9+
<script src="js/main.js"></script>
10+
</body>
11+
</html>

public/css/style.css

Whitespace-only changes.

public/js/main.js

Whitespace-only changes.

0 commit comments

Comments
 (0)