Skip to content
Host your own link shortener that works with a bot. Just send the link to a bot and it'll take care of the rest for you.
Shell Ruby
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.openshift ALT: remove force clean build Mar 28, 2017
public ADD: just seeing if the gear works Mar 28, 2017
tmp
.gitignore
Dockerfile
Gemfile ADD: dockerize Sep 28, 2017
Gemfile.lock ADD: dockerize Sep 28, 2017
README.md ADD: license Sep 29, 2017
app.rb
entrypoint ADD: dockerize Sep 28, 2017

README.md

Link shortener front end

Host your own link shortener that works with a bot. Just send the link to a bot and it'll take care of the rest for you. Demo: @GiveMeShortLinkBot

This is the backend (nevermind the repo name) for the link shortener. You need a bot to add links to this link shortener. For source code of the bot see tommyku/link-shortener-bot

Getting Started

  1. Make sure you have Ruby 2.3.1+ installed and a Firebase database set up
  2. Run bundle install from project root folder
  3. Set the environmental variables FIREBASE_BASE_URI and FIREBASE_SECRET_KEY in your environment
  4. To push some data into the Firebase database, use bundle exec irb:
irb> require 'firebase'
irb> firebase = Firebase::Client.new(ENV['FIREBASE_BASE_URI'], ENV['FIREBASE_SECRET_KEY'])
irb> firebase.push('appleorange', 'https://github.com/tommyku/link-shortener-front-end')
irb> response = firebase.get('appleorange')
irb> response.body
{'-somefirebasekey': 'https://github.com/tommyku/link-shortener-front-end'}
  1. To run the server locally, run bundle exec ruby app.rb and navigate to http://localhost:3000/appleorange, you should have been redirected to https://github.com/tommyku/link-shortener-front-end

Prerequisites

  1. Ruby 2.3.1+
  2. Set up Firebase database from the official site.

Installing

After cloning the repo, you should create two environmental variables FIREBASE_BASE_URI and FIREBASE_SECRET_KEY referring to your to the Firebase realtime database.

To run locally:

$ bundle install
$ bundle exec ruby app.rb

Deployment

Building Docker image

SSH into your production environment and build the image there:

$ docker build -t link-shortener-front-end .

Alternatively, you can build it locally and sftp/scp it onto the production server:

(local)$ docker build -t link-shortener-front-end .
(local)$ docker save -o link-shortener-front-end link-shortener-front-end
(local)$ scp link-shortener-front-end username@production-server:~/link-shortener-front-end

(prod)$ docker load -i link-shortener-front-end

Run the image

From the project folder,

$ docker run -e FIREBASE_BASE_URI=FIREBASE_BASE_URI -e FIREBASE_SECRET_KEY=FIREBASE_SECRET_KEY -e PORT=3000 -p 3000:3000 link-shortener-front-end

Built With

License

This project is an open-sourced software licensed under the MIT license.

You can’t perform that action at this time.