Skip to content

Commit

Permalink
redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
mekhovov committed Apr 30, 2011
1 parent 2723ba8 commit 774ffb7
Show file tree
Hide file tree
Showing 22 changed files with 220 additions and 141 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -4,5 +4,5 @@ db/*.sqlite3
log/*.log
tmp/
public/system/
Gemfile.lock


3 changes: 3 additions & 0 deletions app/controllers/users_controller.rb
Expand Up @@ -4,6 +4,7 @@ class UsersController < ApplicationController
def index
@top_rated = Attach.all.sort_by {|att| att.likes.count}.reverse.paginate :page => params[:page], :per_page => 7
@new_added = Attach.order('updated_at DESC').limit(7)
@new_comments = Comment.order('updated_at DESC').limit(5)
get_index_view_type
end

Expand All @@ -22,6 +23,8 @@ def create

def show
@user = User.find(params[:id])
@user_photos = @user.attaches.paginate :page => params[:page], :per_page => 10, :order => 'created_at DESC'
@user.attaches.build
get_view_type
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Expand Up @@ -9,7 +9,7 @@ class User < ActiveRecord::Base
has_attached_photos
has_many :likes, :dependent => :destroy

accepts_nested_attributes_for :attaches, :allow_destroy => true, :reject_if => proc{ |att| att['photo'].blank?}
accepts_nested_attributes_for :attaches, :allow_destroy => true#, :reject_if => proc{ |att| att['photo'].blank?}

has_attached_file(:avatar,
:default_url => ":gravatar_url",
Expand Down
2 changes: 1 addition & 1 deletion app/views/attaches/_attach.haml
@@ -1,5 +1,5 @@
%span.photo_thumb
= image_tag attach.photo.url(:thumb), {:alt => attach.photo.url, :id => attach.id}
= link_to image_tag( attach.photo.url(:thumb), {:alt => attach.photo.url, :id => attach.id}), user_path(attach.user)
%span.comment-count= attach.comments.count
= form_for Like.new(:attach => attach), :html => {:id => "new_like_#{attach.id}"} do |f|
= f.hidden_field :attach_id
Expand Down
6 changes: 3 additions & 3 deletions app/views/devise/registrations/new.haml
Expand Up @@ -20,12 +20,12 @@
%label Email:
%span#er_email.errors
%br
= f.email_field :email, :size => 25
= f.email_field :email, :size => 22
%label#lb_password Password:
%span#er_password.errors
%br
= f.password_field :password, :size => 25
= f.password_field :password, :size => 22
%br
%label#conf_password Password confirm:
= f.password_field :password_confirmation, :size => 25
= f.password_field :password_confirmation, :size => 22
%button.large.large_w.awesome.yellow{:type => "submit"} Create account
4 changes: 2 additions & 2 deletions app/views/devise/sessions/new.haml
Expand Up @@ -20,9 +20,9 @@
%label Email:
%span#er_email.errors
%br
= f.email_field :email, :size => 25
= f.email_field :email, :size => 22
%label#lb_password Password:
%span#er_password.errors
%br
= f.password_field :password, :size => 25
= f.password_field :password, :size => 22
%button.large.large_w.awesome.green{:type => "submit"} Sign In
6 changes: 4 additions & 2 deletions app/views/layouts/_article_comments.haml
Expand Up @@ -2,8 +2,10 @@
%article.article_block_comments
%header.title
%h2
%a{:href => "#"} Comments
%a{:href => "#"} Recently added comments
%br/
%br/
.article_content
%img{:src => "/images/_tmp/example_comments.png"}
#comments
=render :partial => 'layouts/comment', :collection => @new_comments
/%img{:src => "/images/_tmp/example_comments.png"}
13 changes: 13 additions & 0 deletions app/views/layouts/_comment.haml
@@ -0,0 +1,13 @@
%span.photo_thumb
= link_to image_tag( comment.attach.photo.url(:thumb), {:alt => comment.attach.photo.url, :id => comment.attach.id}), user_path(comment.attach.user)
%b
-if comment.user_id.nil?
/=image_tag "/images/no_avatar.png"
guest:
-else
/=image_tag User.find(comment.user_id).avatar.url(:thumb)
=User.find(comment.user_id).email + ":"
/=comment.created_at.strftime('%a, %d %B %Y')
%br
=comment.comment
%hr
4 changes: 2 additions & 2 deletions app/views/layouts/_logo_intro.haml
@@ -1,7 +1,7 @@
/ Logo intro
%section.logo_intro
%ul.left.tick
%a{:class => "large medium_w orange awesome", :href => new_user_session_path}
%a{:class => "large medium_w orange awesome", :href => current_user ? edit_user_path(current_user) : new_user_session_path}
Upload photo
%a{:class => "large medium_w blue awesome", :href => new_user_session_path}
Take a tour
Expand All @@ -12,7 +12,7 @@
.right
%ul.right.tick
- if current_user
%a{:class => "large medium_w green awesome", :href => edit_user_path(current_user)}
%a{:class => "large medium_w green awesome", :href => user_path(current_user)}
Your page
%a{:class => "large medium_w yellow awesome", :href => destroy_session_path(current_user)}
Log Out
Expand Down
5 changes: 5 additions & 0 deletions app/views/layouts/_logo_photos.haml
@@ -0,0 +1,5 @@
/ Logo intro
%section.logo_intro
%br
.photos_thumbs_container.clearfix#thumbnails
= render :partial => "user", :object => @user
5 changes: 1 addition & 4 deletions app/views/layouts/application.haml
Expand Up @@ -19,16 +19,13 @@
= link_to "Home", root_path
- if current_user
%li
= link_to "Show profile", user_path(current_user)
%li
= link_to "Edit profile", edit_user_path(current_user)
= link_to "Your page", user_path(current_user)
%li
= link_to "Log out", destroy_session_path(current_user)
- else
%li
= link_to "Sign in", new_user_session_path
.logo_title ImHo: Images Hosting
= render(:partial => 'layouts/logo_intro')
/ Content
= yield

22 changes: 15 additions & 7 deletions app/views/users/_edit_user_photos.haml
@@ -1,16 +1,24 @@
#photos
%a{:href => "", :id => "more_attaches", :class => "large medium_w awesome"}
Add photo
%br
%br
.photos_thumbs_container.clearfix
.photos_thumbs_container.clearfix#thumbnails
-f.fields_for :attaches do |attach|
.thumb{:id => "thumb_#{attach.object.id}", :style => attach.object.new_record? ? 'display:none' : nil}
- unless attach.object.new_record?
%span.photo_thumb
=link_to image_tag(attach.object.thumbnail_url, {:title => "Click to replace"}), "", {:class => 'edit_img', :id => attach.object.id}
= link_to image_tag(attach.object.thumbnail_url, {:alt => attach.object.photo.url, :id => attach.object.id}), "", {:class => 'edit_img', :id => attach.object.id}
%span.comment-count= attach.object.comments.count
= form_for Like.new(:attach => attach.object), :html => {:id => "new_like_#{attach.object.id}"} do |f|
= f.hidden_field :attach_id
%span.like-count{:class => like_class(attach.object.id)}= attach.object.likes.count
%span.photo-edit
%a{:class => "small green awesome", :href => edit_attach_path(attach.object.id) }
edit
=attach.check_box "_destroy"
=attach.label "Del"
=attach.label "Delete"
.attach{:id => "attach_#{attach.object.id}", :style => 'display:none' }
=attach.label "Photo:"
=attach.file_field :photo
%br
%a{:href => "", :id => "more_attaches", :class => "large medium_w red awesome"}
Add photo
%br
%br
4 changes: 2 additions & 2 deletions app/views/users/_form.haml
Expand Up @@ -8,11 +8,11 @@
.group
= f.label :email, 'Email', :class => :label
= f.text_field :email
%span.description Ex: a simple text
%span.description
.group
= f.label :name, 'Name', :class => :label
= f.text_field :name
%span.description Ex: a simple text
%span.description
.hr
.group
%h4 Photos
Expand Down
14 changes: 14 additions & 0 deletions app/views/users/_form_photos.haml
@@ -0,0 +1,14 @@
= form_for @user, :url => user_path, :html => { :class => :form, :multipart => true } do |f|
.group
= edit_user_photos f
= f.label :name, 'Name', :class => :label
= f.text_field :name
%span.description
add your name
.avatar
= image_tag current_user.avatar.url(:medium)
= f.label :avatar, 'Avatar', :class => :label
= f.file_field :avatar
.hr
%button.large.large_w.awesome.green{:type => "submit"} Save

24 changes: 24 additions & 0 deletions app/views/users/_form_upload_photo.haml
@@ -0,0 +1,24 @@
= form_for @user, :url => user_path, :html => { :class => :form, :multipart => true } do |f|
#photos
.photos_thumbs_container.clearfix
-f.fields_for :attaches do |attach|
.thumb{:id => "thumb_#{attach.object.id}", :style => attach.object.new_record? ? 'display:none' : nil}
.attach{:id => "attach_#{attach.object.id}", :style => 'display:none' }
=attach.label "Photo:"
=attach.file_field :photo
%br
%a{:href => "", :id => "more_attaches", :class => "large medium_w red awesome"}
Add photo
%button.large.large_w.awesome.green{:type => "submit"} Save

:javascript
var name = $(".attach:last input").attr("name");
var num = name.match(/\[(\d+)\]\[.+\]$/)[1];

$(".attach:last").after($(".attach:last").clone());
$(".attach:last input").attr("name", name.replace(num, parseInt(num)+1));
$(".attach:last input").val("");
$(".attach:last").show();



3 changes: 2 additions & 1 deletion app/views/users/_user.haml
@@ -1 +1,2 @@
= render :partial => "attaches/attach", :collection => user.attaches
= render :partial => "attaches/attach", :collection => @user_photos
= will_paginate @user_photos
28 changes: 14 additions & 14 deletions app/views/users/edit.haml
@@ -1,14 +1,14 @@
%section.content
.flash
- flash.each do |type, message|
%div{:class => "message #{type}"}
%p= message
/ Article top photo
%article
%header.title
%h2
= link_to "#{@user.name ? @user.name : @user.email}", user_path(@user)
%br/
%br/
.article_content
= render :partial => "form"
#regFormMainBlock.modalBlock
.modalOverlay
.modalWindow.ui-draggable
.modalMessage
.modalMessageHead
Upload Photo
%a{:href => root_path}
#modalCloseCross.modalClose
.flash
- flash.each do |type, message|
%div{:class => "message #{type}"}
%p= message
#uploadForm
= render :partial => "form_upload_photo"
3 changes: 2 additions & 1 deletion app/views/users/index.haml
@@ -1,3 +1,4 @@
= render(:partial => 'layouts/logo_intro')
%section.content
.flash
- flash.each do |type, message|
Expand All @@ -11,5 +12,5 @@
/ Article block comments
= render(:partial => 'layouts/article_comments')
/ Article block tags
= render(:partial => 'layouts/article_tags')
/= render(:partial => 'layouts/article_tags')

60 changes: 52 additions & 8 deletions app/views/users/show.haml
@@ -1,3 +1,5 @@
- unless current_user && current_user.id == @user.id
= render(:partial => 'layouts/logo_photos')
%section.content
.flash
- flash.each do |type, message|
Expand All @@ -7,17 +9,59 @@
%article
%header.title
%h2
= link_to @user.full_name, user_path(@user)
= link_to "Photos by #{@user.full_name}", user_path(@user)
%br/
%br/
.article_content
- unless @user.attaches.count.zero?
%article
.article_content
#preview
= show_comments @user, @comments
.photos_thumbs_container.clearfix#thumbnails
= render :partial => "user", :object => @user

#preview
= show_comments @user, @comments
%section.sidebar
%article.article_block_tags
%header.title
%h2
%a{:href => "#"} You can do
%br
%br
%br
.article_content
%ul.right.tick
- if current_user
%span.avatar
= image_tag(current_user.avatar.url(:thumb))
%strong
= current_user.full_name
,
= current_user.attaches.count
Photos
%br
%br
%a{:class => "large small_w blue awesome", :href => edit_user_path(current_user)}
Upload photo
%a{:class => "large small_w green awesome", :href => user_path(current_user)}
Your page
%a{:class => "large small_w yellow awesome", :href => destroy_session_path(current_user)}
Log Out
-else
%a{:class => "large medium_w green awesome", :href => new_user_session_path}
Sign in
%a{:class => "large medium_w yellow awesome", :href => new_user_registration_path}
Sign Up
%br
%br
%a{:class => "large medium_w orange awesome", :href => new_user_session_path}
Upload photo
%a{:class => "large medium_w blue awesome", :href => new_user_session_path}
Take a tour
%br
%br
- if current_user && current_user.id == @user.id
%article.article_users_photos
%header.title
%h2
%a{:href => "#"} Manage your photos, name, avatar
.article_content
= render :partial => "form_photos"
%br/


0 comments on commit 774ffb7

Please sign in to comment.