vvoody / cmprzurl

A simple implement of TinyURL.com and deploy easily on your own domain.

This URL has Read+Write access

vvoody (author)
Fri May 29 21:54:05 -0700 2009
commit  436d7bfc657a52e03122d761f5dddb173e5548a0
tree    f9f3a13c8d4a585fb3916d073520d3ba0381299e
parent  a3866166b3337de488658cc927f5002d47c367fb
cmprzurl / README
100644 102 lines (70 sloc) 2.76 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
cmprzurl
    - a simple implement of TinyURL.com and deploy easily on your own domain.
 
==============
Introduction:
==============
    Have you ever heard of tinyurl.com or is.gd?
    Do you wanna make your domain have the ability to shorten long url?
 
    Yes, all we need is 4 files.
    Maybe you should read the section 'What each file do?' first ;-)
 
=============
Requirement:
=============
    * Apache web server and support .htaccess [2.0.63]
    * SQLite3 [3.2.1]
    * Python [2.3.5]
    * pysqlite2 (or sqlite3) module
 
    # My environment is what you see in the brackets.
 
===========
Installation:
===========
    The following steps we are under root directory of your domain. e.g.:
    http://xxxxxx.org -> /home/xxxxxx/xxxxxx.org/
 
    0. Upload the files:
 
       cmprzurl.py, redirect.py, dotaccess, cmprzurl.sql, (cmprzurl.db)
 
    1. Create a sqlite3 database and a table using the following directive:
 
       $ sqlite3 cmprzurl.db < cmprzurl.sql
 
       # You can also skip this step by using the db I had created
        named 'cmprzurl.db'.
 
    2. Append the content of dotaccess into your .htaccess:
 
       $ cat dotaccess >> .htaccess
 
    3. Make the two scripts executable:
 
       $ chmod +x cmprzurl.py redirect.py
 
    4. Clean up & done:
 
       $ rm dotaccess cmprzurl.sql
 
====================
What each file do?:
====================
    * cmprzurl.py
 
      Generate an alias like 'eJk8pA' for mapping the long url,
      then store the alias and longurl into database.
 
    * redirect.py
 
      Redirect the request url like 'http://xxxxxx.org/eJk8pA'
      to the real url.
 
    * dotaccess
 
      Make the files/dirs under domain root directory works well
      as before, but the alias like 'eJk8pA' can be redirected
      correctly.
 
    * cmprzurl.db
 
      Store the aliases and their mapping longurls.
 
=======
Usage:
=======
    Type the url from browser address bar directly:
        http://xxxxxx.org/cmprzurl.py?longurl=http://www.faqs.org/rfcs/rfc3022.html
 
    Or, you can generate a html form like:
 
    <form method="post" action="http://xxxxxx.org/cmprzurl.py">
        <input type="text" name="longurl"> <!-- must be 'longurl' or modify the source code -->
        <input type="submit" value="Shorten!">
    </form>
 
    Then, 'cmprzurl.py' will generate an alias for the long url like:
        http://xxxxxx.org/a9Y7Hz
 
=========
License:
=========
    Copyright 2009 vvoody <wxj{AT}vvoody.org>
    All rights reserved.
 
    The programs are released under GNU General Public License version 3.
    For license details, checkout:
        http://www.gnu.org/copyleft/gpl.html
 
Any problems please contact vvoody -> wxj_AT_vvoody.org