Migrated site to Slim v4 and supporting libraries; removed some old band info (namely removed Andrew and Zakk from the about page); added Grunt.js config for compiling SASS/CoffeeScript

This commit is contained in:
Gregory Ballantine 2023-05-12 23:34:43 -04:00
parent d071bdeba6
commit e34ec3b947
29 changed files with 3078 additions and 644 deletions

7
.gitignore vendored
View File

@ -15,6 +15,13 @@ mode.php
###################
# we don't need to sync these everywhere
vendor/
node_modules/
# Compiled CSS and JS #
#######################
# these will be compiled as needed
public/css/
public/js/
# Audio and video files #
#########################

65
Gruntfile.js Normal file
View File

@ -0,0 +1,65 @@
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dist: {
options: {
style: 'compressed'
},
files: [{
expand: true,
cwd: 'assets/styles',
src: ['**/*.sass'],
dest: 'public/css',
ext: '.css'
}]
}
},
coffee: {
options: {
sourceMap: true,
style: 'compressed'
},
files: {
expand: true,
flatten: true,
cwd: 'assets/coffee',
src: ['*.coffee'],
dest: 'public/js',
ext: '.js'
}
},
watch: {
css: {
files: ['assets/styles/**/*.sass'],
tasks: ['sass'],
options: {
atBegin: true,
spawn: false
}
},
js: {
files: ['assets/coffee/*.coffee'],
tasks: ['coffee'],
options: {
atBegin: true,
spawn: false
}
}
}
});
// Load plugins.
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-coffee');
grunt.loadNpmTasks('grunt-contrib-watch');
// Default task(s).
grunt.registerTask('default', ['sass', 'coffee']);
};

View File

@ -1,31 +0,0 @@
<?php
$authenticationCheck = function($required) use ($app) {
return function() use ($required, $app) {
if ((!$app->auth && $required) || ($app->auth && !$required)) {
if (!$app->auth && $required) {
$app->flash('global', 'Hey buddy, you need to sign in first!');
} else if ($app->auth && !$required) {
$app->flash('global', 'Woah there, why do you want to do that?');
}
$app->redirect($app->urlFor('home'));
}
};
};
$authenticated = function() use ($authenticationCheck) {
return $authenticationCheck(true);
};
$guest = function() use ($authenticationCheck) {
return $authenticationCheck(false);
};
$admin = function() use ($app) {
return function() use ($app) {
if (!$app->auth || !$app->auth->isAdmin()) {
$app->flash('global', 'You don\'t have permissions for that, man.');
$app->redirect($app->urlFor('home'));
}
};
};

View File

@ -1,15 +1,16 @@
<?php
// Main view routes
require 'routes/pages/index.php';
require 'routes/pages/about.php';
require 'routes/pages/contact.php';
require 'routes/pages/home.php';
require 'routes/pages/music.php';
require 'routes/pages/shows.php';
// index GET route - this page should welcome the user
$app->get('/', '\\Halftone\\Website\\Controllers\\HomeController:getIndex')->setName('home');
// API routes
require 'routes/apiv1/music.php';
// about GET route - display information about the band!
$app->get('/about', '\\Halftone\\Website\\Controllers\\HomeController:getAbout')->setName('about');
// Errors
require 'routes/errors/404.php';
// contact GET route - display the band's contact info
$app->get('/contact', '\\Halftone\\Website\\Controllers\\HomeController:getContact')->setName('contact');
// music routes group
$app->get('/music', '\\Halftone\\Website\\Controllers\\MusicController:getIndex')->setName('music.index');
// shows routes group
$app->get('/shows', '\\Halftone\\Website\\Controllers\\ShowsController:getIndex')->setName('shows.index');

View File

@ -1,16 +1,11 @@
<?php
// Slim deps
use Slim\Slim;
use DI\Container;
use Slim\Factory\AppFactory;
use Slim\Views\Twig;
use Slim\Views\TwigExtension;
use Slim\Views\TwigMiddleware;
// Config struff
use Noodlehaus\Config;
// Our dependencies
use Fieldprotocol\Music\Album;
use Fieldprotocol\Music\Song;
require __DIR__ . '/../vendor/autoload.php';
// Let's get this session started
session_cache_limiter(false);
@ -19,55 +14,18 @@ session_start();
// For now, display some errors
ini_set('display_errors', 'On');
// The app's root directory
define('INC_ROOT', dirname(__DIR__));
// Create new container object
$container = new Container();
// Set container to create App with on AppFactory
AppFactory::setContainer($container);
$app = AppFactory::create();
// Autoload our stuff >:D
require INC_ROOT . '/vendor/autoload.php';
// Time to create our app
$app = new Slim([
'mode' => trim(file_get_contents(INC_ROOT . '/mode.php')),
'view' => new Twig(),
'templates.path' => INC_ROOT . '/app/views'
]);
// Run some crap before the middleware
//$app->add(new BeforeMiddleware);
//$app->add(new CSRFMiddleware);
$app->configureMode($app->config('mode'), function() use ($app) {
$app->config = Config::load(INC_ROOT . "/app/config/{$app->mode}.php");
});
// Create Twig
$twig = Twig::create(__DIR__ . '/../views', ['cache' => false]);
// Add Twig-View Middleware
$app->add(TwigMiddleware::create($app, $twig));
// Database configs
require 'database.php';
// Filters
require 'filters.php';
//require 'database.php';
// Routes configs
require 'routes.php';
//$app->auth = false;
// Album singleton
$app->container->set('album', function() {
return new Album;
});
// Song singleton
$app->container->set('song', function() {
return new Song;
});
// Slappin' some hoes with our views
$view = $app->view();
$view->parserOptions = [
'debug' => $app->config->get('twig.debug')
];
$view->setTemplatesDirectory('../app/views');
$view->parserExtensions = [
new TwigExtension()
];
// Run Slim
$app->run();

3
bin/php-run.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
php -S localhost:8080 -t public public/index.php

23
composer.json Executable file → Normal file
View File

@ -1,15 +1,24 @@
{
"name": "halftone/website",
"description": "HalfTone website",
"type": "project",
"license": "BSD-2-Clause",
"autoload": {
"psr-4": {
"Fieldprotocol\\": "app/Fieldprotocol"
"Halftone\\Website\\": "src/"
}
},
"authors": [
{
"name": "Gregory Ballantine",
"email": "gballantine@metaunix.net"
}
],
"minimum-stability": "stable",
"require": {
"slim/slim": "^2.6",
"slim/views": "^0.1.3",
"twig/twig": "^1.18",
"illuminate/database": "^5.0",
"hassankhan/config": "^0.8.2",
"alexgarrett/violin": "^2.2"
"slim/slim": "^4.11",
"slim/psr7": "^1.6",
"slim/twig-view": "^3.3",
"php-di/php-di": "^7.0"
}
}

1590
composer.lock generated Executable file → Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

1741
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

30
package.json Normal file
View File

@ -0,0 +1,30 @@
{
"name": "halftone-website",
"version": "1.0.0",
"description": "HalfTone website",
"main": "index.js",
"scripts": {
"grunt": "grunt",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://git.metaunix.net/HalfTone/website.git"
},
"keywords": [
"halftone",
"music",
"website",
"rock"
],
"author": "Gregory Ballantine <gballantine@metaunix.net>",
"license": "BSD-2-Clause",
"devDependencies": {
"grunt": "^1.6.1",
"grunt-cli": "^1.4.3",
"grunt-contrib-coffee": "^2.1.0",
"grunt-contrib-sass": "^2.0.0",
"grunt-contrib-watch": "^1.1.0",
"sass": "^1.62.1"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 663 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 295 KiB

View File

@ -1,3 +1,23 @@
<?php
require '../app/start.php';
// if we're looking for static files in dev, return false so they can be served.
if (PHP_SAPI == 'cli-server') {
$url = parse_url($_SERVER['REQUEST_URI']);
$file = __DIR__ . $url['path'];
// check the file types, only serve standard files
if (preg_match('/\.(?:png|js|jpg|jpeg|gif|css)$/', $file)) {
// does the file exist? If so, return it
if (is_file($file))
return false;
// file does not exist. return a 404
header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
printf('"%s" does not exist', $_SERVER['REQUEST_URI']);
return false;
}
}
require_once __DIR__ . '/../app/start.php';
$app->run();

View File

@ -9,3 +9,5 @@
});
}).call(this);
//# sourceMappingURL=bit.js.map

View File

@ -4,3 +4,5 @@
});
}).call(this);
//# sourceMappingURL=main.js.map

View File

@ -0,0 +1,19 @@
<?php
namespace Halftone\Website\Controllers;
use Psr\Container\ContainerInterface;
class Controller {
protected $container;
public function __construct(ContainerInterface $container) {
$this->container = $container;
}
public function get(string $name) {
return $this->container->get($name);
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace Halftone\Website\Controllers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Views\Twig;
class HomeController extends Controller {
public function getIndex(Request $request, Response $response): Response {
$view = Twig::fromRequest($request);
return $view->render($response, 'pages/home.twig', []);
}
public function getAbout(Request $request, Response $response): Response {
$view = Twig::fromRequest($request);
return $view->render($response, 'pages/about.twig', []);
}
public function getContact(Request $request, Response $response): Response {
$view = Twig::fromRequest($request);
return $view->render($response, 'pages/contact.twig', []);
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace Halftone\Website\Controllers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Views\Twig;
class MusicController extends Controller {
public function getIndex(Request $request, Response $response): Response {
$view = Twig::fromRequest($request);
return $view->render($response, 'pages/music.twig', []);
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace Halftone\Website\Controllers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Views\Twig;
class ShowsController extends Controller {
public function getIndex(Request $request, Response $response): Response {
$view = Twig::fromRequest($request);
return $view->render($response, 'pages/shows.twig', []);
}
}

View File

@ -49,18 +49,6 @@
<a href="#"></a>
</div>
</section>
<section class="col-md-6 col-xs-12">
<div class="thumbnail shadow-1">
<img src="img/about/andrew.jpg" alt="Andrew Hall">
<div class="caption">
<h3>Andrew Hall</h3>
<hr />
<h4>Bass Guitar</h4>
<p>Ginger, enough said.</p>
</div>
<a href="#"></a>
</div>
</section>
<section class="col-md-6 col-xs-12">
<div class="thumbnail shadow-1">
<img src="img/about/greg.jpg" alt="Gregory Ballantine">
@ -73,17 +61,5 @@
<a href="#"></a>
</div>
</section>
<section class="col-md-6 col-xs-12">
<div class="thumbnail shadow-1">
<img src="img/about/zakk.jpg" alt="Zakk Vigneri">
<div class="caption">
<h3>Zakk Vigneri</h3>
<hr />
<h4>Lead guitar/Backing vocals</h4>
<p>The Amateur Hour champion!</p>
</div>
<a href="#"></a>
</div>
</section>
</div>
{% endblock %}

View File

@ -20,19 +20,19 @@
<div class="collapse navbar-collapse" id="navbar-collapse">
<ul class="nav navbar-nav">
<li class="nav_item">
<a href="{{ urlFor('home') }}">Home</a>
<a href="{{ url_for('home') }}">Home</a>
</li>
<li class="nav_item">
<a href="{{ urlFor('about') }}">About</a>
<a href="{{ url_for('about') }}">About</a>
</li>
<li class="nav_item">
<a href="{{ urlFor('shows') }}">Shows</a>
<a href="{{ url_for('shows.index') }}">Shows</a>
</li>
<li class="nav_item">
<a href="{{ urlFor('music') }}">Music</a>
<a href="{{ url_for('music.index') }}">Music</a>
</li>
<li class="nav_item">
<a href="{{ urlFor('contact') }}">Contact</a>
<a href="{{ url_for('contact') }}">Contact</a>
</li>
</ul>
</div>