diff --git a/app.psgi b/app.psgi new file mode 100644 index 0000000..14b80b7 --- /dev/null +++ b/app.psgi @@ -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 ] + ]; +} diff --git a/genregenerator.py b/genregenerator.py deleted file mode 100644 index 80e1745..0000000 --- a/genregenerator.py +++ /dev/null @@ -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 -# 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: diff --git a/genres.yaml b/genres.yaml new file mode 100644 index 0000000..d1182c9 --- /dev/null +++ b/genres.yaml @@ -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 diff --git a/index.html b/index.tt similarity index 66% rename from index.html rename to index.tt index 1d5fc0f..aa4daa8 100644 --- a/index.html +++ b/index.tt @@ -4,7 +4,7 @@ - + @@ -13,11 +13,11 @@
- viking rotterdam trance + [% genre %]
-
+
diff --git a/style.css b/static/style.css similarity index 100% rename from style.css rename to static/style.css