Skip to content

Commit

Permalink
Refactored naming conventions.
Browse files Browse the repository at this point in the history
Make ActiveBlog's helper methods extremely obvious by using active_blog_ prefix
Reduce duplication active_blog.rb initializer
  • Loading branch information
mchung committed Dec 6, 2011
1 parent 08002a1 commit 9df8dbc
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 45 deletions.
29 changes: 16 additions & 13 deletions app/helpers/active_blog/application_helper.rb
@@ -1,35 +1,38 @@
module ActiveBlog
# These helpers are intended to be used by developers.
#
#
module ApplicationHelper
def blog_title
ActiveBlog.blog_title
def active_blog_title
ActiveBlog.title
end

def blog_description
ActiveBlog.blog_description
def active_blog_description
ActiveBlog.description
end

def blog_sidebar(&block)
sidebar_content_for = ActiveBlog.blog_content_for_sidebar
def active_blog_sidebar(&block)
sidebar_content_for = ActiveBlog.content_for_sidebar
if sidebar_content_for
content_for sidebar_content_for do
yield
end
end
end

def blog_author_name
ActiveBlog.blog_author_name
def active_blog_author_name
ActiveBlog.author_name
end

def blog_author_uri
ActiveBlog.blog_author_uri
def active_blog_author_uri
ActiveBlog.author_uri
end

def blog_author_email
ActiveBlog.blog_author_email
def active_blog_author_email
ActiveBlog.author_email
end

def blog_atom_link_tag
def active_blog_atom_link_tag
auto_discovery_link_tag(:atom, "#{active_blog_feed_url}.atom", {:title => "Subscribe to this blog"})
end
end
Expand Down
@@ -1,4 +1,4 @@
<%= schema_span_for 'name', "#{blog_post.title} | #{blog_title}" %>
<%= schema_span_for 'name', "#{blog_post.title} | #{active_blog_title}" %>
<%= schema_span_for 'description', markdown_for_schema(blog_post.body) %>
<%= schema_span_for 'datePublished', schema_date(blog_post.published_at) %>
<%= schema_span_for 'headline', blog_post.title %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/active_blog/blog_posts/_sidebar.html.erb
@@ -1,4 +1,4 @@
<%= blog_sidebar do %>
<%= active_blog_sidebar do %>
<div class='section active_blog sidebar'>
<h6>Recent posts</h6>
</div>
Expand Down
8 changes: 4 additions & 4 deletions app/views/active_blog/blog_posts/feed.atom.builder
@@ -1,5 +1,5 @@
atom_feed({}) do |feed|
feed.title(blog_title)
feed.title(active_blog_title)
feed.updated(@blog_posts[0].published_at) if @blog_posts.length > 0

@blog_posts.each do |post|
Expand All @@ -12,9 +12,9 @@ atom_feed({}) do |feed|
entry.content(markdown(post.body), :type => 'html')

entry.author do |author|
author.name(blog_author_name) if blog_author_name
author.uri(blog_author_uri) if blog_author_uri
author.email(blog_author_email) if blog_author_email
author.name(active_blog_author_name) if active_blog_author_name
author.uri(active_blog_author_uri) if active_blog_author_uri
author.email(active_blog_author_email) if active_blog_author_email
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions app/views/active_blog/blog_posts/index.html.erb
@@ -1,12 +1,12 @@
<%= content_for :title do %><%= blog_title %><% end %>
<%= content_for :head do %><%= blog_atom_link_tag %><% end %>
<%= content_for :title do %><%= active_blog_title %><% end %>
<%= content_for :head do %><%= active_blog_atom_link_tag %><% end %>
<%= content_for :schema do %>
<%= schema_span_for 'name', blog_title %>
<%= schema_span_for 'description', blog_description %>
<%= schema_span_for 'name', active_blog_title %>
<%= schema_span_for 'description', active_blog_description %>
<%= schema_span_for 'url', active_blog_url %>
<% end %>
<div class="section active_blog index">
<h1><%= blog_title %></h1>
<h1><%= active_blog_title %></h1>

<% if @blog_posts.empty? %>
<%= link_to "Write your first blog post", admin_active_blog_blog_posts_path %>
Expand Down
24 changes: 12 additions & 12 deletions lib/active_blog.rb
Expand Up @@ -6,28 +6,28 @@
module ActiveBlog

# The blog's title
mattr_accessor :blog_title
@@blog_title = 'New ActiveBlog!'
mattr_accessor :title
@@title = 'New ActiveBlog!'

# The blog's description
mattr_accessor :blog_description
@@blog_description = "Here's where your description goes"
mattr_accessor :description
@@description = "Here's where your description goes"

# Yield to your layout's sidebar, i.e. :sidebar
mattr_accessor :blog_content_for_sidebar
@@blog_content_for_sidebar = nil
mattr_accessor :content_for_sidebar
@@content_for_sidebar = nil

# Blog author's name
mattr_accessor :blog_author_name
@@blog_author_name = nil
mattr_accessor :author_name
@@author_name = nil

# Blog author's uri
mattr_accessor :blog_author_uri
@@blog_author_uri = nil
mattr_accessor :author_uri
@@author_uri = nil

# Blog author's email
mattr_accessor :blog_author_email
@@blog_author_email = nil
mattr_accessor :author_email
@@author_email = nil

def self.setup
yield self
Expand Down
18 changes: 9 additions & 9 deletions lib/generators/active_blog/install/templates/active_blog.rb
@@ -1,19 +1,19 @@
ActiveBlog.setup do |config|
# Name of your blog.
# config.blog_title = "Your Blog Title"
# Title of your blog.
# config.title = "Your Blog Title"

# Description
# config.blog_description = "Your Blog Description"

# Assuming your layout has a sidebar, active_blog will yield via content_for.
# config.blog_content_for_sidebar = :sidebar
# config.description = "Your Blog Description"

# Blog author's name
# config.blog_author_name = "John Doe"
# config.author_name = "John Doe"

# Blog author's URI
# config.blog_author_name = "http://example.com"
# config.author_name = "http://example.com"

# Blog author's email
# config.blog_author_email = "mchung@example.com"
# config.author_email = "mchung@example.com"

# Assuming your layout has a sidebar, active_blog will yield via content_for.
# config.content_for_sidebar = :sidebar
end

0 comments on commit 9df8dbc

Please sign in to comment.