class Kanboard::JekyllRenderer

Constants

OUTPUT_DIR

Public Class Methods

new(board) click to toggle source
# File lib/kanboard/jekyll_renderer.rb, line 6
def initialize(board)
  @board = board
end

Public Instance Methods

render() click to toggle source
# File lib/kanboard/jekyll_renderer.rb, line 10
def render
  Dir.mkdir(OUTPUT_DIR) if not Dir.exists?(OUTPUT_DIR)

  board_filename = File.join(OUTPUT_DIR, 
                             @board.project.gsub(/[\p{Punct}\p{Space}]+/, "_") +
                             ".textile")
  File.open(board_filename, 'w') do |f|
    f.puts render_board
  end

  board_filename = File.join(OUTPUT_DIR, 
                             @board.project.gsub(/[\p{Punct}\p{Space}]+/, "_") +
                             "-assignments.textile")
  File.open(board_filename, 'w') do |f|
    f.puts render_assignments
  end
end
render_assignments() click to toggle source
# File lib/kanboard/jekyll_renderer.rb, line 64
  def render_assignments
    output = ""
    output << "---
title: Assignments for #{@board.project}
layout: default
---
h1. Assignments for #{@board.project}\n\n"
    @board.owners.each do |owner|
      output << "h2. #{owner}\n"
      @board.cards_of(owner).each do |card|
        output << "* #{card}\n"
      end
    end
    output
  end
render_board() click to toggle source
# File lib/kanboard/jekyll_renderer.rb, line 28
  def render_board
    statuses = @board.statuses
    swimlanes = @board.swimlanes

    output = ""
    output << "---
title: Kanban Board for #{@board.project}
layout: default
---
h1. Board for #{@board.project}\n\n"
    output << "<table class=\"board\">"
    output << "<tr>\n"
    output << "  <th></th>\n"
    statuses.each do |status|
      output << "  <th>#{status}</th>\n"
    end
    output << "</tr>\n"

    swimlanes.each do |swimlane|
      output << "<tr>\n"
      output << "  <td>#{swimlane}</td>\n"

      statuses.each do |status|
        output << "  <td>\n"
        @board.cards(status, swimlane).each do |card|
          output << "    <div class=\"card\">#{card}</div>\n"
        end
        output << "  </td>\n"
      end
      output << "</tr>\n"
    end
    output << "</table>\n"

    output
  end