picky-generators 4.12.5 → 4.12.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (22) hide show
  1. data/lib/picky-generators/generators/all_in_one/sinatra.rb +2 -2
  2. data/lib/picky-generators/generators/server/sinatra.rb +2 -2
  3. data/prototypes/{all_in_one/sinatra → shared/client}/images/picky.png +0 -0
  4. data/prototypes/shared/client/javascripts/application.js +75 -0
  5. data/prototypes/{all_in_one/sinatra → shared/client}/javascripts/history.min.js +0 -0
  6. data/prototypes/{all_in_one/sinatra → shared/client}/javascripts/jquery-1.5.0.min.js +0 -0
  7. data/prototypes/{client/sinatra → shared/client}/javascripts/picky.min.js +0 -0
  8. data/prototypes/{all_in_one/sinatra → shared/client}/stylesheets/application.css +0 -0
  9. data/prototypes/{all_in_one/sinatra → shared/client}/stylesheets/images/background.png +0 -0
  10. data/prototypes/{all_in_one/sinatra → shared/client}/stylesheets/images/cancel.svg +0 -0
  11. data/prototypes/{all_in_one/sinatra → shared/client}/stylesheets/picky.css +0 -0
  12. data/prototypes/{all_in_one/sinatra → shared/client}/views/search.haml +7 -80
  13. metadata +16 -24
  14. data/prototypes/all_in_one/sinatra/javascripts/picky.min.js +0 -19
  15. data/prototypes/client/sinatra/images/picky.png +0 -0
  16. data/prototypes/client/sinatra/javascripts/history.min.js +0 -2
  17. data/prototypes/client/sinatra/javascripts/jquery-1.5.0.min.js +0 -16
  18. data/prototypes/client/sinatra/stylesheets/application.css +0 -86
  19. data/prototypes/client/sinatra/stylesheets/images/background.png +0 -0
  20. data/prototypes/client/sinatra/stylesheets/images/cancel.svg +0 -10
  21. data/prototypes/client/sinatra/stylesheets/picky.css +0 -277
  22. data/prototypes/client/sinatra/views/search.haml +0 -311
@@ -1,10 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 15.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="32px" height="64px" viewBox="0 0 32 64" enable-background="new 0 0 32 64" xml:space="preserve">
6
- <path fill="#C0C0C8" d="M16,2C8.268,2,2,8.268,2,16s6.268,14,14,14s14-6.268,14-14S23.732,2,16,2z M24.5,21.5l-3,3L16,19l-5.5,5.5
7
- l-3-3L13,16l-5.5-5.5l3-3L16,13l5.5-5.5l3,3L19,16L24.5,21.5z"/>
8
- <path fill="#A0A0A8" d="M16,34C8.268,34,2,40.268,2,48s6.268,14,14,14s14-6.268,14-14S23.732,34,16,34z M24.5,53.5l-3,3L16,51
9
- l-5.5,5.5l-3-3L13,48l-5.5-5.5l3-3L16,45l5.5-5.5l3,3L19,48L24.5,53.5z"/>
10
- </svg>
@@ -1,277 +0,0 @@
1
- /* Form */
2
- form
3
- {
4
- display: block;
5
- position: relative;
6
- height: 46px;
7
- background: -webkit-gradient(linear, left top, left bottom, from(rgba(0,0,0,0)), to(rgba(0,0,0,0.08))), rgba(255,255,255,0.4);
8
- background: -moz-linear-gradient(top, rgba(0,0,0,0), rgba(0,0,0,0.08)), rgba(255,255,255,0.4);
9
- border-radius: 99px;
10
- box-shadow: inset 0 1px 0 rgba(0,0,0,0.08), inset 0 0 4px rgba(0,0,0,0.6), 0 0px 0 rgba(255,255,255,0.6);
11
- -webkit-user-select: none;
12
- -webkit-tap-highlight-color: rgba(0,0,0,0);
13
- }
14
- form input[type=search],
15
- form input[type=button],
16
- form .status
17
- {
18
- height: 46px;
19
- border: 1px solid #98989f;
20
- -webkit-appearance: none;
21
- border-radius: 99px;
22
- box-shadow: inset 0 2px 4px rgba(0,0,0,0.12);
23
- background: #fff;
24
- line-height: 1;
25
- -webkit-tap-highlight-color: rgba(0,0,0,0);
26
- -webkit-box-sizing: border-box;
27
- -moz-box-sizing: border-box;
28
- box-sizing: border-box;
29
- }
30
- form input[type=search] {
31
- font-size: 30px;
32
- z-index: 3;
33
- display: block;
34
- position: absolute;
35
- margin: 0 0 0 2em;
36
- padding: 0 8px 0 13px;
37
- width: 526px;
38
- }
39
- form input[type=search]::-webkit-input-placeholder
40
- {
41
- color: #c0c0c8;
42
- font-size: 30px;
43
- line-height: 36px; /* Fixes placeholder vertical alignment in Chrome and Webkit Nightly (535.*) */
44
- }
45
- form input[type=search]:-moz-placeholder
46
- {
47
- color: #c0c0c8;
48
- }
49
- form input[type=search]:focus
50
- {
51
- outline: none;
52
- border-color: #6e96c7;
53
- box-shadow: inset 0 0 4px #6e96c7, inset 0 0 4px #6e96c7, 0 0 4px #6e96c7, 0 0 4px #6e96c7, inset 0 2px 4px rgba(0,0,0,0.16);
54
- }
55
- form input[type=search]::-webkit-search-cancel-button
56
- {
57
- z-index: 9;
58
- position: absolute;
59
- right: 6px;
60
- top: 6px;
61
- width: 32px;
62
- height: 32px;
63
- margin: 0;
64
- padding: 0;
65
- background: url(images/cancel.svg);
66
- -webkit-appearance: none;
67
- }
68
- form input[type=search]::-webkit-search-cancel-button:active
69
- {
70
- background-position: 0 -32px;
71
- }
72
- form input[type=search]::-webkit-search-cancel-button
73
- {
74
- /* outline: 1px dashed red !important;*/
75
- }
76
- form input[type=button]
77
- {
78
- background: rgba(0,0,0,0.01);
79
- font-size: 1.2em;
80
- z-index: 2;
81
- display: block;
82
- position: absolute;
83
- padding-right: 0.8em;
84
- right: 0;
85
- width: 130px;
86
- color: #606068;
87
- text-align: right;
88
- text-shadow: 0 1px 0 rgba(255,255,255,0.8);
89
- -webkit-transition: background 0.15s ease-in;
90
- }
91
- form input[type=button]:active
92
- {
93
- background: rgba(0,0,0,0.08);
94
- -webkit-transition-duration: 0;
95
- }
96
- form .status {
97
- background: rgba(0,0,0,0.0);
98
- z-index: 2;
99
- display: block;
100
- position: absolute;
101
- left: 0;
102
- width: 100px;
103
- line-height: 46px;
104
- padding-right: 2em;
105
- text-align: right;
106
- font-size: 1.5em;
107
- }
108
- .picky form.empty .status {
109
- background-color: hsl(215, 51%, 70%); }
110
- .picky form.empty .feedback {
111
- background-color: #d0e2ff; }
112
- .picky form.none .status {
113
- background-color: hsl(6, 51%, 70%); }
114
- .picky form.none .feedback {
115
- background-color: #ffdddd; }
116
- .picky form.support .status {
117
- background-color: hsl(29, 51%, 70%); }
118
- .picky form.support .feedback {
119
- background-color: #faf3d0; }
120
- .picky form.ok .status {
121
- background-color: hsl(82, 51%, 70%); }
122
- .picky form.ok .feedback {
123
- background-color: #bcf0b3; }
124
- .picky form .feedback {
125
- width: 85%;
126
- float: left;
127
- border: 1px solid #cccccc;
128
- padding: 0;
129
- margin: 0; }
130
-
131
- /* To the top */
132
- .picky .header .tothetop {
133
- float: right;
134
- }
135
- .picky .header .tothetop a {
136
- display: block;
137
- width: 20px;
138
- height: 20px;
139
- text-align: center;
140
- margin-left: 1em;
141
- border-radius: 5px;
142
- background-color: #EEE;
143
- text-decoration: none;
144
- font-size: 1em;
145
- font-weight: bold;
146
- color: #777;
147
- }
148
- .picky .header .tothetop a:hover {
149
- background-color: white;
150
- }
151
-
152
- /* Addination */
153
- .picky .addination {
154
- line-height: 2em;
155
- text-align: center;
156
- cursor: pointer;
157
- }
158
- .picky .addination:hover {
159
- background-color: #eee;
160
- }
161
-
162
- /* Allocations */
163
- .picky .allocations ol {
164
- margin-bottom: 10px;
165
- }
166
- .picky ol {
167
- cursor: pointer;
168
- list-style-type: none;
169
- margin: 0;
170
- padding: 0;
171
- }
172
- .picky li:hover {
173
- background-color: #eee;
174
- }
175
- .picky ol.more,
176
- .picky ol.hidden {
177
- margin-top: 3px;
178
- }
179
- .picky .allocations ol.hidden {
180
- display: none; }
181
- .picky .allocations ol.more:hover {
182
- background-color: #ccc;
183
- cursor: pointer; }
184
- .picky .allocations ol {
185
- list-style-position: outside;
186
- list-style: none;
187
- padding: 0;}
188
-
189
- .picky .allocations li {
190
- font-size: 1.2em;
191
- padding: 24px;
192
- overflow: hidden;
193
- border-bottom: 1px solid rgba(0,0,0,0.1);
194
- }
195
- .picky .allocations li:last-child {
196
- border-bottom: 0px;
197
- margin-bottom: 0;
198
- }
199
- .picky .allocations .text {
200
- max-width: 90%;
201
- float: left; }
202
- .picky .allocations .count {
203
- float: right;
204
- color: #cccccc; }
205
-
206
- .picky .results .header {
207
- padding: 0.5em;
208
- background-color: rgba(0, 0, 0, 0.04);
209
- background: -webkit-gradient(radial, 0% 100%, 90, 0% 100%, 600, from(rgba(0, 0, 0, 0.02)), to(rgba(0, 0, 0, 0.1)));
210
- text-align: right;
211
- }
212
- .picky .allocations,
213
- .picky .no_results,
214
- .picky .results,
215
- .picky .more {
216
- display: none;
217
- margin: 0 1.5em;
218
- padding: 0 0 0 0;
219
- background-color: rgba(0, 0, 0, 0.02);
220
- border-bottom-left-radius: 1em;
221
- border-bottom-right-radius: 1em;
222
- border-bottom: solid 1px #b8b8ba;
223
- box-shadow: inset 0 1px 3px rgba(255,255,255,0), 0 1px 3px rgba(0,0,0,0.16);
224
- }
225
- .picky ol.more, .picky .no_results {
226
- display: none;
227
- }
228
- .picky ol.more h3, .picky .no_results h3 {
229
- margin: 0;
230
- text-align: center;
231
- }
232
- .picky .allocations .more {
233
- position: absolute;
234
- font-weight: bold;
235
- line-height: 1.1em;
236
- padding: 0.2em 1em 0.4em;
237
- margin: 0 16.5%;
238
- -moz-border-radius-bottomleft: 20px;
239
- -webkit-border-bottom-left-radius: 20px;
240
- -o-border-bottom-left-radius: 20px;
241
- -ms-border-bottom-left-radius: 20px;
242
- -khtml-border-bottom-left-radius: 20px;
243
- border-bottom-left-radius: 20px;
244
- -moz-border-radius-bottomright: 20px;
245
- -webkit-border-bottom-right-radius: 20px;
246
- -o-border-bottom-right-radius: 20px;
247
- -ms-border-bottom-right-radius: 20px;
248
- -khtml-border-bottom-right-radius: 20px;
249
- border-bottom-right-radius: 20px;
250
- border-left-width: 1px;
251
- border-right-width: 1px;
252
- border-bottom-width: 2px;
253
- }
254
-
255
- /* Results */
256
- .picky .results li {
257
- margin: 0;
258
- padding: 1em;
259
- border-bottom: 1px solid #aaa;
260
- }
261
- .picky .results li:last-child {
262
- border-bottom: 0px;
263
- }
264
- .picky .results li h3 {
265
- margin-top: 0;
266
- }
267
- .picky .results li h3 a:link,
268
- .picky .results li h3 a:visited {
269
- color: black;
270
- text-decoration: none;
271
- }
272
- .picky .results li h3 a:hover {
273
- text-decoration: underline;
274
- }
275
- .picky .no_results {
276
- padding: 1em;
277
- }
@@ -1,311 +0,0 @@
1
- !!!
2
- %html{ :lang => 'en' }
3
- %head
4
- %link{ :href => "stylesheets/application.css", :media => "screen", :rel => "stylesheet", :type => "text/css" }/
5
- %link{ :href => "stylesheets/picky.css", :media => "screen", :rel => "stylesheet", :type => "text/css" }/
6
- %script{ :src => 'javascripts/jquery-1.5.0.min.js', :type => 'text/javascript' }
7
- %script{ :src => 'javascripts/history.min.js', :type => 'text/javascript' }
8
- %script{ :src => 'javascripts/history.adapter.jquery.min.js', :type => 'text/javascript' }
9
- %script{ :src => 'javascripts/picky.min.js', :type => 'text/javascript' }
10
- %body
11
- %hgroup
12
- / Replace these headers with your code
13
- %img{ :class => 'picky', :src => "images/picky.png"}/
14
- %h1 Picky
15
- %h2
16
- Scaffold: A great start into your
17
- %em fantastic
18
- search engine!
19
-
20
- %a{ :href => "http://florianhanke.com/picky" } Picky Homepage
21
- .content
22
- = Picky::Helper.cached_interface
23
- %section
24
- %h1 Examples:
25
- %p
26
- %a{:href => "", :onclick => "pickyClient.insert('alan');"} alan
27
- finds Alan in the title, and Alans who wrote books. The title is ranked higher due to weighing.
28
- %p
29
- %a{:href => "", :onclick => "pickyClient.insert('title:women');"} title:women
30
- finds "women*" just in titles.
31
- %p
32
- %a{:href => "", :onclick => "pickyClient.insert('pinchn~');"} pinchn~
33
- finds the similar "pynchon".
34
- %p
35
- %a{:href => "", :onclick => "pickyClient.insert('title:lyterature~');"} title:lyterature~
36
- finds similar titles.
37
- %p
38
- %a{:href => "", :onclick => "pickyClient.insert('sp');"} sp
39
- finds "sp*" in multiple categories. Choose the one you're looking for.
40
- %p
41
- %a{:href => "", :onclick => "pickyClient.insert('soc* p');"} soc* p
42
- means "find something that starts with soc, and another thing starting with p".
43
- %section
44
- %h1 Already made it this far? You're good!
45
- %p I think you're ready for configuring me for your own purposes.
46
- %h2 Configuring the Picky client.
47
- %p
48
- There are two places where you configure the Picky client:
49
- %ol
50
- %li
51
- %a{ :href => '#controller' } In the controller.
52
- (client to Picky server)
53
- %li
54
- %a{ :href => '#view' } In the view.
55
- (javascript client interface)
56
- %h2#controller Controller
57
- %p
58
- Open the file
59
- %strong app.rb
60
- and take a peek inside.
61
- %p
62
- First you need both a client instance for a
63
- %strong full
64
- or a
65
- %strong live search
66
- depending on what you need (Full gets results with IDs, Live without and is used for updating the counter).
67
- %p
68
- In the example, I called it
69
- %strong BookSearch
70
- \.
71
- %code
72
- %pre
73
- :preserve
74
- BookSearch = Picky::Client.new host: 'localhost',
75
- port: 8080,
76
- path: '/books'
77
- %p
78
- Both clients offer the options:
79
- %dl
80
- %dt
81
- %strong host
82
- %dd The Picky search server host.
83
- %dt
84
- %strong port
85
- %dd The Picky search server port (see unicorn.rb in the server).
86
- %dt
87
- %strong path
88
- %dd The Picky search path (see app.rb in the server).
89
- %p
90
- Then, use these Client instances in your actions. For example like this:
91
- %code
92
- %pre
93
- :preserve
94
- get '/search/full' do
95
- results = BookSearch.search params[:query],
96
- :ids => params[:ids],
97
- :offset => params[:offset]
98
- results.extend Picky::Convenience
99
- results.populate_with Book do |book|
100
- book.to_s
101
- end
102
- ActiveSupport::JSON.encode results
103
- end
104
- %p
105
- This part gets a
106
- %strong hash
107
- with the results:
108
- %code
109
- %pre
110
- :preserve
111
- results = BookSearch.search params[:query],
112
- :ids => params[:ids],
113
- :offset => params[:offset]
114
- %p
115
- This part takes the
116
- %strong hash
117
- and extends it with a few useful and convenient methods:
118
- %code
119
- %pre results.extend Picky::Convenience
120
- %p
121
- One of these methods is the
122
- %strong populate_with
123
- method which takes a
124
- %strong model
125
- as parameter, and then gets the corresponding
126
- %strong model instances
127
- for each id in the result.
128
- %code
129
- %pre
130
- :preserve
131
- results.populate_with Book do |book|
132
- book.to_s
133
- end
134
- The
135
- %strong book.to_s
136
- simulates rendering a book.
137
- You can do whatever with the book instance if you just return a rendered thing that's supposed to be shown in the front end.
138
- %p
139
- If you don't want to render in the controller, you can do so in a view. In the controller just call
140
- %code
141
- %pre
142
- results.populate_with Book
143
- and then render the books in a view using:
144
- %code
145
- %pre
146
- :preserve
147
- results.entries do |book|
148
- render book # or book.to_s, or however you like to render the book.
149
- end
150
- %p
151
- At the end, encode the hash in JSON:
152
- %code
153
- %pre
154
- ActiveSupport::JSON.encode results
155
- That's it for the controller.
156
- %p
157
- All the steps in one:
158
- %code
159
- %pre
160
- :preserve
161
- BookSearch = Picky::Client.new host: 'localhost',
162
- port: 8080,
163
- path: '/books'
164
-
165
- get '/search/full' do
166
- results = BookSearch.search params[:query],
167
- ids: params[:ids],
168
- offset: params[:offset]
169
-
170
- results.extend Picky::Convenience
171
- results.populate_with Book do |book|
172
- book.to_s
173
- end
174
-
175
- ActiveSupport::JSON.encode results
176
- end
177
- %h2#view View
178
- %p
179
- The view is even easier. Just add the line
180
- %code
181
- %pre
182
- :preserve
183
- = Picky::Helper.cached_interface
184
- if you use just one language, or
185
- %code
186
- %pre
187
- :preserve
188
- = Picky::Helper.interface button: 'search',
189
- no_results: 'No results!',
190
- more: 'more'
191
- if you use multiple languages.
192
- (You'd use the options
193
- %code
194
- %pre
195
- :preserve
196
- button: t(:'search.button'),
197
- no_results: t(:'search.no_results'),
198
- more: t(:'search.more')
199
- of course, with proper i18n)
200
- The same options can be used for
201
- %strong #cached_interface
202
- but they will be cached, so you can only set them once and then reused.
203
- %p
204
- You're almost finished. Take a look at the file
205
- %strong views/search.haml
206
- where you'll find javascript at the end. It looks something like this:
207
- %code
208
- %pre
209
- :preserve
210
- :javascript
211
- pickyClient = new PickyClient({
212
- // A full query displays the rendered results.
213
- //
214
- full: '/search/full',
215
-
216
- // etc.
217
- Just take a look at the possible javascript client options in that file.
218
- %p
219
- %strong Good luck my friend!
220
- %em *waves several stubby pink tentacles*
221
- %footer
222
- Website design by
223
- %a{ :href => 'http://twitter.com/thijs' } Thijs van der Vossen
224
- of
225
- %a{ :href => 'http://fngtps.com' } Fingertips
226
- with modifications by
227
- = succeed('.') do
228
- %a{ :href => 'http://twitter.com/hanke' } Florian Hanke
229
- :javascript
230
- $(window).load(function() {
231
- pickyClient = new PickyClient({
232
- // A full query displays the rendered results.
233
- //
234
- full: '/search/full',
235
- // fullResults: 100, // Optional. Amount of ids to search for, default 20.
236
-
237
- // A live query just updates the count.
238
- //
239
- live: '/search/live',
240
- // liveResults: 0, // Optional. Amount of ids to search for, default 0.
241
-
242
- // showResultsLimit: 100, // Optional. Default is 10.
243
-
244
- // Wrap each li group (like author-title, or title-isbn etc.) of results
245
- // in this element.
246
- // Optional. Default is '<ol class="results"></ol>'.
247
- //
248
- // wrapResults: '<div class="hello"><ol class="world"></ol></div>',
249
-
250
- // before: function(query, params) { }, // Optional. Before Picky sends any data. Return modified query.
251
- // success: function(data, query) { }, // Optional. Just after Picky receives data. (Get a PickyData object)
252
- // after: function(data, query) { }, // Optional. After Picky has handled the data and updated the view.
253
-
254
- // This is used to generate the correct query strings, localized. E.g. "subject:war".
255
- // Optional. If you don't give these, the field identifier given in the Picky server is used.
256
- //
257
- qualifiers: {
258
- en:{
259
- subjects: 'subject'
260
- }
261
- },
262
-
263
- // Use this to group the choices (those are used when Picky needs more feedback).
264
- // If a category is missing, it is appended in a virtual group at the end.
265
- // Optional. Default is [].
266
- //
267
- groups: [['author', 'title', 'subjects']],
268
- // This is used for formatting inside the choice groups.
269
- //
270
- // Use %n$s, where n is the position of the category in the key.
271
- // Optional. Default is {}.
272
- //
273
- choices: {
274
- en:{
275
- 'title': {
276
- format: "Called <strong>%1$s</strong>",
277
- filter: function(text) { return text.toUpperCase(); },
278
- ignoreSingle: true
279
- },
280
- 'author': 'Written by %1$s',
281
- 'subjects': 'Being about %1$s',
282
- 'publisher': 'Published by %1$s',
283
- 'author,title': 'Called %1$s, written by %2$s',
284
- 'title,author': 'Called %2$s, written by %1$s',
285
- 'title,subjects': 'Called %1$s, about %2$s',
286
- 'author,subjects': '%1$s who wrote about %2$s'
287
- }
288
- },
289
-
290
- // This is used to explain the preceding word in the suggestion text (if it
291
- // has not yet been defined by the choices above), localized. E.g. "Peter (author)".
292
- // Optional. Default are the field identifiers from the Picky server.
293
- //
294
- explanations: {
295
- en:{
296
- title: 'titled',
297
- author: 'written by',
298
- year: 'published in',
299
- publisher: 'published by',
300
- subjects: 'with subjects'
301
- }
302
- }
303
- });
304
-
305
- // An initial search text, prefilled
306
- // this one is passed through the query param q.
307
- //
308
- // Example: www.mysearch.com/?q=example
309
- //
310
- pickyClient.insertFromURL('#{@query}');
311
- });