diff --git a/.travis.yml b/.travis.yml index ceafce8..42d3381 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,13 +12,9 @@ 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 - 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 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/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 fffeac2..71e0250 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/**/*').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.*' @@ -20,10 +34,7 @@ compile '/assets/stylesheets/**/*.scss' do end # Compile all posts -compile '/posts/**/*.md' do - # Every post is an article, needed for blogging helper - @item.attributes[:kind] = 'article' - +compile '/posts/**/*' do filter :kramdown layout '/eventpost.*' @@ -33,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 @@ -52,3 +68,20 @@ route '/**/*.{erb,html,md}' do end layout '/**/*', :erb + +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/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..3a667f1 100644 --- a/content/index.erb +++ b/content/index.erb @@ -3,7 +3,9 @@
- + + +
diff --git a/content/search.erb b/content/search.erb new file mode 100644 index 0000000..1a92bad --- /dev/null +++ b/content/search.erb @@ -0,0 +1,31 @@ +
+
+
+ + <%= render '/partials/_navbar.*' %> +
+ +
+
+ +
+
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) %> 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/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 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