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 @@
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.
No cinemagraph found. Boo.
<% end %> diff --git a/app/views/posts/index.html.erb b/app/views/posts/index.html.erb index 36aa812..c08c3d9 100644 --- a/app/views/posts/index.html.erb +++ b/app/views/posts/index.html.erb @@ -9,7 +9,7 @@ <% @posts.each do |post| %><%= link_to post.title, post_path(post) %>
diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb index d47a2d5..98cbc18 100644 --- a/app/views/posts/show.html.erb +++ b/app/views/posts/show.html.erb @@ -2,8 +2,8 @@No cinemagraph found. Boo.
<% end %> diff --git a/config/environments/production.rb b/config/environments/production.rb index e9f0697..2b39625 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -64,4 +64,14 @@ # Log the query plan for queries taking more than this (works # with SQLite, MySQL, and PostgreSQL) # config.active_record.auto_explain_threshold_in_seconds = 0.5 + + # Paperclip + config.paperclip_defaults = { + :storage => :s3, + :s3_credentials => { + :bucket => ENV['AWS_BUCKET_NAME'], + :access_key_id => ENV['AWS_ACCESS_KEY_ID'], + :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'] + } + } end diff --git a/db/migrate/20131026150129_remove_extension_to_posts.rb b/db/migrate/20131026150129_remove_extension_to_posts.rb new file mode 100644 index 0000000..991054f --- /dev/null +++ b/db/migrate/20131026150129_remove_extension_to_posts.rb @@ -0,0 +1,9 @@ +class RemoveExtensionToPosts < ActiveRecord::Migration + def up + remove_column :posts, :extension + end + + def down + add_column :posts, :extension, :string + end +end diff --git a/db/migrate/20131026192026_add_attachment_cinemagraph_to_posts.rb b/db/migrate/20131026192026_add_attachment_cinemagraph_to_posts.rb new file mode 100644 index 0000000..8981bd4 --- /dev/null +++ b/db/migrate/20131026192026_add_attachment_cinemagraph_to_posts.rb @@ -0,0 +1,11 @@ +class AddAttachmentCinemagraphToPosts < ActiveRecord::Migration + def self.up + change_table :posts do |t| + t.attachment :cinemagraph + end + end + + def self.down + drop_attached_file :posts, :cinemagraph + end +end diff --git a/db/schema.rb b/db/schema.rb index a61da34..318aee0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130923041936) do +ActiveRecord::Schema.define(:version => 20131026192026) do create_table "comments", :force => true do |t| t.integer "user_id" @@ -29,9 +29,12 @@ t.integer "user_id" t.string "title" t.text "content" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "extension" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "cinemagraph_file_name" + t.string "cinemagraph_content_type" + t.integer "cinemagraph_file_size" + t.datetime "cinemagraph_updated_at" end add_index "posts", ["user_id"], :name => "index_posts_on_user_id"