Class: Post

Inherits:
Zarchitect show all
Defined in:
lib/zarchitect/post.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(path, section) ⇒ Post

Returns a new instance of Post.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/zarchitect/post.rb', line 6

def initialize(path, section)
  GPI.print "Initializing post #{path}.", GPI::CLU.check_option('v')
  @section = section
  @source_path = path
  @conf = Config.new(path)
  @conf.validate_post
  @conf.setup
  @id = @conf.id.clone if @conf.has_option?("id")
  if @conf.has_option?("key")
    @key = @conf.key.clone
  else
    @key = @id.clone
  end
  if @conf.has_option?("always_write")
    @always_write = @conf.always_write.clone 
  else
    @always_write = false
  end
  @category = nil
  @write_block = false
  set_draft
  set_rss
  set_date
  fetch_category if @conf.has_option?("category")
  create_dir
  set_url
  set_html_path
  fetch_content 
  set_description
  set_name
  setup_html
  rss.try_item(self)
end

Instance Attribute Details

#categoryObject (readonly)

Returns the value of attribute category.



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

def category
  @category
end

#confObject (readonly)

Returns the value of attribute conf.



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

def conf
  @conf
end

#contentObject (readonly)

Returns the value of attribute content.



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

def content
  @content
end

#dateObject (readonly)

Returns the value of attribute date.



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

def date
  @date
end

#descriptionObject (readonly)

Returns the value of attribute description.



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

def description
  @description
end

#draftObject (readonly)

Returns the value of attribute draft.



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

def draft
  @draft
end

#html_pathObject (readonly)

Returns the value of attribute html_path.



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

def html_path
  @html_path
end

#keyObject (readonly)

Returns the value of attribute key.



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

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#source_pathObject (readonly)

Returns the value of attribute source_path.



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

def source_path
  @source_path
end

#urlObject (readonly)

Returns the value of attribute url.



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

def url
  @url
end

#write_blockObject

Returns the value of attribute write_block.



4
5
6
# File 'lib/zarchitect/post.rb', line 4

def write_block
  @write_block
end

Instance Method Details

#build_htmlObject



48
49
50
51
# File 'lib/zarchitect/post.rb', line 48

def build_html
  GPI.print "Composing HTML for #{@source_path}.", GPI::CLU.check_option('v')
  @html.compose
end

#rss?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/zarchitect/post.rb', line 64

def rss?
  return @rss
end

#tagsObject



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

def tags
  if @conf.has_option?("tags")
    @conf.tags
  else
    Array.new
  end
end

#write_htmlObject



53
54
55
56
57
58
59
60
61
62
# File 'lib/zarchitect/post.rb', line 53

def write_html
  if @write_block && !@always_write
    GPI.print "Skipping HTML write from #{@source_path}.",
      GPI::CLU.check_option('v')
  else
    GPI.print "Writing HTML from #{@source_path}.",
      GPI::CLU.check_option('v')
    @html.write
  end
end