Skip to content

Commit db0b3aa

Browse files
committed
Added consistent sub-navigation to program index and show
1 parent a89b0fe commit db0b3aa

4 files changed

Lines changed: 47 additions & 17 deletions

File tree

app/assets/stylesheets/content.css.scss

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,26 @@ h2 {
1616
p {
1717
margin-bottom: 1em;
1818
}
19+
}
20+
21+
ul.inline-menu {
22+
@include clearfix;
23+
list-style-type: none;
24+
margin: 0;
25+
li {
26+
float: left;
27+
padding-right: 1em;
28+
border-right: 1px solid #ccc;
29+
margin-right: 1em;
30+
}
31+
li:last-child {
32+
border: none;
33+
margin: 0;
34+
padding: 0;
35+
}
36+
}
37+
38+
.bottom-nav {
39+
border-top: 1px solid #ccc;
40+
padding-top: 1.5em;
1941
}

app/views/programs/index.html.haml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
- content_for :title do
2-
Programs
2+
- if @user
3+
#{@user.username}'s Programs
4+
- else
5+
Programs
36

4-
- unless @featured.blank?
7+
- unless @featured.blank? or @user
58
#featured.programs
69
.heading
710
%h3 Featured
@@ -14,12 +17,18 @@
1417
.author= author_link program.author_username, program
1518

1619
#all-programs.programs
17-
.heading
18-
%h3 All Programs
19-
.description Every program uploaded by our users!
20+
- unless @user
21+
.heading
22+
%h3 All Programs
23+
.description Every program uploaded by our users!
2024

2125
%ul
2226
- @programs.each do |program|
2327
%li
2428
.title= program_link program
2529
.author= author_link program.author_username, program
30+
31+
- if @user
32+
%ul.inline-menu.bottom-nav
33+
%li= link_to "All Programs", programs_path
34+
%li= link_to "#{@user.username}'s profile", user_path(@user)

app/views/programs/show.html.haml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@
1919
by
2020
= link_to @program.author_username, user_path(@program.author_username)
2121

22-
%pre.prettyprint= @program.source_code
22+
#program
23+
%pre.prettyprint= @program.source_code
2324

24-
%hr/
25-
26-
%h3 Other Programs
27-
28-
Make sure to check out all the other programs other users have made on the #{link_to "All Programs page", programs_path}!
25+
%ul.inline-menu.bottom-nav
26+
%li= link_to "#{@program.author_username}'s programs", user_programs_path(@program.author_username)
27+
%li= link_to "All Programs", programs_path

app/views/users/show.html.haml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
%h2= "About #{resource.username}"
1818
%h4= resource.about
1919
%hr
20-
%p
21-
= link_to "Programs", user_programs_path(resource)
22-
%p
20+
%p
21+
= link_to pluralize(resource.programs.count, "Program"), user_programs_path(resource)
22+
%p
2323
Following:
2424
=link_to resource.following.count, resource_path(resource) + "/following"
25-
%p
25+
%p
2626
Followers:
2727
= link_to resource.followers.count, resource_path(resource) + "/followers"
2828
%hr
@@ -32,7 +32,7 @@
3232

3333
- unless @user.questions.empty?
3434
%section.questions
35-
%header
35+
%header
3636
%h2 Questions
3737
- @user.questions.each do |question|
3838
%article.question
@@ -44,7 +44,7 @@
4444
%h2 Answers
4545
- @user.answers.each do |answer|
4646
%article.answer
47-
%h4
47+
%h4
4848
= "#{@user.username} answered"
4949
= link_to(answer.question.title, answer.question)
5050
with:

0 commit comments

Comments
 (0)