Class: Rog::Blog

Inherits:
Object
  • Object
show all
Defined in:
lib/rog/blog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(blog_path = 'blog', pages_path = "#{blog_path}/pages", archives_path = "#{pages_path}/archives", posts_path = "#{pages_path}/posts") ⇒ Blog

Returns a new instance of Blog.



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/rog/blog.rb', line 53

def initialize(blog_path='blog', pages_path="#{blog_path}/pages", 
               archives_path = "#{pages_path}/archives", 
               posts_path="#{pages_path}/posts")
  @blog_path = blog_path
  @pages_path = pages_path
  @archives_path = archives_path
  @posts_path = posts_path
  
  @tags_hash = Hash.new

  load_config
  scan_for_posts
end

Instance Attribute Details

#blog_subtitleObject (readonly)

Returns the value of attribute blog_subtitle.



50
51
52
# File 'lib/rog/blog.rb', line 50

def blog_subtitle
  @blog_subtitle
end

#blog_titleObject (readonly)

Returns the value of attribute blog_title.



50
51
52
# File 'lib/rog/blog.rb', line 50

def blog_title
  @blog_title
end

#buttonsObject (readonly)

Returns the value of attribute buttons.



50
51
52
# File 'lib/rog/blog.rb', line 50

def buttons
  @buttons
end

Returns the value of attribute links.



50
51
52
# File 'lib/rog/blog.rb', line 50

def links
  @links
end

#pagesObject (readonly)

Returns the value of attribute pages.



50
51
52
# File 'lib/rog/blog.rb', line 50

def pages
  @pages
end

#projectsObject (readonly)

Returns the value of attribute projects.



50
51
52
# File 'lib/rog/blog.rb', line 50

def projects
  @projects
end

#publish_urlObject (readonly)

Returns the value of attribute publish_url.



50
51
52
# File 'lib/rog/blog.rb', line 50

def publish_url
  @publish_url
end

#urlObject (readonly)

Returns the value of attribute url.



50
51
52
# File 'lib/rog/blog.rb', line 50

def url
  @url
end

Instance Method Details

#each_month(&proc) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/rog/blog.rb', line 85

def each_month(&proc)
  prev_year = @blog_posts[0].year
  prev_month = @blog_posts[0].month

  month_posts = Array.new

  @blog_posts << nil

  @blog_posts.each do |post|
    if (not post.nil?) and (post.year == prev_year and post.month == prev_month) then
      month_posts.push post
    else
      yield month_posts
	  break if post.nil?
      prev_year = post.year
      prev_month = post.month
      month_posts = [ post ]
    end
  end

  @blog_posts.pop

  #yield [ @blog_posts.last ] if not month_posts.include? @blog_posts.last
end

#each_post(&proc) ⇒ Object



79
80
81
82
83
# File 'lib/rog/blog.rb', line 79

def each_post(&proc)
  @blog_posts.each do |bpost|
    yield bpost
  end
end

#get_last_postsObject



110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/rog/blog.rb', line 110

def get_last_posts
  last_posts = Array.new

  (0...7).each do |i| 
    if not @blog_posts[i].nil?
      last_posts.push @blog_posts[i] 
    else
      break
    end
  end

  last_posts
end

#postsObject



71
72
73
# File 'lib/rog/blog.rb', line 71

def posts
  @blog_posts
end

#posts?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/rog/blog.rb', line 75

def posts?
  @blog_posts.length >= 1
end

#tagsObject



67
68
69
# File 'lib/rog/blog.rb', line 67

def tags
  @tags_hash
end