Commit 199589e294bd117afdfe07e53c6e890eb02f2278
1 parent
0f613d07
Exists in
master
and in
29 other branches
ActionItem139: added helper to insert css specific to blocks in use
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1285 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
3 changed files
with
24 additions
and
3 deletions
Show diff stats
app/helpers/application_helper.rb
... | ... | @@ -343,14 +343,25 @@ module ApplicationHelper |
343 | 343 | |
344 | 344 | |
345 | 345 | def stylesheet_import(*sources) |
346 | - options = sources.last.is_a?(Hash) ? sources.pop.stringify_keys : { } | |
346 | + options = sources.last.is_a?(Hash) ? sources.pop : { } | |
347 | + themed_source = options.delete(:themed_source) | |
347 | 348 | content_tag( 'style', |
348 | 349 | "\n" + |
349 | - sources.flatten.collect do |source| | |
350 | - source = ' @import url('+ stylesheet_path(source.to_s()) +");\n"; | |
350 | + sources.flatten.map do |source| | |
351 | + ' @import url(' + | |
352 | + ( themed_source ? theme_stylesheet_path(source.to_s) : stylesheet_path(source.to_s) ) + | |
353 | + ");\n"; | |
351 | 354 | end.join(), |
352 | 355 | { "type" => "text/css" }.merge(options) |
353 | 356 | ) |
357 | + end | |
358 | + | |
359 | + def theme_stylesheet_path(file_name) | |
360 | + '/designs/templates/' + current_theme + '/stylesheets/' + file_name + '.css' | |
361 | + end | |
362 | + | |
363 | + def current_theme | |
364 | + 'default' | |
354 | 365 | end |
355 | 366 | |
356 | 367 | end | ... | ... |
app/helpers/boxes_helper.rb
... | ... | @@ -109,4 +109,13 @@ module BoxesHelper |
109 | 109 | content_tag('div', buttons.join("\n") + tag('br', :style => 'clear: left'), :class => 'button-bar') |
110 | 110 | end |
111 | 111 | |
112 | + def current_blocks | |
113 | + @controller.boxes_holder.boxes.map(&:blocks).flatten | |
114 | + end | |
115 | + | |
116 | + def import_blocks_stylesheets | |
117 | + stylesheet_import( current_blocks.map(&:css_class_name).uniq ) + "\n" + | |
118 | + stylesheet_import( current_blocks.map(&:css_class_name).uniq, :themed_source => true ) | |
119 | + end | |
120 | + | |
112 | 121 | end | ... | ... |
app/views/layouts/application.rhtml
... | ... | @@ -14,6 +14,7 @@ |
14 | 14 | must be loaded before the page show. |
15 | 15 | %> |
16 | 16 | <%= stylesheet_import %w( common help menu button search blocks forms login-box ) %> |
17 | + <%= import_blocks_stylesheets %> | |
17 | 18 | <%= |
18 | 19 | # Load the controller's css file if it exists: |
19 | 20 | css = "controller_"+ @controller.controller_name() +".css" | ... | ... |