Commit 09ab009f authored by Fabio Pesari's avatar Fabio Pesari

Switched to Rubygem

parent f4c88886
......@@ -6,6 +6,15 @@ It outputs a static HTML board, no JS, from a text-based YAML definition.
I wrote it because I was looking for an easy way to visualize
task priorities, without running server-side or JavaScript code.
## Installation
You can install kanbanale like any Rubygem:
```
gem build kanbanale.gemspec
gem install kanbanale*.gemspec --user
```
## Usage
In order to use kanbanale, you need to know YAML.
......
......@@ -26,33 +26,24 @@ BANNER = <<~USAGE
kanbanale update kanbanale.yaml website/
USAGE
def _data_directory
(ENV['XDG_DATA_DIRS'].split(':') << ENV['XDG_DATA_HOME']).each do |dir|
return dir if Pathname.new(dir).join('kanbanale').exist?
end
Pathname.new(__FILE__).dirname.realpath.parent
end
DATA_DIRECTORY = _data_directory
def quit(message)
warn message
exit(-1)
end
def copy_database(database_filename)
source = Pathname.new(DATA_DIRECTORY).join('templates', 'kanbanale.yaml')
source = Pathname.new(__dir__).parent.join 'templates', 'kanbanale.yaml'
FileUtils.cp source, Pathname.new(database_filename)
end
def copy_website(tar_directory_name)
source = Pathname.new(DATA_DIRECTORY).join 'static'
source = Pathname.new(__dir__).parent.join 'static'
FileUtils.mkdir_p tar_directory_name
FileUtils.cp_r source, Pathname.new(tar_directory_name)
end
def compile_website(database_filename, target_directory_name)
html_template = Pathname.new(DATA_DIRECTORY).join 'templates', 'index.erb'
html_template = Pathname.new(__dir__).parent.join 'templates', 'index.erb'
board = YAML.load_file database_filename
html = ERB.new(File.read(html_template)).result binding
File.write Pathname.new(target_directory_name).join('index.html'), html
......
......@@ -15,8 +15,13 @@
<% column_name = column.keys.first %>
<div class="grid__col grid__col--1-of-<%= columns.length %>" id="<%= column_name.downcase.gsub(' ', '-') %>">
<h2><%= column_name %></h2>
<% column.values.first['cards'].each do |card| %>
<div class="card"><%= card %></div>
<% cards = column.values.first['cards'] %>
<% if cards.class == String %>
<div class="card"><%= cards %></div>
<% elsif cards.class == Array %>
<% cards.each do |card| %>
<div class="card"><%= card %></div>
<% end %>
<% end %>
</div>
<% end %>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment