Coder Social home page Coder Social logo

shots's Introduction

shots's People

Contributors

knksmith57 avatar

Watchers

 avatar  avatar

shots's Issues

Figure out a way to make the "uploads/" prefix a config option [models/image.rb]

filename : models/image.rb
line # : 7
tag : todo
md5 : a5e9b5d0de37c70b903c9aedd7eeecd1

  # [todo] - Figure out a way to make the "uploads/" prefix a config option
  def path!
    # return the image's full path from the root ==
    "uploads/" + self.image_id + self.extension
  end

  # from: http://stackoverflow.com/a/12109098
  def generate_id
    self.image_id = loop do
      random_token = SecureRandom.hex(10) # 20 digit long random hex string (hex doubles the input number for length)
      break random_token unless Image.exists?(:image_id => random_token)
    end
  end

end

# [todo] - On access to a valid image, update time stamps / tracking info

Implement an actual JWT schema for tokens [models/token.rb]

filename : models/token.rb
line # : 1
tag : fix
md5 : 8348d5cc8630147b1af072f32b45acf5

# [fix] - Implement an actual JWT schema for tokens

class Token < ActiveRecord::Base
  validates_uniqueness_of :token_id

  after_initialize :init
  before_validation :generate_id

  # set up default parameters
  def init
    self.expires_at = DateTime.now + (60*60*24*365)  # tokens are valid for 1 year
  end

  # from: http://stackoverflow.com/a/12109098
  def generate_id
    self.token_id = loop do
      random_token = SecureRandom.urlsafe_base64(nil, false)

Figure out what the default behavior should be [app.rb]

filename : app.rb
line # : 12
tag : todo
md5 : 6b68f3d94ecfb1ebf072b292b94cbd2a

# [todo] - Figure out what the default behavior should be
get '/' do
  # maybe should show an empty page? or a login page?
  haml :index
end

get '/:image_id' do
  # render the image inside of a minimal UI
  img = image(params[:image_id])
  if img.nil?
    status 404
    return haml :no_image
  end

  haml :image, :locals => {:img => img}
end

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.