1 <&| SELF:wrapper, title => "odin.gg URL Shortener" &>
2 <h1><tt>odin.gg</tt> URL Shortener</h1>
3 <form method="POST" accept-charset="UTF-8" enctype="multipart/form-data">
4 <label for="url" accesskey="u"><u>U</u>RL to shorten:</label>
5 <input id="url" name="u" value="<% $u // "" |h %>">
6 <button type="submit">Go</button>
9 <p>Shortened to: <a href="<% "$Odin::SHORTURL/$tag" %>"><%
10 "$Odin::SHORTURL/$tag" %></a>
15 my $tag = $m->dhandler_arg;
17 my $url = Odin::get_shorturl $tag;
18 if ($q) { $m->comp(".query", url => $url); }
19 else { $m->redirect($url, 301); }
21 } elsif (defined $u) {
22 $tag = Odin::new_shorturl $u;
24 Odin::path_info($r) =~ m:/$:
25 or $m->redirect("$Odin::SHORTURL/", 301);
36 % $r->content_type("text/plain; charset=utf8");
44 <&| SELF:error, title => "not found", status => 404 &>\
45 tag ‘<% $tag |h %>’ not found
53 <&| SELF:error, title => "invalid url", status => 404 &>\
54 ‘<tt><% $u |h %></tt>’ is not a valid URL