added public timeline
This commit is contained in:
parent
0e52a9aef8
commit
2251a21872
|
@ -0,0 +1,9 @@
|
||||||
|
class PublicController < ApplicationController
|
||||||
|
def index
|
||||||
|
@timeline = Answer.all.reverse_order.paginate(page: params[:page])
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,2 @@
|
||||||
|
module PublicHelper
|
||||||
|
end
|
|
@ -0,0 +1,16 @@
|
||||||
|
.container.j2-page
|
||||||
|
.col-md-3.col-sm-3.hidden-xs
|
||||||
|
= render 'shared/links'
|
||||||
|
.col-md-9.col-xs-12.col-sm-9
|
||||||
|
= render 'layouts/messages'
|
||||||
|
|
||||||
|
#timeline
|
||||||
|
- @timeline.each do |answer|
|
||||||
|
= render 'shared/answerbox', a: answer
|
||||||
|
|
||||||
|
#pagination= will_paginate @timeline, renderer: BootstrapPagination::Rails, page_links: false
|
||||||
|
|
||||||
|
- if @timeline.next_page
|
||||||
|
%button#load-more-btn.btn.btn-default{type: :button, data: { current_page: @timeline.current_page }}
|
||||||
|
Load more
|
||||||
|
.visible-xs= render 'shared/links'
|
|
@ -0,0 +1,8 @@
|
||||||
|
$('#timeline').append('<% @timeline.each do |answer|
|
||||||
|
%><%= j render 'shared/answerbox', a: answer
|
||||||
|
%><% end %>');
|
||||||
|
<% if @timeline.next_page %>
|
||||||
|
$('#pagination').html('<%= j will_paginate @timeline, renderer: BootstrapPagination::Rails, page_links: false %>');
|
||||||
|
<% else %>
|
||||||
|
$('#pagination, #load-more-btn').remove();
|
||||||
|
<% end %>
|
|
@ -40,6 +40,8 @@ Rails.application.routes.draw do
|
||||||
match '/create_comment', to: 'comment#create', via: :post, as: :create_comment
|
match '/create_comment', to: 'comment#create', via: :post, as: :create_comment
|
||||||
end
|
end
|
||||||
|
|
||||||
|
match '/public', to: 'public#index', via: :get, as: :public_timeline
|
||||||
|
|
||||||
match '/inbox', to: 'inbox#show', via: 'get'
|
match '/inbox', to: 'inbox#show', via: 'get'
|
||||||
|
|
||||||
match '/user/:username(/p/:page)', to: 'user#show', via: 'get', defaults: {page: 1}
|
match '/user/:username(/p/:page)', to: 'user#show', via: 'get', defaults: {page: 1}
|
||||||
|
|
Loading…
Reference in New Issue