Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: Melonking on March 18, 2023, 06:45:45 PM

Title: Change the author on RSS feeds to username?
Post by: Melonking on March 18, 2023, 06:45:45 PM
Is it possible to change the author included in the RSS feeds from emails to usernames?

I have some forum members who like to script their own RSS readers; they don't want to deal with atom apparently because it's harder to work with. It would handy if I could just swap this setting for them  ;D

Modifying PHP code is not an issue, id just like a pointer as to where and if there is the best way to do this.
Title: Re: Change the author on RSS feeds to username?
Post by: Arantor on March 18, 2023, 07:39:05 PM
If these people really did RSS properly, they'd know that the format explicitly directs using emails, it's literally in the specification to use email addresses for the <author> element of an <item>.

Changing it would potentially make the output invalid, unless you were to use email@domain (username) as a format. Here's the thing: if you're going that far, *just use Atom*. If you're hand parsing XML in this day and age and not using a library to unpack the XML, you're doing it wrong, period. And if you're using a library that only handles the XML, you're just targeting a slightly different element to get the author/

Code ((rss)) Select
        <item>
            <title>Change the author on RSS feeds to username?</title>
            <link>https://www.simplemachines.org/community/index.php?topic=585413.0</link>
            <description><![CDATA[Is it possible to change the author included in the RSS feeds from emails to usernames?<br><br>I have some forum members who like to script their own RSS readers; they don&#39;t want to deal with atom apparently because it&#39;s harder to work with. It would handy if...]]></description>
            <comments>https://www.simplemachines.org/community/index.php?action=post;topic=585413.0</comments>
            <category>SMF 2.0.x Support</category>
            <pubDate>Sat, 18 Mar 2023 22:45:45 GMT</pubDate>
            <guid isPermaLink="false">tag:www.simplemachines.org,2023-03-18:topic=585413</guid>
        </item>

(note the email is not even exposed by default in RSS, I don't see email addresses here because I'm not an admin or have the moderate forum permission, which your users won't either unless you give it out to them and then their weird RSS reader will have to log in first anyway which is just... weird, this is literally one of the reasons Atom was invented)

    <entry>
        <title>Change the author on RSS feeds to username?</title>
        <link rel="alternate" type="text/html" href="https://www.simplemachines.org/community/index.php?topic=585413.0" />
        <summary type="html"><![CDATA[Is it possible to change the author included in the RSS feeds from emails to usernames?<br><br>I have some forum members who like to script their own RSS readers; they don&#39;t want to deal with atom apparently because it&#39;s harder to work with. It would handy if...]]></summary>
        <category term="SMF 2.0.x Support" />
        <author>
            <name>Melonking</name>
            <uri>https://www.simplemachines.org/community/index.php?action=profile;u=653733</uri>
        </author>
        <published>2023-03-18T22:45:45Z</published>
        <updated>2023-03-18T22:45:45Z</updated>
        <id>tag:www.simplemachines.org,2023-03-18:topic=585413</id>
    </entry>

Notice how much *wildly* different the structure is (almost none at all). If you're using any competent XML library this is a *trivial* change. E.g. in SimpleXML, it's $xml->entry->author->name as opposed to... what would be $xml->item->author (and then string munge it if it were altered to export the email address)
Title: Re: Change the author on RSS feeds to username?
Post by: Melonking on March 18, 2023, 07:58:45 PM
You always come across as being in a bad mood Arantor but I always appreciate you taking the time to reply  :D

I think they are just playing around with a bit of Lua and probably don't know a lot about specs or programming, they said something about wanting to get the latest posts to appear in a program called conky (https://github.com/brndnmtthws/conky).

I let them know it won't be possible  :(
Title: Re: Change the author on RSS feeds to username?
Post by: Arantor on March 18, 2023, 08:38:38 PM
Quote from: Melonking on March 18, 2023, 07:58:45 PMYou always come across as being in a bad mood

I usually am in a bad mood. Something about this place does that.

In this case it's your developer folks who are making some assertions that aren't true - seriously, if you're already wrangling RSS, Atom is literally no more complex. It's just a little bit different as per the samples above.
Title: Re: Change the author on RSS feeds to username?
Post by: Sesquipedalian on March 18, 2023, 11:48:12 PM
Quote from: Melonking on March 18, 2023, 07:58:45 PMI let them know it won't be possible  :(

It's entirely possible. They just have to use the right tool, which is Atom.
Title: Re: Change the author on RSS feeds to username?
Post by: Steve on March 19, 2023, 05:38:19 AM
Quote from: Melonking on March 18, 2023, 07:58:45 PMYou always come across as being in a bad mood Arantor
Don't let him fool you, he's actually a nice guy. He just doesn't put up with any bull crap and isn't afraid to be blunt about it.  :P