Class: Section

Inherits:
Zarchitect show all
Defined in:
lib/zarchitect/section.rb

Constant Summary

Constants inherited from Zarchitect

Zarchitect::ASSETDIR, Zarchitect::ASSETSDIR, Zarchitect::BUILDIR, Zarchitect::CONFIGDIR, Zarchitect::DEBUGSDIR, Zarchitect::DRAFTDIR, Zarchitect::FILEDIR, Zarchitect::FILESDIR, Zarchitect::HTMLDIR, Zarchitect::LAYOUTDIR, Zarchitect::NODEDIR, Zarchitect::SHARESDIR, Zarchitect::VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Zarchitect

#main, #rss

Constructor Details

#initialize(conf) ⇒ Section

Returns a new instance of Section.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/zarchitect/section.rb', line 4

def initialize(conf)
  @index = false
  GPI.print "Initializing Section #{conf.key}.", GPI::CLU.check_option('v')
  @conf = conf
  @key = conf.key
  @name = @conf.name.clone
  if @conf.index
    @url = "/index.html"
  else
    @url = "/#{@conf.key}/index.html"
  end
  create_dir
  fetch_categories
  fetch_posts
  sort_posts
  if @conf.collection && @conf.categorize
    @categories.each do |c|
      c.setup_index
      c.fetch_tags if @conf.tags
    end
  end
  setup_index
end

Instance Attribute Details

#categoriesObject (readonly)

Returns the value of attribute categories.



2
3
4
# File 'lib/zarchitect/section.rb', line 2

def categories
  @categories
end

#confObject (readonly)

Returns the value of attribute conf.



2
3
4
# File 'lib/zarchitect/section.rb', line 2

def conf
  @conf
end

#indexObject (readonly)

Returns the value of attribute index.



2
3
4
# File 'lib/zarchitect/section.rb', line 2

def index
  @index
end

#keyObject (readonly)

Returns the value of attribute key.



2
3
4
# File 'lib/zarchitect/section.rb', line 2

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



2
3
4
# File 'lib/zarchitect/section.rb', line 2

def name
  @name
end

#urlObject (readonly)

Returns the value of attribute url.



2
3
4
# File 'lib/zarchitect/section.rb', line 2

def url
  @url
end

Instance Method Details

#all_postsObject



36
37
38
# File 'lib/zarchitect/section.rb', line 36

def all_posts
  @posts
end

#build_htmlObject



40
41
42
43
44
45
46
# File 'lib/zarchitect/section.rb', line 40

def build_html
  posts.each { |p| p.build_html }
  if @categories
    @categories.each { |c| c.build_html }
  end
  @index.build_html unless @conf.has_option?("file")
end

#find_category(key) ⇒ Object



56
57
58
59
60
61
# File 'lib/zarchitect/section.rb', line 56

def find_category(key)
  @categories.each do |c|
    return c if c.key == key
  end
  nil
end

#postsObject



28
29
30
31
32
33
34
# File 'lib/zarchitect/section.rb', line 28

def posts
  if GPI::CLU.check_option('D')
    @posts
  else
    @posts.select { |p| p.draft == false }
  end
end

#write_htmlObject



48
49
50
51
52
53
54
# File 'lib/zarchitect/section.rb', line 48

def write_html
  posts.each { |p| p.write_html }
  if @categories
    @categories.each { |c| c.write_html }
  end
  @index.write_html unless @conf.has_option?("file")
end