Commit b95e86473db7e8f2034b8cf0816824d8bc769418
Exists in
master
and in
29 other branches
Merge commit 'refs/merge-requests/254' of git://gitorious.org/noosfero/noosfero …
…into merge-requests/254 Conflicts: app/helpers/application_helper.rb app/views/layouts/application-ng.rhtml
Showing
4 changed files
with
119 additions
and
104 deletions
Show diff stats
app/helpers/application_helper.rb
... | ... | @@ -34,6 +34,8 @@ module ApplicationHelper |
34 | 34 | |
35 | 35 | include ContentViewerHelper |
36 | 36 | |
37 | + include LayoutHelper | |
38 | + | |
37 | 39 | def locale |
38 | 40 | (@page && !@page.language.blank?) ? @page.language : FastGettext.locale |
39 | 41 | end |
... | ... | @@ -356,10 +358,6 @@ module ApplicationHelper |
356 | 358 | end |
357 | 359 | end |
358 | 360 | |
359 | - def theme_stylesheet_path | |
360 | - theme_path + '/style.css' | |
361 | - end | |
362 | - | |
363 | 361 | def current_theme |
364 | 362 | @current_theme ||= |
365 | 363 | begin |
... | ... | @@ -877,14 +875,6 @@ module ApplicationHelper |
877 | 875 | content_tag('div', labelled_check_box(_('Public'), 'profile_data[fields_privacy]['+name+']', 'public', profile.public_fields.include?(name)), :class => 'field-privacy-selector') |
878 | 876 | end |
879 | 877 | |
880 | - def template_stylesheet_path | |
881 | - if profile.nil? | |
882 | - "/designs/templates/#{environment.layout_template}/stylesheets/style.css" | |
883 | - else | |
884 | - "/designs/templates/#{profile.layout_template}/stylesheets/style.css" | |
885 | - end | |
886 | - end | |
887 | - | |
888 | 878 | def login_url |
889 | 879 | options = Noosfero.url_options.merge({ :controller => 'account', :action => 'login' }) |
890 | 880 | url_for(options) |
... | ... | @@ -923,18 +913,6 @@ module ApplicationHelper |
923 | 913 | end |
924 | 914 | end |
925 | 915 | |
926 | - def icon_theme_stylesheet_path | |
927 | - icon_themes = [] | |
928 | - theme_icon_themes = theme_option(:icon_theme) || [] | |
929 | - for icon_theme in theme_icon_themes do | |
930 | - theme_path = "/designs/icons/#{icon_theme}/style.css" | |
931 | - if File.exists?(File.join(RAILS_ROOT, 'public', theme_path)) | |
932 | - icon_themes << theme_path | |
933 | - end | |
934 | - end | |
935 | - icon_themes | |
936 | - end | |
937 | - | |
938 | 916 | def page_title |
939 | 917 | (@page ? @page.title + ' - ' : '') + |
940 | 918 | (profile ? profile.short_name + ' - ' : '') + |
... | ... | @@ -946,40 +924,11 @@ module ApplicationHelper |
946 | 924 | (@category ? " - #{@category.full_name}" : '') |
947 | 925 | end |
948 | 926 | |
949 | - def noosfero_javascript | |
950 | - render :file => 'layouts/_javascript' | |
951 | - end | |
952 | - | |
953 | - def noosfero_stylesheets | |
954 | - [ | |
955 | - 'application', | |
956 | - 'search', | |
957 | - 'thickbox', | |
958 | - 'lightbox', | |
959 | - 'colorpicker', | |
960 | - 'colorbox', | |
961 | - pngfix_stylesheet_path, | |
962 | - ] + | |
963 | - tokeninput_stylesheets | |
964 | - end | |
965 | - | |
966 | 927 | # DEPRECATED. Do not use this· |
967 | 928 | def import_controller_stylesheets(options = {}) |
968 | 929 | stylesheet_import( "controller_"+ @controller.controller_name(), options ) |
969 | 930 | end |
970 | 931 | |
971 | - def pngfix_stylesheet_path | |
972 | - 'iepngfix/iepngfix.css' | |
973 | - end | |
974 | - | |
975 | - def tokeninput_stylesheets | |
976 | - ['token-input', 'token-input-facebook', 'token-input-mac', 'token-input-facet'] | |
977 | - end | |
978 | - | |
979 | - def noosfero_layout_features | |
980 | - render :file => 'shared/noosfero_layout_features' | |
981 | - end | |
982 | - | |
983 | 932 | def link_to_email(email) |
984 | 933 | javascript_tag('var array = ' + email.split('@').to_json + '; document.write("<a href=\'mailto:" + array.join("@") + "\'>" + array.join("@") + "</a>")') |
985 | 934 | end |
... | ... | @@ -1052,10 +1001,6 @@ module ApplicationHelper |
1052 | 1001 | theme_option(:jquery_theme) || 'smoothness_mod' |
1053 | 1002 | end |
1054 | 1003 | |
1055 | - def jquery_ui_theme_stylesheet_path | |
1056 | - 'jquery.ui/' + jquery_theme + '/jquery-ui-1.8.2.custom' | |
1057 | - end | |
1058 | - | |
1059 | 1004 | def ui_error(message) |
1060 | 1005 | content_tag('div', ui_icon('ui-icon-alert') + message, :class => 'alert fg-state-error ui-state-error') |
1061 | 1006 | end | ... | ... |
... | ... | @@ -0,0 +1,88 @@ |
1 | +module LayoutHelper | |
2 | + | |
3 | + def body_classes | |
4 | + # Identify the current controller and action for the CSS: | |
5 | + " controller-#{@controller.controller_name}" + | |
6 | + " action-#{@controller.controller_name}-#{@controller.action_name}" + | |
7 | + " template-#{profile.nil? ? "default" : profile.layout_template}" + | |
8 | + (!profile.nil? && profile.is_on_homepage?(request.path,@page) ? " profile-homepage" : "") | |
9 | + end | |
10 | + | |
11 | + def noosfero_javascript | |
12 | + plugins_javascripts = @plugins.map { |plugin| plugin.js_files.map { |js| plugin.class.public_path(js) } }.flatten | |
13 | + | |
14 | + output = '' | |
15 | + output += render :file => 'layouts/_javascript' | |
16 | + output += javascript_tag 'render_all_jquery_ui_widgets()' | |
17 | + unless plugins_javascripts.empty? | |
18 | + output += javascript_include_tag plugins_javascripts, :cache => "cache/plugins-#{Digest::MD5.hexdigest plugins_javascripts.to_s}" | |
19 | + end | |
20 | + output | |
21 | + end | |
22 | + | |
23 | + def noosfero_stylesheets | |
24 | + standard_stylesheets = [ | |
25 | + 'application', | |
26 | + 'search', | |
27 | + 'thickbox', | |
28 | + 'lightbox', | |
29 | + 'colorpicker', | |
30 | + 'colorbox', | |
31 | + pngfix_stylesheet_path, | |
32 | + ] + tokeninput_stylesheets | |
33 | + plugins_stylesheets = @plugins.select(&:stylesheet?).map { |plugin| plugin.class.public_path('style.css') } | |
34 | + | |
35 | + output = '' | |
36 | + output += stylesheet_link_tag standard_stylesheets, :cache => 'cache' | |
37 | + output += stylesheet_link_tag template_stylesheet_path | |
38 | + output += stylesheet_link_tag icon_theme_stylesheet_path | |
39 | + output += stylesheet_link_tag jquery_ui_theme_stylesheet_path | |
40 | + unless plugins_stylesheets.empty? | |
41 | + output += stylesheet_link_tag plugins_stylesheets, :cache => "cache/plugins-#{Digest::MD5.hexdigest plugins_stylesheets.to_s}" | |
42 | + end | |
43 | + output += stylesheet_link_tag theme_stylesheet_path | |
44 | + output | |
45 | + end | |
46 | + | |
47 | + def pngfix_stylesheet_path | |
48 | + 'iepngfix/iepngfix.css' | |
49 | + end | |
50 | + | |
51 | + def tokeninput_stylesheets | |
52 | + ['token-input', 'token-input-facebook', 'token-input-mac', 'token-input-facet'] | |
53 | + end | |
54 | + | |
55 | + def noosfero_layout_features | |
56 | + render :file => 'shared/noosfero_layout_features' | |
57 | + end | |
58 | + | |
59 | + def template_stylesheet_path | |
60 | + if profile.nil? | |
61 | + "/designs/templates/#{environment.layout_template}/stylesheets/style.css" | |
62 | + else | |
63 | + "/designs/templates/#{profile.layout_template}/stylesheets/style.css" | |
64 | + end | |
65 | + end | |
66 | + | |
67 | + def icon_theme_stylesheet_path | |
68 | + icon_themes = [] | |
69 | + theme_icon_themes = theme_option(:icon_theme) || [] | |
70 | + for icon_theme in theme_icon_themes do | |
71 | + theme_path = "/designs/icons/#{icon_theme}/style.css" | |
72 | + if File.exists?(File.join(RAILS_ROOT, 'public', theme_path)) | |
73 | + icon_themes << theme_path | |
74 | + end | |
75 | + end | |
76 | + icon_themes | |
77 | + end | |
78 | + | |
79 | + def jquery_ui_theme_stylesheet_path | |
80 | + 'jquery.ui/' + jquery_theme + '/jquery-ui-1.8.2.custom' | |
81 | + end | |
82 | + | |
83 | + def theme_stylesheet_path | |
84 | + theme_path + '/style.css' | |
85 | + end | |
86 | + | |
87 | +end | |
88 | + | ... | ... |
... | ... | @@ -0,0 +1,24 @@ |
1 | +<div id="user"> | |
2 | + <span class='logged-in' style='display: none;'> | |
3 | + <%= usermenu_logged_in %> | |
4 | + </span> | |
5 | + <span class='not-logged-in' style='display: none'> | |
6 | + | |
7 | + <%= _("<span class='login'>%s</span>") % thickbox_inline_popup_link('<i class="icon-menu-login"></i><strong>' + _('Login') + '</strong>', login_url, 'inlineLoginBox', :id => 'link_login') %> | |
8 | + <%= @plugins.dispatch(:alternative_authentication_link).collect { |content| instance_eval(&content) }.join("") %> | |
9 | + | |
10 | + <div id='inlineLoginBox' style='display: none;'> | |
11 | + <%= render :file => 'account/login', :locals => { :is_thickbox => true } %> | |
12 | + </div> | |
13 | + | |
14 | + <% unless @plugins.dispatch(:allow_user_registration).include?(false) %> | |
15 | + <%= _("<span class='or'>or</span> <span class='signup'>%s</span>") % link_to('<strong>' + _('Sign up') + '</strong>', :controller => 'account', :action => 'signup')%> | |
16 | + <% end %> | |
17 | + | |
18 | + </span> | |
19 | + <form action="/search" id="top-search" class="search_form clean" method="get"> | |
20 | + <input name="query" size="15" title="<%=_('Search...')%>" onfocus="this.form.className='focused';" onblur="this.form.className=''" /> | |
21 | + <div><%=_('Press <strong>Enter</strong> to send the search query.')%></div> | |
22 | + <%= javascript_tag 'jQuery("#user form input").hint();' %> | |
23 | + </form> | |
24 | +</div><!-- end id="user" --> | ... | ... |
app/views/layouts/application-ng.rhtml
... | ... | @@ -8,38 +8,19 @@ |
8 | 8 | <meta name="description" content="<%= @environment.name %>" /> |
9 | 9 | <link rel="shortcut icon" href="<%= image_path(theme_favicon) %>" type="image/x-icon" /> |
10 | 10 | <%= noosfero_javascript %> |
11 | - <%= stylesheet_link_tag noosfero_stylesheets, :cache => 'cache' %> | |
12 | - <%= stylesheet_link_tag template_stylesheet_path %> | |
13 | - <%= stylesheet_link_tag icon_theme_stylesheet_path %> | |
14 | - <%= stylesheet_link_tag jquery_ui_theme_stylesheet_path %> | |
15 | - <% | |
16 | - plugins_stylesheets = @plugins.select(&:stylesheet?).map { |plugin| plugin.class.public_path('style.css') } | |
17 | - %> | |
18 | - <%= stylesheet_link_tag(plugins_stylesheets, :cache => 'cache/plugins-' + Digest::MD5.hexdigest(plugins_stylesheets.to_s)) unless plugins_stylesheets.empty? %> | |
19 | - <%= stylesheet_link_tag theme_stylesheet_path %> | |
11 | + <%= noosfero_stylesheets %> | |
20 | 12 | |
21 | 13 | <%# Add custom tags/styles/etc via content_for %> |
22 | 14 | <%= yield :head %> |
23 | - <%= javascript_tag('render_all_jquery_ui_widgets()') %> | |
24 | - <% | |
25 | - plugins_javascripts = @plugins.map { |plugin| plugin.js_files.map { |js| plugin.class.public_path(js) } }.flatten | |
26 | - %> | |
27 | - <%= javascript_include_tag(plugins_javascripts, :cache => 'cache/plugins-' + Digest::MD5.hexdigest(plugins_javascripts.to_s)) unless plugins_javascripts.empty? %> | |
28 | 15 | <%= |
29 | 16 | @plugins.dispatch(:head_ending).collect do |content| |
30 | 17 | content.respond_to?(:call) ? content.call : content |
31 | 18 | end.join("\n") |
32 | 19 | %> |
33 | 20 | </head> |
34 | - <body class="<%= | |
35 | - # Identify the current controller and action for the CSS: | |
36 | - " controller-"+ @controller.controller_name() + | |
37 | - " action-"+ @controller.controller_name() +"-"+ @controller.action_name() + | |
38 | - " template-"+ ( profile.nil? ? "default" : profile.layout_template ) + | |
39 | - (!profile.nil? && profile.is_on_homepage?(request.path,@page) ? " profile-homepage" : "") | |
40 | - %>" > | |
41 | - | |
21 | + <body class="<%= body_classes %>"> | |
42 | 22 | <a href="#content" id="link-go-content"><span><%= _("Go to the content") %></span></a> |
23 | + | |
43 | 24 | <%= |
44 | 25 | @plugins.dispatch(:body_beginning).collect do |content| |
45 | 26 | content.respond_to?(:call) ? content.call : content |
... | ... | @@ -50,31 +31,8 @@ |
50 | 31 | <div id='theme-header'> |
51 | 32 | <%= theme_header %> |
52 | 33 | </div> |
53 | - <div id="wrap-2"> | |
54 | - <div id="user"> | |
55 | - <span class='logged-in' style='display: none;'> | |
56 | - <%= usermenu_logged_in %> | |
57 | - </span> | |
58 | - <span class='not-logged-in' style='display: none'> | |
59 | - | |
60 | - <%= _("<span class='login'>%s</span>") % thickbox_inline_popup_link('<i class="icon-menu-login"></i><strong>' + _('Login') + '</strong>', login_url, 'inlineLoginBox', :id => 'link_login') %> | |
61 | - <%= @plugins.dispatch(:alternative_authentication_link).collect { |content| instance_eval(&content) }.join("") %> | |
62 | - | |
63 | - <div id='inlineLoginBox' style='display: none;'> | |
64 | - <%= render :file => 'account/login', :locals => { :is_thickbox => true } %> | |
65 | - </div> | |
66 | - | |
67 | - <% unless @plugins.dispatch(:allow_user_registration).include?(false) %> | |
68 | - <%= _("<span class='or'>or</span> <span class='signup'>%s</span>") % link_to('<strong>' + _('Sign up') + '</strong>', :controller => 'account', :action => 'signup')%> | |
69 | - <% end %> | |
70 | - | |
71 | - </span> | |
72 | - <form action="/search" class="search_form clean" method="get" id="top-search"> | |
73 | - <input name="query" size="15" title="<%=_('Search...')%>" onfocus="this.form.className='focused';" onblur="this.form.className=''" /> | |
74 | - <div><%=_('Press <strong>Enter</strong> to send the search query.')%></div> | |
75 | - <%= javascript_tag 'jQuery("#user form input").hint();' %> | |
76 | - </form> | |
77 | - </div><!-- end id="user" --> | |
34 | + <div id="wrap-2">' | |
35 | + <%= render :partial => 'layouts/user' %> | |
78 | 36 | |
79 | 37 | <h1 id="site-title"> |
80 | 38 | <%= theme_site_title %> | ... | ... |