15689-theme_favicon.patch

Felix Schäfer, 2013-12-12 16:10

Download (1.5 KB)

View differences:

app/helpers/application_helper.rb
1254 1254
  end
1255 1255

  
1256 1256
  def favicon
1257
    "<link rel='shortcut icon' href='#{image_path('/favicon.ico')}' />".html_safe
1257
    fav_path = (current_theme && current_theme.favicon?) ? current_theme.favicon_path : '/favicon.ico'
1258
    "<link rel='shortcut icon' href='#{image_path(fav_path)}' />".html_safe
1258 1259
  end
1259 1260

  
1260 1261
  def robot_exclusion_tag
lib/redmine/themes.rb
75 75
        @javascripts ||= assets("javascripts", "js")
76 76
      end
77 77

  
78
      def favicon
79
        # we need to cache the array as [].first is nil and wouldn't be cached
80
        (@favicons ||= assets("favicon")).first
81
      end
82

  
83
      def favicon?
84
        favicon.present?
85
      end
86

  
78 87
      def stylesheet_path(source)
79 88
        "/themes/#{dir}/stylesheets/#{source}"
80 89
      end
......
87 96
        "/themes/#{dir}/javascripts/#{source}"
88 97
      end
89 98

  
99
      def favicon_path
100
        "/themes/#{dir}/favicon/#{favicon}"
101
      end
102

  
90 103
      private
91 104

  
92 105
      def assets(dir, ext=nil)