diff --git a/app/models/article.rb b/app/models/article.rb index 2f27375..921d238 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -2,7 +2,7 @@ require 'hpricot' class Article < ActiveRecord::Base - track_actions :create_article, :after_create, :keep_params => [:name, :url, :lead], :if => Proc.new { |a| a.is_trackable? && !a.image? } + track_actions :create_article, :after_create, :keep_params => [:name, :url, :lead, :first_image], :if => Proc.new { |a| a.is_trackable? && !a.image? } # xss_terminate plugin can't sanitize array fields before_save :sanitize_tag_list @@ -566,6 +566,11 @@ class Article < ActiveRecord::Base ActionTracker::Record.find_by_target_type_and_target_id 'Article', self.id end + def first_image + img = Hpricot(self.lead.to_s).search('img[@src]').first || Hpricot(self.body.to_s).search('img').first + img.nil? ? '' : img.attributes['src'] + end + private def sanitize_tag_list diff --git a/app/views/profile/_comment.rhtml b/app/views/profile/_comment.rhtml index 01a45bf..3398bf4 100644 --- a/app/views/profile/_comment.rhtml +++ b/app/views/profile/_comment.rhtml @@ -4,8 +4,7 @@
<%= comment.title %>
<%= txt2html comment.body %>
<%= link_to activity.user.name, activity.user.url %> <%= describe activity %>
-<%= activity.params['lead'] %>
+<%= time_ago_as_sentence(activity.created_at) + ' ' + _('ago') %>
- <% if logged_in? && current_person.follows?(activity.user) %> - <%= link_to_function _('Comment'), "hide_and_show(['#profile-wall-reply-response-#{activity.id}'],['#profile-wall-reply-#{activity.id}', '#profile-wall-reply-form-#{activity.id}']);$('reply_content_#{activity.id}').value='';$('reply_content_#{activity.id}').focus();$('activity_id_#{activity.id}').value='#{activity.id}';return false", :class => "profile-send-reply" %> - <% end %> -
<%= render :partial => 'comment', :collection => activity.comments %>
diff --git a/config/environments/development.rb b/config/environments/development.rb index 0c45bc1..d67452f 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,21 +1,17 @@ # Settings specified here will take precedence over those in config/environment.rb -# The production environment is meant for finished, "live" apps. -# Code is not reloaded between requests -config.cache_classes = true +# In the development environment your application's code is reloaded on +# every request. This slows down response time but is perfect for development +# since you don't have to restart the webserver when you make code changes. +config.cache_classes = false -# Use a different logger for distributed setups -# config.logger = SyslogLogger.new +# Log error messages when you accidentally call methods on nil. +config.whiny_nils = true -# Full error reports are disabled and caching is turned on -config.action_controller.consider_all_requests_local = false -config.action_controller.perform_caching = true -config.action_view.cache_template_loading = true +# Show full error reports and disable caching +config.action_controller.consider_all_requests_local = true +config.action_view.debug_rjs = true +config.action_controller.perform_caching = false -# Enable serving of images, stylesheets, and javascripts from an asset server -# config.action_controller.asset_host = "http://assets.example.com" - -# Disable delivery errors, bad email addresses will be ignored -# config.action_mailer.raise_delivery_errors = false - -config.cache_store = :mem_cache_store, "localhost" +# Don't care if the mailer can't send +config.action_mailer.raise_delivery_errors = false diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 9a134e7..88ca7df 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -5883,11 +5883,24 @@ h1#agenda-title { #profile-activity li, #profile-network li, #profile-wall li { display: block; padding: 10px; - margin-bottom: 0; + margin-bottom: 10px; background-color: #f0f0f1; border-bottom: 0; } +.profile-activity-lead img { + width: 64px; + float: left; + margin-right: 5px; +} + +.profile-activity-lead { + width: 370px; + float: right; + text-align: left; + margin: 5px 0; +} + #profile-activity li a, #profile-network li a, #profile-wall li a, #profile-wall .profile-wall-send-reply { color: #333; @@ -6169,6 +6182,7 @@ h1#agenda-title { background: #e8e8e8; border-bottom: 1px solid #d2d2d2 !important; border-top: 1px solid #fff; + margin-bottom: 0; } #profile-wall .profile-wall-activities-comments img { diff --git a/test/unit/article_test.rb b/test/unit/article_test.rb index 6f905af..78fb647 100644 --- a/test/unit/article_test.rb +++ b/test/unit/article_test.rb @@ -1584,4 +1584,20 @@ assert_equal 'bla', profile.articles.map(&:comments_count) assert_includes Article.created_between(from, to), article2 assert_not_includes Article.created_between(from, to), article3 end + + should 'get first image from lead' do + a = fast_create(Article, :body => 'Foo
Bar
', + :abstract => 'Lead
Bar
') + assert_equal 'leadbar.png', a.first_image + end + + should 'get first image from body' do + a = fast_create(Article, :body => 'Foo
Bar
') + assert_equal 'bar.png', a.first_image + end + + should 'not get first image from anywhere' do + a = fast_create(Article, :body => 'Foo
Bar
') + assert_equal '', a.first_image + end end -- libgit2 0.21.2