diff --git a/app/controllers/application.rb b/app/controllers/application.rb index f0b973a..6e73ba8 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -2,6 +2,12 @@ # available in all controllers. class ApplicationController < ActionController::Base + include ApplicationHelper + layout :get_layout + def get_layout + theme_option(:layout) || 'application' + end + filter_parameter_logging :password def log_processing diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 78ccb72..241cd15 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -290,7 +290,12 @@ module ApplicationHelper if in_theme result << theme_path end - result << '/stylesheets/' << name << '.css' + name += '.css' if ( name[-4..-1] != '.css' ) + if ( name[0..0] == '/' ) + result << name + else + result << '/stylesheets/' << name + end end def theme_path @@ -301,6 +306,10 @@ module ApplicationHelper end end + def theme_stylesheet_path + theme_path + '/style.css' + end + def current_theme return session[:theme] if (session[:theme]) p = profile @@ -311,13 +320,21 @@ module ApplicationHelper end end - def theme_footer - footer = ('../../public' + theme_path + '/footer.rhtml') - if File.exists?(RAILS_ROOT + '/app/views/' + footer) - render :file => footer + def theme_include(template) + file = ('../../public' + theme_path + '/' + template + '.rhtml') + if File.exists?(RAILS_ROOT + '/app/views/' + file) + render :file => file end end + def theme_header + theme_include('header') + end + + def theme_footer + theme_include('footer') + end + def is_testing_theme !@controller.session[:theme].nil? end @@ -727,13 +744,16 @@ module ApplicationHelper end end - def template_stylesheet_tag + def template_stylesheet_path if profile.nil? - stylesheet_link_tag '/designs/templates/default/stylesheets/style.css' + '/designs/templates/default/stylesheets/style.css' else - stylesheet_link_tag "/designs/templates/#{profile.layout_template}/stylesheets/style.css" + "/designs/templates/#{profile.layout_template}/stylesheets/style.css" end end + def template_stylesheet_tag + stylesheet_import template_stylesheet_path() + end def login_url options = Noosfero.url_options.merge({ :controller => 'account', :action => 'login' }) @@ -770,9 +790,11 @@ module ApplicationHelper end def meta_tags_for_article(article) - if article and (article.blog? or (article.parent and article.parent.blog?)) - blog = article.blog? ? article : article.parent - "" + if @controller.controller_name == 'content_viewer' + if article and (article.blog? or (article.parent and article.parent.blog?)) + blog = article.blog? ? article : article.parent + "" + end end end @@ -789,14 +811,40 @@ module ApplicationHelper end end - def icon_theme_stylesheet_tag + def icon_theme_stylesheet_path theme_path = "/designs/icons/#{environment.icon_theme}/style.css" if File.exists?(File.join(RAILS_ROOT, 'public', theme_path)) - stylesheet_link_tag theme_path + theme_path else - "\n" + - stylesheet_link_tag("/designs/icons/default/style.css") + '/designs/icons/default/style.css' end end + def icon_theme_stylesheet_tag + theme_path = "/designs/icons/#{environment.icon_theme}/style.css" + stylesheet_import icon_theme_stylesheet_path() + end + + def page_title + (@page ? @page.name + ' - ' : '') + + (@profile ? @profile.name + ' - ' : '') + + @environment.name + + (@category ? "→ #{@category.full_name}" : '') + end + + def noosfero_javascript + render :file => 'layouts/_javascript' + end + + def import_controller_stylesheets(options = {}) + stylesheet_import( "controller_"+ @controller.controller_name(), options ) + end + + def pngfix_stylesheet_path + 'iepngfix/iepngfix.css' + end + def pngfix_stylesheet + stylesheet_import pngfix_stylesheet_path() + end + end diff --git a/app/helpers/blog_helper.rb b/app/helpers/blog_helper.rb index 8ce05c2..583cf7e 100644 --- a/app/helpers/blog_helper.rb +++ b/app/helpers/blog_helper.rb @@ -21,14 +21,20 @@ module BlogHelper :next_label => _('Older posts »') }) content = [] - articles.map{ |i| - css_add = '' - if i.published? || (user==i.profile) - css_add = '-not-published' if !i.published? - content << content_tag('div', display_post(i), :class => 'blog-post' + css_add, :id => "post-#{i.id}") + artic_len = articles.length + articles.each_with_index{ |art,i| + css_add = [ 'position-'+(i+1).to_s() ] + if art.published? || (user==art.profile) + css_add << 'first' if i == 0 + css_add << 'last' if i == (artic_len-1) + css_add << 'not-published' if !art.published? + content << content_tag('div', + display_post(art), + :class => 'blog-post ' + css_add.join(' '), + :id => "post-#{art.id}") end } - content.join("\n