From da5fb4440b03fce4e073b1a5501cc138545ee829 Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Sat, 18 Jun 2016 21:19:58 +0100 Subject: [PATCH] Translations & keep our public folder --- .gitignore | 1 - app/Http/Controllers/Admin/RequestLineBanController.php | 2 +- app/Http/Controllers/Auth/AuthController.php | 7 ++++--- app/Http/Controllers/DJ/DJSaysController.php | 6 +++--- app/Http/Controllers/DJ/RequestController.php | 4 ++-- app/Http/Controllers/DJ/TimetableController.php | 14 +++++++------- app/Http/Controllers/Event/TimetableController.php | 14 +++++++------- app/Http/Controllers/StatsController.php | 5 +---- app/Http/Middleware/Authenticate.php | 2 +- app/Models/Event.php | 1 + public/.gitignore | 4 ++++ public/.htaccess | 20 ++++++++++++++++++++ public/favicon.ico | 0 public/index.php | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public/robots.txt | 2 ++ public/web.config | 23 +++++++++++++++++++++++ resources/assets/js/push-notifications.js | 6 ++++++ 17 files changed, 140 insertions(+), 29 deletions(-) create mode 100644 public/.gitignore create mode 100644 public/.htaccess create mode 100644 public/favicon.ico create mode 100644 public/index.php create mode 100644 public/robots.txt create mode 100644 public/web.config diff --git a/.gitignore b/.gitignore index bbb56ff..0f66c59 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ /node_modules /public/storage /storage -/public Homestead.yaml Homestead.json .env diff --git a/app/Http/Controllers/Admin/RequestLineBanController.php b/app/Http/Controllers/Admin/RequestLineBanController.php index 13525ea..758a8b4 100644 --- a/app/Http/Controllers/Admin/RequestLineBanController.php +++ b/app/Http/Controllers/Admin/RequestLineBanController.php @@ -47,7 +47,7 @@ class RequestLineBanController extends Controller { return redirect()->route('dashboard::admin::request-ban')->with('msg', [ 'type' => 'success', - 'msg' => 'Successfully banned IP address from the request line.' + 'msg' => _('Successfully banned IP address from the request line.') ]); } diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 9e407ad..84523b6 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -43,16 +43,17 @@ class AuthController extends Controller case 'private-dj': // trying to subscribe to DJ push notifications. ensure they're a DJ. if (!auth()->user()->is(Group::RADIO_DJ, Group::GUEST_DJ)) { - abort(403, 'Unauthorized.'); + abort(403, _('Unauthorized.')); } break; default: // they're trying to subscribe to a channel we don't know about. don't let them do it. - abort(403, 'Unauthorized.'); + abort(403, _('Unauthorized.')); break; } - return Pusher::connection()->socket_auth($request->get('channel_name'), $request->get('socket_id')); + return response(Pusher::connection()->socket_auth($request->get('channel_name'), $request->get('socket_id'))) + ->header('Content-Type', 'application/json'); } } diff --git a/app/Http/Controllers/DJ/DJSaysController.php b/app/Http/Controllers/DJ/DJSaysController.php index 62b4c71..6a08b85 100644 --- a/app/Http/Controllers/DJ/DJSaysController.php +++ b/app/Http/Controllers/DJ/DJSaysController.php @@ -21,7 +21,7 @@ class DJSaysController extends Controller public function getForm() { $says = DJSays::remember(5)->orderBy('id', 'desc')->take(1)->first(); - return view('dj.dj-says', ['current' => $says ? e($says->msg) : 'Currently unset.']); + return view('dj.dj-says', ['current' => $says ? e($says->msg) : _('Currently unset.')]); } /** @@ -34,7 +34,7 @@ class DJSaysController extends Controller { $this->validate($request, [ 'msg' => 'required|string|max:200' - ], [], ['msg' => 'DJ Says']); + ], [], ['msg' => _('DJ Says')]); $says = new DJSays; $says->dj = auth()->user()->userid; @@ -59,7 +59,7 @@ class DJSaysController extends Controller if ($says) { return ['dj' => User::remember(30)->find($says->dj)->username, 'msg' => e($says->msg)]; } else { - return ['dj' => 'Unavailable', 'msg' => 'Currently unset.']; + return ['dj' => _('Unavailable'), 'msg' => _('Currently unset.')]; } } } diff --git a/app/Http/Controllers/DJ/RequestController.php b/app/Http/Controllers/DJ/RequestController.php index c533684..87c35ae 100644 --- a/app/Http/Controllers/DJ/RequestController.php +++ b/app/Http/Controllers/DJ/RequestController.php @@ -34,7 +34,7 @@ class RequestController extends Controller public function deleteRequest(int $id) { Request::findOrFail($id)->delete(); - return redirect()->back()->with('msg', ['type' => 'success', 'msg' => 'Successfully deleted request.']); + return redirect()->back()->with('msg', ['type' => 'success', 'msg' => _('Successfully deleted request.')]); } /** @@ -50,7 +50,7 @@ class RequestController extends Controller 'request' => 'required|string|max:500' ]); - if (RequestBan::where('ip', $request->ip())->count()) { + if (RequestBan::where('ip_address', $request->ip())->count()) { // This IP is banned from the request line. abort(403); } diff --git a/app/Http/Controllers/DJ/TimetableController.php b/app/Http/Controllers/DJ/TimetableController.php index 85635b8..114660b 100644 --- a/app/Http/Controllers/DJ/TimetableController.php +++ b/app/Http/Controllers/DJ/TimetableController.php @@ -138,13 +138,13 @@ class TimetableController extends Controller $week = Timetable::where('week', Carbon::now()->weekOfYear)->where('year', Carbon::now()->year)->get(); $timetable = [ - 0 => ['name' => 'Monday'], - 1 => ['name' => 'Tuesday'], - 2 => ['name' => 'Wednesday'], - 3 => ['name' => 'Thursday'], - 4 => ['name' => 'Friday'], - 5 => ['name' => 'Saturday'], - 6 => ['name' => 'Sunday'] + 0 => ['name' => _('Monday')], + 1 => ['name' => _('Tuesday')], + 2 => ['name' => _('Wednesday')], + 3 => ['name' => _('Thursday')], + 4 => ['name' => _('Friday')], + 5 => ['name' => _('Saturday')], + 6 => ['name' => _('Sunday')] ]; foreach ($week as $slot) { diff --git a/app/Http/Controllers/Event/TimetableController.php b/app/Http/Controllers/Event/TimetableController.php index 513c31e..7bf62e4 100644 --- a/app/Http/Controllers/Event/TimetableController.php +++ b/app/Http/Controllers/Event/TimetableController.php @@ -191,13 +191,13 @@ class TimetableController extends Controller ->get(); $timetable = [ - 0 => ['name' => 'Monday'], - 1 => ['name' => 'Tuesday'], - 2 => ['name' => 'Wednesday'], - 3 => ['name' => 'Thursday'], - 4 => ['name' => 'Friday'], - 5 => ['name' => 'Saturday'], - 6 => ['name' => 'Sunday'] + 0 => ['name' => _('Monday')], + 1 => ['name' => _('Tuesday')], + 2 => ['name' => _('Wednesday')], + 3 => ['name' => _('Thursday')], + 4 => ['name' => _('Friday')], + 5 => ['name' => _('Saturday')], + 6 => ['name' => _('Sunday')] ]; foreach ($week as $slot) { diff --git a/app/Http/Controllers/StatsController.php b/app/Http/Controllers/StatsController.php index 7e7fe5c..ed196a0 100644 --- a/app/Http/Controllers/StatsController.php +++ b/app/Http/Controllers/StatsController.php @@ -55,10 +55,7 @@ class StatsController extends Controller file_put_contents(storage_path('stats.json'), json_encode($ret)); } - return [ - 'dj' => $stats->dj, - 'song' => $stats->song - ]; + return $ret; } else { return json_decode(file_get_contents(storage_path('stats.json')), true); } diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index 09a4410..43c09c8 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -20,7 +20,7 @@ class Authenticate { if (Auth::guard($guard)->guest()) { if ($request->ajax() || $request->wantsJson()) { - return response('Unauthorized.', $request->is('auth/pusher') ? 403 : 401); + return response(_('Unauthorized.'), $request->is('auth/pusher') ? 403 : 401); } else { return redirect()->guest(route('auth::login')); } diff --git a/app/Models/Event.php b/app/Models/Event.php index ece17dc..31e1840 100644 --- a/app/Models/Event.php +++ b/app/Models/Event.php @@ -20,6 +20,7 @@ use Illuminate\Database\Query\Builder; * @property integer $hour * @property integer $event_type_id * @property integer $room_id + * @property boolean $approved * @property Carbon $created_at * @property Carbon $updated_at * @property string $deleted_at diff --git a/public/.gitignore b/public/.gitignore new file mode 100644 index 0000000..89056cb --- /dev/null +++ b/public/.gitignore @@ -0,0 +1,4 @@ +build/ +css/ +fonts/ +js/ diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 0000000..903f639 --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,20 @@ + + + Options -MultiViews + + + RewriteEngine On + + # Redirect Trailing Slashes If Not A Folder... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule ^(.*)/$ /$1 [L,R=301] + + # Handle Front Controller... + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^ index.php [L] + + # Handle Authorization Header + RewriteCond %{HTTP:Authorization} . + RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] + diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/public/favicon.ico diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..c582053 --- /dev/null +++ b/public/index.php @@ -0,0 +1,58 @@ + + */ + +/* +|-------------------------------------------------------------------------- +| Register The Auto Loader +|-------------------------------------------------------------------------- +| +| Composer provides a convenient, automatically generated class loader for +| our application. We just need to utilize it! We'll simply require it +| into the script here so that we don't have to worry about manual +| loading any of our classes later on. It feels nice to relax. +| +*/ + +require __DIR__.'/../bootstrap/autoload.php'; + +/* +|-------------------------------------------------------------------------- +| Turn On The Lights +|-------------------------------------------------------------------------- +| +| We need to illuminate PHP development, so let us turn on the lights. +| This bootstraps the framework and gets it ready for use, then it +| will load up this application so that we can run it and send +| the responses back to the browser and delight our users. +| +*/ + +$app = require_once __DIR__.'/../bootstrap/app.php'; + +/* +|-------------------------------------------------------------------------- +| Run The Application +|-------------------------------------------------------------------------- +| +| Once we have the application, we can handle the incoming request +| through the kernel, and send the associated response back to +| the client's browser allowing them to enjoy the creative +| and wonderful application we have prepared for them. +| +*/ + +$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); + +$response = $kernel->handle( + $request = Illuminate\Http\Request::capture() +); + +$response->send(); + +$kernel->terminate($request, $response); diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000..eb05362 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: diff --git a/public/web.config b/public/web.config new file mode 100644 index 0000000..624c176 --- /dev/null +++ b/public/web.config @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/assets/js/push-notifications.js b/resources/assets/js/push-notifications.js index 24252d7..d88a771 100644 --- a/resources/assets/js/push-notifications.js +++ b/resources/assets/js/push-notifications.js @@ -1,5 +1,11 @@ import Pusher from 'pusher-websocket-iso'; +Pusher.log = function (message) { + if (window.console && window.console.log) { + window.console.log(message); + } +}; + const bindPusher = () => { if (IS_DJ) { const pusher = new Pusher(PUSHER_APP_KEY, { -- libgit2 1.7.2