From bce47ca93be69043d1469566d20caa3ab63a39f4 Mon Sep 17 00:00:00 2001 From: Lorin Werthen Date: Wed, 20 Jul 2016 14:38:50 +0200 Subject: [PATCH 1/6] start work on tipue search --- Rules | 34 +++++++++++++++++++++++++--- content/assets/stylesheets/main.scss | 2 +- content/index.erb | 9 ++++++++ layouts/default.erb | 5 ++++ 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/Rules b/Rules index fffeac2..50ba791 100644 --- a/Rules +++ b/Rules @@ -1,6 +1,20 @@ #!/usr/bin/env ruby # frozen_string_literal: true +require 'json' + +preprocess do + # Tag all posts with 'article' + @items.find_all('/posts/**/*.md').each do |i| + i.attributes[:kind] = 'article' + end + + @items.create('', {}, '/tipuesearch_content.js', binary: false) +end + +# This makes sure this tipuesearch_content doesn't get deleted +passthrough '/tipuesearch_content.js' + # ERB compile '/*.erb' do layout '/default.*' @@ -21,9 +35,6 @@ end # Compile all posts compile '/posts/**/*.md' do - # Every post is an article, needed for blogging helper - @item.attributes[:kind] = 'article' - filter :kramdown layout '/eventpost.*' @@ -52,3 +63,20 @@ route '/**/*.{erb,html,md}' do end layout '/**/*', :erb + +postprocess do + tmp = articles.map do |e| + { + title: e[:title], + url: url_for(e), + text: '', + 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/assets/stylesheets/main.scss b/content/assets/stylesheets/main.scss index 43eae56..2e1bb5e 100644 --- a/content/assets/stylesheets/main.scss +++ b/content/assets/stylesheets/main.scss @@ -5,7 +5,7 @@ $event-border-color: #DDD; $cammie-controls-color: rgba(0, 0, 0, 0.60); -@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,700); +@import url(https://fonts.googleapis.com/css?family=Open+Sans:300,400,700); html, button, input, select, textarea, .pure-g [class *= "pure-u"] { diff --git a/content/index.erb b/content/index.erb index 8f6d386..79ba798 100644 --- a/content/index.erb +++ b/content/index.erb @@ -20,6 +20,15 @@ <%= render '/partials/_navbar.*' %>
+
+ +
+
+
<%= render '/partials/_tile.*', article: sorted_articles[0] %>
diff --git a/layouts/default.erb b/layouts/default.erb index 8d8edd1..34146ab 100644 --- a/layouts/default.erb +++ b/layouts/default.erb @@ -24,6 +24,11 @@ + + + + + <%= content_for(@item, :head) %> From a9374438f99016ff96db8104625bb1c569362b1c Mon Sep 17 00:00:00 2001 From: Lorin Werthen Date: Wed, 20 Jul 2016 17:52:56 +0200 Subject: [PATCH 2/6] working search in a very awkward place --- Gemfile | 3 ++- Gemfile.lock | 24 ++++++++---------------- Rules | 11 ++++++++--- lib/strip_filter.rb | 9 +++++++++ 4 files changed, 27 insertions(+), 20 deletions(-) create mode 100644 lib/strip_filter.rb diff --git a/Gemfile b/Gemfile index 6a290ee..d704cfe 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,8 @@ # A sample Gemfile 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 'kramdown' gem 'coffee-script' # Needed for relativize_urls diff --git a/Gemfile.lock b/Gemfile.lock index ce37b08..defa644 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,13 +1,3 @@ -GIT - remote: https://github.com/werthen/nanoc.git - revision: bd3235d8dbae71c5bf0328ba4630070c53a5d3f4 - branch: add-resources-to-ilinks-check - specs: - nanoc (4.2.3) - cri (~> 2.3) - hamster (~> 3.0) - ref (~> 2.0) - GEM remote: https://rubygems.org/ specs: @@ -23,7 +13,7 @@ GEM cri (2.7.0) colored (~> 1.2) execjs (2.7.0) - ffi (1.9.10) + ffi (1.9.14) formatador (0.2.5) guard (2.14.0) formatador (>= 0.2.4) @@ -42,7 +32,7 @@ GEM hamster (3.0.0) concurrent-ruby (~> 1.0) json (2.0.1) - kramdown (1.10.0) + kramdown (1.11.1) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) @@ -50,6 +40,9 @@ GEM lumberjack (1.0.10) method_source (0.8.2) mini_portile2 (2.1.0) + nanoc (4.2.2) + cri (~> 2.3) + hamster (~> 3.0) nenv (0.3.0) nokogiri (1.6.8) mini_portile2 (~> 2.1.0) @@ -58,15 +51,14 @@ GEM nenv (~> 0.1) shellany (~> 0.0) pkg-config (1.1.7) - pry (0.10.3) + pry (0.10.4) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) - rack (1.6.4) + rack (2.0.1) rb-fsevent (0.9.7) rb-inotify (0.9.7) ffi (>= 0.5.0) - ref (2.0.0) ruby_dep (1.3.1) sass (3.4.22) shellany (0.0.1) @@ -84,7 +76,7 @@ DEPENDENCIES coffee-script guard-nanoc kramdown - nanoc! + nanoc (= 4.2.2) nokogiri sass w3c_validators diff --git a/Rules b/Rules index 50ba791..69eb3ba 100644 --- a/Rules +++ b/Rules @@ -5,7 +5,7 @@ require 'json' preprocess do # Tag all posts with 'article' - @items.find_all('/posts/**/*.md').each do |i| + @items.find_all('/posts/**/*').each do |i| i.attributes[:kind] = 'article' end @@ -34,7 +34,7 @@ compile '/assets/stylesheets/**/*.scss' do end # Compile all posts -compile '/posts/**/*.md' do +compile '/posts/**/*' do filter :kramdown layout '/eventpost.*' @@ -44,6 +44,11 @@ compile '/posts/**/*.md' do filter :relativize_paths, type: :html end +compile '/posts/**/*', rep: :text do + filter :kramdown + filter :strip_html +end + route '/index.*' do '/index.html' end @@ -69,7 +74,7 @@ postprocess do { title: e[:title], url: url_for(e), - text: '', + text: e.reps[:text].compiled_content, tags: '' } end diff --git a/lib/strip_filter.rb b/lib/strip_filter.rb new file mode 100644 index 0000000..21252a9 --- /dev/null +++ b/lib/strip_filter.rb @@ -0,0 +1,9 @@ +include Nanoc::Helpers::Text + +class StripFilter < Nanoc::Filter + identifier :strip_html + + def run(content, _params = {}) + strip_html(content) + end +end From 13733d4088f78a66450b289e2889f6ade9956a4e Mon Sep 17 00:00:00 2001 From: Lorin Werthen Date: Wed, 20 Jul 2016 18:23:38 +0200 Subject: [PATCH 3/6] search page --- Rules | 2 +- content/index.erb | 13 +++---------- content/search.erb | 31 +++++++++++++++++++++++++++++++ layouts/partials/_navbar.erb | 3 +++ nanoc.yaml | 3 ++- 5 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 content/search.erb diff --git a/Rules b/Rules index 69eb3ba..71e0250 100644 --- a/Rules +++ b/Rules @@ -74,7 +74,7 @@ postprocess do { title: e[:title], url: url_for(e), - text: e.reps[:text].compiled_content, + text: excerptize(e.reps[:text].compiled_content, length: 200), tags: '' } end diff --git a/content/index.erb b/content/index.erb index 79ba798..3a667f1 100644 --- a/content/index.erb +++ b/content/index.erb @@ -3,7 +3,9 @@
-
- -
-
-
<%= render '/partials/_tile.*', article: sorted_articles[0] %>
diff --git a/content/search.erb b/content/search.erb new file mode 100644 index 0000000..379d139 --- /dev/null +++ b/content/search.erb @@ -0,0 +1,31 @@ + +<%= render '/partials/_navbar.*' %> +
+
+
+
+ +
+
+ +
+
diff --git a/layouts/partials/_navbar.erb b/layouts/partials/_navbar.erb index 5e18fc5..98a098b 100644 --- a/layouts/partials/_navbar.erb +++ b/layouts/partials/_navbar.erb @@ -8,6 +8,9 @@ Contact + + Search + Cammie diff --git a/nanoc.yaml b/nanoc.yaml index f3b1a3d..8e684cd 100644 --- a/nanoc.yaml +++ b/nanoc.yaml @@ -1,4 +1,5 @@ -base_url: https://zeus.ugent.be/beta +#base_url: https://zeus.ugent.be/beta +base_url: http://localhost:3000 # The syntax to use for patterns in the Rules file. Can be either `"glob"` # (default) or `"legacy"`. The former will enable glob patterns, which behave From af48e56698c680365a4a2757483e44c283041bfc Mon Sep 17 00:00:00 2001 From: Lorin Werthen Date: Wed, 20 Jul 2016 19:50:54 +0200 Subject: [PATCH 4/6] checks --- .travis.yml | 6 +----- Checks | 8 ++++++++ content/search.erb | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 Checks diff --git a/.travis.yml b/.travis.yml index ceafce8..2ae0668 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,11 +12,7 @@ before_install: - echo -e "Host zeus.ugent.be\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config script: - bundle exec nanoc -- bundle exec nanoc check elinks -- bundle exec nanoc check html -- bundle exec nanoc check ilinks -- bundle exec nanoc check mixed_content -- bundle exec nanoc check stale +- bundle exec nanoc check --deploy after_success: - mv deploy_key ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa diff --git a/Checks b/Checks new file mode 100644 index 0000000..0a52fbf --- /dev/null +++ b/Checks @@ -0,0 +1,8 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +deploy_check :elinks +deploy_check :html +deploy_check :ilinks +deploy_check :mixed_content +deploy_check :stale diff --git a/content/search.erb b/content/search.erb index 379d139..f5ab388 100644 --- a/content/search.erb +++ b/content/search.erb @@ -18,7 +18,7 @@
-
+
From d4883824c72cb2028f542ce3525baba87eee4438 Mon Sep 17 00:00:00 2001 From: Lorin Werthen Date: Wed, 20 Jul 2016 21:56:45 +0200 Subject: [PATCH 5/6] layouting --- content/search.erb | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/content/search.erb b/content/search.erb index f5ab388..1a92bad 100644 --- a/content/search.erb +++ b/content/search.erb @@ -1,23 +1,23 @@ - -<%= render '/partials/_navbar.*' %>
-
-
+
+
+ + <%= render '/partials/_navbar.*' %>
From 20ef5a4460b2d876f0855f03eac56d0a53435ce7 Mon Sep 17 00:00:00 2001 From: Lorin Werthen Date: Thu, 21 Jul 2016 14:51:36 +0200 Subject: [PATCH 6/6] pls dont deploy --- .travis.yml | 2 +- .travis/deploy.sh | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) delete mode 100644 .travis/deploy.sh diff --git a/.travis.yml b/.travis.yml index 2ae0668..42d3381 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,4 +17,4 @@ after_success: - mv deploy_key ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa - chmod +x .travis/deploy.sh -- .travis/deploy.sh +- '[[ $TRAVIS_BRANCH == "master" ]] && echo "Deploying site"' diff --git a/.travis/deploy.sh b/.travis/deploy.sh deleted file mode 100644 index b2ec0e1..0000000 --- a/.travis/deploy.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -if [[ $TRAVIS_BRANCH == 'master' ]]; then - echo "Deploying site..." - bundle exec nanoc deploy --target public -else - echo "Not deploying." -fi