GithubHelp home page GithubHelp logo

bitly_clone's Introduction

Bitly Clone

Skill Level: Intermediate Time Limit: 1-2 hours

Bitly.com is a link shortening service that provides people with a way to take really long urls and turn them into short urls for easy use in email and social media. Today, you'll create a clone.

Note: If you have scant Rails knowledge, we highly recommend tackling TasksApp or following the Rails Getting Started guide when attempting this drill.

For this challenge, you may ONLY use the controllers provided to you in the source folder.

Release 0: Simple Shortener

We have one resource: Urls. For our controllers, we have a URL that lists all our Url objects and another URL that, when POSTed to, creates a Url object.

We'll also need a URL that redirects us to the full (unshortened) URL. If you've never used bitly, use it now to get a feel for how it works.

  • Use a before_save callback in the Url model to generate the short URL.
  • Make sure to use RESTFUL routes

Release 1: Add a Counter!

Add a click_count field to your urls table, which keeps track of how many times someone has visited the shortened URL. Add code to the appropriate place in your controller code so that any time someone hits a short URL the counter for the appropriate Url is incremented by 1.

Release 2: Add Validations

Add a validation to your Url model so that only Urls with valid URLs get saved to the database.

A valid URL is...

  • Any non-empty string
  • Any non-empty string that starts with "http://" or "https://"
  • Any string that the Ruby URI module says is valid
  • Any URL-looking thing which responds to a HTTP request, i.e., we actually check to see if the URL is accessible via HTTP

Release 3: Add Error Handling

Display a helpful error message if a user enters an invalid URL, giving them the opportunity to correct their error.

EXTRA CREDIT - Add User Authentication

Create one model, User to handle both regular users and at least one administrator. Your controllers should support a few core actions:

  1. Logging in
  2. Logging out
  3. Creating an account
  4. Viewing the secret page
  5. Redirecting a user back to the "log in" screen if they try to view the secret page without being logged in

Resources

bitly_clone's People

Contributors

orlando21 avatar

Watchers

James Cloos avatar  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.