Page MenuHomePhabricator

RSS: Automatically find "link" from "description" field
Closed, DeclinedPublicFeature

Description

Feature summary (what you would like to be able to do and where): I'd like it if the link element could optionally be generated automatically from the first link to appear within the "description" field. I think this would have to be an option, as usually people would want the link to go to the relevant wiki page.

Is this an option that you'd be willing to add? If not, I'll have a think and likely can find a way round it (maybe by manually storing the link as a separate Cargo field).

Use case(s) (list the steps that you performed to discover that problem, and describe the actual underlying problem which you want to solve. Do not describe only a solution): I have a "News" table but don't want the RSS link element to be the wiki page. Instead I want it to be the link (or a link) from the description element.

Benefits (why should this be implemented?): See Use case above.

Event Timeline

Does the url field not already do this?

I've added some notes to the docs about what field names are possible. Feel free to edit.

The url field could be used for that but I'd need to add a separate URL field to my Cargo table, manually add the URL for each item, and include that field in the Cargo query. That's likely what I will do.

But it would be easier if the feed format would just take the description, see that no url field appears in the Cargo query, and automatically take a URL from the description.

Thanks, the changes look good!

The url field could be used for that but I'd need to add a separate URL field to my Cargo table, manually add the URL for each item, and include that field in the Cargo query. That's likely what I will do.

Perhaps you could do it without creating a new field in the table, but by constructing the required link with CONCAT within the query? It seems to me that there must be something about the rows in your query that is part of the URL you want to use, otherwise how do you know that the items are different? Even if they're multiple items from the same page, could you perhaps add a section ID or something?

the first link to appear within the "description" field

I feel like this is likely to be unexpected behaviour, and actually I'm not really sure how we'd go about extracting the link. @Yaron_Koren do you have an opinion about this task?

Yes, this sounds like a "too-clever" solution, which indeed could lead to unexpected behavior - I don't think it's a good idea.

It would be fairly simple and if you had a link from description parameter it shouldn't lead to unintended consequences. If I were to submit a patch here would you consider it?

That's true, "link from description" would solve the problem of unexpected behavior. But is this even that useful? Is it common for the canonical link of a news/etc. item to be contained within the description, and then for it be guaranteed as the first link? This might be specific to your particular description format.

Yes, it might be! It would be useful when you're using Cargo as a back end for an RSS feed but never want the Cargo wiki page to be visited. I can't remember whether I use the first or last link as usually there is only one, e.g. "A new Between the Brackets podcast has been released: see [link]." Hypothetical example :-)

It could reuse whatever code I'm using at the minute to achieve the same effect (just simple pattern matching on the HTML).

Admittedly, adding a separate link field would have a similar effect, though if Cargo could do it automatically it would be easier.

I still don't really see the point of a "link from description" parameter. If you use the "url" field, then you don't even need the "see ..." text, because the link is already there - no? And of course, with "url", you don't need to worry that every editor remembers the required format for the description.

Yes, maybe I'm trying to shoehorn my old ways into Cargo where they don't fit... I've used the Bulletfeed extension for ages. It was a tag extension that converted a bullet list into an RSS feed (with an optional extra tag per bullet for description). It took the link from the description (parsing the HTML so treating internal and external links alike) as there wasn't a separate tag for url. When Cargo came along I just used Cargo to create the same bullet list. But since I can now cut out the middle man there's no reason I couldn't specify the url in the query. I'll give that a go anyway.

I hadn't heard of the (now-archived) Bullet Feed extension - I just looked at it. Very interesting; yes, it has a more informal approach to linking and all that. Okay, I'm glad you can modify your setup to handle this more structured approach. I'm "declining" this task; hopefully that's alright.