From 601b7173e832e6f44fea71c2388d6541626fbf56 Mon Sep 17 00:00:00 2001 From: Gregory Ballantine Date: Sat, 13 May 2023 00:09:46 -0400 Subject: [PATCH] Removed old code; moved code under app/ to src/ --- app/Fieldprotocol/Music/Album.php | 34 ---------------- app/Fieldprotocol/Music/Song.php | 22 ----------- app/Fieldprotocol/Music/StoreLink.php | 20 ---------- app/Fieldprotocol/User/User.php | 57 --------------------------- app/config/example.php | 35 ---------------- app/database.php | 18 --------- app/routes/apiv1/music.php | 38 ------------------ app/routes/errors/404.php | 5 --- app/routes/pages/about.php | 7 ---- app/routes/pages/contact.php | 7 ---- app/routes/pages/home.php | 7 ---- app/routes/pages/index.php | 7 ---- app/routes/pages/music.php | 16 -------- app/routes/pages/shows.php | 32 --------------- public/index.php | 2 +- {app => src}/routes.php | 0 {app => src}/start.php | 0 17 files changed, 1 insertion(+), 306 deletions(-) delete mode 100644 app/Fieldprotocol/Music/Album.php delete mode 100644 app/Fieldprotocol/Music/Song.php delete mode 100644 app/Fieldprotocol/Music/StoreLink.php delete mode 100755 app/Fieldprotocol/User/User.php delete mode 100644 app/config/example.php delete mode 100755 app/database.php delete mode 100644 app/routes/apiv1/music.php delete mode 100644 app/routes/errors/404.php delete mode 100755 app/routes/pages/about.php delete mode 100755 app/routes/pages/contact.php delete mode 100755 app/routes/pages/home.php delete mode 100644 app/routes/pages/index.php delete mode 100755 app/routes/pages/music.php delete mode 100755 app/routes/pages/shows.php rename {app => src}/routes.php (100%) rename {app => src}/start.php (100%) diff --git a/app/Fieldprotocol/Music/Album.php b/app/Fieldprotocol/Music/Album.php deleted file mode 100644 index 12f5bd8..0000000 --- a/app/Fieldprotocol/Music/Album.php +++ /dev/null @@ -1,34 +0,0 @@ -hasMany('Fieldprotocol\Music\Song'); - } - - public function links() { - return $this->hasMany('Fieldprotocol\Music\StoreLink', 'album_id'); - } - - public function releaseDate() { - return date('F j, Y', strtotime($this->release_date)); - } - - public function releaseYear() { - return date('Y', strtotime($this->release_date)); - } - -} diff --git a/app/Fieldprotocol/Music/Song.php b/app/Fieldprotocol/Music/Song.php deleted file mode 100644 index 94c678c..0000000 --- a/app/Fieldprotocol/Music/Song.php +++ /dev/null @@ -1,22 +0,0 @@ -belongsTo('Fieldprotocol\Music\Album'); - } - -} diff --git a/app/Fieldprotocol/Music/StoreLink.php b/app/Fieldprotocol/Music/StoreLink.php deleted file mode 100644 index fcce421..0000000 --- a/app/Fieldprotocol/Music/StoreLink.php +++ /dev/null @@ -1,20 +0,0 @@ -belongsTo('Fieldprotocol\Music\Album', 'album_id'); - } - -} diff --git a/app/Fieldprotocol/User/User.php b/app/Fieldprotocol/User/User.php deleted file mode 100755 index 67c1b35..0000000 --- a/app/Fieldprotocol/User/User.php +++ /dev/null @@ -1,57 +0,0 @@ -first_name || !$this->last_name) { - return null; - } - - return "{$this->first_name} {$this->last_name}"; - } - - public function getName() { - return $this->getFullName() ?: $this->username; - } - - public function getAvatarUrl($options = []) { - $size = isset($options['size']) ? $options['size'] : 45; - return 'http://www.gravatar.com/avatar/' . md5($this->email) . '?s=' . $size . '&d=identicon'; - } - - /*public function permissions() { - return $this->hasOne('Fieldprotocol\User\UserPermission', 'user_id'); - } - - public function hasPermission($permission) { - return (bool) $this->permissions->{$permission}; - } - - public function isAdmin() { - return $this->hasPermission('is_admin'); - } - - public function isEditor() { - return $this->hasPermission('is_editor'); - } - - public function isAuthor() { - return $this->hasPermission('is_author'); - }*/ - -} diff --git a/app/config/example.php b/app/config/example.php deleted file mode 100644 index 11f0d82..0000000 --- a/app/config/example.php +++ /dev/null @@ -1,35 +0,0 @@ - [ - 'url' => 'https://halftoneband.com', - 'hash' => [ - 'algo' => PASSWORD_BCRYPT, - 'cost' => 10, - ], - ], - - 'db' => [ - 'driver' => 'mysql', - 'host' => 'db.example.com', - 'name' => 'db_name', - 'username' => 'db_user', - 'password' => 'db_secret', - 'charset' => 'utf8', - 'collation' => 'utf8_unicode_ci', - 'prefix' => '', - ], - - 'auth' => [ - 'session' => 'user_id', - 'remember' => 'user_r', - ], - - 'twig' => [ - 'debug' => true, - ], - - 'csrf' => [ - 'key' => 'csrf_token', - ], -]; diff --git a/app/database.php b/app/database.php deleted file mode 100755 index f961e14..0000000 --- a/app/database.php +++ /dev/null @@ -1,18 +0,0 @@ -addConnection([ - 'driver' => $app->config->get('db.driver'), - 'host' => $app->config->get('db.host'), - 'database' => $app->config->get('db.name'), - 'username' => $app->config->get('db.username'), - 'password' => $app->config->get('db.password'), - 'charset' => $app->config->get('db.charset'), - 'collation' => $app->config->get('db.collation'), - 'prefix' => $app->config->get('db.prefix'), -]); - -$capsule->bootEloquent(); diff --git a/app/routes/apiv1/music.php b/app/routes/apiv1/music.php deleted file mode 100644 index 4b45590..0000000 --- a/app/routes/apiv1/music.php +++ /dev/null @@ -1,38 +0,0 @@ -get('/apiv1/music/album-info/:albumid', function($albumid) use($app) { - - if (!ctype_digit($albumid)) { - echo 'Don\'t do that'; - return; - } - - $album = $app->album->where('id', $albumid)->first(); - - if ($album) { - echo json_encode($album); - } else { - $app->notFound(); - } - -})->name('apiv1.music.album-info'); - -// retrieve an album's songs -$app->get('/apiv1/music/album-songs/:albumid', function($albumid) use($app) { - - if (!ctype_digit($albumid)) { - echo 'Don\'t do that'; - return; - } - - $album = $app->album->where('id', $albumid)->first(); - - if ($album) { - $json = ['songs' => $album->songs]; - echo json_encode($json); - } else { - $app->notFound(); - } - -})->name('apiv1.music.album-songs'); diff --git a/app/routes/errors/404.php b/app/routes/errors/404.php deleted file mode 100644 index de40286..0000000 --- a/app/routes/errors/404.php +++ /dev/null @@ -1,5 +0,0 @@ -notFound(function() use ($app) { - $app->render('errors/404.twig'); -}); diff --git a/app/routes/pages/about.php b/app/routes/pages/about.php deleted file mode 100755 index fdad5dc..0000000 --- a/app/routes/pages/about.php +++ /dev/null @@ -1,7 +0,0 @@ -get('/about', function() use($app) { - - $app->render('pages/about.twig'); - -})->name('about'); diff --git a/app/routes/pages/contact.php b/app/routes/pages/contact.php deleted file mode 100755 index 931f4a6..0000000 --- a/app/routes/pages/contact.php +++ /dev/null @@ -1,7 +0,0 @@ -get('/contact', function() use($app) { - - $app->render('pages/contact.twig'); - -})->name('contact'); diff --git a/app/routes/pages/home.php b/app/routes/pages/home.php deleted file mode 100755 index d55a9e0..0000000 --- a/app/routes/pages/home.php +++ /dev/null @@ -1,7 +0,0 @@ -get('/home', function() use($app) { - - $app->render('pages/home.twig'); - -})->name('home'); diff --git a/app/routes/pages/index.php b/app/routes/pages/index.php deleted file mode 100644 index 5a562fb..0000000 --- a/app/routes/pages/index.php +++ /dev/null @@ -1,7 +0,0 @@ -get('/', function() use($app) { - - $app->response->redirect($app->urlFor('home'), '303'); - -})->name('index'); diff --git a/app/routes/pages/music.php b/app/routes/pages/music.php deleted file mode 100755 index f64ba0d..0000000 --- a/app/routes/pages/music.php +++ /dev/null @@ -1,16 +0,0 @@ -get('/music', function() use($app) { - - $albums = $app->album->all()->sortByDesc('release_date')->values()->all(); - $songs = $albums[0]->songs; - $links = $albums[0]->links; - - $app->render('pages/music.twig', [ - 'albums' => $albums, - 'songs' => $songs, - 'links' => $links, - ]); - -})->name('music'); diff --git a/app/routes/pages/shows.php b/app/routes/pages/shows.php deleted file mode 100755 index 32863e3..0000000 --- a/app/routes/pages/shows.php +++ /dev/null @@ -1,32 +0,0 @@ -get('/shows', function() use($app) { - - $shows = json_decode(file_get_contents('http://api.bandsintown.com/artists/HALFtone/events.json?api_version=2.0&app_id=shows_halftoneband.com')); - - foreach ($shows as $show) { - $show->date = date('M dS', strtotime($show->datetime)); - $show->day = date('D', strtotime($show->datetime)); - $show->time = date('H:i', strtotime($show->datetime)); - } - - $app->render('pages/shows.twig', [ - 'shows' => $shows, - ]); - -})->name('shows'); - -$app->get('/shows/json', function() use($app) { - - $shows = json_decode(file_get_contents('http://api.bandsintown.com/artists/HALFtone/events.json?api_version=2.0&app_id=shows_halftoneband.com')); - - foreach ($shows as $show) { - $show->date = date('M dS', strtotime($show->datetime)); - $show->day = date('D', strtotime($show->datetime)); - $show->time = date('H:i', strtotime($show->datetime)); - print_r($show); - echo '

'; - } - die(); - -})->name('shows.json'); diff --git a/public/index.php b/public/index.php index afe4034..63ab897 100755 --- a/public/index.php +++ b/public/index.php @@ -18,6 +18,6 @@ if (PHP_SAPI == 'cli-server') { } } -require_once __DIR__ . '/../app/start.php'; +require_once __DIR__ . '/../src/start.php'; $app->run(); diff --git a/app/routes.php b/src/routes.php similarity index 100% rename from app/routes.php rename to src/routes.php diff --git a/app/start.php b/src/start.php similarity index 100% rename from app/start.php rename to src/start.php