forked from saurabh/orbit4-5
fix for pagination and also added data-module in body
This commit is contained in:
parent
e73ebe9037
commit
3a1fb9c72b
|
@ -354,14 +354,15 @@ class PagesController < ApplicationController
|
|||
if @editmode
|
||||
session[:mobile] = $temp_mobile
|
||||
end
|
||||
format_date(final_html_for_render) rescue final_html_for_render
|
||||
format_date(final_html_for_render,(original_view == "home" ? "home" : page.module)) rescue final_html_for_render
|
||||
end
|
||||
|
||||
def format_date(html)
|
||||
def format_date(html,module_key)
|
||||
doc = Nokogiri::HTML(html, nil, "UTF-8")
|
||||
doc.css("body").first.set_attribute("data-module",module_key) rescue nil
|
||||
dates = doc.css("*[date-format]")
|
||||
if dates.blank?
|
||||
return html
|
||||
return doc.to_html
|
||||
else
|
||||
dates.each do |d|
|
||||
format = d.attributes["date-format"].value
|
||||
|
|
|
@ -238,7 +238,6 @@ module ApplicationHelper
|
|||
html = html.gsub("{{#{key}}}",value.to_s)
|
||||
html = html.gsub("%7B%7B#{key}%7D%7D",value.to_s)
|
||||
end
|
||||
|
||||
total_pages = data['total_pages'].to_i rescue 1
|
||||
if total_pages > 1
|
||||
html = html.gsub("{{pagination_goes_here}}",create_pagination(total_pages))
|
||||
|
@ -424,12 +423,14 @@ module ApplicationHelper
|
|||
file = File.open(file)
|
||||
doc = Nokogiri::HTML(file, nil, "UTF-8")
|
||||
file.close
|
||||
querystring = request.GET rescue {}
|
||||
querystring.delete("page_no")
|
||||
paginationobj = doc.css("*[data-pagination='true']").first
|
||||
in_html = first = last = nextpage = prevpage = paginationobj.inner_html
|
||||
f_html = ""
|
||||
current_page_number = OrbitHelper.page_number
|
||||
if current_page_number > 1
|
||||
first = first.gsub("%7B%7Bpagination_link%7D%7D","?page_no=1")
|
||||
first = first.gsub("%7B%7Bpagination_link%7D%7D","?page_no=1&#{querystring.to_query}")
|
||||
first = first.gsub("{{page_number}}","First")
|
||||
first = first.gsub("{{pagination_active}}","")
|
||||
f_html = f_html + first
|
||||
|
@ -447,25 +448,25 @@ module ApplicationHelper
|
|||
end_number = end_number > total_pages ? total_pages : end_number
|
||||
(start_number..end_number).each do |i|
|
||||
h = in_html
|
||||
h = h.gsub("%7B%7Bpagination_link%7D%7D","?page_no=#{i.to_s}")
|
||||
h = h.gsub("%7B%7Bpagination_link%7D%7D","?page_no=#{i.to_s}&#{querystring.to_query}")
|
||||
h = h.gsub("{{page_number}}",i.to_s)
|
||||
h = h.gsub("{{pagination_active}}",(i == current_page_number ? "active" : ""))
|
||||
f_html = f_html + h
|
||||
end
|
||||
if current_page_number > 1
|
||||
prevpage = prevpage.gsub("%7B%7Bpagination_link%7D%7D","?page_no=#{current_page_number - 1}")
|
||||
prevpage = prevpage.gsub("%7B%7Bpagination_link%7D%7D","?page_no=#{current_page_number - 1}&#{querystring.to_query}")
|
||||
prevpage = prevpage.gsub("{{page_number}}","«")
|
||||
prevpage = prevpage.gsub("{{pagination_active}}","")
|
||||
f_html = f_html + prevpage
|
||||
end
|
||||
|
||||
if current_page_number < total_pages
|
||||
nextpage = nextpage.gsub("%7B%7Bpagination_link%7D%7D","?page_no=#{current_page_number + 1}")
|
||||
nextpage = nextpage.gsub("%7B%7Bpagination_link%7D%7D","?page_no=#{current_page_number + 1}&#{querystring.to_query}")
|
||||
nextpage = nextpage.gsub("{{page_number}}","»")
|
||||
nextpage = nextpage.gsub("{{pagination_active}}","")
|
||||
f_html = f_html + nextpage
|
||||
|
||||
last = last.gsub("%7B%7Bpagination_link%7D%7D","?page_no=#{total_pages}")
|
||||
last = last.gsub("%7B%7Bpagination_link%7D%7D","?page_no=#{total_pages}&#{querystring.to_query}")
|
||||
last = last.gsub("{{page_number}}","Last")
|
||||
last = last.gsub("{{pagination_active}}","")
|
||||
f_html = f_html + last
|
||||
|
|
Loading…
Reference in New Issue