NAME
Net::Lujoyglamour - Create short URLs with luxury and glamour
VERSION
This document describes Net::Lujoyglamour version 0.0.5.1.9
SYNOPSIS
use Net::Lujoyglamour qw(is_valid);
#Deploy database
my $dsn = 'dbi:SQLite:dbname=:memory:';
my $schema = Net::Lujoyglamour->connect($dsn);
$schema->deploy({ add_drop_tables => 1});
#Most straighforward way to use
if ( is_valid( "shortie" ) {
$schema->create_new_short( "very.long.url/like/this",
"shortie" );
}
$schema->create_new_short( "even.longer.url/this/and/that" );
DESCRIPTION
Model/Control part of a framework intended for creating short URLs. Inherits from DBIx::Class; adds functionality for creating a keeping a table of long/short URLs. Funky name comes from the novel lujoyglamour.net
, in Spanish, which I also wrote (and obtained a literary price), and you can check out at http://lujoyglamour.es or buy at http://compra.lujoyglamour.net.
The module has been tested with SQLite and MySQL, and is in fact running using both. You just need to change the $dsn
for using either. It hasn't been tested using other databases; would be grateful if anybody tried/patched for these.
INTERFACE
connect( $dsn[, $username] [, $password] [, \%attr] )
Actually, inherited from DBIx::Class, but useful here too
deploy
Also inherited, used for creating the database from the schema description in the class
is_valid( $string )
Check for requested short URL validity; only alphanumeric characters are allowed
generate_candidate_url
Generates a random URL with the character limitation set. It checks URLs with increasing size, until it finds one.
create_new_short ( $long_url[, $short_url] )
Creates and inserts into the database a new short URL, optionally using a requested short URL.
get_long_for ( $short_url )
Returns the long URL that corresponds to the short one
DIAGNOSTICS
Url space exhausted!!
-
No more URLs availables. You probably have a very successful URL shortener site. You already used up all available short addresses. Time to expand your database!
Invalid short URL $want_short
-
The requested URL is invalid
CONFIGURATION AND ENVIRONMENT
You need to have a database system ready and able. If there's none installed, SQLite will do nicely, but do check reading/writing permissions over the file. Use the app/lg-deploy
script, modified for your environment, to create the initial environment.
There are some template and CGI examples under the app/
directory of the distribution. Check them for usage, or use your own. You only need to keep the filenames of the .html
files and copy them in the same directory as the CGI. A htaccess
file is also provided as an example; you will have to modify it with the actual file names you will be using.
DEPENDENCIES
DBIx::Class, String::Random, Regexp::Common and drivers for database system. If you want to use the provided WebApp, you will need CGI::Application and corresponding drivers.
INCOMPATIBILITIES
None reported.
BUGS AND LIMITATIONS
Other than the limited space available, for the time being there are none.
Please report any bugs or feature requests to bug-net-lujoyglamour@rt.cpan.org
, or through the web interface at http://rt.cpan.org.
SEE ALSO
The module is used with a SQLite database at the site http://lugl.info/, and with MySQL at http://l-g.me (in Spanish). Any comments and suggestions are welcome. If you decide to run your URL shortener on this, please let me know.
Other URL shortening modules you might want to check out are CGI::Shorten, WWW::Shorten::MakeAShorterLink and WWW::Shorten, which is rather an interface for available URL shortening services.
There is an example app at the aptly named app
directory, retrieve it from your CPAN directory or from the CPAN website.
This version includes the PDF of the novel lujoyglamour.net, distributed with a CC licence, in Spanish. Look under the t/
directory, and read it using your favorite PDF browser or ebook reader. If you publish a review, please trackback http://lujoyglamour.es .
ACKNOWLEDGEMENTS
CPANTS tester Sebastian Woetzel helped me fix a bug in my tests scripts.
AUTHOR
JJ Merelo <jj@merelo.net>
LICENCE AND COPYRIGHT
Copyright (c) 2009, 2010, JJ Merelo <jj@merelo.net>
. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
DISCLAIMER OF WARRANTY
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.