Skip to content

Commit

Permalink
added final stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Berry committed Nov 10, 2009
1 parent 3cb4643 commit a75fd50
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 0 deletions.
33 changes: 33 additions & 0 deletions app/views/home/following.html.erb
@@ -0,0 +1,33 @@
<ul id="flits_list">
<% @friends.each do |friend| %>
<li<% if @friends.first == friend %> class="first"<% end %> id="<%= friend.username %>">
<%= image_tag friend.gravatar_url %>
<div class="flit_message_container" style="width: 305px;">
<h3><%= link_to friend.username, user_flits_path(friend.username) %></h3>
<% if friend.flits.length > 0 %>
<%= h friend.flits.last.message %>
<%= distance_of_time_in_words_to_now(friend.flits.last.created_at) %> ago
<% end %>
</div>
<div class="button_container">
<input type="button" name="<%= friend.username %>" class="button ajax_button" value="Stop Following"/>
</div>
<div class="clear"></div>
</li>
<% end %>
</ul>

<script type="text/javascript">
$(function() {
$('.ajax_button').click(function() {
$.ajax({
type: "POST",
url: "/remove_friend/" + $(this).attr('name'),
success: function(msg){
//alert( "You are no longer following: " + msg );
$('#' + msg).slideUp('slow');
}
});
})
});
</script>
38 changes: 38 additions & 0 deletions app/views/home/search.html.erb
@@ -0,0 +1,38 @@
<ul id="flits_list">
<% @friends.each do |friend| %>
<li<% if @friends.first == friend %> class="first"<% end %> id="<%= friend.username %>">
<%= image_tag friend.gravatar_url %>
<div class="flit_message_container" style="width: 305px;">
<h3><%= link_to friend.username, user_flits_path(friend.username) %></h3>
<% if friend.flits.length > 0 %>
<%= h friend.flits.last.message %>
<%= distance_of_time_in_words_to_now(friend.flits.last.created_at) %> ago
<% end %>
</div>
<div class="button_container">
<input type="button" name="<%= friend.username %>" id="btn_<%= friend.username %>" class="button ajax_button"
value="<% if current_user.is_friend? friend %>Stop Following<% else %>Follow<% end %>"/>
</div>
<div class="clear"></div>
</li>
<% end %>
</ul>

<script type="text/javascript">
$(function() {
$('.ajax_button').click(function() {
$.ajax({
type: "POST",
url: "/" + $(this).attr('name') + "/toggle_follow_via_ajax",
success: function(msg){
elm = $('#btn_' + msg);
if (elm.val() == "Stop Following") {
elm.val("Follow");
} else {
elm.val("Stop Following");
}
}
});
})
});
</script>
27 changes: 27 additions & 0 deletions app/views/includes/_side_contents.html.erb
@@ -0,0 +1,27 @@
<div id="my_info_container">
<%= link_to image_tag(current_user.gravatar_url(:size => 30), :border => 0), user_flits_path(current_user.username) %>
<div class="contents">
<%= link_to current_user.username, user_flits_path(current_user.username) %><br/>
<span class="small"><%= pluralize(current_user.flits.length, "Flit") %></span>
</div>
</div>
<div class="clear"></div>

<div id="side_content_container">
<h4><%= link_to "#{current_user.friends.count} following", following_path %></h4>
<h4><%= pluralize(current_user.friends_of.count, "follower") %></h4>
</div>

<% form_tag search_path do %>
<div id="search_bar">
<%= text_field_tag :q, @q, :class => "text" %>
<div id="search_submit_button">&nbsp;</div>
</div>
<% end %>

<div id="side_content_container">
<h4>Followers</h4>
<% current_user.friends_of.each do |friend| %>
<%= link_to image_tag(friend.gravatar_url(:size => 25), :border => 0, :alt => friend.username, :title => friend.username), user_flits_path(friend.username) %>
<% end %>
</div>
17 changes: 17 additions & 0 deletions db/migrate/20091108192658_add_indexes_to_users.rb
@@ -0,0 +1,17 @@
class AddIndexesToUsers < ActiveRecord::Migration
def self.up
add_index :users, :username
add_index :users, :email
add_index :friendships, :user_id
add_index :friendships, :friend_id
add_index :flits, :user_id
end

def self.down
remove_index :users, :username
remove_index :users, :email
remove_index :friendships, :user_id
remove_index :friendships, :friend_id
remove_index :flits, :user_id
end
end
Binary file added public/images/bg-clouds.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/nav_search_submit.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit a75fd50

Please sign in to comment.