<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/views/contacts/_contact.html.erb</filename>
    </added>
    <added>
      <filename>app/views/contacts/_form.html.erb</filename>
    </added>
    <added>
      <filename>app/views/contacts/edit.html.erb</filename>
    </added>
    <added>
      <filename>app/views/contacts/new.html.erb</filename>
    </added>
    <added>
      <filename>public/images/delete.gif</filename>
    </added>
    <added>
      <filename>public/images/globe.gif</filename>
    </added>
    <added>
      <filename>public/images/gravatar.gif</filename>
    </added>
    <added>
      <filename>public/images/home.gif</filename>
    </added>
    <added>
      <filename>public/images/mail.gif</filename>
    </added>
    <added>
      <filename>public/images/mobile.gif</filename>
    </added>
    <added>
      <filename>public/images/phone.gif</filename>
    </added>
    <added>
      <filename>public/images/table.gif</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,2 +1,6 @@
 class Application &lt; Merb::Controller
+  private
+    def current_user
+      session.authentication.user
+    end
 end
\ No newline at end of file</diff>
      <filename>app/controllers/application.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,55 @@
 class Contacts &lt; Application
+  before :ensure_authenticated
+  
   def index
-    render
+    @contacts = current_user.contacts.sorted
+    display @contacts
   end
   
   def new
     @contact = Contact.new
     display @contact
   end
+  
+  def create(contact)
+    @contact = current_user.contacts.build(contact)
+    
+    if @contact.save
+      message[:notice] = &quot;A new contact has been added!&quot;
+      redirect url(:contacts), :message =&gt; message
+    else
+      render :new
+    end
+  end
+  
+  def edit(id)
+    @contact = current_user.contacts.get(id)
+    raise NotFound unless @contact
+    
+    display @contact
+  end
+  
+  def update(id, contact)
+    @contact = current_user.contacts.get(id)
+    raise NotFound unless @contact
+    
+    if @contact.update_attributes(contact)
+      message[:notice] = &quot;The contact has been updated!&quot;
+      redirect url(:contacts), :message =&gt; message
+    else
+      render :edit
+    end
+  end
+  
+  def destroy(id)
+    @contact = current_user.contacts.get(id)
+    raise NotFound unless @contact
+    
+    if @contact.destroy
+      message[:notice] = &quot;The contact has been removed&quot;
+      redirect url(:contacts), :message =&gt; message
+    else
+      raise InternalServerError
+    end
+  end
 end</diff>
      <filename>app/controllers/contacts.rb</filename>
    </modified>
    <modified>
      <diff>@@ -8,7 +8,8 @@ class Users &lt; Application
     @user = User.new(user)
     
     if @user.save
-      redirect url(:login), :message =&gt; {:notice =&gt; &quot;Welcome to Contacts! Please login to access your account.&quot;}
+      message[:notice] = &quot;Welcome to Contacts! Please login to access your account.&quot;
+  	  redirect url(:session, :new), :message =&gt; message
     else
       render :new
     end</diff>
      <filename>app/controllers/users.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,8 +4,16 @@ module Merb
       message.collect {|type, text| tag(:p, text, :class =&gt; &quot;message #{type}&quot;) }.join
     end
     
-    def current_user
-      session.authentication.user
+    def photo_tag(email)
+      info = [
+        Digest::MD5.hexdigest(email), # =&gt; hash
+        36, # =&gt; size
+        'http%3A%2F%2Ff.simplesideias.com.br%2Fgravatar.gif' # =&gt; default gravatar
+      ]
+      
+      src = &quot;http://www.gravatar.com/avatar/%s?s=%s&amp;amp;r=g&amp;amp;d=%s&quot; % info
+      
+      '&lt;img src=&quot;%s&quot; alt=&quot;&quot; class=&quot;photo&quot; /&gt;' % src
     end
   end
 end</diff>
      <filename>app/helpers/global_helpers.rb</filename>
    </modified>
    <modified>
      <diff>@@ -10,4 +10,8 @@ class Contact
   property :address, String
   
   belongs_to :user
+  
+  def self.sorted
+    all :order =&gt; [:name.asc]
+  end
 end</diff>
      <filename>app/models/contact.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1 +1,13 @@
-You're in index of the Contacts controller.
\ No newline at end of file
+&lt;h2&gt;Your contacts&lt;/h2&gt;
+
+&lt;p&gt;
+	&lt;%= link_to &quot;Add contact&quot;, url(:new_contact) %&gt;
+&lt;/p&gt;
+
+&lt;div id=&quot;contacts&quot;&gt;
+	&lt;% unless @contacts.empty? %&gt;
+		&lt;%= partial :contact, :with =&gt; @contacts %&gt;
+	&lt;% else %&gt;
+		&lt;p&gt;You have no contacts&lt;/p&gt;
+	&lt;% end %&gt;
+&lt;/div&gt;
\ No newline at end of file</diff>
      <filename>app/views/contacts/index.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,10 @@ Merb.logger.info(&quot;Compiling routes...&quot;)
 Merb::Router.prepare do
   resources :users
   resources :session
-  resources :contacts
+  
+  #authenticate do
+    resources :contacts
+  #end
   
   slice(:merb_auth_slice_password, :name_prefix =&gt; nil, :path_prefix =&gt; &quot;&quot;)
   default_routes</diff>
      <filename>config/router.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,6 +6,7 @@
 body {
 	background: #727272 url(../images/bg.png) repeat-x;
 	font-family: &quot;Lucida Grande&quot;, Arial;
+	font-size: 13px;
 	padding: 20px;
 }
 
@@ -32,7 +33,6 @@ h2 {
 }
 
 p, ul {
-	font-size: 13px;
 	padding: 10px 0;
 }
 
@@ -43,6 +43,11 @@ ul {
 label {
 	display: block;
 	font-size: 14px;
+	padding-bottom: 3px;
+}
+
+label span {
+	color: #999;
 }
 
 input[type=text],
@@ -60,6 +65,16 @@ a:hover {
 	color: #900;
 }
 
+p.submit a {
+	color: #f00;
+	padding: 5px;
+}
+
+p.submit a:hover {
+	background: #f00;
+	color: #fff;
+}
+
 /* error message */
 div.error {
 	background: #fcc url(../images/error.png) no-repeat 15px 15px;
@@ -138,4 +153,112 @@ p.login-info {
 	position: absolute;
 	right: 0;
 	top: 0;
+	
+	-webkit-border-radius: 6px;
+	-moz-border-radius: 6px;
+}
+
+/* vcard */
+#contacts {
+	padding-top: 10px;
+}
+
+.vcard {
+	background: #e9e9e9;
+	border: 1px solid #ddd;
+	font-size: 11px;
+	margin-bottom: 15px;
+	padding: 10px 10px 20px 60px;
+	position: relative;
+	-webkit-border-radius: 10px;
+	-moz-border-radius: 10px;
+}
+
+img.photo {
+	left: 10px;
+	position: absolute;
+}
+
+.vcard span {
+	font-weight: bold;
+}
+
+.vcard span.email,
+.vcard span.street-address,
+.vcard span.organization-name {
+	font-weight: normal;
+}
+
+.vcard .type:after,
+.vcard .label:after {
+	content: &quot;:&quot;;
+}
+
+.vcard .email-group .label {
+	content: url(../images/mail.gif);
+}
+
+.vcard .adr .type {
+	content: url(../images/home.gif);
+}
+
+.vcard .mobile .type {
+	content: url(../images/mobile.gif);
+}
+
+.vcard .phone .type {
+	content: url(../images/phone.gif);
+}
+
+.vcard .org .label {
+	content: url(../images/globe.gif);
+}
+
+.vcard h3 {
+	font-size: 16px;
+}
+
+.vcard div {
+	padding-bottom: 3px;
+}
+
+.vcard .actions {
+	display: none;
+	padding: 0;
+}
+
+.vcard:hover .actions {
+	display: block;
+}
+
+.vcard .actions form {
+	bottom: 5px;
+	cursor: pointer;
+	display: inline;
+	position: absolute;
+	right: 5px;
+}
+
+.vcard .actions input {
+	background: none;
+	border: none;
+	color: #333;
+	cursor: pointer;
+}
+
+.vcard .actions a {
+	bottom: 5px;
+	color: #333;
+	position: absolute;
+	right: 50px;
+	text-decoration: none;
+}
+
+.vcard .actions input,
+.vcard .actions a {
+	font-size: 11px;
+}
+
+.vcard .actions form:before {
+	content: &quot; | &quot;;
 }
\ No newline at end of file</diff>
      <filename>public/stylesheets/master.css</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>06312b6860f61964dbd20870327aa8e6da7a2a8d</id>
    </parent>
  </parents>
  <author>
    <name>Nando Vieira</name>
    <email>fnando.vieira@gmail.com</email>
  </author>
  <url>http://github.com/fnando/merb-contacts-app/commit/7a50d37e4cd2b618edbc50dcbfad1b3ff7b479d5</url>
  <id>7a50d37e4cd2b618edbc50dcbfad1b3ff7b479d5</id>
  <committed-date>2008-11-21T16:09:49-08:00</committed-date>
  <authored-date>2008-11-21T16:09:49-08:00</authored-date>
  <message>Finished app... almost!</message>
  <tree>109440c49ca98cec5a277434abf2d130e4c44eae</tree>
  <committer>
    <name>Nando Vieira</name>
    <email>fnando.vieira@gmail.com</email>
  </committer>
</commit>
