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' source 'https://rubygems.org'
# gem 'nanoc', git: 'https://github.com/werthen/nanoc.git', branch: 'add-resources-to-ilinks-check' # 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 'kramdown'
gem 'coffee-script' gem 'coffee-script'
# Needed for relativize_urls # Needed for relativize_urls

View file

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

35
Rules
View file

@ -32,13 +32,8 @@ preprocess do
binary: false binary: false
) )
end end
@items.create('', {}, '/tipuesearch_content.js', binary: false)
end end
# This makes sure this tipuesearch_content doesn't get deleted
passthrough '/tipuesearch_content.js'
# #
# #
# COMPILATION # COMPILATION
@ -88,6 +83,10 @@ end
# #
# GENERIC ERB PAGES # GENERIC ERB PAGES
# #
compile '/tipuesearch_content.js.erb' do
filter :erb
end
compile '/*.erb' do compile '/*.erb' do
layout '/generic.*' layout '/generic.*'
layout '/default.*' layout '/default.*'
@ -122,6 +121,9 @@ route '/index.*' do
'/index.html' '/index.html'
end end
route '/tipuesearch_content.js.erb' do
'/tipuesearch_content.js'
end
# #
# ASSETS # ASSETS
# #
@ -145,26 +147,3 @@ end
# #
layout '/**/*', :erb 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 %>
]};