cable 0.9.8 → 0.9.9
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/VERSION +1 -1
- data/app/controllers/admin/search_controller.rb +16 -0
- data/app/helpers/admin/search_controller_helper.rb +12 -0
- data/app/views/admin/search/index.html.erb +13 -0
- data/app/views/admin/search/index.json.erb +1 -0
- data/app/views/layouts/_search.html.erb +30 -0
- data/app/views/layouts/admin.html.erb +8 -2
- data/config/routes.rb +6 -0
- data/lib/cable.rb +9 -0
- data/lib/cable/errors/search_error.rb +6 -0
- data/lib/generators/cable/install_generator.rb +1 -1
- data/public/javascripts/jquery.ui.autocomplete.html.js +40 -0
- data/public/stylesheets/cable/regions.css +1 -0
- data/public/stylesheets/cable/search.css +9 -11
- data/public/stylesheets/cable/tables.css +3 -4
- metadata +11 -4
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.9.
|
|
1
|
+
0.9.9
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class Admin::SearchController < AdminController
|
|
2
|
+
include Admin::SearchControllerHelper
|
|
3
|
+
respond_to :js, :html
|
|
4
|
+
|
|
5
|
+
def index
|
|
6
|
+
@admin_layout = "single"
|
|
7
|
+
@results = ThinkingSphinx.search params[:term], :match_mode => :extended, :star => true
|
|
8
|
+
respond_to do |format|
|
|
9
|
+
format.json { render request.format.to_sym => to_json_for_autocomplete( @results) }
|
|
10
|
+
format.html
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module Admin::SearchControllerHelper
|
|
2
|
+
|
|
3
|
+
def to_json_for_autocomplete( results )
|
|
4
|
+
results.collect do |result|
|
|
5
|
+
if result.respond_to? :to_json_for_autocomplete
|
|
6
|
+
result.to_json_for_autocomplete
|
|
7
|
+
else
|
|
8
|
+
raise Cable::Errors::SearchError::MissingInterfaceMethod , "to_json_for_autocomplete method should be defined on #{result.class.name}"
|
|
9
|
+
end
|
|
10
|
+
end.to_json
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<table>
|
|
2
|
+
<thead>
|
|
3
|
+
<tr>
|
|
4
|
+
<th>Result</th>
|
|
5
|
+
<th>Type</th>
|
|
6
|
+
</tr>
|
|
7
|
+
</thead>
|
|
8
|
+
<tbody>
|
|
9
|
+
<% @results.each do |result| %>
|
|
10
|
+
<%= render :partial => "/admin/#{result.class.name.tableize}/search", :locals => {:result => result}%>
|
|
11
|
+
<% end %>
|
|
12
|
+
</tbody>
|
|
13
|
+
</table>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%=raw @results %>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
$(document).ready(function() {
|
|
3
|
+
$("input#global_search").autocomplete({
|
|
4
|
+
minLength: 3,
|
|
5
|
+
delay: 600,
|
|
6
|
+
html: true,
|
|
7
|
+
source: function(request, response) {
|
|
8
|
+
$.ajax({
|
|
9
|
+
url: '<%= admin_search_index_path %>',
|
|
10
|
+
dataType: "json",
|
|
11
|
+
data: {term: request.term},
|
|
12
|
+
success: function( data ) {
|
|
13
|
+
response( data );
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
})
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<div class="span-9 last search">
|
|
22
|
+
<div class="box shadow">
|
|
23
|
+
<div>
|
|
24
|
+
<%= semantic_form_for 'search', :url => admin_search_index_path, :html => {:method => :get} do |f| %>
|
|
25
|
+
<%= f.input :term, :input_html => {:id => "global_search", :name => "term"} , :label => "Search: ", :required => false %>
|
|
26
|
+
<%= f.commit_button "search" %>
|
|
27
|
+
<% end %>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<%= stylesheet_link_tag 'cable/formtastic' %>
|
|
12
12
|
<%= stylesheet_link_tag 'cable/formtastic_changes' %>
|
|
13
13
|
<%= stylesheet_link_tag 'jquery/ui/jquery-ui-1.8.7.custom.css' %>
|
|
14
|
-
<%= javascript_include_tag 'jquery' , 'jquery-ui', 'rails','tinymce/jquery.tinymce.js', 'jquery.tablesorter.min.js', 'admin.js' %>
|
|
14
|
+
<%= javascript_include_tag 'jquery' , 'jquery-ui', 'rails','tinymce/jquery.tinymce.js', 'jquery.tablesorter.min.js', 'jquery.ui.autocomplete.html.js', 'admin.js' %>
|
|
15
15
|
<%= yield :scripts %>
|
|
16
16
|
</head>
|
|
17
17
|
<body>
|
|
@@ -27,11 +27,13 @@
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
<% if @admin_layout == "single" %>
|
|
30
|
+
|
|
31
|
+
<%= render :partial => "layouts/search" %>
|
|
32
|
+
|
|
30
33
|
<div id="main" class="span-24">
|
|
31
34
|
<div class="box shadow">
|
|
32
35
|
<h2 id="title"><%= @page_title %></h2>
|
|
33
36
|
<div id="help"><%= yield :help %><a class="button">Help</a></div>
|
|
34
|
-
<%= render :partial => 'layouts/breadcrumb' %>
|
|
35
37
|
<%= yield :page_menu %>
|
|
36
38
|
<%= render :partial => 'layouts/messages' %>
|
|
37
39
|
<%= yield %>
|
|
@@ -43,8 +45,12 @@
|
|
|
43
45
|
<%= yield :sidebar %>
|
|
44
46
|
</div>
|
|
45
47
|
|
|
48
|
+
<div class='span-11'><%= render :partial => 'layouts/breadcrumb' %></div>
|
|
49
|
+
<%= render :partial => "layouts/search" %>
|
|
50
|
+
|
|
46
51
|
<div id="main" class="span-20 last">
|
|
47
52
|
<div class="box shadow">
|
|
53
|
+
|
|
48
54
|
<h2 id="title"><%= @page_title %></h2>
|
|
49
55
|
<div id="help"><%= yield :help %><a class="button">Help</a></div>
|
|
50
56
|
<%= render :partial => 'layouts/breadcrumb' %>
|
data/config/routes.rb
CHANGED
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
# match '/admin(/:action(/:id))' => 'admin'
|
|
5
5
|
# end
|
|
6
6
|
Rails.application.routes.draw do
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
namespace :admin do
|
|
10
|
+
resources :search, :only => [:index], :as => 'search'
|
|
11
|
+
end
|
|
12
|
+
|
|
7
13
|
match '/admin' => 'admin#index'
|
|
8
14
|
match '/admin(/:action(/:id))' => 'admin'
|
|
9
15
|
match '*url' => 'main#find_by_url'
|
data/lib/cable.rb
CHANGED
|
@@ -18,6 +18,8 @@ module Cable
|
|
|
18
18
|
|
|
19
19
|
module Errors
|
|
20
20
|
autoload :ResourceAssociationError, "cable/errors/resource_association_error"
|
|
21
|
+
autoload :SearchError, 'cable/errors/search_error'
|
|
22
|
+
autoload :MissingInterfaceMethod, 'cable/errors/search_error'
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
module Menu
|
|
@@ -62,6 +64,13 @@ module Cable
|
|
|
62
64
|
rsrc.flatten
|
|
63
65
|
end
|
|
64
66
|
|
|
67
|
+
def self.resource_types
|
|
68
|
+
rsrc = Cable.resources.collect do |r|
|
|
69
|
+
r.classify.constantize if Cable.class_exists?( r )
|
|
70
|
+
end
|
|
71
|
+
rsrc.flatten
|
|
72
|
+
end
|
|
73
|
+
|
|
65
74
|
def self.class_exists?(class_name)
|
|
66
75
|
klass = Module.const_get(class_name)
|
|
67
76
|
return klass.is_a?(Class)
|
|
@@ -67,7 +67,7 @@ module Cable
|
|
|
67
67
|
|
|
68
68
|
def install_cocoon
|
|
69
69
|
generate('cocoon:install')
|
|
70
|
-
insert_into_file 'app/views/layouts/admin.html.erb',
|
|
70
|
+
insert_into_file 'app/views/layouts/admin.html.erb', "<%= javascript_include_tag :cocoon %>\n", :before => '<%= yield :scripts %>'
|
|
71
71
|
end
|
|
72
72
|
|
|
73
73
|
def install_routes
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* jQuery UI Autocomplete HTML Extension
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2010, Scott González (http://scottgonzalez.com)
|
|
5
|
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
6
|
+
*
|
|
7
|
+
* http://github.com/scottgonzalez/jquery-ui-extensions
|
|
8
|
+
*/
|
|
9
|
+
(function( $ ) {
|
|
10
|
+
|
|
11
|
+
var proto = $.ui.autocomplete.prototype,
|
|
12
|
+
initSource = proto._initSource;
|
|
13
|
+
|
|
14
|
+
function filter( array, term ) {
|
|
15
|
+
var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
|
|
16
|
+
return $.grep( array, function(value) {
|
|
17
|
+
return matcher.test( $( "<div>" ).html( value.label || value.value || value ).text() );
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
$.extend( proto, {
|
|
22
|
+
_initSource: function() {
|
|
23
|
+
if ( this.options.html && $.isArray(this.options.source) ) {
|
|
24
|
+
this.source = function( request, response ) {
|
|
25
|
+
response( filter( this.options.source, request.term ) );
|
|
26
|
+
};
|
|
27
|
+
} else {
|
|
28
|
+
initSource.call( this );
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
_renderItem: function( ul, item) {
|
|
33
|
+
return $( "<li></li>" )
|
|
34
|
+
.data( "item.autocomplete", item )
|
|
35
|
+
.append( $( "<a></a>" )[ this.options.html ? "html" : "text" ]( item.label + "<span class='search_type'>" + item.type +"</span>") )
|
|
36
|
+
.appendTo( ul );
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
})( jQuery );
|
|
@@ -6,20 +6,13 @@
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
#search_term {
|
|
9
|
-
|
|
9
|
+
background:#ffffff; width:100%;-webkit-box-shadow:none;text-shadow:none; color:#000;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
#
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
#search_submit{
|
|
13
|
+
display: none;
|
|
14
|
+
float: left;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
#search_term_input label {
|
|
18
|
-
float: left;
|
|
19
|
-
display: block;
|
|
20
|
-
width: 70px;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
16
|
.inline-search #search_submit {
|
|
24
17
|
font-size: .75em !important;
|
|
25
18
|
}
|
|
@@ -43,3 +36,8 @@
|
|
|
43
36
|
float: left;
|
|
44
37
|
width: 260px;
|
|
45
38
|
}
|
|
39
|
+
.formtastic.search li { list-style-type:none;}
|
|
40
|
+
|
|
41
|
+
input#global_search{ font-size: 1.3em; color:#888; width:250px; height:20px; padding:2px; margin-top:5px; margin-bottom:5px;}
|
|
42
|
+
div.search label {font-weight:bold}
|
|
43
|
+
.search_type {display:block; float:right; color:#888; font-size:x-small;}
|
|
@@ -4,14 +4,13 @@ table{
|
|
|
4
4
|
margin-bottom: 1em;
|
|
5
5
|
}
|
|
6
6
|
thead th{
|
|
7
|
-
background: #
|
|
8
|
-
border-bottom:
|
|
7
|
+
background: #ccc;
|
|
8
|
+
border-bottom: 1px solid #bbb;
|
|
9
9
|
font-weight:bold;
|
|
10
10
|
font-size:1em;
|
|
11
11
|
}
|
|
12
12
|
tbody th{
|
|
13
|
-
|
|
14
|
-
border-right: 2px solid #ccc;
|
|
13
|
+
background: #eee !important; border-right: 1px solid #BBB; border-bottom:1px solid #ddd;
|
|
15
14
|
font-weight:bold;
|
|
16
15
|
font-size:1em;
|
|
17
16
|
width:150px;
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cable
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 41
|
|
5
5
|
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 9
|
|
9
|
-
-
|
|
10
|
-
version: 0.9.
|
|
9
|
+
- 9
|
|
10
|
+
version: 0.9.9
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Spencer Markowski
|
|
@@ -17,7 +17,7 @@ autorequire:
|
|
|
17
17
|
bindir: bin
|
|
18
18
|
cert_chain: []
|
|
19
19
|
|
|
20
|
-
date: 2011-04-
|
|
20
|
+
date: 2011-04-07 00:00:00 -04:00
|
|
21
21
|
default_executable:
|
|
22
22
|
dependencies:
|
|
23
23
|
- !ruby/object:Gem::Dependency
|
|
@@ -159,12 +159,14 @@ extra_rdoc_files: []
|
|
|
159
159
|
files:
|
|
160
160
|
- VERSION
|
|
161
161
|
- app/controllers/admin/cable_settings_controller.rb
|
|
162
|
+
- app/controllers/admin/search_controller.rb
|
|
162
163
|
- app/controllers/admin_controller.rb
|
|
163
164
|
- app/controllers/attachable_assets_controller.rb
|
|
164
165
|
- app/controllers/attachable_documents_controller.rb
|
|
165
166
|
- app/controllers/attachable_images_controller.rb
|
|
166
167
|
- app/controllers/cable/cable_admin_controller.rb
|
|
167
168
|
- app/helpers/admin/menus_helper.rb
|
|
169
|
+
- app/helpers/admin/search_controller_helper.rb
|
|
168
170
|
- app/helpers/admin_helper.rb
|
|
169
171
|
- app/models/attachable_asset.rb
|
|
170
172
|
- app/models/attachable_document.rb
|
|
@@ -174,11 +176,14 @@ files:
|
|
|
174
176
|
- app/views/admin/cable_settings/edit.html.erb
|
|
175
177
|
- app/views/admin/cable_settings/index.html.erb
|
|
176
178
|
- app/views/admin/index.html.erb
|
|
179
|
+
- app/views/admin/search/index.html.erb
|
|
180
|
+
- app/views/admin/search/index.json.erb
|
|
177
181
|
- app/views/attachable_assets/index.html.erb
|
|
178
182
|
- app/views/attachable_assets/new.html.erb
|
|
179
183
|
- app/views/attachable_assets/show.html.erb
|
|
180
184
|
- app/views/layouts/_breadcrumb.html.erb
|
|
181
185
|
- app/views/layouts/_messages.html.erb
|
|
186
|
+
- app/views/layouts/_search.html.erb
|
|
182
187
|
- app/views/layouts/admin.html.erb
|
|
183
188
|
- config/admin_navigation.rb
|
|
184
189
|
- config/navigation.rb
|
|
@@ -191,6 +196,7 @@ files:
|
|
|
191
196
|
- lib/cable/controllers/cable_controller_helpers.rb
|
|
192
197
|
- lib/cable/engine.rb
|
|
193
198
|
- lib/cable/errors/resource_association_error.rb
|
|
199
|
+
- lib/cable/errors/search_error.rb
|
|
194
200
|
- lib/cable/media/acts_as_attachable.rb
|
|
195
201
|
- lib/cable/media/asset.rb
|
|
196
202
|
- lib/cable/menu.rb
|
|
@@ -258,6 +264,7 @@ files:
|
|
|
258
264
|
- public/javascripts/cable_menu.js
|
|
259
265
|
- public/javascripts/jquery.tablesorter.min.js
|
|
260
266
|
- public/javascripts/jquery.tagsinput.js
|
|
267
|
+
- public/javascripts/jquery.ui.autocomplete.html.js
|
|
261
268
|
- public/javascripts/tinymce/jquery.tinymce.js
|
|
262
269
|
- public/javascripts/tinymce/langs/en.js
|
|
263
270
|
- public/javascripts/tinymce/license.txt
|