Commit 9c4dd907ae769f34bc5d2aeda3c1497d71362e4c

Authored by Victor Costa
2 parents 0b3b2bf5 6edafc75

Merge branch 'next' into stable

Conflicts:
	app/helpers/layout_helper.rb
	app/views/layouts/_javascript.html.erb
Gemfile
... ... @@ -21,6 +21,11 @@ gem 'locale', '~> 2.0.5'
21 21 gem 'whenever', :require => false
22 22 gem 'eita-jrails', '>= 0.9.5', :require => 'jrails'
23 23  
  24 +group :assets do
  25 + gem 'uglifier', '>= 1.0.3'
  26 + gem 'sass-rails'
  27 +end
  28 +
24 29 group :production do
25 30 gem 'dalli', '~> 2.7.0'
26 31 end
... ...
app/assets/designs/icons 0 → 120000
... ... @@ -0,0 +1 @@
  1 +../../../public/designs/icons
0 2 \ No newline at end of file
... ...
app/assets/designs/themes 0 → 120000
... ... @@ -0,0 +1 @@
  1 +../../../public/designs/themes
0 2 \ No newline at end of file
... ...
app/assets/images 0 → 120000
... ... @@ -0,0 +1 @@
  1 +../../public/images
0 2 \ No newline at end of file
... ...
app/assets/javascripts 0 → 120000
... ... @@ -0,0 +1 @@
  1 +../../public/javascripts
0 2 \ No newline at end of file
... ...
app/assets/plugins 0 → 120000
... ... @@ -0,0 +1 @@
  1 +../../public/plugins
0 2 \ No newline at end of file
... ...
app/assets/stylesheets 0 → 120000
... ... @@ -0,0 +1 @@
  1 +../../public/stylesheets
0 2 \ No newline at end of file
... ...
app/helpers/application_helper.rb
... ... @@ -929,18 +929,6 @@ module ApplicationHelper
929 929 end
930 930 end
931 931  
932   - def icon_theme_stylesheet_path
933   - icon_themes = []
934   - theme_icon_themes = theme_option(:icon_theme) || []
935   - for icon_theme in theme_icon_themes do
936   - theme_path = "/designs/icons/#{icon_theme}/style.css"
937   - if File.exists?(Rails.root.join('public', theme_path[1..-1]))
938   - icon_themes << theme_path
939   - end
940   - end
941   - icon_themes
942   - end
943   -
944 932 def page_title
945 933 CGI.escapeHTML(
946 934 (@page ? @page.title + ' - ' : '') +
... ...
app/helpers/layout_helper.rb
... ... @@ -28,12 +28,12 @@ module LayoutHelper
28 28 end
29 29  
30 30 def noosfero_javascript
31   - plugins_javascripts = @plugins.map { |plugin| [plugin.js_files].flatten.map { |js| plugin.class.public_path(js) } }.flatten
  31 + plugins_javascripts = @plugins.flat_map{ |plugin| plugin.js_files.map{ |js| plugin.class.public_path(js, true) } }.flatten
32 32  
33 33 output = ''
34 34 output += render 'layouts/javascript'
35 35 unless plugins_javascripts.empty?
36   - output += javascript_include_tag plugins_javascripts, :cache => "cache/plugins-#{Digest::MD5.hexdigest plugins_javascripts.to_s}"
  36 + output += javascript_include_tag *plugins_javascripts
37 37 end
38 38 output += theme_javascript_ng.to_s
39 39 output += javascript_tag 'render_all_jquery_ui_widgets()'
... ... @@ -42,31 +42,21 @@ module LayoutHelper
42 42 end
43 43  
44 44 def noosfero_stylesheets
45   - standard_stylesheets = [
46   - 'application',
47   - 'search',
48   - 'colorbox',
49   - 'selectordie',
50   - 'inputosaurus',
51   - 'chat',
52   - 'selectordie-theme',
53   - 'block-store',
54   - pngfix_stylesheet_path,
55   - ] + tokeninput_stylesheets
56 45 plugins_stylesheets = @plugins.select(&:stylesheet?).map { |plugin|
57   - plugin.class.public_path('style.css')
  46 + plugin.class.public_path('style.css', true)
58 47 }
59 48 global_css_pub = "/designs/themes/#{environment.theme}/global.css"
60 49 global_css_at_fs = Rails.root.join 'public' + global_css_pub
61 50  
62 51 output = []
63   - output << stylesheet_link_tag(standard_stylesheets, :cache => 'cache/application')
  52 + output << stylesheet_link_tag('application')
64 53 output << stylesheet_link_tag(template_stylesheet_path)
65   - output << stylesheet_link_tag(icon_theme_stylesheet_path)
  54 + output << stylesheet_link_tag(*icon_theme_stylesheet_path)
66 55 output << stylesheet_link_tag(jquery_ui_theme_stylesheet_path)
67 56 unless plugins_stylesheets.empty?
68   - cacheid = "cache/plugins-#{Digest::MD5.hexdigest plugins_stylesheets.to_s}"
69   - output << stylesheet_link_tag(plugins_stylesheets, :cache => cacheid)
  57 + # FIXME: caching does not work with asset pipeline
  58 + #cacheid = "cache/plugins-#{Digest::MD5.hexdigest plugins_stylesheets.to_s}"
  59 + output << stylesheet_link_tag(*plugins_stylesheets)
70 60 end
71 61 if File.exists? global_css_at_fs
72 62 output << stylesheet_link_tag(global_css_pub)
... ... @@ -75,14 +65,6 @@ module LayoutHelper
75 65 output.join "\n"
76 66 end
77 67  
78   - def pngfix_stylesheet_path
79   - 'iepngfix/iepngfix.css' #TODO: deprecate it
80   - end
81   -
82   - def tokeninput_stylesheets
83   - ['token-input', 'token-input-facebook', 'token-input-mac', 'token-input-facet']
84   - end
85   -
86 68 def noosfero_layout_features
87 69 render :file => 'shared/noosfero_layout_features'
88 70 end
... ... @@ -100,7 +82,7 @@ module LayoutHelper
100 82 icon_themes = []
101 83 theme_icon_themes = theme_option(:icon_theme) || []
102 84 for icon_theme in theme_icon_themes do
103   - theme_path = "/designs/icons/#{icon_theme}/style.css"
  85 + theme_path = "designs/icons/#{icon_theme}/style.css"
104 86 if File.exists?(Rails.root.join('public', theme_path))
105 87 icon_themes << theme_path
106 88 end
... ... @@ -113,7 +95,7 @@ module LayoutHelper
113 95 end
114 96  
115 97 def theme_stylesheet_path
116   - theme_path + '/style.css'
  98 + "/assets#{theme_path}/style.css"
117 99 end
118 100  
119 101 def layout_template
... ...
app/helpers/macros_helper.rb
... ... @@ -42,7 +42,9 @@ module MacrosHelper
42 42 [macro.configuration[:js_files]].flatten.map { |js| plugins_javascripts << macro.plugin.public_path(js) }
43 43 end
44 44 end
45   - javascript_include_tag(plugins_javascripts, :cache => 'cache/plugins-' + Digest::MD5.hexdigest(plugins_javascripts.to_s)) unless plugins_javascripts.empty?
  45 + unless plugins_javascripts.empty?
  46 + javascript_include_tag *plugins_javascripts
  47 + end
46 48 end
47 49  
48 50 def macro_css_files
... ...
app/views/layouts/_javascript.html.erb
1   -<%= javascript_include_tag 'jquery-2.1.1.min', 'jquery-migrate-1.2.1', 'jrails', 'rails.js',
2   - 'jquery.cycle.all.min.js', 'jquery.colorbox-min.js',
3   - 'jquery-ui-1.10.4/js/jquery-ui-1.10.4.min', 'jquery.scrollTo', 'jquery.form.js', 'jquery-validation/jquery.validate',
4   - 'jquery.cookie', 'jquery.ba-bbq.min.js', 'reflection', 'jquery.tokeninput', 'jquery.typewatch', 'jquery.textchange',
5   - 'jquery-timepicker-addon/dist/jquery-ui-timepicker-addon', 'inputosaurus.js', 'select-or-die/_src/selectordie',
6   - 'slick.js',
7   - # noosfero libraries
8   - 'application.js', 'modal.js', 'block-store.js',
9   - 'add-and-join', 'report-abuse', 'catalog', 'manage-products', 'autogrow',
10   - :cache => 'cache/application' %>
  1 +<%= javascript_include_tag 'application.js' %>
11 2  
12 3 <% language = FastGettext.locale %>
13 4 <% %w{messages methods}.each do |type| %>
... ...
app/views/layouts/application.html.erb
... ... @@ -21,7 +21,7 @@
21 21 import_controller_stylesheets(:themed_source => true)
22 22 %>
23 23 <%= stylesheet_link_tag template_stylesheet_path %>
24   - <%= stylesheet_link_tag icon_theme_stylesheet_path %>
  24 + <%= stylesheet_link_tag *icon_theme_stylesheet_path %>
25 25 <%= stylesheet_link_tag jquery_ui_theme_stylesheet_path %>
26 26  
27 27 <%# Add custom tags/styles/etc via content_for %>
... ...
app/views/layouts/slideshow.html.erb
... ... @@ -11,7 +11,7 @@
11 11 %></title>
12 12  
13 13 <%= stylesheet_import "slideshow" %>
14   - <%= javascript_include_tag 'jquery-2.1.1.min', 'sliderjs', 'pikachoose', :cache => 'cache/slideshow' %>
  14 + <%= javascript_include_tag 'jquery-2.1.1.min', 'sliderjs', 'pikachoose' %>
15 15 <script type="text/javascript">
16 16 $(document).ready(function (){
17 17 $("#slideshow").PikaChoose({
... ...
config/application.rb
... ... @@ -90,11 +90,25 @@ module Noosfero
90 90 config.active_record.whitelist_attributes = true
91 91  
92 92 # Enable the asset pipeline
93   - config.assets.enabled = false
  93 + config.assets.enabled = true
  94 +
  95 + # don't let rails prepend app/assets to config.assets.paths
  96 + # as we are doing it
  97 + config.paths['app/assets'] = ''
  98 +
  99 + config.assets.paths =
  100 + Dir.glob("app/assets/plugins/*/{,stylesheets,javascripts}") +
  101 + Dir.glob("app/assets/{,stylesheets,javascripts}") +
  102 + # no precedence over core
  103 + Dir.glob("app/assets/designs/{icons,themes,user_themes}/*")
94 104  
95 105 # Version of your assets, change this if you want to expire all your assets
96 106 config.assets.version = '1.0'
97 107  
  108 + config.sass.preferred_syntax = :scss
  109 + config.sass.cache = true
  110 + config.sass.line_comments = false
  111 +
98 112 def noosfero_session_secret
99 113 require 'fileutils'
100 114 target_dir = File.join(File.dirname(__FILE__), '../tmp')
... ...
config/environments/production.rb
... ... @@ -14,12 +14,15 @@ Noosfero::Application.configure do
14 14 # Compress JavaScripts and CSS
15 15 config.assets.compress = true
16 16  
17   - # Don't fallback to assets pipeline if a precompiled asset is missed
18   - config.assets.compile = false
19   -
20 17 # Generate digests for assets URLs
21 18 config.assets.digest = true
22 19  
  20 + # pre-compile every asset
  21 + config.assets.precompile = Dir.glob("app/assets/**/*").map do |file|
  22 + next unless File.exists?(file) and File.file?(file)
  23 + File.basename file
  24 + end.compact
  25 +
23 26 # Defaults to nil and saved in location specified by config.assets.prefix
24 27 # config.assets.manifest = YOUR_PATH
25 28  
... ...
config/routes.rb
... ... @@ -52,7 +52,6 @@ Noosfero::Application.routes.draw do
52 52  
53 53 # categories index
54 54 match 'cat/*category_path' => 'search#category_index', :as => :category
55   - match 'assets/:asset(/*category_path)' => 'search#assets', :as => :assets
56 55 # search
57 56 match 'search(/:action(/*category_path))', :controller => 'search'
58 57  
... ...
db/schema.rb
... ... @@ -11,7 +11,7 @@
11 11 #
12 12 # It's strongly recommended to check this file into your version control system.
13 13  
14   -ActiveRecord::Schema.define(:version => 20150223180806) do
  14 +ActiveRecord::Schema.define(:version => 20150408231524) do
15 15  
16 16 create_table "abuse_reports", :force => true do |t|
17 17 t.integer "reporter_id"
... ... @@ -263,6 +263,7 @@ ActiveRecord::Schema.define(:version =&gt; 20150223180806) do
263 263 t.string "source_type"
264 264 t.string "user_agent"
265 265 t.string "referrer"
  266 + t.text "settings"
266 267 end
267 268  
268 269 add_index "comments", ["source_id", "spam"], :name => "index_comments_on_source_id_and_spam"
... ...
gitignore.example
... ... @@ -22,8 +22,12 @@ public/user_themes
22 22 public/designs/themes/default
23 23 public/designs/themes/*
24 24 public/designs/icons/default
  25 +
  26 +public/assets
  27 +.sass-cache
25 28 public/javascripts/cache*
26 29 public/stylesheets/cache*
  30 +
27 31 public/plugins
28 32 db/development.db
29 33 db/production.db
... ...
lib/noosfero/plugin.rb
... ... @@ -150,8 +150,8 @@ class Noosfero::Plugin
150 150 self.name.underscore.gsub('_plugin','')
151 151 end
152 152  
153   - def public_path(file = '')
154   - File.join('/plugins', public_name, file)
  153 + def public_path file = '', relative=false
  154 + File.join "#{if relative then '' else '/' end}plugins", public_name, file
155 155 end
156 156  
157 157 def root_path
... ...
plugins/pjax/public/javascripts/pjax.js
... ... @@ -8,7 +8,7 @@ pjax = {
8 8 themes: {},
9 9  
10 10 load: function() {
11   - var target = jQuery('#content');
  11 + var target = jQuery('#wrap-1');
12 12 var content = jQuery('#content-inner');
13 13 var loadingTarget = jQuery('#content');
14 14  
... ... @@ -52,7 +52,7 @@ pjax = {
52 52 from_state = this.current_state || this.initial_state;
53 53  
54 54 if (state.layout_template != from_state.layout_template) {
55   - var lt_css = jQuery('head link[href^="/designs/templates"]');
  55 + var lt_css = jQuery('head link[href*="designs/templates"]');
56 56 lt_css.attr('href', lt_css.attr('href').replace(/templates\/.+\/stylesheets/, 'templates/'+state.layout_template+'/stylesheets'));
57 57 }
58 58  
... ... @@ -78,7 +78,7 @@ pjax = {
78 78 return !pjax.css_loaded('/designs/themes/'+state.theme.id+'/style.css');
79 79 });
80 80  
81   - var css = jQuery('head link[href^="/designs/themes/'+from_state.theme.id+'/style"]');
  81 + var css = jQuery('head link[href*="designs/themes/'+from_state.theme.id+'/style"]');
82 82 css.attr('href', css.attr('href').replace(/themes\/.+\/style/, 'themes/'+state.theme.id+'/style'));
83 83  
84 84 jQuery('head link[rel="shortcut icon"]').attr('href', state.theme.favicon);
... ... @@ -88,7 +88,7 @@ pjax = {
88 88 jQuery('#navigation ul').html(state.theme.extra_navigation);
89 89 jQuery('#theme-footer').html(state.theme.footer);
90 90  
91   - jQuery('head script[src^="/designs/themes/'+from_state.theme.id+'/theme.js"]').remove();
  91 + jQuery('head script[src*="designs/themes/'+from_state.theme.id+'/theme.js"]').remove();
92 92 if (state.theme.js_src) {
93 93 var script = document.createElement('script');
94 94 script.type = 'text/javascript', script.src = state.theme.js_src;
... ...
plugins/pjax/views/layouts/pjax.html.erb
1 1 <%
2   - update_js = render(:file => "#{Rails.root}/public/designs/themes/#{current_theme}/pjax_update.js.erb").to_json rescue nil
  2 + update_js = render(file: "#{Rails.root}/public/designs/themes/#{current_theme}/pjax_update.js.erb").to_json rescue nil
3 3 %>
4 4  
5 5 <title><%= h page_title %></title>
6 6  
7   -<%= render :file => "#{Rails.root}/public/designs/themes/#{current_theme}/layouts/_content.html.erb" rescue
  7 +<%= render file: "#{Rails.root}/public/designs/themes/#{current_theme}/layouts/_content.html.erb" rescue
8 8 render "layouts/content" %>
9 9  
10 10 <%= javascript_tag do %>
... ...
public/javascripts/application.js
1 1 // Place your application-specific JavaScript functions and classes here
2 2 // This file is automatically included by javascript_include_tag :defaults
  3 +/*
  4 +* third party libraries
  5 +*= require jquery-2.1.1.min.js
  6 +*= require jquery-migrate-1.2.1.js
  7 +*= require jquery.cycle.all.min.js
  8 +*= require jquery.colorbox-min.js
  9 +*= require jquery-ui-1.10.4/js/jquery-ui-1.10.4.min.js
  10 +*= require jquery.scrollTo.js
  11 +*= require jquery.form.js
  12 +*= require jquery-validation/jquery.validate.js
  13 +*= require jquery.cookie.js
  14 +*= require jquery.ba-bbq.min.js
  15 +*= require jquery.tokeninput.js
  16 +*= require jquery-timepicker-addon/dist/jquery-ui-timepicker-addon.js
  17 +*= require inputosaurus.js
  18 +*= require reflection.js
  19 +*= require rails.js
  20 +*= require jrails.js
  21 +* noosfero libraries
  22 +*= require_self
  23 +*= require modal.js
  24 +* views speficics
  25 +*= require add-and-join.js
  26 +*= require report-abuse.js
  27 +*= require manage-products.js
  28 +*= require catalog.js
  29 +*= require autogrow.js
  30 +*/
3 31  
4 32 // scope for noosfero stuff
5 33 noosfero = {
... ...
public/javascripts/codepress/languages/asp.css
... ... @@ -6,7 +6,7 @@
6 6  
7 7 b {
8 8 color:#000080;
9   -}
  9 +}
10 10 /* comments */
11 11 big, big b, big em, big ins, big s, strong i, strong i b, strong i s, strong i u, strong i a, strong i a u, strong i s u {
12 12 color:gray;
... ... @@ -17,12 +17,12 @@ strong dfn, strong dfn a,strong dfn var, strong dfn a u, strong dfn u{
17 17 color:gray;
18 18 font-weight:normal;
19 19 }
20   - /* attributes */
  20 + /* attributes */
21 21 s, s b, span s u, span s cite, strong span s {
22 22 color:#5656fa ;
23 23 font-weight:normal;
24 24 }
25   - /* strings */
  25 + /* strings */
26 26 strong s,strong s b, strong s u, strong s cite {
27 27 color:#009900;
28 28 font-weight:normal;
... ... @@ -34,7 +34,6 @@ strong ins{
34 34 /* Syntax */
35 35 strong a, strong a u {
36 36 color:#0000FF;
37   - font-weight:;
38 37 }
39 38 /* Native Keywords */
40 39 strong u {
... ... @@ -58,7 +57,7 @@ em {
58 57 color:#800080;
59 58 font-style:normal;
60 59 }
61   - /* script */
  60 + /* script */
62 61 ins {
63 62 color:#800000;
64 63 font-weight:bold;
... ... @@ -68,4 +67,4 @@ ins {
68 67 cite, s cite {
69 68 color:red;
70 69 font-weight:bold;
71   -}
72 70 \ No newline at end of file
  71 +}
... ...
public/javascripts/codepress/languages/vbscript.css
1 1 /*
2   - * CodePress color styles for ASP-VB syntax highlighting
  2 + * CodePress color styles for ASP-VB syntax highlighting
3 3 * By Martin D. Kirk
4 4 */
5 5  
6 6 /* tags */
7 7 b {
8 8 color:#000080;
9   -}
  9 +}
10 10 /* comments */
11 11 big, big b, big em, big ins, big s, strong i, strong i b, strong i s, strong i u, strong i a, strong i a u, strong i s u {
12 12 color:gray;
... ... @@ -17,12 +17,12 @@ strong dfn, strong dfn a,strong dfn var, strong dfn a u, strong dfn u{
17 17 color:gray;
18 18 font-weight:normal;
19 19 }
20   - /* attributes */
  20 + /* attributes */
21 21 s, s b, span s u, span s cite, strong span s {
22 22 color:#5656fa ;
23 23 font-weight:normal;
24 24 }
25   - /* strings */
  25 + /* strings */
26 26 strong s,strong s b, strong s u, strong s cite {
27 27 color:#009900;
28 28 font-weight:normal;
... ... @@ -34,7 +34,6 @@ strong ins{
34 34 /* Syntax */
35 35 strong a, strong a u {
36 36 color:#0000FF;
37   - font-weight:;
38 37 }
39 38 /* Native Keywords */
40 39 strong u {
... ... @@ -58,7 +57,7 @@ em {
58 57 color:#800080;
59 58 font-style:normal;
60 59 }
61   - /* script */
  60 + /* script */
62 61 ins {
63 62 color:#800000;
64 63 font-weight:bold;
... ... @@ -68,4 +67,4 @@ ins {
68 67 cite, s cite {
69 68 color:red;
70 69 font-weight:bold;
71   -}
72 70 \ No newline at end of file
  71 +}
... ...
public/javascripts/jquery-ui-1.10.4/development-bundle/themes/base/minified/jquery.ui.theme.min.css
... ... @@ -1,5 +0,0 @@
1   -/*! jQuery UI - v1.10.4 - 2014-04-02
2   -* http://jqueryui.com
3   -* Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
4   -
5   -undefined
6 0 \ No newline at end of file
public/stylesheets/application.css
  1 +/*
  2 + * thidparty libraries
  3 + *= require colorbox
  4 + *= require selectordie
  5 + *= require selectordie-theme
  6 + *= require inputosaurus
  7 + *= require token-input
  8 + *= require token-input-facebook
  9 + *= require token-input-mac
  10 + *= require token-input-facet
  11 + * noosfero libraries
  12 + *= require_self
  13 + *= require iepngfix/iepngfix
  14 + * views specifics
  15 + *= require chat
  16 + *= require search
  17 + */
  18 +
1 19 /* browser fixes */
2 20  
3 21 img:-moz-broken {
... ... @@ -4403,7 +4421,8 @@ h1#agenda-title {
4403 4421 #groups-list li {
4404 4422 display: block;
4405 4423 list-style: none;
4406   - margin-bottom: 20px background-color: #B8CFE7;
  4424 + margin-bottom: 20px;
  4425 + background-color: #B8CFE7;
4407 4426 }
4408 4427  
4409 4428 #groups-list li .vcard {
... ... @@ -6918,8 +6937,8 @@ li.profile-activity-item.upload_image .activity-gallery-images-count-1 img {
6918 6937 }
6919 6938  
6920 6939 .fetching-overlay {
6921   - position: absolute;
6922   - top: 0px;
  6940 + position: absolute;
  6941 + top: 0px;
6923 6942 left: 0px;
6924 6943 right: 0px;
6925 6944 bottom: 0px;
... ...
public/stylesheets/search.css
... ... @@ -563,7 +563,8 @@ li.search-product-item {
563 563 }
564 564 li.search-product-item {
565 565 display:block;
566   - float:none overflow:visible;
  566 + float:none;
  567 + overflow:visible;
567 568 padding:10px 0;
568 569 margin:10px 0;
569 570 border-bottom:1px solid #ccc;
... ...
test/unit/application_helper_test.rb
... ... @@ -463,13 +463,13 @@ class ApplicationHelperTest &lt; ActionView::TestCase
463 463  
464 464 should 'base theme uses default icon theme' do
465 465 stubs(:current_theme).returns('base')
466   - assert_equal "/designs/icons/default/style.css", icon_theme_stylesheet_path.first
  466 + assert_equal "designs/icons/default/style.css", icon_theme_stylesheet_path.first
467 467 end
468 468  
469 469 should 'base theme uses config to specify more then an icon theme' do
470 470 stubs(:current_theme).returns('base')
471   - assert_includes icon_theme_stylesheet_path, "/designs/icons/default/style.css"
472   - assert_includes icon_theme_stylesheet_path, "/designs/icons/pidgin/style.css"
  471 + assert_includes icon_theme_stylesheet_path, "designs/icons/default/style.css"
  472 + assert_includes icon_theme_stylesheet_path, "designs/icons/pidgin/style.css"
473 473 end
474 474  
475 475 should 'not display active field if only required' do
... ...