start work on tipue search

This commit is contained in:
Lorin Werthen 2016-07-20 14:38:50 +02:00
parent c938586cf1
commit bce47ca93b
No known key found for this signature in database
GPG key ID: F11FFC921E0E08E0
4 changed files with 46 additions and 4 deletions

34
Rules
View file

@ -1,6 +1,20 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# frozen_string_literal: true # 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 # ERB
compile '/*.erb' do compile '/*.erb' do
layout '/default.*' layout '/default.*'
@ -21,9 +35,6 @@ end
# Compile all posts # Compile all posts
compile '/posts/**/*.md' do compile '/posts/**/*.md' do
# Every post is an article, needed for blogging helper
@item.attributes[:kind] = 'article'
filter :kramdown filter :kramdown
layout '/eventpost.*' layout '/eventpost.*'
@ -52,3 +63,20 @@ route '/**/*.{erb,html,md}' do
end end
layout '/**/*', :erb 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

View file

@ -5,7 +5,7 @@ $event-border-color: #DDD;
$cammie-controls-color: rgba(0, 0, 0, 0.60); $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, html, button, input, select, textarea,
.pure-g [class *= "pure-u"] { .pure-g [class *= "pure-u"] {

View file

@ -20,6 +20,15 @@
<%= render '/partials/_navbar.*' %> <%= render '/partials/_navbar.*' %>
</header> </header>
<main> <main>
<form action="?">
<input type="text" name="q" id="tipue_search_input" autocomplete="off" required>
</form>
<div id="tipue_search_content"></div>
<script>
$(document).ready(function() {
$('#tipue_search_input').tipuesearch();
});
</script>
<div id="all-events"> <div id="all-events">
<%= render '/partials/_tile.*', article: sorted_articles[0] %> <%= render '/partials/_tile.*', article: sorted_articles[0] %>
<div class="pure-g"> <div class="pure-g">

View file

@ -24,6 +24,11 @@
<meta property="fb:app_id" content="597670540410704"> <meta property="fb:app_id" content="597670540410704">
<script src="/tipuesearch_content.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/Tipue-Search/5.0.0/tipuesearch.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/Tipue-Search/5.0.0/tipuesearch_set.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Tipue-Search/5.0.0/tipuesearch.min.js"></script>
<%= content_for(@item, :head) %> <%= content_for(@item, :head) %>
</head> </head>
<body> <body>