Created
March 26, 2013 01:28
-
-
Save RogerDodger/5242390 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Mojolicious::Lite; | |
open my $fh, "<", "nouns.txt"; | |
my @nouns = map { chomp && lc $_ } $fh->getlines; | |
close $fh; | |
sub nurble { | |
my $text = uc shift; | |
$text =~ s{ | |
([\w']+) | |
}{ | |
my $word = $1; | |
lc $word ~~ @nouns ? $word : '<span class="nurble">nurble</span>'; | |
}exg; | |
$text =~ s/\n/<br>/g; | |
return $text; | |
} | |
get '/' => 'index'; | |
post '/' => sub { | |
my $self = shift; | |
$self->stash(nurble => nurble($self->param('text') || '')); | |
$self->render('nurble'); | |
}; | |
app->start; | |
__DATA__ | |
@@ index.html.ep | |
% layout 'default'; | |
<h1>Nurblizer</h1> | |
<form action="/" method="post"> | |
<fieldset> | |
<ul> | |
<li> | |
<label>Text to nurblize</label> | |
<textarea name="text"></textarea> | |
</li> | |
<li> | |
<input type="submit" value="Nurblize Away!"> | |
</li> | |
</ul> | |
</fieldset> | |
</form> | |
<p> | |
<a href="http://www.smbc-comics.com/?id=2779">wtf?</a> | |
</p> | |
@@ nurble.html.ep | |
% layout 'default'; | |
<h1>Your Nurbled Text</h1> | |
<div><%== $nurble %></div> | |
<p> | |
<a href="/"><< Back</a> | |
</p> | |
@@ layouts/default.html.ep | |
<html> | |
<head> | |
<title>Nurblizer</title> | |
<style><%= include 'style', format => 'css' %></style> | |
</head> | |
<body> | |
<div class="container"> | |
<%= content %> | |
</div> | |
</body> | |
</html> | |
@@ style.css.ep | |
body{ | |
font-size: 16px; | |
font-family: Arial; | |
line-height: 1.68em; | |
background: #333; | |
color: #333; | |
} | |
footer{ | |
width: 728px; | |
margin: 5px auto; | |
text-align: right; | |
} | |
footer a{ | |
color: #47f; | |
} | |
.container{ | |
max-width: 728px; | |
margin: 20px auto; | |
background: #fff; | |
box-shadow: 0px 2px 10px #000; | |
padding: 1px 20px; | |
} | |
.nurble{ | |
color: #999; | |
} | |
fieldset{ | |
border: 0px; | |
margin: 0px; | |
padding: 0px; | |
} | |
fieldset ul, | |
fieldset li{ | |
list-style: none; | |
padding: 0px; | |
margin: 0px; | |
} | |
fieldset label{ | |
display: block; | |
font-weight: bold; | |
} | |
textarea{ | |
display: block; | |
width: 100%; | |
height: 24em; | |
border: 1px solid #ddd; | |
border-top-color: #bbb; | |
font-family: inherit; | |
font-size: inherit; | |
padding: 10px; | |
} | |
input[type=submit]{ | |
margin-top: 20px; | |
width: 100%; | |
font-size: 20px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment