[logbooks] use org-mode for rendering syntax of log entries

master
Ryan Rix 2020-01-07 17:50:37 -08:00
parent 93275243ee
commit eddf67dfd7
7 changed files with 44 additions and 8 deletions

View File

@ -49,3 +49,5 @@ group :test do
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'org-ruby'

View File

@ -114,6 +114,8 @@ GEM
nio4r (2.5.2)
nokogiri (1.10.5)
mini_portile2 (~> 2.4.0)
org-ruby (0.9.12)
rubypants (~> 0.2)
pg (1.1.4)
pry (0.12.2)
coderay (~> 1.1.0)
@ -183,6 +185,7 @@ GEM
rspec-support (~> 3.8)
rspec-support (3.9.0)
ruby_dep (1.5.0)
rubypants (0.7.1)
rubyzip (2.0.0)
sass-rails (6.0.0)
sassc-rails (~> 2.1, >= 2.1.1)
@ -253,6 +256,7 @@ DEPENDENCIES
factory_bot_rails
jbuilder (~> 2.7)
listen (>= 3.0.5, < 3.2)
org-ruby
pg (~> 1.1)
pry
pry-rails

View File

@ -1,3 +1,5 @@
require 'org-ruby'
module ApplicationHelper
def glitch_tag text
content_tag :span, text, { 'data-text': text, class: 'glitch' }
@ -14,4 +16,14 @@ module ApplicationHelper
choices[rand(choices.count)]
end
def render_org text
parser = Orgmode::Parser.new(
text,
{ markup_file: "config/org-tags.yml" }
)
parser.to_html.html_safe
end
end

View File

@ -3,7 +3,7 @@
<h2><%= logbook.name %></h2>
<p>
<%= logbook.description %>
<%= render_org logbook.description %>
</p>
<dl class="grid-x">

View File

@ -6,13 +6,14 @@
</div>
<% @object.entries.each do |log_entry| %>
<div class="small-12 cell aug secondary">
<dl>
<dt>
<%= link_to log_entry.name, log_entry_path(log_entry.id) %>
<h3 class="text-small">
<%= link_to log_entry.name, log_entry_path(log_entry.id) %>
<small>
at <%= log_entry.updated_at.strftime("%Y %b %-d at %T %Z") %>
</dt>
<dd><%= log_entry.description %></dd>
</p>
</small>
</h3>
<%= render_org log_entry.description %>
</div>
<% end %>
</div>

View File

@ -149,13 +149,21 @@ $header-styles: (
'h6': ('font-size': 16),
),
medium: (
'h1': ('font-size': 24),
'h2': ('font-size': 20),
'h3': ('font-size': 19),
'h4': ('font-size': 18),
'h5': ('font-size': 17),
'h6': ('font-size': 16),
),
large: (
'h1': ('font-size': 48),
'h2': ('font-size': 40),
'h3': ('font-size': 31),
'h4': ('font-size': 25),
'h5': ('font-size': 20),
'h6': ('font-size': 16),
),
),
);
$header-text-rendering: optimizeLegibility;
$small-font-size: 80%;

9
config/org-tags.yml Normal file
View File

@ -0,0 +1,9 @@
---
:HtmlBlockTag:
:heading1: h3
:heading2: h4
:heading3: h5
:heading4: h6
:heading5: h7
:heading6: h8
:title: h3