webgen-tipue_search-bundle 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/ChangeLog +3 -0
- data/LICENSE +20 -0
- data/LICENSE-TIPUESEARCH +20 -0
- data/README.md +123 -0
- data/VERSION +1 -0
- data/lib/webgen/bundle/tipue_search/data/javascripts/tipue_search/tipuesearch.min.js +12 -0
- data/lib/webgen/bundle/tipue_search/data/javascripts/tipue_search/tipuesearch_set.js +23 -0
- data/lib/webgen/bundle/tipue_search/data/stylesheets/tipue_search/img/expand.png +0 -0
- data/lib/webgen/bundle/tipue_search/data/stylesheets/tipue_search/img/link.png +0 -0
- data/lib/webgen/bundle/tipue_search/data/stylesheets/tipue_search/img/loader.gif +0 -0
- data/lib/webgen/bundle/tipue_search/data/stylesheets/tipue_search/img/search.gif +0 -0
- data/lib/webgen/bundle/tipue_search/data/stylesheets/tipue_search/metainfo +4 -0
- data/lib/webgen/bundle/tipue_search/data/stylesheets/tipue_search/tipuesearch.css +159 -0
- data/lib/webgen/bundle/tipue_search/data/templates/tipue_search.template +24 -0
- data/lib/webgen/bundle/tipue_search/info.yaml +73 -0
- data/lib/webgen/bundle/tipue_search/init.rb +19 -0
- data/lib/webgen/bundle/tipue_search/tipue_search_path_handler.rb +77 -0
- data/lib/webgen/bundle/tipue_search/tipue_search_tag.rb +37 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MDQyNWZhZGM2NDVhYjUyYjRkMjBjYzc3ZDMyMDlkMDhjOWNlZGRmNg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZTBkYjhmNTAwYWNkZGUxYzA1NzA5MWZmNGY5NTgxMDZiNjk3OWNlMw==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NDNkNWFiOWJhODkxMmRkYThmOGMwMTljNGJjM2E2MjM2MjllNWY1NzM3NDk4
|
10
|
+
YzhmY2IwYjRmMjFmNjkxNzRmZjZlNzIxNDRiNjRmNWQ1NzUwN2YyNGU0NDUx
|
11
|
+
OGRlYTkxOTkzMjNlYzY5OWE4MWEyOTY4M2RkOTk3NGI4MmM5MmQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NGE0N2ViZjgwYzI4M2Q3ODYwZjg2YjJlMmRjZGFjNWEyZWI4YjEyMGQ5NWIz
|
14
|
+
Y2FhNTA0MzQ5NmJiY2JiNWQ3NzgzY2QwMGVjODE4M2YxMDQ0OGNmZTRkNWQ2
|
15
|
+
Mzk5NzNkMGIwMjg1OWZkYzQxZDdkY2VhZmRmYjg3MDQwYmI4NjU=
|
data/ChangeLog
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Thomas Leitner
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
4
|
+
copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included
|
12
|
+
in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
15
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/LICENSE-TIPUESEARCH
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Tipue Search Copyright (c) 2012 Tipue
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
# Tipue Search integration for [webgen]
|
2
|
+
|
3
|
+
[Tipue Search] is a site search engine which uses jQuery. It provides
|
4
|
+
three modes of operation:
|
5
|
+
|
6
|
+
* live mode where one supplies a list of URLs which are then searched
|
7
|
+
(not very fast, needs a web server),
|
8
|
+
|
9
|
+
* json mode where the search data is loaded via an Ajax request (still
|
10
|
+
needs a web server) and
|
11
|
+
|
12
|
+
* static mode where the search data is loaded directly by the HTML file
|
13
|
+
(fast, no web server needed).
|
14
|
+
|
15
|
+
[Tipue Search]: http://www.tipue.com/search/
|
16
|
+
[webgen]: http://webgen.rubyforge.org
|
17
|
+
|
18
|
+
|
19
|
+
# Usage
|
20
|
+
|
21
|
+
## Provided Paths
|
22
|
+
|
23
|
+
This [webgen] extension bundle contains all needed Tipue Search files
|
24
|
+
except jQuery. Remember that one needs to load the jQuery library before
|
25
|
+
Tipue Search!
|
26
|
+
|
27
|
+
The Tipue Search files are provided as passive paths at the following
|
28
|
+
locations:
|
29
|
+
|
30
|
+
* `/javascriptss/tipue_search/tipuesearch.min.js` - the main Tipue
|
31
|
+
Search javascript file
|
32
|
+
|
33
|
+
* `/javascripts/tipue_search/tipuesearch_set.js` - defines stop and
|
34
|
+
replacement words as well as word stems
|
35
|
+
|
36
|
+
* `/stylesheets/tipue_search/tipuesearch.css` - the CSS file that includes the
|
37
|
+
necessary styles
|
38
|
+
|
39
|
+
* `/stylesheets/tipue_search/img/loader.gif`,
|
40
|
+
`/stylesheets/tipue_search/img/link.png`,
|
41
|
+
`/stylesheets/tipue_search/img/search.gif,
|
42
|
+
`/stylesheets/tipue_search/img/expand.png` - images needed by the CSS
|
43
|
+
file
|
44
|
+
|
45
|
+
Additionally, the following paths are provided:
|
46
|
+
|
47
|
+
* `/templates/tipue_search.template` - provides the blocks for rendering
|
48
|
+
the tag and the path handler contents
|
49
|
+
|
50
|
+
|
51
|
+
## Easy Usage
|
52
|
+
|
53
|
+
Tipue Search can easily be integrated into a webgen website by using the
|
54
|
+
included `tipue_search` tag:
|
55
|
+
|
56
|
+
{tipue_search: {path: data.js, options: {mode: static},
|
57
|
+
nodes: {alcn: /**/*.html}}}
|
58
|
+
|
59
|
+
The option `options` can be used to set any [Tipue Search
|
60
|
+
option][tipuset] and the option `nodes` specifies the nodes that should
|
61
|
+
appear in the search index (more information on this below).
|
62
|
+
|
63
|
+
If this tag occurs on a page, the needed nodes are automatically linked
|
64
|
+
to it and a new node representing the search index at the specified path
|
65
|
+
is created.
|
66
|
+
|
67
|
+
[tipueset]: http://www.tipue.com/search/docs/set/
|
68
|
+
|
69
|
+
|
70
|
+
## Manual Usage
|
71
|
+
|
72
|
+
It is also possible to craft the needed HTML fragments manually and just
|
73
|
+
use this extension for providing the necessary files. If you want to use
|
74
|
+
it this way, have a look at the [Tipue Search documentation][tipuedoc]
|
75
|
+
|
76
|
+
A search index node can be created by the path handler `tipue_search`
|
77
|
+
which uses paths in Webgen Page Format. Since no path extension is
|
78
|
+
registered for it, you need to explicitly specify the `handler` meta
|
79
|
+
information for a path that should be handled by the tipue_search
|
80
|
+
handler via a meta information path.
|
81
|
+
|
82
|
+
The following meta information on a tipue search node should be set:
|
83
|
+
|
84
|
+
* `entries` (mandatory): The node finder option set specifying the nodes
|
85
|
+
that should be used for the search index. It is assumed that the nodes
|
86
|
+
are valid HTML files.
|
87
|
+
|
88
|
+
* `mode` (mandatory): The Tipue Search mode (static, live or json).
|
89
|
+
|
90
|
+
* `content_css`: A CSS query for selecting the elements that contain the
|
91
|
+
text that should be indexed. Default is `body`.
|
92
|
+
|
93
|
+
The template which defines the content of a search index node can be
|
94
|
+
customized by adding a content block named 'tipue_search' to the path.
|
95
|
+
|
96
|
+
[tipuedoc]: http://www.tipue.com/search/docs/
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
# Installation
|
101
|
+
|
102
|
+
The easiest way to install this extension bundle is by installing the
|
103
|
+
corresponding Rubygem:
|
104
|
+
|
105
|
+
gem install webgen-tipue_search-bundle
|
106
|
+
|
107
|
+
If you don't use Rubygems, copy the folder
|
108
|
+
`lib/webgen/bundle/tipue_search` into your `ext` directory.
|
109
|
+
|
110
|
+
After that you just need to tell webgen to use this extension bundle by
|
111
|
+
adding the following line to your `ext/init.rb` file:
|
112
|
+
|
113
|
+
load("tipue_search")
|
114
|
+
|
115
|
+
|
116
|
+
# Copyright and license
|
117
|
+
|
118
|
+
Copyright (c) 2013 Thomas Leitner under the MIT License (see LICENSE)
|
119
|
+
|
120
|
+
* * *
|
121
|
+
|
122
|
+
The included Tipue Search files are also licensed under the MIT (see
|
123
|
+
LICENSE-TIPUESEARCH).
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
@@ -0,0 +1,12 @@
|
|
1
|
+
(function($){$.fn.tipuesearch=function(options){var set=$.extend({"show":7,"newWindow":false,"showURL":true,"minimumLength":3,"descriptiveWords":25,"highlightTerms":true,"highlightEveryTerm":false,"mode":"static","liveDescription":"*","liveContent":"*","contentLocation":"tipuesearch/tipuesearch_content.json"},options);return this.each(function(){var tipuesearch_in={pages:[]};$.ajaxSetup({async:false});if(set.mode=="live")for(var i=0;i<tipuesearch_pages.length;i++)$.get(tipuesearch_pages[i],"",function(html){var cont=
|
2
|
+
$(set.liveContent,html).text();cont=cont.replace(/\s+/g," ");var desc=$(set.liveDescription,html).text();desc=desc.replace(/\s+/g," ");var t_1=html.toLowerCase().indexOf("<title>");var t_2=html.toLowerCase().indexOf("</title>",t_1+7);if(t_1!=-1&&t_2!=-1)var tit=html.slice(t_1+7,t_2);else var tit="No title";tipuesearch_in.pages.push({"title":tit,"text":desc,"tags":cont,"loc":tipuesearch_pages[i]})});if(set.mode=="json")$.getJSON(set.contentLocation,function(json){tipuesearch_in=$.extend({},json)});
|
3
|
+
if(set.mode=="static")tipuesearch_in=$.extend({},tipuesearch);var tipue_search_w="";if(set.newWindow)tipue_search_w=' target="_blank"';function getURLP(name){return decodeURIComponent(((new RegExp("[?|&]"+name+"="+"([^&;]+?)(&|#|;|$)")).exec(location.search)||[,""])[1].replace(/\+/g,"%20"))||null}if(getURLP("q")){$("#tipue_search_input").val(getURLP("q"));getTipueSearch(0,true)}$("#tipue_search_button").click(function(){getTipueSearch(0,true)});$(this).keyup(function(event){if(event.keyCode=="13")getTipueSearch(0,
|
4
|
+
true)});function getTipueSearch(start,replace){$("#tipue_search_content").hide();var out="";var results="";var show_replace=false;var show_stop=false;var d=$("#tipue_search_input").val().toLowerCase();d=$.trim(d);var d_w=d.split(" ");d="";for(var i=0;i<d_w.length;i++){var a_w=true;for(var f=0;f<tipuesearch_stop_words.length;f++)if(d_w[i]==tipuesearch_stop_words[f]){a_w=false;show_stop=true}if(a_w)d=d+" "+d_w[i]}d=$.trim(d);d_w=d.split(" ");if(d.length>=set.minimumLength){if(replace){var d_r=d;for(var i=
|
5
|
+
0;i<d_w.length;i++)for(var f=0;f<tipuesearch_replace.words.length;f++)if(d_w[i]==tipuesearch_replace.words[f].word){d=d.replace(d_w[i],tipuesearch_replace.words[f].replace_with);show_replace=true}d_w=d.split(" ")}var d_t=d;for(var i=0;i<d_w.length;i++)for(var f=0;f<tipuesearch_stem.words.length;f++)if(d_w[i]==tipuesearch_stem.words[f].word)d_t=d_t+" "+tipuesearch_stem.words[f].stem;d_w=d_t.split(" ");var c=0;found=new Array;for(var i=0;i<tipuesearch_in.pages.length;i++){var score=1E9;var s_t=tipuesearch_in.pages[i].text;
|
6
|
+
for(var f=0;f<d_w.length;f++){var pat=new RegExp(d_w[f],"i");if(tipuesearch_in.pages[i].title.search(pat)!=-1)score-=2E5-i;if(tipuesearch_in.pages[i].text.search(pat)!=-1)score-=15E4-i;if(set.highlightTerms){if(set.highlightEveryTerm)var patr=new RegExp("("+d_w[f]+")","gi");else var patr=new RegExp("("+d_w[f]+")","i");s_t=s_t.replace(patr,"<b>$1</b>")}if(tipuesearch_in.pages[i].tags.search(pat)!=-1)score-=1E5-i}if(score<1E9)found[c++]=score+"^"+tipuesearch_in.pages[i].title+"^"+s_t+"^"+tipuesearch_in.pages[i].loc}if(c!=
|
7
|
+
0){if(show_replace==1){out+='<div id="tipue_search_warning_head">Showing results for '+d+"</div>";out+='<div id="tipue_search_warning">Search for <a href="javascript:void(0)" id="tipue_search_replaced">'+d_r+"</a></div>"}if(c==1)out+='<div id="tipue_search_results_count">1 result</div>';else{c_c=c.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",");out+='<div id="tipue_search_results_count">'+c_c+" results</div>"}found.sort();var l_o=0;for(var i=0;i<found.length;i++){var fo=found[i].split("^");if(l_o>=
|
8
|
+
start&&l_o<set.show+start){out+='<div class="tipue_search_content_title"><a href="'+fo[3]+'"'+tipue_search_w+">"+fo[1]+"</a></div>";var t=fo[2];var t_d="";var t_w=t.split(" ");if(t_w.length<set.descriptiveWords)t_d=t;else for(var f=0;f<set.descriptiveWords;f++)t_d+=t_w[f]+" ";t_d=$.trim(t_d);if(t_d.charAt(t_d.length-1)!=".")t_d+=" ...";out+='<div class="tipue_search_content_text">'+t_d+"</div>";if(set.showURL){t_url=fo[3];if(t_url.length>45)t_url=fo[3].substr(0,45)+" ...";out+='<div class="tipue_search_content_loc"><a href="'+
|
9
|
+
fo[3]+'"'+tipue_search_w+">"+t_url+"</a></div>"}}l_o++}if(c>set.show){var pages=Math.ceil(c/set.show);var page=start/set.show;out+='<div id="tipue_search_foot"><ul id="tipue_search_foot_boxes">';if(start>0)out+='<li><a href="javascript:void(0)" class="tipue_search_foot_box" id="'+(start-set.show)+"_"+replace+'">Prev</a></li>';if(page<=2){var p_b=pages;if(pages>3)p_b=3;for(var f=0;f<p_b;f++)if(f==page)out+='<li class="current">'+(f+1)+"</li>";else out+='<li><a href="javascript:void(0)" class="tipue_search_foot_box" id="'+
|
10
|
+
f*set.show+"_"+replace+'">'+(f+1)+"</a></li>"}else{var p_b=page+3;if(p_b>pages)p_b=pages;for(var f=page;f<p_b;f++)if(f==page)out+='<li class="current">'+(f+1)+"</li>";else out+='<li><a href="javascript:void(0)" class="tipue_search_foot_box" id="'+f*set.show+"_"+replace+'">'+(f+1)+"</a></li>"}if(page+1!=pages)out+='<li><a href="javascript:void(0)" class="tipue_search_foot_box" id="'+(start+set.show)+"_"+replace+'">Next</a></li>';out+="</ul></div>"}}else out+='<div id="tipue_search_warning_head">Nothing found</div>'}else if(show_stop)out+=
|
11
|
+
'<div id="tipue_search_warning_head">Nothing found</div><div id="tipue_search_warning">Common words are largely ignored</div>';else{out+='<div id="tipue_search_warning_head">Search too short</div>';if(set.minimumLength==1)out+='<div id="tipue_search_warning">Should be one character or more</div>';else out+='<div id="tipue_search_warning">Should be '+set.minimumLength+" characters or more</div>"}$("#tipue_search_content").html(out);$("#tipue_search_content").slideDown(200);$("#tipue_search_replaced").click(function(){getTipueSearch(0,
|
12
|
+
false)});$(".tipue_search_foot_box").click(function(){var id_v=$(this).attr("id");var id_a=id_v.split("_");getTipueSearch(parseInt(id_a[0]),id_a[1])})}})}})(jQuery);
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
Tipue Search 3.0.1
|
4
|
+
Copyright (c) 2013 Tipue
|
5
|
+
Tipue Search is released under the MIT License
|
6
|
+
http://www.tipue.com/search
|
7
|
+
*/
|
8
|
+
|
9
|
+
|
10
|
+
var tipuesearch_stop_words = ["and", "be", "by", "do", "for", "he", "how", "if", "is", "it", "my", "not", "of", "or", "the", "to", "up", "what", "when"];
|
11
|
+
|
12
|
+
var tipuesearch_replace = {"words": [
|
13
|
+
{"word": "tipua", replace_with: "tipue"},
|
14
|
+
{"word": "javscript", replace_with: "javascript"}
|
15
|
+
]};
|
16
|
+
|
17
|
+
var tipuesearch_stem = {"words": [
|
18
|
+
{"word": "e-mail", stem: "email"},
|
19
|
+
{"word": "javascript", stem: "script"},
|
20
|
+
{"word": "javascript", stem: "js"}
|
21
|
+
]};
|
22
|
+
|
23
|
+
|
@@ -0,0 +1,159 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
Tipue Search 3.0.1
|
4
|
+
Copyright (c) 2013 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: 12px/1.7 'open sans', sans-serif;
|
13
|
+
color: #333;
|
14
|
+
padding: 7px;
|
15
|
+
width: 150px;
|
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
|
+
}
|
24
|
+
#tipue_search_input:focus
|
25
|
+
{
|
26
|
+
border: 1px solid #ccc;
|
27
|
+
}
|
28
|
+
#tipue_search_button
|
29
|
+
{
|
30
|
+
width: 70px;
|
31
|
+
height: 36px;
|
32
|
+
border: 0;
|
33
|
+
border-radius: 1px;
|
34
|
+
background: #5193fb url('<%= context.tag("relocatable", "img/search.gif") %>') no-repeat center;
|
35
|
+
outline: none;
|
36
|
+
}
|
37
|
+
#tipue_search_button:hover
|
38
|
+
{
|
39
|
+
background-color: #4589fb;
|
40
|
+
}
|
41
|
+
|
42
|
+
#tipue_search_content
|
43
|
+
{
|
44
|
+
clear: left;
|
45
|
+
max-width: 650px;
|
46
|
+
padding: 25px 0 13px 0;
|
47
|
+
margin: 0;
|
48
|
+
}
|
49
|
+
#tipue_search_loading
|
50
|
+
{
|
51
|
+
padding-top: 60px;
|
52
|
+
background: #fff url('<%= context.tag("relocatable", "img/loader.gif") %>') no-repeat left;
|
53
|
+
}
|
54
|
+
|
55
|
+
#tipue_search_warning_head
|
56
|
+
{
|
57
|
+
font: 300 16px/1.6 'open sans', sans-serif;
|
58
|
+
color: #333;
|
59
|
+
}
|
60
|
+
#tipue_search_warning
|
61
|
+
{
|
62
|
+
font: 12px/1.6 'open sans', sans-serif;
|
63
|
+
color: #333;
|
64
|
+
margin: 7px 0;
|
65
|
+
}
|
66
|
+
#tipue_search_warning a
|
67
|
+
{
|
68
|
+
color: #3f72d8;
|
69
|
+
text-decoration: none;
|
70
|
+
}
|
71
|
+
#tipue_search_warning a:hover
|
72
|
+
{
|
73
|
+
padding-bottom: 1px;
|
74
|
+
border-bottom: 1px solid #ccc;
|
75
|
+
}
|
76
|
+
#tipue_search_results_count
|
77
|
+
{
|
78
|
+
font: 13px/1.6 'open sans', sans-serif;
|
79
|
+
color: #333;
|
80
|
+
}
|
81
|
+
.tipue_search_content_title
|
82
|
+
{
|
83
|
+
font: 300 23px/1.6 'open sans', sans-serif;
|
84
|
+
margin-top: 31px;
|
85
|
+
}
|
86
|
+
.tipue_search_content_title a
|
87
|
+
{
|
88
|
+
color: #3f72d8;
|
89
|
+
text-decoration: none;
|
90
|
+
}
|
91
|
+
.tipue_search_content_title a:hover
|
92
|
+
{
|
93
|
+
padding-bottom: 1px;
|
94
|
+
border-bottom: 1px solid #ccc;
|
95
|
+
}
|
96
|
+
.tipue_search_content_text
|
97
|
+
{
|
98
|
+
font: 12px/1.7 'open sans', sans-serif;
|
99
|
+
color: #333;
|
100
|
+
padding: 13px 0;
|
101
|
+
}
|
102
|
+
.tipue_search_content_loc
|
103
|
+
{
|
104
|
+
font: 300 13px/1.7 'open sans', sans-serif;
|
105
|
+
overflow: auto;
|
106
|
+
}
|
107
|
+
.tipue_search_content_loc a
|
108
|
+
{
|
109
|
+
color: #555;
|
110
|
+
text-decoration: none;
|
111
|
+
}
|
112
|
+
.tipue_search_content_loc a:hover
|
113
|
+
{
|
114
|
+
padding-bottom: 1px;
|
115
|
+
border-bottom: 1px solid #ccc;
|
116
|
+
}
|
117
|
+
#tipue_search_foot
|
118
|
+
{
|
119
|
+
margin: 51px 0 21px 0;
|
120
|
+
}
|
121
|
+
#tipue_search_foot_boxes
|
122
|
+
{
|
123
|
+
padding: 0;
|
124
|
+
margin: 0;
|
125
|
+
font: 12px/1 'open sans', sans-serif;
|
126
|
+
}
|
127
|
+
#tipue_search_foot_boxes li
|
128
|
+
{
|
129
|
+
list-style: none;
|
130
|
+
margin: 0;
|
131
|
+
padding: 0;
|
132
|
+
display: inline;
|
133
|
+
}
|
134
|
+
#tipue_search_foot_boxes li a
|
135
|
+
{
|
136
|
+
padding: 7px 13px 8px 13px;
|
137
|
+
background-color: #f1f1f1;
|
138
|
+
border: 1px solid #dcdcdc;
|
139
|
+
border-radius: 1px;
|
140
|
+
color: #333;
|
141
|
+
margin-right: 7px;
|
142
|
+
text-decoration: none;
|
143
|
+
text-align: center;
|
144
|
+
}
|
145
|
+
#tipue_search_foot_boxes li.current
|
146
|
+
{
|
147
|
+
padding: 7px 13px 8px 13px;
|
148
|
+
background: #fff;
|
149
|
+
border: 1px solid #dcdcdc;
|
150
|
+
border-radius: 1px;
|
151
|
+
color: #333;
|
152
|
+
margin-right: 7px;
|
153
|
+
text-align: center;
|
154
|
+
}
|
155
|
+
#tipue_search_foot_boxes li a:hover
|
156
|
+
{
|
157
|
+
border: 1px solid #ccc;
|
158
|
+
background-color: #f3f3f3;
|
159
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
--- name:tag.tipue_search pipeline:erb
|
2
|
+
<%
|
3
|
+
options = context[:config]['tag.tipue_search.options'].dup
|
4
|
+
options['contentLocation'] = context[:data_node].url if options['mode'] == 'json'
|
5
|
+
%>
|
6
|
+
<input type="text" placeholder="search" id="tipue_search_input" />
|
7
|
+
<input type="button" id="tipue_search_button" />
|
8
|
+
<div id="tipue_search_content"></div>
|
9
|
+
<script>
|
10
|
+
$(document).ready(function() {
|
11
|
+
$('#tipue_search_input').tipuesearch(<%= JSON.dump(options) %>);
|
12
|
+
});
|
13
|
+
</script>
|
14
|
+
--- name:tipue_search pipeline:ruby
|
15
|
+
if context.node['mode'] == 'live'
|
16
|
+
context.content = "var tipuesearch_pages = #{JSON.dump(context.node.entries.map {|e| e.url})}"
|
17
|
+
else
|
18
|
+
data = []
|
19
|
+
context.node.entries.each do |node|
|
20
|
+
data << {'loc' => node.url, 'title' => node['title'], 'tags' => '', 'text' => context.node.text_for(node)}
|
21
|
+
end
|
22
|
+
|
23
|
+
context.content = "var tipuesearch = {\"pages\": #{JSON.dump(data)}};"
|
24
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
author: &author Thomas Leitner <t_leitner@gmx.at>
|
2
|
+
summary: webgen extension bundle for Tipue Search javascript site search engine
|
3
|
+
description: |
|
4
|
+
Tipue Search is a site search engine which uses jQuery. It can use a
|
5
|
+
pre-built search index to provide a fast search experience for a
|
6
|
+
static website.
|
7
|
+
version: 1.0.0
|
8
|
+
license: MIT
|
9
|
+
homepage: http://github.com/gettalong/webgen-tipue_search-bundle
|
10
|
+
|
11
|
+
extensions:
|
12
|
+
path_handler.tipue_search:
|
13
|
+
author: *author
|
14
|
+
summary: |
|
15
|
+
Creates a search index data file for the Tipue Search site search
|
16
|
+
engine
|
17
|
+
|
18
|
+
tag.tipue_search:
|
19
|
+
author: *author
|
20
|
+
summary: |
|
21
|
+
Creates a site search field and result area for displaying search
|
22
|
+
results
|
23
|
+
|
24
|
+
options:
|
25
|
+
tag.tipue_search.path:
|
26
|
+
summary: |
|
27
|
+
The source path that should be used for creating the Tipue Search
|
28
|
+
data file. The destination path is derived from this path the
|
29
|
+
usual way. Don't use a path that does already exist!
|
30
|
+
syntax: |
|
31
|
+
`PATH` where `PATH` is a relative or absolute source path
|
32
|
+
example:
|
33
|
+
tag: |
|
34
|
+
{tipue_search: {path: data.js, options: {mode: static}, entries: {alcn: /**/*.html}}}
|
35
|
+
|
36
|
+
tag.tipue_search.options:
|
37
|
+
summary: |
|
38
|
+
Options passed to the Tipue Search engine (and partially to
|
39
|
+
path_handler.tipue_search). The keys 'mode' and 'liveDescription'
|
40
|
+
are mapped to the meta information keys 'mode' and 'content_css'
|
41
|
+
for path_handler.tipue_search.
|
42
|
+
syntax: |
|
43
|
+
`{KEY: VALUE, ...}` where `KEY` and `VALUE` are key-value pairs of
|
44
|
+
Tipue Search options
|
45
|
+
example:
|
46
|
+
config: |
|
47
|
+
tag.tipue_search.options: {}
|
48
|
+
tag: |
|
49
|
+
{tipue_search: {path: data.js, options: {mode: static}, entries: {alcn: /**/*.html}}}
|
50
|
+
|
51
|
+
tag.tipue_search.entries:
|
52
|
+
summary: |
|
53
|
+
Node finder option set defining the search index. The nodes of the
|
54
|
+
result set may only contain valid HTML content.
|
55
|
+
syntax: |
|
56
|
+
`OPTIONS` where `OPTIONS` is a hash with node finder options
|
57
|
+
example:
|
58
|
+
tag: |
|
59
|
+
{tipue_search: {path: data.js, options: {mode: static}, entries: {alcn: /**/*.html}}}
|
60
|
+
|
61
|
+
tag.tipue_search.template:
|
62
|
+
summary: |
|
63
|
+
The template node used for rendering the tag. It has to contain the block
|
64
|
+
'tag.tipue_search' because this block is used for rendering.
|
65
|
+
syntax: |
|
66
|
+
`PATH` where `PATH` is the (a)(l)cn of the template node
|
67
|
+
example:
|
68
|
+
config: |
|
69
|
+
tag.tipue_search.template: /other.template
|
70
|
+
tag: |
|
71
|
+
{tipue_search: {path: data.js, options: {mode: static},
|
72
|
+
entries: {alcn: /**/*.html}, template: /my.template}}
|
73
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Extension bundle initialization
|
2
|
+
|
3
|
+
mount_passive('data/', '/')
|
4
|
+
|
5
|
+
require_relative('tipue_search_tag')
|
6
|
+
require_relative('tipue_search_path_handler')
|
7
|
+
|
8
|
+
is_hash = lambda do |val|
|
9
|
+
raise "The value has to be a hash" unless val.kind_of?(Hash)
|
10
|
+
val
|
11
|
+
end
|
12
|
+
|
13
|
+
website.ext.tag.register('Webgen::Tag::TipueSearch', :mandatory => ['path', 'entries'])
|
14
|
+
option('tag.tipue_search.path', '')
|
15
|
+
option('tag.tipue_search.options', {'mode' => 'static'}, &is_hash)
|
16
|
+
option('tag.tipue_search.entries', nil, &is_hash)
|
17
|
+
option('tag.tipue_search.template', '/templates/tipue_search.template')
|
18
|
+
|
19
|
+
website.ext.path_handler.register('Webgen::PathHandler::TipueSearch')
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'nokogiri'
|
5
|
+
require 'webgen/path_handler/base'
|
6
|
+
require 'webgen/path_handler/page_utils'
|
7
|
+
require 'webgen/context'
|
8
|
+
|
9
|
+
module Webgen
|
10
|
+
class PathHandler
|
11
|
+
|
12
|
+
# Path handler for creating a Tipue Search site index.
|
13
|
+
class TipueSearch
|
14
|
+
|
15
|
+
include Base
|
16
|
+
include PageUtils
|
17
|
+
|
18
|
+
|
19
|
+
# Provides custom methods for tipue search nodes.
|
20
|
+
class Node < PageUtils::Node
|
21
|
+
|
22
|
+
# Return the entries for the tipue search +node+.
|
23
|
+
def entries
|
24
|
+
tree.website.ext.node_finder.find(node_info[:entries], self)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Return the text content of the given node.
|
28
|
+
def text_for(node)
|
29
|
+
if tree.website.ext.destination.exists?(node.dest_path)
|
30
|
+
Nokogiri::HTML(tree.website.ext.destination.read(node.dest_path)).
|
31
|
+
css(self['content_css'] || 'body').text.gsub(/\s+/, ' ')
|
32
|
+
else
|
33
|
+
''
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
# The mandatory keys that need to be set in a tipue search file.
|
41
|
+
MANDATORY_INFOS = %W[mode entries]
|
42
|
+
|
43
|
+
# Create a Tipue Search site index from +path+.
|
44
|
+
def create_nodes(path, blocks)
|
45
|
+
if MANDATORY_INFOS.any? {|t| path.meta_info[t].nil?}
|
46
|
+
raise Webgen::NodeCreationError.new("At least one of #{MANDATORY_INFOS.join('/')} is missing",
|
47
|
+
"path_handler.tipue_search", path)
|
48
|
+
end
|
49
|
+
|
50
|
+
if @website.config['website.base_url'].empty?
|
51
|
+
raise Webgen::NodeCreationError.new("The configuration option 'website.base_url' needs to be set",
|
52
|
+
"path_handler.tipue_search", path)
|
53
|
+
end
|
54
|
+
|
55
|
+
path.ext = 'js'
|
56
|
+
path['node_class'] = Node.to_s
|
57
|
+
path['write_order'] = 'z'
|
58
|
+
create_node(path) do |node|
|
59
|
+
set_blocks(node, blocks)
|
60
|
+
node.node_info[:entries] = {:flatten => true, :and => node['entries']}
|
61
|
+
@website.ext.item_tracker.add(node, :nodes, :node_finder_option_set,
|
62
|
+
{:opts => node.node_info[:entries], :ref_alcn => node.alcn}, :content)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Return the rendered feed represented by +node+.
|
67
|
+
def content(node)
|
68
|
+
context = Webgen::Context.new(@website)
|
69
|
+
context.render_block(:name => "tipue_search", :node => 'first',
|
70
|
+
:chain => [node, node.resolve("/templates/tipue_search.template", node.lang, true),
|
71
|
+
node].compact)
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'webgen/tag'
|
5
|
+
|
6
|
+
module Webgen
|
7
|
+
class Tag
|
8
|
+
|
9
|
+
# Generates the Tipue Search HTML fragments (input box, result area) and links the necessary
|
10
|
+
# nodes to the destination node.
|
11
|
+
module TipueSearch
|
12
|
+
|
13
|
+
# Generate the menu.
|
14
|
+
def self.call(tag, body, context)
|
15
|
+
path = Webgen::Path.append(context.ref_node.parent.alcn, context[:config]['tag.tipue_search.path'])
|
16
|
+
path = Webgen::Path.new(path)
|
17
|
+
|
18
|
+
path.meta_info['mode'] = context[:config]['tag.tipue_search.options']['mode'] || 'static'
|
19
|
+
path.meta_info['content_css'] = context[:config]['tag.tipue_search.options']['liveDescription'] || 'body'
|
20
|
+
path.meta_info['entries'] = context[:config]['tag.tipue_search.entries']
|
21
|
+
path.meta_info['handler'] = 'tipue_search'
|
22
|
+
|
23
|
+
node = context.website.ext.path_handler.create_secondary_nodes(path, '', context.ref_node.alcn).first
|
24
|
+
|
25
|
+
context.html_head.link_file(:css, '/stylesheets/tipue_search/tipuesearch.css')
|
26
|
+
context.html_head.link_file(:js, '/javascripts/tipue_search/tipuesearch_set.js')
|
27
|
+
context.html_head.link_file(:js, node.alcn) unless path.meta_info['mode'] == 'json'
|
28
|
+
context.html_head.link_file(:js, '/javascripts/tipue_search/tipuesearch.min.js')
|
29
|
+
|
30
|
+
context[:data_node] = node
|
31
|
+
Webgen::Tag.render_tag_template(context, "tipue_search")
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: webgen-tipue_search-bundle
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Thomas Leitner
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: ! 'Tipue Search is a site search engine which uses jQuery. It can use
|
28
|
+
a
|
29
|
+
|
30
|
+
pre-built search index to provide a fast search experience for a
|
31
|
+
|
32
|
+
static website.
|
33
|
+
|
34
|
+
'
|
35
|
+
email:
|
36
|
+
- t_leitner@gmx.at
|
37
|
+
executables: []
|
38
|
+
extensions: []
|
39
|
+
extra_rdoc_files: []
|
40
|
+
files:
|
41
|
+
- lib/webgen/bundle/tipue_search/data/javascripts/tipue_search/tipuesearch.min.js
|
42
|
+
- lib/webgen/bundle/tipue_search/data/javascripts/tipue_search/tipuesearch_set.js
|
43
|
+
- lib/webgen/bundle/tipue_search/data/stylesheets/tipue_search/img/expand.png
|
44
|
+
- lib/webgen/bundle/tipue_search/data/stylesheets/tipue_search/img/link.png
|
45
|
+
- lib/webgen/bundle/tipue_search/data/stylesheets/tipue_search/img/loader.gif
|
46
|
+
- lib/webgen/bundle/tipue_search/data/stylesheets/tipue_search/img/search.gif
|
47
|
+
- lib/webgen/bundle/tipue_search/data/stylesheets/tipue_search/metainfo
|
48
|
+
- lib/webgen/bundle/tipue_search/data/stylesheets/tipue_search/tipuesearch.css
|
49
|
+
- lib/webgen/bundle/tipue_search/data/templates/tipue_search.template
|
50
|
+
- lib/webgen/bundle/tipue_search/info.yaml
|
51
|
+
- lib/webgen/bundle/tipue_search/init.rb
|
52
|
+
- lib/webgen/bundle/tipue_search/tipue_search_path_handler.rb
|
53
|
+
- lib/webgen/bundle/tipue_search/tipue_search_tag.rb
|
54
|
+
- README.md
|
55
|
+
- ChangeLog
|
56
|
+
- LICENSE
|
57
|
+
- LICENSE-TIPUESEARCH
|
58
|
+
- VERSION
|
59
|
+
homepage: http://github.com/gettalong/webgen-tipue_search-bundle
|
60
|
+
licenses:
|
61
|
+
- MIT
|
62
|
+
metadata: {}
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.0.0
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: webgen extension bundle for Tipue Search javascript site search engine
|
83
|
+
test_files: []
|