diff --git a/.gitignore b/.gitignore index 3666b52..9f9d880 100644 --- a/.gitignore +++ b/.gitignore @@ -13,11 +13,19 @@ # Ignore all logfiles and tempfiles. /log/*.log /tmp +logfile .DS_Store # Ignore all photos previously added. -/public/cinemagraph_storage/* +/public/system/* coverage ngrok + +/coverage/.resultset.json +/coverage/.last_run.json + +*.rvmrc* +/.rvmrc.* +.ruby-version diff --git a/Gemfile b/Gemfile index 2e2b47d..0ed6d98 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,9 @@ gem 'rails', '3.2.11' gem 'pg' gem 'jquery-rails' gem 'bcrypt-ruby', '~> 3.0.0' -gem 'mini_magick' +gem 'paperclip' +gem 'aws-sdk' +gem 'pry' group :assets do gem 'sass-rails', '~> 3.2.3' @@ -13,7 +15,7 @@ group :assets do end group :test, :development do - gem "rspec-rails", "~> 2.0" + gem 'rspec-rails', '~> 2.0' gem 'shoulda' gem 'capybara' gem 'factory_girl_rails' diff --git a/Gemfile.lock b/Gemfile.lock index 702bffc..9af2d25 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -38,6 +38,10 @@ GEM i18n (~> 0.6) multi_json (~> 1.0) arel (3.0.2) + aws-sdk (1.11.1) + json (~> 1.4) + nokogiri (>= 1.4.4) + uuidtools (~> 2.1) bcrypt-ruby (3.0.1) builder (3.0.4) capybara (2.1.0) @@ -48,6 +52,11 @@ GEM xpath (~> 2.0) childprocess (0.3.9) ffi (~> 1.0, >= 1.0.11) + climate_control (0.0.3) + activesupport (>= 3.0) + cocaine (0.5.3) + climate_control (>= 0.0.3, < 1.0) + coderay (1.0.9) database_cleaner (1.1.1) diff-lcs (1.2.4) erubis (2.7.0) @@ -71,15 +80,23 @@ GEM i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) + method_source (0.8.2) mime-types (1.25) - mini_magick (3.6.0) - subexec (~> 0.2.1) mini_portile (0.5.1) multi_json (1.8.0) nokogiri (1.6.0) mini_portile (~> 0.5.0) + paperclip (3.5.2) + activemodel (>= 3.0.0) + activesupport (>= 3.0.0) + cocaine (~> 0.5.3) + mime-types pg (0.17.0) polyglot (0.3.3) + pry (0.9.12.2) + coderay (~> 1.0.5) + method_source (~> 0.8) + slop (~> 3.4) rack (1.4.5) rack-cache (1.2) rack (>= 0.4) @@ -137,12 +154,12 @@ GEM multi_json (~> 1.0) simplecov-html (~> 0.7.1) simplecov-html (0.7.1) + slop (3.4.6) sprockets (2.2.2) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - subexec (0.2.3) thor (0.18.1) tilt (1.4.1) treetop (1.4.15) @@ -152,6 +169,7 @@ GEM uglifier (2.2.1) execjs (>= 0.3.0) multi_json (~> 1.0, >= 1.0.2) + uuidtools (2.1.4) websocket (1.0.7) xpath (2.0.0) nokogiri (~> 1.3) @@ -161,14 +179,16 @@ PLATFORMS DEPENDENCIES anjlab-bootstrap-rails! + aws-sdk bcrypt-ruby (~> 3.0.0) capybara database_cleaner factory_girl_rails faker jquery-rails - mini_magick + paperclip pg + pry rails (= 3.2.11) rspec-rails (~> 2.0) sass-rails (~> 3.2.3) diff --git a/README.md b/README.md index 331ea06..e58f803 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,5 @@ -#CineHerd -team: Dan, Lloyd, Luisa, Chae +#[CineHerd](http://calm-meadow-5876.herokuapp.com/) -Our [trello board](https://trello.com/b/1ObtqHqL/stackexchange) is hosted at: https://trello.com/b/1ObtqHqL/stackexchange - -Please take a second to look over all of our cards and comments— - -We'd like to add response functionality for our posts. There's a small catch—our schema is such that responses and posts are designed to be the same object. The main post for any given thread should have a parent_id and a root_id attribute that are set to nil. - -Any direct responses to that post (say, the post with post_id of 1) should have a root_id and parent_id set to reference that post (1). (Let's assume our response has a post_id of 2) - -Any comments to THAT response should have a parent_id set to reference the response's post_id (2) and a root_id set to the post_id of the root post (1). - -POST 1 (ROOT) -post_id: 1 -root_id: nil -parent_id: nil - -POST 2 (DIRECT RESPONSE) -post_id: 2 -root_id: 1 -parent_id: 1 - -POST 3 (COMMENT TO DIRECT RESPONSE) -post_id: 3 -root_id: 1 -parent_id: 2 - -User signup page exists, but it isn't currently linked to from the root or navbar. Navigate directly there with: - -localhost:3000/users/new +[http://calm-meadow-5876.herokuapp.com/](http://calm-meadow-5876.herokuapp.com/) +Weekend DBC project created by [Dan](https://github.com/danapczynski), [Chae](https://github.com/ChaeOkay), [Luisa](https://github.com/LBeck), and [Lloyd](https://github.com/llnimetz) diff --git a/app/assets/javascripts/post.js b/app/assets/javascripts/post.js index 68eb1bd..bf23b33 100644 --- a/app/assets/javascripts/post.js +++ b/app/assets/javascripts/post.js @@ -1,12 +1,34 @@ -$(document).ready(function(){ + +var SubmitPost = function() { +} + +SubmitPost.prototype.afterSubmit = function() { $("#new_post_form").on('ajax:success', function(xhr, settings){ displayLoadingAnimation() }).on('ajax:complete', function(e, data, status, xhr){ console.log(data) }) -}) +} + +var Arrows = function(images){ + this.arrowImages = images + this.dissableButton = $('#sign_in') +} -function displayLoadingAnimation() { - $("#new_post_button").removeClass('btn-primary').addClass('btn-danger') - $("#new_post_button").val('Uploading Cinemagraph...') -} \ No newline at end of file +Arrows.prototype.disable = function(){ + if (this.dissableButton.length > 0) + { + $.each(this.arrowImages, function(index, value){ + $(value).attr('onClick', 'return false') + }) + } +} + + +$(document).ready(function(){ + newPost = new SubmitPost() + newPost.afterSubmit() + + arrowImages = new Arrows($('i')) + arrowImages.disable() +}) diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 63386e7..11bf2a6 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -1,7 +1,6 @@ class PostsController < ApplicationController def index - #@vote = Vote.index @posts = Post.all end diff --git a/app/models/post.rb b/app/models/post.rb index edbd80c..8b7f788 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -2,68 +2,11 @@ class Post < ActiveRecord::Base belongs_to :user has_many :votes, :as => :votable has_many :comments - attr_accessible :content, :title, :user, :cinemagraph, :extension - validates_presence_of :content, :title, :user, :extension - validates_uniqueness_of :title - - after_save :store_cinemagraph - - include MiniMagick - - def cinemagraph=(file_data) - unless file_data.blank? - @file_data = file_data - self.extension = file_data.original_filename.split('.').last.downcase - end - end - - def cinemagraph_filename - File.join(CINEMAGRAPH_STORAGE, "#{self.id}.#{self.extension}") - end - - def cinemagraph_still_filename - File.join(CINEMAGRAPH_STORAGE, "#{self.id}_still.#{self.extension}") - end - - def cinemagraph_path - "/cinemagraph_storage/#{self.id}.#{self.extension}" - end - def cinemagraph_still_path - "/cinemagraph_storage/#{self.id}_still.#{self.extension}" - end + attr_accessible :content, :title, :user, :cinemagraph + has_attached_file :cinemagraph, :styles => { :medium => "600x400>"} - def has_cinemagraph? - File.exists?(cinemagraph_filename) - end - - CINEMAGRAPH_STORAGE = File.join(Rails.root, 'public', 'cinemagraph_storage') - - private - - def store_cinemagraph - if @file_data - FileUtils.mkdir_p CINEMAGRAPH_STORAGE - File.open(cinemagraph_filename, 'wb') do |f| - f.write(@file_data.read) - end - resize_cinemagraph(cinemagraph_filename) - create_still(cinemagraph_filename) - @file_data = nil - end - end - - def resize_cinemagraph(cinemagraph_filename) - image = MiniMagick::Image.open(cinemagraph_filename) - image.coalesce - image.resize("600x400") - image.write(cinemagraph_filename) - end - - def create_still(cinemagraph_filename) - image = MiniMagick::Image.open(cinemagraph_filename) - image.collapse! - image.colorspace("Gray") - image.write(cinemagraph_still_filename) - end + #add paperclip validations for content type, size, attachment presence + validates_presence_of :content, :title, :user + validates_uniqueness_of :title end diff --git a/app/views/pages/about.html.erb b/app/views/pages/about.html.erb index 0470315..059c7df 100644 --- a/app/views/pages/about.html.erb +++ b/app/views/pages/about.html.erb @@ -1,14 +1,14 @@

CineHerd (pronounced "seen-heard") -

-

...the easiest way to share & find the world's best Cinemagraphs. -

+ + +

...the easiest way to share & find the world's best Cinemagraphs.


-

The Cinemagraph is the photograph of the future. It captures one single moment in time but with some extra, subtle flare that brings that moment alive more than a photograph ever could! +

The Cinemagraph is the photograph of the future. It captures one single moment in time but with some extra, subtle flare that brings that moment alive more than a photograph ever could!

-

Dan, Lloyd, Chae and Luisa were searching for cinemagraphs online one day and realized that there wasn't yet a site that made them it easy to find. So we decided to build our own, tapping into the power of crowdsourcing and the social wed (a.k.a. 'herds') to do so.

+

<%= link_to "Dan", "https://github.com/danapczynski" %>, <%= link_to "Chae", "https://github.com/ChaeOkay" %>, <%= link_to "Lloyd", "https://github.com/llnimetz" %>, and <%= link_to "Luisa", "https://github.com/LBeck" %> were searching for cinemagraphs online one day and realized that there wasn't yet a site that made them it easy to find. So we decided to build our own, tapping into the power of crowdsourcing and the social wed (a.k.a. 'herds') to do so.

-

We built this app in just a few days and plan to add features so stay tuned for updates. +

We built this app in just a few days and plan to add features so stay tuned for updates.

diff --git a/app/views/posts/_formroot.html.erb b/app/views/posts/_formroot.html.erb index 5c5e957..cedbbf5 100644 --- a/app/views/posts/_formroot.html.erb +++ b/app/views/posts/_formroot.html.erb @@ -1,9 +1,7 @@
- -

Contribute to the Herd:

-<%= form_for @post, :remote => true, :html => { :id => 'new_post_form', :class => "form-group" } do |f| %> +<%= form_for @post, :remote => true, :html => { :multipart => true } do |f| %> <%= f.text_field :title, :placeholder => "Title", :class => "form-control" %>
<%= f.text_field :content, :placeholder => "Description", :class => "form-control" %>
<%= f.file_field :cinemagraph, :placeholder => "Cinemagraph", :class => "form-control", :id => "file_uploader" %>
diff --git a/app/views/posts/_show2.html.erb b/app/views/posts/_show2.html.erb index e5cea38..2ca0d3c 100644 --- a/app/views/posts/_show2.html.erb +++ b/app/views/posts/_show2.html.erb @@ -10,7 +10,7 @@