Commit 224dcf933fcf1abbbdd0e8f3cf1ce53715bc4385
Exists in
master
and in
22 other branches
Merge branch 'stoa' of gitlab.com:colivre/noosfero into feedback
Showing
17 changed files
with
169 additions
and
41 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
... | ... | @@ -114,7 +114,7 @@ class CmsController < MyProfileController |
114 | 114 | @success_back_to = params[:success_back_to] |
115 | 115 | # user must choose an article type first |
116 | 116 | |
117 | - @parent = profile.articles.find(params[:parent_id]) if params && params[:parent_id] | |
117 | + @parent = profile.articles.find(params[:parent_id]) if params && params[:parent_id].present? | |
118 | 118 | record_coming |
119 | 119 | @type = params[:type] |
120 | 120 | if @type.blank? |
... | ... | @@ -159,7 +159,10 @@ class CmsController < MyProfileController |
159 | 159 | if continue |
160 | 160 | redirect_to :action => 'edit', :id => @article |
161 | 161 | else |
162 | - success_redirect | |
162 | + respond_to do |format| | |
163 | + format.html { success_redirect } | |
164 | + format.json { render :text => {:id => @article.id, :full_name => profile.identifier + '/' + @article.full_name}.to_json } | |
165 | + end | |
163 | 166 | end |
164 | 167 | return |
165 | 168 | end |
... | ... | @@ -477,7 +480,7 @@ class CmsController < MyProfileController |
477 | 480 | files = profile.files |
478 | 481 | end |
479 | 482 | |
480 | - files = files.more_recent | |
483 | + files = files.reorder('created_at DESC') | |
481 | 484 | images = files.images |
482 | 485 | generics = files.no_images |
483 | 486 | ... | ... |
app/models/profile_suggestion.rb
... | ... | @@ -157,4 +157,22 @@ class ProfileSuggestion < ActiveRecord::Base |
157 | 157 | self.save |
158 | 158 | end |
159 | 159 | |
160 | + def self.generate_all_profile_suggestions | |
161 | + Delayed::Job.enqueue(ProfileSuggestion::GenerateAllJob.new) unless ProfileSuggestion::GenerateAllJob.exists? | |
162 | + end | |
163 | + | |
164 | + def self.generate_profile_suggestions(person_id) | |
165 | + Delayed::Job.enqueue ProfileSuggestionsJob.new(person_id) unless ProfileSuggestionsJob.exists?(person_id) | |
166 | + end | |
167 | + | |
168 | + class GenerateAllJob | |
169 | + def self.exists? | |
170 | + Delayed::Job.by_handler("--- !ruby/object:ProfileSuggestion::GenerateAllJob {}\n").count > 0 | |
171 | + end | |
172 | + | |
173 | + def perform | |
174 | + Person.find_each {|person| ProfileSuggestion.generate_profile_suggestions(person.id) } | |
175 | + end | |
176 | + end | |
177 | + | |
160 | 178 | end | ... | ... |
app/views/admin_panel/_signup_welcome_screen.html.erb
1 | 1 | <div class='description'> |
2 | - <%= _('This text will be showed as a welcome message to users after signup.') %><br/><br/> | |
2 | + <%= _('If you enable this feature on the "Features" section of the Administration Panel, this text will be shown as a welcome message to users after signup.') %><br/><br/> | |
3 | 3 | </div> |
4 | 4 | <%= labelled_form_field(_('Body'), text_area(:environment, :signup_welcome_screen_body, :cols => 40, :style => 'width: 100%', :class => 'mceEditor')) %> |
5 | 5 | |
... | ... | @@ -8,4 +8,4 @@ |
8 | 8 | <%= _('If this content is left blank, the following page will be displayed to the user:') %><br/><br/> |
9 | 9 | </div> |
10 | 10 | <p> |
11 | -<%= render :file => 'home/welcome' %> | |
11 | +<%= render :file => 'home/welcome', :locals => {:default_message => true} %> | ... | ... |
... | ... | @@ -0,0 +1,15 @@ |
1 | +<%= form_tag({:action => 'new', :profile => profile.identifier}, :id => 'new-folder-dialog', :title => _('Create new folder'), :style => 'display: none;') do %> | |
2 | + <%= select_profile_folder( | |
3 | + _('Choose parent folder:'), | |
4 | + :parent_id, profile, default_folder, {}, {}, | |
5 | + "type='Folder' or type='Gallery'") | |
6 | + %> | |
7 | + | |
8 | + <%= content_tag(:label, radio_button_tag(:folder_type, 'Gallery', true) + _('Gallery')) %> | |
9 | + <%= content_tag(:label, radio_button_tag(:folder_type, 'Folder', false) + _('Folder')) %> | |
10 | + | |
11 | + <%= labelled_form_field _('Name:'), text_field_tag(:new_folder, nil, 'data-url' => url_for({:action => 'new', :profile => profile.identifier})) %> | |
12 | + <% button_bar do %> | |
13 | + <%= submit_button(:newfolder, _('Create')) %> | |
14 | + <% end %> | |
15 | +<% end %> | ... | ... |
app/views/cms/_text_editor_sidebar.html.erb
1 | +<% default_folder = content_id_to_str default_folder_for_image_upload(profile) %> | |
2 | + | |
1 | 3 | <div class='text-editor-sidebar'> |
2 | 4 | <span class='button-add' data-value='<%= _('Add to the text') %>'></span> |
3 | 5 | <span class='button-zoom' data-value='<%= _('Zoom in') %>'></span> |
4 | 6 | <span class='button-close' data-value='<%= _('Close') %>'></span> |
5 | 7 | |
8 | + <div class='header'><strong><%= _('Insert media') %></strong><%= button('vertical-toggle', _('Show/Hide'), '#') %></div> | |
9 | + | |
6 | 10 | <%= render(:partial => 'textile_quick_reference') if @article.is_a?(TextileArticle) %> |
7 | 11 | <div class='text-editor-sidebar-box' id='media-upload-box'> |
8 | - <div class='header'><strong><%= _('Insert media') %></strong></div> | |
9 | 12 | <div id='media-upload-form'> |
10 | 13 | <%= form_tag({ :action => 'media_upload' }, :multipart => true) do %> |
11 | 14 | <div class='formfield'> |
12 | - <% default_folder = content_id_to_str default_folder_for_image_upload(profile) %> | |
13 | 15 | <%= select_profile_folder( |
14 | 16 | _('Choose folder to upload files:'), |
15 | 17 | :parent_id, profile, default_folder, {}, {}, |
16 | 18 | "type='Folder' or type='Gallery'" |
17 | 19 | ) %> |
18 | 20 | </div> |
21 | + <%= button(:newfolder, _('New folder'), '#', :id => 'new-folder-button') %> | |
19 | 22 | <p><%= file_field_tag('file', :multiple => true) %></p> |
20 | 23 | <% end %> |
21 | 24 | </div> |
... | ... | @@ -26,7 +29,6 @@ |
26 | 29 | </div> |
27 | 30 | |
28 | 31 | <div id='published-media' class='text-editor-sidebar-box' data-url='<%= url_for({:controller => 'cms', :action => 'published_media_items', :profile => profile.identifier}) %>'> |
29 | - <div class='header'><strong><%= _('Published media') %></strong></div> | |
30 | 32 | <%= select_profile_folder(nil, :parent_id, profile, 'recent-media', {}, {}, |
31 | 33 | "type='Folder' or type='Gallery'", {:root_label => _('Recent media')}) %> |
32 | 34 | <%= labelled_form_field _('Search'), text_field_tag('q') %> |
... | ... | @@ -45,4 +47,5 @@ |
45 | 47 | </div> |
46 | 48 | </script> |
47 | 49 | |
50 | +<%= render :partial => 'media_new_folder', :locals => {:default_folder => default_folder} %> | |
48 | 51 | <%= javascript_include_tag 'jquery.fileupload.js', 'tmpl.js', 'media-panel.js' %> | ... | ... |
app/views/cms/media_upload.js.erb
1 | -<% klass = @file.class.name.split('::').last.to_css_class %> | |
2 | -jQuery("#published-media .items .<%= klass.pluralize %> .section-title").after("<%= j render :partial => "cms/media_panel/#{klass}" %>"); | |
3 | -jQuery("#published-media .items .<%= klass.pluralize %>").show(); | |
1 | +loadPublishedMedia(); | ... | ... |
app/views/enterprise_registration/creation.html.erb
1 | -<h1><%= __('Enterprise registration completed') %></h1> | |
2 | -<p><%= __("Your enterprise (%s) was successfully registered.") % @enterprise.name %></p> | |
3 | -<p><%= link_to __('You can manage your enterprise now.'), @enterprise.admin_url %></p> | |
1 | +<h1><%= _('Enterprise registration completed') %></h1> | |
2 | +<p><%= _("Your enterprise (%s) was successfully registered.") % @enterprise.name %></p> | |
3 | +<p><%= link_to _('You can manage your enterprise now.'), @enterprise.admin_url %></p> | |
4 | 4 | |
5 | 5 | <%= render :partial => 'shared/template_welcome_page', :locals => {:template => @enterprise.template, :header => _("What can I do with a %s?")} %> |
6 | 6 | ... | ... |
app/views/home/welcome.html.erb
1 | +<% default_message = defined?(default_message) ? default_message : false %> | |
2 | + | |
1 | 3 | <div id='thanks-for-signing'> |
2 | 4 | <h1><%= _("Welcome to %s!") % environment.name %></h1> |
3 | - <% if environment.has_custom_welcome_screen? %> | |
5 | + <% if environment.has_custom_welcome_screen? && !default_message %> | |
4 | 6 | <%= environment.settings[:signup_welcome_screen_body].html_safe %> |
5 | 7 | <% else %> |
6 | 8 | <h3><%= _("Thanks for signing up, we're thrilled to have you on our social network!") %></h3> | ... | ... |
app/views/memberships/welcome.html.erb
1 | -<h1><%= __('Community created') %></h1> | |
2 | -<p><%= __("Your community (%s) was successfully created.") % @community.name %></p> | |
3 | -<p><%= link_to __('You can manage your community now.'), @community.admin_url %></p> | |
1 | +<h1><%= _('Community created') %></h1> | |
2 | +<p><%= _("Your community (%s) was successfully created.") % @community.name %></p> | |
3 | +<p><%= link_to _('You can manage your community now.'), @community.admin_url %></p> | |
4 | 4 | |
5 | 5 | <%= render :partial => 'shared/template_welcome_page', :locals => {:template => @community.template, :header => _("What can I do with a %s?")} %> |
6 | 6 | ... | ... |
app/views/profile_editor/welcome_page.html.erb
app/views/shared/_lead_and_body.html.erb
... | ... | @@ -20,16 +20,16 @@ |
20 | 20 | <div class='article-lead' id="article-lead-<%=lead_id.to_s%>"> |
21 | 21 | |
22 | 22 | <% if f %> |
23 | - <%= labelled_form_field(_(abstract_label), f.text_area(abstract_method, :style => 'width: 98%; height: 200px;', :class => editor_type)) %> | |
23 | + <%= labelled_form_field(_(abstract_label), f.text_area(abstract_method, :style => 'width: 100%; height: 200px;', :class => editor_type)) %> | |
24 | 24 | <% else %> |
25 | - <%= labelled_form_field(_(abstract_label), text_area(object, abstract_method, :style => 'width: 98%; height: 200px;', :class => editor_type)) %> | |
25 | + <%= labelled_form_field(_(abstract_label), text_area(object, abstract_method, :style => 'width: 100%; height: 200px;', :class => editor_type)) %> | |
26 | 26 | <% end %> |
27 | 27 | </div> |
28 | 28 | <div style="margin-top: 10px;"> |
29 | 29 | <% if f %> |
30 | - <%= labelled_form_field(_(body_label), f.text_area(body_method, :style => 'width: 98%; height: 400px;', :class => editor_type)) %> | |
30 | + <%= labelled_form_field(_(body_label), f.text_area(body_method, :style => 'width: 100%; height: 400px;', :class => editor_type)) %> | |
31 | 31 | <% else %> |
32 | - <%= labelled_form_field(_(body_label), text_area(object, body_method, :style => 'width: 98%; height: 400px;', :class => editor_type)) %> | |
32 | + <%= labelled_form_field(_(body_label), text_area(object, body_method, :style => 'width: 100%; height: 400px;', :class => editor_type)) %> | |
33 | 33 | <% end %> |
34 | 34 | </div> |
35 | 35 | ... | ... |
config/schedule.rb
lib/profile_suggestions_job.rb
1 | 1 | class ProfileSuggestionsJob < Struct.new(:person_id) |
2 | 2 | |
3 | + def self.exists?(person_id) | |
4 | + !find(person_id).empty? | |
5 | + end | |
6 | + | |
7 | + def self.find(person_id) | |
8 | + Delayed::Job.by_handler("--- !ruby/struct:ProfileSuggestionsJob\nperson_id: #{person_id}\n") | |
9 | + end | |
10 | + | |
3 | 11 | def perform |
12 | + logger = Delayed::Worker.logger | |
4 | 13 | begin |
5 | 14 | person = Person.find(person_id) |
6 | 15 | |
7 | 16 | ProfileSuggestion::RULES.each do |rule| |
8 | 17 | ProfileSuggestion.send(rule, person) |
9 | 18 | end |
10 | - | |
11 | 19 | UserMailer.profiles_suggestions_email(person).deliver |
12 | 20 | rescue Exception => exception |
13 | - Rails.logger.warn("Error with suggestions for person ID %d\n%s" % [person_id, exception.to_s]) | |
21 | + logger.warn("Error with suggestions for person ID %d: %s" % [person_id, exception.to_s]) | |
14 | 22 | end |
15 | 23 | end |
16 | 24 | ... | ... |
public/designs/icons/tango/style.css
... | ... | @@ -72,6 +72,7 @@ |
72 | 72 | .icon-newupload-file { background-image: url(Tango/16x16/actions/filesave.png) } |
73 | 73 | .icon-slideshow { background-image: url(Tango/16x16/mimetypes/x-office-presentation.png) } |
74 | 74 | .icon-photos { background-image: url(Tango/16x16/devices/camera-photo.png) } |
75 | +.icon-vertical-toggle { background-image: url(Tango/16x16/actions/mail-send-receive.png) } | |
75 | 76 | |
76 | 77 | .icon-text-html { background-image: url(Tango/16x16/mimetypes/text-html.png) } |
77 | 78 | .icon-text-plain { background-image: url(Tango/16x16/mimetypes/text-x-generic.png) } | ... | ... |
public/javascripts/article.js
... | ... | @@ -74,9 +74,9 @@ jQuery(function($) { |
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | - function zoom_dialog_html(img) { | |
77 | + function zoom_dialog_html(name, img) { | |
78 | 78 | // FIXME organize this code better |
79 | - return '<div class="item" data-item="div"><div><img src="' + img + '" style="max-width: 640px; max-height: 480px"/></div>' + '<div class="button-bar">' + add_to_text_button('with-text') + ' ' + close_button('with-text') + '</div></div>' | |
79 | + return '<h3 style="text-align: center;">'+ name +'</h3><div class="item" data-item="div"><div><img src="' + img + '" style="max-width: 640px; max-height: 480px"/></div>' + '<div class="button-bar">' + add_to_text_button('with-text') + ' ' + close_button('with-text') + '</div></div>' | |
80 | 80 | } |
81 | 81 | |
82 | 82 | $('.view-all-images .item').live('click', function(){ |
... | ... | @@ -94,9 +94,10 @@ jQuery(function($) { |
94 | 94 | $('a.zoom').live('click', function() { |
95 | 95 | var $item = $(this).closest('.item'); |
96 | 96 | var html_selector = $item.attr('data-item'); |
97 | + var name = $item.attr('title'); | |
97 | 98 | var img = $item.find(html_selector).find('img').attr('src'); |
98 | 99 | $.colorbox({ |
99 | - html: zoom_dialog_html(img), | |
100 | + html: zoom_dialog_html(name, img), | |
100 | 101 | scrolling: false |
101 | 102 | }); |
102 | 103 | return false; | ... | ... |
public/javascripts/media-panel.js
... | ... | @@ -84,3 +84,45 @@ jQuery("#published-media #q").typeWatch({ |
84 | 84 | }); |
85 | 85 | |
86 | 86 | jQuery("#published-media #q").bind('notext', function(){ loadPublishedMedia() }); |
87 | + | |
88 | +jQuery("#new-folder-dialog").submit(function( event ) { | |
89 | + var name = jQuery('#new_folder').val(); | |
90 | + var parent_id = jQuery("#new-folder-dialog #parent_id").val(); | |
91 | + jQuery("#media-upload-box #parent_id").val(); | |
92 | + jQuery.ajax({ | |
93 | + url: this.action, | |
94 | + type: 'POST', | |
95 | + data: { | |
96 | + 'parent_id': parent_id, | |
97 | + 'article': {'name': name, 'published': true}, | |
98 | + 'type': jQuery('input[name=folder_type]:checked').val() }, | |
99 | + dataType: 'json', | |
100 | + beforeSend: function(){jQuery("#new-folder-dialog").addClass('fetching')}, | |
101 | + success: function(response) { | |
102 | + var option_selected = "<option value='"+ response.id +"' selected='selected'>"+ response.full_name +"</options>" | |
103 | + var option = "<option value='"+ response.id +"'>"+ response.full_name +"</options>" | |
104 | + jQuery('#media-upload-form #parent_id').append(option_selected); | |
105 | + jQuery('#published-media #parent_id').append(option); | |
106 | + jQuery('#new_folder').val(''); | |
107 | + }, | |
108 | + error: function(response, textStatus, xhr) { | |
109 | + console.log(response); | |
110 | + console.log(textStatus); | |
111 | + }, | |
112 | + complete: function(response){ | |
113 | + jQuery("#new-folder-dialog").removeClass('fetching'); | |
114 | + jQuery("#new-folder-dialog").dialog('close'); | |
115 | + } | |
116 | + }); | |
117 | + return false; | |
118 | +}); | |
119 | + | |
120 | +jQuery('.text-editor-sidebar .header .icon-vertical-toggle').click(function(){ | |
121 | + jQuery('#content').toggleClass('show-media-panel'); | |
122 | + return false; | |
123 | +}); | |
124 | + | |
125 | +jQuery('#new-folder-button').click(function(){ | |
126 | + jQuery('#new-folder-dialog').dialog({modal: true}); | |
127 | + return false; | |
128 | +}); | ... | ... |
public/stylesheets/application.css
... | ... | @@ -3443,11 +3443,18 @@ table.cms-articles .icon:hover { |
3443 | 3443 | |
3444 | 3444 | /* Text editors sidebar */ |
3445 | 3445 | |
3446 | -.controller-cms div.with_media_panel { | |
3446 | +.controller-cms .with_media_panel { | |
3447 | 3447 | float: left; |
3448 | + width: 900px; | |
3449 | + transition: 1s 0.5s; | |
3450 | +} | |
3451 | + | |
3452 | +.controller-cms .show-media-panel .with_media_panel { | |
3448 | 3453 | width: 600px; |
3454 | + transition: 1s; | |
3449 | 3455 | } |
3450 | -div.with_media_panel .formfield input[type="checkbox"] { | |
3456 | + | |
3457 | +.with_media_panel .formfield input[type="checkbox"] { | |
3451 | 3458 | width: auto; |
3452 | 3459 | } |
3453 | 3460 | |
... | ... | @@ -3466,6 +3473,11 @@ div.with_media_panel .formfield input[type="checkbox"] { |
3466 | 3473 | float: right; |
3467 | 3474 | } |
3468 | 3475 | |
3476 | +#media-upload-form .progress { | |
3477 | + background-color: #ddd; | |
3478 | + border-radius: 3px; | |
3479 | +} | |
3480 | + | |
3469 | 3481 | #media-upload-form .bar { |
3470 | 3482 | height: 10px; |
3471 | 3483 | background: #729fcf; |
... | ... | @@ -3496,13 +3508,14 @@ div.with_media_panel .formfield input[type="checkbox"] { |
3496 | 3508 | } |
3497 | 3509 | |
3498 | 3510 | #media-upload-box .upload .file-name{ |
3499 | - width: 87%; | |
3511 | + width: 86%; | |
3500 | 3512 | white-space: nowrap; |
3501 | 3513 | overflow: hidden; |
3502 | 3514 | text-overflow: ellipsis; |
3503 | 3515 | } |
3504 | 3516 | |
3505 | 3517 | #media-upload-box .upload .percentage { |
3518 | + text-align: right; | |
3506 | 3519 | width: 12%; |
3507 | 3520 | } |
3508 | 3521 | |
... | ... | @@ -3512,6 +3525,14 @@ div.with_media_panel .formfield input[type="checkbox"] { |
3512 | 3525 | width: 280px; |
3513 | 3526 | right: 20px; |
3514 | 3527 | top: 70px; |
3528 | + max-height: 45px; | |
3529 | + overflow: hidden; | |
3530 | + transition: 1s; | |
3531 | +} | |
3532 | + | |
3533 | +.show-media-panel .text-editor-sidebar { | |
3534 | + max-height: 1200px; | |
3535 | + transition: 1s 0.5s; | |
3515 | 3536 | } |
3516 | 3537 | |
3517 | 3538 | .text-editor-sidebar-box { |
... | ... | @@ -3521,12 +3542,23 @@ div.with_media_panel .formfield input[type="checkbox"] { |
3521 | 3542 | margin-bottom: 10px; |
3522 | 3543 | } |
3523 | 3544 | |
3524 | -.text-editor-sidebar-box .header { | |
3525 | - margin: -10px -10px 0px -10px; | |
3526 | - padding: 10px; | |
3527 | - font-weight: bold; | |
3528 | - border-bottom: 1px solid #d3d7cf; | |
3529 | - background-color: #eeeeec; | |
3545 | +.text-editor-sidebar .header { | |
3546 | + margin: 0 0 10px 0; | |
3547 | + padding: 10px; | |
3548 | + font-weight: bold; | |
3549 | + border: 1px solid #d3d7cf; | |
3550 | + background-color: #eeeeec; | |
3551 | + background-repeat: no-repeat; | |
3552 | + background-position: 98% 10px; | |
3553 | + position: relative; | |
3554 | +} | |
3555 | + | |
3556 | +.text-editor-sidebar .header .icon-vertical-toggle { | |
3557 | + position: absolute; | |
3558 | + right: 6px; | |
3559 | + top: 6px; | |
3560 | + padding-top: 0px; | |
3561 | + padding-bottom: 0px; | |
3530 | 3562 | } |
3531 | 3563 | |
3532 | 3564 | .text-editor-sidebar code, |
... | ... | @@ -3601,6 +3633,7 @@ div.with_media_panel .formfield input[type="checkbox"] { |
3601 | 3633 | .text-editor-sidebar select, |
3602 | 3634 | .text-editor-sidebar input { |
3603 | 3635 | width: 100%; |
3636 | + margin-bottom: 5px; | |
3604 | 3637 | } |
3605 | 3638 | |
3606 | 3639 | .text-editor-sidebar .items :hover, |
... | ... | @@ -3639,10 +3672,6 @@ div.with_media_panel .formfield input[type="checkbox"] { |
3639 | 3672 | margin-top: 4px; |
3640 | 3673 | } |
3641 | 3674 | |
3642 | -.text-editor-sidebar .header { | |
3643 | - background-repeat: no-repeat; | |
3644 | - background-position: 98% 10px; | |
3645 | -} | |
3646 | 3675 | .text-editor-sidebar .media-upload-error { |
3647 | 3676 | color: red; |
3648 | 3677 | } |
... | ... | @@ -6918,3 +6947,7 @@ li.profile-activity-item.upload_image .activity-gallery-images-count-1 img { |
6918 | 6947 | .fetching { |
6919 | 6948 | opacity: 0.3; |
6920 | 6949 | } |
6950 | + | |
6951 | +body .ui-widget-overlay { | |
6952 | + background: #000; | |
6953 | +} | ... | ... |