In the public atom feed, the post title is not truncated
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.
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?
Also when uploading and posting a picture, it would be nice to have that picture's url show up in the content tag
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(/</?[^>]*>/, ""))}
Very interested in this issue and development, let me know if you need someone to test you atom feed "[email protected]"
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.
this is still an issue
Thanks for the update. If you'd like to convert the patch into a pull request we'll take a look at it.
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.
@maxwell have you worked on the atom feed?
I think we can leave the markdown in the text for now. For this issue, let's just address the title problem.
Can you please merge this? I am not sure if you have seen the fix.
Is there a pull request? Github doesn't seem to think so, although I thought I remembered one, but it clearly is not there
I do not know, but if not @beardedninja: Please make one.
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 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
Yeah I made pull request then closed it because the atom feeds were re-done in a nicer way, with truncation to boot.
Titles are truncated and links are clickable ... we got it all ;)