Commit 93116c6ba4aced536610483f5c1f116c17da0d54
1 parent
82ae16fc
Exists in
master
and in
29 other branches
Encapsulate stylesheets code
Showing
3 changed files
with
75 additions
and
66 deletions
Show diff stats
app/helpers/application_helper.rb
@@ -30,6 +30,8 @@ module ApplicationHelper | @@ -30,6 +30,8 @@ module ApplicationHelper | ||
30 | 30 | ||
31 | include AccountHelper | 31 | include AccountHelper |
32 | 32 | ||
33 | + include LayoutHelper | ||
34 | + | ||
33 | def locale | 35 | def locale |
34 | (@page && !@page.language.blank?) ? @page.language : FastGettext.locale | 36 | (@page && !@page.language.blank?) ? @page.language : FastGettext.locale |
35 | end | 37 | end |
@@ -352,10 +354,6 @@ module ApplicationHelper | @@ -352,10 +354,6 @@ module ApplicationHelper | ||
352 | end | 354 | end |
353 | end | 355 | end |
354 | 356 | ||
355 | - def theme_stylesheet_path | ||
356 | - theme_path + '/style.css' | ||
357 | - end | ||
358 | - | ||
359 | def current_theme | 357 | def current_theme |
360 | @current_theme ||= | 358 | @current_theme ||= |
361 | begin | 359 | begin |
@@ -873,14 +871,6 @@ module ApplicationHelper | @@ -873,14 +871,6 @@ module ApplicationHelper | ||
873 | content_tag('div', labelled_check_box(_('Public'), 'profile_data[fields_privacy]['+name+']', 'public', profile.public_fields.include?(name)), :class => 'field-privacy-selector') | 871 | content_tag('div', labelled_check_box(_('Public'), 'profile_data[fields_privacy]['+name+']', 'public', profile.public_fields.include?(name)), :class => 'field-privacy-selector') |
874 | end | 872 | end |
875 | 873 | ||
876 | - def template_stylesheet_path | ||
877 | - if profile.nil? | ||
878 | - "/designs/templates/#{environment.layout_template}/stylesheets/style.css" | ||
879 | - else | ||
880 | - "/designs/templates/#{profile.layout_template}/stylesheets/style.css" | ||
881 | - end | ||
882 | - end | ||
883 | - | ||
884 | def login_url | 874 | def login_url |
885 | options = Noosfero.url_options.merge({ :controller => 'account', :action => 'login' }) | 875 | options = Noosfero.url_options.merge({ :controller => 'account', :action => 'login' }) |
886 | url_for(options) | 876 | url_for(options) |
@@ -919,18 +909,6 @@ module ApplicationHelper | @@ -919,18 +909,6 @@ module ApplicationHelper | ||
919 | end | 909 | end |
920 | end | 910 | end |
921 | 911 | ||
922 | - def icon_theme_stylesheet_path | ||
923 | - icon_themes = [] | ||
924 | - theme_icon_themes = theme_option(:icon_theme) || [] | ||
925 | - for icon_theme in theme_icon_themes do | ||
926 | - theme_path = "/designs/icons/#{icon_theme}/style.css" | ||
927 | - if File.exists?(File.join(RAILS_ROOT, 'public', theme_path)) | ||
928 | - icon_themes << theme_path | ||
929 | - end | ||
930 | - end | ||
931 | - icon_themes | ||
932 | - end | ||
933 | - | ||
934 | def page_title | 912 | def page_title |
935 | (@page ? @page.title + ' - ' : '') + | 913 | (@page ? @page.title + ' - ' : '') + |
936 | (profile ? profile.short_name + ' - ' : '') + | 914 | (profile ? profile.short_name + ' - ' : '') + |
@@ -942,40 +920,11 @@ module ApplicationHelper | @@ -942,40 +920,11 @@ module ApplicationHelper | ||
942 | (@category ? " - #{@category.full_name}" : '') | 920 | (@category ? " - #{@category.full_name}" : '') |
943 | end | 921 | end |
944 | 922 | ||
945 | - def noosfero_javascript | ||
946 | - render :file => 'layouts/_javascript' | ||
947 | - end | ||
948 | - | ||
949 | - def noosfero_stylesheets | ||
950 | - [ | ||
951 | - 'application', | ||
952 | - 'search', | ||
953 | - 'thickbox', | ||
954 | - 'lightbox', | ||
955 | - 'colorpicker', | ||
956 | - 'colorbox', | ||
957 | - pngfix_stylesheet_path, | ||
958 | - ] + | ||
959 | - tokeninput_stylesheets | ||
960 | - end | ||
961 | - | ||
962 | # DEPRECATED. Do not use this· | 923 | # DEPRECATED. Do not use this· |
963 | def import_controller_stylesheets(options = {}) | 924 | def import_controller_stylesheets(options = {}) |
964 | stylesheet_import( "controller_"+ @controller.controller_name(), options ) | 925 | stylesheet_import( "controller_"+ @controller.controller_name(), options ) |
965 | end | 926 | end |
966 | 927 | ||
967 | - def pngfix_stylesheet_path | ||
968 | - 'iepngfix/iepngfix.css' | ||
969 | - end | ||
970 | - | ||
971 | - def tokeninput_stylesheets | ||
972 | - ['token-input', 'token-input-facebook', 'token-input-mac', 'token-input-facet'] | ||
973 | - end | ||
974 | - | ||
975 | - def noosfero_layout_features | ||
976 | - render :file => 'shared/noosfero_layout_features' | ||
977 | - end | ||
978 | - | ||
979 | def link_to_email(email) | 928 | def link_to_email(email) |
980 | javascript_tag('var array = ' + email.split('@').to_json + '; document.write("<a href=\'mailto:" + array.join("@") + "\'>" + array.join("@") + "</a>")') | 929 | javascript_tag('var array = ' + email.split('@').to_json + '; document.write("<a href=\'mailto:" + array.join("@") + "\'>" + array.join("@") + "</a>")') |
981 | end | 930 | end |
@@ -1018,10 +967,6 @@ module ApplicationHelper | @@ -1018,10 +967,6 @@ module ApplicationHelper | ||
1018 | theme_option(:jquery_theme) || 'smoothness_mod' | 967 | theme_option(:jquery_theme) || 'smoothness_mod' |
1019 | end | 968 | end |
1020 | 969 | ||
1021 | - def jquery_ui_theme_stylesheet_path | ||
1022 | - 'jquery.ui/' + jquery_theme + '/jquery-ui-1.8.2.custom' | ||
1023 | - end | ||
1024 | - | ||
1025 | def ui_error(message) | 970 | def ui_error(message) |
1026 | content_tag('div', ui_icon('ui-icon-alert') + message, :class => 'alert fg-state-error ui-state-error') | 971 | content_tag('div', ui_icon('ui-icon-alert') + message, :class => 'alert fg-state-error ui-state-error') |
1027 | end | 972 | end |
@@ -0,0 +1,72 @@ | @@ -0,0 +1,72 @@ | ||
1 | +module LayoutHelper | ||
2 | + | ||
3 | + def noosfero_javascript | ||
4 | + render :file => 'layouts/_javascript' | ||
5 | + end | ||
6 | + | ||
7 | + def noosfero_stylesheets | ||
8 | + standard_stylesheets = [ | ||
9 | + 'application', | ||
10 | + 'search', | ||
11 | + 'thickbox', | ||
12 | + 'lightbox', | ||
13 | + 'colorpicker', | ||
14 | + 'colorbox', | ||
15 | + pngfix_stylesheet_path, | ||
16 | + ] + tokeninput_stylesheets | ||
17 | + plugins_stylesheets = @plugins.select(&:stylesheet?).map { |plugin| plugin.class.public_path('style.css') } | ||
18 | + | ||
19 | + output = '' | ||
20 | + output += stylesheet_link_tag standard_stylesheets, :cache => 'cache' | ||
21 | + output += stylesheet_link_tag template_stylesheet_path | ||
22 | + output += stylesheet_link_tag icon_theme_stylesheet_path | ||
23 | + output += stylesheet_link_tag jquery_ui_theme_stylesheet_path | ||
24 | + unless plugins_stylesheets.empty? | ||
25 | + output += stylesheet_link_tag plugins_stylesheets, :cache => "cache/plugins-#{Digest::MD5.hexdigest plugins_stylesheets.to_s}" | ||
26 | + end | ||
27 | + output += stylesheet_link_tag theme_stylesheet_path | ||
28 | + output | ||
29 | + end | ||
30 | + | ||
31 | + def pngfix_stylesheet_path | ||
32 | + 'iepngfix/iepngfix.css' | ||
33 | + end | ||
34 | + | ||
35 | + def tokeninput_stylesheets | ||
36 | + ['token-input', 'token-input-facebook', 'token-input-mac', 'token-input-facet'] | ||
37 | + end | ||
38 | + | ||
39 | + def noosfero_layout_features | ||
40 | + render :file => 'shared/noosfero_layout_features' | ||
41 | + end | ||
42 | + | ||
43 | + def template_stylesheet_path | ||
44 | + if profile.nil? | ||
45 | + "/designs/templates/#{environment.layout_template}/stylesheets/style.css" | ||
46 | + else | ||
47 | + "/designs/templates/#{profile.layout_template}/stylesheets/style.css" | ||
48 | + end | ||
49 | + end | ||
50 | + | ||
51 | + def icon_theme_stylesheet_path | ||
52 | + icon_themes = [] | ||
53 | + theme_icon_themes = theme_option(:icon_theme) || [] | ||
54 | + for icon_theme in theme_icon_themes do | ||
55 | + theme_path = "/designs/icons/#{icon_theme}/style.css" | ||
56 | + if File.exists?(File.join(RAILS_ROOT, 'public', theme_path)) | ||
57 | + icon_themes << theme_path | ||
58 | + end | ||
59 | + end | ||
60 | + icon_themes | ||
61 | + end | ||
62 | + | ||
63 | + def jquery_ui_theme_stylesheet_path | ||
64 | + 'jquery.ui/' + jquery_theme + '/jquery-ui-1.8.2.custom' | ||
65 | + end | ||
66 | + | ||
67 | + def theme_stylesheet_path | ||
68 | + theme_path + '/style.css' | ||
69 | + end | ||
70 | + | ||
71 | +end | ||
72 | + |
app/views/layouts/application-ng.rhtml
@@ -8,15 +8,7 @@ | @@ -8,15 +8,7 @@ | ||
8 | <meta name="description" content="<%= @environment.name %>" /> | 8 | <meta name="description" content="<%= @environment.name %>" /> |
9 | <link rel="shortcut icon" href="<%= image_path(theme_favicon) %>" type="image/x-icon" /> | 9 | <link rel="shortcut icon" href="<%= image_path(theme_favicon) %>" type="image/x-icon" /> |
10 | <%= noosfero_javascript %> | 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 | <%# Add custom tags/styles/etc via content_for %> | 13 | <%# Add custom tags/styles/etc via content_for %> |
22 | <%= yield :head %> | 14 | <%= yield :head %> |