Skip to content

Commit 863c937

Browse files
committed
Refactored user profiles
* Unified user's question and answer lists * Updated user info sidebar styles * User edit page uses correct form elements and appropriate sidebar
1 parent 94c20a0 commit 863c937

11 files changed

Lines changed: 96 additions & 85 deletions

File tree

app/assets/stylesheets/application.css.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@
1515
@import "home.css.scss";
1616
@import "questions.css.scss";
1717
@import "programs.css.scss";
18+
@import "users.css.scss";
1819

app/assets/stylesheets/content.css.scss

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,27 @@ h2 {
1111
margin-bottom: 0.5em;
1212
}
1313

14+
.heading {
15+
@include clearfix;
16+
padding: 0.75em;
17+
background: $green;
18+
19+
h3, .description {
20+
color: white;
21+
}
22+
23+
h3 {
24+
float: left;
25+
margin-bottom: 0;
26+
margin-right: 1em;
27+
}
28+
.description {
29+
float: left;
30+
margin-top: 0.2em;
31+
}
32+
}
33+
34+
1435
.block-message {
1536
margin-bottom: 0.5em;
1637
p {

app/assets/stylesheets/layout.css.scss

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@ html {
33
}
44

55
body {
6+
color: $text-color;
67
background: $background url("square_bg.png") fixed;
78
}
89

10+
p,h1,h2,h3,h4,h5 {
11+
color: $text-color;
12+
}
13+
914
.topbar {
1015
position: relative;
1116
height: auto;
@@ -86,9 +91,6 @@ header .topbar-inner {
8691

8792
}
8893

89-
p,h1,h2,h3,h4,h5 {
90-
color: $text-color;
91-
}
9294

9395
.alert-message {
9496
margin-top: -18px;

app/assets/stylesheets/programs.css.scss

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,6 @@
11
.programs {
22

33
margin-bottom: 2em;
4-
.heading {
5-
@include clearfix;
6-
padding: 0.75em;
7-
background: $green;
8-
9-
h3, .description {
10-
color: white;
11-
}
12-
13-
h3 {
14-
float: left;
15-
margin-bottom: 0;
16-
margin-right: 1em;
17-
}
18-
.description {
19-
float: left;
20-
margin-top: 0.2em;
21-
}
22-
}
23-
244

255
ul {
266
@include clearfix;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.user-questions, .user-answers {
2+
ul {
3+
margin: 0;
4+
list-style-type: none;
5+
padding: 1em 0;
6+
7+
li {
8+
@include clearfix;
9+
padding-bottom: 0.5em;
10+
border-bottom: 1px solid #ddd;
11+
margin-bottom: 0.5em;
12+
13+
.title, .description {
14+
@include columns(8);
15+
}
16+
17+
.meta {
18+
@include columns(3, true);
19+
text-align: right;
20+
}
21+
}
22+
}
23+
}

app/models/answer.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ class Answer
22
include MongoMapper::Document
33

44
key :description, String
5+
timestamps!
56

67
validates_presence_of :description
78

app/views/devise/registrations/edit.html.erb

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
- content_for :title do
2+
Edit #{resource_name.to_s.humanize}
3+
4+
= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f|
5+
= f.error_notification
6+
.inputs
7+
= f.input :username, :autofocus => true
8+
= f.input :email, :autofocus => true
9+
.inputs
10+
= f.input :password, :hint => "Leave it blank if you don't want to change it", :required => false
11+
= f.input :password_confirmation, :required => false
12+
.inputs
13+
= f.input :about, :as => :text
14+
.actions
15+
= f.button :submit, "Update", :class => "btn primary"
16+
17+
- content_for :sidebar do
18+
%section
19+
%h2 Cancel my account
20+
%p
21+
Unhappy? #{link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete}.

app/views/users/_form.html.erb

Lines changed: 0 additions & 15 deletions
This file was deleted.

app/views/users/show.html.haml

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
- content_for :title do
2-
= "#{resource.username}'s page"
2+
= "#{resource.username}'s Profile"
33

44
-content_for :sidebar do
55
%section.about-user
@@ -14,9 +14,8 @@
1414
= f.hidden_field :followee, :value => resource.id
1515
= f.button :submit, :value => "Follow", :class => "primary btn"
1616

17-
%h2= "About #{resource.username}"
18-
%h4= resource.about
19-
%hr
17+
- unless resource.about.blank?
18+
%p= resource.about
2019
%p
2120
= link_to pluralize(resource.programs.count, "Program"), user_programs_path(resource), :class => "user-programs"
2221
%p
@@ -31,21 +30,25 @@
3130

3231

3332
- unless @user.questions.empty?
34-
%section.questions
35-
%header
36-
%h2 Questions
37-
- @user.questions.each do |question|
38-
%article.question
39-
%h4= link_to question.title, question_path(question)
33+
%section.user-questions
34+
.heading
35+
%h3= pluralize(@user.questions.count, "Question")
36+
%ul
37+
- @user.questions.each do |question|
38+
%li
39+
.title
40+
= link_to question.title, question_path(question)
41+
.meta
42+
asked #{question.created_at.strftime("%b %e, %l:%M %p")}
4043

4144
- unless @user.answers.empty?
42-
%section.answers
43-
%header
44-
%h2 Answers
45-
- @user.answers.each do |answer|
46-
%article.answer
47-
%h4
48-
= "#{@user.username} answered"
49-
= link_to(answer.question.title, answer.question)
50-
with:
51-
%p= answer.description
45+
%section.user-answers
46+
.heading
47+
%h3= pluralize(@user.answers.count, "Answer")
48+
%ul
49+
- @user.answers.each do |answer|
50+
%li
51+
.description
52+
= answer.description.truncate(100)
53+
.meta
54+
= link_to("View Answer", answer.question)

0 commit comments

Comments
 (0)