#!/usr/bin/env perl use Mojolicious::Lite; use URI::Title qw( title ); get '/' => sub { my $c = shift; $c->render(template => 'index'); }; get '/comment' => sub { my $c = shift; my $v = $c->param('v'); if (! $v) { $c->render(template => 'error', error => 'No video specified!'); } elsif ($v =~ m! (?: \bv i? [/=] | be/ ) ([a-zA-Z_\-]+) !x) { $c = $c->redirect_to("/comment?v=$1"); } elsif ($v !~ /.........../) { $c->render(template => 'error', error => 'Invalid video ID!'); } else { my $title = title('http://youtube.com/watch?v='.$v); if (! $title) { $c->render(template => 'error', error => 'Invalid video, or could not fetch video.'); } else { $title =~ s/(.*) - YouTube/$1/; $c->stash(title => $title); $c->stash(v => $v); $c->render(template => 'comment'); } } }; app->start; __DATA__ @@ index.html.ep % layout 'default'; % title 'Hello hello!'; <%= title %>

OpinionsAllowed

Voice your opinion for any video, comments are never disabled!

%= form_for 'comment' => (method => 'GET') => begin %= label_for v => 'Video Link: ' %= text_field 'v' % end

OpinionsAllowed 2015 - Written in Mojolicious for Perl 5

@@ comment.html.ep <%= $title %> - OpinionsAllowed

Video

<%= $title %>