all repos — h3rald @ a835825f45933c2e63bbf9c04557564b9ad27bba

The sources of https://h3rald.com

Streamlined PDF generation for articles.
h3rald h3rald@h3rald.com
Thu, 10 Jun 2010 10:11:04 +0200
commit

a835825f45933c2e63bbf9c04557564b9ad27bba

parent

e293eab571225956ed9d80ac34782c32022bb131

2 files changed, 39 insertions(+), 31 deletions(-)

jump to
M RulesRules

@@ -51,37 +51,15 @@ rep.filter :bbcode

layout 'default' when 'glyph' then # Create the PDF file - doc = %{ -article[ - @head[ - style[default.css] - style[pagination.css] - <style> - h1 { - font-size: 24px; - margin: 0.5em auto; - padding: 0.5em auto; - } - .contents { - text-align:justify; - margin-bottom: 2em; - padding-bottom: 2em; - border-bottom: 1px solid #000; - } - </style> - ] - @halftitlepage[ - =>[http://www.h3rald.com/archives/|image[@width[25%]@height[25%]$[site.root]/images/theme/h3rald.svg]] - title[] - author[] - span[@class[pubdate]$[document.date]] - div[em[Originally published on =>[http://www.h3rald.com#{item.identifier}|H3RALD.com]]] - toc[] - ] -#{item.raw_content} -]} f = Pathname.new "#{Dir.pwd}/output#{item.identifier.gsub(/\/$/, '')}.glyph" f.parent.mkpath + doc = %{ + include[#{f.parent.parent.parent}/lib/data] + h3rald_article[ + @identifier[#{item.identifier}] + @content[#{item.raw_content}] + ] + } # Write the new raw file using Glyph's file_write method file_write f, doc # Now compile the PDF (works if Prince is installed)

@@ -94,8 +72,8 @@ Glyph['document.title'] = item[:title]

Glyph['document.subtitle'] = "" Glyph.compile f.to_s begin - f.unlink - Pathname.new(f.to_s.gsub(/\.glyph$/, '.html')).unlink + #f.unlink + #Pathname.new(f.to_s.gsub(/\.glyph$/, '.html')).unlink rescue end Glyph['site.root'] = ""
A lib/data.glyph

@@ -0,0 +1,30 @@

+rw:[h3rald_article| + article[ + @pubdate[$[document.date]] + @head[ + style[default.css] + style[pagination.css] + <style> + h1 { + font-size: 24px; + margin: 0.5em auto; + padding: 0.5em auto; + } + .contents { + text-align:justify; + margin-bottom: 2em; + padding-bottom: 2em; + border-bottom: 1px solid #000; + } + </style> + ] + @pre-title[ + =>[http://www.h3rald.com/archives/|image[@width[25%]@height[25%]$[site.root]/images/theme/h3rald.svg]] + ] + @post-title[ + div[em[Originally published on =>[http://www.h3rald.com{{identifier}}|H3RALD.com]]] + toc[] + ] + {{content}} + ] +]