Skip to content

Commit 9f05dfe

Browse files
committed
Basics of showing a blog.
1 parent 993dcc5 commit 9f05dfe

15 files changed

Lines changed: 88 additions & 1 deletion

File tree

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/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Place all the styles related to the blog controller here.
2+
// They will automatically be included in application.css.
3+
// You can use Sass (SCSS) here: http://sass-lang.com/

app/controllers/blog_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class BlogController < ApplicationController
2+
def show
3+
@posts = BlogPost.all
4+
end
5+
end

app/helpers/blog_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module BlogHelper
2+
end

app/models/blog_post.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class BlogPost
2+
include MongoMapper::Document
3+
4+
key :title, String
5+
key :content, String
6+
7+
timestamps!
8+
end

app/views/blog/show.html.haml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
%h1 The Hackety Blog!
2+
3+
- @posts.each do |post|
4+
%h2= post.title
5+
%h3= post.created_at
6+
:markdown
7+
#{post.content}
8+
%hr/
9+
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
= semantic_menu :class => "pills" do |root|
22
- root.add "Home", root_path
3+
- root.add "Blog", blog_path
34
- root.add "Questions", questions_path
45
- root.add "Programs", programs_path
56
- root.add "FAQ", faq_path
67
- root.add "Support", support_questions_path
7-
8+

app/views/shared/menu/_main.html.haml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
= semantic_menu :class => "nav" do |root|
2+
- root.add "Blog", blog_path
23
- root.add "Questions", questions_path
34
- root.add "Lessons", lessons_path
45
- root.add "Programs", programs_path

config/routes.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
resources :answers
77
end
88

9+
match "/blog", :to => "blog#show"
10+
911
get "/downloads/latest/:platform", :to => "static#download", :as => 'downloads'
1012
get "/downloads/latest", :to => "static#download", :as => 'download'
1113
match "/download" => redirect("/downloads/latest")

features/blog.feature

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Feature: Hackety Blog
2+
3+
As an admin, I can post to the hackety blog.
4+
5+
Scenario: Read the blog
6+
Given a blog post exists
7+
When I visit the blog
8+
Then I should see the content of that post
9+
And I should see the title of that post

0 commit comments

Comments
 (0)