Replace with Mojolicious version

This commit is contained in:
Maximilian Gass 2011-09-06 21:37:54 +02:00 committed by Maximilian Gass
parent 739793d624
commit 495b8efdeb
20 changed files with 285 additions and 529 deletions

View File

@ -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

View File

@ -1,13 +0,0 @@
^\.git\/
maint
^tags$
.last_cover_stats
Makefile$
^blib
^pm_to_blib
^.*.bak
^.*.old
^t.*sessions
^cover_db
^.*\.log
^.*\.swp$

View File

@ -1,21 +0,0 @@
use strict;
use warnings;
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'genregenerator',
AUTHOR => q{YOUR NAME <youremail@example.com>},
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-*' },
);

View File

@ -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;

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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

285
gg.pl Executable file
View File

@ -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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>
Listen to <%= $genre %>
</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="/style.css" />
</head>
<body>
<div id="title"> Listen to </div>
<div id="genre"> <a href="/"><%= $genre %></a> </div>
<div id="twitter">
<a href="http://twitter.com/share" class="twitter-share-button"
data-text="I listen to <%= $genre %> data-count="horizontal">
Tweet
</a>
<script type="text/javascript"
src="http://platform.twitter.com/widgets.js"> </script>
<br />
</div>
<div id="impressum">
Created by
<a href="http://www.thehappy.de/~xeno/"> xeno </a>
and
<a href="http://ghosthacking.net"> mxey </a>
|
<a href="htts://github.com/mxey/genregenerator"> fork me on github </a>
</div>
</body>
</html>
@@ 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;
}

View File

@ -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;

View File

@ -1,18 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Error 404</title>
<link rel="stylesheet" href="/css/error.css" />
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>Error 404</h1>
<div id="content">
<h2>Page Not Found</h2><p>Sorry, this is the void.</p>
</div>
<div id="footer">
Powered by <a href="http://perldancer.org/">Dancer</a> 1.3060
</div>
</body>
</html>

View File

@ -1,18 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Error 500</title>
<link rel="stylesheet" href="/css/error.css" />
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>Error 500</h1>
<div id="content">
<h2>Internal Server Error</h2><p>Wooops, something went wrong</p>
</div>
<div id="footer">
Powered by <a href="http://perldancer.org/">Dancer</a> 1.3060
</div>
</body>
</html>

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -1 +0,0 @@
/usr/share/javascript/jquery/jquery.js

View File

@ -1,5 +0,0 @@
use Test::More tests => 1;
use strict;
use warnings;
use_ok 'App::Genregenerator';

View File

@ -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 /';

View File

@ -1,28 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="/css/style.css" />
</head>
<body>
<div id="title">
Listen to
</div>
<div id="genre">
<a href="/"><% genre %></a>
</div>
<div id="twitter">
<a href="http://twitter.com/share" class="twitter-share-button" data-text="I listen to <% genre %> #genregenerator" data-count="horizontal">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script><br />
</div>
<div id="impressum">
Created by <a href="http://www.thehappy.de/~xeno/">xeno</a> and <a href="http://ghosthacking.net">mxey</a> | <a href="http://ghosthacking.net/git/genregenerator.git">git</a>
</div>
</body>
</html>