%# -*-html-*- %# %# URL shortener webservice for Odin %# %# (c) 2015 Mark Wooding %# %#----- Licensing notice ---------------------------------------------------- %# %# This file is part of the `odin.gg' service, `odin-cgi'. %# %# `odin-cgi' is free software; you can redistribute it and/or modify %# it under the terms of the GNU Affero General Public License as %# published by the Free Software Foundation; either version 3 of the %# License, or (at your option) any later version. %# %# `odin-cgi' is distributed in the hope that it will be useful, %# but WITHOUT ANY WARRANTY; without even the implied warranty of %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the %# GNU Affero General Public License for more details. %# %# You should have received a copy of the GNU Affero General Public %# License along with `odin-cgi'; if not, see %# . %# <&| SELF:wrapper, title => "odin.gg URL Shortener" &>

odin.gg URL Shortener

">
% if (defined $tag) {

Shortened to: "><% "$Odin::SHORTURL/$tag" %> % } %# <%init> my $tag = $m->dhandler_arg; if (length $tag) { my $url = Odin::get_shorturl $tag; if ($q) { $m->comp(".query", url => $url); } else { $m->redirect($url, 301); } return; } elsif (defined $u) { $tag = Odin::new_shorturl $u; } else { Odin::path_info($r) =~ m:/$: or $m->redirect("$Odin::SHORTURL/", 301); $tag = undef; } %# <%args> $q => undef $u => undef %# <%def .query>\ % $r->content_type("text/plain; charset=utf8"); <% $url %> <%args> $url %# <%def .notfound>\ <&| SELF:error, title => "not found", status => 404 &>\ tag ‘<% $tag |h %>’ not found <%args> $tag %# <%def .badurl>\ <&| SELF:error, title => "invalid url", status => 404 &>\ ‘<% $u |h %>’ is not a valid URL <%args> $u %# <%once> use utf8; use Odin;