Skip to content

Commit ba10454

Browse files
author
Marylou Lenhart
committed
Merge branch 'master' of git://github.com/hacketyhack/hackety-hack.com
2 parents 8a170ca + 993dcc5 commit ba10454

24 files changed

Lines changed: 293 additions & 43 deletions

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ source 'http://rubygems.org'
33
gem 'rails', '3.1.0'
44
gem 'json'
55

6+
gem 'hackety_hack-lessons', '~> 1.1', :require => 'hackety_hack/lessons'
7+
68
gem 'haml-rails'
79
gem 'jquery-rails'
810
gem 'mongo_mapper'

Gemfile.lock

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ GEM
5959
rack-test (>= 0.5.4)
6060
selenium-webdriver (~> 2.0)
6161
xpath (~> 0.1.4)
62-
childprocess (0.2.6)
62+
childprocess (0.3.0)
6363
ffi (~> 1.0.6)
64-
coderay (0.9.8)
64+
coderay (1.0.5)
6565
coffee-rails (3.1.1)
6666
coffee-script (>= 2.2.0)
6767
railties (~> 3.1.0)
@@ -79,21 +79,23 @@ GEM
7979
capybara (>= 1.1.2)
8080
cucumber (>= 1.1.3)
8181
nokogiri (>= 1.5.0)
82-
database_cleaner (0.7.0)
82+
database_cleaner (0.7.1)
8383
devise (1.5.3)
8484
bcrypt-ruby (~> 3.0)
8585
orm_adapter (~> 0.0.3)
8686
warden (~> 1.1)
8787
diff-lcs (1.1.3)
8888
erubis (2.7.0)
89-
execjs (1.2.13)
89+
execjs (1.3.0)
9090
multi_json (~> 1.0)
9191
fabrication (1.2.0)
9292
faker (1.0.1)
9393
i18n (~> 0.4)
9494
ffi (1.0.11)
95-
gherkin (2.7.2)
95+
gherkin (2.7.6)
9696
json (>= 1.4.6)
97+
hackety_hack-lessons (1.1.2)
98+
metadown
9799
haml (3.1.4)
98100
haml-rails (0.3.4)
99101
actionpack (~> 3.0)
@@ -111,7 +113,7 @@ GEM
111113
jquery-rails (1.0.19)
112114
railties (~> 3.0)
113115
thor (~> 0.14)
114-
json (1.6.4)
116+
json (1.6.5)
115117
kgio (2.7.2)
116118
launchy (2.0.5)
117119
addressable (~> 2.2.6)
@@ -120,13 +122,14 @@ GEM
120122
mime-types (~> 1.16)
121123
treetop (~> 1.4.8)
122124
metaclass (0.0.1)
123-
method_source (0.6.7)
124-
ruby_parser (>= 2.3.1)
125+
metadown (1.0.1)
126+
redcarpet
127+
method_source (0.7.0)
125128
mime-types (1.17.2)
126129
mm-devise (1.3)
127130
devise (>= 1.2)
128131
mongo_mapper (>= 0.9.0)
129-
mocha (0.10.0)
132+
mocha (0.10.3)
130133
metaclass (~> 0.0.1)
131134
mongo (1.5.2)
132135
bson (= 1.5.2)
@@ -136,16 +139,15 @@ GEM
136139
plucky (~> 0.4.0)
137140
multi_json (1.0.4)
138141
nokogiri (1.5.0)
139-
orm_adapter (0.0.5)
142+
orm_adapter (0.0.6)
140143
pg (0.12.2)
141-
plucky (0.4.3)
142-
mongo (~> 1.3)
144+
plucky (0.4.4)
145+
mongo (~> 1.5)
143146
polyglot (0.3.3)
144-
pry (0.9.7.4)
145-
coderay (~> 0.9.8)
146-
method_source (~> 0.6.7)
147-
ruby_parser (>= 2.3.1)
148-
slop (~> 2.1.0)
147+
pry (0.9.8)
148+
coderay (~> 1.0.5)
149+
method_source (~> 0.7)
150+
slop (>= 2.4.3, < 3)
149151
rack (1.3.6)
150152
rack-cache (1.0.3)
151153
rack (>= 0.4)
@@ -175,7 +177,8 @@ GEM
175177
rdiscount (1.6.8)
176178
rdoc (3.12)
177179
json (~> 1.4)
178-
responders (0.6.4)
180+
redcarpet (2.1.0)
181+
responders (0.6.5)
179182
rspec (2.8.0)
180183
rspec-core (~> 2.8.0)
181184
rspec-expectations (~> 2.8.0)
@@ -189,22 +192,19 @@ GEM
189192
activesupport (>= 3.0)
190193
railties (>= 3.0)
191194
rspec (~> 2.8.0)
192-
ruby_parser (2.3.1)
193-
sexp_processor (~> 3.0)
194195
rubyzip (0.9.5)
195196
sass (3.1.12)
196197
sass-rails (3.1.5)
197198
actionpack (~> 3.1.0)
198199
railties (~> 3.1.0)
199200
sass (~> 3.1.10)
200201
tilt (~> 1.3.2)
201-
selenium-webdriver (2.16.0)
202+
selenium-webdriver (2.17.0)
202203
childprocess (>= 0.2.5)
203204
ffi (~> 1.0.9)
204205
multi_json (~> 1.0.4)
205206
rubyzip
206-
sexp_processor (3.0.10)
207-
slop (2.1.0)
207+
slop (2.4.3)
208208
sprockets (2.0.3)
209209
hike (~> 1.2)
210210
rack (~> 1.0)
@@ -217,7 +217,7 @@ GEM
217217
polyglot
218218
polyglot (>= 0.3.1)
219219
tzinfo (0.3.31)
220-
uglifier (1.2.1)
220+
uglifier (1.2.2)
221221
execjs (>= 0.3.0)
222222
multi_json (>= 1.0.2)
223223
unicorn (4.1.1)
@@ -242,6 +242,7 @@ DEPENDENCIES
242242
devise (>= 1.2)
243243
fabrication
244244
faker
245+
hackety_hack-lessons (~> 1.1)
245246
haml-rails
246247
inherited_resources
247248
jnunemaker-validatable (>= 1.8.4)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Place all the behaviors and hooks related to the matching controller here.
2+
# All this logic will automatically be available in application.js.
3+
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

app/assets/stylesheets/application.css.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@
1616
@import "questions.css.scss";
1717
@import "programs.css.scss";
1818
@import "users.css.scss";
19+
@import "lessons.css.scss";
1920

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/* Lessons menu */
2+
ul#lessons {
3+
list-style-type: none;
4+
margin: 0;
5+
> li {
6+
@include clearfix;
7+
padding-bottom: 1em;
8+
border-bottom: 1px solid #ccc;
9+
margin-bottom: 1em;
10+
.info {
11+
@include columns(7);
12+
.title {
13+
font-size: 1.1em;
14+
font-weight: bold;
15+
margin-bottom: 0.2em;
16+
}
17+
}
18+
.categories {
19+
@include columns(4, last);
20+
li {
21+
float: right;
22+
}
23+
}
24+
}
25+
}
26+
27+
/* Lesson content styles */
28+
#content-wrap.lesson {
29+
.page-title {
30+
margin-left: 3em;
31+
}
32+
#lesson-content {
33+
padding-left: 3em;
34+
max-width: 500px;
35+
36+
h2 {
37+
margin-top: 0.75em;
38+
border-top: 1px solid #ccc;
39+
padding-top: 0.5em;
40+
}
41+
42+
img {
43+
@include border-radius;
44+
@include box-shadow;
45+
border: 1px solid #ccc;
46+
padding: 0.75em;
47+
}
48+
}
49+
}
50+
51+
/* Category pills */
52+
ul.lesson-categories {
53+
@include clearfix;
54+
list-style-type: none;
55+
margin: 0;
56+
font-size: 0.9em;
57+
58+
li {
59+
float: left;
60+
@include border-radius(50px);
61+
padding: 0.25em 0.75em;
62+
margin-right: 0.5em;
63+
background: #ddd;
64+
border: 1px solid #ccc;
65+
}
66+
67+
.beginner {
68+
background-color: $green;
69+
border-color: darken($green, 10%);
70+
color: white;
71+
}
72+
.hackety {
73+
background-color: $blue;
74+
border-color: darken($blue, 10%);
75+
color: white;
76+
}
77+
.shoes {
78+
background-color: $orangered;
79+
border-color: darken($orangered, 10%);
80+
color: white;
81+
}
82+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class LessonsController < ApplicationController
2+
def index
3+
@lessons = HacketyHack::Lessons.all
4+
end
5+
6+
def show
7+
@lesson = HacketyHack::Lessons.find_by_slug(params[:id])
8+
end
9+
end

app/helpers/lessons_helper.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module LessonsHelper
2+
3+
def lesson_categories lesson
4+
output = content_tag :ul, :class => "lesson-categories" do
5+
lesson.metadata["categories"].reduce('') { |c, x|
6+
c << content_tag(:li, x, :class => x)
7+
}.html_safe
8+
end
9+
end
10+
11+
end

app/helpers/programs_helper.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
module ProgramsHelper
22
def program_link program
3-
"#{link_to(program.title.titleize, user_program_path(program.author_username, program))}".html_safe
3+
if program.author_username.present?
4+
"#{link_to(program.title.titleize, user_program_path(program.author_username, program))}".html_safe
5+
else
6+
"#{link_to(program.title.titleize, url_for(:controller => '/programs', :action => 'show', :id => program.slug))}".html_safe
7+
end
48
end
59

610
def author_link username, program = nil
11+
return nil unless username
712
output = ""
813
output += link_to(username, user_path(username))
914

app/models/user.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class User
1717
:message => "Make your username from letters, numbers, underscores('_'), and dots('.')."
1818
validates_length_of :username, :in => (1..32),
1919
:message => "Your username needs at least 1 character but no more than 32."
20+
validates_uniqueness_of :username,
21+
:message => "User name has been taken already. Please try another"
2022

2123
def to_param
2224
self.username

app/views/lessons/index.html.haml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
- content_for :title do
2+
Lessons
3+
4+
- content_for :sidebar do
5+
= render :partial => "shared/ask"
6+
= render :partial => "shared/lessons"
7+
8+
%p Want to learn programming? Here are some lessons that we've put online.
9+
10+
%ul#lessons
11+
- @lessons.each do |lesson|
12+
%li
13+
.info
14+
.title
15+
= link_to lesson.metadata["title"], lesson_path(lesson.metadata["slug"])
16+
= lesson.metadata["blurb"]
17+
.categories
18+
= lesson_categories lesson
19+
20+

0 commit comments

Comments
 (0)