freefind_rails 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 06bff47b8e75c63704693cca30f2e7284696a88d
4
+ data.tar.gz: a4f61e7e3f7c2a762b996902f94216fcf0cb7f6a
5
+ SHA512:
6
+ metadata.gz: 5fca0ac5905fa0dbc8c48cf4fcf60d29a00d25f907bfff2add98b6afe5ba42edb0b65b8123649da657dbf3e42400a3678a485344587b4ddc671fb32b02a5ce0b
7
+ data.tar.gz: 87b62df8f958a1013461e45eb86820ab02516e30d07cc6ec826ad28cfcbe5d9fd8db354df482fbb537c97cfca0772bb4a62b80f9bded186f0c689bd3c547a1a8
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in freefind_rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Ben Liu
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # Freefind Rails
2
+
3
+ Easy way to use freefind.com search service in your Rails app. You need to create an account at freefind.com first.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'freefind_rails'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install freefind_rails
20
+
21
+ Include the javascript into the asset pipeline:
22
+ /app/assets/javascripts/application.js
23
+
24
+ //= require freefind
25
+
26
+ ## Usage
27
+
28
+ Add the _freefind_search.html.haml view partial where you want the search input box to appear
29
+
30
+ = render partial: '/freefind_search', locals: { freefind_site_id: your-id }
31
+
32
+ Make sure to pass your freefind site id into the partial as a local variable. This can be done in the parent application by hardcoding it directly or by using a Rails configuration file.
33
+
34
+ Add the _freefind_onpage_results.html.haml view partial to the same page if you want search results to populate into that same page instead of in a new page.
35
+
36
+ = render partial: '/freefind_onpage_results'
37
+
38
+ ## Contributing
39
+
40
+ 1. Fork it ( https://github.com/[my-github-username]/freefind_rails/fork )
41
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
42
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
43
+ 4. Push to the branch (`git push origin my-new-feature`)
44
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,11 @@
1
+ #ffresult_win{ style: "z-index:1; padding: 20px 0 16px 0; margin:0px; width:538px; height:728px; border:none; display:none; position:absolute; top:0px; left:0px;" }
2
+ #ffresult_bar{ onmousedown: "ffresults.drag(event,false)", style: "cursor: move; z-index:5; position:absolute; top:0px; left:0px; background-color:maroon; padding:0; text-align: right; width:100%; height:20px; display:block; border:solid; border-width: 1px; border-bottom: 0px; border-color:maroon;" }
3
+ %a#ffrclose{ style: "z-index:6; font-family: arial, verdana, sans-serif; font-size:8pt; color:white;", href: "javascript:ffresults.hide()" } Close window [X]
4
+
5
+ #ffresult_2{ style: "z-index:7; position: relative; height: 100%; background-color:white; display:block;" }
6
+ #ffresult_cvr{ style: "z-index:0; position:absolute; top:0px; left:0px; display:block; width:100%; height:100%;" }
7
+ %iframe#ffresult_ifr{ name: "ffresult_frame", style: "z-index:1; position:absolute; top:0px; left:0px; border:solid; border-width: 0px 1px 0px 1px; border-color:gray;", src: "", width: "100%", height: "100%", scrolling: "auto", frameborder: "0" }
8
+
9
+ #ffresult_btm{ style: "position:absolute; bottom:-1; left:0px; border:solid; border-color:gray; border-width: 1px; border-top: 0px; display: block; z-index:18; background-color:#d0d0d0; width:100%; height:16px;" }
10
+ #ffresult_sbx{ onmousedown: "ffresults.drag(event,true);", style: "cursor: se-resize; float:right; border:none; border-color:gray; border-width: 0px; width:16px; height:16px;" }
11
+ %img#ffresult_szimg{ height: 16, width: 16, border: 0, src: '' alt: '' }
@@ -0,0 +1,22 @@
1
+ %table{ cellpadding: 0, cellspacing: 0, border: 0 }
2
+ %tr
3
+ %td{ style: "font-family: Arial, Helvetica, sans-serif; font-size: 7.5pt;" }
4
+ %center
5
+ %table{ width: "90%", cellpadding: 0, cellspacing: 0, border: 0 }
6
+ %tr{ style: "font-family: Arial, Helvetica, sans-serif; font-size: 7.5pt;" }
7
+ %td{ style: "font-family: Arial, Helvetica, sans-serif; font-size: 7.5pt;", align: 'left' }
8
+ %a#ffresult_idx1{ onclick: "ffresults.show(1);", href: "http://search.freefind.com/siteindex.html?si=71497153&sbv=j1" } index
9
+ %td{ style: "font-family: Arial, Helvetica, sans-serif; font-size: 7.5pt;", align: 'center' }
10
+ %a#ffresult_smp1{ onclick: "ffresults.show(1);", href: "http://search.freefind.com/find.html?si=71497153&m=0&p=0&sbv=j1" } sitemap
11
+ %td{ style: "font-family: Arial, Helvetica, sans-serif; font-size: 7.5pt;", align: 'right' }
12
+ %a#ffresult_adv1{ onclick: "ffresults.show(1);", href: "http://search.freefind.com/find.html?si=71497153&pid=a&sbv=j1" } advanced
13
+
14
+ %form#ffresult_sbox1{ style: "margin:0px; margin-top:4px;", action: "http://search.freefind.com/find.html", method: :get, accept_charset: "utf-8", onsubmit: "ffresults.show(1);" }
15
+ %input{ type: "hidden", name: "si", value: freefind_site_id }
16
+ %input{ type: "hidden", name: "pid", value: "r" }
17
+ %input{ type: "hidden", name: "n", value: "0" }
18
+ %input{ type: "hidden", name: "_charset_", value: "" }
19
+ %input{ type: "hidden", name: "bcd", value: "÷" }
20
+ %input{ type: "hidden", name: "sbv", value: "j1" }
21
+ %input{ type: "text", name: "query", size: "15" }
22
+ %input{ type: "submit", value: "search" }
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'freefind_rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "freefind_rails"
8
+ spec.version = FreefindRails::VERSION
9
+ spec.authors = ["Ben Liu"]
10
+ spec.email = ["ben@gelatincube.com"]
11
+ spec.summary = %q{A gem to integrate freefind.com search into a Rails application.}
12
+ spec.description = %q{A gem to integrate freefind.com search service into a Rails application.}
13
+ spec.homepage = "https://github.com/blzabub/freefind_rails"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "rails", "~> 4.0"
22
+ spec.add_dependency "haml", "~> 4.0"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
@@ -0,0 +1,6 @@
1
+ require "freefind_rails/version"
2
+
3
+ module FreefindRails
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module FreefindRails
2
+ VERSION = "0.1.2"
3
+ end
@@ -0,0 +1,279 @@
1
+ var ffresults = {
2
+
3
+ // copyright 2008 - 2014 FreeFind.com - authorized for use with the FreeFind service only
4
+
5
+ // Start of config settings
6
+
7
+ autoPos : true, // automatic initial window position / size.
8
+
9
+ // if autoPos if false, the following four numbers are used as initial window position and size
10
+
11
+ initialX : 78, // left position (pixels)
12
+ initialY : 66, // right position (pixels)
13
+ initialH : 395, // height of window
14
+ initialW : 622, // width of window
15
+
16
+ // choose a number for z-index that is high enough so the results window appears above other windows on your page
17
+
18
+ initialZ : 10000000, // initial z-index of the results window
19
+
20
+ // the following value controls the color of the window's drag bar (top area of window)
21
+
22
+ barColor : 'navy',
23
+
24
+ // end of config settings
25
+
26
+ element : undefined,
27
+ cover : undefined,
28
+ mouseDownX : 0,
29
+ mouseDownY : 0,
30
+ objectX : 0,
31
+ objectY : 0,
32
+ objectH : 0,
33
+ objectW : 0,
34
+ ipos : false,
35
+ resize : false,
36
+
37
+ sizeImageUrl : 'http://search.freefind.com/img/rsize.gif',
38
+
39
+ selectFunc : undefined,
40
+ selectState : undefined,
41
+ mozSelect : undefined,
42
+
43
+ noSelect : function()
44
+ {
45
+ var obj = document.body;
46
+
47
+ ffresults.selectFunc = obj.onselectstart;
48
+ ffresults.selectState = obj.unselectable;
49
+ ffresults.mozSelect = obj.style.MozUserSelect;
50
+
51
+ obj.onselectstart = function(){ return false; };
52
+ obj.unselectable = 'on';
53
+ obj.style.MozUserSelect = 'none';
54
+ },
55
+
56
+ restoreSelect : function()
57
+ {
58
+ var obj = document.body;
59
+
60
+ obj.onselectstart = ffresults.selectFunc;
61
+ obj.unselectable = ffresults.selectState;
62
+ obj.style.MozUserSelect = ffresults.mozSelect;
63
+ },
64
+
65
+
66
+ drag : function (e,size)
67
+ {
68
+ if(!document.getElementById) return;
69
+
70
+ if(!e) e = window.event;
71
+ var targ = e.target || e.srcElement;
72
+ ffresults.resize = size;
73
+
74
+ if(targ.id != 'ffresult_bar' && targ.id != 'ffresult_szimg') return true;
75
+ ffresults.noSelect();
76
+
77
+ ffresults.element = document.getElementById('ffresult_win');
78
+ ffresults.objectX = parseInt(ffresults.element.style.left,10);
79
+ ffresults.objectY = parseInt(ffresults.element.style.top,10);
80
+ ffresults.objectH = parseInt(ffresults.element.style.height,10);
81
+ ffresults.objectW = parseInt(ffresults.element.style.width,10);
82
+
83
+ ffresults.cover = document.getElementById('ffresult_cvr');
84
+ ffresults.cover.style.zIndex = '40';
85
+ ffresults.mouseDownX = e.clientX;
86
+ ffresults.mouseDownY = e.clientY;
87
+ if(e.preventDefault) e.preventDefault();
88
+ e.returnValue = false;
89
+ e.cancelBubble = true;
90
+ ffresults.attach(document,"mouseup",ffresults.drop);
91
+ ffresults.attach(document,"mousemove",ffresults.move);
92
+ },
93
+
94
+
95
+
96
+
97
+ attach : function(to,eventname,func)
98
+ {
99
+ if(to.addEventListener)
100
+ to.addEventListener(eventname,func,false);
101
+ else
102
+ to.attachEvent("on" + eventname,func);
103
+ },
104
+
105
+ detach : function(to,eventname,func)
106
+ {
107
+ if(to.removeEventListener)
108
+ to.removeEventListener(eventname,func,false);
109
+ else
110
+ to.detachEvent("on" + eventname,func);
111
+ },
112
+
113
+ drop : function(e)
114
+ {
115
+ ffresults.detach(document,"mouseup",ffresults.drop);
116
+ ffresults.detach(document,"mousemove",ffresults.move);
117
+ ffresults.cover.style.zIndex = 0;
118
+ ffresults.element = null;
119
+ ffresults.restoreSelect();
120
+ },
121
+
122
+ move: function(e)
123
+ {
124
+ if(!e) e = window.event;
125
+
126
+ e.returnValue = false;
127
+ e.cancelBubble = true;
128
+ if(e.preventDefault) e.preventDefault();
129
+
130
+ var x = e.clientX;
131
+ var y = e.clientY;
132
+
133
+ if(ffresults.resize)
134
+ {
135
+ var winW = ffresults.objectW + x - ffresults.mouseDownX;
136
+ var winH = ffresults.objectH + y - ffresults.mouseDownY;
137
+
138
+ if(winH < 128) winH = 128;
139
+ if(winW < 128) winW = 128;
140
+
141
+ ffresults.element.style.width = winW + "px";
142
+ ffresults.element.style.height = winH + "px";
143
+ }
144
+ else
145
+ {
146
+ var left = ffresults.objectX + x - ffresults.mouseDownX;
147
+ var top = ffresults.objectY + y - ffresults.mouseDownY;
148
+
149
+ ffresults.element.style.left = left + "px";
150
+ ffresults.element.style.top = top + "px";
151
+ }
152
+
153
+
154
+ },
155
+
156
+ hide : function()
157
+ {
158
+ var rStyle = document.getElementById('ffresult_win').style;
159
+ rStyle.display = "none";
160
+ rStyle.zIndex = 0;
161
+ var ifr = document.getElementById('ffresult_ifr');
162
+ if(ifr) ifr.src="";
163
+ var szImg = document.getElementById('ffresult_szimg');
164
+ if(szImg) szImg.src = "";
165
+
166
+ },
167
+
168
+
169
+ show : function(num)
170
+ {
171
+ if(!document.getElementById) return;
172
+
173
+ var searchForm = document.getElementById('ffresult_sbox'+num);
174
+ var idxLink = document.getElementById('ffresult_idx'+num);
175
+ var smpLink = document.getElementById('ffresult_smp'+num);
176
+ var advLink = document.getElementById('ffresult_adv'+num);
177
+
178
+ if(searchForm) searchForm.target = 'ffresult_frame';
179
+ if(idxLink) idxLink.target = 'ffresult_frame';
180
+ if(smpLink) smpLink.target = 'ffresult_frame';
181
+ if(advLink) advLink.target = 'ffresult_frame';
182
+
183
+ var rDiv = document.getElementById('ffresult_win');
184
+
185
+ if(!ffresults.ipos)
186
+ {
187
+ if(ffresults.autoPos)
188
+ {
189
+ ffresults.computePos(rDiv);
190
+ }
191
+ else
192
+ {
193
+ rDiv.style.top = ffresults.initialY + 'px';
194
+ rDiv.style.left = ffresults.initialX + 'px';
195
+ rDiv.style.width = ffresults.initialW + 'px';
196
+ rDiv.style.height = (ffresults.initialH - 36) + 'px';
197
+ }
198
+ ffresults.ipos = true;
199
+ }
200
+
201
+ var szImg = document.getElementById('ffresult_szimg');
202
+ if(szImg) szImg.src = ffresults.sizeImageUrl;
203
+
204
+ var dragBar = document.getElementById('ffresult_bar');
205
+ if(dragBar)
206
+ {
207
+ dragBar.style.backgroundColor = ffresults.barColor;
208
+ dragBar.style.borderColor = ffresults.barColor;
209
+ }
210
+
211
+ rDiv.style.zIndex = ffresults.initialZ;
212
+ rDiv.style.display = "block";
213
+ },
214
+
215
+
216
+
217
+ computePos : function(rDiv)
218
+ {
219
+
220
+ var view = ffresults.viewSize();
221
+ var w = parseInt(view.width * 0.75,10);
222
+ var h = parseInt(view.height * 0.75,10);
223
+ if(w < 220) w = 220;
224
+ if(h < 220) h = 220;
225
+
226
+
227
+ var left = parseInt((view.width - w ) / 2,10);
228
+ var top = parseInt((view.height - (h + 36)) / 2,10);
229
+
230
+
231
+ if(left < 0) left = 0;
232
+ if(top < 0) top = 0;
233
+
234
+ rDiv.style.top = (top + view.scrollY) + 'px';
235
+ rDiv.style.left = (left + view.scrollX) + 'px';
236
+ rDiv.style.width = w + 'px';
237
+ rDiv.style.height = h + 'px';
238
+
239
+ },
240
+
241
+ viewSize : function()
242
+ {
243
+ var w = 0;
244
+ var h = 0;
245
+ var sx = 0;
246
+ var sy = 0;
247
+
248
+ if(window.innerWidth)
249
+ { // non-ie
250
+ w = window.innerWidth;
251
+ h = window.innerHeight;
252
+ sx = window.pageXOffset;
253
+ sy = window.pageYOffset;
254
+ }
255
+ else
256
+ {
257
+ var elem;
258
+ if(document.documentElement && document.documentElement.clientWidth != 0)
259
+ { // ie strict
260
+ elem = document.documentElement;
261
+ }
262
+ else
263
+ { // ie quirks
264
+ elem = document.body;
265
+ }
266
+ w = elem.clientWidth;
267
+ h = elem.clientHeight;
268
+ sx = elem.scrollLeft;
269
+ sy = elem.scrollTop;
270
+
271
+ }
272
+
273
+
274
+ return {width: w,height: h, scrollX: sx, scrollY: sy};
275
+
276
+ }
277
+
278
+
279
+ };
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: freefind_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Ben Liu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: haml
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description: A gem to integrate freefind.com search service into a Rails application.
70
+ email:
71
+ - ben@gelatincube.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - app/views/_freefind_onpage_results.html.haml
82
+ - app/views/_freefind_search.html.haml
83
+ - freefind_rails.gemspec
84
+ - lib/freefind_rails.rb
85
+ - lib/freefind_rails/version.rb
86
+ - vendor/assets/javascripts/freefind.js
87
+ homepage: https://github.com/blzabub/freefind_rails
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.4.5
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: A gem to integrate freefind.com search into a Rails application.
111
+ test_files: []