forked from saurabh/orbit4-5
date formating made easy for designers and also sitemap style changed
This commit is contained in:
parent
9288d66660
commit
c2fe693ceb
|
@ -0,0 +1,13 @@
|
||||||
|
.sitemap-list {
|
||||||
|
padding-left: 1em;
|
||||||
|
li {
|
||||||
|
line-height: 1.5;
|
||||||
|
margin-bottom: 0.8em;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.sitemap-list.level-2,
|
||||||
|
.sitemap-list.level-3 {
|
||||||
|
margin: 12px 0;
|
||||||
|
padding-left: 2em;
|
||||||
|
}
|
|
@ -353,7 +353,22 @@ class PagesController < ApplicationController
|
||||||
if @editmode
|
if @editmode
|
||||||
session[:mobile] = $temp_mobile
|
session[:mobile] = $temp_mobile
|
||||||
end
|
end
|
||||||
final_html_for_render
|
format_date(final_html_for_render) rescue final_html_for_render
|
||||||
|
end
|
||||||
|
|
||||||
|
def format_date(html)
|
||||||
|
doc = Nokogiri::HTML(html, nil, "UTF-8")
|
||||||
|
dates = doc.css("*[date-format]")
|
||||||
|
if dates.blank?
|
||||||
|
return html
|
||||||
|
else
|
||||||
|
dates.each do |d|
|
||||||
|
format = d.attributes["date-format"].value
|
||||||
|
date = DateTime.parse(d.inner_text)
|
||||||
|
d.inner_html = d.inner_html.gsub(d.inner_text, " " + date.strftime(format))
|
||||||
|
end
|
||||||
|
return doc.to_html
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_widget_path(widget)
|
def get_widget_path(widget)
|
||||||
|
|
|
@ -376,14 +376,23 @@ module ApplicationHelper
|
||||||
|
|
||||||
def render_sitemap
|
def render_sitemap
|
||||||
items = action_data
|
items = action_data
|
||||||
def node(items)
|
def node(items, level)
|
||||||
html = "<ul>"
|
class_name = nil
|
||||||
|
case level
|
||||||
|
when 0
|
||||||
|
class_name = "sitemap-list level-1"
|
||||||
|
when 1
|
||||||
|
class_name = "sitemap-list level-2"
|
||||||
|
when 2
|
||||||
|
class_name = "sitemap-list level-3"
|
||||||
|
end
|
||||||
|
html = "<ul class='#{class_name}'>"
|
||||||
items.each do |key,item|
|
items.each do |key,item|
|
||||||
if item["children"] && !item["children"].empty?
|
if item["children"] && !item["children"].empty?
|
||||||
url = item["url"]
|
url = item["url"]
|
||||||
target = item["target"]
|
target = item["target"]
|
||||||
html = html + "<li><a href='#{url}' target='#{target}'>#{key}</a>"
|
html = html + "<li><a href='#{url}' target='#{target}'>#{key}</a>"
|
||||||
html = html + node(item["children"])
|
html = html + node(item["children"],level + 1)
|
||||||
html = html + "</li>"
|
html = html + "</li>"
|
||||||
else
|
else
|
||||||
target = item["target"]
|
target = item["target"]
|
||||||
|
@ -394,7 +403,7 @@ module ApplicationHelper
|
||||||
html = html + "</ul>"
|
html = html + "</ul>"
|
||||||
html
|
html
|
||||||
end
|
end
|
||||||
html = node(items)
|
html = node(items,0)
|
||||||
html.html_safe
|
html.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
|
<%= stylesheet_link_tag "sitemap" %>
|
||||||
<%= render_sitemap %>
|
<%= render_sitemap %>
|
Loading…
Reference in New Issue