Rules
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
#!/usr/bin/env ruby compile /^\/archives\// do rep.filter :erb layout 'default' end compile /^\/(home|projects|about)/ do rep.filter :erb rep.filter :redcloth layout 'default' end compile /(rss|atom)/ do begin rep.filter :erb rescue Exception end end compile '/css/*' do filter :sass, { :load_paths => [Dir.pwd+"/content/css"], :full_exception => true, :line_numbers => true } end compile 'sitemap' do begin rep.filter :erb rescue Exception end end compile /^\/(js\/.+?)/ do # do nothing end compile '*' do if item[:filters_pre] && !item[:filters_pre].empty? then item[:filters_pre].each do |f| rep.filter f.to_sym end layout 'default' else unless rep.binary? then case item[:extension] when 'textile' then rep.filter :redcloth layout 'default' when 'md','markdown' then rep.filter :bluecloth layout 'default' when 'bbcode' then rep.filter :bbcode layout 'default' when 'glyph' then # Create the PDF file doc = %{ document[ head[ style[default.css] style[css3.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> ] body[ titlepage[ =>[http://www.h3rald.com/archives/|img[$[site.root]/images/theme/h3rald.svg|25%|25%]] title[] author[] <span class="pubdate">\\.$[document.date]</span> <div><em>Originally published on =>[http://www.h3rald.com#{item.identifier}|H3RALD.com]</em></div> toc[] ] textile[ #{item.raw_content} ] ] ] } f = Pathname.new "#{Dir.pwd}/output#{item.identifier.gsub(/\/$/, '')}.glyph" f.parent.mkpath # Write the new raw file using Glyph's file_write method file_write f, doc # Now compile the PDF (works if Prince is installed) target = Glyph['document.output'] Glyph['document.output'] = 'pdf' Glyph['site.root'] = ".." Glyph['document.date'] = item[:date].strftime "%A, %d %B %Y" Glyph['document.title'] = item[:title] Glyph['document.subtitle'] = "" Glyph.compile f.to_s, f.to_s.gsub(/\.glyph$/, '.pdf') begin f.unlink Pathname.new(f.to_s.gsub(/\.glyph$/, '.html')).unlink rescue end # Re-apply overrides require 'lib/glyph-data' # Filter text rep rep.filter :glyph layout 'default' Glyph.reset end end end end route /^\/tags\/.+?-(atom|rss)/ do item.identifier.gsub(/(.+)-(rss|atom)\/$/, '\1/\2') + '.xml' end route '/(atom|rss)/' do item.identifier.gsub(/\/$/, '') + '.xml' end route '/css/*' do item.identifier.gsub(/\/$/, '') + '.css' end route '/sitemap' do item.identifier.gsub(/\/$/, '') + '.xml' end route "/htaccess" do "/.htaccess" end route /\/(images|img|files|favicon|robots)\// do item.identifier.gsub(/\/$/, '') + ".#{item[:extension]}" end route '/js/*' do item.identifier.gsub(/\/$/, '') + '.js' end route '*' do item.identifier + 'index.html' end layout '*', :erb |