guillotine ruby Rubygems

URL shortening hobby kit

Guillotine

Simple URL Shortener hobby kit.

USAGE

The easiest way to use it is with the built-in memory adapter.

# app.rb
require 'guillotine'
module MyApp
  class App < Guillotine::App
    set :db => Guillotine::Adapters::MemoryAdapter.new

    get '/' do
      redirect 'https://homepage.com'
    end
  end
end
# config.ru
require "rubygems"
require File.expand_path("../app.rb", __FILE__)
run MyApp::App

Once it’s running, add URLs with a simple POST.

curl http://localhost:4567 -i \
  -F "url=http://techno-weenie.net"

You can specify your own code too:

curl http://localhost:4567 -i \
  -F "url=http://techno-weenie.net" \
  -F "code=abc"

Sequel

The memory adapter sucks though. You probably want to use a DB.

require 'guillotine'
require 'sequel'
module MyApp
  class App < Guillotine::App
    set :db => Guillotine::Adapters::SequelAdapter.new(Sequel.sqlite)
  end
end

Riak

If you need to scale out your url shortening services across the cloud, you can use Riak!

require 'guillotine'
require 'riak/client'
module MyApp
  class App < Guillotine::App
    client = Riak::Client.new :protocol => 'pbc', :pb_port => 8087
    bucket = client['guillotine']
    set :db => Guillotine::Adapters::RiakAdapter.new(bucket)
  end
end

Domain Restriction

You can restrict what domains that Guillotine will shorten.

require 'guillotine'
module MyApp
  class App < Guillotine::App
    # only this domain
    set :required_host, 'github.com'

    # or, any *.github.com domain
    set :required_host, /(^|\.)github\.com$/
  end
end

Not TODO

  • Statistics
  • Authentication

Related Repositories

GuillotineMenu

GuillotineMenu

Our Guillotine Menu Transitioning Animation implemented in Swift reminds a bit of a notorious killing machine. ...

GuillotineMenu-Android

GuillotineMenu-Android

Neat library, that provides a simple way to implement guillotine-styled animation ...

guillotine

guillotine

URL shortening hobby kit ...

guillotine

guillotine

jQuery plugin to crop images within an area (fully responsive), allowing to drag (touch support), zoom and rotate. ...

katana

katana

ready to go heroku hosted URL shortener based on guillotine ...


Top Contributors

technoweenie brianmario max-power snatchev

Releases

-   v1.0.8 zip tar
-   v1.0.7 zip tar
-   v1.0.6 zip tar
-   v1.0.5 zip tar
-   v1.0.4 zip tar
-   v1.0.3 zip tar
-   v1.0.2 zip tar
-   v1.0.1 zip tar
-   v1.0.0 zip tar
-   v0.2.0 zip tar
-   v0.1.2 zip tar
-   v0.1.1 zip tar
-   v0.1.0 zip tar
-   v0.0.5 zip tar
-   v0.0.4 zip tar
-   v0.0.3 zip tar
-   v0.0.2 zip tar
-   v0.0.1 zip tar