use memcache to store the top_downloads for a while
[opensuse:software-o-o.git] / app / helpers / application_helper.rb
1 # Methods added to this helper will be available to all templates in the application.
2 module ApplicationHelper
3
4   @@theme_prefix = nil
5
6   def theme_prefix
7     return @@theme_prefix if @@theme_prefix
8     @@theme_prefix = '/themes'
9     @@theme_prefix
10   end
11
12   def compute_asset_host(source)
13     if USE_STATIC and source.slice(0, theme_prefix.length) == theme_prefix
14       return "https://static.opensuse.org"
15     end
16     super(source)
17   end
18
19   def setup_baseproject
20     if @baseproject
21       scr = "setCookie('search_baseproject','#{@baseproject}');\n"
22     else
23       scr = "var p = getCookie('search_baseproject'); if (p) { $(\"#baseproject option[value='\" + p + \"']\").attr('selected', 'selected'); }\n"
24     end
25     "<script type=\"text/javascript\">\n" +
26     "//<![CDATA[\n" +
27     scr +
28     "//]]>\n" +
29     "</script>\n"
30   end
31
32 end