Code Monkey home page Code Monkey logo

dogstagram's Introduction

#Dogstagram Ruby, Ruby on Rails, Javascript, React, Flux

Dogstagram

Dogstagram is a web application for dog selfies inspired by Instagram built using Ruby on Rails and React.js.

Features

Dogstagram allows users to:

  • Create an account
  • Log in / Log out
  • Follow Users
  • Create, Read, and Delete Posts
  • Like Posts
  • Create, Read, and Delete Comments

Implementation Details

###Custom made user authentication I overwrote the password= method using the BCrypt gem in the user model to store a hashed and salted password:

def password=(password)
  @password = password
  self.password_digest = BCrypt::Password.create(password)
end

Incoming passwords can then be compared against the stored password hash to see if the password is correct

def is_password?(password)
  BCrypt::Password.new(self.password_digest).is_password?(password)
end

A users session is then stored as a session token to remember a user is signed in at a specific computer

def reset_token!
  self.session_token = generate_session_token
  self.save
  self.session_token
end

I implement a check for duplicate session tokens for the security of all my users' accounts. While it is uncommon for the same token to be generated twice, it becomes more likely to happen as the user base grows.

def generate_session_token
  token = SecureRandom.urlsafe_base64(16)

  while User.exists?(session_token: token)
    token = SecureRandom.urlsafe_base64(16)
  end

  token
end

###Feed based on user follows The feed only displays posts from users that the current user is following, with most recent first

def index
  following_ids = "SELECT followed_id FROM relationships
                   WHERE  follower_id = :user_id"

  @posts = Post.includes(:user, :likes, comments: [:user])
    .where("user_id IN (#{following_ids})
            OR user_id = :user_id", user_id: current_user.id)
end

##Photos

###Login Page Login

###Photo Feed Photo Feed

###User Page User Page

###Search Search

##Included Gems and Libraries

  • BCrypt
  • Figaro
  • React

Bonus Features (To do)

  • Edit images with filters
  • Pagination / infinite scroll for Images feed
  • Add videos
  • Add notifications and user tagging

dogstagram's People

Contributors

jtung1104 avatar

Stargazers

 avatar

Watchers

 avatar

dogstagram's Issues

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.