diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..f0774c34e --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile '~/.gitignore_global' + +# Ignore bundler config. +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 +/db/*.sqlite3-journal + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore Byebug command history file. +.byebug_history + +# Ignore application configuration +/config/application.yml diff --git a/.rspec b/.rspec new file mode 100644 index 000000000..6f2522bdf --- /dev/null +++ b/.rspec @@ -0,0 +1,3 @@ +--color +--require spec_helper +--format doc \ No newline at end of file diff --git a/Gemfile b/Gemfile new file mode 100644 index 000000000..b680ced22 --- /dev/null +++ b/Gemfile @@ -0,0 +1,78 @@ +source 'https://rubygems.org' + +#mail +gem 'daemons' +gem 'delayed_job_active_record' +#photos +gem 'paperclip' +gem 'figaro' +gem 'aws-sdk' +#rails app +gem 'rails-controller-testing' +gem 'simple_form' +gem 'taps' +gem 'pg' +gem 'hirb' +gem 'faker' +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '~> 5.0.0' +# Use sqlite3 as the database for Active Record +# Use Puma as the app server +gem 'puma', '~> 3.0' +# Use SCSS for stylesheets +gem 'sass-rails', '~> 5.0' +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# Use CoffeeScript for .coffee assets and views +gem 'coffee-rails', '~> 4.2' +# See https://github.com/rails/execjs#readme for more supported runtimes +# gem 'therubyracer', platforms: :ruby + +# Use jquery as the JavaScript library +gem 'jquery-rails' +# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks +gem 'turbolinks', '~> 5' +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 2.5' +# Use Redis adapter to run Action Cable in production +# gem 'redis', '~> 3.0' +# Use ActiveModel has_secure_password +gem 'bcrypt', '~> 3.1.7' + +# Use Capistrano for deployment +# gem 'capistrano-rails', group: :development + +group :development, :test do + # Call 'byebug' anywhere in the code to stop execution and get a debugger console + gem 'byebug', platform: :mri + gem 'guard-rspec' +end + +group :test do + gem 'capybara' + gem 'launchy' + gem 'shoulda-matchers', '~> 3.1' +end + +group :production do + gem 'rails_12factor' +end + +group :development do + # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. + gem 'web-console' + gem 'listen', '~> 3.0.5' + # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring + gem 'spring' + gem 'spring-watcher-listen', '~> 2.0.0' + gem 'better_errors' + gem 'binding_of_caller' + gem 'rspec-rails' + gem 'guard-rspec', require: false + gem 'factory_girl_rails', '~> 4.0' + gem 'letter_opener' + +end + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 000000000..48ac87837 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,324 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.0.0) + actionpack (= 5.0.0) + nio4r (~> 1.2) + websocket-driver (~> 0.6.1) + actionmailer (5.0.0) + actionpack (= 5.0.0) + actionview (= 5.0.0) + activejob (= 5.0.0) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.0.0) + actionview (= 5.0.0) + activesupport (= 5.0.0) + rack (~> 2.0) + rack-test (~> 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.0.0) + activesupport (= 5.0.0) + builder (~> 3.1) + erubis (~> 2.7.0) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + activejob (5.0.0) + activesupport (= 5.0.0) + globalid (>= 0.3.6) + activemodel (5.0.0) + activesupport (= 5.0.0) + activerecord (5.0.0) + activemodel (= 5.0.0) + activesupport (= 5.0.0) + arel (~> 7.0) + activesupport (5.0.0) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (~> 0.7) + minitest (~> 5.1) + tzinfo (~> 1.1) + addressable (2.4.0) + arel (7.1.1) + aws-sdk (2.5.4) + aws-sdk-resources (= 2.5.4) + aws-sdk-core (2.5.4) + jmespath (~> 1.0) + aws-sdk-resources (2.5.4) + aws-sdk-core (= 2.5.4) + bcrypt (3.1.11) + better_errors (2.1.1) + coderay (>= 1.0.0) + erubis (>= 2.6.6) + rack (>= 0.9.0) + binding_of_caller (0.7.2) + debug_inspector (>= 0.0.1) + builder (3.2.2) + byebug (9.0.5) + capybara (2.7.1) + addressable + mime-types (>= 1.16) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + xpath (~> 2.0) + climate_control (0.0.3) + activesupport (>= 3.0) + cocaine (0.5.8) + climate_control (>= 0.0.3, < 1.0) + coderay (1.1.1) + coffee-rails (4.2.1) + coffee-script (>= 2.2.0) + railties (>= 4.0.0, < 5.2.x) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.10.0) + concurrent-ruby (1.0.2) + daemons (1.2.3) + debug_inspector (0.0.2) + delayed_job (4.1.2) + activesupport (>= 3.0, < 5.1) + delayed_job_active_record (4.1.1) + activerecord (>= 3.0, < 5.1) + delayed_job (>= 3.0, < 5) + diff-lcs (1.2.5) + erubis (2.7.0) + execjs (2.7.0) + factory_girl (4.7.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.7.0) + factory_girl (~> 4.7.0) + railties (>= 3.0.0) + faker (1.6.6) + i18n (~> 0.5) + ffi (1.9.14) + figaro (1.1.1) + thor (~> 0.14) + formatador (0.2.5) + globalid (0.3.7) + activesupport (>= 4.1.0) + guard (2.14.0) + formatador (>= 0.2.4) + listen (>= 2.7, < 4.0) + lumberjack (~> 1.0) + nenv (~> 0.1) + notiffany (~> 0.0) + pry (>= 0.9.12) + shellany (~> 0.0) + thor (>= 0.18.1) + guard-compat (1.2.1) + guard-rspec (4.7.3) + guard (~> 2.1) + guard-compat (~> 1.1) + rspec (>= 2.99.0, < 4.0) + hirb (0.7.3) + i18n (0.7.0) + jbuilder (2.6.0) + activesupport (>= 3.0.0, < 5.1) + multi_json (~> 1.2) + jmespath (1.3.1) + jquery-rails (4.1.1) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) + thor (>= 0.14, < 2.0) + launchy (2.4.3) + addressable (~> 2.3) + letter_opener (1.4.1) + launchy (~> 2.2) + listen (3.0.8) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + loofah (2.0.3) + nokogiri (>= 1.5.9) + lumberjack (1.0.10) + mail (2.6.4) + mime-types (>= 1.16, < 4) + method_source (0.8.2) + mime-types (3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2016.0521) + mimemagic (0.3.1) + mini_portile2 (2.1.0) + minitest (5.9.0) + multi_json (1.12.1) + nenv (0.3.0) + nio4r (1.2.1) + nokogiri (1.6.8) + mini_portile2 (~> 2.1.0) + pkg-config (~> 1.1.7) + notiffany (0.1.1) + nenv (~> 0.1) + shellany (~> 0.0) + paperclip (5.0.0) + activemodel (>= 4.2.0) + activesupport (>= 4.2.0) + cocaine (~> 0.5.5) + mime-types + mimemagic (~> 0.3.0) + pg (0.18.4) + pkg-config (1.1.7) + pry (0.10.4) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + puma (3.6.0) + rack (2.0.1) + rack-test (0.6.3) + rack (>= 1.0) + rails (5.0.0) + actioncable (= 5.0.0) + actionmailer (= 5.0.0) + actionpack (= 5.0.0) + actionview (= 5.0.0) + activejob (= 5.0.0) + activemodel (= 5.0.0) + activerecord (= 5.0.0) + activesupport (= 5.0.0) + bundler (>= 1.3.0, < 2.0) + railties (= 5.0.0) + sprockets-rails (>= 2.0.0) + rails-controller-testing (1.0.1) + actionpack (~> 5.x) + actionview (~> 5.x) + activesupport (~> 5.x) + rails-dom-testing (2.0.1) + activesupport (>= 4.2.0, < 6.0) + nokogiri (~> 1.6.0) + rails-html-sanitizer (1.0.3) + loofah (~> 2.0) + rails_12factor (0.0.3) + rails_serve_static_assets + rails_stdout_logging + rails_serve_static_assets (0.0.5) + rails_stdout_logging (0.0.5) + railties (5.0.0) + actionpack (= 5.0.0) + activesupport (= 5.0.0) + method_source + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rake (11.2.2) + rb-fsevent (0.9.7) + rb-inotify (0.9.7) + ffi (>= 0.5.0) + rest-client (1.6.7) + mime-types (>= 1.16) + rspec (3.5.0) + rspec-core (~> 3.5.0) + rspec-expectations (~> 3.5.0) + rspec-mocks (~> 3.5.0) + rspec-core (3.5.2) + rspec-support (~> 3.5.0) + rspec-expectations (3.5.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.5.0) + rspec-mocks (3.5.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.5.0) + rspec-rails (3.5.1) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 3.5.0) + rspec-expectations (~> 3.5.0) + rspec-mocks (~> 3.5.0) + rspec-support (~> 3.5.0) + rspec-support (3.5.0) + sass (3.4.22) + sass-rails (5.0.6) + railties (>= 4.0.0, < 6) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + sequel (3.20.0) + shellany (0.0.1) + shoulda-matchers (3.1.1) + activesupport (>= 4.0.0) + simple_form (3.2.1) + actionpack (> 4, < 5.1) + activemodel (> 4, < 5.1) + sinatra (1.0) + rack (>= 1.0) + slop (3.6.0) + spring (1.7.2) + spring-watcher-listen (2.0.0) + listen (>= 2.7, < 4.0) + spring (~> 1.2) + sprockets (3.7.0) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.1.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + taps (0.3.24) + rack (>= 1.0.1) + rest-client (>= 1.4.0, < 1.7.0) + sequel (~> 3.20.0) + sinatra (~> 1.0.0) + thor (0.19.1) + thread_safe (0.3.5) + tilt (2.0.5) + turbolinks (5.0.1) + turbolinks-source (~> 5) + turbolinks-source (5.0.0) + tzinfo (1.2.2) + thread_safe (~> 0.1) + uglifier (3.0.1) + execjs (>= 0.3.0, < 3) + web-console (3.3.1) + actionview (>= 5.0) + activemodel (>= 5.0) + debug_inspector + railties (>= 5.0) + websocket-driver (0.6.4) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.2) + xpath (2.0.0) + nokogiri (~> 1.3) + +PLATFORMS + ruby + +DEPENDENCIES + aws-sdk + bcrypt (~> 3.1.7) + better_errors + binding_of_caller + byebug + capybara + coffee-rails (~> 4.2) + daemons + delayed_job_active_record + factory_girl_rails (~> 4.0) + faker + figaro + guard-rspec + hirb + jbuilder (~> 2.5) + jquery-rails + launchy + letter_opener + listen (~> 3.0.5) + paperclip + pg + puma (~> 3.0) + rails (~> 5.0.0) + rails-controller-testing + rails_12factor + rspec-rails + sass-rails (~> 5.0) + shoulda-matchers (~> 3.1) + simple_form + spring + spring-watcher-listen (~> 2.0.0) + taps + turbolinks (~> 5) + tzinfo-data + uglifier (>= 1.3.0) + web-console + +BUNDLED WITH + 1.12.5 diff --git a/Guardfile b/Guardfile new file mode 100644 index 000000000..3215f0137 --- /dev/null +++ b/Guardfile @@ -0,0 +1,70 @@ +# A sample Guardfile +# More info at https://github.com/guard/guard#readme + +## Uncomment and set this to only include directories you want to watch +# directories %w(app lib config test spec features) \ +# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")} + +## Note: if you are using the `directories` clause above and you are not +## watching the project directory ('.'), then you will want to move +## the Guardfile to a watched dir and symlink it back, e.g. +# +# $ mkdir config +# $ mv Guardfile config/ +# $ ln -s config/Guardfile . +# +# and, you'll have to watch "config/Guardfile" instead of "Guardfile" + +# Note: The cmd option is now required due to the increasing number of ways +# rspec may be run, below are examples of the most common uses. +# * bundler: 'bundle exec rspec' +# * bundler binstubs: 'bin/rspec' +# * spring: 'bin/rspec' (This will use spring if running and you have +# installed the spring binstubs per the docs) +# * zeus: 'zeus rspec' (requires the server to be started separately) +# * 'just' rspec: 'rspec' + +guard :rspec, cmd: "bundle exec rspec" do + require "guard/rspec/dsl" + dsl = Guard::RSpec::Dsl.new(self) + + # Feel free to open issues for suggestions and improvements + + # RSpec files + rspec = dsl.rspec + watch(rspec.spec_helper) { rspec.spec_dir } + watch(rspec.spec_support) { rspec.spec_dir } + watch(rspec.spec_files) + + # Ruby files + ruby = dsl.ruby + dsl.watch_spec_files_for(ruby.lib_files) + + # Rails files + rails = dsl.rails(view_extensions: %w(erb haml slim)) + dsl.watch_spec_files_for(rails.app_files) + dsl.watch_spec_files_for(rails.views) + + watch(rails.controllers) do |m| + [ + rspec.spec.call("routing/#{m[1]}_routing"), + rspec.spec.call("controllers/#{m[1]}_controller"), + rspec.spec.call("acceptance/#{m[1]}") + ] + end + + # Rails config changes + watch(rails.spec_helper) { rspec.spec_dir } + watch(rails.routes) { "#{rspec.spec_dir}/routing" } + watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" } + + # Capybara features specs + watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") } + watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") } + + # Turnip features and steps + watch(%r{^spec/acceptance/(.+)\.feature$}) + watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m| + Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance" + end +end diff --git a/Procfile b/Procfile new file mode 100644 index 000000000..52dad52ea --- /dev/null +++ b/Procfile @@ -0,0 +1,4 @@ +worker: bundle exec rake jobs:work + +web: bundle exec rails s -p $PORT -e $RACK_ENV + diff --git a/README.md b/README.md index 24602872a..cfe1f7d7e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,9 @@ -danebook -======== +A Facebook clone in progress. 80% functionality. + +https://daneb00k.herokuapp.com/ + +![Login](http://i.imgur.com/QNUGB15.png) + +![Timeline](http://i.imgur.com/Y7uTs1C.png) + -This is the Real Dane Deal. diff --git a/Rakefile b/Rakefile new file mode 100644 index 000000000..e85f91391 --- /dev/null +++ b/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative 'config/application' + +Rails.application.load_tasks diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js new file mode 100644 index 000000000..b16e53d6d --- /dev/null +++ b/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/app/assets/images/.keep b/app/assets/images/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js new file mode 100644 index 000000000..b12018d09 --- /dev/null +++ b/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require jquery +//= require jquery_ujs +//= require turbolinks +//= require_tree . diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js new file mode 100644 index 000000000..71ee1e66d --- /dev/null +++ b/app/assets/javascripts/cable.js @@ -0,0 +1,13 @@ +// Action Cable provides the framework to deal with WebSockets in Rails. +// You can generate new channels where WebSocket features live using the rails generate channel command. +// +//= require action_cable +//= require_self +//= require_tree ./channels + +(function() { + this.App || (this.App = {}); + + App.cable = ActionCable.createConsumer(); + +}).call(this); diff --git a/app/assets/javascripts/channels/.keep b/app/assets/javascripts/channels/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/app/assets/javascripts/comments.coffee b/app/assets/javascripts/comments.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/app/assets/javascripts/comments.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/friendings.coffee b/app/assets/javascripts/friendings.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/app/assets/javascripts/friendings.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/likings.coffee b/app/assets/javascripts/likings.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/app/assets/javascripts/likings.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/news_feeds.coffee b/app/assets/javascripts/news_feeds.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/app/assets/javascripts/news_feeds.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/photos.coffee b/app/assets/javascripts/photos.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/app/assets/javascripts/photos.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/posts.js b/app/assets/javascripts/posts.js new file mode 100644 index 000000000..0f1cae02f --- /dev/null +++ b/app/assets/javascripts/posts.js @@ -0,0 +1,106 @@ + +// var APP = APP || {}; + +// APP.postModel = (function() { +// stub = {}; + +// var posts = []; + +// var getPosts = function() { +// return $.ajax({ +// url: '/posts', +// contentType: 'application/json', +// type: 'GET', +// dataType: 'json', +// success: buildPosts +// }) +// }; + +// var createPost = function(desc, user_id) { +// var post = { +// user_id: user_id, +// description: desc +// }; + +// return $.ajax({ +// url: '/posts', +// contentType: 'application/json', +// type: 'POST', +// dataType: 'json', +// success: updatePosts, +// data: function() { +// console.log("i dunno what to do"); +// } +// }) +// }; + +// var buildPosts = function(response) { +// posts = response; +// }; + +// var updatePosts = function(response) { +// posts.push(response); +// }; + +// stub.init = function() { +// return getPosts(); +// }; + +// return stub; +// })(); + +// APP.postView = (function($) { +// stub = {}; + +// // var postPostListener = function(post) { +// // $('#post-submit').on('click', function(e) { +// // e.preventDefault(); +// // var description = $('#post_description').val(); +// // var user_id = $('h4[user-id]').attr('user-id'); +// // APP.postController.createPost(description, user_id); +// // }); +// // } + +// var buildSinglePost = function(post) { +// $post = $(''); +// } + +// var renderPosts = function(postsArr) { +// for (var i in PostsArr) { +// buildSinglePost(postsArr[i]); +// } +// }; + +// stub.init = function () { +// //postPostListener(); +// } + +// stub.render = function(postsArr) { +// $('#comment-panels-box').empty(); + +// renderPosts(postsArr) + +// }; + +// return stub; +// })($); + +// APP.postController = (function(Model, View) { +// stub = {}; + +// stub.init = function () { +// var promise = Model.init(); +// promise.then(View.init()); +// }; + +// stub.createPost = function(description, user_id) { +// Model.createPost(description, user_id); + +// }; + +// return stub; +// })(APP.postModel, APP.postView); + +// $(document).ready(function() { +// APP.postController.init(); +// }); \ No newline at end of file diff --git a/app/assets/javascripts/profiles.coffee b/app/assets/javascripts/profiles.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/app/assets/javascripts/profiles.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/sessions.coffee b/app/assets/javascripts/sessions.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/app/assets/javascripts/sessions.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/timelines.coffee b/app/assets/javascripts/timelines.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/app/assets/javascripts/timelines.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/users.coffee b/app/assets/javascripts/users.coffee new file mode 100644 index 000000000..24f83d18b --- /dev/null +++ b/app/assets/javascripts/users.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss new file mode 100644 index 000000000..9c7f1ff13 --- /dev/null +++ b/app/assets/stylesheets/application.scss @@ -0,0 +1,279 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. + * + *= require_tree . + *= require_self + */ + + * { + font-family: Comic; + } + +#well { + margin-bottom: 0px; + background-color: rgba(245, 245, 245, 0.4); + +} + +.row-eq-height { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; +} + +p { + display: block; + color: black; + margin: 0px; + padding: 0px; } + +li { + margin-left: 20%; + text-align: left; } + +h1 { + color: black; + margin: 0px 0px 0px 0px; } + +#main-nav { + background-color: #3b5998; + } + +.col-md-4 { + display: inline; } + + +.col-md-6 { + margin: 0px; } + + * { + font-family: Comic; } + +.container-fluid { + padding: 0px; } + +.container { + padding-bottom: 25px; } + +.navbar-fixed-top { + border: none; + background-color: #3b5998; + height: 8%; } + +.navbar-fixed-top img { + margin-top: 10px; + } + +.input-group { + width: 100%; + } + +.form-control { + height: 100%; +} + +.form-inline .form-control { + height: 100%; +} + +textarea.form-control { + height: 100%; } + +span.nav-default { + border: none; } + +.nav-default { + border: solid; + border-width: 0.5px; } + +.row { + margin-right: 1px; + margin-bottom: 5px; } + +.row .nav-default .container-fluid { + width: 100%; } + +.row.header-bar { + margin: 0px; + border-bottom-style: solid; + border-width: 0.5px; + padding-bottom: 5px; } + +.row.footer-bar { + background-color: #f3f6fb; + margin: 0px 0px 0px 0px; + border-top-style: solid; + border-width: 0.5px; + padding-top: 5px; } + +.row-eq-height { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; } + +#body-container { + margin: 0% 0% 0% 0%; + padding: 0px; + border: 1px solid black; + } + +#title-tag { + margin-top: 10px; +} + +.container { + margin-top: 0px; + margin-bottom: 10px; } + + + + + +.col-xs-9.col-xs-offset-3 { + padding: 0px; } + +.col-xs-8.col-xs-offset-4 { + padding: 0px; } + +.col-xs-5 { + padding: 0px; } + +.main .col-xs-3 img { + height: 100%; + width: 100%; + border: 1px solid gold; } + +.main .col-xs-4 img { + height: 100%; + width: 100%; + border: 1px solid gold; } + +p, li { + text-align: left; } + +.btn-sm { + text-align: center; + width: 100%; } + +.btn-primary { + text-align: center; + width: 100%; } + +button { + width: 50%; } + +li { + verticle-align: middle; } + +#helpBlock { + margin: 0px; } + +#friends { + margin: 0px; + padding: 5px; + width: 100%; } + +#photos { + height: 25%; + width: 25%; } + +#footers li { + display: inline; +} +#footers { + padding: 15px; + margin-bottom: 5px; +} + +#panels { + display: block; + } + +h1 { + font-size: 30px; + text-align: center; + border: 0px; + padding: 0px; + margin: 0px; } + +.nav-link { + font-size: 15px; +} + + +#big-body { + border-radius: 10px; + margin-bottom: 0px; + padding: 0px; + border: 1px solid grey; +} + +#main-body-container { + padding: 0px; +} + +#photo-container { + background-color: #F3F3F3; + padding: 0px; + display: block; +} + +#background-container { + padding: 0px; +} + +#phototron-container { + padding: 0px; margin-bottom: 0px; +} + +#photo { + min-height: 70%; + max-height: 70%; +} + +#nav-container { + padding: 0px; +} + +#post-panels { + padding: 0px; + margin-bottom: 5px; + border: 1px solid grey; +} + +#extra-padding { + padding: 15px; +} + +#post-panels-box { + padding: 0px; +} + +#post-options li { + display: inline; + margin: 0px; +} + +#post-options { + padding: 0px; +} + +#sign-up-form { + +} + +.main { + border: 1px solid black; +} + diff --git a/app/assets/stylesheets/comments.scss b/app/assets/stylesheets/comments.scss new file mode 100644 index 000000000..3722c124e --- /dev/null +++ b/app/assets/stylesheets/comments.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the comments controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/friendings.scss b/app/assets/stylesheets/friendings.scss new file mode 100644 index 000000000..b93309da3 --- /dev/null +++ b/app/assets/stylesheets/friendings.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Friendings controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/likings.scss b/app/assets/stylesheets/likings.scss new file mode 100644 index 000000000..02469f30d --- /dev/null +++ b/app/assets/stylesheets/likings.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Likings controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/news_feeds.scss b/app/assets/stylesheets/news_feeds.scss new file mode 100644 index 000000000..74261b62a --- /dev/null +++ b/app/assets/stylesheets/news_feeds.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the NewsFeeds controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/photos.scss b/app/assets/stylesheets/photos.scss new file mode 100644 index 000000000..16dc630d3 --- /dev/null +++ b/app/assets/stylesheets/photos.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Photos controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/posts.scss b/app/assets/stylesheets/posts.scss new file mode 100644 index 000000000..ed4dfd10f --- /dev/null +++ b/app/assets/stylesheets/posts.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Posts controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/profiles.scss b/app/assets/stylesheets/profiles.scss new file mode 100644 index 000000000..191c4ea3a --- /dev/null +++ b/app/assets/stylesheets/profiles.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Profiles controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/sessions.scss b/app/assets/stylesheets/sessions.scss new file mode 100644 index 000000000..7bef9cf82 --- /dev/null +++ b/app/assets/stylesheets/sessions.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the sessions controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/timelines.scss b/app/assets/stylesheets/timelines.scss new file mode 100644 index 000000000..92f39ca74 --- /dev/null +++ b/app/assets/stylesheets/timelines.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the timelines controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/users.scss b/app/assets/stylesheets/users.scss new file mode 100644 index 000000000..31a2eacb8 --- /dev/null +++ b/app/assets/stylesheets/users.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Users controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb new file mode 100644 index 000000000..d67269728 --- /dev/null +++ b/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/app/channels/application_cable/connection.rb b/app/channels/application_cable/connection.rb new file mode 100644 index 000000000..0ff5442f4 --- /dev/null +++ b/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/app/controllers/about_controller.rb b/app/controllers/about_controller.rb new file mode 100644 index 000000000..ef2dd8c5c --- /dev/null +++ b/app/controllers/about_controller.rb @@ -0,0 +1,5 @@ +class AboutController < ApplicationController + + def index + end +end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb new file mode 100644 index 000000000..accca737d --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,47 @@ +class ApplicationController < ActionController::Base + #protect_from_forgery with: :exception + + private + # switched to cookies-based from session-based + # regenerate the token as well + def sign_in(user) + user.regenerate_auth_token + cookies[:auth_token] = user.auth_token + @current_user = user + end + + # new wrinkle for permanent sign-in + # uses `cookies.permanent` instead of just `cookies` + def permanent_sign_in(user) + user.regenerate_auth_token + cookies.permanent[:auth_token] = user.auth_token + @current_user = user + end + + def require_login + unless signed_in_user? + flash[:alert] = "Not authorized, please sign in!" + redirect_to login_path + end + end + + # cookies! + def sign_out + @current_user = nil + cookies.delete(:auth_token) + end + + # cookies! + def current_user + @current_user ||= User.find_by_auth_token(cookies[:auth_token]) if cookies[:auth_token] + end + helper_method :current_user + + def signed_in_user? + !!current_user + end + + helper_method :signed_in_user? + + +end diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb new file mode 100644 index 000000000..d8d8d7cb4 --- /dev/null +++ b/app/controllers/comments_controller.rb @@ -0,0 +1,56 @@ +class CommentsController < ApplicationController + def create + @post = Post.find(params[:post_id]) + # @comment = Comment.new( + # description: params[:comment][:description], + # commentable_type: params[:commentable], + # commentable_id: params[:post_id], + # user_id: current_user.id) + + @comment = @post.comments.build(whitelisted_comment_params); + @comment.user_id = current_user.id; + + if @comment.save + flash[:success] = "Comment Successfully created!" + + respond_to do |format| + # format.html { render(:text => "not implemented") } + format.js { } + end + else + + flash[:notice] = "Comment NOT! Sucessfully created!" + end + end + + def update + + end + + def destroy + raise + @comment = Comment.find(params[:id]) + if @comment.destroy + flash[:success] = "Comment Successfully Deleted!" + respond_to do |format| + # format.html { render(:text => "not implemented") } + format.js { } + end + end + redirect_to current_user + end + + private + def whitelisted_comment_params + params.require(:comment). + permit( :description) + end + + #implemented + # def get_commentable_resource + # resource = Post.find(params[:post_id]) if params[:post_id] + # resource = Comment.find(params[:comment_id]) if params[:comment_id] + # resource = Photo.find(params[:photo_id]) if params[:photo_id] + # resource + # end +end diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/app/controllers/friendings_controller.rb b/app/controllers/friendings_controller.rb new file mode 100644 index 000000000..6900f7f6c --- /dev/null +++ b/app/controllers/friendings_controller.rb @@ -0,0 +1,32 @@ +class FriendingsController < ApplicationController + + def index + @users = User.all + @user = User.find(params[:user_id]) + @profile = Profile.find_by_user_id(params[:user_id]) + end + + def create + curr_user = User.find(current_user.id) + friending_recipient = User.find(params[:user_id]) + if curr_user.friended_users << friending_recipient + flash[:success] = "Successfully friended #{friending_recipient.username}" + redirect_to friending_recipient + else + flash[:error] = "Failed to friend! Sad :(" + redirect_to friending_recipient + end + end + + def destroy + @friending = Friending.find_by_friend_id(params[:id]) + if @friending + @friending.destroy + flash[:success] = "He's unfriended now" + redirect_to user_friendings_path(current_user) + else + flash[:alert] = "Couldn't unfriend him, try blocking him eh." + render :index + end + end +end diff --git a/app/controllers/likings_controller.rb b/app/controllers/likings_controller.rb new file mode 100644 index 000000000..e3686b1eb --- /dev/null +++ b/app/controllers/likings_controller.rb @@ -0,0 +1,29 @@ +class LikingsController < ApplicationController + + def index + redirect_to user_path(current_user) + end + + def create + @post = Post.find(params[:post_id]) + @post.likes.create(user_id: current_user.id) + + respond_to do |format| + format.js { } + end + end + + def destroy + @liking = Liking.find(params[:id]) + @post = @liking.likeable + @user = @liking.user + if @liking.destroy + respond_to do |format| + # format.html { render(:text => "not implemented") } + format.js { } + end + else + redirect_to user_path(current_user) + end + end +end diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb new file mode 100644 index 000000000..312f20d44 --- /dev/null +++ b/app/controllers/photos_controller.rb @@ -0,0 +1,48 @@ +class PhotosController < ApplicationController + + # create a belongs_to cover, profile photo for profile. and add migration + + def index + @photos = current_user.photos + end + + def create + which = params["photoable"].downcase + if (which == "user") + @photoable = params["photoable"].classify.constantize.find(params["user_id"]); + @photo = @photoable.photos.build(whitelisted_photo_params) + + elsif (which == "profile") + @photoable = params["photoable"].classify.constantize.find_by_user_id(params["user_id"]) + avatar = Photo.find(params[:photo_id]).avatar + @photo = @photoable.build_photo() + @photo.avatar = avatar; + end + + if @photo.save + flash[:success] = "Photo was uploaded" + redirect_to current_user + else + flash[:error] = "Photo did not load" + render :index + end + end + + def show + @photo = Photo.find(params[:id]) + end + + def set_background + end + + def set_profile + end + + private + + def whitelisted_photo_params + params.require(:photo). + permit(:label, :avatar) + end + +end diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb new file mode 100644 index 000000000..e8144af2a --- /dev/null +++ b/app/controllers/posts_controller.rb @@ -0,0 +1,52 @@ +class PostsController < ApplicationController + + def index + @posts = Post.all + respond_to do |format| + format.js { render json: @posts.to_json(:include => :user) } + end + end + + def create + @post = current_user.posts.build(whitelisted_post_params) + + if @post.save + # Post.delay(queue: "email", priority: 28, run_at: 5.seconds.from_now).send_trigger_email(current_user.id, @post) + # redirect_to current_user + flash.now[:success] = "Post was created in User" + respond_to do |format| + format.js {} + end + else + flash[:error] = "Post was NOT! saved in User" + respond_to do |format| + format.js { } + end + end + + + end + + def destroy + @post= Post.find(params[:id]) + if @post.destroy + flash[:success] = "Post was deleted in User" + + respond_to do |format| + # format.html { render(:text => "not implemented") } + format.js { } + end + else + flash[:error] = "Post was NOT! deleted in User" + redirect_to current_user + end + end + + private + def whitelisted_post_params + params. + require(:post). + permit( :description, + :photo_attributes => [:label, :avatar]) + end +end diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb new file mode 100644 index 000000000..ebffc0906 --- /dev/null +++ b/app/controllers/profiles_controller.rb @@ -0,0 +1,44 @@ +class ProfilesController < ApplicationController + before_action :require_login, :only => [:index, :show, :update] + before_action :current_user, :only => [:show, :update] + + def index + @user = User.find(params[:user_id]) + @profile = @user.profile + end + + def show + @user = User.find(params[:user_id]) + @profile = @user.profile + + end + + def update + @user = User.find(params[:user_id]) + @profile = @user.profile + if @profile.update(whitelisted_profile_params) + redirect_to user_profiles_path(current_user) + else + render :show + end + end + + def photos + flash[:notice] = "have yet to implement" + redirect_to user_profiles_path(current_user) + end + + private + + def whitelisted_profile_params + params. + require(:profile). + permit( :college, + :home_town, + :currently_lives, + :phone_number, + :year, + :photo_attributes => [:label, :avatar] + ) + end +end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb new file mode 100644 index 000000000..c063207cd --- /dev/null +++ b/app/controllers/sessions_controller.rb @@ -0,0 +1,23 @@ +class SessionsController < ApplicationController + def create + @user = User.find_by_email(params[:email]) + if @user && @user.authenticate(params[:password]) + + # we'll put this logic into a simple helper + sign_in(@user) + + flash[:success] = "You've successfully signed in" + redirect_to user_profiles_path(@user) + else + flash[:error] = "We couldn't sign you in" + redirect_to new_user_path + end + end + + def destroy + # another simple helper + sign_out + flash[:success] = "You've successfully signed out" + redirect_to root_url + end +end diff --git a/app/controllers/timelines_controller.rb b/app/controllers/timelines_controller.rb new file mode 100644 index 000000000..276bc2c2a --- /dev/null +++ b/app/controllers/timelines_controller.rb @@ -0,0 +1,8 @@ +class TimelinesController < ApplicationController + + def index + @user = current_user + @friends = @user.friended_users + end +end + diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb new file mode 100644 index 000000000..158e8cc02 --- /dev/null +++ b/app/controllers/users_controller.rb @@ -0,0 +1,85 @@ +class UsersController < ApplicationController + before_action :set_user, only: [:edit, :update] + before_action :require_login, only: [:show] + + def index + if params[:query] + @users = User.search(params[:query]) + else + @users = User.all.order("created_at DESC") + end + end + + def show + @user = User.find(params[:id]) + @profile = @user.profile + @post = Post.new + @posts = @user.posts + if @profile + @photo = @profile.photo + else + @photo = nil + end + end + + def new + redirect_to current_user if signed_in_user? + @user = User.new + @profile = Profile.new + + end + + def create + + @user = User.new(whitelisted_user_params) + @profile = @user.build_profile(whitelisted_profile_params) + + if @user.save && @profile.save + User.delay(queue: "email", priority: 28, run_at: 5.seconds.from_now).send_welcome_email(@user.id) + + flash[:success] = "User was saved in database" + redirect_to @user + else + flash[:error] = "User was NOT! saved in database" + render :new + end + end + + def edit + end + + def update + #tobewritten + end + + def destroy + #tobewritten + end + + private + def set_user + @user = User.find(current_user.id) + @profile = @user.profile + end + + def whitelisted_user_params + params. + require(:user). + permit( :username, + :email, + :password, + :password_confirmation) + + end + + def whitelisted_profile_params + params. + require(:profile). + permit( :first_name, + :last_name, + :month, + :day, + :year, + :gender) + end +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb new file mode 100644 index 000000000..de6be7945 --- /dev/null +++ b/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb new file mode 100644 index 000000000..0ec9ca5f2 --- /dev/null +++ b/app/helpers/comments_helper.rb @@ -0,0 +1,2 @@ +module CommentsHelper +end diff --git a/app/helpers/friendings_helper.rb b/app/helpers/friendings_helper.rb new file mode 100644 index 000000000..fce356995 --- /dev/null +++ b/app/helpers/friendings_helper.rb @@ -0,0 +1,2 @@ +module FriendingsHelper +end diff --git a/app/helpers/likings_helper.rb b/app/helpers/likings_helper.rb new file mode 100644 index 000000000..3640a6f05 --- /dev/null +++ b/app/helpers/likings_helper.rb @@ -0,0 +1,2 @@ +module LikingsHelper +end diff --git a/app/helpers/news_feeds_helper.rb b/app/helpers/news_feeds_helper.rb new file mode 100644 index 000000000..ffc5fb116 --- /dev/null +++ b/app/helpers/news_feeds_helper.rb @@ -0,0 +1,2 @@ +module NewsFeedsHelper +end diff --git a/app/helpers/photos_helper.rb b/app/helpers/photos_helper.rb new file mode 100644 index 000000000..0a10d472b --- /dev/null +++ b/app/helpers/photos_helper.rb @@ -0,0 +1,2 @@ +module PhotosHelper +end diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb new file mode 100644 index 000000000..a7b8cec89 --- /dev/null +++ b/app/helpers/posts_helper.rb @@ -0,0 +1,2 @@ +module PostsHelper +end diff --git a/app/helpers/profiles_helper.rb b/app/helpers/profiles_helper.rb new file mode 100644 index 000000000..4e430508f --- /dev/null +++ b/app/helpers/profiles_helper.rb @@ -0,0 +1,2 @@ +module ProfilesHelper +end diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb new file mode 100644 index 000000000..309f8b2eb --- /dev/null +++ b/app/helpers/sessions_helper.rb @@ -0,0 +1,2 @@ +module SessionsHelper +end diff --git a/app/helpers/timelines_helper.rb b/app/helpers/timelines_helper.rb new file mode 100644 index 000000000..1f1a4f076 --- /dev/null +++ b/app/helpers/timelines_helper.rb @@ -0,0 +1,2 @@ +module TimelinesHelper +end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb new file mode 100644 index 000000000..2310a240d --- /dev/null +++ b/app/helpers/users_helper.rb @@ -0,0 +1,2 @@ +module UsersHelper +end diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb new file mode 100644 index 000000000..a009ace51 --- /dev/null +++ b/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb new file mode 100644 index 000000000..286b2239d --- /dev/null +++ b/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb new file mode 100644 index 000000000..22b6d48e6 --- /dev/null +++ b/app/mailers/user_mailer.rb @@ -0,0 +1,14 @@ +class UserMailer < ApplicationMailer + default :from => "thebomb@dot.com" + + def welcome(user) + @user = user + mail(to: @user.email, subject: 'Welcome to Danebook by Adrian!') + end + + def trigger(user, post) + @user = user + @post = post + mail(to: @user.email, subject: 'Thanks for being active on Danebook!') + end +end diff --git a/app/models/application_record.rb b/app/models/application_record.rb new file mode 100644 index 000000000..10a4cba84 --- /dev/null +++ b/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/app/models/comment.rb b/app/models/comment.rb new file mode 100644 index 000000000..7ab823cfa --- /dev/null +++ b/app/models/comment.rb @@ -0,0 +1,5 @@ +class Comment < ApplicationRecord + belongs_to :commentable, :polymorphic => true + + belongs_to :user, class_name: "User" +end diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/app/models/friending.rb b/app/models/friending.rb new file mode 100644 index 000000000..6cfd3fa28 --- /dev/null +++ b/app/models/friending.rb @@ -0,0 +1,11 @@ +class Friending < ApplicationRecord + # The Initiator side + belongs_to :friend_initiator, :foreign_key => :friender_id, + :class_name => "User" + + # The Recipient side + belongs_to :friend_recipient, :foreign_key => :friend_id, + :class_name => "User" + + validates :friend_id, :uniqueness => { :scope => :friender_id } +end diff --git a/app/models/liking.rb b/app/models/liking.rb new file mode 100644 index 000000000..61a8b4019 --- /dev/null +++ b/app/models/liking.rb @@ -0,0 +1,4 @@ +class Liking < ApplicationRecord + belongs_to :likeable, :polymorphic => true#, counter_cache: true + belongs_to :user +end diff --git a/app/models/photo.rb b/app/models/photo.rb new file mode 100644 index 000000000..dcb7423a5 --- /dev/null +++ b/app/models/photo.rb @@ -0,0 +1,6 @@ +class Photo < ApplicationRecord + has_attached_file :avatar, :styles => { medium: "300x300", thumb: "150x150", small: "50x50"} + validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/ + + belongs_to :photoable, :polymorphic => true +end diff --git a/app/models/post.rb b/app/models/post.rb new file mode 100644 index 000000000..1d4f8df61 --- /dev/null +++ b/app/models/post.rb @@ -0,0 +1,34 @@ +class Post < ApplicationRecord + belongs_to :user + + validates :description, length: {minimum: 1} + has_many :comments, class_name: "Comment" + + has_many :likes, :as => :likeable, class_name: "Liking" + + has_many :comments, :as => :commentable, class_name: "Comment" + + has_one :photo, :as => :photoable, class_name: "Photo", inverse_of: :photoable + accepts_nested_attributes_for :photo + + def already_likes? + !likes.empty? + end + + def has_photo? + !!(self.photo.nil?) + end + + def self.send_trigger_email(id, post) + user = User.find(id) + UserMailer.trigger(user, post).deliver + end + + def self.recent_posts(dayz_ago) + if dayz_ago + where("created_at > ?", (dayz_ago).days.ago) + else + raise + end + end +end diff --git a/app/models/profile.rb b/app/models/profile.rb new file mode 100644 index 000000000..f0987c96f --- /dev/null +++ b/app/models/profile.rb @@ -0,0 +1,19 @@ +class Profile < ApplicationRecord + belongs_to :user, class_name: "User" + + validates :first_name, length: { :minimum => 1} + validates :last_name, length: { :minimum => 1} + + validates :month, presence: true + # validates_format_of :month, with: /[A-Z][a-z]*/ + validates :day, numericality: true + validates_inclusion_of :day, in: (1..30) + validates :year, numericality: true + validates_inclusion_of :year, in: (1900..2016) + + validates_inclusion_of :gender, in: %w(male female) + + has_one :photo, :as => :photoable, class_name: "Photo", inverse_of: :photoable + accepts_nested_attributes_for :photo + +end diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 000000000..22d21b1ab --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,58 @@ +class User < ApplicationRecord + has_secure_password + + validates :username, length: { :minimum => 1}, uniqueness: true + validates :email, uniqueness: true + validates_format_of :email, :with => /@.*[.]com\z/ + #validates :password, :allow_nil => false#, length: { in: (5..26) } + before_create :generate_token + + has_one :profile, class_name: "Profile" + has_many :posts, class_name: "Post" + has_many :comments, class_name: "Comment" + + has_many :likes, :as => :likeable, class_name: "Liking" + has_many :photos, :as => :photoable, class_name: "Photo" + + # When acting as the initiator of the friending + has_many :initiated_friendings, :foreign_key => :friender_id, + :class_name => "Friending" + has_many :friended_users, :through => :initiated_friendings, + :source => :friend_recipient + + # When acting as the recipient of the friending + has_many :received_friendings, :foreign_key => :friend_id, + :class_name => "Friending" + has_many :users_friended_by, :through => :received_friendings, + :source => :friend_initiator + + #generates and regenerates tokens and sets to self + def generate_token + begin + self[:auth_token] = SecureRandom.urlsafe_base64 + end while User.exists?(:auth_token => self[:auth_token]) + end + + def regenerate_auth_token + self.auth_token = nil + generate_token + save! + end + + def already_likes? + !likes.empty? + end + + def self.send_welcome_email(id) + user = User.find(id) + UserMailer.welcome(user).deliver + end + + def self.search(query) + if query + where("username LIKE ?", "%#{query}%") + else + where("") + end + end +end diff --git a/app/views/comments/create.js.erb b/app/views/comments/create.js.erb new file mode 100644 index 000000000..f5f54773b --- /dev/null +++ b/app/views/comments/create.js.erb @@ -0,0 +1,6 @@ +(function() { + var $new_comment = $("<%= escape_javascript (render partial: 'shared/post_comment', locals: { comment: @comment }) %>").addClass('temp-new'); + $("#post-panels[post-id='<%= @post.id %>']").find('#comments-box').prepend($new_comment); + $('.temp-new').hide().show(3000).removeClass('temp-new'); + $("#new_comment").find("input[type='text']").val(""); +})(); \ No newline at end of file diff --git a/app/views/comments/delete.js.erb b/app/views/comments/delete.js.erb new file mode 100644 index 000000000..b034233a5 --- /dev/null +++ b/app/views/comments/delete.js.erb @@ -0,0 +1,3 @@ +(function() { + $("#comments-box").children().first().empty(); +})(); \ No newline at end of file diff --git a/app/views/friendings/index.html.erb b/app/views/friendings/index.html.erb new file mode 100644 index 000000000..f0c0eab59 --- /dev/null +++ b/app/views/friendings/index.html.erb @@ -0,0 +1,47 @@ +
+
+ <%= render partial: "shared/user_phototron", locals: { profile: current_user.profile} %> +
+
+
+ + + +
+
+

Friends

+
+
+ + <% current_user.friended_users.each do |user| %> +
+
+
+
+ +
+
+ + + <%= user.username %> + + + + <%= user.friended_users.count %> + +
+
+ <% if current_user.friended_users.include?(user) %> + <%= link_to "Remove", friending_path(current_user.friended_users.find(user.id)), method: :delete , class: "btn btn-outline-primary btn-md" %> + <% else %> + <%= link_to "Friend", user_friendings_path(user), method: :create , class: "btn btn-outline-primary btn-md" %> + <% end %> +
+
+
+
+ <% end %> +
+
\ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb new file mode 100644 index 000000000..6f2a82ea5 --- /dev/null +++ b/app/views/layouts/application.html.erb @@ -0,0 +1,46 @@ + + + + + + + ProjectDanebook + <%= csrf_meta_tags %> + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + + + + + + + + + + + <%= render "shared/nav" %> + + +
+
+ <% flash.each do |key, value| %> +
+ <%= value %> +
+ <% end %> +
+ +
+ +
+
+
+
+
+ <%= yield %> +
+ + + + + diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb new file mode 100644 index 000000000..cbd34d2e9 --- /dev/null +++ b/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/app/views/layouts/mailer.text.erb b/app/views/layouts/mailer.text.erb new file mode 100644 index 000000000..37f0bddbd --- /dev/null +++ b/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/app/views/likings/create.js.erb b/app/views/likings/create.js.erb new file mode 100644 index 000000000..d63175fb0 --- /dev/null +++ b/app/views/likings/create.js.erb @@ -0,0 +1,16 @@ +(function(){ + + ($($("#post-panels[post-id='<%= @post.id %>']").find($(".footer-bar")).find($('.row')).children()[1])).fadeIn(2000).empty(); + + $likes = $("
  • "); + + + $likes.text('<%= @post.likes.count %> likes..').attr("id", "likes-count"); + + $likes.insertAfter($($("#post-panels[post-id='<%= @post.id %>']").find($(".footer-bar")).find($('.row')).children()[0])); + + $likes.hide.show(2000); + + + +})(); \ No newline at end of file diff --git a/app/views/likings/destroy.js.erb b/app/views/likings/destroy.js.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/photos/index.html.erb b/app/views/photos/index.html.erb new file mode 100644 index 000000000..09489e5dd --- /dev/null +++ b/app/views/photos/index.html.erb @@ -0,0 +1,49 @@ +
    +
    + <%= render partial: "shared/user_phototron", locals: { profile: current_user.profile} %> +
    +
    +
    + + + +
    +
    +

    Photo Gallery

    + +
    + + <% @photos.each do |photo| %> +
    +
    +
    + <%= image_tag photo.avatar.url, style: "width: 100%", id: "photo" %> +
    +
    +

    <%= photo.label %>

    +

    <%= photo.created_at.to_s.slice(0,10) %>

    + <%= link_to "View", user_photo_path(current_user, photo), class: "btn btn-outline-danger btn-lg" %> +
    +
    +
    + <% end %> +
    + +
    +
    +

    Add A Photo

    + <%= form_for :photo, :url => user_photos_path(current_user), :method => "post" do |photo_fields| %> + <%= photo_fields.label :label , style: "color: black"%> +
    + <%= photo_fields.text_field :label, class: "form-control" %> +
    + <%= photo_fields.file_field :avatar, class: "btn btn-small btn-file" %> +
    + <%= photo_fields.submit class: "btn btn-primary active"%> + <% end %> +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/photos/show.html.erb b/app/views/photos/show.html.erb new file mode 100644 index 000000000..470431f96 --- /dev/null +++ b/app/views/photos/show.html.erb @@ -0,0 +1,48 @@ +
    +
    + <%= render partial: "shared/user_phototron", locals: { profile: current_user.profile} %> +
    +
    + +
    + + + +
    + +
    +

    Photo

    +
    + +
    +
    +
    +

    <%= @photo.label %>

    +
    +
    +
    + <%= image_tag @photo.avatar.url, style: "width: 100%", id: "photo" %> +
    +
    +
    +
    + <%= link_to "Set as Background Image", user_photo_path(current_user, @photo), class: "btn btn-outline-info btn-lg"%> +
    +
    + <%= link_to "Set as Profile Picture", + user_profiles_photos_path(current_user, photo_id: @photo.id), + :method => "post", + class: "btn btn-outline-warning btn-lg" %> +
    +
    + + +
    + + +
    +
    \ No newline at end of file diff --git a/app/views/posts/create.js.erb b/app/views/posts/create.js.erb new file mode 100644 index 000000000..dbf42ee0d --- /dev/null +++ b/app/views/posts/create.js.erb @@ -0,0 +1,5 @@ +var haha = (function(){ + $("#post-panels-box").prepend("<%= escape_javascript(render partial: 'shared/wall_post', locals: { post: @post}) %>"); + $("#post-panels-box").children().first().hide().show(3000); + $("#new_post").find("input[type='text']").val(""); +})(); \ No newline at end of file diff --git a/app/views/posts/destroy.js.erb b/app/views/posts/destroy.js.erb new file mode 100644 index 000000000..110543b29 --- /dev/null +++ b/app/views/posts/destroy.js.erb @@ -0,0 +1,4 @@ +var hello4 = (function() { + console.log("hello"); + $("#post-panels[post-id='<%= @post.id%>']").hide(3000); +})(); \ No newline at end of file diff --git a/app/views/profiles/friends.html.erb b/app/views/profiles/friends.html.erb new file mode 100644 index 000000000..ca70b6f52 --- /dev/null +++ b/app/views/profiles/friends.html.erb @@ -0,0 +1,192 @@ + + + + + + + + + + + + + + +
    +
    + +
    + +
    + +
    +
    +
    +
    +

    Friends

    +
    +
    + +
    +
    +
    +
    +
    +
    + friend_picture +
    +
    + Hermoine Granger + 432 Friends +   +
    +
    + +
    +
    +
    +
    + + +
    +
    +
    +
    + friend_picture +
    +
    + Hermoine Granger + 432 Friends +   +
    +
    + +
    +
    +
    +
    +
    +
    + +
    +
    + +
    +
    +
    +
    + friend_picture +
    +
    + Hermoine Granger + 432 Friends +   +
    +
    + +
    +
    +
    +
    + + +
    +
    +
    +
    + friend_picture +
    +
    + Hermoine Granger + 432 Friends +   +
    +
    + +
    +
    +
    +
    + +
    +
    + +
    +
    +
    +
    +
    +
    + friend_picture +
    +
    + Hermoine Granger + 432 Friends +   +
    +
    + +
    +
    +
    +
    + + +
    +
    +
    +
    + friend_picture +
    +
    + Hermoine Granger + 432 Friends +   +
    +
    + +
    +
    +
    +
    +
    + + + +
    + +
    + + \ No newline at end of file diff --git a/app/views/profiles/index.html.erb b/app/views/profiles/index.html.erb new file mode 100644 index 000000000..f242c8c9c --- /dev/null +++ b/app/views/profiles/index.html.erb @@ -0,0 +1,59 @@ +
    +
    + <%= render partial: "shared/user_phototron", locals: { profile: current_user.profile} %> +
    +
    + +
    + + + +
    +
    +

    About

    +
    +
    +

    Basic Information

    +
    +
      +
    • Birthday:
    • +
    • College:
    • +
    • Hometown:
    • +
    • Currently Lives:
    • +
    +
    +
    +
      +
    • <%= @profile.month %>, <%= @profile.day %>, <%= @profile.year %>
    • +
    • <%= @profile.college %>
    • +
    • <%= @profile.home_town %>
    • +
    • <%= @profile.currently_lives %>
    • +
    +
    + +

    Contact Information

    +
    +
      +
    • Email:
    • +
    • Telephone:
    • +
    +
    +
    +
      +
    • <%= current_user.email %>
    • +
    • <%= @profile.phone_number %>
    • +
    +
    +
    + +
    +

    Words to Live By

    +

    Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.

    +

    About Me

    +

    Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/profiles/photos.html.erb b/app/views/profiles/photos.html.erb new file mode 100644 index 000000000..8d61b2243 --- /dev/null +++ b/app/views/profiles/photos.html.erb @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + +
    +
    + +
    + +
    + +
    +
    +
    +
    +
    +

    Photos

    +
    + +
    +
    + +
    + +
    +
    + friend_picture +
    +
    + +
    +
    + friend_picture +
    +
    + +
    +
    + friend_picture +
    +
    + +
    +
    + friend_picture +
    +
    + +
    + +
    + +
    +
    + friend_picture +
    +
    + +
    +
    + friend_picture +
    +
    + +
    +
    + friend_picture +
    +
    + +
    +
    + friend_picture +
    +
    + +
    + +
    + +
    +
    + friend_picture +
    +
    + +
    +
    + friend_picture +
    +
    + +
    +
    + friend_picture +
    +
    + +
    +
    + friend_picture +
    +
    + +
    + +
    + +
    +
    + friend_picture +
    +
    + +
    +
    + friend_picture +
    +
    + +
    +
    + friend_picture +
    +
    + +
    +
    + friend_picture +
    +
    + +
    + + + + + + +
    + + + + +
    + + \ No newline at end of file diff --git a/app/views/profiles/show.html.erb b/app/views/profiles/show.html.erb new file mode 100644 index 000000000..20b28fbd1 --- /dev/null +++ b/app/views/profiles/show.html.erb @@ -0,0 +1,71 @@ +
    +
    + <%= render partial: "shared/user_phototron", locals: { profile: current_user.profile} %> +
    +
    + +
    + + + +
    +
    +

    About

    +
    + <%= simple_form_for current_user.profile, :url => user_profiles_path(current_user) do |f| %> + <%= f.input :college, label: 'Where did you go for college?' %> + <%= f.input :home_town, label: 'Where were you born?' %> + <%= f.input :currently_lives, placeholder: 'Where do you currently live?' %> + <%= f.input :phone_number, inline_label: 'Phone number so ladies can slide in your DM' %> + <%= f.button :submit, class: "btn btn-success"%> + <% end %> +
    +
    + +
    +
    +
    +
    +

    Basic Information

    +
    +
      +
    • Birthday:
    • +
    • College:
    • +
    • Hometown:
    • +
    • Currently Lives:
    • +
    +
    +
    +
      +
    • <%= @profile.month %>, <%= @profile.day %>, <%= @profile.year %>
    • +
    • <%= @profile.college %>
    • +
    • <%= @profile.home_town %>
    • +
    • <%= @profile.currently_lives %>
    • +
    +
    + +

    Contact Information

    +
    +
      +
    • Email:
    • +
    • Telephone:
    • +
    +
    +
    +
      +
    • <%= current_user.email %>
    • +
    • <%= @profile.phone_number %>
    • +
    +
    +
    +
    +

    Words to Live By

    +

    Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.

    +

    About Me

    +

    Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.

    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb new file mode 100644 index 000000000..d8c61332c --- /dev/null +++ b/app/views/sessions/new.html.erb @@ -0,0 +1,14 @@ +<%= form_tag session_path do %> + + <%= label_tag do %> + Email + <%= text_field_tag :email %> + <% end %> + + <%= label_tag do %> + Password + <%= password_field_tag :password %> + <% end %> + + <%= submit_tag "Log in" %> +<% end %> \ No newline at end of file diff --git a/app/views/shared/_nav.html.erb b/app/views/shared/_nav.html.erb new file mode 100644 index 000000000..5c5c03349 --- /dev/null +++ b/app/views/shared/_nav.html.erb @@ -0,0 +1,31 @@ + \ No newline at end of file diff --git a/app/views/shared/_nav_login.html.erb b/app/views/shared/_nav_login.html.erb new file mode 100644 index 000000000..b6bdf527f --- /dev/null +++ b/app/views/shared/_nav_login.html.erb @@ -0,0 +1,48 @@ +<% if !signed_in_user? %> + <%= form_tag session_path do %> + +
    +
    +
    + <%= label_tag :email, "Email:", class: "control-label"%> +
    +
    + + <%= text_field_tag :email, nil, class: "form-control", style: "width: 150px" %> +
    + +
    + <%= label_tag :password, "Password:", class: "control-label"%> +
    + +
    + + <%= password_field_tag :password, nil, class: "form-control"%> +
    + +
    + <%= submit_tag "Log in", class: "btn btn-outline-success" %> +
    +
    +
    + + <% end %> + +<% else %> +
    +
    +
    +
    +
    + <%= link_to current_user.username, user_path(current_user), class: "btn btn-outline-success" %> +
    +
    + <%= link_to "Logout", logout_path, method: :delete, data: {confirm: "Are you sure you want to log out?"}, class: "btn btn-outline-success"%> +
    +
    + +
    +<% end %> + + + diff --git a/app/views/shared/_post_comment.html.erb b/app/views/shared/_post_comment.html.erb new file mode 100644 index 000000000..64c860798 --- /dev/null +++ b/app/views/shared/_post_comment.html.erb @@ -0,0 +1,13 @@ +<% if comment.persisted? %> +
  • +
    + + <%= User.find(comment.user_id).username %> says: + <%= comment.description %> + +
    +
    + X +
    +
  • +<% end %> diff --git a/app/views/shared/_post_comment_form.html.erb b/app/views/shared/_post_comment_form.html.erb new file mode 100644 index 000000000..7b8f555e3 --- /dev/null +++ b/app/views/shared/_post_comment_form.html.erb @@ -0,0 +1,10 @@ +<%= form_for([post, post.comments.build], remote: true) do |f| %> + + + <%= f.label :description %> + <%= f.text_field :description %> + + + <%= f.submit "Comment"%> + +<% end %> \ No newline at end of file diff --git a/app/views/shared/_user_nav_bar.html.erb b/app/views/shared/_user_nav_bar.html.erb new file mode 100644 index 000000000..7100f2582 --- /dev/null +++ b/app/views/shared/_user_nav_bar.html.erb @@ -0,0 +1,45 @@ + + \ No newline at end of file diff --git a/app/views/shared/_user_phototron.html.erb b/app/views/shared/_user_phototron.html.erb new file mode 100644 index 000000000..f713ea860 --- /dev/null +++ b/app/views/shared/_user_phototron.html.erb @@ -0,0 +1,34 @@ +
    +
    +
    +
    + <% unless profile.nil?%> + <% if !(profile.photo.nil?) %> + <%= image_tag profile.photo.avatar.url(:thumb), style: "display:block; margin:auto;" %> + <% else %> + <%= image_tag "http://learngroup.org/assets/images/logos/default_male.jpg" %> + <% end %> + <% end %> +
    +
    +

    <%= current_user.username %>

    +
    +
    +
    + +
    +
    +
    +
    +

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.

    +
    Someone famous in Source Title
    +
    +
    +

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.

    +
    Someone famous in Source Title
    +
    +
    +
    +
    +
    + diff --git a/app/views/shared/_users_form.html.erb b/app/views/shared/_users_form.html.erb new file mode 100644 index 000000000..1d97d5a92 --- /dev/null +++ b/app/views/shared/_users_form.html.erb @@ -0,0 +1,130 @@ +<%= form_for user do |user_fields| %> + <% if user.errors.any? %> +
    +

    <%= pluralize(user.errors.count, "error") %> prohibited this user from being saved:

    + + +
    + <% end %> + + <%= fields_for profile do |fa| %> + + <% if profile.errors.any? %> +
    +

    <%= pluralize(profile.errors.count, "error") %> prohibited this user's profile from being saved:

    + +
    + <% end %> + +
    + +
    +
    +
    + <%=fa.label :first_name , class: "btn btn-primary"%> +
    +
    + <%=fa.text_field :first_name , class: "form-control"%> +
    +
    + +
    +
    + <%=fa.label :last_name, class: "btn btn-primary" %> +
    +
    + <%=fa.text_field :last_name, class: "form-control" %> +
    +
    + +
    +
    + <%=fa.label :month , class: "btn btn-primary"%> +
    +
    + <%=fa.text_field :month, class: "form-control" %> +
    +
    + +
    +
    + <%=fa.label :day , class: "btn btn-primary"%> +
    +
    + <%=fa.number_field :day, class: "form-control" %> +
    +
    + +
    +
    + <%=fa.label :year , class: "btn btn-primary"%> +
    +
    + <%=fa.number_field :year, class: "form-control" %> +
    +
    + +
    +
    + <%=fa.label :gender, class: "btn btn-primary" %> +
    +
    + <%= fa.select(:gender, [['Female',"female"], ['Male',"male"]], {}, { required: 'true', class: 'form-control'}) %> +
    +
    + <% end %> +
    + +
    +
    +
    + <%= user_fields.label :username , class: "btn btn-primary"%> +
    +
    + <%= user_fields.text_field :username, class: "form-control" %> +
    +
    + +
    +
    + <%= user_fields.label :email, class: "btn btn-primary" %> +
    +
    + <%= user_fields.text_field :email, class: "form-control" %> +
    +
    + +
    +
    + <%= user_fields.label :password , class: "btn btn-primary"%> +
    +
    + <%= user_fields.password_field :password, class: "form-control" %> +
    +
    + +
    +
    + <%= user_fields.label :password_confirmation, class: "btn btn-primary" %> +
    +
    + <%= user_fields.password_field :password_confirmation, class: "form-control" %> +
    +
    + +
    + <%= user_fields.submit "Sign Up", class: "btn btn-success", style: "width: 400px"%> +
    + +
    +
    +
    +<% end %> \ No newline at end of file diff --git a/app/views/shared/_wall_post.html.erb b/app/views/shared/_wall_post.html.erb new file mode 100644 index 000000000..fda7daad0 --- /dev/null +++ b/app/views/shared/_wall_post.html.erb @@ -0,0 +1,76 @@ + +
    +
    +
    +
    +
    +
    + <% if User.find(post.user_id).profile.photo %> + + <%= image_tag User.find(post.user_id).profile.photo.avatar.url(:small) %> + <% else %> + <%= image_tag "http://learngroup.org/assets/images/logos/default_male.jpg", style: "width: 300px, height: 300px" %> + <% end %> +
    +
    + <%= link_to "#{User.find(post.user_id).profile.first_name} #{User.find(post.user_id).profile.last_name}", user_path(User.find(post.user_id)) %> + +
    +
    +
    +
    +
    +
    Posted on <%= post.created_at %> +
    +
    +
    + +
    +
    +

    <%= post.description %>

    + + <% if post.photo %> + <%= image_tag post.photo.avatar.url(:medium) %> + <% end %> +
    +
    + + +
    diff --git a/app/views/shared/_wall_post_form.html.erb b/app/views/shared/_wall_post_form.html.erb new file mode 100644 index 000000000..a996c70b2 --- /dev/null +++ b/app/views/shared/_wall_post_form.html.erb @@ -0,0 +1,29 @@ +<%= simple_form_for @post, :url => user_posts_path(current_user), remote: true do |f| %> +
    +
    +
    +
    +

    Post

    +
    +
    +
    + <%= f.text_area :description , style: "width: 80%"%> +
    + + +
    + + +
    +<% end %> \ No newline at end of file diff --git a/app/views/timelines/index.html.erb b/app/views/timelines/index.html.erb new file mode 100644 index 000000000..0beca4d65 --- /dev/null +++ b/app/views/timelines/index.html.erb @@ -0,0 +1,23 @@ +
    +



    + + \ No newline at end of file diff --git a/app/views/user_mailer/trigger.html.erb b/app/views/user_mailer/trigger.html.erb new file mode 100644 index 000000000..96f85f8aa --- /dev/null +++ b/app/views/user_mailer/trigger.html.erb @@ -0,0 +1,16 @@ +

    Triggered! No, not the meme. I mean that you have posted or commented somewhere.

    + +

    + Hi <%= @user.username %> + + You posted at: + <%= @post.created_at %> on <%= @user.username %>'s wall with the following _::_ + +
    + + <%= @post.description %> +

    + +

    + View your account at <%= link_to "#{user_url(@user.id)}", user_url(@user.id) %> +

    \ No newline at end of file diff --git a/app/views/user_mailer/trigger.text.erb b/app/views/user_mailer/trigger.text.erb new file mode 100644 index 000000000..5ff1780d4 --- /dev/null +++ b/app/views/user_mailer/trigger.text.erb @@ -0,0 +1,7 @@ +Triggered! No, not the meme. I mean that you have posted or commented somewhere. + +Hi <%= @user.username %>, + +You posted at: <%= @post.created_at %> on <%= @user.username %>'s wall with the following _::_ <%= @post.description %> + +View your account at <%= link_to "#{user_url(@user.id)}", user_url(@user.id) %> \ No newline at end of file diff --git a/app/views/user_mailer/welcome.html.erb b/app/views/user_mailer/welcome.html.erb new file mode 100644 index 000000000..d1e2e839f --- /dev/null +++ b/app/views/user_mailer/welcome.html.erb @@ -0,0 +1,9 @@ +

    Welcome!

    + +

    + Hi <%= @user.username %>, welcome to CrudCrud! +

    + +

    + View your account at <%= link_to "#{user_url(@user.id)}", user_url(@user.id) %> +

    \ No newline at end of file diff --git a/app/views/user_mailer/welcome.text.erb b/app/views/user_mailer/welcome.text.erb new file mode 100644 index 000000000..cda6ac193 --- /dev/null +++ b/app/views/user_mailer/welcome.text.erb @@ -0,0 +1,5 @@ +Welcome! + +Hi <%= @user.username %>, welcome to CrudCrud! + +View your account at <%= link_to "#{user_url(@user.id)}", user_url(@user.id) %> \ No newline at end of file diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb new file mode 100644 index 000000000..2c7c8d21d --- /dev/null +++ b/app/views/users/index.html.erb @@ -0,0 +1,23 @@ +
    +
    +
    +
    +
    + +

    + These users popped up in your query search :: +

    + + \ No newline at end of file diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb new file mode 100644 index 000000000..a5f42f8c3 --- /dev/null +++ b/app/views/users/new.html.erb @@ -0,0 +1,42 @@ +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + +

    Connect with all your friends!

    See photos and updates in your news feed
    Post your status for the world to see from your profile
    Get in touch with your friends by "friending" them
    Like things because you're a positive person!
    +
    + +
    +
    +
    +

    Sign Up

    +
    +
    + <%= render partial: "shared/users_form", locals: {user: @user, profile: @profile} %> +
    +
    +
    +
    +
    +
    + \ No newline at end of file diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb new file mode 100644 index 000000000..5f2e70124 --- /dev/null +++ b/app/views/users/show.html.erb @@ -0,0 +1,110 @@ + +
    +
    + <%= render partial: "shared/user_phototron", locals: { profile: @profile} %> +
    +
    + +
    + + + +
    +
    + +
    +

    About Me

    + + + + + + + + + + + + + + + + + + + + + + + + + +
    Category
    Born On<%= @profile.month %>, <%= @profile.day %>, <%= @profile.year %>
    Education<%= @profile.college %>
    Currently<%= @profile.currently_lives %>
    Telephone1-800-NONEYA
    +
    + +
    +

    Photos

    +
    +
    + <% @user.photos.each do |photo| %> +
    +
    + <%= image_tag photo.avatar.url, styles: :small, style: "width: 100%", id: "photo" %> +
    +
    + <% end %> +
    +
    +
    + +
    +

    Friends

    +
    +
    + <% @user.friended_users.each do |user| %> +
    + +
    + <% end %> +
    +
    +
    + + +
    +
    +
    +

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.

    +
    Someone famous in Source Title
    +
    +
    +
    + +
    +
    +
    +

    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.

    +
    Someone famous in Source Title
    +
    +
    +
    +
    + +
    +
    + <%= render "shared/wall_post_form"%> +
    + +
    + <% if current_user && current_user.id == @user.id %> + <% @posts.reverse.each do |post| %> + <%= render partial: "shared/wall_post", locals: { post: post} %> + <% end %> + <% end %> +
    + +
    + +
    \ No newline at end of file diff --git a/assignment_danebook_homepage b/assignment_danebook_homepage new file mode 160000 index 000000000..7c5e235f7 --- /dev/null +++ b/assignment_danebook_homepage @@ -0,0 +1 @@ +Subproject commit 7c5e235f7f86d138e15f9d08b9b620f7cab6c659 diff --git a/bin/bundle b/bin/bundle new file mode 100755 index 000000000..66e9889e8 --- /dev/null +++ b/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +load Gem.bin_path('bundler', 'bundle') diff --git a/bin/delayed_job b/bin/delayed_job new file mode 100755 index 000000000..edf195985 --- /dev/null +++ b/bin/delayed_job @@ -0,0 +1,5 @@ +#!/usr/bin/env ruby + +require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment')) +require 'delayed/command' +Delayed::Command.new(ARGV).daemonize diff --git a/bin/rails b/bin/rails new file mode 100755 index 000000000..073966023 --- /dev/null +++ b/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path('../config/application', __dir__) +require_relative '../config/boot' +require 'rails/commands' diff --git a/bin/rake b/bin/rake new file mode 100755 index 000000000..17240489f --- /dev/null +++ b/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative '../config/boot' +require 'rake' +Rake.application.run diff --git a/bin/setup b/bin/setup new file mode 100755 index 000000000..e620b4dad --- /dev/null +++ b/bin/setup @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby +require 'pathname' +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/bin/update b/bin/update new file mode 100755 index 000000000..a8e4462f2 --- /dev/null +++ b/bin/update @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +require 'pathname' +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/config.ru b/config.ru new file mode 100644 index 000000000..f7ba0b527 --- /dev/null +++ b/config.ru @@ -0,0 +1,5 @@ +# This file is used by Rack-based servers to start the application. + +require_relative 'config/environment' + +run Rails.application diff --git a/config/application.rb b/config/application.rb new file mode 100644 index 000000000..af54ad3ac --- /dev/null +++ b/config/application.rb @@ -0,0 +1,15 @@ +require_relative 'boot' + +require 'rails/all' + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module ProjectDanebook + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + end +end diff --git a/config/boot.rb b/config/boot.rb new file mode 100644 index 000000000..30f5120df --- /dev/null +++ b/config/boot.rb @@ -0,0 +1,3 @@ +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) + +require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/config/cable.yml b/config/cable.yml new file mode 100644 index 000000000..0bbde6f74 --- /dev/null +++ b/config/cable.yml @@ -0,0 +1,9 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: redis://localhost:6379/1 diff --git a/config/database.yml b/config/database.yml new file mode 100644 index 000000000..3bd0fe3c4 --- /dev/null +++ b/config/database.yml @@ -0,0 +1,31 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +# +default: &default + adapter: postgresql + pool: 5 + timeout: 5000 + +development: + adapter: postgresql + database: db/project_development + pool: 5 + timeout: 5000 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + adapter: postgresql + database: db/project_test + pool: 5 + timeout: 5000 + +production: + adapter: postgresql + database: db/project_production + pool: 5 + timeout: 5000 diff --git a/config/environment.rb b/config/environment.rb new file mode 100644 index 000000000..426333bb4 --- /dev/null +++ b/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative 'application' + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb new file mode 100644 index 000000000..555fa05a8 --- /dev/null +++ b/config/environments/development.rb @@ -0,0 +1,82 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + #letter + + config.action_mailer.delivery_method = :letter_opener + + config.action_mailer.default_url_options = { :host => "thebombdot.com" } + Paperclip.options[:command_path] = "/user/local/bin" + + config.paperclip_defaults = { + + # Don't forget to make S3 your storage option! + :storage => :s3, + + :s3_credentials => { + + # put your host name here if needed + # see the reading below for more details + # NOTE: This must be the correct region for YOU + :s3_host_name => "s3-us-west-2.amazonaws.com", + :s3_region => "us-west-2", + + # NOTE: these lines are changed to use secrets.yml + # from the examples (which use ENV vars instead) + :bucket => Rails.application.secrets.s3_bucket_name, + :access_key_id => Rails.application.secrets.aws_access_key_id, + :secret_access_key => Rails.application.secrets.aws_secret_access_key + } + } + + config.cache_classes = false + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + if Rails.root.join('tmp/caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => 'public, max-age=172800' + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = false + + config.action_mailer.perform_caching = false + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker +end diff --git a/config/environments/production.rb b/config/environments/production.rb new file mode 100644 index 000000000..ce7b0b02c --- /dev/null +++ b/config/environments/production.rb @@ -0,0 +1,118 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + config.serve_static_assets = true + + config.action_mailer.smtp_settings = { + :address => 'smtp.sendgrid.net', + :port => '587', + :authentication => :plain, + :user_name => ENV['SENDGRID_USERNAME'], + :password => ENV['SENDGRID_PASSWORD'], + :domain => 'heroku.com', + :enable_starttls_auto => true + } + config.action_mailer.delivery_method ||= :smtp + + config.action_mailer.default_url_options = { :host => 'daneb00k.herokuapp.com'} + + config.paperclip_defaults = { + :storage => :s3, + :s3_credentials => { + + # put your host name here if needed + # see the reading below for more details + # NOTE: This must be the correct region for YOU + :s3_host_name => "s3-us-west-2.amazonaws.com", + :s3_region => "us-west-2", + + # NOTE: these lines are changed to use secrets.yml + # from the examples (which use ENV vars instead) + :bucket => Rails.application.secrets.s3_bucket_name, + :access_key_id => Rails.application.secrets.aws_access_key_id, + :secret_access_key => Rails.application.secrets.aws_secret_access_key + } + } + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = false + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "project_danebook_#{Rails.env}" + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/config/environments/test.rb b/config/environments/test.rb new file mode 100644 index 000000000..30587ef6d --- /dev/null +++ b/config/environments/test.rb @@ -0,0 +1,42 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Do not eager load code on boot. This avoids loading your whole application + # just for the purpose of running a single test. If you are using a tool that + # preloads Rails for running tests, you may have to set it to true. + config.eager_load = false + + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => 'public, max-age=3600' + } + + # Show full error reports and disable caching. + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates. + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + config.action_mailer.perform_caching = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true +end diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb new file mode 100644 index 000000000..51639b67a --- /dev/null +++ b/config/initializers/application_controller_renderer.rb @@ -0,0 +1,6 @@ +# Be sure to restart your server when you modify this file. + +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb new file mode 100644 index 000000000..01ef3e663 --- /dev/null +++ b/config/initializers/assets.rb @@ -0,0 +1,11 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path +# Rails.application.config.assets.paths << Emoji.images_path + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# Rails.application.config.assets.precompile += %w( search.js ) diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb new file mode 100644 index 000000000..59385cdf3 --- /dev/null +++ b/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb new file mode 100644 index 000000000..5a6a32d37 --- /dev/null +++ b/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 000000000..4a994e1e7 --- /dev/null +++ b/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Configure sensitive parameters which will be filtered from the log file. +Rails.application.config.filter_parameters += [:password] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb new file mode 100644 index 000000000..ac033bf9d --- /dev/null +++ b/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb new file mode 100644 index 000000000..dc1899682 --- /dev/null +++ b/config/initializers/mime_types.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff --git a/config/initializers/new_framework_defaults.rb b/config/initializers/new_framework_defaults.rb new file mode 100644 index 000000000..0706cafd4 --- /dev/null +++ b/config/initializers/new_framework_defaults.rb @@ -0,0 +1,24 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains migration options to ease your Rails 5.0 upgrade. +# +# Read the Rails 5.0 release notes for more info on each option. + +# Enable per-form CSRF tokens. Previous versions had false. +Rails.application.config.action_controller.per_form_csrf_tokens = true + +# Enable origin-checking CSRF mitigation. Previous versions had false. +Rails.application.config.action_controller.forgery_protection_origin_check = true + +# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`. +# Previous versions had false. +ActiveSupport.to_time_preserves_timezone = true + +# Require `belongs_to` associations by default. Previous versions had false. +Rails.application.config.active_record.belongs_to_required_by_default = true + +# Do not halt callback chains when a callback returns false. Previous versions had true. +ActiveSupport.halt_callback_chains_on_return_false = false + +# Configure SSL options to enable HSTS with subdomains. Previous versions had false. +Rails.application.config.ssl_options = { hsts: { subdomains: true } } diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb new file mode 100644 index 000000000..f2d118131 --- /dev/null +++ b/config/initializers/session_store.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.session_store :cookie_store, key: '_project_danebook_session' diff --git a/config/initializers/simple_form.rb b/config/initializers/simple_form.rb new file mode 100644 index 000000000..934487af6 --- /dev/null +++ b/config/initializers/simple_form.rb @@ -0,0 +1,165 @@ +# Use this setup block to configure all options available in SimpleForm. +SimpleForm.setup do |config| + # Wrappers are used by the form builder to generate a + # complete input. You can remove any component from the + # wrapper, change the order or even add your own to the + # stack. The options given below are used to wrap the + # whole input. + config.wrappers :default, class: :input, + hint_class: :field_with_hint, error_class: :field_with_errors do |b| + ## Extensions enabled by default + # Any of these extensions can be disabled for a + # given input by passing: `f.input EXTENSION_NAME => false`. + # You can make any of these extensions optional by + # renaming `b.use` to `b.optional`. + + # Determines whether to use HTML5 (:email, :url, ...) + # and required attributes + b.use :html5 + + # Calculates placeholders automatically from I18n + # You can also pass a string as f.input placeholder: "Placeholder" + b.use :placeholder + + ## Optional extensions + # They are disabled unless you pass `f.input EXTENSION_NAME => true` + # to the input. If so, they will retrieve the values from the model + # if any exists. If you want to enable any of those + # extensions by default, you can change `b.optional` to `b.use`. + + # Calculates maxlength from length validations for string inputs + b.optional :maxlength + + # Calculates pattern from format validations for string inputs + b.optional :pattern + + # Calculates min and max from length validations for numeric inputs + b.optional :min_max + + # Calculates readonly automatically from readonly attributes + b.optional :readonly + + ## Inputs + b.use :label_input + b.use :hint, wrap_with: { tag: :span, class: :hint } + b.use :error, wrap_with: { tag: :span, class: :error } + + ## full_messages_for + # If you want to display the full error message for the attribute, you can + # use the component :full_error, like: + # + # b.use :full_error, wrap_with: { tag: :span, class: :error } + end + + # The default wrapper to be used by the FormBuilder. + config.default_wrapper = :default + + # Define the way to render check boxes / radio buttons with labels. + # Defaults to :nested for bootstrap config. + # inline: input + label + # nested: label > input + config.boolean_style = :nested + + # Default class for buttons + config.button_class = 'btn' + + # Method used to tidy up errors. Specify any Rails Array method. + # :first lists the first message for each field. + # Use :to_sentence to list all errors for each field. + # config.error_method = :first + + # Default tag used for error notification helper. + config.error_notification_tag = :div + + # CSS class to add for error notification helper. + config.error_notification_class = 'error_notification' + + # ID to add for error notification helper. + # config.error_notification_id = nil + + # Series of attempts to detect a default label method for collection. + # config.collection_label_methods = [ :to_label, :name, :title, :to_s ] + + # Series of attempts to detect a default value method for collection. + # config.collection_value_methods = [ :id, :to_s ] + + # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none. + # config.collection_wrapper_tag = nil + + # You can define the class to use on all collection wrappers. Defaulting to none. + # config.collection_wrapper_class = nil + + # You can wrap each item in a collection of radio/check boxes with a tag, + # defaulting to :span. + # config.item_wrapper_tag = :span + + # You can define a class to use in all item wrappers. Defaulting to none. + # config.item_wrapper_class = nil + + # How the label text should be generated altogether with the required text. + # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" } + + # You can define the class to use on all labels. Default is nil. + # config.label_class = nil + + # You can define the default class to be used on forms. Can be overriden + # with `html: { :class }`. Defaulting to none. + # config.default_form_class = nil + + # You can define which elements should obtain additional classes + # config.generate_additional_classes_for = [:wrapper, :label, :input] + + # Whether attributes are required by default (or not). Default is true. + # config.required_by_default = true + + # Tell browsers whether to use the native HTML5 validations (novalidate form option). + # These validations are enabled in SimpleForm's internal config but disabled by default + # in this configuration, which is recommended due to some quirks from different browsers. + # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations, + # change this configuration to true. + config.browser_validations = false + + # Collection of methods to detect if a file type was given. + # config.file_methods = [ :mounted_as, :file?, :public_filename ] + + # Custom mappings for input types. This should be a hash containing a regexp + # to match as key, and the input type that will be used when the field name + # matches the regexp as value. + # config.input_mappings = { /count/ => :integer } + + # Custom wrappers for input types. This should be a hash containing an input + # type as key and the wrapper that will be used for all inputs with specified type. + # config.wrapper_mappings = { string: :prepend } + + # Namespaces where SimpleForm should look for custom input classes that + # override default inputs. + # config.custom_inputs_namespaces << "CustomInputs" + + # Default priority for time_zone inputs. + # config.time_zone_priority = nil + + # Default priority for country inputs. + # config.country_priority = nil + + # When false, do not use translations for labels. + # config.translate_labels = true + + # Automatically discover new inputs in Rails' autoload path. + # config.inputs_discovery = true + + # Cache SimpleForm inputs discovery + # config.cache_discovery = !Rails.env.development? + + # Default class for inputs + # config.input_class = nil + + # Define the default class of the input wrapper of the boolean input. + config.boolean_label_class = 'checkbox' + + # Defines if the default input wrapper class should be included in radio + # collection wrappers. + # config.include_default_input_wrapper_class = true + + # Defines which i18n scope will be used in Simple Form. + # config.i18n_scope = 'simple_form' +end diff --git a/config/initializers/simple_form_bootstrap.rb b/config/initializers/simple_form_bootstrap.rb new file mode 100644 index 000000000..109d29a37 --- /dev/null +++ b/config/initializers/simple_form_bootstrap.rb @@ -0,0 +1,149 @@ +# Use this setup block to configure all options available in SimpleForm. +SimpleForm.setup do |config| + config.error_notification_class = 'alert alert-danger' + config.button_class = 'btn btn-default' + config.boolean_label_class = nil + + config.wrappers :vertical_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| + b.use :html5 + b.use :placeholder + b.optional :maxlength + b.optional :pattern + b.optional :min_max + b.optional :readonly + b.use :label, class: 'control-label' + + b.use :input, class: 'form-control' + b.use :error, wrap_with: { tag: 'span', class: 'help-block' } + b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + end + + config.wrappers :vertical_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| + b.use :html5 + b.use :placeholder + b.optional :maxlength + b.optional :readonly + b.use :label, class: 'control-label' + + b.use :input + b.use :error, wrap_with: { tag: 'span', class: 'help-block' } + b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + end + + config.wrappers :vertical_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| + b.use :html5 + b.optional :readonly + + b.wrapper tag: 'div', class: 'checkbox' do |ba| + ba.use :label_input + end + + b.use :error, wrap_with: { tag: 'span', class: 'help-block' } + b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + end + + config.wrappers :vertical_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| + b.use :html5 + b.optional :readonly + b.use :label, class: 'control-label' + b.use :input + b.use :error, wrap_with: { tag: 'span', class: 'help-block' } + b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + end + + config.wrappers :horizontal_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| + b.use :html5 + b.use :placeholder + b.optional :maxlength + b.optional :pattern + b.optional :min_max + b.optional :readonly + b.use :label, class: 'col-sm-3 control-label' + + b.wrapper tag: 'div', class: 'col-sm-9' do |ba| + ba.use :input, class: 'form-control' + ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } + ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + end + end + + config.wrappers :horizontal_file_input, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| + b.use :html5 + b.use :placeholder + b.optional :maxlength + b.optional :readonly + b.use :label, class: 'col-sm-3 control-label' + + b.wrapper tag: 'div', class: 'col-sm-9' do |ba| + ba.use :input + ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } + ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + end + end + + config.wrappers :horizontal_boolean, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| + b.use :html5 + b.optional :readonly + + b.wrapper tag: 'div', class: 'col-sm-offset-3 col-sm-9' do |wr| + wr.wrapper tag: 'div', class: 'checkbox' do |ba| + ba.use :label_input + end + + wr.use :error, wrap_with: { tag: 'span', class: 'help-block' } + wr.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + end + end + + config.wrappers :horizontal_radio_and_checkboxes, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| + b.use :html5 + b.optional :readonly + + b.use :label, class: 'col-sm-3 control-label' + + b.wrapper tag: 'div', class: 'col-sm-9' do |ba| + ba.use :input + ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } + ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + end + end + + config.wrappers :inline_form, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| + b.use :html5 + b.use :placeholder + b.optional :maxlength + b.optional :pattern + b.optional :min_max + b.optional :readonly + b.use :label, class: 'sr-only' + + b.use :input, class: 'form-control' + b.use :error, wrap_with: { tag: 'span', class: 'help-block' } + b.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + end + + config.wrappers :multi_select, tag: 'div', class: 'form-group', error_class: 'has-error' do |b| + b.use :html5 + b.optional :readonly + b.use :label, class: 'control-label' + b.wrapper tag: 'div', class: 'form-inline' do |ba| + ba.use :input, class: 'form-control' + ba.use :error, wrap_with: { tag: 'span', class: 'help-block' } + ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' } + end + end + # Wrappers for forms and inputs using the Bootstrap toolkit. + # Check the Bootstrap docs (http://getbootstrap.com) + # to learn about the different styles for forms and inputs, + # buttons and other elements. + config.default_wrapper = :vertical_form + config.wrapper_mappings = { + check_boxes: :vertical_radio_and_checkboxes, + radio_buttons: :vertical_radio_and_checkboxes, + file: :vertical_file_input, + boolean: :vertical_boolean, + datetime: :multi_select, + date: :multi_select, + time: :multi_select + } +end diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb new file mode 100644 index 000000000..bbfc3961b --- /dev/null +++ b/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/config/locales/en.yml b/config/locales/en.yml new file mode 100644 index 000000000..065395716 --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,23 @@ +# Files in the config/locales directory are used for internationalization +# and are automatically loaded by Rails. If you want to use locales other +# than English, add the necessary files in this directory. +# +# To use the locales, use `I18n.t`: +# +# I18n.t 'hello' +# +# In views, this is aliased to just `t`: +# +# <%= t('hello') %> +# +# To use a different locale, set it with `I18n.locale`: +# +# I18n.locale = :es +# +# This would use the information in config/locales/es.yml. +# +# To learn more, please read the Rails Internationalization guide +# available at http://guides.rubyonrails.org/i18n.html. + +en: + hello: "Hello world" diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml new file mode 100644 index 000000000..237438334 --- /dev/null +++ b/config/locales/simple_form.en.yml @@ -0,0 +1,31 @@ +en: + simple_form: + "yes": 'Yes' + "no": 'No' + required: + text: 'required' + mark: '*' + # You can uncomment the line below if you need to overwrite the whole required html. + # When using html, text and mark won't be used. + # html: '*' + error_notification: + default_message: "Please review the problems below:" + # Examples + # labels: + # defaults: + # password: 'Password' + # user: + # new: + # email: 'E-mail to sign in.' + # edit: + # email: 'E-mail.' + # hints: + # defaults: + # username: 'User name to sign in.' + # password: 'No special characters, please.' + # include_blanks: + # defaults: + # age: 'Rather not say' + # prompts: + # defaults: + # age: 'Select your age' diff --git a/config/puma.rb b/config/puma.rb new file mode 100644 index 000000000..c7f311f81 --- /dev/null +++ b/config/puma.rb @@ -0,0 +1,47 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum, this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests, default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. If you use this option +# you need to make sure to reconnect any threads in the `on_worker_boot` +# block. +# +# preload_app! + +# The code in the `on_worker_boot` will be called if you are using +# clustered mode by specifying a number of `workers`. After each worker +# process is booted this block will be run, if you are using `preload_app!` +# option you will want to use this block to reconnect to any threads +# or connections that may have been created at application boot, Ruby +# cannot share connections between processes. +# +# on_worker_boot do +# ActiveRecord::Base.establish_connection if defined?(ActiveRecord) +# end + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 000000000..45b60ee2f --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,33 @@ +Rails.application.routes.draw do + root to: 'users#new' + resources :users, :except => [:update, :destroy] do + resources :photos, :defaults => { :photoable => 'User'} + resources :friendings, :only => [:index, :create, :index] + + resources :posts, :only => [:create, :destroy] do + resources :photos, :defaults => { :photoable => 'Post'}, :only => [:create] + resources :likings, :only => [:create] + end + + resource :profiles, :except => [:create, :destroy] do + resources :photos, :defaults => { :photoable => 'Profile'}, :only => [:create] + get "/edit" => "profiles#show" + get "/" => "profiles#index" + end + end + + resources :posts, :except => [:create, :destroy] do + resources :comments, :defaults => { :commentable => 'Post'}, :except => [:destroy] + end + + resources :comments, :only => [:destroy] + + resources :timelines, :only => [:index] + resources :friendings, :only => [:destroy] + resources :likings, :only => [:destroy] + resource :session, :only => [:new, :create, :destroy] + + get "login" => "sessions#new" + delete "logout" => "sessions#destroy" + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html +end diff --git a/config/secrets.yml b/config/secrets.yml new file mode 100644 index 000000000..9dbc59eb2 --- /dev/null +++ b/config/secrets.yml @@ -0,0 +1,28 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key is used for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! + +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +# You can use `rails secret` to generate a secure secret key. + +# Make sure the secrets in this file are kept private +# if you're sharing your code publicly. + +development: + secret_key_base: a33cf0bc51531d81b29af66b636ef52b44ed88fc69f706fba42832bd38461ac5638a5c28c7fee022f671930fcfb5f9f1e8d521e03f5814f933ddc0f98d6a992d + s3_bucket_name: <%= ENV["S3_BUCKET_NAME"] %> + aws_access_key_id: <%= ENV["AWS_ACCESS_KEY_ID"] %> + aws_secret_access_key: <%= ENV["AWS_SECRET_ACCESS_KEY"] %> + +test: + secret_key_base: 6f2239f357284dc5574ffe9ca724a23ecb5d092838a612e88d1cdb7b109552909af90618d4bc776bd6a5d8ca75ccf8f7830f9320c5fbf51924ab6711a19d9add + +# Do not keep production secrets in the repository, +# instead read values from the environment. +production: + secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> + s3_bucket_name: <%= ENV["S3_BUCKET_NAME"] %> + aws_access_key_id: <%= ENV["AWS_ACCESS_KEY_ID"] %> + aws_secret_access_key: <%= ENV["AWS_SECRET_ACCESS_KEY"] %> diff --git a/config/spring.rb b/config/spring.rb new file mode 100644 index 000000000..c9119b40c --- /dev/null +++ b/config/spring.rb @@ -0,0 +1,6 @@ +%w( + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +).each { |path| Spring.watch(path) } diff --git a/db/migrate/20160810213243_create_users.rb b/db/migrate/20160810213243_create_users.rb new file mode 100644 index 000000000..a835c0c99 --- /dev/null +++ b/db/migrate/20160810213243_create_users.rb @@ -0,0 +1,11 @@ +class CreateUsers < ActiveRecord::Migration[5.0] + def change + create_table :users do |t| + t.string :username + t.string :email + t.string :password_digest + + t.timestamps + end + end +end diff --git a/db/migrate/20160810224508_add_auth_token_to_users.rb b/db/migrate/20160810224508_add_auth_token_to_users.rb new file mode 100644 index 000000000..350799bed --- /dev/null +++ b/db/migrate/20160810224508_add_auth_token_to_users.rb @@ -0,0 +1,6 @@ +class AddAuthTokenToUsers < ActiveRecord::Migration[5.0] + def change + add_column :users, :auth_token, :string + add_index :users, :auth_token, :unique => true + end +end diff --git a/db/migrate/20160811182202_create_profiles.rb b/db/migrate/20160811182202_create_profiles.rb new file mode 100644 index 000000000..cf09f7391 --- /dev/null +++ b/db/migrate/20160811182202_create_profiles.rb @@ -0,0 +1,16 @@ +class CreateProfiles < ActiveRecord::Migration[5.0] + def change + create_table :profiles do |t| + t.string :first_name + t.string :last_name + t.string :month + t.integer :day + t.integer :year + t.string :gender + + t.references :user, index: true, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20160811232849_add_basic_information_to_profile.rb b/db/migrate/20160811232849_add_basic_information_to_profile.rb new file mode 100644 index 000000000..66c428b43 --- /dev/null +++ b/db/migrate/20160811232849_add_basic_information_to_profile.rb @@ -0,0 +1,8 @@ +class AddBasicInformationToProfile < ActiveRecord::Migration[5.0] + def change + add_column :profiles, :college, :string, optional: true + add_column :profiles, :home_town, :string, optional: true + add_column :profiles, :currently_lives, :string, optional: true + add_column :profiles, :phone_number, :string, optional: true + end +end diff --git a/db/migrate/20160812161906_create_posts.rb b/db/migrate/20160812161906_create_posts.rb new file mode 100644 index 000000000..ce6c96f4d --- /dev/null +++ b/db/migrate/20160812161906_create_posts.rb @@ -0,0 +1,10 @@ +class CreatePosts < ActiveRecord::Migration[5.0] + def change + create_table :posts do |t| + t.string :description + + t.references :user, index: true, foreign_key: true + t.timestamps + end + end +end diff --git a/db/migrate/20160815081204_create_likings.rb b/db/migrate/20160815081204_create_likings.rb new file mode 100644 index 000000000..2e5bd8d0e --- /dev/null +++ b/db/migrate/20160815081204_create_likings.rb @@ -0,0 +1,11 @@ +class CreateLikings < ActiveRecord::Migration[5.0] + def change + create_table :likings do |t| + t.integer :user_id + t.integer :likeable_id + t.string :likeable_type + + t.timestamps + end + end +end diff --git a/db/migrate/20160818220430_create_photos.rb b/db/migrate/20160818220430_create_photos.rb new file mode 100644 index 000000000..06e40ca99 --- /dev/null +++ b/db/migrate/20160818220430_create_photos.rb @@ -0,0 +1,11 @@ +class CreatePhotos < ActiveRecord::Migration[5.0] + def change + create_table :photos do |t| + t.integer :user_id + t.string :label + + t.references :photoable, :polymorphic => true + t.timestamps + end + end +end diff --git a/db/migrate/20160819201330_create_delayed_jobs.rb b/db/migrate/20160819201330_create_delayed_jobs.rb new file mode 100644 index 000000000..27fdcf6cc --- /dev/null +++ b/db/migrate/20160819201330_create_delayed_jobs.rb @@ -0,0 +1,22 @@ +class CreateDelayedJobs < ActiveRecord::Migration + def self.up + create_table :delayed_jobs, force: true do |table| + table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue + table.integer :attempts, default: 0, null: false # Provides for retries, but still fail eventually. + table.text :handler, null: false # YAML-encoded string of the object that will do work + table.text :last_error # reason for last failure (See Note below) + table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future. + table.datetime :locked_at # Set when a client is working on this object + table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead) + table.string :locked_by # Who is working on this object (if locked) + table.string :queue # The name of the queue this job is in + table.timestamps null: true + end + + add_index :delayed_jobs, [:priority, :run_at], name: "delayed_jobs_priority" + end + + def self.down + drop_table :delayed_jobs + end +end diff --git a/db/migrate/20160819230223_create_friendings.rb b/db/migrate/20160819230223_create_friendings.rb new file mode 100644 index 000000000..931ba6f44 --- /dev/null +++ b/db/migrate/20160819230223_create_friendings.rb @@ -0,0 +1,12 @@ +class CreateFriendings < ActiveRecord::Migration[5.0] + def change + create_table :friendings do |t| + t.integer :friend_id, :null => false + t.integer :friender_id, :null => false + + t.timestamps + end + + add_index :friendings, [:friend_id, :friender_id], :unique => true + end +end diff --git a/db/migrate/20160822211904_create_comments.rb b/db/migrate/20160822211904_create_comments.rb new file mode 100644 index 000000000..17d3cbf9c --- /dev/null +++ b/db/migrate/20160822211904_create_comments.rb @@ -0,0 +1,11 @@ +class CreateComments < ActiveRecord::Migration[5.0] + def change + create_table :comments do |t| + t.string :user_id + t.string :description + + t.references :commentable, :polymorphic => true + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 000000000..4079a4b6d --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,115 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 20160822211904) do + + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + + create_table "comments", force: :cascade do |t| + t.string "user_id" + t.string "description" + t.string "commentable_type" + t.integer "commentable_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["commentable_type", "commentable_id"], name: "index_comments_on_commentable_type_and_commentable_id", using: :btree + end + + create_table "delayed_jobs", force: :cascade do |t| + t.integer "priority", default: 0, null: false + t.integer "attempts", default: 0, null: false + t.text "handler", null: false + t.text "last_error" + t.datetime "run_at" + t.datetime "locked_at" + t.datetime "failed_at" + t.string "locked_by" + t.string "queue" + t.datetime "created_at" + t.datetime "updated_at" + t.index ["priority", "run_at"], name: "delayed_jobs_priority", using: :btree + end + + create_table "friendings", force: :cascade do |t| + t.integer "friend_id", null: false + t.integer "friender_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["friend_id", "friender_id"], name: "index_friendings_on_friend_id_and_friender_id", unique: true, using: :btree + end + + create_table "likes", force: :cascade do |t| + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "likings", force: :cascade do |t| + t.integer "user_id" + t.integer "likeable_id" + t.string "likeable_type" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "photos", force: :cascade do |t| + t.integer "user_id" + t.string "label" + t.string "photoable_type" + t.integer "photoable_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "avatar_file_name" + t.string "avatar_content_type" + t.integer "avatar_file_size" + t.datetime "avatar_updated_at" + t.index ["photoable_type", "photoable_id"], name: "index_photos_on_photoable_type_and_photoable_id", using: :btree + end + + create_table "posts", force: :cascade do |t| + t.string "description" + t.integer "user_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["user_id"], name: "index_posts_on_user_id", using: :btree + end + + create_table "profiles", force: :cascade do |t| + t.string "first_name" + t.string "last_name" + t.string "month" + t.integer "day" + t.integer "year" + t.string "gender" + t.integer "user_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "college" + t.string "home_town" + t.string "currently_lives" + t.string "phone_number" + t.index ["user_id"], name: "index_profiles_on_user_id", using: :btree + end + + create_table "users", force: :cascade do |t| + t.string "username" + t.string "email" + t.string "password_digest" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "auth_token" + t.index ["auth_token"], name: "index_users_on_auth_token", unique: true, using: :btree + end + + add_foreign_key "posts", "users" + add_foreign_key "profiles", "users" +end diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 000000000..802053b66 --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1,10 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). +# +# Examples: +# +# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) +# Character.create(name: 'Luke', movie: movies.first) +Post.destroy_all +Profile.destroy_all +User.destroy_all \ No newline at end of file diff --git a/lib/assets/.keep b/lib/assets/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/lib/tasks/.keep b/lib/tasks/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/lib/templates/erb/scaffold/_form.html.erb b/lib/templates/erb/scaffold/_form.html.erb new file mode 100644 index 000000000..201a069e2 --- /dev/null +++ b/lib/templates/erb/scaffold/_form.html.erb @@ -0,0 +1,13 @@ +<%%= simple_form_for(@<%= singular_table_name %>) do |f| %> + <%%= f.error_notification %> + +
    + <%- attributes.each do |attribute| -%> + <%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %> + <%- end -%> +
    + +
    + <%%= f.button :submit %> +
    +<%% end %> diff --git a/log/.keep b/log/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/project_danebook_pages b/project_danebook_pages new file mode 160000 index 000000000..400df2dbf --- /dev/null +++ b/project_danebook_pages @@ -0,0 +1 @@ +Subproject commit 400df2dbf13353f99c4448318bbf3b8af8550f7a diff --git a/public/404.html b/public/404.html new file mode 100644 index 000000000..b612547fc --- /dev/null +++ b/public/404.html @@ -0,0 +1,67 @@ + + + + The page you were looking for doesn't exist (404) + + + + + + +
    +
    +

    The page you were looking for doesn't exist.

    +

    You may have mistyped the address or the page may have moved.

    +
    +

    If you are the application owner check the logs for more information.

    +
    + + diff --git a/public/422.html b/public/422.html new file mode 100644 index 000000000..a21f82b3b --- /dev/null +++ b/public/422.html @@ -0,0 +1,67 @@ + + + + The change you wanted was rejected (422) + + + + + + +
    +
    +

    The change you wanted was rejected.

    +

    Maybe you tried to change something you didn't have access to.

    +
    +

    If you are the application owner check the logs for more information.

    +
    + + diff --git a/public/500.html b/public/500.html new file mode 100644 index 000000000..061abc587 --- /dev/null +++ b/public/500.html @@ -0,0 +1,66 @@ + + + + We're sorry, but something went wrong (500) + + + + + + +
    +
    +

    We're sorry, but something went wrong.

    +
    +

    If you are the application owner check the logs for more information.

    +
    + + diff --git a/public/apple-touch-icon-precomposed.png b/public/apple-touch-icon-precomposed.png new file mode 100644 index 000000000..e69de29bb diff --git a/public/apple-touch-icon.png b/public/apple-touch-icon.png new file mode 100644 index 000000000..e69de29bb diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 000000000..e69de29bb diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 000000000..3c9c7c01f --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,5 @@ +# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file +# +# To ban all spiders from the entire site uncomment the next two lines: +# User-agent: * +# Disallow: / diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb new file mode 100644 index 000000000..ebb867fa2 --- /dev/null +++ b/spec/controllers/comments_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe CommentsController, type: :controller do + +end diff --git a/spec/controllers/friendings_controller_spec.rb b/spec/controllers/friendings_controller_spec.rb new file mode 100644 index 000000000..55d19a900 --- /dev/null +++ b/spec/controllers/friendings_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe FriendingsController, type: :controller do + +end diff --git a/spec/controllers/news_feeds_controller_spec.rb b/spec/controllers/news_feeds_controller_spec.rb new file mode 100644 index 000000000..d82348f26 --- /dev/null +++ b/spec/controllers/news_feeds_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe NewsFeedsController, type: :controller do + +end diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb new file mode 100644 index 000000000..89e503b82 --- /dev/null +++ b/spec/controllers/photos_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe PhotosController, type: :controller do + +end diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb new file mode 100644 index 000000000..676cbd06e --- /dev/null +++ b/spec/controllers/profiles_controller_spec.rb @@ -0,0 +1,82 @@ +require 'rails_helper' +require 'pry' + +describe ProfilesController do + let(:user){create(:user)} + let(:profile){create(:profile, user: user)} + + context 'for a visitor' do + end + + context 'for self/current_user' do + describe 'GET index' do + end + + describe 'GET show' do + end + + describe 'PATCH #update' do + end + end + + + context 'for logged in as user' do + + before :each do + cookies[:auth_token] = user.auth_token + end + + describe 'GET index' do + it "renders the :index template for profile" do + get :index, user_id: user.id + expect(response).to render_template :index + end + end + + describe 'GET show' do + it "renders the :index template for profile" do + + get :show, user_id: user.id + expect(response).to render_template :show + end + end + + describe 'PATCH #update' do + context "with valid attributes" do + let(:updated_year){1969} + + + before :each do + profile + put :update, + user_id: user.id, + profile: attributes_for( + :profile, + :year => updated_year) + profile.reload + end + + it "finds the specific secret" do + expect(assigns(:profile)).to eq(profile) + end + + it "redirects to the updated secret" do + expect(response).to redirect_to user_profiles_path(user) + end + + it "actually updates the secret" do + expect(user.profile.year).to eq(updated_year) + end + end + + context "with invalid attributes" do + it "stuff" do end + end + end + end + + + + + +end \ No newline at end of file diff --git a/spec/controllers/timelines_controller_spec.rb b/spec/controllers/timelines_controller_spec.rb new file mode 100644 index 000000000..a32fafe64 --- /dev/null +++ b/spec/controllers/timelines_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe TimelinesController, type: :controller do + +end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb new file mode 100644 index 000000000..076881fe3 --- /dev/null +++ b/spec/controllers/users_controller_spec.rb @@ -0,0 +1,60 @@ +require 'rails_helper' + +describe UsersController do + let(:user){create(:user)} + let(:profile){user.create_profile(attributes_for(:profile))} + + context "for visitor" do + describe 'GET #show' do + it "redirects to sign_up page" do + get :show, params: { id: user.id } + expect(response).to render_template :show + end + end + + describe 'GET #new' do + it "renders the :new template for user" do + get :new + expect(response).to render_template :new + end + end + + describe 'POST #create' do + + context "with proper attributes" do + it "creates a new user" do + expect{ + + post :create, user: attributes_for(:user) + }.to change(User, :count).by(1) + end + + it "redirects to new user" do + post :create, user: attributes_for(:user) + expect(response).to redirect_to user_path(assigns(:user)) + end + + it "sets a flash message" do + post :create, user: attributes_for(:user) + assert_equal flash[:success], "User was saved in database" + end + end + end + end + + context "for logged in user" do + before :each do + cookies[:auth_token] = user.auth_token + end + + describe 'GET #show' do + it "renders the :show template for user" do + get :show, id: user.id + expect(response).to render_template :show + end + end + + describe '#update' + end + +end \ No newline at end of file diff --git a/spec/factories/comments.rb b/spec/factories/comments.rb new file mode 100644 index 000000000..cc687ac62 --- /dev/null +++ b/spec/factories/comments.rb @@ -0,0 +1,5 @@ +FactoryGirl.define do + factory :comment do + + end +end diff --git a/spec/factories/friendings.rb b/spec/factories/friendings.rb new file mode 100644 index 000000000..024c1bfc6 --- /dev/null +++ b/spec/factories/friendings.rb @@ -0,0 +1,5 @@ +FactoryGirl.define do + factory :friending do + + end +end diff --git a/spec/factories/liking_factory.rb b/spec/factories/liking_factory.rb new file mode 100644 index 000000000..f91dcb278 --- /dev/null +++ b/spec/factories/liking_factory.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + + factory :liking do + user + #f.association :liking, factory: :likeable + end +end \ No newline at end of file diff --git a/spec/factories/photos.rb b/spec/factories/photos.rb new file mode 100644 index 000000000..8893964de --- /dev/null +++ b/spec/factories/photos.rb @@ -0,0 +1,5 @@ +FactoryGirl.define do + factory :photo do + + end +end diff --git a/spec/factories/post_factory.rb b/spec/factories/post_factory.rb new file mode 100644 index 000000000..60926b115 --- /dev/null +++ b/spec/factories/post_factory.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + + factory :post do + user + description "abcdefg" + end +end \ No newline at end of file diff --git a/spec/factories/profile_factory.rb b/spec/factories/profile_factory.rb new file mode 100644 index 000000000..c3c3c14bf --- /dev/null +++ b/spec/factories/profile_factory.rb @@ -0,0 +1,12 @@ +FactoryGirl.define do + + factory :profile do + user + sequence(:first_name) { |n| "fname_#{n}"} + sequence(:last_name) { |n| "lname#{n}"} + month "Jan" + day 26 + year 1995 + gender "male" + end +end \ No newline at end of file diff --git a/spec/factories/user_factory.rb b/spec/factories/user_factory.rb new file mode 100644 index 000000000..48d9c06cc --- /dev/null +++ b/spec/factories/user_factory.rb @@ -0,0 +1,10 @@ +FactoryGirl.define do + + factory :user do + sequence(:username) { |n| "user_#{n}"} + email { "#{username}@email.com"} + password "abc123." + password_confirmation "abc123." + + end +end \ No newline at end of file diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb new file mode 100644 index 000000000..ce8190ad8 --- /dev/null +++ b/spec/features/users_spec.rb @@ -0,0 +1,89 @@ +require 'rails_helper' + +feature 'User accounts' do + before do + visit root_path + user.profile = profile + user.posts << post + + end + + let(:user) { build(:user)} + let(:profile) { build(:profile)} + let(:post) {build(:post)} + let(:liking) {build(:liking)} + + context "as a visitor" do + + scenario "I want to sign up" do + fill_sign_up(user) + + expect(page).to have_content('User was saved in database') + end + + scenario "to sign in to my account" do + user.save! + fill_sign_in(user) + + expect(page).to have_content("You've successfully signed in") + end + end + + context "as a signed-in user" do + before do + user.save! + fill_sign_in(user) + end + + context "in terms of redirection" do + + scenario "clicking Danebook redirects me to my profile" do + click_link(user.username) + expect(page).to have_content("About(Text Area)") + end + + scenario "clicking my name redirects me to my profile" do + click_link(user.username) + expect(page).to have_content("About(Text Area)") + end + + scenario "logout of my account" do + click_link("Logout") + expect(page).to have_content("You've successfully signed out") + end + end + + context "in terms of posts" do + before do + visit root_path + end + + scenario "create a post on my timeline" do + fill_post(post) + expect(page).to have_content("Post was created in User") + end + + context "when a post exists" do + before do + fill_post(post) + + end + + scenario "delete a post on my timeline" do + first(:link, "Destroy").click + expect(page).to have_content("Post was deleted in User") + end + + scenario "like a post on my timeline" do + first(:link, "Like").click + expect(page).to have_content("#{user.username} likes this..") + end + end + + context "when a post doesn't exist" do + end + end + end + +end + diff --git a/spec/helpers/comments_helper_spec.rb b/spec/helpers/comments_helper_spec.rb new file mode 100644 index 000000000..729cd87bf --- /dev/null +++ b/spec/helpers/comments_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the CommentsHelper. For example: +# +# describe CommentsHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe CommentsHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/friendings_helper_spec.rb b/spec/helpers/friendings_helper_spec.rb new file mode 100644 index 000000000..e8a5977d7 --- /dev/null +++ b/spec/helpers/friendings_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the FriendingsHelper. For example: +# +# describe FriendingsHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe FriendingsHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/news_feeds_helper_spec.rb b/spec/helpers/news_feeds_helper_spec.rb new file mode 100644 index 000000000..8a7c02b2a --- /dev/null +++ b/spec/helpers/news_feeds_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the NewsFeedsHelper. For example: +# +# describe NewsFeedsHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe NewsFeedsHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/photos_helper_spec.rb b/spec/helpers/photos_helper_spec.rb new file mode 100644 index 000000000..6b5aa7d30 --- /dev/null +++ b/spec/helpers/photos_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the PhotosHelper. For example: +# +# describe PhotosHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe PhotosHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/timelines_helper_spec.rb b/spec/helpers/timelines_helper_spec.rb new file mode 100644 index 000000000..ad5c3e45d --- /dev/null +++ b/spec/helpers/timelines_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the TimelinesHelper. For example: +# +# describe TimelinesHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe TimelinesHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/mailers/previews/user_mailer_preview.rb b/spec/mailers/previews/user_mailer_preview.rb new file mode 100644 index 000000000..957e12b64 --- /dev/null +++ b/spec/mailers/previews/user_mailer_preview.rb @@ -0,0 +1,4 @@ +# Preview all emails at http://localhost:3000/rails/mailers/user_mailer +class UserMailerPreview < ActionMailer::Preview + +end diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb new file mode 100644 index 000000000..c48d3adee --- /dev/null +++ b/spec/mailers/user_mailer_spec.rb @@ -0,0 +1,5 @@ +require "rails_helper" + +RSpec.describe UserMailerMailer, type: :mailer do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb new file mode 100644 index 000000000..c10688d91 --- /dev/null +++ b/spec/models/comment_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Comment, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/friending_spec.rb b/spec/models/friending_spec.rb new file mode 100644 index 000000000..e5b208edf --- /dev/null +++ b/spec/models/friending_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Friending, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/liking_spec.rb b/spec/models/liking_spec.rb new file mode 100644 index 000000000..e69de29bb diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb new file mode 100644 index 000000000..568cabbc1 --- /dev/null +++ b/spec/models/photo_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Photo, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb new file mode 100644 index 000000000..de3762a7f --- /dev/null +++ b/spec/models/post_spec.rb @@ -0,0 +1,26 @@ +require 'rails_helper' + +describe Post do + let(:post){build(:post)} + + describe 'validations' do + it "invalid if description is nil/empty" do + new_user = build(:post, :description => nil) + expect(new_user.valid?).to eq(false) + end + end + + describe 'associations' do + it "responds to user association" do + expect(post).to respond_to(:user) + end + + it "responds to comment association" do + expect(post).to respond_to(:comments) + end + + it "responds to likes association" do + expect(post).to respond_to(:likes) + end + end +end \ No newline at end of file diff --git a/spec/models/profile_spec.rb b/spec/models/profile_spec.rb new file mode 100644 index 000000000..bbf1d146b --- /dev/null +++ b/spec/models/profile_spec.rb @@ -0,0 +1,112 @@ +require 'rails_helper' + +describe Profile do + let(:profile){build(:profile)} + + describe 'validations' do + + it "is valid with default attributes" do + expect(profile).to be_valid + end + + it "saves with default attributes" do + expect{ profile.save! }.to_not raise_error + end + + it "doesn't allow first_name to be nil/empty" do + new_user = build(:profile, :first_name => nil) + expect(new_user.valid?).to eq(false) + end + + it "doesn't allow last_name to be nil/empty" do + new_user = build(:profile, :last_name => nil) + expect(new_user.valid?).to eq(false) + end + + context "month" do + + it "doesn't allow month to be a non-string" do + new_user = build(:profile, :month => 123) + expect(new_user.valid?).to eq(false) + end + end + + context "day" do + + it "doesn't allow day to be a non-integer" do + new_user = build(:profile, :day => "hehe") + expect(new_user.valid?).to eq(false) + end + + it "doesn't allow day to be a below 1" do + new_user = build(:profile, :day => 0) + expect(new_user.valid?).to eq(false) + end + + it "allow day to be a 1" do + new_user = build(:profile, :day => 1) + expect(new_user.valid?).to eq(true) + end + + it "doesn't allow day to be a above 30" do + new_user = build(:profile, :day => 31) + expect(new_user.valid?).to eq(false) + end + + it "allow day to be a 30" do + new_user = build(:profile, :day => 30) + expect(new_user.valid?).to eq(true) + end + end + + context "year" do + + it "doesn't allow year to be a non-integer" do + new_user = build(:profile, :year => "hehe") + expect(new_user.valid?).to eq(false) + end + + it "doesn't allow year to be a below 1900" do + new_user = build(:profile, :year => 1899) + expect(new_user.valid?).to eq(false) + end + + it "allow year to be a 1900" do + new_user = build(:profile, :year => 1900) + expect(new_user.valid?).to eq(true) + end + + it "doesn't allow year to be a above 2016" do + new_user = build(:profile, :year => 2017) + expect(new_user.valid?).to eq(false) + end + + it "allow year to be a 2016" do + new_user = build(:profile, :year => 2016) + expect(new_user.valid?).to eq(true) + end + end + + describe 'gender' do + it "valid when gender to be male" do + new_user = build(:profile, :gender => "male") + expect(new_user.valid?).to eq(true) + end + + it "valid when gender to be female" do + new_user = build(:profile, :gender => "female") + expect(new_user.valid?).to eq(true) + end + + it "invalid when gender is not male/female" do + new_user = build(:profile, :gender => 123123) + expect(new_user.valid?).to eq(false) + end + end + end + describe 'associations' do + it "responds to user association" do + expect(profile).to respond_to(:user) + end + end +end \ No newline at end of file diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb new file mode 100644 index 000000000..2c7b62ea1 --- /dev/null +++ b/spec/models/user_spec.rb @@ -0,0 +1,76 @@ +require 'rails_helper' + +describe User do + let(:user){build(:user)} + + describe 'validations' do + it "is valid with default attributes" do + expect(user).to be_valid + end + + it "saves with default attributes" do + expect{ user.save! }.to_not raise_error + end + + it "doesn't allow username to be nil/empty" do + new_user = build(:user, :username => nil) + expect(new_user.valid?).to eq(false) + end + + it "doesn't allow email to be in the wrong format" do + new_user = build(:user, :email => "sdfsd@.comsdf") + expect(new_user.valid?).to eq(false) + end + + it "doesn't allow password to be below 5 and above 25 in length" do + new_user1 = build(:user, :password => "i" * 4) + expect(new_user1.valid?).to eq(false) + + new_user2 = build(:user, :password => "i" * 26) + expect(new_user2.valid?).to eq(false) + end + + it "doesn't allow password to be empty/nil" do + new_user = build(:user, :password => nil) + expect(new_user.valid?).to eq(false) + end + + context "when saving multiple users" do + before do + user.save! + end + it "doesn't allow identical email addresses" do + new_user = build(:user, :email => user.email) + expect(new_user.valid?).to eq(false) + end + + it "doesn't allow identical usernames" do + new_user = build(:user, :username => user.username) + expect(new_user.valid?).to eq(false) + end + end + end + + describe 'associations' do + it "responds to single profile association" do + expect(user).to respond_to(:profile) + end + + it "responds to post association" do + expect(user).to respond_to(:posts) + end + + it "responds to comment association" do + expect(user).to respond_to(:comments) + end + end + + + describe '#regenerate_auth_token by calling generate_auth_token' do + it "generates new token for nil token user" do + new_user = build(:user, auth_token: nil) + + expect(new_user.regenerate_auth_token).to_not eq(nil) + end + end +end \ No newline at end of file diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 000000000..c1612cf77 --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,80 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +ENV['RAILS_ENV'] ||= 'test' +require File.expand_path('../../config/environment', __FILE__) +# Prevent database truncation if the environment is production +abort("The Rails environment is running in production mode!") if Rails.env.production? +require 'spec_helper' +require 'rspec/rails' +require 'factory_girl_rails' +require 'capybara/rails' + +Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} + +RSpec.configure do |config| + config.include LoginMacros + config.include PostMacros +end + + +Shoulda::Matchers.configure do |config| + config.integrate do |with| + # Choose a test framework: + with.test_framework :rspec + + with.library :rails + end +end + +RSpec.configure do |config| + config.include FactoryGirl::Syntax::Methods +end +# Add additional requires below this line. Rails is not loaded until this point! + +# Requires supporting ruby files with custom matchers and macros, etc, in +# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are +# run as spec files by default. This means that files in spec/support that end +# in _spec.rb will both be required and run as specs, causing the specs to be +# run twice. It is recommended that you do not name files matching this glob to +# end with _spec.rb. You can configure this pattern with the --pattern +# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. +# +# The following line is provided for convenience purposes. It has the downside +# of increasing the boot-up time by auto-requiring all files in the support +# directory. Alternatively, in the individual `*_spec.rb` files, manually +# require only the support files necessary. +# +# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } + +# Checks for pending migration and applies them before tests are run. +# If you are not using ActiveRecord, you can remove this line. +ActiveRecord::Migration.maintain_test_schema! + +RSpec.configure do |config| + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_path = "#{::Rails.root}/spec/fixtures" + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = true + + # RSpec Rails can automatically mix in different behaviours to your tests + # based on their file location, for example enabling you to call `get` and + # `post` in specs under `spec/controllers`. + # + # You can disable this behaviour by removing the line below, and instead + # explicitly tag your specs with their type, e.g.: + # + # RSpec.describe UsersController, :type => :controller do + # # ... + # end + # + # The different available types are documented in the features, such as in + # https://relishapp.com/rspec/rspec-rails/docs + config.infer_spec_type_from_file_location! + + # Filter lines from Rails gems in backtraces. + config.filter_rails_from_backtrace! + # arbitrary gems may also be filtered via: + # config.filter_gems_from_backtrace("gem name") +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 000000000..8f698be46 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,99 @@ +# This file was generated by the `rails generate rspec:install` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# The `.rspec` file also contains a few flags that are not defaults but that +# users commonly want. +# +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + + # This option will default to `:apply_to_host_groups` in RSpec 4 (and will + # have no way to turn it off -- the option exists only for backwards + # compatibility in RSpec 3). It causes shared context metadata to be + # inherited by the metadata hash of host groups and examples, rather than + # triggering implicit auto-inclusion in groups with matching metadata. + config.shared_context_metadata_behavior = :apply_to_host_groups + +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. +=begin + # This allows you to limit a spec run to individual examples or groups + # you care about by tagging them with `:focus` metadata. When nothing + # is tagged with `:focus`, all examples get run. RSpec also provides + # aliases for `it`, `describe`, and `context` that include `:focus` + # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + config.filter_run_when_matching :focus + + # Allows RSpec to persist some state between runs in order to support + # the `--only-failures` and `--next-failure` CLI options. We recommend + # you configure your source control system to ignore this file. + config.example_status_persistence_file_path = "spec/examples.txt" + + # Limits the available syntax to the non-monkey patched syntax that is + # recommended. For more details, see: + # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ + # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode + config.disable_monkey_patching! + + # Many RSpec users commonly either run the entire suite or an individual + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = 'doc' + end + + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. + config.profile_examples = 10 + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed +=end +end diff --git a/spec/support/login_macros.rb b/spec/support/login_macros.rb new file mode 100644 index 000000000..15480a847 --- /dev/null +++ b/spec/support/login_macros.rb @@ -0,0 +1,19 @@ +module LoginMacros + def fill_sign_up(user) + within('.col-md-6 .new_user') do + fill_in 'Username', with: user.username + fill_in 'Email', with: user.email + fill_in 'Password', with: user.password + fill_in 'Password confirmation', with: user.password + click_button('Sign Up') + end + end + + def fill_sign_in(user) + within('#nav-bar') do + fill_in 'Email:', with: user.email + fill_in 'Password:', with: user.password + click_button('Log in') + end + end +end \ No newline at end of file diff --git a/spec/support/post_macros.rb b/spec/support/post_macros.rb new file mode 100644 index 000000000..f3f95791c --- /dev/null +++ b/spec/support/post_macros.rb @@ -0,0 +1,6 @@ +module PostMacros + def fill_post(post) + fill_in 'Description', with: post.description + click_button("Post the Post") + end +end \ No newline at end of file diff --git a/test/controllers/.keep b/test/controllers/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/test/controllers/likings_controller_test.rb b/test/controllers/likings_controller_test.rb new file mode 100644 index 000000000..2a32ccc50 --- /dev/null +++ b/test/controllers/likings_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class LikingsControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb new file mode 100644 index 000000000..6135ce6af --- /dev/null +++ b/test/controllers/sessions_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class SessionsControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end diff --git a/test/fixtures/.keep b/test/fixtures/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/test/fixtures/files/.keep b/test/fixtures/files/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/test/helpers/.keep b/test/helpers/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/test/integration/.keep b/test/integration/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/test/mailers/.keep b/test/mailers/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/test/models/.keep b/test/models/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 000000000..92e39b2d7 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,10 @@ +ENV['RAILS_ENV'] ||= 'test' +require File.expand_path('../../config/environment', __FILE__) +require 'rails/test_help' + +class ActiveSupport::TestCase + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. + fixtures :all + + # Add more helper methods to be used by all tests here... +end diff --git a/tmp/.keep b/tmp/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/assets/javascripts/.keep b/vendor/assets/javascripts/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/assets/stylesheets/.keep b/vendor/assets/stylesheets/.keep new file mode 100644 index 000000000..e69de29bb