class Jekyll::AuthorsGenerator

Public Instance Methods

atomize(site, type, posts) click to toggle source
# File _plugins/jekyll-autgenerator.rb, line 20
def atomize(site, type, posts)
  path = "/author/#{posts[0]}"
  atom = AtomPageAuthor.new(site, site.source, path, type, posts[0], posts[1])
  site.pages << atom
end
build_subpages(site, type, posts) click to toggle source
# File _plugins/jekyll-autgenerator.rb, line 14
def build_subpages(site, type, posts)
  posts[1] = posts[1].sort_by { |p| -p.date.to_f }
  atomize(site, type, posts)
  paginate(site, type, posts)
end
generate(site) click to toggle source
# File _plugins/jekyll-autgenerator.rb, line 7
def generate(site)
  site.data['authors'].each do |author, data|
    posts = [author, posts_by_author(site, author)]
    build_subpages(site, 'author', posts)
  end
end
paginate(site, type, posts) click to toggle source
# File _plugins/jekyll-autgenerator.rb, line 26
def paginate(site, type, posts)
  pages = Jekyll::Paginate::Pager.calculate_pages(posts[1], site.config['paginate'].to_i)
  (1..pages).each do |num_page|
    pager = Jekyll::Paginate::Pager.new(site, num_page, posts[1], pages)
    path = "/author/#{posts[0]}"
    if num_page > 1
      path = path + "/page#{num_page}"
    end
    newpage = GroupSubPageAuthor.new(site, site.source, path, type, posts[0])
    newpage.pager = pager
    site.pages << newpage

  end
end

Private Instance Methods

posts_by_author(site, author) click to toggle source
# File _plugins/jekyll-autgenerator.rb, line 43
def posts_by_author(site, author)
  site.posts.docs.select { |post| post.data['author'] == author }
end