picky-generators 1.5.2 → 1.5.3
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.
- data/prototypes/client/sinatra/app.rb +6 -6
- data/prototypes/client/sinatra/book.rb +7 -7
- data/prototypes/client/sinatra/views/configure.haml +4 -4
- data/prototypes/client/sinatra/views/search.haml +12 -12
- data/prototypes/server/empty_unicorn/app/application.rb +2 -2
- data/prototypes/server/shared_unicorn/Gemfile +0 -3
- data/prototypes/server/shared_unicorn/config.ru +1 -1
- metadata +4 -4
@@ -21,7 +21,7 @@ set :views, File.expand_path('views', File.dirname(__FILE__))
|
|
21
21
|
#
|
22
22
|
get '/' do
|
23
23
|
@query = params[:q]
|
24
|
-
|
24
|
+
|
25
25
|
haml :'/search'
|
26
26
|
end
|
27
27
|
|
@@ -40,15 +40,15 @@ get '/search/full' do
|
|
40
40
|
results.populate_with Book do |book|
|
41
41
|
book.to_s
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
#
|
45
45
|
# Or use:
|
46
46
|
# results.populate_with Book
|
47
|
-
#
|
47
|
+
#
|
48
48
|
# Then:
|
49
49
|
# rendered_entries = results.entries.map do |book| (render each book here) end
|
50
50
|
#
|
51
|
-
|
51
|
+
|
52
52
|
ActiveSupport::JSON.encode results
|
53
53
|
end
|
54
54
|
|
@@ -59,9 +59,9 @@ get '/search/live' do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
helpers do
|
62
|
-
|
62
|
+
|
63
63
|
def js path
|
64
64
|
"<script src='javascripts/#{path}.js' type='text/javascript'></script>"
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
end
|
@@ -9,28 +9,28 @@ require 'csv'
|
|
9
9
|
# * a number of subjects
|
10
10
|
#
|
11
11
|
class Book
|
12
|
-
|
12
|
+
|
13
13
|
@@books_mapping = {}
|
14
|
-
|
14
|
+
|
15
15
|
# Load the books on startup.
|
16
16
|
#
|
17
17
|
file_name = File.expand_path 'library.csv', File.dirname(__FILE__)
|
18
18
|
CSV.open(file_name, 'r').each do |row|
|
19
19
|
@@books_mapping[row.shift.to_i] = row
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
# Find uses a lookup table.
|
23
23
|
#
|
24
24
|
def self.find ids, _ = {}
|
25
25
|
ids.map { |id| new(id, *@@books_mapping[id]) }
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
attr_reader :id
|
29
|
-
|
29
|
+
|
30
30
|
def initialize id, title, author, year, publisher, subjects
|
31
31
|
@id, @title, @author, @year, @publisher, @subjects = id, title, author, year, publisher, subjects
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
# "Rendering" ;)
|
35
35
|
#
|
36
36
|
# Note: This is just an example. Please do not render in the model.
|
@@ -38,5 +38,5 @@ class Book
|
|
38
38
|
def to_s
|
39
39
|
"<li class='book'><p>\"#{@title}\", by #{@author}</p><p>#{@year}, #{@publisher}</p><p>#{@subjects}</p></li>"
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
end
|
@@ -123,15 +123,15 @@
|
|
123
123
|
:preserve
|
124
124
|
FullBooks = Picky::Client::Full.new :host => 'localhost', :port => 8080, :path => '/books/full'
|
125
125
|
LiveBooks = Picky::Client::Live.new :host => 'localhost', :port => 8080, :path => '/books/live'
|
126
|
-
|
126
|
+
|
127
127
|
get '/search/full' do
|
128
128
|
results = FullBooks.search params[:query], :offset => params[:offset]
|
129
|
-
|
129
|
+
|
130
130
|
results.extend Picky::Convenience
|
131
131
|
results.populate_with Book do |book|
|
132
132
|
book.to_s
|
133
133
|
end
|
134
|
-
|
134
|
+
|
135
135
|
ActiveSupport::JSON.encode results
|
136
136
|
end
|
137
137
|
%h2#view View
|
@@ -163,7 +163,7 @@
|
|
163
163
|
// A full query displays the rendered results.
|
164
164
|
//
|
165
165
|
full: '/search/full',
|
166
|
-
|
166
|
+
|
167
167
|
// etc.
|
168
168
|
Just take a look at the possible javascript client options in that file.
|
169
169
|
%p
|
@@ -3,10 +3,10 @@
|
|
3
3
|
%head
|
4
4
|
%link{:href => "stylesheets/picky.css", :media => "screen", :rel => "stylesheet", :type => "text/css"}/
|
5
5
|
%link{:href => "stylesheets/application.css", :media => "screen", :rel => "stylesheet", :type => "text/css"}/
|
6
|
-
|
6
|
+
|
7
7
|
= js 'jquery-1.5.0.min'
|
8
8
|
= js 'jquery.address-1.3.2.min'
|
9
|
-
|
9
|
+
|
10
10
|
= js 'picky.min'
|
11
11
|
%body
|
12
12
|
%img{:src => "images/picky.png"}/
|
@@ -60,23 +60,23 @@
|
|
60
60
|
// A full query displays the rendered results.
|
61
61
|
//
|
62
62
|
full: '/search/full',
|
63
|
-
|
63
|
+
|
64
64
|
// A live query just updates the count.
|
65
65
|
//
|
66
66
|
live: '/search/live',
|
67
|
-
|
67
|
+
|
68
68
|
// showResultsLimit: 10, // Optional. Default is 10.
|
69
|
-
|
69
|
+
|
70
70
|
// Wrap each li group (like author-title, or title-isbn etc.) of results
|
71
71
|
// in this element.
|
72
72
|
// Optional. Default is '<ol class="results"></ol>'.
|
73
73
|
//
|
74
74
|
// wrapResults: '<div class="hello"><ol class="world"></ol></div>',
|
75
|
-
|
75
|
+
|
76
76
|
// before: function(params, query, offset) { }, // Optional. Before Picky sends any data.
|
77
77
|
// success: function(data, query) { }, // Optional. Just after Picky receives data. (Get a PickyData object)
|
78
78
|
// after: function(data, query) { }, // Optional. After Picky has handled the data and updated the view.
|
79
|
-
|
79
|
+
|
80
80
|
// This is used to generate the correct query strings, localized. E.g. "subject:war".
|
81
81
|
// Optional. If you don't give these, the field identifier given in the Picky server is used.
|
82
82
|
//
|
@@ -85,7 +85,7 @@
|
|
85
85
|
subjects: 'subject'
|
86
86
|
}
|
87
87
|
},
|
88
|
-
|
88
|
+
|
89
89
|
// Use this to group the choices (those are used when Picky needs more feedback).
|
90
90
|
// If a category is missing, it is appended in a virtual group at the end.
|
91
91
|
// Optional. Default is [].
|
@@ -101,7 +101,7 @@
|
|
101
101
|
'title': {
|
102
102
|
format: "<strong>%1$s</strong>",
|
103
103
|
filter: function(text) { return text.toUpperCase(); },
|
104
|
-
ignoreSingle: false
|
104
|
+
ignoreSingle: false
|
105
105
|
},
|
106
106
|
'author,title': '%1$s, who wrote %2$s',
|
107
107
|
'title,author': '%2$s, written by %2$s',
|
@@ -109,7 +109,7 @@
|
|
109
109
|
'author,subjects': '%1$s, who wrote about %2$s'
|
110
110
|
}
|
111
111
|
},
|
112
|
-
|
112
|
+
|
113
113
|
// This is used to explain the preceding word in the suggestion text (if it
|
114
114
|
// has not yet been defined by the choices above), localized. E.g. "Peter (author)".
|
115
115
|
// Optional. Default are the field identifiers from the Picky server.
|
@@ -124,14 +124,14 @@
|
|
124
124
|
}
|
125
125
|
}
|
126
126
|
});
|
127
|
-
|
127
|
+
|
128
128
|
// An initial search text, prefilled
|
129
129
|
// this one is passed through the query param q.
|
130
130
|
//
|
131
131
|
// Example: www.mysearch.com/?q=example
|
132
132
|
//
|
133
133
|
// If there isn't a q parameter (because it is empty), we try to
|
134
|
-
// take it from the deep linking /#/?q parameter.
|
134
|
+
// take it from the deep linking /#/?q parameter.
|
135
135
|
//
|
136
136
|
pickyClient.insertFromURL('#{@query}');
|
137
137
|
});
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: picky-generators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.5.
|
5
|
+
version: 1.5.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Florian Hanke
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-03-
|
13
|
+
date: 2011-03-13 00:00:00 +01:00
|
14
14
|
default_executable: picky-generate
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
requirements:
|
33
33
|
- - ~>
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 1.5.
|
35
|
+
version: 1.5.3
|
36
36
|
type: :runtime
|
37
37
|
version_requirements: *id002
|
38
38
|
- !ruby/object:Gem::Dependency
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - ~>
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 1.5.
|
46
|
+
version: 1.5.3
|
47
47
|
type: :runtime
|
48
48
|
version_requirements: *id003
|
49
49
|
description: Generators for Picky.
|