SpringAll icon indicating copy to clipboard operation
SpringAll copied to clipboard

In the public atom feed, the post title is not truncated

Open amckinstry opened this issue 15 years ago • 17 comments

Hi,

When I use DIASPORA* as a public blog platform the individual pages look fine, but the atom feed is unusable.

The problems are: (1) The whole message is used as a title. (2) The message is then repeated in the content, without any formatting.

amckinstry avatar Oct 16 '11 13:10 amckinstry

The problem is apps/models/status_message.rb

 def to_activity(opts={})
119     author = opts[:author] || self.author #Use an already loaded author if passed in.

121   <entry>
122     <title>#{x(self.formatted_message(:plain_text => true))}</title>
123     <content>#{x(self.formatted_message(:plain_text => true))}</content>
124     <link rel="alternate" type="text/html" href="#{author.url}p/#{self.id}"/>
125     <id>#{author.url}p/#{self.id}</id>
126     <published>#{self.created_at.xmlschema}

Lines 122,123. Preferably for the public feed 'title' would be a one-liner, and both would be escaped HTML, no?

amckinstry avatar Oct 16 '11 14:10 amckinstry

Also when uploading and posting a picture, it would be nice to have that picture's url show up in the content tag

wanderer avatar Oct 17 '11 03:10 wanderer

Ok, to do a proper job the atom feed would need to be converted to xml from markdown and then labelled as such, eg. <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" ... >

in the atom header. But I think this breaks internal operation of Diaspora. So instead, I've just converted the shared output to simple text, trimming the title (using markdownify to clear the markdown, and then stripping the html tags. So locally I'm testing:

diff --git a/app/models/status_message.rb b/app/models/status_message.rb index 07d206f..02e57d9 100644 --- a/app/models/status_message.rb +++ b/app/models/status_message.rb @@ -10,6 +10,7 @@ class StatusMessage < Post require File.join(Rails.root, 'lib/youtube_titles') include ActionView::Helpers::TextHelper include PeopleHelper

  • include MarkdownifyHelper

acts_as_taggable_on :tags extract_tags_from :raw_message @@ -116,8 +117,8 @@ class StatusMessage < Post author = opts[:author] || self.author #Use an already loaded author if passed in. <<-XML

  • #{x(self.formatted_message(:plain_text => true))}
  • #{x(self.formatted_message(:plain_text => true))}
  • #{x(markdownify(self.formatted_message(:plain_text => true)).gsub(/<\/?[^>]_>/, "").match(/\A._?$/)[0])}
  • #{x(markdownify(self.formatted_message(:plain_text => true)).gsub(/</?[^>]*>/, ""))}
#{author.url}p/#{self.id} #{self.created_at.xmlschema}

amckinstry avatar Nov 07 '11 16:11 amckinstry

Very interested in this issue and development, let me know if you need someone to test you atom feed "[email protected]"

ntetreau avatar Nov 15 '11 10:11 ntetreau

Thanks for reporting this. I think it's still an issue. I edited the title to be more in line with our other bug reports.

sarahmei avatar Jan 10 '12 04:01 sarahmei

this is still an issue

ntetreau avatar Jan 25 '12 14:01 ntetreau

Thanks for the update. If you'd like to convert the patch into a pull request we'll take a look at it.

sarahmei avatar Jan 26 '12 04:01 sarahmei

This patch needs work. In fact, stripping out the html tags led to poor results: posting photos, for example, led to blank posts as the images were stripped. Converting with markdownify() is right but the atom header needs to be added. Hints from someone who knows D* better as to whether this is safe (and where to do it) would be good.

amckinstry avatar Jan 26 '12 07:01 amckinstry

@maxwell have you worked on the atom feed?

sarahmei avatar Jan 26 '12 15:01 sarahmei

I think we can leave the markdown in the text for now. For this issue, let's just address the title problem.

sarahmei avatar Jan 29 '12 20:01 sarahmei

Can you please merge this? I am not sure if you have seen the fix.

gandaro avatar Mar 20 '12 13:03 gandaro

Is there a pull request? Github doesn't seem to think so, although I thought I remembered one, but it clearly is not there

maxwell avatar Mar 20 '12 15:03 maxwell

I do not know, but if not @beardedninja: Please make one.

gandaro avatar Mar 20 '12 15:03 gandaro

This one: #2926 ? That was for clickable links in Atom, but it was made obsolete since in the meantime something got pulled that changed the whole way the Atom feed is produced. It should not be too hard to adapt, though, I guess.

Otherwise, titles in the Atom feed are tuncated already: https://github.com/diaspora/diaspora/blob/master/app/views/users/public.atom.builder#L34

Raven24 avatar Mar 20 '12 15:03 Raven24

@Raven24 thank you for the clarification, I remember now. It would be great to get that feature back using the builder, which is SO much better :P

maxwell avatar Mar 20 '12 17:03 maxwell

Yeah I made pull request then closed it because the atom feeds were re-done in a nicer way, with truncation to boot.

beardedninja avatar Mar 20 '12 21:03 beardedninja

Titles are truncated and links are clickable ... we got it all ;)

Raven24 avatar Apr 06 '12 19:04 Raven24