Permalink
Browse files

Added all the stuff that was not committed

I think it's search API, some fixes to themes and some new themes
  • Loading branch information...
1 parent 85427ab commit 2a448d66e56a51165c06ade1da7ee00041e6cead Vin committed Apr 8, 2016
@@ -7,13 +7,17 @@ class API extends Controller {
use HanyuuTrait;
use DjImageTrait;
use SongTrait;
+ use SearchTrait;
+ use RequestTrait;
protected $limit;
protected $offset = 0;
protected $routes = ["tracks", "djs", "faves", "can-request", "request", "metadata", "dj-image", "song"];
public function __construct() {
$this->limit = Config::get("radio.api.limit", 25);
+// $this->beforeFilter('csrf', ["on" => "postRequest"]);
+ $this->setupClient();
}
/**
@@ -127,4 +131,27 @@ public function getUserCooldown() {
return Response::json($response);
}
+
+ public function getSearch($query) {
+ $limit = Input::get('limit', 20);
+ $raw = $this->search($query ?: "", "track", "song-database", true);
+ $total = $raw["hits"]["total"];
+ $res = [];
+ $start = (Paginator::getCurrentPage() - 1) * $limit;
+ $raw = array_slice($raw["hits"]["hits"], $start, $limit);
+ for ($i = 0; $i < count($raw); $i++) {
+ $x = $raw[$i]["_source"];
+ $res[] = [
+ "artist" => $x["artist"],
+ "title" => $x["title"],
+ "id" => $x["id"],
+ "lastplayed" => $x["lastplayed"],
+ "lastrequested" => $x["lastrequested"],
+ "requestable" => requestable($x["lastrequested"], $x["requests"]),
+// "token" => base64url_encode(daypass_crypt(hex2bin(substr($x["hash"], 0, 20))))
+ ];
+ }
+ $pag = Paginator::make($res, $total, $limit);
+ return Response::json($pag);
+ }
}
View
@@ -78,4 +78,16 @@
{
throw new Illuminate\Session\TokenMismatchException;
}
-});
+});
+
+Route::filter('req_api_csrf', function()
+{
+throw new Exception;
+ $s = Track::find(Route::input('id'));
+ if($s) {
+ if(substr($s->hash, 0, 20) != base64url_decode(daypass_crypt(bin2hex(Input::get('_token'))))) {
+ throw new Illuminate\Session\TokenMismatchException;
+ }
+ }
+});
+
@@ -9,7 +9,7 @@
"faves" => "Favourites",
"stats" => "Stats",
"submit" => "Submit",
- "irc" => "IRC",
+ "irc" => "Chat",
"search" => "Search",
"request" => "Request",
"graphs" => "Graphs & Metrics",
@@ -79,7 +79,7 @@ public function putUsers($id) {
$status = "User {$user->user} updated.";
$user->save();
} catch (Exception $e) {
- $status = $e->getMessage();
+ $status = $e->__toString();
}
}
@@ -169,11 +169,10 @@ protected function updateProfile($user) {
return;
}
- $dj = Dj::create([
- "djname" => $name,
- "djtext" => "x",
- "djimage" => "x",
- ]);
+ $dj = new Dj;
+ $dj->djname = $name;
+ $dj->djtext = "x";
+ $dj->djimage = "x";
$dj->save();
$user->djid = $dj->id;
$user->save();
@@ -48,6 +48,10 @@ public function search($terms, $type, $index, $usable_only = true) {
"query" => $terms,
]
],
+ "sort" => [
+ ["requests" => ["order" => "desc", "ignore_unmapped" => true]],
+ ["_score" => ["order" => "desc"]]
+ ],
],
];
@@ -2,8 +2,10 @@
trait SongTrait {
- public function getSong($b64) {
+ public function getSong($b64="") {
// this will probably throw an exception on anything strange
+ if($b64 === "")
+ App::abort(404);
$decoded = base64url_decode($b64);
$hash = bin2hex(daypass_crypt($decoded));
// return $hash;
@@ -46,9 +46,9 @@ class="dropdown"
</li>
@endif
- <li @if (Request::segment(2) == "djs") class="active" @endif>
+ <!-- <li @if (Request::segment(2) == "djs") class="active" @endif>
<a href="/admin/djs">DJs</a>
- <li>
+ <li> -->
@if (Auth::user()->isDev())
<li @if (Request::segment(2) == "dev") class="active" @endif>
@@ -68,9 +68,9 @@ class="dropdown"
<a href="/admin/profile" class="dropdown-toggle" data-toggle="dropdown">Profile <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="/admin/profile">Edit Profile</a></li>
- @if (Auth::user()->isDJ())
+ <!-- @if (Auth::user()->isDJ())
<li><a href="/admin/profile#dj">DJ Profile</a></li>
- @endif
+ @endif -->
<li><a href="/admin/profile#password">Change Password</a></li>
<li><a href="/logout">Log Out</a></li>
</ul>
@@ -376,4 +376,4 @@ function loop() {
}
</script>
-<script>init('Div1');</script>
+<!-- <script>init('Div1');</script> -->
@@ -15,10 +15,12 @@
<li><a href="/set-theme/-1">Use DJ Theme</a></li>
@endif
@foreach ($themes as $t)
- @if ($t->name === $cur_theme)
- <li class="active"><a href="/set-theme/{{ $t->id }}">{{{ $t->display_name }}}</a></li>
- @else
- <li><a href="/set-theme/{{ $t->id }}">{{{ $t->display_name }}}</a></li>
+ @if ($t->display_name != "")
+ @if ($t->name === $cur_theme)
+ <li class="active"><a href="/set-theme/{{ $t->id }}">{{{ $t->display_name }}}</a></li>
+ @else
+ <li><a href="/set-theme/{{ $t->id }}">{{{ $t->display_name }}}</a></li>
+ @endif
@endif
@endforeach
<li class="divider"></li>
@@ -0,0 +1,190 @@
+body {
+ background: url("/images/halloween/halloween.png") center no-repeat;
+ background-origin: padding-box;
+ background-position: center top;
+ background-repeat: no-repeat;
+ background-size: cover;
+ min-height: 100%;
+ background-attachment: fixed;
+ background-clip: border-box;
+ background-color: #440088;
+}
+
+.divider {
+ border: 1px solid #000;
+}
+
+.row {
+ margin: 0px;
+}
+
+.footer {
+ display: none;
+}
+
+.container {
+ margin-left: 0px;
+ padding: 0px;
+}
+
+.top-content {
+ margin-left: 15px;
+}
+
+.middle-content {
+ margin-left: 15px;
+}
+
+.btn-default {
+ background-color: rgba(0, 0, 0, 0);
+ color: rgba(255, 255, 255, 0.43);
+ border: none;
+}
+
+.btn-default:hover {
+ background-color: rgba(255, 255, 255, 0.1);
+ color: rgba(255, 255, 255, 0.43);
+ border: none;
+}
+
+.well, .form-control {
+ background-color: transparent;
+ border: none;
+}
+
+.panel, .list-group-item, #dj-mode, #dj-mode a {
+ background-color: rgba(0, 0, 0, 0.75);
+ border: none;
+ color: rgba(255, 255, 255, 0.43);
+}
+
+.navbar {
+ background-color: rgba(0, 0, 0, 0.75);
+ border: none;
+ color: rgba(255, 255, 255, 0.43);
+ padding-left: 25px;
+}
+
+.navbar-right {
+ float: none !important;;
+}
+
+.panel-default > .panel-heading, .panel-default > .panel-heading a {
+ background-color: rgba(0, 0, 0, 0.25);
+ border: none;
+ color: rgba(255, 255, 255, 0.43);
+}
+
+h1, h2, h3 {
+ color: rgba(255, 255, 255, 0.50);
+}
+
+.thumbnail {
+ background: none;
+ border: none;
+ color: rgba(255, 255, 255, 0.6)
+}
+
+.top-content {
+ background-color: rgba(0, 0, 0, 0.75);
+ border-radius: 6px;
+ border: none;
+ color: rgba(255, 255, 255, 0.43);
+ padding-top: 25px;
+}
+
+.progress {
+ background-color: rgba(255, 255, 255, 0.25);
+}
+
+.progress-bar {
+ background-color: rgba(253, 83, 69, 0.5);
+}
+
+.btn-primary, .btn-info {
+ background-color: rgba(253, 83, 69, 0.75);
+ border: none;
+}
+
+.btn-primary:hover {
+ background-color: rgba(253, 83, 69, 0.45);
+ border: none;
+}
+
+.dropdown-menu {
+ background-color: rgba(0, 0, 0, 0.9);
+ border: none;
+}
+
+.dropdown-menu li a {
+ color: #FFF;
+}
+
+.dropdown-menu li a:hover {
+ background-color: rgba(255, 255, 255, 0.15);
+ color: #FFF;
+
+}
+
+.dropdown-menu > .active > a, .dropdown-menu > .active > a:hover, .dropdown-menu > .active > a:focus {
+ background-color: rgba(253, 83, 69, 0.45) !important;
+}
+
+.modal-content {
+ background-color: rgba(0, 0, 0, 0.95);
+ border: none;
+ color: rgba(255, 255, 255, 0.43);
+}
+
+.disable {
+ background-color: rgba(0, 0, 0, 0.75);
+ border: none;
+ color: rgba(255, 255, 255, 0.43);
+ border-radius: 5px;
+}
+
+.disable {
+ margin-left: 15px;
+ margin-bottom: 15px;
+}
+
+hr {
+ border: none;
+}
+
+.pagination > .disabled > span, .pagination > .disabled > span:hover, .pagination > .disabled > span:focus, .pagination > .disabled > a, .pagination > .disabled > a:hover, .pagination > .disabled > a:focus {
+ background-color: rgba(0, 0, 0, 0.25);
+ border: none;
+ color: rgba(255, 255, 255, 0.43);
+}
+
+.pagination > .active > a, .pagination > .active > span, .pagination > .active > a:hover, .pagination > .active > span:hover, .pagination > .active > a:focus, .pagination > .active > span:focus {
+ background-color: rgba(0, 0, 0, 0.25);
+ border: none;
+ color: rgba(255, 255, 255, 0.43);
+}
+
+.pagination > li > a, .pagination > li > span {
+ background-color: rgba(0, 0, 0, 0.25);
+ border: none;
+ color: rgba(255, 255, 255, 0.43);
+}
+
+.container.main.content {
+ background-color: rgba(0, 0, 0, 0.75);
+ border: none;
+ color: rgba(255, 255, 255, 0.43);
+ border-radius: 6px;
+ margin-left: 15px;
+ margin-bottom: 15px;
+ padding: 15px;
+}
+
+.alert-success {
+ background-color: rgba(0, 0, 0, 0);
+ border: none;
+}
+
+.request-button {
+ width: 90%;
+}
Oops, something went wrong.

0 comments on commit 2a448d6

Please sign in to comment.