added public timeline

This commit is contained in:
nilsding 2014-12-11 06:39:35 +01:00
parent 0e52a9aef8
commit 2251a21872
5 changed files with 37 additions and 0 deletions

View File

@ -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

View File

@ -0,0 +1,2 @@
module PublicHelper
end

View File

@ -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'

View File

@ -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 %>

View File

@ -40,6 +40,8 @@ Rails.application.routes.draw do
match '/create_comment', to: 'comment#create', via: :post, as: :create_comment
end
match '/public', to: 'public#index', via: :get, as: :public_timeline
match '/inbox', to: 'inbox#show', via: 'get'
match '/user/:username(/p/:page)', to: 'user#show', via: 'get', defaults: {page: 1}