Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

facebook theme and likable implementation

  • Loading branch information...
commit ce05b8ce466d2a61476d30b6b9743fa12228499d 1 parent 2144f4c
Timothy Fisher timothyf authored
Showing with 1,292 additions and 13 deletions.
  1. +1 −0  app/controllers/home_controller.rb
  2. +45 −0 app/controllers/likes_controller.rb
  3. +25 −5 app/helpers/activity_feed_helper.rb
  4. +2 −0  app/helpers/likes_helper.rb
  5. +1 −0  app/models/activity.rb
  6. +21 −0 app/models/user.rb
  7. +1 −1  app/views/sessions/new.html.erb
  8. +5 −3 config/assets.yml
  9. +2 −3 config/routes.rb
  10. +12 −1 db/schema.rb
  11. +398 −0 lib/tasks/facebook_clone_populate.rake
  12. BIN  public/images/themes/facebook_clone/preview.gif
  13. +38 −0 public/javascripts/application.js
  14. +154 −0 public/stylesheets/themes/facebook_clone/facebook_clone.css
  15. +8 −0 test/functional/likes_controller_test.rb
  16. +4 −0 test/unit/helpers/likes_helper_test.rb
  17. +96 −0 themes/facebook_clone/views/home/index.html.erb
  18. +81 −0 themes/facebook_clone/views/layouts/application.html.erb
  19. +90 −0 themes/facebook_clone/views/shared/_nav_menu.html.erb
  20. +9 −0 themes/facebook_clone/views/status_posts/_status_post_form.html.erb
  21. +52 −0 themes/facebook_clone/views/users/show.html.erb
  22. +65 −0 themes/facebook_clone/views/widgets/activity_feed_home.html.erb
  23. +41 −0 themes/facebook_clone/views/widgets/activity_feed_profile.html.erb
  24. +57 −0 themes/facebook_clone/views/widgets/events_profile.html.erb
  25. +56 −0 themes/facebook_clone/views/widgets/photos_profile.html.erb
  26. +28 −0 themes/facebook_clone/views/widgets/status_posts_profile.html.erb
1  app/controllers/home_controller.rb
View
@@ -80,6 +80,7 @@ def index
else
@section = 'MAIN'
@page = Page.find_by_name('home')
+ @user = current_user
@photos = Photo.find(:all, :limit=>6,
:select=>'id, parent_id, filename',
:order => Photo.connection.adapter_name == 'PostgreSQL' ? 'RANDOM()' : 'RAND()',
45 app/controllers/likes_controller.rb
View
@@ -0,0 +1,45 @@
+class LikesController < ApplicationController
+
+ include ActivityFeedHelper
+
+ def create
+ user_id = params[:user_id]
+ likable_id = params[:likable_id]
+ likable_type = params[:likable_type]
+
+ # prevent a user from liking something twice
+ like = Like.find_by_user_id_and_likable_id_and_likable_type(user_id, likable_id, likable_type)
+ if like == nil || like.size == 0
+ @like = Like.create(:user_id => user_id, :likable_id => likable_id, :likable_type => likable_type)
+ end
+
+ respond_to do |format|
+ #if @like.save
+ format.xml { render :xml => @like, :status => :created, :location => @like }
+ format.json {render :json => @like, :status => :created, :location => @like }
+ #else
+ # format.xml { render :xml => @link.errors, :status => :unprocessable_entity }
+ # format.json { render :json => @link.errors.to_json, :status => :unprocessable_entity }
+ #end
+ end
+ end
+
+
+ def like_text
+ activity = Activity.find(params[:activity_id])
+ render :text=>display_like_text(activity), :layout => false
+ end
+
+
+ def destroy
+ @like = Like.find(params[:id])
+ @like.destroy
+ respond_to do |format|
+ format.html { redirect_to(likes_url) }
+ format.xml { head :ok }
+ format.json { head :ok }
+ end
+ end
+
+
+end
30 app/helpers/activity_feed_helper.rb
View
@@ -13,6 +13,26 @@
# limitations under the License.
module ActivityFeedHelper
+ def display_like_text(activity)
+ if current_user.like_this?(activity) == true
+ if activity.likes.size > 1
+ text = "You and #{(activity.likes.size - 1).to_s} other #{activity.likes.size > 2 ? 'people':'person'} like this"
+ else
+ text = "You like this"
+ end
+ elsif activity.likes && activity.likes.size > 0
+ if activity.likes.size > 1
+ text = "#{(activity.likes.size).to_s} people like this"
+ else
+ text = "1 person likes this"
+ end
+ else
+ text = "Be the first to like this"
+ end
+ return text
+ end
+
+
def user_link(user)
"#{link_to(user.name, user_url(user))}"
end
@@ -41,14 +61,14 @@ def activity_feed_message(activity)
end
when "Photo"
if activity.action == 'destroy'
- %(#{user_link(user)} deleted a photo. #{activity_date(activity)})
+ %(<span class="activity_text"><span class="activity_user_link">#{user_link(user)}</span> deleted a photo.</span>#{activity_date(activity)})
else
if activity.item
photo = Photo.find(activity.item.id, :select=>"id, user_id, filename, parent_id, created_at")
- %(#{user_link(user)} uploaded a photo - <a href="/photos/#{photo.id}">#{image_tag(photo.public_filename(:small))}</a>. #{activity_date(photo)})
+ %(<span class="activity_text"><span class="activity_user_link">#{user_link(user)}</span> uploaded a photo - <a href="/photos/#{photo.id}">#{image_tag(photo.public_filename(:small))}</a>.</span>#{activity_date(photo)})
else
# photo no longer exists, but still need to display upload event for history
- %(#{user_link(user)} uploaded a photo. #{activity_date(activity)})
+ %(<span class="activity_text"><span class="activity_user_link">#{user_link(user)}</span> uploaded a photo.</span>#{activity_date(activity)})
end
end
when "Group"
@@ -71,7 +91,7 @@ def activity_feed_message(activity)
end
when "Membership"
membership = activity.item
- %(#{user_link(user)} joined the group, <a href="/groups/#{membership.group.id}">#{membership.group.name}</a>. #{activity_date(membership)})
+ %(<span class="activity_text"><span class="activity_user_link">#{user_link(user)}</span> joined the group, <a href="/groups/#{membership.group.id}">#{membership.group.name}</a>. </span>#{activity_date(membership)})
when "ForumPost"
forum_post = activity.item
%(#{user_link(user)} posted a new message to the forum, <a href="/forum_posts/#{forum_post.id}">#{forum_post.title}</a>. #{activity_date(forum_post)})
@@ -88,7 +108,7 @@ def activity_feed_message(activity)
%(#{user.name} posted a new review for #{book_review.name}. #{activity_date(book_review)})
when "StatusPost"
status_post = activity.item
- %(#{user_link(user)} #{EngineyUtil.linkify(status_post.body)} #{activity_date(status_post)})
+ %(<span class="activity_text"><span class="activity_user_link">#{user_link(user)}</span> #{EngineyUtil.linkify(status_post.body)}</span>#{activity_date(status_post)})
when "Link"
link = activity.item
if link
2  app/helpers/likes_helper.rb
View
@@ -0,0 +1,2 @@
+module LikesHelper
+end
1  app/models/activity.rb
View
@@ -31,6 +31,7 @@ class Activity < ActiveRecord::Base
belongs_to :user
belongs_to :item, :polymorphic => true
has_many :feeds
+ acts_as_likable
GLOBAL_FEED_SIZE = 10
21 app/models/user.rb
View
@@ -26,6 +26,8 @@ class User < ActiveRecord::Base
has_many :memberships, :dependent => :destroy
has_many :groups, :through => :memberships
+ has_many :likes
+
# TODO:
# Add a condition to only get the attendances set in the future.
# Do not get attendances for past events
@@ -111,6 +113,25 @@ def current_status
end
+ # Return true if the user likes the activity passed in, otherwise false
+ def like_this?(activity)
+ @likes = Like.find_likes_cast_by_user(self)
+ if @likes
+ results = @likes.select{|like| (like.likable_id == activity.id && like.likable_type == 'Activity') }
+ if results && results.size > 0
+ return true
+ end
+ end
+ return false
+ end
+
+
+ # Returns the Like object associated with the Activity passed in for this user, if this user 'likes' the activity
+ def get_like(activity)
+ Like.find_by_user_id_and_likable_id_and_likable_type(self.id, activity.id, 'Activity')
+ end
+
+
# Returns an array of users who have an API key
def self.with_api_key
User.find(:all, :conditions => "api_key != ''")
2  app/views/sessions/new.html.erb
View
@@ -18,7 +18,7 @@ limitations under the License.
<div class="notice"><%= flash[:notice] %></div>
<% end %>
<div id="login_form">
- <h5>Sign in with your RubyMI login and password</h5>
+ <h5>Sign in with your login and password</h5>
<% form_tag session_path do -%>
<div class="form_field">
<label for="login">Login:</label>
8 config/assets.yml
View
@@ -1,9 +1,11 @@
embed_assets: on
javascripts:
-
+ workspace:
+ - public/javascripts/*.js
stylesheets:
+ common:
+ - public/stylesheets/*.css
+ - public/stylesheets/themes/**/*.css
-
-templates:
5 config/routes.rb
View
@@ -1,13 +1,10 @@
ActionController::Routing::Routes.draw do |map|
map.resources :nav_items
-
map.resources :ey_modules
-
map.resources :modules
Jammit::Routes.draw(map)
-
map.resources :follows
map.resources :contents
map.resources :facebook_posts
@@ -54,6 +51,7 @@
map.connect 'users/authenticate.:format', :controller=>'users', :action=>'authenticate'
map.connect 'blog_post_topics/ajax_save', :controller=>'blog_post_topics', :action=>'ajax_save'
map.connect 'blog_post_topics/fetch_topic_list', :controller=>'blog_post_topics', :action=>'fetch_topic_list'
+ map.connect 'likes/like_text', :controller=>'likes', :action=>'like_text'
map.resources :blog_post_topics
map.resources :videos
@@ -66,6 +64,7 @@
map.resources :users
map.resources :memberships
map.resource :session
+ map.resources :likes
map.activate '/activate/:activation_code', :controller => 'users', :action => 'activate', :activation_code => nil
13 db/schema.rb
View
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20100628192855) do
+ActiveRecord::Schema.define(:version => 20100707160333) do
create_table "activities", :force => true do |t|
t.integer "user_id"
@@ -274,6 +274,17 @@
t.datetime "updated_at"
end
+ create_table "likes", :force => true do |t|
+ t.integer "user_id", :null => false
+ t.integer "likable_id", :null => false
+ t.string "likable_type", :null => false
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "likes", ["likable_type", "likable_id"], :name => "index_likable_type"
+ add_index "likes", ["user_id"], :name => "fk_likes_user"
+
create_table "links", :force => true do |t|
t.integer "user_id"
t.string "title"
398 lib/tasks/facebook_clone_populate.rake
View
@@ -0,0 +1,398 @@
+namespace :enginey do
+ namespace :db do
+ desc "Add sample data to the database"
+ task :facebook_clone_populate => :environment do
+
+ ##########################################################################
+ # SETUP, modify this to change how you want to configure your sample data
+ NETWORK_NAME = 'Facebook Clone'
+ NUMBER_OF_TEST_USERS = 12
+ GROUP_PHOTO_1 = File.new(RAILS_ROOT + "/public/images/rails.png")
+ GROUP_PHOTO_2 = File.new(RAILS_ROOT + "/public/images/rails2.png")
+ ##########################################################################
+
+ # Output configuration
+ puts 'Setting up sample data for your EngineY network.'
+ puts 'Network Name: ' + NETWORK_NAME
+ puts '# of Users: ' + NUMBER_OF_TEST_USERS.to_s
+
+ # Start data creation
+ puts 'Create network...'
+ Network.destroy_all
+ network = Network.create(:name => NETWORK_NAME,
+ :organization => 'Facebook Clone',
+ :website => 'http://www.rubymi.org',
+ :url => 'http://www.rubymi.org',
+ :admin_email => 'admin@rubymi.org',
+ :description => 'Welcome to the Facebook Clone Website.')
+
+
+ puts 'Populating roles...'
+ network.init_network()
+
+
+ ##########################################################################
+ puts 'Creating config settings...'
+ ConfigSetting.destroy_all
+ Configuration.create_defaults
+
+
+ ##########################################################################
+ puts 'Creating users...'
+ Activity.destroy_all
+ User.destroy_all
+ Photo.destroy_all
+ state_id = State.find_by_name('MICHIGAN').id
+ print '.'
+ user1 = User.new :first_name=>'Timothy',
+ :last_name=>'Fisher',
+ :sex=>'M',
+ :state_id=>state_id,
+ :country_id=>1,
+ :zip=>'48134',
+ :login=>'admin',
+ :email=>'timothyf@gmail.com',
+ :city=>'Flat Rock',
+ :twitter_id=>'tfisher',
+ :facebook_url=>'http://www.facebook.com/trfisher',
+ :activated_at=>'2009-01-01',
+ :password=>'admin',
+ :password_confirmation=>'admin'
+ user1.save
+
+ photo = ProfilePhoto.create(:is_profile => true,
+ :temp_path => File.new(RAILS_ROOT + "/public/images/tim.png"),
+ :filename => 'tim.png',
+ :content_type => 'image/png',
+ :user => user1)
+ user1.profile_photo = photo
+ user1.save
+ user1.activate
+ user1.roles << Role.find_by_rolename('creator')
+ print '.'
+ user = User.new :first_name=>'John',
+ :last_name=>'Smith',
+ :sex=>'M',
+ :state_id=>state_id,
+ :country_id=>1,
+ :zip=>'48134',
+ :login=>'jsmith',
+ :email=>'john@gmail.com',
+ :city=>'Flat Rock',
+ :activated_at=>'2009-01-01',
+ :password=>'jsmith',
+ :password_confirmation=>'jsmith'
+ user.save
+ #user.set_temp_photo()
+ #user.save
+ user.activate
+ user.make_group_admin(1)
+ #user.roles << Role.find_by_rolename('user')
+ print '.'
+ user2 = User.new :first_name=>'Paul',
+ :last_name=>'Edwards',
+ :sex=>'M',
+ :state_id=>state_id,
+ :country_id=>1,
+ :zip=>'48134',
+ :login=>'pedwards',
+ :email=>'paul@gmail.com',
+ :city=>'Flat Rock',
+ :activated_at=>'2009-01-01',
+ :password=>'pedwards',
+ :password_confirmation=>'pedwards'
+ user2.save
+ #user2.set_temp_photo
+ #user2.save
+ user2.activate
+ #user2.make_group_admin(1)
+
+ network.create_sample_users(NUMBER_OF_TEST_USERS)
+ puts ''
+
+ ##########################################################################
+ puts 'Creating friendships...'
+ Friendship.destroy_all
+
+ # FRIENDS
+ @user = User.find(1)
+ @friend = User.find(2)
+ Friendship.request(@user, @friend)
+
+ @user = User.find(2)
+ @friend = User.find(1)
+ Friendship.accept(@user, @friend)
+
+ @user = User.find(1)
+ @friend = User.find(3)
+ Friendship.request(@user, @friend)
+
+ @user = User.find(3)
+ @friend = User.find(1)
+ Friendship.accept(@user, @friend)
+
+ # REQUESTED FRIENDS
+ @user = User.find(1)
+ @friend = User.find(4)
+ Friendship.request(@user, @friend)
+
+ @user = User.find(1)
+ @friend = User.find(5)
+ Friendship.request(@user, @friend)
+
+ # PENDING FRIENDS
+ @user = User.find(6)
+ @friend = User.find(1)
+ Friendship.request(@user, @friend)
+
+ @user = User.find(6)
+ @friend = User.find(1)
+ Friendship.request(@user, @friend)
+
+ ##########################################################################
+ puts 'Creating test groups...'
+ Group.destroy_all
+ group = Group.new(:name => 'Detroit Ruby User Group',
+ :description => 'The Detroit Ruby User Group.',
+ :creator_id => user1.id,
+ :featured => false)
+ photo = ProfilePhoto.create(:is_profile => true,
+ :temp_path => GROUP_PHOTO_1,
+ :filename => 'testgroup.png',
+ :content_type => 'image/png',
+ :group => group)
+ group.profile_photo = photo
+ group.save
+
+ group = Group.new(:name => 'Ann Arbor Ruby Brigade',
+ :description => 'The Ann Arbor Ruby User Group.',
+ :creator_id => user1.id,
+ :featured => false)
+ photo = ProfilePhoto.create(:is_profile => true,
+ :temp_path => GROUP_PHOTO_2,
+ :filename => 'testgroup2.png',
+ :content_type => 'image/png',
+ :group => group)
+ group.profile_photo = photo
+ group.save
+
+ puts 'Creating group memberships'
+ Membership.destroy_all
+ role = Role.find_by_rolename('user')
+ (1..NUMBER_OF_TEST_USERS).each do |num|
+ Membership.create({:group_id=>1,
+ :user_id=>num,
+ :role_id=>role.id})
+ end
+
+ ##########################################################################
+ puts 'Creating test Events...'
+ Event.destroy_all
+ event = Event.new(:name => "Detroit RUG Meeting",
+ :user_id => user1.id,
+ :description => 'DRUG Meeting for April.',
+ :event_type => 'User Group Meeting',
+ :start_time => Time.new,
+ :end_time => Time.new,
+ :location => "Compuware Building",
+ :street => 'One Campus Martius',
+ :city => 'Detroit',
+ :website => 'http://drug.rubymi.org',
+ :phone => '555-555-1212',
+ :organized_by => 'Timothy Fisher')
+ photo = ProfilePhoto.create(:is_profile => true,
+ :temp_path => File.new(RAILS_ROOT + "/public/images/testevent.jpg"),
+ :filename => 'testevent.jpg',
+ :content_type => 'image/jpg',
+ :event => event)
+ event.profile_photo = photo
+ event.save
+
+ event = Event.new(:name => "AnnArbor.rb Meeting",
+ :user_id => user1.id,
+ :description => 'April Meeting for Ann Arbor Ruby Brigade.',
+ :event_type => 'User Group Meeting',
+ :start_time => Time.new,
+ :end_time => Time.new,
+ :location => "Compuware Building",
+ :street => 'One Campus Martius',
+ :city => 'Detroit',
+ :website => 'http://aa.rubymi.org',
+ :phone => '555-555-1212',
+ :organized_by => 'Timothy Fisher')
+ photo = ProfilePhoto.create(:is_profile => true,
+ :temp_path => File.new(RAILS_ROOT + "/public/images/testevent.jpg"),
+ :filename => 'testevent.jpg',
+ :content_type => 'image/jpg',
+ :event => event)
+ event.profile_photo = photo
+ event.save
+
+ ##########################################################################
+ puts 'Creating RSS Feed...'
+ RssFeed.destroy_all
+ RssFeed.create(:name => "Tim's Blog",
+ :url => 'http://feeds.feedburner.com/TimothyFishersBlog',
+ :user => user1)
+
+ ##########################################################################
+ puts 'Creating a message...'
+ Message.destroy_all
+ Message.create(:subject=>'Test Message',
+ :body=>'This is just a test message',
+ :sender_id=>user.id,
+ :recipient_id=>user1.id)
+
+
+ ##########################################################################
+ puts 'Creating blog posts...'
+ BlogPost.destroy_all
+ BlogPost.create(:user => user1,
+ :title => 'Welcome to RubyMI',
+ :body => "This site is being launched as a new community site for anyone who programs in or aspires to program in the Ruby programming language. This site is not affiliated with a single user group, but provides a single point of contact for you to keep up with what is going on in the Ruby community throughout Michigan. Here you will find notification of upcoming Ruby related events in Michigan and nearby, a community of like-minded Ruby enthusiasts to network with, and a place to share your knowledge with others.<br/><br/>I hope you enjoy the new RubyMI community site.<br/><br/>Sincerely,<br/>Timothy Fisher",
+ :published => true,
+ :featured => true
+ )
+ (1..NUMBER_OF_TEST_USERS).each do |number|
+ BlogPost.create(:user => User.find_by_login("testuser#{number}"),
+ :title => "Post from Test User #{number}",
+ :body => "This site is being launched as a new community site for anyone who programs in or aspires to program in the Ruby programming language. This site is not affiliated with a single user group, but provides a single point of contact for you to keep up with what is going on in the Ruby community throughout Michigan. Here you will find notification of upcoming Ruby related events in Michigan and nearby, a community of like-minded Ruby enthusiasts to network with, and a place to share your knowledge with others.<br/><br/>I hope you enjoy the new RubyMI community site.<br/><br/>Sincerely,<br/>Timothy Fisher",
+ :published => true,
+ :featured => false
+ )
+ end
+
+ ##########################################################################
+ puts 'Creating Photo Albums...'
+ PhotoAlbum.create(:title=>'Summer Photos',
+ :description=>'A collection of summer photos.',
+ :user=>user1)
+
+ PhotoAlbum.create(:title=>'Winter Photos',
+ :description=>'A collection of winter photos.',
+ :user=>user1)
+
+
+ ##########################################################################
+ # Close File Streams
+ puts 'Closing file streams...'
+ GROUP_PHOTO_1.close
+ GROUP_PHOTO_2.close
+
+
+ ##########################################################################
+ # Create HTML Contents
+ puts 'Creating managed content...'
+ HtmlContent.create(:title => 'sample_content',
+ :body => 'This is an example of <b>managed content</b>.');
+
+
+ ##########################################################################
+ # Create Modules and widgets
+ puts 'Creating modules and widgets...'
+ mod = EyModule.create(:name => 'blog_posts')
+ Widget.create(:ey_module_id => mod.id, :name => 'blog_posts_home', :description => 'Display recent blog posts', :profile => false)
+ Widget.create(:ey_module_id => mod.id, :name => 'blog_posts_profile', :description => 'Display users blog posts', :profile => true)
+
+ mod = EyModule.create(:name => 'members')
+ Widget.create(:ey_module_id => mod.id, :name => 'members_home', :description => 'Display some members', :profile => false)
+
+ mod = EyModule.create(:name => 'groups')
+ Widget.create(:ey_module_id => mod.id, :name => 'groups_home', :description => 'Display some groups', :profile => false)
+ Widget.create(:ey_module_id => mod.id, :name => 'groups_profile', :description => 'Display users groups', :profile => true)
+
+ mod = EyModule.create(:name => 'events')
+ Widget.create(:ey_module_id => mod.id, :name => 'events_home', :description => 'Display upcoming events', :profile => false)
+ Widget.create(:ey_module_id => mod.id, :name => 'events_profile', :description => 'Display users events', :profile => true)
+
+ mod = EyModule.create(:name => 'announcements')
+ Widget.create(:ey_module_id => mod.id, :name => 'announcements_home', :description => 'Display recent announcements', :profile => false)
+
+ mod = EyModule.create(:name => 'activity_feed')
+ Widget.create(:ey_module_id => mod.id, :name => 'activity_feed_home', :description => 'Display recent activities', :profile => false)
+ Widget.create(:ey_module_id => mod.id, :name => 'activity_feed_profile', :description => 'Display users activities', :profile => true)
+
+ mod = EyModule.create(:name => 'links')
+ Widget.create(:ey_module_id => mod.id, :name => 'links_home', :description => 'Display some links', :profile => false)
+ Widget.create(:ey_module_id => mod.id, :name => 'links_profile', :description => 'Display users links', :profile => true)
+
+ mod = EyModule.create(:name => 'photos')
+ Widget.create(:ey_module_id => mod.id, :name => 'photos_home', :description => 'Slide show of photos', :profile => false)
+ Widget.create(:ey_module_id => mod.id, :name => 'photos_profile', :description => 'Slide show of photos', :profile => true)
+
+ mod = EyModule.create(:name => 'html_content')
+ Widget.create(:ey_module_id => mod.id, :name => 'html_content_home', :description => 'Managed Content Widget', :profile => false)
+
+ mod = EyModule.create(:name => 'status_posts')
+ Widget.create(:ey_module_id => mod.id, :name => 'status_posts_profile', :description => 'Display users status posts', :profile => true)
+
+ mod = EyModule.create(:name => 'about_me')
+ Widget.create(:ey_module_id => mod.id, :name => 'about_me_profile', :description => 'Display users bio', :profile => true)
+
+
+ ##########################################################################
+ # Create Pages
+ puts 'Creating pages...'
+ home_pg = Page.create(:name => 'home', :title => 'RubyMI Home')
+ prof_pg = Page.create(:name => 'profile', :title => 'User Profile')
+
+
+ ##########################################################################
+ # Create Nav Items
+ puts 'Creating nav items...'
+ NavItem.create(:name => 'main', :title => 'Home', :url => '/',
+ :login_required => false, :login_allowed => true,
+ :admin_required => false, :enabled => true)
+ NavItem.create(:name => 'profile', :title => 'My Page', :url => '/users',
+ :login_required => true, :login_allowed => true,
+ :admin_required => false, :enabled => true)
+ NavItem.create(:name => 'members', :title => 'Members', :url => '/users',
+ :login_required => false, :login_allowed => true,
+ :admin_required => false, :enabled => true)
+ NavItem.create(:name => 'blogs', :title => 'Blogs', :url => '/blog_posts',
+ :login_required => false, :login_allowed => true,
+ :admin_required => false, :enabled => true)
+ NavItem.create(:name => 'groups', :title => 'Groups', :url => '/groups',
+ :login_required => false, :login_allowed => true,
+ :admin_required => false, :enabled => true)
+ NavItem.create(:name => 'events', :title => 'Events', :url => '/events',
+ :login_required => false, :login_allowed => true,
+ :admin_required => false, :enabled => true)
+ NavItem.create(:name => 'photos', :title => 'Photos', :url => '/photo_manager',
+ :login_required => false, :login_allowed => true,
+ :admin_required => false, :enabled => true)
+ NavItem.create(:name => 'manage', :title => 'Manage', :url => '/admin',
+ :login_required => true, :login_allowed => true,
+ :admin_required => true, :enabled => false)
+
+
+ ##########################################################################
+ # Create Layouts
+ puts 'Creating layouts...'
+ WidgetLayout.create(:widget_id => Widget.find_by_name("events_profile").id, :page_id => home_pg.id, :col_num => 1)
+ WidgetLayout.create(:widget_id => Widget.find_by_name("photos_profile").id, :page_id => home_pg.id, :col_num => 1)
+
+ WidgetLayout.create(:widget_id => Widget.find_by_name("status_posts_profile").id, :page_id => home_pg.id, :col_num => 2)
+ WidgetLayout.create(:widget_id => Widget.find_by_name("activity_feed_home").id, :page_id => home_pg.id, :col_num => 2)
+
+
+ WidgetLayout.create(:widget_id => Widget.find_by_name("groups_profile").id, :page_id => prof_pg.id, :col_num => 1)
+
+ WidgetLayout.create(:widget_id => Widget.find_by_name("status_posts_profile").id, :page_id => prof_pg.id, :col_num => 2)
+ WidgetLayout.create(:widget_id => Widget.find_by_name("about_me_profile").id, :page_id => prof_pg.id, :col_num => 2)
+ WidgetLayout.create(:widget_id => Widget.find_by_name("activity_feed_profile").id, :page_id => prof_pg.id, :col_num => 2)
+
+ WidgetLayout.create(:widget_id => Widget.find_by_name("events_profile").id, :page_id => prof_pg.id, :col_num => 3)
+ WidgetLayout.create(:widget_id => Widget.find_by_name("links_profile").id, :page_id => prof_pg.id, :col_num => 3)
+
+
+ ##########################################################################
+ # Set Theme
+ puts 'Setting theme...'
+ Theme.create(:name=>'facebook_clone')
+
+
+ puts 'Database population done!'
+ end
+ end
+end
BIN  public/images/themes/facebook_clone/preview.gif
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 public/javascripts/application.js
View
@@ -225,3 +225,41 @@ function forum_post_reply_saved(request) {
tinyMCE.activeEditor.setContent("");
}
+function like_activity_item(activity_id, user_id, like_id) {
+ $.post('/likes.json',
+ '&user_id=' + user_id + '&likable_id=' + activity_id +'&likable_type=Activity',
+ function (data) {activity_like_saved(data, activity_id, user_id, like_id);});
+}
+
+function unlike_activity_item(activity_id, user_id, like_id) {
+ $.ajax({url:'/likes/' + like_id + '.json',
+ type: 'POST',
+ data: '_method=delete',
+ dataType: 'text',
+ success: function (data) {activity_like_saved(data, activity_id, user_id, like_id);},
+ });
+}
+
+function activity_like_saved(data, activity_id, user_id, like_id) {
+ if (data.id) {
+ like_id = data.id;
+ }
+ $.get('/likes/like_text',
+ '&activity_id=' + activity_id,
+ function(data) {update_like_text(data, activity_id, user_id, like_id);})
+}
+
+function update_like_text(data, activity_id, user_id, like_id) {
+ $('#like_users' + activity_id).html(data);
+ // change like/dislike link
+ if ($('#like_lnk_' + activity_id).html() == 'Unlike') {
+ $('#like_lnk_' + activity_id).html('Like');
+ var href = "javascript:like_activity_item(" + activity_id + ", " + user_id + "," + like_id + ")";
+ $('#like_lnk_' + activity_id).attr("href", href);
+ }
+ else {
+ $('#like_lnk_' + activity_id).html('Unlike');
+ var href = "javascript:unlike_activity_item(" + activity_id + ", " + user_id + "," + like_id + ")";
+ $('#like_lnk_' + activity_id).attr("href", href);
+ }
+}
154 public/stylesheets/themes/facebook_clone/facebook_clone.css
View
@@ -0,0 +1,154 @@
+body {
+ font-family:"lucida grande",tahoma,verdana,arial,sans-serif;
+}
+
+a, a:visited, #user_control_widget a, #user_control_widget a:visited {
+ color: #3B5998;
+}
+
+#content {
+ width: 100%;
+}
+
+#main {
+ width: 981px;
+ margin: auto;
+ border-right:1px solid #BBBBBB;
+}
+
+#header, #footer {
+ background-color: #3B5998 !important;
+ width: 100%;
+ height: 40px;
+}
+
+#header a, #header a:visited {
+ color: white;
+}
+
+#logo_text {
+ float: left;
+ width: 150px;
+ margin-left: 150px;
+ font-weight: bold;
+ font-size:14pt;
+ color: white;
+ padding-top: 10px;
+}
+
+#header #navigation {
+ margin-left: 60px;
+ width: 300px;
+}
+
+.current_menu {
+ background-color: white;
+}
+
+.nav_list_item {
+ height: 24px;
+}
+
+.nav_list_link {
+ height: 18px;
+}
+
+.column_1 {
+ width: 175px;
+}
+
+.column_2 {
+ width: 470px;
+ border-left:1px solid #BBBBBB;
+}
+
+.activity_item {
+ float: left;
+ clear: both;
+ border-bottom:1px solid #BBBBBB;
+ padding-top: 10px;
+ padding-bottom: 10px;
+}
+
+.activity_user_img {
+ float: left;
+ width: 80px;
+}
+
+.activity_feed_item {
+ float: left;
+ width: 380px;
+ border: none;
+ font-size: 13px;
+}
+
+.activity_user_link {
+ font-weight: bold;
+ font-size: 13px;
+}
+
+.activity_user_link a {
+ text-decoration: none;
+}
+
+.activity_user_link a:hover {
+ text-decoration: underline;
+}
+
+.activity_text {
+ float: left;
+ margin-left: 8px;
+}
+
+.activity_date {
+ font-size: 11px;
+ color: #808080;
+ width: 50px;
+ float: left;
+ clear: both;
+ line-height: 1em;
+ margin-top: 8px;
+ margin-left: 10px;
+}
+
+.like_link {
+ float: left;
+ width: 40px;
+ line-height: 1em;
+}
+
+.activity_likes {
+ font-size: 11px;
+ margin-top: 8px;
+ float: left;
+}
+
+.like_users {
+ float: left;
+ color: #808080;
+ line-height: 1em;
+}
+
+.like_link a, .like_link a:visited {
+ font-size: 11px;
+}
+
+.like_link a {
+ text-decoration: none;
+}
+
+.like_link a:hover {
+ text-decoration: underline;
+}
+
+#user_control_widget {
+ width: 175px;
+}
+
+#activity_feed_home_head {
+ display: none;
+}
+
+#status_posts_profile_head {
+ display: none;
+}
8 test/functional/likes_controller_test.rb
View
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class LikesControllerTest < ActionController::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
4 test/unit/helpers/likes_helper_test.rb
View
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class LikesHelperTest < ActionView::TestCase
+end
96 themes/facebook_clone/views/home/index.html.erb
View
@@ -0,0 +1,96 @@
+<%#
+Copyright 2009 Timothy Fisher
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+%>
+
+<% content_for :script_content do %>
+ <script>
+ function page_init() {
+ // delay slideshow start to allow photos widget to load via ajax
+ setTimeout(start_slideshow, 10000);
+ }
+
+ function start_slideshow() {
+ <% photo = @photos[0] %>
+ var slide_show = new SlideShow("widget_photo", 3000);
+ <% @photos.each do |photo| %>
+ {
+ var img<%= photo.id %> = new Image();
+ img<%= photo.id %>.onload = function(){slide_show.add_slide(img<%= photo.id %>);};
+ img<%= photo.id %>.src = "<%= photo.public_filename(:display) %>";
+ }
+ <% end %>
+ }
+ </script>
+<% end %>
+
+<% if logged_in? %>
+ <div class="col1">
+ <div class="column_1">
+ <% if flash[:notice] %>
+ <div class="notice"><%= flash[:notice] %></div>
+ <% end %>
+ <%= render :partial => 'users/user_control_widget' %>
+ <div id="col_1_widgets"></div>
+ </div>
+ <div class="column_2">
+ <h2>News Feed</h2>
+ <div id="col_2_widgets"></div>
+ <!-- display HTML widgets
+ <% if @html_contents %>
+ <% @html_contents.each do |html_content| %>
+ <%= render :partial => 'html_contents/html_content_widget', :locals=>{:content=>html_content} %>
+ <% end %>
+ <% end %>
+ -->
+ </div>
+ </div>
+ <div class="col2">
+ <!-- place holder for AJAX widgets -->
+ <div id="col_3_widgets"></div>
+ </div>
+ <div style="clear:both;"></div>
+<% else %>
+ <div class="main">
+ <% if flash[:notice] %>
+ <div class="notice"><%= flash[:notice] %></div>
+ <% end %>
+ <div id="login_form">
+ <h5>Sign in with your login and password</h5>
+ <% form_tag session_path do -%>
+ <div class="form_field">
+ <label for="login">Login:</label>
+ <%= text_field_tag 'login' %>
+ </div>
+ <div class="form_field">
+ <label for="password">Password:</label>
+ <%= password_field_tag 'password' %>
+ </div>
+ <div id="login_btn">
+ <%= submit_tag 'Log in', :class=>'login_btn' %>
+ </div>
+ <% end -%>
+ <div style="clear:both;"></div>
+ </div>
+ <% if Configuration.ENABLE_FACEBOOK_CONNECT %>
+ <div id="facebook_login">
+ <h5>Signin with your Facebook account</h5>
+ <div id="facebook_login_button">
+ <%= fb_login_button('window.location = "/users/link_facebook_account";')%>
+ </div>
+ </div>
+ <% end %>
+ <div style="clear:both;"></div>
+ </div>
+<% end %>
81 themes/facebook_clone/views/layouts/application.html.erb
View
@@ -0,0 +1,81 @@
+<%#
+Copyright 2009 Timothy Fisher
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html>
+<head>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+ <title><%= @network.name %></title>
+ <link rel="shortcut icon" href="/favicon.ico" />
+ <%= stylesheet_link_tag 'style' %>
+ <%= stylesheet_link_tag 'themes/facebook_clone/facebook_clone' %>
+
+ <%= javascript_include_tag "jquery-1.4.2.min.js" %>
+
+ <%= javascript_include_tag "widget" %>
+
+ <%= render 'layouts/widgets' %>
+
+ <%= javascript_include_tag "slide_show" %>
+
+ <%= yield :script_content %>
+
+ <%= javascript_include_tag "application" %>
+
+ <script type="text/javascript">
+ var authenticity_token = "<%= form_authenticity_token %>";
+ </script>
+
+ <%= include_tiny_mce_if_needed %>
+
+ <%= javascript_tag "var AUTH_TOKEN = #{form_authenticity_token.inspect};" if protect_against_forgery? %>
+
+</head>
+
+<body>
+ <% if Configuration.ENABLE_FACEBOOK_CONNECT %>
+ <%= fb_connect_javascript_tag %>
+ <%= init_fb_connect('XFBML', :js => :jquery) %>
+ <% end %>
+ <div id="content">
+ <div id="header">
+ <div id="logo_text">Social Network</div>
+ <%= render :partial => 'shared/nav_menu' %>
+ </div>
+ <div id="main">
+ <% if @section == 'MAIN' || @section == 'PROFILE' || (@section == 'MEMBERS' && @user != nil)%>
+ <%= yield %>
+ <% else %>
+ <div class="col1">
+ <%= yield %>
+ </div>
+ <div class="col2">
+
+ </div>
+ <div style="clear:both;"></div>
+ <% end %>
+ </div>
+ <div id="footer">
+ <%= render :partial => 'shared/footer' %>
+ </div>
+ <div style="clear:both;"></div>
+ </div>
+ <%= render '/layouts/analytics' %>
+</body>
+
+</html>
+
90 themes/facebook_clone/views/shared/_nav_menu.html.erb
View
@@ -0,0 +1,90 @@
+<%#
+Copyright 2009 Timothy Fisher
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+%>
+
+<%
+# These are the items displayed in the top navigation bar
+# if restricted = true, this means that the item requires a logged in user
+# and the logged in user's id will be appended to the url
+# To remove an item from the menu bar, just comment out the corresponding line here
+def nav_menu_items
+ [
+ {'name'=>'main', 'title'=>'Home', 'url'=>'/', 'restricted'=>'false', 'roles'=>''},
+ {'name'=>'profile','title'=>'Profile', 'url'=>"/users", 'restricted'=>'true', 'roles'=>''},
+ {'name'=>'events', 'title'=>'Events', 'url'=>'/events', 'restricted'=>'false', 'roles'=>''},
+ {'name'=>'photos', 'title'=>'Photos', 'url'=>'/photo_manager', 'restricted'=>'false', 'roles'=>''},
+ #{'name'=>'manage','title'=>'Manage', 'url'=>'/admin', 'restricted'=>'true', 'roles'=>'admin'}
+ ]
+end
+%>
+
+<% nav_items = NavItem.find_all_by_enabled(true) %>
+
+<div id="navigation">
+ <% if logged_in? %>
+ <ul id="nav_list">
+ <% nav_menu_items.each do |item| %>
+ <% if item['restricted'] == 'false' || logged_in? %>
+ <!-- Item is not restricted or a user is logged in -->
+ <% if item['roles'] != '' %>
+ <!-- Item is role restricted -->
+ <% else %>
+ <!-- Item is not role restricted -->
+ <% if @section == item['name'].upcase %>
+ <li id="current_menu" class="nav_list_item current_menu">
+ <% if item['restricted'] == 'true' && logged_in? %>
+ <%= link_to item['title'], item['url'] + "/#{current_user.id}", :class=>'nav_list_link' %>
+ <% else %>
+ <%= link_to item['title'], item['url'], :class=>'nav_list_link' %>
+ <% end %>
+ </li>
+ <% else %>
+ <% if item['restricted'] == 'true' && logged_in? %>
+ <li class="nav_list_item">
+ <%= link_to item['title'], item['url'] + "/#{current_user.id}", :class=>'nav_list_link' %>
+ </li>
+ <% else %>
+ <li class="nav_list_item">
+ <%= link_to item['title'], item['url'], :class=>'nav_list_link' %>
+ </li>
+ <% end %>
+ <% end %>
+ <% end %>
+ <% else %>
+ <!-- Item is restricted or a user is not logged in -->
+ <!-- do not show menu item -->
+ <% end %>
+ <% end %>
+
+ <% if logged_in_as_admin? %>
+ <% if @section == 'MANAGE' %>
+ <li id="current_menu" class="nav_list_item current_menu"><%= link_to 'Manage', { :controller=>'admin'}, :class=>'nav_list_link' %></li>
+ <% else %>
+ <li class="nav_list_item"><%= link_to 'Manage', { :controller=>'admin'}, :class=>'nav_list_link' %></li>
+ <% end %>
+ <% end %>
+ </ul>
+ <!--
+ <ul id="nav_list_right" style="float:right;">
+ <% if @section == 'BUG' %>
+ <li class="nav_list_item current_menu" id="current_menu"><%= link_to 'Report a Bug', bug_reports_url, :class=>'nav_list_link' %></li>
+ <% else %>
+ <li class="nav_list_item"><%= link_to 'Report a Bug', bug_reports_url, :class=>'nav_list_link' %></li>
+ <% end %>
+ </ul>
+ -->
+ <div style="clear:both;"></div>
+ <% end %>
+</div>
9 themes/facebook_clone/views/status_posts/_status_post_form.html.erb
View
@@ -0,0 +1,9 @@
+<form style="display:inline;" id="status_post_entry_form" name="status_post_entry_form" action="/status_posts/create" method="POST">
+ <input type="hidden" id="authenticity_token" name="authenticity_token" value="<%= form_authenticity_token %>" />
+ <input type="hidden" id="layout_id" name="layout_id" value="<%= @layout.id %>" />
+ <input type="hidden" id="activity_layout_id" name="activity_layout_id" value="<%= @activity_profile_layout_id %>" />
+ <label>What's on your mind?</label><br/>
+ <%= text_area(:status_post, :body, :cols => 60, :rows => 3 ) %>
+ <a href="javascript:post_status()">Submit</a>
+ <!-- include checkbox to send post to Twitter -->
+</form>
52 themes/facebook_clone/views/users/show.html.erb
View
@@ -0,0 +1,52 @@
+<%#
+Copyright 2009 Timothy Fisher
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+%>
+<%= stylesheet_link_tag 'profile' %>
+
+<div class="col1">
+ <div class="profile">
+ <div class="column_1">
+ <div id="user_photo" class="user_profile_section">
+ <% if (@user.profile_photo) %>
+ <%= image_tag(@user.profile_photo.public_filename()) %>
+ <% else %>
+ <div class="no_photo_member"></div>
+ <% end %>
+ </div>
+ <div id="user_detail" class="user_profile_section">
+ <%= render :partial => 'user_detail_widget' %>
+ </div>
+ <div id="user_friends" class="user_profile_section">
+ <%= render :partial => 'friends/friends_widget' %>
+ </div>
+ <div id="col_1_widgets"></div>
+ </div>
+ <div class="column_2">
+ <div id="col_2_widgets"></div>
+ <% if @user.twitter_id && @user.display_tweets %>
+ <%= render :partial => 'tweets/display_tweets' %>
+ <% end %>
+ <%= render :partial => 'shared/wall_posts_widget', :locals=>{:parent=>@user} %>
+ </div>
+ </div>
+</div>
+<div class="col2">
+ <%= render :partial => 'users/add_friend_widget' %>
+ <% if current_user == @user %>
+ <%= render :partial => 'messages/unread_messages_widget' %>
+ <% end %>
+ <div id="col_3_widgets"></div>
+</div>
+<div style="clear:both;"></div>
65 themes/facebook_clone/views/widgets/activity_feed_home.html.erb
View
@@ -0,0 +1,65 @@
+<%#
+Copyright 2009 Timothy Fisher
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+%>
+<% widget_title = "Latest Activity" %>
+
+<% if logged_in? && include_friends %>
+ <% @user = User.find(current_user.id) %>
+ <% activities = @user.friends_activity_stream %>
+<% else %>
+ <% activities = Activity.find(:all, :limit=>8, :order=>'created_at DESC', :include=>[:user, :item]) %>
+<% end %>
+<% @activities = activities[0...8] %>
+
+
+<% content_for :module_body do %>
+ <% @activities.each do |activity| %>
+ <div class="activity_item">
+ <div class="activity_user_img">
+ <% if activity.user %>
+ <% if activity.user.profile_photo %>
+ <%= link_to image_tag(activity.user.profile_photo.public_filename(:small), :alt=>activity.user.name), user_url(activity.user) %>
+ <% else %>
+ <%= link_to '<div class="no_photo_user_widget"></div>', user_url(activity.user) %>
+ <% end %>
+ <% else %>
+ No User
+ <% end %>
+ </div>
+ <div class="activity_feed_item">
+ <%= activity_feed_message(activity) %>
+ <div class="activity_likes">
+ <span class="like_link">
+ <% if current_user.like_this?(activity) == true %>
+ <a id="like_lnk_<%= activity.id.to_s %>" href="javascript:unlike_activity_item(<%= activity.id %>, <%= current_user.id %>, <%= current_user.get_like(activity).id %>)">Unlike</a>
+ <% else %>
+ <a id="like_lnk_<%= activity.id.to_s %>" href="javascript:like_activity_item(<%= activity.id %>, <%= current_user.id %>, null)">Like</a>
+ <% end %>
+ </span>
+ <span class="like_users" id="like_users<%= activity.id.to_s %>">
+ <%= display_like_text(activity) %>
+ </span>
+ <div class="clear:both;"></div>
+ </div>
+ </div>
+ </div>
+ <% end %>
+<% end %>
+
+<% content_for :module_footer do %>
+ <%= link_to 'View All', activities_path %>&nbsp;|&nbsp;
+ <%= link_to 'RSS', formatted_activities_url(:rss) %>
+ <%= link_to image_tag('feed.png', :alt=>'rss', :align=>'absmiddle'), formatted_activities_url(:rss) %>
+<% end %>
41 themes/facebook_clone/views/widgets/activity_feed_profile.html.erb
View
@@ -0,0 +1,41 @@
+<%#
+Copyright 2009 Timothy Fisher
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+%>
+<% widget_title = "Latest Activity" %>
+
+<% @user = User.find(user_id) %>
+<% if only_statuses && include_friends %>
+ <% activities = @user.friends_status_activity_stream %>
+<% elsif include_friends %>
+ <% activities = @user.friends_activity_stream %>
+<% elsif only_statuses %>
+ <% activities = @user.status_activity_stream %>
+<% else %>
+ <% activities = @user.activities %>
+<% end %>
+<% @activities = activities[0...8] %>
+
+
+<% content_for :module_body do %>
+ <% @activities.each do |activity| %>
+ <div class="activity_feed_item"><%= activity_feed_message(activity) %></div>
+ <% end %>
+<% end %>
+
+<% content_for :module_footer do %>
+ <%= link_to 'View All', user_activities_path(@user) %>&nbsp;|&nbsp;
+ <%= link_to 'RSS', formatted_activities_url(:rss) %>
+ <%= link_to image_tag('feed.png', :alt=>'rss', :align=>'absmiddle'), formatted_activities_url(:rss) %>
+<% end %>
57 themes/facebook_clone/views/widgets/events_profile.html.erb
View
@@ -0,0 +1,57 @@
+<%#
+Copyright 2009 Timothy Fisher
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+%>
+<% widget_title = "My Events" %>
+
+<% @user = User.find(user_id) %>
+
+<% content_for :module_header do %>
+ <div class="head_left">
+ <%= image_tag('calendar.png', :alt=>'events', :align=>'absmiddle')%>&nbsp;&nbsp;<%= widget_title %>
+ </div>
+ <div class="head_right">
+ <div id="expand_collapse_btn">
+ <a href="javascript:widget_change_display('my_events')">
+ <img id="my_events_collapse_img" src="/images/collapse.png"/>
+ </a>
+ </div>
+ </div>
+ <div style="clear:both;"></div>
+<% end %>
+
+<% content_for :module_body do %>
+ <% @user.events.each do |event| %>
+ <div>
+ <span class="event_name">
+ <%= link_to event.name, event_url(event) %>
+ </span><br/>
+ <%= event.start_time.to_s(:event_brief) %><br/>
+ <%= event.location %>
+ </div>
+ <% end %>
+ <% if @user.events.length == 0 %>
+ <% if @user == current_user %>
+ You have no events scheduled.<br/>
+ <% else %>
+ User has no events scheduled.<br/>
+ <% end %>
+ <%= link_to 'View all events...', events_url() %>
+ <% end %>
+ <div style="clear:both;"></div>
+<% end %>
+
+<% content_for :module_footer do %>
+
+<% end %>
56 themes/facebook_clone/views/widgets/photos_profile.html.erb
View
@@ -0,0 +1,56 @@
+<%#
+Copyright 2009 Timothy Fisher
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+%>
+<% widget_title = "My Photos" %>
+
+<% @user = User.find(user_id) %>
+
+<% content_for :module_header do %>
+ <div class="head_left">
+ <%= image_tag('photos.png', :alt=>'events', :align=>'absmiddle')%>&nbsp;&nbsp;<%= widget_title %>
+ </div>
+ <div class="head_right">
+
+ </div>
+ <div style="clear:both;"></div>
+<% end %>
+
+<% content_for :module_body do %>
+ <% displayed = 0 %>
+ <% @user.photos.each do |photo| %>
+ <% if photo.is_profile == false || photo.is_profile == nil %>
+ <% displayed = displayed + 1 %>
+ <div class="photo_display">
+ <%= link_to image_tag(photo.public_filename(:medium)), photo_path(photo.id) %>
+ </div>
+ <% end %>
+ <% end %>
+ <% if displayed == 0 %>
+ <% if @user == current_user %>
+ You have not uploaded any photos yet.
+ <% else %>
+ User has not uploaded any photos.
+ <% end %>
+ <% end %>
+ <div style="clear:both;"></div>
+<% end %>
+
+<% content_for :module_footer do %>
+ <% if logged_in? %>
+ <div class="foot_left"><%= link_to 'Add Photos', new_photo_path %></div>
+ <% end %>
+ <div class="foot_right"><%= link_to 'View All', photos_url %></div>
+ <div style="clear:both;"></div>
+<% end %>
28 themes/facebook_clone/views/widgets/status_posts_profile.html.erb
View
@@ -0,0 +1,28 @@
+<%#
+Copyright 2009 Timothy Fisher
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+%>
+
+<% widget_title = 'Status' %>
+
+<% @user = User.find(user_id) %>
+
+<% content_for :module_body do %>
+ <% if logged_in? && current_user == @user %>
+ <%= render :partial => 'status_posts/status_post_form' %>
+ <% end %>
+ <div id="current_status">
+ <%= show_last_post(@user) %>
+ </div>
+<% end %>
Please sign in to comment.
Something went wrong with that request. Please try again.