From 3f26c0e3d714b07d34088b5ceedb7cc6d378d508 Mon Sep 17 00:00:00 2001 From: Diaspora Europe Date: Wed, 14 Mar 2012 15:19:24 +0100 Subject: [PATCH 1/3] mobile: added will paginate for bootstrap --- Gemfile | 2 +- app/views/contacts/index.mobile.haml | 2 +- app/views/notifications/index.mobile.haml | 2 +- app/views/people/index.mobile.haml | 2 +- config/initializers/will_paginate.rb | 11 +++++++++++ 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 753f41d90..2c60443ac 100644 --- a/Gemfile +++ b/Gemfile @@ -105,7 +105,7 @@ gem 'typhoeus' gem 'haml' gem 'mobile-fu' gem 'sass' -gem 'will_paginate' +gem 'bootstrap-will_paginate' gem 'client_side_validations' # web diff --git a/app/views/contacts/index.mobile.haml b/app/views/contacts/index.mobile.haml index b0c74893a..aa6044cc3 100644 --- a/app/views/contacts/index.mobile.haml +++ b/app/views/contacts/index.mobile.haml @@ -17,7 +17,7 @@ - if @contacts.size > 0 - for contact in @contacts = render 'people/person', :person => contact.person, :contact => contact - = will_paginate @contacts + = will_paginate @contacts, :renderer => WillPaginate::ActionView::BootstrapLinkRenderer - else %h3.no_contacts = t('.no_contacts') diff --git a/app/views/notifications/index.mobile.haml b/app/views/notifications/index.mobile.haml index 6ea77428d..cf1159f9d 100644 --- a/app/views/notifications/index.mobile.haml +++ b/app/views/notifications/index.mobile.haml @@ -21,4 +21,4 @@ .time = time_ago_in_words(note.created_at) - = will_paginate @notifications + = will_paginate @notifications, :renderer => WillPaginate::ActionView::BootstrapLinkRenderer diff --git a/app/views/people/index.mobile.haml b/app/views/people/index.mobile.haml index 7101e929b..d93c79d04 100644 --- a/app/views/people/index.mobile.haml +++ b/app/views/people/index.mobile.haml @@ -32,5 +32,5 @@ - for hash in @hashes = render :partial => 'people/person', :locals => hash - = will_paginate @people + = will_paginate @people, :renderer => WillPaginate::ActionView::BootstrapLinkRenderer diff --git a/config/initializers/will_paginate.rb b/config/initializers/will_paginate.rb index dfed3fe9e..b10133edc 100644 --- a/config/initializers/will_paginate.rb +++ b/config/initializers/will_paginate.rb @@ -1 +1,12 @@ require 'will_paginate/array' + +# Optional for Bootstrap :renderer => WillPaginate::ActionView::BootstrapLinkRenderer +# https://github.com/yrgoldteeth/bootstrap-will_paginate + +module WillPaginate + module ActionView + def will_paginate(collection = nil, options = { :renderer => WillPaginate::ActionView::LinkRenderer } ) + super.try :html_safe + end + end +end From fe6505862486500f34019d8aee08c522013d5bdf Mon Sep 17 00:00:00 2001 From: Diaspora Europe Date: Thu, 15 Mar 2012 12:26:47 +0100 Subject: [PATCH 2/3] use will paginate, added renderer for bootstrap --- Gemfile | 2 +- config/initializers/will_paginate.rb | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 2c60443ac..753f41d90 100644 --- a/Gemfile +++ b/Gemfile @@ -105,7 +105,7 @@ gem 'typhoeus' gem 'haml' gem 'mobile-fu' gem 'sass' -gem 'bootstrap-will_paginate' +gem 'will_paginate' gem 'client_side_validations' # web diff --git a/config/initializers/will_paginate.rb b/config/initializers/will_paginate.rb index b10133edc..69626fd72 100644 --- a/config/initializers/will_paginate.rb +++ b/config/initializers/will_paginate.rb @@ -8,5 +8,25 @@ module WillPaginate def will_paginate(collection = nil, options = { :renderer => WillPaginate::ActionView::LinkRenderer } ) super.try :html_safe end + + class BootstrapLinkRenderer < LinkRenderer + protected + + def html_container(html) + tag :div, tag(:ul, html), container_attributes + end + + def page_number(page) + tag :li, link(page, page, :rel => rel_value(page)), :class => ('active' if page == current_page) + end + + def gap + tag :li, link(super, '#'), :class => 'disabled' + end + + def previous_or_next_page(page, text, classname) + tag :li, link(text, page || '#'), :class => [classname[0..3], classname, ('disabled' unless page)].join(' ') + end + end end end From 563e94b8047e83d5ab299958ddcce582a1f39116 Mon Sep 17 00:00:00 2001 From: Diaspora Europe Date: Thu, 15 Mar 2012 16:43:46 +0100 Subject: [PATCH 3/3] let date looks nice --- app/views/notifications/index.mobile.haml | 3 ++- public/stylesheets/sass/mobile.scss | 12 ++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/views/notifications/index.mobile.haml b/app/views/notifications/index.mobile.haml index cf1159f9d..c19d28b47 100644 --- a/app/views/notifications/index.mobile.haml +++ b/app/views/notifications/index.mobile.haml @@ -8,7 +8,8 @@ - @group_days.each do |day, notes| %li .notification_day_header - = day + %span.label + = day %ul.notifications_for_day - notes.each do |note| .stream_element{:data=>{:guid => note.id}, :class => "#{note.unread ? 'unread' : ''}"} diff --git a/public/stylesheets/sass/mobile.scss b/public/stylesheets/sass/mobile.scss index a5a54d1ba..cc3ce2919 100644 --- a/public/stylesheets/sass/mobile.scss +++ b/public/stylesheets/sass/mobile.scss @@ -601,9 +601,17 @@ select { .navbar-fixed-top { position: fixed !important; - max-height: 45px !important; min-height: 45px !important; height: 45px !important; overflow: hidden; -} \ No newline at end of file +} + +.notifications { + list-style: none; +} + +.notification_day_header { + margin-bottom: 5px; +} +