Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(WIP)Move some controller code to models (#519)
* Remove trailing white spaces and unnecessary blank lines * Remove basic rubocop offenses * add few maps tests * refactor maps controller * fix 'line too long' rubocop offense
- Loading branch information
1 parent
d58e237
commit 0a8813c
Showing
20 changed files
with
262 additions
and
261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,56 @@ | ||
class FeedsController < ApplicationController | ||
|
||
def all | ||
#(Warpable.all + Map.all).sort_by(&:created_at) | ||
@maps = Map.find(:all, | ||
:order => "id DESC",:limit => 20, | ||
:conditions => {:archived => false, :password => ''}, | ||
:joins => [:user, :warpables], | ||
:group => "maps.id") | ||
render :layout => false, :template => "feeds/all" | ||
response.headers["Content-Type"] = "application/xml; charset=utf-8" | ||
# (Warpable.all + Map.all).sort_by(&:created_at) | ||
@maps = Map.find(:all, order: 'id DESC', limit: 20, | ||
conditions: { archived: false, password: '' }, | ||
joins: %i[user warpables], | ||
group: 'maps.id') | ||
render layout: false, template: 'feeds/all' | ||
response.headers['Content-Type'] = 'application/xml; charset=utf-8' | ||
end | ||
|
||
def clean | ||
@maps = Map.order(id: :desc) | ||
.limit(20) | ||
.where(archived: false, password: '') | ||
.joins(:warpables) | ||
.group("maps.id") | ||
render layout: false, template: "feeds/clean" | ||
response.headers["Content-Type"] = "application/xml; charset=utf-8" | ||
.limit(20) | ||
.where(archived: false, password: '') | ||
.joins(:warpables) | ||
.group('maps.id') | ||
render layout: false, template: 'feeds/clean' | ||
response.headers['Content-Type'] = 'application/xml; charset=utf-8' | ||
end | ||
|
||
def license | ||
@maps = Map.order(id: :desc) | ||
.limit(20) | ||
.where(archived: false, password: '', license: params[:id]) | ||
.joins(:warpables) | ||
.group("maps.id") | ||
render layout: false, template: "feeds/license" | ||
response.headers["Content-Type"] = "application/xml; charset=utf-8" | ||
@maps = Map.order(id: :desc) | ||
.limit(20) | ||
.where(archived: false, password: '', license: params[:id]) | ||
.joins(:warpables) | ||
.group('maps.id') | ||
render layout: false, template: 'feeds/license' | ||
response.headers['Content-Type'] = 'application/xml; charset=utf-8' | ||
end | ||
|
||
def author | ||
@maps = Map.find_all_by_author(params[:id],:order => "id DESC", :conditions => {:archived => false, :password => ''},:joins => :warpables, :group => "maps.id") | ||
@maps = Map.find_all_by_author(params[:id], | ||
order: 'id DESC', | ||
conditions: { archived: false, password: '' }, | ||
joins: :warpables, group: 'maps.id') | ||
images = [] | ||
@maps.each do |map| | ||
images = images + map.warpables | ||
images += map.warpables | ||
end | ||
@feed = (@maps + images).sort_by(&:created_at) | ||
render :layout => false, :template => "feeds/author" | ||
response.headers["Content-Type"] = "application/xml; charset=utf-8" | ||
render layout: false, template: 'feeds/author' | ||
response.headers['Content-Type'] = 'application/xml; charset=utf-8' | ||
end | ||
|
||
def tag | ||
@tag = Tag.find_by_name params[:id] | ||
if @tag | ||
@maps = @tag.maps.paginate(:page => params[:page], :per_page => 24) | ||
render :layout => false, :template => "feeds/tag" | ||
response.headers["Content-Type"] = "application/xml; charset=utf-8" | ||
@maps = @tag.maps.paginate(page: params[:page], per_page: 24) | ||
render layout: false, template: 'feeds/tag' | ||
response.headers['Content-Type'] = 'application/xml; charset=utf-8' | ||
else | ||
render text: "No maps with tag #{params[:id]}" | ||
end | ||
end | ||
|
||
end |
Oops, something went wrong.