Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
c4e0d09
added IG authentication
wangg131 Aug 5, 2015
fee3e8b
added login via IG link
wangg131 Aug 5, 2015
cf22794
Finished user model tests.
ElsaTKO Aug 5, 2015
60bf415
removed email presence validation in user model, not passed via insta…
acmei Aug 5, 2015
302b82b
Created TwittersControllers, started views. Need auth to access API.
ElsaTKO Aug 5, 2015
8d134fd
instagram api WIP
wangg131 Aug 6, 2015
1022354
WIP twitter feed. Need to re-work initializer for twitter gem.
ElsaTKO Aug 6, 2015
17cf707
added ability to access twitter API via twitter gem, class Twit
acmei Aug 6, 2015
5cbc2f6
WIP - working on IG feeds - sm
sallyamoore Aug 6, 2015
b8f4e72
added twitter API with search function, currently working on pulling …
acmei Aug 6, 2015
9b804f0
Merge pull request #4 from acmei/twitter-feed/edm+acw
acmei Aug 6, 2015
f4271d3
merging master into this branch
sallyamoore Aug 6, 2015
40d7582
Implemented search in Instagram using HTTParty. It was WAY simpler th…
sallyamoore Aug 6, 2015
27674b7
Added overall structure and pages.
sallyamoore Aug 6, 2015
d1fb32a
raked migration
sallyamoore Aug 6, 2015
199f6d3
Added join tables, renamed Twitters to Tweets, added routes for feeds…
sallyamoore Aug 6, 2015
4fca9cd
Model specs for instagrams and tweets
sallyamoore Aug 6, 2015
f483352
Extracted model tests into rspec shared example.
ElsaTKO Aug 6, 2015
50c80ab
Merge pull request #5 from acmei/model-tests
Aug 6, 2015
152be91
Added bootstrap to layout.
ElsaTKO Aug 6, 2015
fae0d44
Added instagrams#create method for when users follow an instagramer.
ElsaTKO Aug 6, 2015
be9952b
Got create method to pass for valid params.
ElsaTKO Aug 7, 2015
05a7d18
forms for instagram search
acmei Aug 7, 2015
4fa13da
added search results for instagram
acmei Aug 7, 2015
fc3a175
Added (passing) specs for instagrams_controller and tweets_controller.
sallyamoore Aug 7, 2015
2e0a97b
In sessions controller, added a line to get the :access_token into th…
sallyamoore Aug 7, 2015
7fed92a
added inline form class and additional info in search results for ins…
acmei Aug 7, 2015
26476ca
cleaned up comments
acmei Aug 7, 2015
c5c1fc6
Twitter search WIP
acmei Aug 7, 2015
31e802c
fixed merge conflict in instagram.rb
acmei Aug 7, 2015
e961948
Merge pull request #7 from acmei/search-partial
acmei Aug 7, 2015
c2778c0
bootstrapin feed#index
wangg131 Aug 7, 2015
6096344
Merge branch 'bootstrap-layout' into ninjaparty/master
wangg131 Aug 7, 2015
54a953e
merin moar bootstrap stuff
wangg131 Aug 7, 2015
ea14f49
Merging master into branch
sallyamoore Aug 7, 2015
ac5c0e8
fixed #create method multiple redirect issue by adding return before …
sallyamoore Aug 7, 2015
7d0063a
Merge pull request #6 from acmei/model-tests
sallyamoore Aug 7, 2015
77c43db
fixed partial for twitter search
acmei Aug 7, 2015
d7bcec7
fixed error flashing
acmei Aug 7, 2015
2fa8108
instagram followers working. feed wip
wangg131 Aug 7, 2015
6b545db
minor visual changes
wangg131 Aug 7, 2015
8e4bc02
working twitter search
acmei Aug 7, 2015
29f7244
Merge pull request #8 from acmei/twitter-search
acmei Aug 7, 2015
2ce517e
Merge branch 'instagrams_follow_people' into ninjaparty/master
wangg131 Aug 7, 2015
9d67703
Fixed the link and params to follow a social media user.
ElsaTKO Aug 7, 2015
5bf3cb9
Fixed success message when following a new social user.
ElsaTKO Aug 7, 2015
bb13ad3
can now add a user to twitter people followed.
sallyamoore Aug 7, 2015
ca85122
Can now remove social users from feed.
ElsaTKO Aug 7, 2015
6d4afa5
Merge pull request #9 from acmei/twitter/add-user
sallyamoore Aug 7, 2015
47254e9
Fixed bug to allow following a social user that has been previously u…
ElsaTKO Aug 7, 2015
0b15cba
Merge branch 'ninjaparty/master' of github.com:acmei/C3Projects--SeeM…
ElsaTKO Aug 7, 2015
ebe7647
Added social user images to db, integrated tweet people into assassin…
ElsaTKO Aug 7, 2015
1753e3d
removed extra folder
acmei Aug 7, 2015
f4f2368
WIP - Working on displaying instagram feed. Displaying feed with HTTP…
sallyamoore Aug 7, 2015
b2f0c2a
twitter feed displaying. still need to order by created_at
wangg131 Aug 7, 2015
cd7de6c
Merge branch 'ninjaparty/master' of github.com:acmei/C3Projects--SeeM…
wangg131 Aug 7, 2015
76bab5f
Moved INSTAGRAM_URI constant to applications controller.
sallyamoore Aug 7, 2015
6d76e18
Resolving merge conflict
sallyamoore Aug 7, 2015
8eba57b
Merge pull request #10 from acmei/ig-feed
sallyamoore Aug 7, 2015
0e23674
Revised feeds_controller to deal with merge conflict
sallyamoore Aug 7, 2015
d9061dc
Merge branch 'ninjaparty/master' of github.com:acmei/C3Projects--SeeM…
sallyamoore Aug 7, 2015
49e7abd
Merge pull request #11 from acmei/ig-feed
sallyamoore Aug 7, 2015
2e906e4
WIP ig feed on index view
sallyamoore Aug 8, 2015
62e9c05
edited feed so that there's no error, may need to return and refactor
acmei Aug 8, 2015
57e017c
Feed now displaying ig post content
sallyamoore Aug 9, 2015
42f83a0
Created model and controller for InstagramPosts. Added a route for #c…
sallyamoore Aug 10, 2015
abf7b85
Added associations to User and Instagram models for InstagramPost. In…
sallyamoore Aug 10, 2015
a486be3
Updated INSTAGRAM_URI in application controller so I could use it for…
sallyamoore Aug 10, 2015
e4d70db
Revised views to display instagram post info based on persisted insta…
sallyamoore Aug 10, 2015
2db216b
Resolving merge conflicts
sallyamoore Aug 10, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed .env
Empty file.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@

coverage
.DS_Store
.env
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ gem 'httparty'

# OmniAuth Gems
gem 'omniauth'
gem 'omniauth-instagram'

# OAuth
gem 'twitter'

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
Expand Down Expand Up @@ -73,4 +77,3 @@ end
group :production do
gem 'pg'
end

39 changes: 39 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.3.8)
arel (6.0.2)
autoprefixer-rails (5.2.1.1)
execjs
Expand All @@ -49,6 +50,7 @@ GEM
bootstrap-sass (3.3.5.1)
autoprefixer-rails (>= 5.0.0.1)
sass (>= 3.3.0)
buftok (0.2.0)
builder (3.2.2)
byebug (5.0.0)
columnize (= 0.9.0)
Expand All @@ -68,16 +70,22 @@ GEM
dotenv-rails (2.0.2)
dotenv (= 2.0.2)
railties (~> 4.0)
equalizer (0.0.11)
erubis (2.7.0)
execjs (2.5.2)
factory_girl (4.5.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.5.0)
factory_girl (~> 4.5.0)
railties (>= 3.0.0)
faraday (0.9.1)
multipart-post (>= 1.2, < 3)
globalid (0.3.5)
activesupport (>= 4.1.0)
hashie (3.4.2)
http (0.6.4)
http_parser.rb (~> 0.6.0)
http_parser.rb (0.6.0)
httparty (0.13.5)
json (~> 1.8)
multi_xml (>= 0.5.2)
Expand All @@ -90,21 +98,38 @@ GEM
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.3)
jwt (1.5.1)
loofah (2.0.2)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1)
method_source (0.8.2)
mime-types (2.6.1)
mini_portile (0.6.2)
minitest (5.7.0)
multi_json (1.11.2)
multi_xml (0.5.5)
multipart-post (2.0.0)
naught (1.0.0)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
oauth2 (1.0.0)
faraday (>= 0.8, < 0.10)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (~> 1.2)
omniauth (1.2.2)
hashie (>= 1.2, < 4)
rack (~> 1.0)
omniauth-instagram (1.0.1)
omniauth (~> 1.0)
omniauth-oauth2 (~> 1.0)
omniauth-oauth2 (1.3.1)
oauth2 (~> 1.0)
omniauth (~> 1.2)
pg (0.18.2)
pry (0.10.1)
coderay (~> 1.1.0)
Expand Down Expand Up @@ -168,6 +193,7 @@ GEM
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
simple_oauth (0.3.1)
simplecov (0.10.0)
docile (~> 1.1.0)
json (~> 1.8)
Expand All @@ -187,6 +213,17 @@ GEM
tilt (1.4.1)
turbolinks (2.5.3)
coffee-rails
twitter (5.14.0)
addressable (~> 2.3)
buftok (~> 0.2.0)
equalizer (~> 0.0.9)
faraday (~> 0.9.0)
http (~> 0.6.0)
http_parser.rb (~> 0.6.0)
json (~> 1.8)
memoizable (~> 0.4.0)
naught (~> 1.0)
simple_oauth (~> 0.3.0)
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (2.7.1)
Expand All @@ -213,6 +250,7 @@ DEPENDENCIES
jbuilder (~> 2.0)
jquery-rails
omniauth
omniauth-instagram
pg
pry-rails
rails (= 4.2.3)
Expand All @@ -223,6 +261,7 @@ DEPENDENCIES
spring
sqlite3
turbolinks
twitter
uglifier (>= 1.3.0)
web-console (~> 2.0)

Expand Down
Binary file added app/assets/images/notso-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/assets/javascripts/instagram_posts.coffee
Original file line number Diff line number Diff line change
@@ -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/
3 changes: 3 additions & 0 deletions app/assets/javascripts/instagrams.coffee
Original file line number Diff line number Diff line change
@@ -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/
3 changes: 3 additions & 0 deletions app/assets/javascripts/tweets.coffee
Original file line number Diff line number Diff line change
@@ -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/
19 changes: 19 additions & 0 deletions app/assets/stylesheets/custom.css.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
@import "bootstrap-sprockets";
@import "bootstrap";

.content {
padding-top: 35px;
// background: image-url("notso-2.png") no-repeat;
}

.center {
text-align: center;
margin: auto;
float: none;
}

.header {
font-size: 60px;
}

a:hover {
text-decoration: none;
}
3 changes: 3 additions & 0 deletions app/assets/stylesheets/instagram_posts.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the InstagramPosts controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/instagrams.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Instagrams controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/tweets.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the twitters controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
22 changes: 22 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
require 'twitter'
require 'twit'

class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :twit

INSTAGRAM_URI = "https://api.instagram.com/v1/"
MESSAGES = {
no_username: "There's no user by that name. Search again.",
success: "Success!",
follow_error: "Oops. Something went wrong.",
login_required: "You have to be logged in to do that!"
}

def twit
@twitter ||= Twit.new
end

def require_login
unless session[:user_id]
redirect_to root_path, flash: { error: MESSAGES[:login_required] }
end
end
end
37 changes: 36 additions & 1 deletion app/controllers/feeds_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,42 @@
require 'httparty'

class FeedsController < ApplicationController

def index
@user = User.find_by(id: session[:user_id])

@posts = []
if @user && @user.instagrams
@user.instagram_posts.each do |post|
@posts << HTTParty.get(INSTAGRAM_URI + "media/" + post.post_id + "?access_token=#{session[:access_token]}")
end
@posts.sort_by! { |post| post["data"]["created_time"]}
@posts.reverse!
end

if @user && @user.tweets
@people = []
# @people << Instagram.find(@user.instagram_ids)
@people << Tweet.find(@user.tweet_ids)
@people.flatten!
@people.sort_by! { |person| person.username.downcase }

@feed = []
@people.each do |person|
username = person.username
@feed << @twitter.client.user_timeline(username, count: 10)
@feed.flatten!
@feed.sort_by { |tweet| tweet.created_at.strftime("%m/%d/%Y") }
end
end
end

def search; end

def people
@user = User.find_by(id: session[:user_id])
if @user
@people = Instagram.find(@user.instagram_ids) + Tweet.find(@user.tweet_ids)
end
end

end
42 changes: 42 additions & 0 deletions app/controllers/instagram_posts_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
require 'httparty'

class InstagramPostsController < ApplicationController
before_action :require_login, only: [:create]

def create
user = User.find_by(id: session[:user_id])
if user && user.instagrams
get_posts(user)

# Check if db table includes each post;
# if not, create new InstagramPost
@all_posts.each do |post|
params[:instagram_post] = {
post_id: post[:post_id],
instagram_id: post[:ig_id]
}
InstagramPost.find_or_create_by(instagram_post_params)
end
end
redirect_to root_path
end

private

def get_posts(user)
# Get an array of all recent post ids associated with
# all followed instagram users
@all_posts = []
user.instagrams.each do |gram|
ig_user_posts = HTTParty.get(INSTAGRAM_URI + "users/#{gram.provider_id}/media/recent?count=10&access_token=#{session[:access_token]}")
all_post_ids = ig_user_posts["data"].each do |post|
@all_posts << { ig_id: gram.id, post_id: post["id"]}
end
end
return @all_posts
end

def instagram_post_params
params.require(:instagram_post).permit(:post_id, :instagram_id)
end
end
52 changes: 52 additions & 0 deletions app/controllers/instagrams_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
require 'httparty'

class InstagramsController < ApplicationController
before_action :require_login, only: [:create]

CALLBACK_URL = "http://localhost:3000/auth/instagram/callback"

def search
if params[:instagram].present?
instagram_search = params[:instagram][:username]
response = HTTParty.get(INSTAGRAM_URI + "users/search?q=#{instagram_search}&client_id=#{ENV["INSTAGRAM_ID"]}")

@users = response["data"]

return render "feeds/search"
else
redirect_to root_path, flash: { error: MESSAGES[:no_username] }
end
end

def create
@instagram_person = Instagram.find_or_create_by(instagram_params)
@person = @instagram_person.username
@instagram_person.users << User.find(session[:user_id])

if @instagram_person.save
return redirect_to root_path, flash: { alert: MESSAGES[:success] }
else
return render "feeds/search", flash: { error: MESSAGES[:follow_error] }
end
redirect_to search_path
# add flash: no search results were found for 'username'
end

def destroy
user = User.find_by(id: session[:user_id])
instagramer = Instagram.find(params[:id])

if instagramer
user.instagrams.destroy(instagramer)
end

redirect_to people_path, flash: { alert: MESSAGES[:success] }
end

private

def instagram_params
params.require(:instagram).permit(:username, :provider_id, :image_url)
end

end
5 changes: 4 additions & 1 deletion app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ class SessionsController < ApplicationController

def create
auth_hash = request.env['omniauth.auth'] || params
@user = User.find_or_create_from_omniauth_developer(auth_hash)
@user = User.find_or_create_from_omniauth(auth_hash)
session[:user_id] = @user.id

# NOTE: SM added. Gets the user's access_token from Instagram
session[:access_token] = auth_hash[:credentials][:token]

redirect_to root_path
end

Expand Down
Loading