muck-contents 3.1.5 → 3.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.5
1
+ 3.1.6
@@ -1,9 +1,32 @@
1
1
  class Admin::Muck::ContentsController < Admin::Muck::BaseController
2
2
 
3
3
  def index
4
- @contents = Content.by_title.by_newest
5
4
  respond_to do |format|
6
- format.html { render :template => 'admin/contents/index' }
5
+ format.html do
6
+ @contents = Content.by_title.by_newest.paginate(:page => @page, :per_page => @per_page)
7
+ render :template => 'admin/contents/index'
8
+ end
9
+ format.json do
10
+ @contents = Content.by_title.by_newest.where("title like ?", params[:term] + '%').paginate(:page => @page, :per_page => @per_page)
11
+ render :json => @contents
12
+ end
13
+ end
14
+ end
15
+
16
+ def destroy
17
+ @content = Content.find(params[:id])
18
+ @content.destroy
19
+ respond_to do |format|
20
+ format.html do
21
+ flash[:notice] = t('muck.contents.content_removed')
22
+ redirect_to admin_contents_path
23
+ end
24
+ format.js do
25
+ render(:update) do |page|
26
+ page << "jQuery('##{@content.dom_id}').fadeOut();"
27
+ end
28
+ end
29
+ format.json { render :json => { :success => true, :message => t("muck.contents.content_removed"), :content_id => @content.id } }
7
30
  end
8
31
  end
9
32
 
@@ -52,7 +52,7 @@ class Muck::ContentsController < ApplicationController
52
52
  end
53
53
  else
54
54
  # TODO think about caching this:
55
- @content = Content.find('404-page-not-found', :scope => MuckContents::GLOBAL_SCOPE) rescue nil
55
+ @content = Content.find('404-page-not-found', :include => :slugs, :conditions => {:slugs => {:scope => MuckContents::GLOBAL_SCOPE}}) rescue nil
56
56
  if @content.blank?
57
57
  @content = Content.new(:title => I18n.t('muck.contents.default_404_title'), :body_raw => I18n.t('muck.contents.default_404_body'), :locale => I18n.locale.to_s)
58
58
  @content.uri = '/404-page-not-found'
@@ -1,6 +1,7 @@
1
1
  <li id="<%=content.dom_id%>" class="contentContainer delete-container">
2
2
  <span class="link"><a href="<%=content.uri%>" target="_blank"><%= content.title %></a></span>
3
3
  <span class="content-controls">
4
- <%= render :partial => 'contents/admin', :locals => {:content => content} %>
4
+ <%= link_to t('muck.contents.edit'), edit_content_path(content.id), :title => t('muck.contents.edit_title'), :class => 'admin-content' -%> |
5
+ <%= link_to t('muck.contents.delete'), admin_content_path(content.id), :title => t('muck.contents.confirm_delete_content'), :class => 'admin-content ajax-delete' -%>
5
6
  </span>
6
7
  </li>
@@ -13,15 +13,35 @@
13
13
  <% content_for :javascript do -%>
14
14
  <script type="text/javascript" language="JavaScript">
15
15
  jQuery(document).ready(function() {
16
- var data = <%= @contents.collect{|content| { :title => content.title, :id => content.id } }.to_json.html_safe %>;
17
- jQuery("#auto-search").autocomplete(data, {
18
- minChars: 0,
19
- autoFill: true,
20
- mustMatch: false,
21
- formatItem: function(item) {
22
- return item.title;
23
- }
24
- }).result(function(event, item) { location.href = '/contents/' + item.id + '/edit'; });
16
+ var cache = {};
17
+ var lastXhr;
18
+ jQuery("#auto-search").autocomplete({
19
+ source: function(request, response){
20
+ var term = request.term;
21
+ if(term in cache){
22
+ response(cache[term]);
23
+ return;
24
+ }
25
+ lastXhr = jQuery.getJSON("<%=admin_contents_path(:format => 'json')%>", request, function(data, status, xhr){
26
+ var reduced_data = jQuery.map(data, function(item){
27
+ return {
28
+ label: item.title,
29
+ value: item.id
30
+ }
31
+ });
32
+ cache[term] = reduced_data;
33
+ if(xhr === lastXhr){
34
+ response(reduced_data);
35
+ }
36
+ });
37
+ },
38
+ minLength: 2,
39
+ select: function(event, ui) {
40
+ if(ui.item){
41
+ location.href = '/contents/' + ui.item.value + '/edit';
42
+ }
43
+ }
44
+ });
25
45
  });
26
46
  </script>
27
47
  <% end -%>
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{muck-contents}
8
- s.version = "3.1.5"
8
+ s.version = "3.1.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Justin Ball", "Joel Duffin"]
12
- s.date = %q{2011-03-19}
12
+ s.date = %q{2011-03-30}
13
13
  s.email = %q{justin@tatemae.com}
14
14
  s.extra_rdoc_files = [
15
15
  "README.rdoc"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muck-contents
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 1
9
- - 5
10
- version: 3.1.5
9
+ - 6
10
+ version: 3.1.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Justin Ball
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-03-19 00:00:00 -06:00
19
+ date: 2011-03-30 00:00:00 -06:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency