Class: Zenweb::Site

Inherits:
Object
  • Object
show all
Defined in:
lib/zenweb-autolink.rb

Instance Method Summary collapse

Instance Method Details

#pages_with_titlesObject

Returns all pages in the site that have a title configured.



13
14
15
# File 'lib/zenweb-autolink.rb', line 13

def pages_with_titles
  html_pages.select {|page| page.config["title"] }
end

#pages_with_titles_as_sorted_regular_expressionsObject

Returns all the pages in the site that have a title as an array of arrays, where each array’s first element is a regular expression matching the page’s title and the second element is that page itself. these are sorted so that the longest title is first e.g., [[/blong title/i,page1],] FIXME: In the end may want to memoize this



24
25
26
27
28
29
30
# File 'lib/zenweb-autolink.rb', line 24

def pages_with_titles_as_sorted_regular_expressions
  pages_with_titles.sort_by do |page|
    page.title.size
  end.reverse.map do |page|
    [/\b#{Regexp.escape(page.title)}\b/i, page]
  end
end