Replace with content of genregenerator.de

This commit is contained in:
Maximilian Gass 2011-05-28 21:13:18 +02:00
parent 7cff68b1f0
commit b12d268429
5 changed files with 159 additions and 35 deletions

50
app.psgi Normal file
View File

@ -0,0 +1,50 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Random qw(rand_enum);
use Plack::App::File;
use YAML::XS qw(LoadFile);
use Template;
chdir ('/srv/www/de.genregenerator');
my $data = LoadFile('genres.yaml');
my $template = Template->new({
INCLUDE_PATH => '.',
});
sub chance {
my ($percent) = @_;
return int(rand(100 / $percent)) == 0;
}
sub generate_genre {
my @genre;
if (chance(10)) {
push @genre, rand_enum(set => $data->{cities});
}
if (chance(70)) {
push @genre, rand_enum(set => $data->{subgroup});
}
push @genre, rand_enum(set => $data->{subgroup});
push @genre, rand_enum(set => $data->{group});
return join ' ', map { ucfirst } @genre;
}
my $app = sub {
my $genre = generate_genre();
my $out = '';
$template->process('index.tt', { genre => $genre }, \$out);
return [
200,
[ 'Content-Type' => 'text/html' ],
[ $out ]
];
}

View File

@ -1,32 +0,0 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.
# Author: Stefan Ritter <xeno@thehappy.de>
# Description: Generate music genres
from random import choice, randint
city = ["rotterdam", "berlin", "detroit", "gothenburg", "san francisco", "london", "rio"]
subgroup = ["medieval", "death", "black", "hard", "progressive", "symphonic", "viking", "pagan", "gangsta", "experimental", "alternative", "minimal", "dark", "synth", "future", "body", "christian", "indian", "chinese", "euro", "happy", "power", "fusion", "free", "speed", "trash", "extreme", "surf", "brit", "emo", "electronic", "neo", "noise", "psychedelic", "post", "conscious", "battle", "east coast", "west coast", "glam", "heavy", "avantgarde", "gothic", "groove", "funk", "nu", "melodic", "celtic", "industrial", "latin", "traditional", "harmonica", "dirty", "gospel", "balkan", "lounge", "sunshine", "street", "skate", "garage", "horror", "ghetto", "acid"]
group = ["core", "metal", "pop", "punk", "country", "rap", "western", "ambient", "techno", "house", "trance", "dance", "beat", "dubstep", "samba", "chiptune", "jazz", "ska", "soul", "aggrotech", "rave", "oi!", "bluegrass", "hip-hop", "grunge", "rockabilly", "industrial", "blues", "humppa", "reggae", "dancehall", "dub", "schranz"]
rand1 = randint(0, 1)
rand2 = randint(0, 9)
if rand1 is 0:
if rand2 is 9:
print choice(city),
print choice(subgroup), choice(subgroup), choice(group)
if rand1 is 1:
if rand2 is 9:
print choice(city),
print choice(subgroup), choice(group)
# vim: set sw=4 tw=0 ts=4 expandtab:

106
genres.yaml Normal file
View File

@ -0,0 +1,106 @@
cities:
- Rotterdam
- Berlin
- Detroit
- Gothenburg
- San Francisco
- London
- Rio
group:
- core
- metal
- pop
- punk
- country
- rap
- western
- ambient
- techno
- house
- trance
- dance
- beat
- dubstep
- samba
- chiptune
- jazz
- ska
- soul
- aggrotech
- rave
- oi!
- bluegrass
- hip-hop
- grunge
- rockabilly
- industrial
- blues
- humppa
- reggae
- dancehall
- dub
- schranz
subgroup:
- medieval
- death
- black
- hard
- progressive
- symphonic
- viking
- pagan
- gangsta
- experimental
- alternative
- minimal
- dark
- synth
- future
- body
- christian
- indian
- chinese
- euro
- happy
- power
- fusion
- free
- speed
- trash
- extreme
- surf
- brit
- emo
- electronic
- neo
- noise
- psychedelic
- post
- conscious
- battle
- east coast
- west coast
- glam
- heavy
- avantgarde
- gothic
- groove
- funk
- nu
- melodic
- celtic
- industrial
- latin
- traditional
- harmonica
- dirty
- gospel
- balkan
- lounge
- sunshine
- street
- skate
- garage
- horror
- ghetto
- acid

View File

@ -4,7 +4,7 @@
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css" />
<link rel="stylesheet" type="text/css" href="static/style.css" />
</head>
<body>
@ -13,11 +13,11 @@
</div>
<div id="genre">
<a href="index.html">viking rotterdam trance</a>
<a href="/">[% genre %]</a>
</div>
<div id="twitter">
<a href="http://twitter.com/share" class="twitter-share-button" data-text="Find out new music genres with genregenerator.de!" data-count="horizontal">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script><br />
<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">