Permalink
Browse files

+feed, some views

  • Loading branch information...
1 parent 6316271 commit 11af9f6ec0f32b89cb9f4e3f4ef989db8ab40374 @DarTSeNSe committed Dec 10, 2011
@@ -1,18 +1,18 @@
.container {
- width: 710px;
+ width: 1024px;
}
body {
- background: #cccccc;
+ background: #ccccff;
}
header {
- padding-top: 40px;
+ padding-top: 80px;
}
header img {
padding: 1em;
- background: #fff;
+ background: #ffff99;
}
section {
@@ -49,7 +49,7 @@ nav {
}
nav {
- background-color: white;
+ background-color: #ffff99;
padding: 0 0.7em;
white-space: nowrap;
}
@@ -128,7 +128,7 @@ td.sidebar {
width: 30%;
padding: 1em;
vertical-align: top;
- background: #ffcccc;
+ background: #ffccff;
}
.profile img.gravatar {
@@ -2,7 +2,10 @@ class PagesController < ApplicationController
def home
@title = "Home"
- @phrase = Phrase.new if signed_in?
+ #if signed_in?
+ # @phrase = Phrase.new
+ # @feed_items = current_user.feed.paginate(:page => params[:page])
+ #end
end
def contact
@@ -8,6 +8,7 @@ def create
flash[:success] = "Phrase created!"
redirect_to root_path
else
+ @feed_items = []
render 'pages/home'
end
end
@@ -7,7 +7,6 @@ class UsersController < ApplicationController
def show
@user = User.find(params[:id])
- @phrases = @user.phrases.paginate(:page => params[:page])
@title = @user.name
end
View
@@ -15,7 +15,6 @@ class Phrase < ActiveRecord::Base
validates :tag, :presence => true,
:length => { :maximum => 16 }
validates :user_id, :presence => true
- validates :language_id, :presence => true
default_scope :order => 'phrase.created_at DESC'
end
View
@@ -38,6 +38,10 @@ def self.authenticate_with_salt(id, cookie_salt)
(user && user.salt == cookie_salt) ? user : nil
end
+ def feed
+ Phrase.where("user_id = ?", id)
+ end
+
private
def encrypt_password
@@ -2,8 +2,7 @@
<table class="front" summary="For signed-in users">
<tr>
<td class="main">
- <h1 class="phrase">Your phrase:</h1>
- <%= render 'shared/phrase_form' %>
+
</td>
<td class="sidebar round">
<%= render 'shared/user_info' %>
@@ -1,8 +0,0 @@
-<tr>
- <td class="phrase">
- <span class="content"><%= phrase.content %></span>
- <span class="timestamp">
- Posted <%= time_ago_in_words(phrase.created_at) %> ago.
- </span>
- </td>
-</tr>
@@ -0,0 +1,16 @@
+<tr>
+ <td class="phrase">
+ <span class="content"><%= phrase.phrase %></span>
+ <span class="content"><%= phrase.tag %></span>
+ <span class="timestamp">
+ Posted <%= time_ago_in_words(phrase.created_at) %> ago.
+ </span>
+ </td>
+ <% if current_user?(phrase.user) %>
+ <td>
+ <%= link_to "delete", phrase, :method => :delete,
+ :confirm => "Are You sure?",
+ :title => phrase.phrase %>
+ </td>
+ <% end %>
+</tr>
@@ -0,0 +1,6 @@
+<% unless @feed_items.empty? %>
+ <table class="phrases" summary="User phrases">
+ <%= render :partial => 'shared/feed_item', :collection => @feed_items %>
+ </table>
+ <%= will_paginate @feed_items %>
+<% end %>
@@ -0,0 +1,21 @@
+<tr>
+ <td class="gravatar">
+ <%= link_to gravatar_for(feed_item.user), feed_item.user %>
+ </td>
+ <td class="phrase">
+ <span class="user">
+ <%= link_to feed_item.user.name, feed_item.user %>
+ </span>
+ <span class="content"><%= feed_item.phrase %></span>
+ <span class="timestamp">
+ Posted <%= time_ago_in_words(feed_item.created_at) %> ago.
+ </span>
+ </td>
+ <% if current_user?(feed_item.user) %>
+ <td>
+ <%= link_to "delete", feed_item, :method => :delete,
+ :confirm => "Are You sure?",
+ :title => feed_item.phrase %>
+ </td>
+ <% end %>
+</tr>
@@ -5,12 +5,7 @@
<%= gravatar_for @user %>
<%= @user.name %>
</h1>
- <% unless @user.phrases.empty? %>
- <table class="phrases" summary="User phrases">
- <%= render @phrases %>
- </table>
- <%= will_paginate @phrases %>
- <% end %>
+
</td>
<td class="sidebar round">
<strong>Name</strong> <%= @user.name %><br />
@@ -17,5 +17,11 @@ namespace :db do
:password => password,
:password_confirmation => password)
end
+
+ User.all(:limit => 6).each do |user|
+ 50.times do
+ user.phrases.create!(:phrase => Faker::Lorem.sentence(5), :tag => Faker::name)
+ end
+ end
end
end

0 comments on commit 11af9f6

Please sign in to comment.