Skip to content

Instantly share code, notes, and snippets.

@ar-android
Created December 29, 2018 15:38
Show Gist options
  • Select an option

  • Save ar-android/b87bfb74f06dc1bfe909d483e64cb403 to your computer and use it in GitHub Desktop.

Select an option

Save ar-android/b87bfb74f06dc1bfe909d483e64cb403 to your computer and use it in GitHub Desktop.
<?php
require 'vendor/autoload.php';
require 'helpers.php';
Flight::route('/', function(){
if(isset($_GET['nerd'])){
echo home_url() . random_post();
die;
}
view('home');
});
Flight::route('/import', function(){
if(isset($_GET['nerd'])){
echo home_url() . random_post();
die;
}
view('import');
});
Flight::route('/pages/@page', function($page){
view('pages.page', ['page' => $page]);
});
Flight::route('/@slug.jpg', function($slug){
$data = get_data($slug);
return Flight::redirect(collect($data['images'])->random()['url']);
});
Flight::route('/@slug.html', function($slug){
$data = get_data($slug);
if($data === false){
return Flight::redirect(random_post());
}
$data['keyword'] = str_replace('-', ' ', $slug);
view('image', $data);
});
Flight::map('notFound', function(){
Flight::redirect('/');
});
Flight::start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment