Skip to content

Commit 5a2f1e0

Browse files
committedAug 4, 2015
Upgrade Tipue Search to v5.0
- New JS and CSS files for Tipue Search v5.0. - LateTask to create "search.html" page to use for search entries
1 parent 0546186 commit 5a2f1e0

File tree

13 files changed

+864
-606
lines changed

13 files changed

+864
-606
lines changed
 
368 Bytes
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
2+
/*
3+
Tipue Search 5.0
4+
Copyright (c) 2015 Tipue
5+
Tipue Search is released under the MIT License
6+
http://www.tipue.com/search
7+
*/
8+
9+
10+
#tipue_search_input
11+
{
12+
font: 13px/1.6 'open sans', sans-serif;
13+
color: #333;
14+
padding: 12px 12px 12px 40px;
15+
width: 170px;
16+
border: 1px solid #e2e2e2;
17+
border-radius: 0;
18+
-moz-appearance: none;
19+
-webkit-appearance: none;
20+
box-shadow: none;
21+
outline: 0;
22+
margin: 0;
23+
background: #fff url('img/search.png') no-repeat 15px 15px;
24+
}
25+
26+
#tipue_search_content
27+
{
28+
max-width: 650px;
29+
padding-top: 15px;
30+
margin: 0;
31+
}
32+
#tipue_search_warning
33+
{
34+
font: 300 15px/1.6 'Open Sans', sans-serif;
35+
color: #555;
36+
margin: 7px 0;
37+
}
38+
#tipue_search_warning a
39+
{
40+
color: #396;
41+
text-decoration: none;
42+
}
43+
#tipue_search_warning a:hover
44+
{
45+
color: #555;
46+
}
47+
#tipue_search_results_count
48+
{
49+
font: 300 15px/1.7 'Open Sans', sans-serif;
50+
color: #555;
51+
}
52+
.tipue_search_content_title
53+
{
54+
font: 300 21px/1.7 'Open Sans', sans-serif;
55+
margin-top: 23px;
56+
}
57+
.tipue_search_content_title a
58+
{
59+
color: #333;
60+
text-decoration: none;
61+
}
62+
.tipue_search_content_title a:hover
63+
{
64+
color: #555;
65+
}
66+
.tipue_search_content_url
67+
{
68+
font: 300 14px/1.9 'Open Sans', sans-serif;
69+
word-wrap: break-word;
70+
hyphens: auto;
71+
}
72+
.tipue_search_content_url a
73+
{
74+
color: #396;
75+
text-decoration: none;
76+
}
77+
.tipue_search_content_url a:hover
78+
{
79+
color: #555;
80+
}
81+
.tipue_search_content_text
82+
{
83+
font: 300 15px/1.6 'Open Sans', sans-serif;
84+
color: #555;
85+
word-wrap: break-word;
86+
hyphens: auto;
87+
margin-top: 3px;
88+
}
89+
.tipue_search_content_debug
90+
{
91+
font: 300 13px/1.6 'Open Sans', sans-serif;
92+
color: #555;
93+
margin: 5px 0;
94+
}
95+
.h01
96+
{
97+
color: #333;
98+
font-weight: 400;
99+
}
100+
101+
#tipue_search_foot
102+
{
103+
margin: 51px 0 21px 0;
104+
}
105+
#tipue_search_foot_boxes
106+
{
107+
padding: 0;
108+
margin: 0;
109+
font: 12px 'Open Sans', sans-serif;
110+
}
111+
#tipue_search_foot_boxes li
112+
{
113+
list-style: none;
114+
margin: 0;
115+
padding: 0;
116+
display: inline;
117+
}
118+
#tipue_search_foot_boxes li a
119+
{
120+
padding: 10px 17px 11px 17px;
121+
background-color: #fff;
122+
border: 1px solid #e2e2e2;
123+
border-radius: 1px;
124+
color: #333;
125+
margin-right: 7px;
126+
text-decoration: none;
127+
text-align: center;
128+
}
129+
#tipue_search_foot_boxes li.current
130+
{
131+
padding: 10px 17px 11px 17px;
132+
background: #f6f6f6;
133+
border: 1px solid #e2e2e2;
134+
border-radius: 1px;
135+
color: #333;
136+
margin-right: 7px;
137+
text-align: center;
138+
}
139+
#tipue_search_foot_boxes li a:hover
140+
{
141+
background: #f6f6f6;
142+
}
143+
144+
145+
/* spinner */
146+
147+
148+
.tipue_search_spinner
149+
{
150+
padding: 31px 0;
151+
width: 50px;
152+
height: 28px;
153+
}
154+
.tipue_search_spinner > div
155+
{
156+
background-color: #777;
157+
height: 100%;
158+
width: 3px;
159+
display: inline-block;
160+
margin-right: 2px;
161+
-webkit-animation: stretchdelay 1.2s infinite ease-in-out;
162+
animation: stretchdelay 1.2s infinite ease-in-out;
163+
}
164+
.tipue_search_spinner .tipue_search_rect2
165+
{
166+
-webkit-animation-delay: -1.1s;
167+
animation-delay: -1.1s;
168+
}
169+
.tipue_search_spinner .tipue_search_rect3
170+
{
171+
-webkit-animation-delay: -1.0s;
172+
animation-delay: -1.0s;
173+
}
174+
@-webkit-keyframes stretchdelay
175+
{
176+
0%, 40%, 100%
177+
{
178+
-webkit-transform: scaleY(0.4)
179+
}
180+
20%
181+
{
182+
-webkit-transform: scaleY(1.0)
183+
}
184+
}
185+
@keyframes stretchdelay
186+
{
187+
0%, 40%, 100%
188+
{
189+
transform: scaleY(0.4);
190+
-webkit-transform: scaleY(0.4);
191+
}
192+
20%
193+
{
194+
transform: scaleY(1.0);
195+
-webkit-transform: scaleY(1.0);
196+
}
197+
}
198+
199+
200+
201+
202+
203+

‎v7/localsearch/files/assets/js/tipuesearch.js

+520
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
2+
/*
3+
Tipue Search 5.0
4+
Copyright (c) 2015 Tipue
5+
Tipue Search is released under the MIT License
6+
http://www.tipue.com/search
7+
*/
8+
9+
10+
/*
11+
Stop words
12+
Stop words list from http://www.ranks.nl/stopwords
13+
*/
14+
15+
var tipuesearch_stop_words = ["a", "about", "above", "after", "again", "against", "all", "am", "an", "and", "any", "are", "aren't", "as", "at", "be", "because", "been", "before", "being", "below", "between", "both", "but", "by", "can't", "cannot", "could", "couldn't", "did", "didn't", "do", "does", "doesn't", "doing", "don't", "down", "during", "each", "few", "for", "from", "further", "had", "hadn't", "has", "hasn't", "have", "haven't", "having", "he", "he'd", "he'll", "he's", "her", "here", "here's", "hers", "herself", "him", "himself", "his", "how", "how's", "i", "i'd", "i'll", "i'm", "i've", "if", "in", "into", "is", "isn't", "it", "it's", "its", "itself", "let's", "me", "more", "most", "mustn't", "my", "myself", "no", "nor", "not", "of", "off", "on", "once", "only", "or", "other", "ought", "our", "ours", "ourselves", "out", "over", "own", "same", "shan't", "she", "she'd", "she'll", "she's", "should", "shouldn't", "so", "some", "such", "than", "that", "that's", "the", "their", "theirs", "them", "themselves", "then", "there", "there's", "these", "they", "they'd", "they'll", "they're", "they've", "this", "those", "through", "to", "too", "under", "until", "up", "very", "was", "wasn't", "we", "we'd", "we'll", "we're", "we've", "were", "weren't", "what", "what's", "when", "when's", "where", "where's", "which", "while", "who", "who's", "whom", "why", "why's", "with", "won't", "would", "wouldn't", "you", "you'd", "you'll", "you're", "you've", "your", "yours", "yourself", "yourselves"];
16+
17+
18+
// Word replace
19+
20+
var tipuesearch_replace = {'words': [
21+
{'word': 'tipua', 'replace_with': 'tipue'},
22+
{'word': 'javscript', 'replace_with': 'javascript'},
23+
{'word': 'jqeury', 'replace_with': 'jquery'}
24+
]};
25+
26+
27+
// Weighting
28+
29+
var tipuesearch_weight = {'weight': [
30+
{'url': 'http://www.tipue.com', 'score': 200},
31+
{'url': 'http://www.tipue.com/search', 'score': 100},
32+
{'url': 'http://www.tipue.com/about', 'score': 100}
33+
]};
34+
35+
36+
// Stemming
37+
38+
var tipuesearch_stem = {'words': [
39+
{'word': 'e-mail', 'stem': 'email'},
40+
{'word': 'javascript', 'stem': 'jquery'},
41+
{'word': 'javascript', 'stem': 'js'}
42+
]};
43+
44+
45+
// Internal strings
46+
47+
var tipuesearch_string_1 = 'No title';
48+
var tipuesearch_string_2 = 'Showing results for';
49+
var tipuesearch_string_3 = 'Search instead for';
50+
var tipuesearch_string_4 = '1 result';
51+
var tipuesearch_string_5 = 'results';
52+
var tipuesearch_string_6 = 'Prev';
53+
var tipuesearch_string_7 = 'Next';
54+
var tipuesearch_string_8 = 'Nothing found';
55+
var tipuesearch_string_9 = 'Common words are largely ignored';
56+
var tipuesearch_string_10 = 'Search too short';
57+
var tipuesearch_string_11 = 'Should be one character or more';
58+
var tipuesearch_string_12 = 'Should be';
59+
var tipuesearch_string_13 = 'characters or more';

‎v7/localsearch/localsearch.plugin

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Module = localsearch
44

55
[Documentation]
66
Author = Roberto Alsina
7-
Version = 0.1
7+
Version = 0.2
88
Website = http://plugins.getnikola.com/#localsearch
99
Description = Create data files for local search via Tipue
1010

‎v7/localsearch/localsearch/__init__.py ‎v7/localsearch/localsearch.py

+53-11
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,33 @@
2525
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2626

2727
from __future__ import unicode_literals
28+
from copy import copy
2829
import codecs
2930
import json
3031
import os
3132

3233
from doit.tools import result_dep
3334

3435
from nikola.plugin_categories import LateTask
35-
from nikola.utils import config_changed, copy_tree, makedirs
36+
from nikola.utils import config_changed, copy_tree, makedirs, LocaleBorg
3637

3738
# This is what we need to produce:
3839
# var tipuesearch = {"pages": [
3940
# {"title": "Tipue Search, a jQuery site search engine", "text": "Tipue
4041
# Search is a site search engine jQuery plugin. It's free for both commercial and
4142
# non-commercial use and released under the MIT License. Tipue Search includes
4243
# features such as word stemming and word replacement.", "tags": "JavaScript",
43-
# "loc": "http://www.tipue.com/search"},
44+
# "url": "http://www.tipue.com/search"},
4445
# {"title": "Tipue Search demo", "text": "Tipue Search demo. Tipue Search is
45-
# a site search engine jQuery plugin.", "tags": "JavaScript", "loc":
46+
# a site search engine jQuery plugin.", "tags": "JavaScript", "url":
4647
# "http://www.tipue.com/search/demo"},
4748
# {"title": "About Tipue", "text": "Tipue is a small web development/design
4849
# studio based in North London. We've been around for over a decade.", "tags": "",
49-
# "loc": "http://www.tipue.com/about"}
50+
# "url": "http://www.tipue.com/about"}
5051
# ]};
5152

5253

53-
class Tipue(LateTask):
54+
class TipueSearch(LateTask):
5455
"""Render the blog posts as JSON data."""
5556

5657
name = "local_search"
@@ -64,7 +65,7 @@ def gen_tasks(self):
6465
}
6566

6667
posts = self.site.timeline[:]
67-
dst_path = os.path.join(kw["output_folder"], "assets", "js",
68+
dst_json_path = os.path.join(kw["output_folder"], "assets", "js",
6869
"tipuesearch_content.json")
6970

7071
def save_data():
@@ -81,17 +82,17 @@ def save_data():
8182
data["title"] = post.title(lang)
8283
data["text"] = text
8384
data["tags"] = ",".join(post.tags)
84-
data["loc"] = post.permalink(lang)
85+
data["url"] = post.permalink(lang)
8586
pages.append(data)
8687
output = json.dumps({"pages": pages}, indent=2)
87-
makedirs(os.path.dirname(dst_path))
88-
with codecs.open(dst_path, "wb+", "utf8") as fd:
88+
makedirs(os.path.dirname(dst_json_path))
89+
with codecs.open(dst_json_path, "wb+", "utf8") as fd:
8990
fd.write(output)
9091

9192
yield {
9293
"basename": str(self.name),
93-
"name": dst_path,
94-
"targets": [dst_path],
94+
"name": dst_json_path,
95+
"targets": [dst_json_path],
9596
"actions": [(save_data, [])],
9697
'uptodate': [config_changed(kw), result_dep('sitemap')]
9798
}
@@ -104,3 +105,44 @@ def save_data():
104105
for task in copy_tree(asset_folder, kw["output_folder"]):
105106
task["basename"] = str(self.name)
106107
yield task
108+
109+
110+
# class TipueSearchHTML(LateTask):
111+
# """Render the blog posts as JSON data."""
112+
113+
# name = "local_search_html"
114+
115+
# def gen_tasks(self):
116+
# self.site.scan_posts()
117+
118+
# kw = {
119+
# "translations": self.site.config['TRANSLATIONS'],
120+
# "output_folder": self.site.config['OUTPUT_FOLDER'],
121+
# }
122+
123+
# FIXME: use a setting to define the path
124+
dst_html_path = os.path.join(kw["output_folder"], "search.html")
125+
126+
def create_html():
127+
context = copy(self.site.GLOBAL_CONTEXT)
128+
context.update({
129+
'lang': LocaleBorg().current_lang,
130+
'title': 'Search',
131+
'permalink': '/search.html',
132+
})
133+
134+
# from doit.tools import set_trace; set_trace()
135+
output = self.site.template_system.render_template(
136+
'search.tmpl', None, context
137+
)
138+
makedirs(os.path.dirname(dst_html_path))
139+
with codecs.open(dst_html_path, "wb+", "utf8") as fd:
140+
fd.write(output)
141+
142+
yield {
143+
"basename": str(self.name),
144+
"name": dst_html_path,
145+
"targets": [dst_html_path],
146+
"actions": [(create_html, [])],
147+
'uptodate': [config_changed(kw)]
148+
}
Binary file not shown.
Binary file not shown.

‎v7/localsearch/localsearch/files/assets/css/tipuesearch.css

-159
This file was deleted.

‎v7/localsearch/localsearch/files/assets/js/tipuesearch.js

-384
This file was deleted.

‎v7/localsearch/localsearch/files/assets/js/tipuesearch_set.js

-21
This file was deleted.

‎v7/localsearch/localsearch/files/tipue_search.html

-30
This file was deleted.
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## -*- coding: utf-8 -*-
2+
<%inherit file="base.tmpl"/>
3+
<%block name="extra_head">
4+
${parent.extra_head()}
5+
<link href="/assets/css/tipuesearch.css" rel="stylesheet" type="text/css">
6+
</%block>
7+
8+
<%block name="content">
9+
<div style="float: left;"><input type="text" id="tipue_search_input"></div>
10+
<div style="float: left; margin-left: 13px;"><input type="button" id="tipue_search_button"></div>
11+
<div id="tipue_search_content"><div id="tipue_search_loading"></div></div>
12+
</%block>
13+
14+
<%block name="extra_body_end">
15+
${parent.extra_body_end()}
16+
<script src="/assets/js/tipuesearch_set.js"></script>
17+
<script src="/assets/js/tipuesearch.js"></script>
18+
19+
<script type="text/javascript">
20+
$(document).ready(function() {
21+
$('#tipue_search_input').tipuesearch({
22+
'mode': 'json',
23+
'contentLocation': 'assets/js/tipuesearch_content.json',
24+
'showURL': false
25+
});
26+
});
27+
</script>
28+
</%block>

0 commit comments

Comments
 (0)
Please sign in to comment.