From 495b8efdeb04f621737962c99ff8cff2810e5a98 Mon Sep 17 00:00:00 2001 From: Maximilian Gass Date: Tue, 6 Sep 2011 21:37:54 +0200 Subject: [PATCH] Replace with Mojolicious version --- MANIFEST | 18 --- MANIFEST.SKIP | 13 -- Makefile.PL | 21 --- bin/app.pl | 9 -- config.yml | 9 -- environments/development.yml | 27 ---- environments/production.yml | 17 --- genres.yml | 168 --------------------- gg.pl | 285 +++++++++++++++++++++++++++++++++++ lib/App/Genregenerator.pm | 28 ---- public/404.html | 18 --- public/500.html | 18 --- public/css/error.css | 70 --------- public/css/style.css | 37 ----- public/dispatch.cgi | 15 -- public/dispatch.fcgi | 17 --- public/javascripts/jquery.js | 1 - t/001_base.t | 5 - t/002_index_route.t | 10 -- views/index.tt | 28 ---- 20 files changed, 285 insertions(+), 529 deletions(-) delete mode 100644 MANIFEST delete mode 100644 MANIFEST.SKIP delete mode 100644 Makefile.PL delete mode 100755 bin/app.pl delete mode 100644 config.yml delete mode 100644 environments/development.yml delete mode 100644 environments/production.yml delete mode 100644 genres.yml create mode 100755 gg.pl delete mode 100644 lib/App/Genregenerator.pm delete mode 100644 public/404.html delete mode 100644 public/500.html delete mode 100644 public/css/error.css delete mode 100644 public/css/style.css delete mode 100755 public/dispatch.cgi delete mode 100755 public/dispatch.fcgi delete mode 120000 public/javascripts/jquery.js delete mode 100644 t/001_base.t delete mode 100644 t/002_index_route.t delete mode 100644 views/index.tt diff --git a/MANIFEST b/MANIFEST deleted file mode 100644 index 012488e..0000000 --- a/MANIFEST +++ /dev/null @@ -1,18 +0,0 @@ -MANIFEST -bin/app.pl -config.yml -environments/development.yml -environments/production.yml -views/index.tt -MANIFEST.SKIP -lib/App/Genregenerator.pm -public/css/style.css -public/css/error.css -public/404.html -public/dispatch.fcgi -public/javascripts/jquery.js -public/dispatch.cgi -public/500.html -t/002_index_route.t -t/001_base.t -Makefile.PL diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP deleted file mode 100644 index 8fd3d29..0000000 --- a/MANIFEST.SKIP +++ /dev/null @@ -1,13 +0,0 @@ -^\.git\/ -maint -^tags$ -.last_cover_stats -Makefile$ -^blib -^pm_to_blib -^.*.bak -^.*.old -^t.*sessions -^cover_db -^.*\.log -^.*\.swp$ diff --git a/Makefile.PL b/Makefile.PL deleted file mode 100644 index 65daf72..0000000 --- a/Makefile.PL +++ /dev/null @@ -1,21 +0,0 @@ -use strict; -use warnings; -use ExtUtils::MakeMaker; - -WriteMakefile( - NAME => 'genregenerator', - AUTHOR => q{YOUR NAME }, - VERSION_FROM => 'lib/App/Genregenerator.pm', - ABSTRACT => 'YOUR APPLICATION ABSTRACT', - ($ExtUtils::MakeMaker::VERSION >= 6.3002 - ? ('LICENSE'=> 'perl') - : ()), - PL_FILES => {}, - PREREQ_PM => { - 'Test::More' => 0, - 'YAML' => 0, - 'Dancer' => 1.3060, - }, - dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, - clean => { FILES => 'genregenerator-*' }, -); diff --git a/bin/app.pl b/bin/app.pl deleted file mode 100755 index b0ea287..0000000 --- a/bin/app.pl +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env perl -use Dancer; -use autodie qw(chdir); -use Cwd qw(abs_path); - -chdir abs_path(dirname(__FILE__) . '/..'); -require App::Genregenerator; - -dance; diff --git a/config.yml b/config.yml deleted file mode 100644 index b8e808c..0000000 --- a/config.yml +++ /dev/null @@ -1,9 +0,0 @@ -# Your application's name -appname: "genregenerator" - -# when the charset is set to UTF-8 Dancer will handle for you -# all the magic of encoding and decoding. You should not care -# about unicode within your app when this setting is set (recommended). -charset: "UTF-8" - -template: "simple" diff --git a/environments/development.yml b/environments/development.yml deleted file mode 100644 index bf9f228..0000000 --- a/environments/development.yml +++ /dev/null @@ -1,27 +0,0 @@ -# configuration file for development environment - -# the logger engine to use -# console: log messages to STDOUT (your console where you started the -# application server) -# file: log message to a file in log/ -logger: "console" - -# the log level for this environement -# core is the lowest, it shows Dancer's core log messages as well as yours -# (debug, warning and error) -log: "core" - -# should Dancer consider warnings as critical errors? -warnings: 1 - -# should Dancer show a stacktrace when an error is caught? -show_errors: 1 - -# auto_reload is a development and experimental feature -# you should enable it by yourself if you want it -# Module::Refresh is needed -# -# Be aware it's unstable and may cause a memory leak. -# DO NOT EVER USE THAT FEATURE IN PRODUCTION -# OR TINY KITTENS SHALL DIE WITH LOTS OF SUFFERING -auto_reload: 0 diff --git a/environments/production.yml b/environments/production.yml deleted file mode 100644 index 629973f..0000000 --- a/environments/production.yml +++ /dev/null @@ -1,17 +0,0 @@ -# configuration file for production environment - -# only log warning and error messsages -log: "warning" - -# log message to a file in logs/ -logger: "null" - -# don't consider warnings critical -warnings: 0 - -# hide errors -show_errors: 0 - -# cache route resolution for maximum performance -route_cache: 1 - diff --git a/genres.yml b/genres.yml deleted file mode 100644 index ede79ea..0000000 --- a/genres.yml +++ /dev/null @@ -1,168 +0,0 @@ -cities: -- Berlin -- Bakersfield -- Detroit -- Frankfurt -- Gothenburg -- Ibiza -- London -- New Orleans -- Rio -- Rotterdam -- San Francisco -group: -- Aggrotech -- Ambient -- Beat -- Bluegrass -- Blues -- Chiptune -- Core -- Country -- Cumbia -- Dance -- Dancehall -- Drum and Bass -- Dub -- Dubstep -- EBM -- Flamenco -- Grunge -- Goa -- Gospel -- Hardstyle -- Hip-hop -- House -- Humppa -- Industrial -- Jazz -- Metal -- Oi! -- Polka -- Pop -- Punk -- Rap -- Rave -- Reggae -- Rockabilly -- Samba -- Schranz -- Ska -- Soul -- Techhouse -- Techno -- Tekkno -- Trance -- Triphop -- Twostep -- Western -subgroup: -- 30s -- 40s -- 50s -- 60s -- 70s -- 80s -- Acid -- Alternative -- Ambient -- Anatolian -- Arena -- Art -- Australian -- Australian -- Avantgarde -- Balearic -- Balkan -- Battle -- Black -- Body -- Bossa nova -- Brit -- Celtic -- Chinese -- Christian -- Comedy -- Conscious -- Cow -- Crust -- Dark -- Death -- Dirty -- Doom -- Drone -- East Coast -- Electroclash -- Electronic -- Emo -- Euro -- Experimental -- Extreme -- Flower -- Folk -- Free -- Freestyle -- Fucking -- Fun -- Funk -- Fusion -- Future -- Gangsta -- Garage -- Ghetto -- Glam -- Gospel -- Gothic -- Grind -- Groove -- Happy -- Hard -- Hardcore -- Harmonica -- Handsup -- Heavy -- Horror -- Indian -- Indie -- Independent -- Industrial -- Instrumental -- Latin -- Lounge -- Mainstream -- Medieval -- Melodic -- Minimal -- Neo -- New age -- Ninja -- Nintendo -- Noise -- Nu -- Pagan -- Pirate -- Post -- Power -- Progressive -- Psychedelic -- Skate -- Sludge -- Southern -- Space -- Speed -- Stoner -- Street -- Sunshine -- Surf -- Swedish -- Swing -- Symphonic -- Synth -- Teutonic -- Traditional -- Trash -- Viking -- Vocal -- Wave -- West Coast -- World diff --git a/gg.pl b/gg.pl new file mode 100755 index 0000000..4bb59f6 --- /dev/null +++ b/gg.pl @@ -0,0 +1,285 @@ +#!/usr/bin/env perl +use Mojolicious::Lite; +use Data::Random qw(rand_enum); + +my @genres = ( + 'Aggrotech', + 'Ambient', + 'Beat', + 'Bluegrass', + 'Blues', + 'Chiptune', + 'Core', + 'Country', + 'Cumbia', + 'Dance', + 'Dancehall', + 'Drum and Bass', + 'Dub', + 'Dubstep', + 'EBM', + 'Flamenco', + 'Grunge', + 'Goa', + 'Gospel', + 'Hardstyle', + 'Hip-hop', + 'House', + 'Humppa', + 'Industrial', + 'Jazz', + 'Metal', + 'Oi!', + 'Polka', + 'Pop', + 'Punk', + 'Rap', + 'Rave', + 'Reggae', + 'Rockabilly', + 'Samba', + 'Schranz', + 'Ska', + 'Soul', + 'Techhouse', + 'Techno', + 'Tekkno', + 'Trance', + 'Triphop', + 'Twostep', + 'Western', +); + +my @subgenres = ( + '30s', + '40s', + '50s', + '60s', + '70s', + '80s', + 'Acid', + 'Alternative', + 'Ambient', + 'Anatolian', + 'Arena', + 'Art', + 'Australian', + 'Australian', + 'Avantgarde', + 'Balearic', + 'Balkan', + 'Battle', + 'Black', + 'Body', + 'Bossa nova', + 'Brit', + 'Celtic', + 'Chinese', + 'Christian', + 'Comedy', + 'Conscious', + 'Cow', + 'Crust', + 'Dark', + 'Death', + 'Dirty', + 'Doom', + 'Drone', + 'East Coast', + 'Electroclash', + 'Electronic', + 'Emo', + 'Euro', + 'Experimental', + 'Extreme', + 'Flower', + 'Folk', + 'Free', + 'Freestyle', + 'Fucking', + 'Fun', + 'Funk', + 'Fusion', + 'Future', + 'Gangsta', + 'Garage', + 'Ghetto', + 'Glam', + 'Gospel', + 'Gothic', + 'Grind', + 'Groove', + 'Happy', + 'Hard', + 'Hardcore', + 'Harmonica', + 'Handsup', + 'Heavy', + 'Horror', + 'Indian', + 'Indie', + 'Independent', + 'Industrial', + 'Instrumental', + 'Latin', + 'Lounge', + 'Mainstream', + 'Medieval', + 'Melodic', + 'Minimal', + 'Neo', + 'New age', + 'Ninja', + 'Nintendo', + 'Noise', + 'Nu', + 'Pagan', + 'Pirate', + 'Post', + 'Power', + 'Progressive', + 'Psychedelic', + 'Skate', + 'Sludge', + 'Southern', + 'Space', + 'Speed', + 'Stoner', + 'Street', + 'Sunshine', + 'Surf', + 'Swedish', + 'Swing', + 'Symphonic', + 'Synth', + 'Teutonic', + 'Traditional', + 'Trash', + 'Viking', + 'Vocal', + 'Wave', + 'West Coast', + 'World', +); + +my @cities = ( + 'Berlin', + 'Bakersfield', + 'Detroit', + 'Frankfurt', + 'Gothenburg', + 'Ibiza', + 'London', + 'New Orleans', + 'Rio', + 'Rotterdam', + 'San Francisco', +); + +sub chance { + my ($percent) = @_; + return int(rand 101) <= $percent; +} + +sub generate { + my @genre; + + push @genre, rand_enum(set => \@cities) if chance 10; + push @genre, rand_enum(set => \@subgenres) if chance 70; + push @genre, rand_enum(set => \@subgenres); + push @genre, rand_enum(set => \@genres); + + return join ' ', @genre; +} + +get '/' => sub { + my ($self) = @_; + $self->render('index', genre => generate()); +}; + +get '/plain' => sub { + my ($self) = @_; + $self->render(text => generate()); +}; + +app->start; + +__DATA__ + +@@ index.html.ep + + + + + Listen to <%= $genre %> + + + + + +
Listen to
+ + + +
+ + +
+
+ +
+ Created by + xeno + and + mxey + | + fork me on github +
+ + + + +@@ style.css + +* { + margin: 0px; + padding: 0px; +} + +body, html { + font-family: sans-serif; + text-align: center; +} + +#title { + margin-top: 50px; + font-size: 50px; +} + +#genre { + margin-top: 50px; + font-size: 50px; + font-weight: bold; + color: #666; +} + +#twitter { + margin-top: 80px; + margin-left: 18px; +} + +#impressum { + margin-top: 5px; + font-size: 10px; + color: #999; +} + +a { + color: #666; + text-decoration: none; +} diff --git a/lib/App/Genregenerator.pm b/lib/App/Genregenerator.pm deleted file mode 100644 index 8590cd0..0000000 --- a/lib/App/Genregenerator.pm +++ /dev/null @@ -1,28 +0,0 @@ -package App::Genregenerator; -use Dancer ':syntax'; -use Data::Random qw(rand_enum); -use YAML::XS qw(LoadFile); - -my $data = LoadFile('genres.yml'); - -sub chance { - my ($percent) = @_; - return int(rand(100 / $percent)) == 0; -} - -sub generate_genre { - my @genre; - - push @genre, rand_enum(set => $data->{cities}) if chance 10; - push @genre, rand_enum(set => $data->{subgroup}) if chance 70; - push @genre, rand_enum(set => $data->{subgroup}); - push @genre, rand_enum(set => $data->{group}); - - return join ' ', @genre; -} - -get '/' => sub { - template 'index', { genre => generate_genre() }; -}; - -true; diff --git a/public/404.html b/public/404.html deleted file mode 100644 index c314550..0000000 --- a/public/404.html +++ /dev/null @@ -1,18 +0,0 @@ - - - -Error 404 - - - - -

Error 404

-
-

Page Not Found

Sorry, this is the void.

-
- - - \ No newline at end of file diff --git a/public/500.html b/public/500.html deleted file mode 100644 index 6563a85..0000000 --- a/public/500.html +++ /dev/null @@ -1,18 +0,0 @@ - - - -Error 500 - - - - -

Error 500

-
-

Internal Server Error

Wooops, something went wrong

-
- - - \ No newline at end of file diff --git a/public/css/error.css b/public/css/error.css deleted file mode 100644 index 003ee2a..0000000 --- a/public/css/error.css +++ /dev/null @@ -1,70 +0,0 @@ -body { - font-family: Lucida,sans-serif; -} - -h1 { - color: #AA0000; - border-bottom: 1px solid #444; -} - -h2 { color: #444; } - -pre { - font-family: "lucida console","monaco","andale mono","bitstream vera sans mono","consolas",monospace; - font-size: 12px; - border-left: 2px solid #777; - padding-left: 1em; -} - -footer { - font-size: 10px; -} - -span.key { - color: #449; - font-weight: bold; - width: 120px; - display: inline; -} - -span.value { - color: #494; -} - -/* these are for the message boxes */ - -pre.content { - background-color: #eee; - color: #000; - padding: 1em; - margin: 0; - border: 1px solid #aaa; - border-top: 0; - margin-bottom: 1em; -} - -div.title { - font-family: "lucida console","monaco","andale mono","bitstream vera sans mono","consolas",monospace; - font-size: 12px; - background-color: #aaa; - color: #444; - font-weight: bold; - padding: 3px; - padding-left: 10px; -} - -pre.content span.nu { - color: #889; - margin-right: 10px; -} - -pre.error { - background: #334; - color: #ccd; - padding: 1em; - border-top: 1px solid #000; - border-left: 1px solid #000; - border-right: 1px solid #eee; - border-bottom: 1px solid #eee; -} - diff --git a/public/css/style.css b/public/css/style.css deleted file mode 100644 index fec9ffa..0000000 --- a/public/css/style.css +++ /dev/null @@ -1,37 +0,0 @@ -* { - margin: 0px; - padding: 0px; -} - -body, html { - font-family: sans-serif; - text-align: center; -} - -#title { - margin-top: 50px; - font-size: 50px; -} - -#genre { - margin-top: 50px; - font-size: 50px; - font-weight: bold; - color: #666; -} - -#twitter { - margin-top: 80px; - margin-left: 18px; -} - -#impressum { - margin-top: 5px; - font-size: 10px; - color: #999; -} - -a { - color: #666; - text-decoration: none; -} diff --git a/public/dispatch.cgi b/public/dispatch.cgi deleted file mode 100755 index 3bb7f2a..0000000 --- a/public/dispatch.cgi +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env perl -use Dancer ':syntax'; -use FindBin '$RealBin'; -use Plack::Runner; - -# For some reason Apache SetEnv directives dont propagate -# correctly to the dispatchers, so forcing PSGI and env here -# is safer. -set apphandler => 'PSGI'; -set environment => 'production'; - -my $psgi = path($RealBin, '..', 'bin', 'app.pl'); -die "Unable to read startup script: $psgi" unless -r $psgi; - -Plack::Runner->run($psgi); diff --git a/public/dispatch.fcgi b/public/dispatch.fcgi deleted file mode 100755 index 8c42e3a..0000000 --- a/public/dispatch.fcgi +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env perl -use Dancer ':syntax'; -use FindBin '$RealBin'; -use Plack::Handler::FCGI; - -# For some reason Apache SetEnv directives dont propagate -# correctly to the dispatchers, so forcing PSGI and env here -# is safer. -set apphandler => 'PSGI'; -set environment => 'production'; - -my $psgi = path($RealBin, '..', 'bin', 'app.pl'); -my $app = do($psgi); -die "Unable to read startup script: $@" if $@; -my $server = Plack::Handler::FCGI->new(nproc => 5, detach => 1); - -$server->run($app); diff --git a/public/javascripts/jquery.js b/public/javascripts/jquery.js deleted file mode 120000 index b77fd86..0000000 --- a/public/javascripts/jquery.js +++ /dev/null @@ -1 +0,0 @@ -/usr/share/javascript/jquery/jquery.js \ No newline at end of file diff --git a/t/001_base.t b/t/001_base.t deleted file mode 100644 index 06a2749..0000000 --- a/t/001_base.t +++ /dev/null @@ -1,5 +0,0 @@ -use Test::More tests => 1; -use strict; -use warnings; - -use_ok 'App::Genregenerator'; diff --git a/t/002_index_route.t b/t/002_index_route.t deleted file mode 100644 index 98f6abf..0000000 --- a/t/002_index_route.t +++ /dev/null @@ -1,10 +0,0 @@ -use Test::More tests => 2; -use strict; -use warnings; - -# the order is important -use App::Genregenerator; -use Dancer::Test; - -route_exists [GET => '/'], 'a route handler is defined for /'; -response_status_is ['GET' => '/'], 200, 'response status is 200 for /'; diff --git a/views/index.tt b/views/index.tt deleted file mode 100644 index 3770a01..0000000 --- a/views/index.tt +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - -
- Listen to -
- - - -
-
-
- -
- Created by xeno and mxey | git -
- - -