beef-articles 0.4.14 → 0.4.15

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.14
1
+ 0.4.15
@@ -1,11 +1,11 @@
1
1
  class Admin::ArticlesController < Admin::BaseController
2
2
  unloadable
3
- sortable_attributes :created_at, :published_at, :title, :permalink, :published_to, :body, :description, :allow_comments, :created => 'users.name',:category => 'categories.title', :updated => 'updated_bies_articles.name'
3
+ sortable_attributes :created_at, :published_at, :title, :permalink, :published_to, :body, :description, :allow_comments, :created => 'users.name', :category => 'categories.title', :updated => 'updated_bies_articles.name'
4
4
 
5
5
  # GET /articles
6
6
  # GET /articles.xml
7
7
  def index
8
- @articles = Article.paginate :page => params[:page], :per_page => 20, :order => sort_order(:default => 'desc'), :include => [:created_by, :updated_by, :category]
8
+ @articles = article_type.paginate :page => params[:page], :per_page => 20, :order => sort_order(:default => 'desc'), :include => [:created_by, :updated_by, :category]
9
9
 
10
10
  respond_to do |format|
11
11
  format.html # index.html.erb
@@ -16,7 +16,7 @@ class Admin::ArticlesController < Admin::BaseController
16
16
  # GET /articles/1
17
17
  # GET /articles/1.xml
18
18
  def show
19
- @article = Article.find(params[:id])
19
+ @article = article_type.find(params[:id])
20
20
 
21
21
  respond_to do |format|
22
22
  format.html
@@ -27,7 +27,7 @@ class Admin::ArticlesController < Admin::BaseController
27
27
  # GET /articles/new
28
28
  # GET /articles/new.xml
29
29
  def new
30
- @article = Article.new
30
+ @article = article_type.new
31
31
 
32
32
  respond_to do |format|
33
33
  format.html { render :action =>'show' }
@@ -38,13 +38,13 @@ class Admin::ArticlesController < Admin::BaseController
38
38
  # POST /articles
39
39
  # POST /articles.xml
40
40
  def create
41
- @article = Article.new(params[:article])
41
+ @article = article_type.new(params[:article])
42
42
  @article.updated_by = @article.created_by = current_user
43
43
 
44
44
  respond_to do |format|
45
45
  if @article.save
46
46
  flash[:notice] = 'Article was successfully created.'
47
- format.html { redirect_to(admin_articles_url) }
47
+ format.html { redirect_to :action => 'index' }
48
48
  format.xml { render :xml => @article, :status => :created, :location => @article }
49
49
  else
50
50
  format.html { render :action => "show" }
@@ -56,13 +56,13 @@ class Admin::ArticlesController < Admin::BaseController
56
56
  # PUT /articles/1
57
57
  # PUT /articles/1.xml
58
58
  def update
59
- @article = Article.find(params[:id])
59
+ @article = article_type.find(params[:id])
60
60
  @article.updated_by = current_user
61
61
 
62
62
  respond_to do |format|
63
63
  if @article.update_attributes(params[:article])
64
64
  flash[:notice] = 'Article was successfully updated.'
65
- format.html { redirect_to(admin_articles_url) }
65
+ format.html { redirect_to :action => 'index' }
66
66
  format.xml { head :ok }
67
67
  else
68
68
  format.html { render :action => "show" }
@@ -74,20 +74,27 @@ class Admin::ArticlesController < Admin::BaseController
74
74
  # DELETE /articles/1
75
75
  # DELETE /articles/1.xml
76
76
  def destroy
77
- @article = Article.find(params[:id])
77
+ @article = article_type.find(params[:id])
78
78
  @article.destroy
79
79
  flash[:notice] = 'Article was successfully deleted.'
80
80
 
81
81
  respond_to do |format|
82
- format.html { redirect_to(admin_articles_url) }
82
+ format.html { redirect_to :action => 'index' }
83
83
  format.xml { head :ok }
84
84
  end
85
85
  end
86
-
86
+
87
87
  def preview
88
88
  preview_params = params[:article]
89
- article = Article.find_by_id(params[:id])
89
+ article = article_type.find_by_id(params[:id])
90
90
  preview_params.reverse_merge!(article.attributes) if article
91
91
  session[:article_preview] = preview_params
92
92
  end
93
+
94
+ protected
95
+
96
+ def article_type
97
+ Article
98
+ end
99
+
93
100
  end
@@ -1,6 +1,6 @@
1
1
  class ArticlesController < ApplicationController
2
2
  unloadable
3
-
3
+
4
4
  def index
5
5
  @page_title = 'Articles'
6
6
  if params[:category_id]
@@ -17,44 +17,43 @@ class ArticlesController < ApplicationController
17
17
  if params[:year]
18
18
  @page_title << " from #{params[:day]} #{Date::MONTHNAMES[params[:month].to_i] unless params[:month].nil?} #{params[:year]}"
19
19
  end
20
-
21
- @articles = Article.in_time_delta( params[:year], params[:month], params[:day] ).published.tagged_with(params[:tag], :on => :tags).authored_by(@user).categorised(@category).paginate( :page => params[:page], :per_page => params[:per_page] || Article.per_page, :include => [:created_by] )
22
-
23
- @tags = Article.published.authored_by(@user).categorised(@category).tag_counts(:limit => 20)
24
-
20
+
21
+ @articles = article_type.in_time_delta( params[:year], params[:month], params[:day] ).published.tagged_with(params[:tag], :on => :tags).authored_by(@user).categorised(@category).paginate( :page => params[:page], :per_page => params[:per_page] || article_type.per_page, :include => [:created_by] )
22
+
23
+ @tags = article_type.published.authored_by(@user).categorised(@category).tag_counts(:limit => 20)
24
+
25
25
  respond_to do |format|
26
26
  format.html # index.html.erb
27
27
  format.xml { render :xml => @articles }
28
28
  format.json { render :json => @articles }
29
- format.rss
30
- format.js
29
+ format.rss
30
+ format.js
31
31
  end
32
32
  end
33
33
 
34
34
  def show
35
- @article = Article.published.find_by_permalink(params[:year], params[:month], params[:day], params[:permalink])
35
+ @article = article_type.published.find_by_permalink(params[:year], params[:month], params[:day], params[:permalink])
36
36
  @images = @article.assets.images
37
37
  @documents = @article.assets.documents
38
-
38
+
39
39
  @page_title = @article.title
40
40
  @page_description = @article.description
41
41
  @page_keywords = @article.tag_list
42
-
42
+
43
43
  @tags = @article.tag_counts
44
-
44
+
45
45
  respond_to do |format|
46
46
  format.html # show.html.erb
47
47
  format.xml { render :xml => @article }
48
48
  end
49
49
  end
50
-
50
+
51
51
  def preview
52
52
  @page_class = 'show'
53
- @article = Article.new(session[:article_preview])
53
+ @article = article_type.new(session[:article_preview])
54
54
  asset_ids = session[:article_preview][:asset_ids]
55
55
  @images = Asset.images.all(:conditions => {:id => asset_ids }).sort{|x,y| asset_ids.index(y.id.to_s) <=> asset_ids.index(x.id.to_s) }.reverse
56
56
  @documents = Asset.documents.all(:conditions => {:id => asset_ids }).sort{|x,y| asset_ids.index(y.id.to_s) <=> asset_ids.index(x.id.to_s) }.reverse
57
-
58
57
  @article.id = 0
59
58
  @article.published_at = Time.now
60
59
  @article.created_by = current_user
@@ -62,4 +61,11 @@ class ArticlesController < ApplicationController
62
61
  session[:article_preview] = nil
63
62
  render :action => "show"
64
63
  end
64
+
65
+ protected
66
+
67
+ def article_type
68
+ Article
69
+ end
70
+
65
71
  end
@@ -1,16 +1,17 @@
1
1
  <h1>Listing Articles</h1>
2
2
 
3
3
  <ul class="choices">
4
- <li><%= link_to 'New article', new_admin_article_path, :title => 'Create a new article' %></li>
4
+ <li><%= link_to 'New article', { :action => 'new' }, :title => 'Create a new article' %></li>
5
5
  </ul>
6
6
 
7
- <%= will_paginate %>
7
+ <%= will_paginate @articles %>
8
8
 
9
9
  <table>
10
10
  <thead>
11
11
  <tr>
12
12
  <%= sortable_table_header :name => "Title", :sort => "title" %>
13
13
  <%= sortable_table_header :name => "Status", :sort => "published_at" %>
14
+ <%= sortable_table_header :name => "Category", :sort => "category" if Category.all.any? %>
14
15
  <%= sortable_table_header :name => "Author", :sort => "created" %>
15
16
  <%= sortable_table_header :name => "Editor", :sort => "updated" %>
16
17
  <%= sortable_table_header :name => "Updated", :sort => "updated_at" %>
@@ -26,6 +27,9 @@
26
27
  <tr id="article-<%= article.id %>">
27
28
  <td><%= link_to h( article.title ), admin_article_path(article), :title => 'Edit this article' %></td>
28
29
  <td><%= content_status(article) %></td>
30
+ <% if Category.all.any? -%>
31
+ <td><%=h article.category.title unless article.category.nil? %></td>
32
+ <% end -%>
29
33
  <td><%= article.author %></td>
30
34
  <td><%= article.editor %></td>
31
35
  <td><%= article.updated_at.to_formatted_s(:short) %></td>
@@ -43,6 +47,7 @@
43
47
  <tr>
44
48
  <%= sortable_table_header :name => "Title", :sort => "title" %>
45
49
  <%= sortable_table_header :name => "Status", :sort => "published_at" %>
50
+ <%= sortable_table_header :name => "Category", :sort => "category" if Category.all.any? %>
46
51
  <%= sortable_table_header :name => "Author", :sort => "created_by" %>
47
52
  <%= sortable_table_header :name => "Editor", :sort => "updated_by" %>
48
53
  <%= sortable_table_header :name => "Updated", :sort => "updated_at" %>
@@ -55,5 +60,5 @@
55
60
  </tfoot>
56
61
  </table>
57
62
 
58
- <%= will_paginate %>
63
+ <%= will_paginate @articles %>
59
64
 
@@ -5,9 +5,9 @@
5
5
 
6
6
  <h1><%= @article.new_record? ? 'New' : 'Editing an' %> Article</h1>
7
7
 
8
- <% form_for([:admin, @article], :html => {:id => 'has-assets-form'}) do |f| %>
8
+ <% form_for(:article, @article, :url => polymorphic_path([:admin, @article]), :html => {:id => 'has-assets-form', :method => ( @article.new_record? ? :post : :put ) }) do |f| %>
9
9
  <%= f.error_messages %>
10
-
10
+
11
11
  <p>
12
12
  <%= f.label :title, 'Title*' %><br/>
13
13
  <%= f.text_field :title, :class => 'title' %>
@@ -28,7 +28,7 @@
28
28
  <% if Category.exists? %>
29
29
  <p>
30
30
  <%= f.label :category %>
31
- <%= f.collection_select :category_id, Category.all, :id, :title, :prompt => true %>
31
+ <%= f.collection_select :category_id, Category.all, :id, :title, :prompt => true %>
32
32
  </p>
33
33
  <% end -%>
34
34
  <p>
@@ -11,12 +11,12 @@
11
11
 
12
12
  <!-- so:main-content -->
13
13
  <div id="main-content">
14
-
14
+
15
15
  <dl id="articles">
16
16
  <%= render :partial => @articles %>
17
17
  </dl>
18
-
19
- <%= will_paginate(:previous_label => 'previous', :next_label => 'next') %>
20
-
18
+
19
+ <%= will_paginate(@articles, :previous_label => 'previous', :next_label => 'next') %>
20
+
21
21
  </div>
22
22
  <!-- eo:main-content -->
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{beef-articles}
8
- s.version = "0.4.14"
8
+ s.version = "0.4.15"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Steve England"]
12
- s.date = %q{2010-05-24}
12
+ s.date = %q{2010-06-23}
13
13
  s.email = %q{steve@wearebeef.co.uk}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -60,19 +60,19 @@ Gem::Specification.new do |s|
60
60
  s.homepage = %q{http://github.com/beef/articles}
61
61
  s.rdoc_options = ["--charset=UTF-8"]
62
62
  s.require_paths = ["lib"]
63
- s.rubygems_version = %q{1.3.7}
63
+ s.rubygems_version = %q{1.3.6}
64
64
  s.summary = %q{Article/Blogging engine}
65
65
  s.test_files = [
66
66
  "test/articles_test.rb",
67
- "test/test_helper.rb",
68
- "test/schema.rb"
67
+ "test/schema.rb",
68
+ "test/test_helper.rb"
69
69
  ]
70
70
 
71
71
  if s.respond_to? :specification_version then
72
72
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
73
73
  s.specification_version = 3
74
74
 
75
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
75
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
76
76
  s.add_runtime_dependency(%q<mbleigh-acts-as-taggable-on>, [">= 0"])
77
77
  s.add_runtime_dependency(%q<jackdempsey-acts_as_commentable>, [">= 0"])
78
78
  else
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beef-articles
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 4
9
- - 14
10
- version: 0.4.14
8
+ - 15
9
+ version: 0.4.15
11
10
  platform: ruby
12
11
  authors:
13
12
  - Steve England
@@ -15,18 +14,16 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-05-24 00:00:00 +01:00
17
+ date: 2010-06-23 00:00:00 +01:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: mbleigh-acts-as-taggable-on
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
24
  requirements:
27
25
  - - ">="
28
26
  - !ruby/object:Gem::Version
29
- hash: 3
30
27
  segments:
31
28
  - 0
32
29
  version: "0"
@@ -36,11 +33,9 @@ dependencies:
36
33
  name: jackdempsey-acts_as_commentable
37
34
  prerelease: false
38
35
  requirement: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
36
  requirements:
41
37
  - - ">="
42
38
  - !ruby/object:Gem::Version
43
- hash: 3
44
39
  segments:
45
40
  - 0
46
41
  version: "0"
@@ -106,31 +101,27 @@ rdoc_options:
106
101
  require_paths:
107
102
  - lib
108
103
  required_ruby_version: !ruby/object:Gem::Requirement
109
- none: false
110
104
  requirements:
111
105
  - - ">="
112
106
  - !ruby/object:Gem::Version
113
- hash: 3
114
107
  segments:
115
108
  - 0
116
109
  version: "0"
117
110
  required_rubygems_version: !ruby/object:Gem::Requirement
118
- none: false
119
111
  requirements:
120
112
  - - ">="
121
113
  - !ruby/object:Gem::Version
122
- hash: 3
123
114
  segments:
124
115
  - 0
125
116
  version: "0"
126
117
  requirements: []
127
118
 
128
119
  rubyforge_project:
129
- rubygems_version: 1.3.7
120
+ rubygems_version: 1.3.6
130
121
  signing_key:
131
122
  specification_version: 3
132
123
  summary: Article/Blogging engine
133
124
  test_files:
134
125
  - test/articles_test.rb
135
- - test/test_helper.rb
136
126
  - test/schema.rb
127
+ - test/test_helper.rb