musta been drunk when i did this

This commit is contained in:
Lorin Werthen 2016-07-24 13:09:37 +02:00
parent e2c3a8af93
commit 0a64d063b8
No known key found for this signature in database
GPG key ID: F11FFC921E0E08E0
4 changed files with 20 additions and 31 deletions

View file

@ -3,7 +3,7 @@
source 'https://rubygems.org'
# gem 'nanoc', git: 'https://github.com/werthen/nanoc.git', branch: 'add-resources-to-ilinks-check'
gem 'nanoc', '4.2.2'
gem 'nanoc', '4.2.3'
gem 'kramdown'
gem 'coffee-script'
# Needed for relativize_urls

View file

@ -40,7 +40,7 @@ GEM
lumberjack (1.0.10)
method_source (0.8.2)
mini_portile2 (2.1.0)
nanoc (4.2.2)
nanoc (4.2.3)
cri (~> 2.3)
hamster (~> 3.0)
nenv (0.3.0)
@ -76,7 +76,7 @@ DEPENDENCIES
coffee-script
guard-nanoc
kramdown
nanoc (= 4.2.2)
nanoc (= 4.2.3)
nokogiri
sass
w3c_validators

35
Rules
View file

@ -32,13 +32,8 @@ preprocess do
binary: false
)
end
@items.create('', {}, '/tipuesearch_content.js', binary: false)
end
# This makes sure this tipuesearch_content doesn't get deleted
passthrough '/tipuesearch_content.js'
#
#
# COMPILATION
@ -88,6 +83,10 @@ end
#
# GENERIC ERB PAGES
#
compile '/tipuesearch_content.js.erb' do
filter :erb
end
compile '/*.erb' do
layout '/generic.*'
layout '/default.*'
@ -122,6 +121,9 @@ route '/index.*' do
'/index.html'
end
route '/tipuesearch_content.js.erb' do
'/tipuesearch_content.js'
end
#
# ASSETS
#
@ -145,26 +147,3 @@ end
#
layout '/**/*', :erb
#
#
# POSTPROCESS
#
#
postprocess do
tmp = articles.map do |e|
{
title: e[:title],
url: url_for(e),
text: excerptize(e.reps[:text].compiled_content, length: 200),
tags: ''
}
end
tmp = { pages: tmp }
File.open('output/tipuesearch_content.js', 'w') do |f|
f.write("var tipuesearch = #{tmp.to_json};")
end
end

View file

@ -0,0 +1,10 @@
var tipuesearch = { "pages": [
<% articles.each do |e| %>
{
"title": "<%= e[:title] %>",
"url": "<%= url_for(e) %>",
"text": "<%= excerptize(e.reps[:text].compiled_content, length: 200).gsub(/\n/, ' ') %>",
"tags": ""
},
<% end %>
]};