From 0a64d063b8d7e226f41e251a51d2482176cb0848 Mon Sep 17 00:00:00 2001 From: Lorin Werthen Date: Sun, 24 Jul 2016 13:09:37 +0200 Subject: [PATCH] musta been drunk when i did this --- Gemfile | 2 +- Gemfile.lock | 4 ++-- Rules | 35 ++++++------------------------ content/tipuesearch_content.js.erb | 10 +++++++++ 4 files changed, 20 insertions(+), 31 deletions(-) create mode 100644 content/tipuesearch_content.js.erb diff --git a/Gemfile b/Gemfile index d704cfe..d2aec3b 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index defa644..b94de30 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 diff --git a/Rules b/Rules index c104a41..f8cd188 100644 --- a/Rules +++ b/Rules @@ -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 diff --git a/content/tipuesearch_content.js.erb b/content/tipuesearch_content.js.erb new file mode 100644 index 0000000..d5d0527 --- /dev/null +++ b/content/tipuesearch_content.js.erb @@ -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 %> +]};