Class: Nanoc3::Item

Inherits:
Object
  • Object
show all
Includes:
NanDoc::StringMethods
Defined in:
lib/nandoc/hacks/item-class-hacks.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from NanDoc::StringMethods

#basename_no_extension, #indent, #no_blank_lines, #no_leading_ws, #no_trailing_ws, oxford_comma, #quoted, #reindent, #unindent

Instance Attribute Details

#identifierObject

know what you are doing if you set it



20
21
22
# File 'lib/nandoc/hacks/item-class-hacks.rb', line 20

def identifier
  @identifier
end

Class Method Details

.sorted_visible_childrenObject



8
9
10
11
12
13
14
# File 'lib/nandoc/hacks/item-class-hacks.rb', line 8

def sorted_visible_children
  @svc ||= begin
    proc do |node|
      node.children.select{|c| c.nandoc_visible? }.sort_by(&:nandoc_title)
    end
  end
end

Instance Method Details

#nandoc_content_branch?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/nandoc/hacks/item-class-hacks.rb', line 47

def nandoc_content_branch?
  false # hm
end

#nandoc_content_leaf?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/nandoc/hacks/item-class-hacks.rb', line 43

def nandoc_content_leaf?
  nandoc_content_node? # hm
end

#nandoc_content_node?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/nandoc/hacks/item-class-hacks.rb', line 39

def nandoc_content_node?
  /\A\/(?:css|js|vendor)\// !~ identifier # @todo will have to change!
end

#nandoc_sorted_visible_childrenObject



51
52
53
# File 'lib/nandoc/hacks/item-class-hacks.rb', line 51

def nandoc_sorted_visible_children
  self.class.sorted_visible_children.call(self)
end

#nandoc_titleObject

come up with some title by any means necessary



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/nandoc/hacks/item-class-hacks.rb', line 25

def nandoc_title
  if @attributes[:title]
    @attributes[:title]
  elsif ! nandoc_content_node?
    identifier
  elsif no_ext = basename_no_extension(@attributes[:content_filename])
    no_ext.gsub(/[-_]/, ' ') # we could do wiki-name like crap
  elsif ! (foo = File.basename(@attributes[:content_filename])).empty?
    foo
  else
    identifier == '/' ? 'HOME' : identifier.gsub('/',' - ')
  end
end

#nandoc_visible?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/nandoc/hacks/item-class-hacks.rb', line 55

def nandoc_visible?
  !self[:hidden] && path && nandoc_content_node?
end