OSDN Git Service
(root)
/
pettanr
/
pettanr.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
dbb55e0
)
t#31521:fix story pager
author
yasushiito
<yas@pen-chan.jp>
Thu, 22 Aug 2013 07:35:07 +0000
(16:35 +0900)
committer
yasushiito
<yas@pen-chan.jp>
Thu, 22 Aug 2013 07:35:07 +0000
(16:35 +0900)
app/controllers/stories_controller.rb
patch
|
blob
|
history
app/models/story.rb
patch
|
blob
|
history
app/views/stories/comic.html.erb
patch
|
blob
|
history
spec/models/speech_balloon_spec.rb
patch
|
blob
|
history
diff --git
a/app/controllers/stories_controller.rb
b/app/controllers/stories_controller.rb
index
8d1d1e3
..
ca77f0d
100644
(file)
--- a/
app/controllers/stories_controller.rb
+++ b/
app/controllers/stories_controller.rb
@@
-40,7
+40,20
@@
class StoriesController < ApplicationController
@stories = Story.play_list(@comic, @author, @offset, @panel_count)
respond_to do |format|
format.html {
@stories = Story.play_list(@comic, @author, @offset, @panel_count)
respond_to do |format|
format.html {
- @paginate = Story.play_list_paginate(@comic, @offset, @panel_count)
+ @prev_offset = if @offset > 0
+ if @offset - @panel_count < 0
+ 0
+ else
+ @offset - @panel_count
+ end
+ else
+ nil
+ end
+ @next_offset = if @offset + @panel_count > cnt
+ nil
+ else
+ @offset + @panel_count
+ end
if @author
@new_panels = Panel.mylist(@author, 1, 5)
end
if @author
@new_panels = Panel.mylist(@author, 1, 5)
end
diff --git
a/app/models/story.rb
b/app/models/story.rb
index
ddc52a3
..
cd67cc3
100644
(file)
--- a/
app/models/story.rb
+++ b/
app/models/story.rb
@@
-113,9
+113,6
@@
class Story < ActiveRecord::Base
Story.where(self.himlist_where(au)).includes(Story.list_opt).order('stories.updated_at desc').offset((page -1) * page_size).limit(page_size)
end
Story.where(self.himlist_where(au)).includes(Story.list_opt).order('stories.updated_at desc').offset((page -1) * page_size).limit(page_size)
end
- def self.play_list_paginate comic, author, offset = 0, limit = Story.default_panel_size
- end
-
def self.list_paginate page = 1, page_size = self.default_page_size
Kaminari.paginate_array(Array.new(Story.where(self.list_where()).includes(Story.list_opt).count, nil)).page(page).per(page_size)
end
def self.list_paginate page = 1, page_size = self.default_page_size
Kaminari.paginate_array(Array.new(Story.where(self.list_where()).includes(Story.list_opt).count, nil)).page(page).per(page_size)
end
diff --git
a/app/views/stories/comic.html.erb
b/app/views/stories/comic.html.erb
index
b0a13ea
..
631f6f0
100644
(file)
--- a/
app/views/stories/comic.html.erb
+++ b/
app/views/stories/comic.html.erb
@@
-13,6
+13,15
@@
<%= render 'footer', :story => story, :author => @author %>
<% end %>
<%= render 'licensed_pictures', :licensed_pictures => Story.licensed_pictures(@stories) %>
<%= render 'footer', :story => story, :author => @author %>
<% end %>
<%= render 'licensed_pictures', :licensed_pictures => Story.licensed_pictures(@stories) %>
+
+ <% if @prev_offset -%>
+ <%= link_to h('<<prev'), comic_story_path(@comic, {:offset => @prev_offset, :count => @panel_count}) %>
+ <% end %>
+
+ <% if @next_offset -%>
+ <%= link_to h('next>>'), comic_story_path(@comic, {:offset => @next_offset, :count => @panel_count}) %>
+ <% end %>
+
<% end %>
<% if @comic.own? @author -%>
<h3><%= t('stories.comic.new_panels') -%></h3>
<% end %>
<% if @comic.own? @author -%>
<h3><%= t('stories.comic.new_panels') -%></h3>
diff --git
a/spec/models/speech_balloon_spec.rb
b/spec/models/speech_balloon_spec.rb
index
47e1afb
..
701f1c6
100644
(file)
--- a/
spec/models/speech_balloon_spec.rb
+++ b/
spec/models/speech_balloon_spec.rb
@@
-295,7
+295,7
@@
describe SpeechBalloon do
end
context 'DBに5件あって1ページの件数を2件に変えたとして' do
before do
end
context 'DBに5件あって1ページの件数を2件に変えたとして' do
before do
- @sb2 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 1, :speech_balloon_template_id => @speech_balloon_template.id
+ @sb2 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 1, :speech_balloon_template_id => @speech_balloon_template.id
, :updated_at => Time.now + 100
@speech2 = @sb2.build_speech(
FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
)
@speech2 = @sb2.build_speech(
FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
)
@@
-304,7
+304,7
@@
describe SpeechBalloon do
)
@sb2.boost
@sb2.save!
)
@sb2.boost
@sb2.save!
- @sb3 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 2, :speech_balloon_template_id => @speech_balloon_template.id
+ @sb3 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 2, :speech_balloon_template_id => @speech_balloon_template.id
, :updated_at => Time.now + 200
@speech3 = @sb3.build_speech(
FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
)
@speech3 = @sb3.build_speech(
FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
)
@@
-313,7
+313,7
@@
describe SpeechBalloon do
)
@sb3.boost
@sb3.save!
)
@sb3.boost
@sb3.save!
- @sb4 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 3, :speech_balloon_template_id => @speech_balloon_template.id
+ @sb4 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 3, :speech_balloon_template_id => @speech_balloon_template.id
, :updated_at => Time.now + 300
@speech4 = @sb4.build_speech(
FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
)
@speech4 = @sb4.build_speech(
FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
)
@@
-322,7
+322,7
@@
describe SpeechBalloon do
)
@sb4.boost
@sb4.save!
)
@sb4.boost
@sb4.save!
- @sb5 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 4, :speech_balloon_template_id => @speech_balloon_template.id
+ @sb5 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 4, :speech_balloon_template_id => @speech_balloon_template.id
, :updated_at => Time.now + 400
@speech5 = @sb5.build_speech(
FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
)
@speech5 = @sb5.build_speech(
FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
)
@@
-419,7
+419,7
@@
describe SpeechBalloon do
end
context 'DBに5件あって1ページの件数を2件に変えたとして' do
before do
end
context 'DBに5件あって1ページの件数を2件に変えたとして' do
before do
- @sb2 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 1, :speech_balloon_template_id => @speech_balloon_template.id
+ @sb2 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 1, :speech_balloon_template_id => @speech_balloon_template.id
, :updated_at => Time.now + 100
@speech2 = @sb2.build_speech(
FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
)
@speech2 = @sb2.build_speech(
FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
)
@@
-428,7
+428,7
@@
describe SpeechBalloon do
)
@sb2.boost
@sb2.save!
)
@sb2.boost
@sb2.save!
- @sb3 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 2, :speech_balloon_template_id => @speech_balloon_template.id
+ @sb3 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 2, :speech_balloon_template_id => @speech_balloon_template.id
, :updated_at => Time.now + 200
@speech3 = @sb3.build_speech(
FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
)
@speech3 = @sb3.build_speech(
FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
)
@@
-437,7
+437,7
@@
describe SpeechBalloon do
)
@sb3.boost
@sb3.save!
)
@sb3.boost
@sb3.save!
- @sb4 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 3, :speech_balloon_template_id => @speech_balloon_template.id
+ @sb4 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 3, :speech_balloon_template_id => @speech_balloon_template.id
, :updated_at => Time.now + 300
@speech4 = @sb4.build_speech(
FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
)
@speech4 = @sb4.build_speech(
FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
)
@@
-446,7
+446,7
@@
describe SpeechBalloon do
)
@sb4.boost
@sb4.save!
)
@sb4.boost
@sb4.save!
- @sb5 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 4, :speech_balloon_template_id => @speech_balloon_template.id
+ @sb5 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 4, :speech_balloon_template_id => @speech_balloon_template.id
, :updated_at => Time.now + 400
@speech5 = @sb5.build_speech(
FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
)
@speech5 = @sb5.build_speech(
FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
)