zh / turl

TinyURL service in Ramaze

This URL has Read+Write access

turl / README
100644 36 lines (26 sloc) 0.997 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
TinyURL Ramaze Application
===========================
 
Required gems
--------------
 
sqlite3-ruby, sequel, validatable, ramaze, thin
 
 
Features
---------
 
- everything in one file - model, view, controller
- auto create the database if missing
- unique urls in the database
- url hits counting
- API for command-line access - can shorten urls and restore the original urls
 
 
Usage
------
 
 $ curl -O turl.rb "http://github.com/zh/turl/tree/master%2Fturl.rb?raw=true"
 $ ruby turl.rb
 # browse http://localhost:7000/
 # shorten url (turl)
 $ curl http://admin:secret@localhost:7000/_api?turl=http://github.com/zh/turl/
 # restore the original url
 $ curl http://admin:secret@localhost:7000/_api?url=abc
 # number of hints for given turl
 $ curl http://admin:secret@localhost:7000/_api?hits=abc
 
Do not forget to change the BASE_URL and LOGINS values. By default the database
file (sqlite3) will be created in the same directory with turl.rb. If this is not
acceptable, change the DB_FILE line.