diff --git a/app/assets/javascripts/discourse/components/user-stream.js.es6 b/app/assets/javascripts/discourse/components/user-stream.js.es6
index 0b37142ff66..90b97cdf7de 100644
--- a/app/assets/javascripts/discourse/components/user-stream.js.es6
+++ b/app/assets/javascripts/discourse/components/user-stream.js.es6
@@ -17,6 +17,7 @@ export default Ember.Component.extend(LoadMore, {
$(window).on('resize.discourse-on-scroll', () => this.scrolled());
+ this.$().on('click.details-disabled', 'details.disabled', () => false)
this.$().on('mouseup.discourse-redirect', '.excerpt a', function(e) {
// bypass if we are selecting stuff
const selection = window.getSelection && window.getSelection();
@@ -38,6 +39,7 @@ export default Ember.Component.extend(LoadMore, {
_destroyed: function() {
this.unbindScrolling('user-stream-view');
$(window).unbind('resize.discourse-on-scroll');
+ this.$().off('click.details-disabled', 'details.disabled')
// Unbind link tracking
this.$().off('mouseup.discourse-redirect', '.excerpt a');
diff --git a/app/assets/javascripts/discourse/templates/components/user-card-contents.hbs b/app/assets/javascripts/discourse/templates/components/user-card-contents.hbs
index 441b877b14f..31e9c70b270 100644
--- a/app/assets/javascripts/discourse/templates/components/user-card-contents.hbs
+++ b/app/assets/javascripts/discourse/templates/components/user-card-contents.hbs
@@ -42,7 +42,7 @@
{{#if user.can_send_private_message_to_user}}
- -
+
-
{{d-button
class="btn-primary"
action=(action "composePrivateMessage" user post)
diff --git a/app/assets/stylesheets/common/components/user-stream-item.scss b/app/assets/stylesheets/common/components/user-stream-item.scss
index ef31dfbe1ce..5c98eff7d22 100644
--- a/app/assets/stylesheets/common/components/user-stream-item.scss
+++ b/app/assets/stylesheets/common/components/user-stream-item.scss
@@ -110,6 +110,10 @@
font-size: 0.929em;
word-wrap: break-word;
color: $primary;
+
+ details.disabled {
+ color: $primary-medium;
+ }
}
}
diff --git a/lib/excerpt_parser.rb b/lib/excerpt_parser.rb
index e56a3c32373..5420ef59e04 100644
--- a/lib/excerpt_parser.rb
+++ b/lib/excerpt_parser.rb
@@ -18,6 +18,7 @@ class ExcerptParser < Nokogiri::XML::SAX::Document
@keep_onebox_source = options[:keep_onebox_source] == true
@remap_emoji = options[:remap_emoji] == true
@start_excerpt = false
+ @summary_contents = ""
end
def self.get_excerpt(html, length, options)
@@ -108,6 +109,10 @@ class ExcerptParser < Nokogiri::XML::SAX::Document
include_tag("span", attributes)
@in_spoiler = true
end
+ when "details"
+ @in_details = true
+ when "summary"
+ @in_summary = true
end
end
@@ -126,6 +131,14 @@ class ExcerptParser < Nokogiri::XML::SAX::Document
end
when "aside"
@in_quote = false
+ when "details"
+ @in_details = false
+ when "summary"
+ @in_summary = false
+ if @summary_contents.present?
+ @excerpt << "
#{@summary_contents[0..@length]}
"
+ end
+ @summary_contents = ""
when "div", "span"
throw :done if @start_excerpt
characters("", false, false, false) if @in_spoiler
@@ -135,8 +148,15 @@ class ExcerptParser < Nokogiri::XML::SAX::Document
def characters(string, truncate = true, count_it = true, encode = true)
return if @in_quote
+
# we call length on this so might as well ensure we have a string
string = string.to_s
+ if @in_details
+ if @in_summary
+ @summary_contents << string
+ end
+ return
+ end
encode = encode ? lambda { |s| ERB::Util.html_escape(s) } : lambda { |s| s }
if count_it && @current_length + string.length > @length
diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb
index 52ad0b61830..114ae5e4f77 100644
--- a/spec/components/pretty_text_spec.rb
+++ b/spec/components/pretty_text_spec.rb
@@ -385,6 +385,10 @@ describe PrettyText do
expect(PrettyText.excerpt("spoiler", 100)).to match_html "spoiler"
end
+ it "should keep details" do
+ expect(PrettyText.excerpt("expand
hello
", 30)).to match_html "expand
"
+ end
+
it "should remove meta informations" do
expect(PrettyText.excerpt(wrapped_image, 100)).to match_html "[image]"
end