Git Product home page Git Product logo

shrtn's Introduction

Shrtn

Shrtn (pronounced "shorten") is a tiny url shortener inspired by @joemoreno, @davewiner and @windley - see their posts below for background:

TL;DR version: redirect files are just static html files with meta refresh headers, so the only server requirement is a simple web server - no database, no dynamic code, very little to go wrong.

The set of mappings from codes to urls is just stored in a yaml text file, so it is trivial to backup etc.

And if the data directory is detected to be a git repo, shrtn will automatically commit and push your mappings remotely, making backup completely automatic.

Usage

shrtn is a just a script that generates your shortcodes and redirect html pages for you. Usage is:

./shrtn <url> [<code>]

e.g.

./shrtn http://www.example.com/amazing_piece_of_newness

You can optionally supply your own shortcode, which shrtn will use if available:

./shrtn http://www.openfusion.net/ ofn

You can either run shrtn directly on your server (say via ssh), or you can run it on your laptop or workstation, and sync the generated html files over to your webserver using rsync (just set rsync_path in your data/config.yml file).

shrtn is written in perl; the only requirements are YAML and Digest::MD5 (the latter is in core for perl >= 5.7.3).

Setup

Simple:

git clone https://github.com/gavincarr/shrtn.git
cd shrtn

# Use the shrtn_setup script to copy template configs from conf to a new
# 'data' directory (it will ask you about copying apache or nginx templates)
./shrtn_setup

# Configure to taste (you must at least set the 'base_url' in config.yml,
# and your server name and paths in the webserver configs)
$EDITOR data/*

# If you're setting up on your server, copy or link the webserver configs to
# the appropriate locations, and then restart your webserver
# e.g. apache:
sudo ln -s /etc/httpd/conf.d/shrtn.conf $PWD/data/apache.conf
# e.g. nginx:
sudo ln -s /etc/nginx/conf.d/shrtn.conf $PWD/data/nginx.conf

# If you're going to push your redirect files to a remote webserver, copy
# your shrtn webserver configs remotely, and make sure you set 'rsync_path'
# in your data/config.yml. e.g.
scp data/apache.conf WEBSERVER:/etc/httpd/conf.d/shrtn.conf
scp data/nginx.conf  WEBSERVER:/etc/nginx/conf.d/shrtn.conf

In addition, if you want to auto-commit your shortenings to github, you can create a new repo on github (I'm using 'shrtn-data'), and clone it as your data directory e.g.

mv data data.orig
git clone https://github.com/USER/shrtn-data data
cp data.orig/* data
cd data
git add *
git commit -m 'Initial import.'

After this shrtn will auto-commit and push any new shortenings you add to github.

Author and Licence

Copyright 2012-2014 Gavin Carr [email protected]

Shrtn is available under the same terms as perl i.e. either under the GPL, version 1, or (at your option) any later version; or under the "Artistic License". See http://dev.perl.org/licenses/.

shrtn's People

Contributors

gavincarr avatar

Stargazers

Minho Ryang avatar Zoff avatar Rogerio Prado de Jesus avatar Minho Ryang avatar Gregarious Narain avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.