Skip to content

Commit

Permalink
Merge branch 'master' of github.com:fdv/publify
Browse files Browse the repository at this point in the history
  • Loading branch information
Frédéric de Villamil committed Sep 15, 2013
2 parents e1c463c + c13ebcd commit a4defc2
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 282 deletions.
13 changes: 4 additions & 9 deletions app/controllers/articles_controller.rb
Expand Up @@ -14,17 +14,12 @@ class ArticlesController < ContentController

def index
conditions = (Blog.default.statuses_in_timeline) ? ["type in (?, ?)", "Article", "Note"] : ["type = ?", "Article"]

respond_to do |format|
format.html { @limit = this_blog.limit_article_display }
format.rss { @limit = this_blog.limit_rss_display }
format.atom { @limit = this_blog.limit_rss_display }
end

limit = this_blog.per_page(params[:format])
unless params[:year].blank?
@articles = Content.published_at(params.values_at(:year, :month, :day)).where(conditions).page(params[:page]).per(@limit)
@articles = Content.published_at(params.values_at(:year, :month, :day)).where(conditions).page(params[:page]).per(limit)
else
@articles = Content.published.where(conditions).page(params[:page]).per(@limit)
@articles = Content.published.where(conditions).page(params[:page]).per(limit)
end

@page_title = this_blog.home_title_template
Expand Down Expand Up @@ -56,7 +51,7 @@ def index
end

def search
@articles = this_blog.articles_matching(params[:q], :page => params[:page], :per_page => @limit)
@articles = this_blog.articles_matching(params[:q], page: params[:page], per_page: this_blog.per_page(params[:format]) )
return error(_("No posts found..."), :status => 200) if @articles.empty?
@page_title = this_blog.search_title_template.to_title(@articles, this_blog, params)
@description = this_blog.search_desc_template.to_title(@articles, this_blog, params)
Expand Down
10 changes: 2 additions & 8 deletions app/controllers/authors_controller.rb
Expand Up @@ -4,14 +4,8 @@ class AuthorsController < ContentController
def show
@author = User.find_by_login(params[:id])
raise ActiveRecord::RecordNotFound unless @author

respond_to do |format|
format.html { @limit = this_blog.limit_article_display }
format.rss { @limit = this_blog.limit_rss_display }
format.atom { @limit = this_blog.limit_rss_display }
end

@articles = @author.articles.published.page(params[:page]).per(@limit)

@articles = @author.articles.published.page(params[:page]).per(this_blog.per_page(params[:format]))
@page_title = this_blog.author_title_template.to_title(@author, this_blog, params)
@keywords = this_blog.meta_keywords
@description = this_blog.author_desc_template.to_title(@author, this_blog, params)
Expand Down
11 changes: 3 additions & 8 deletions app/controllers/feedback_controller.rb
Expand Up @@ -33,8 +33,9 @@ def index
render :text => 'this space left blank'
end
end
format.atom { render_feed 'atom', get_feedback }
format.rss { render_feed 'rss', get_feedback }
feedbacks = Feedback.from(controller_name, params[:article_id]).limit(this_blog.per_page(params[:format]))
format.atom { render_feed 'atom', feedbacks }
format.rss { render_feed 'rss', feedbacks }
end
end

Expand All @@ -46,10 +47,4 @@ def render_feed(format, collection)
render "index_#{format}_feed"
end

private

def get_feedback
@items = Feedback.from(controller_name, params[:article_id]).limit(this_blog.rss_limit_params[:limit])
end

end
9 changes: 7 additions & 2 deletions app/models/blog.rb
Expand Up @@ -205,10 +205,15 @@ def file_url(filename)
end
end

def articles_matching(query, args={})
def articles_matching(query, args={})
Article.search(query, args)
end

def per_page(format)
return limit_article_display if format.nil? || format == 'html'
limit_rss_display
end

def rss_limit_params
limit = limit_rss_display.to_i
return limit.zero? \
Expand Down Expand Up @@ -265,7 +270,7 @@ def split_base_url
raise "Invalid base_url: #{self.base_url}"
end
@split_base_url = { :protocol => $1, :host_with_port => $2,
:root_path => $3.gsub(%r{/$},'') }
:root_path => $3.gsub(%r{/$},'') }
end
@split_base_url
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Expand Up @@ -16,7 +16,7 @@ class User < ActiveRecord::Base
:source => 'notify_content',
:uniq => true

has_many :articles, :order => 'created_at DESC'
has_many :articles

serialize :settings, Hash

Expand Down

0 comments on commit a4defc2

Please sign in to comment.