pagination bootstrap update layout

This commit is contained in:
2014-08-21 16:29:29 +05:30
committed by Andreas Stephanides
parent 753d4e212f
commit 1d00b07719
20 changed files with 129 additions and 54 deletions

View File

@@ -103,3 +103,6 @@ gem 'themes_for_rails'
gem 'rubyzip'
gem 'acts_as_votable'
gem 'will_paginate'
gem 'bootstrap-will_paginate'

View File

@@ -0,0 +1,10 @@
jQuery ->
if $('#infinite-scrolling').size() > 0
$(window).on 'scroll', ->
more_posts_url = $('.pagination .next_page a').attr('href')
b=$(document).height() - $(window).height() - 60
if more_posts_url && $(window).scrollTop() > b
$('.pagination').html('<b> Loading...</b>')
$.getScript more_posts_url
return
return

View File

@@ -28,6 +28,7 @@ class HomeController < ApplicationController
def linksnotimplemented
render 'links_notimplemented'
end
def search
unless params['query'].nil? || params['query'].empty?
@@ -54,8 +55,8 @@ class HomeController < ApplicationController
end
end
def choose_contact_topics
File.open("config/contact_topic.yml",'w'){|f| f.write(params[:themen].to_yaml)}
redirect_to admin_home_index_path
File.open("config/contact_topic.yml",'w'){|f| f.write(params[:themen].to_yaml)}
redirect_to admin_home_index_path
end
end

View File

@@ -86,6 +86,11 @@ class NeuigkeitenController < ApplicationController
end
end
def mail_preview
@neuigkeit = Neuigkeit.find(params[:id])
authorize! :publish, @neuigkeit
render template: "news_mailer/neuigkeit_mail", layout: false
end
def edit
@neuigkeit = Neuigkeit.find(params[:id])
@@ -109,8 +114,12 @@ class NeuigkeitenController < ApplicationController
@nlink_search.flatten!
respond_to do |format|
format.html { render action:"show" }
format.js
end
render action:"show"
end
def create_link
@neuigkeit = Neuigkeit.find(params[:id])
@@ -118,7 +127,7 @@ class NeuigkeitenController < ApplicationController
Nlink.create(:link=>params[:link_type].constantize.find(params[:link_id]),:neuigkeit=>Neuigkeit.find(params[:id]))
@nlinks=@neuigkeit.nlinks
respond_to do |format|
format.html { edirect_to action:"show" }
format.html { redirect_to action:"show" }
format.js
end
end

View File

@@ -4,13 +4,18 @@ class RubrikenController < ApplicationController
def index
if can?(:showintern, Rubrik)
@rubriken = Rubrik.all
@neuigkeiten = Neuigkeit.recent
@neuigkeiten = Neuigkeit.paginate(page: params[:page], per_page:3)
else
@rubriken = Rubrik.where(:public=>true)
@neuigkeiten = Neuigkeit.public.recent
end
@calentries= @rubriken.collect(&:calentries).flatten
respond_to do |format|
format.html
format.js {render action: :show}
end
end
def intern
@@ -26,14 +31,17 @@ class RubrikenController < ApplicationController
@moderatoren=User.with_role(:newsmoderator,@rubrik)
@calentries= @rubrik.calentries
if can?(:showunpublished, Neuigkeit)
@neuigkeiten = @rubrik.neuigkeiten
@neuigkeiten = @rubrik.neuigkeiten.paginate(page: params[:page], per_page:3)
else
@neuigkeiten = @rubrik.neuigkeiten.published
@neuigkeiten = @rubrik.neuigkeiten.published.paginate(page: params[:page], per_page:3)
end
@toolbar_elements << {:text=>I18n.t('neuigkeit.new.title'), :path=> new_rubrik_neuigkeit_path(@rubrik),:hicon=>'icon-plus-sign'} if can? :verwalten, @rubrik
@toolbar_elements << {:text=>I18n.t('common.verwalten'), :path=>verwalten_rubrik_path(@rubrik),:icon=>:pencil} if can? :verwalten, @rubrik
respond_to do |format|
format.html
format.js
end
end

View File

@@ -1,23 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="http://glonass.htu.tuwien.ac.at/favicon.ico">
<!--<link rel="shortcut icon" href="http://www.fet.at/favicon.ico">-->
<title>Fetsite</title>
<link rel="shortcut icon" href="http://glonass.htu.tuwien.ac.at/favicon.ico">
<!--<link rel="shortcut icon" href="http://www.fet.at/favicon.ico">-->
<title>Fetsite</title>
<%= stylesheet_link_tag "themes/"+theme_name+"/application", :media => "all" unless theme_name.empty? %>
<%= stylesheet_link_tag "application", :media=>"all" if theme_name.empty? %>
<% theme_stylesheet_link_tag "test", :media => "all" %>
<% theme_stylesheet_link_tag "mod", :media=>"all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
<%= yield :header %>
</head>
<%= stylesheet_link_tag "themes/"+theme_name+"/application", :media => "all" unless theme_name.empty? %>
<%= stylesheet_link_tag "application", :media=>"all" if theme_name.empty? %>
<% theme_stylesheet_link_tag "test", :media => "all" %>
<% theme_stylesheet_link_tag "mod", :media=>"all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<div id="maincontainer" class="container-fluid">
<body>
<div id="maincontainer" class="container-fluid">
<div class="row-fluid">
<div class="span1 "></div>
<div class="span10 ">
@@ -27,7 +27,6 @@
<%= link_to home_index_path do %>
<span class="feticon-fet_logo fa-4x color-1"> </span>
<% end %>
</div>
<div id="menudiv" style="margin-top:12px">
@@ -56,7 +55,7 @@
<div class="span1">
</div>
</div>
</div>
</div>
</body>
</body>
</html>

View File

View File

@@ -1,5 +1,20 @@
<% if defined?(wrap_in) && !wrap_in.blank? %>
<%= content_tag wrap_in do %>
www
<% c =[:linkbox] %>
<% c << "color-"+neuigkeit.rubrik.color.to_s+"-dark" unless neuigkeit.rubrik.color.nil? %>
<%= link_to [neuigkeit.rubrik,neuigkeit], {class: c} do %>
<%= render :partial=>"neuigkeiten/compact",:locals=> {:neuigkeit=> neuigkeit} %>
<% end %>
<% end %>
<% else %>
<% c =[:linkbox] %>
<% c << "color-"+neuigkeit.rubrik.color.to_s+"-dark" unless neuigkeit.rubrik.color.nil? %>
<%= link_to [neuigkeit.rubrik,neuigkeit], {class: c} do %>
<%= render :partial=>"neuigkeiten/compact",:locals=> {:neuigkeit=> neuigkeit} %>
<% end %>
<% end %>

View File

@@ -1,11 +1,11 @@
<li>
<%= link_to nlink_list.link do %>
<div class="contentbox" >
<div class="contentbox" style="height:9em">
<% p = nlink_list.link_type.downcase.pluralize+"/nlink" %>
<%= raw(strip_links(render :partial=>p, :object=>nlink_list.link )) %>
</div>
<% end %>
</li>

View File

@@ -0,0 +1,5 @@
<div id="nlink_list_search">
<ul class="unstyled">
<%= render partial: "nlink_list_search", collection: nlink_list_search_whole %>
</ul>
</div>

View File

@@ -0,0 +1,15 @@
<div id="nlink_list">
<%= I18n.t("neuigkeit.sieheauch") %>
<div class="container-fluid">
<% nlink_list_whole.each_slice(2) do |row| %>
<div class="row-fluid">
<% row.each do |nl| %>
<div class="span6">
<%= render partial: "nlink_list", object: nl %>
</div>
<% end %>
</div>
<% end %>
</div>
</div>

View File

@@ -1,2 +1,2 @@
$('#nlink_list_search').html("");
$('#nlink_list').html("<%= escape_javascript( render partial:"nlink_list", collection: @nlinks )%>");
$('#nlink_list').replaceWith("<%= escape_javascript( render partial:"nlink_list_whole", object: @nlinks )%>");

View File

@@ -0,0 +1 @@
$('#nlink_list_search').replaceWith("<%= escape_javascript( render partial:"nlink_list_search_whole", object: @nlink_search )%>");

View File

@@ -27,18 +27,10 @@
<% end %>
<%= render 'layouts/pretty_toolbar', :object=> @toolbar_elements %>
</div>
<%= I18n.t("neuigkeit.sieheauch") %>
<ul class="unstyled">
<div id="nlink_list">
<%= render partial: "nlink_list", collection: @neuigkeit.nlinks %>
</div>
<div id="nlink_list_search">
<%= render partial: "nlink_list_search", collection: @nlink_search %>
</div>
</ul>
<%= render partial: 'nlink_list_whole', :object=>@neuigkeit.nlinks %>
<%= render partial: 'nlink_list_search_whole', object: @nlink_search %>
<% if can? :find_link, @neuigkeit %>
<%= semantic_form_for :find_link, :url=>find_link_rubrik_neuigkeit_path(@rubrik,@neuigkeit), :html=>{:id=>"search_form", :method=>'get'} do |f| %>
<%= semantic_form_for :find_link, :url=>find_link_rubrik_neuigkeit_path(@rubrik,@neuigkeit), :html=>{:id=>"search_form", :method=>'get'} , :remote=> true do |f| %>
<%= f.input :query, :input_html => { :name => 'query' },:label=>false %>
<% end %>
<% end %>

View File

@@ -1,4 +1,6 @@
<h1>
<%= @neuigkeit.title%>
</h1>
<%= raw(@neuigkeit.text) %>
<h1>
<%= @neuigkeit.title%>
</h1>
<%= image_tag @neuigkeit.picture.big_thumb.url %>
<%= raw(@neuigkeit.text) %>
<p> Eine Nachricht aus deiner Fachschaft! wenn du diese Neuigkeiten nicht mehr bekommen willst hast du leider Pech gehabt es gibt keine Möglichkeit aus der FET wieder auszutreten.</p>

View File

@@ -12,12 +12,17 @@
<div class="span9">
<ul class="unstyled linkbox-list" style="max-width:70em">
<ul class="unstyled linkbox-list" style="max-width:70em" id="neuigkeiten">
<% @neuigkeiten.each do |n| %>
<li><%= render n if can?(:show, n) %> </li>
<% end %>
</ul>
<div id="infinite-scrolling">
<%= will_paginate @neuigkeiten %>
</div>
</div>
<div class="span3">
<%= render 'calendars/calentries', :object=>@calentries %>
</div>

View File

@@ -19,16 +19,18 @@
<div class="row-fluid">
<div class="span9">
<% @neuigkeiten.each_slice(1) do |row| %>
<ul class="unstyled" style="max-width:70em">
<% row.each do |neuigkeit| %>
<ul class="unstyled linkbox-list" style="max-width:70em" id="neuigkeiten">
<% @neuigkeiten.each do |neuigkeit| %>
<li>
<%= render neuigkeit %>
</li>
<% end %>
</ul>
<% end %>
</ul>
<div id="infinite-scrolling">
<%= will_paginate @neuigkeiten %>
</div>
</div>
<div class="span3">
<%= render 'calendars/calentries', :object=>@calentries %>

View File

@@ -0,0 +1,7 @@
$('#neuigkeiten').append('<%= j render @neuigkeiten, :locals => { :wrap_in => :li} %>');
<% if @neuigkeiten.next_page %>
$('.pagination').replaceWith('<%= j will_paginate @neuigkeiten %>');
<% else %>
$(window).off('scroll');
$('.pagination').remove();
<% end %>

View File

@@ -127,6 +127,7 @@ Fetsite::Application.routes.draw do
get 'find_link'
get 'publish_to_facebook'
get 'mail_to_fet'
get 'mail_preview'
end
end
end