Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically select a bridge based on a URL #928

Merged
merged 6 commits into from
Nov 26, 2018
Merged

Automatically select a bridge based on a URL #928

merged 6 commits into from
Nov 26, 2018

Conversation

Roliga
Copy link
Contributor

@Roliga Roliga commented Nov 15, 2018

Hey some time ago I opened #743 and I thought I'd give implementing this feature a shot.

To summarize idea here is to add a new detect action which when given a URL automatically redirects the user directly to a feed, similar to the "I'm feeling lucky" feature some search engines have.

For example to get a feed from: #rss-bridge on twitter we could send a request to:
/?action=detect&format=Atom&url=twitter.com/search%3Fq%3D%2523rss-bridge
which would redirect to: /?action=display&q=%23rss-bridge&bridge=Twitter&format=Atom.

My personal use case for this is integration with my web browser: A browser shortcut that sends the current page URL to rss-bridge which then gives me a feed right away.

In #743 it was brought up to use this to display and auto-fill a bridge in the rss-bridge web UI. That'd need some more work, but it should be compatible with the server-side code in this PR I'd imagine!

Either way feedback appreciated! (:

Roliga added 3 commits November 15, 2018 20:58
This adds a new 'detect' action which accepts a URL from which an
appropriate bridge is selected and relevant parameters are extracted.
The user is then automatically redirected to the selected bridge.

For example to get a feed from: https://twitter.com/search?q=%23rss-bridge
we could send a request to:
'/?action=detect&format=Atom&url=twitter.com/search%3Fq%3D%2523rss-bridge'
which would redirect to:
'/?action=display&q=%23rss-bridge&bridge=Twitter&format=Atom'.

This auto detection happens on a per-bridge basis, so a new function
'detectParameters' is added to BridgeInterface which bridges may implement.
It takes a URL for an argument and returns a list of parameters that were
extracted, or null if the URL isn't relevant for the bridge.
This adds generic "paramater detection" for bridges that don't have any
parameters defined. If the queried URL matches the URI defined in the
bridge (ignoring https://, www. and trailing /) an emtpy list of parameters is
returned.
@logmanoriginal logmanoriginal added the New-Feature This is a new feature label Nov 15, 2018
Copy link
Member

@logmanoriginal logmanoriginal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, this is an awesome addition! 🥇

Find below a few comments.

I'll push lots of documentation changes in a few minutes (to master), which is why I added comments regarding function documentation to your PR.

lib/BridgeInterface.php Outdated Show resolved Hide resolved
lib/BridgeInterface.php Outdated Show resolved Hide resolved
lib/BridgeAbstract.php Show resolved Hide resolved
index.php Outdated Show resolved Hide resolved
index.php Show resolved Hide resolved
index.php Outdated Show resolved Hide resolved
index.php Outdated Show resolved Hide resolved
@logmanoriginal logmanoriginal merged commit 49da67c into RSS-Bridge:master Nov 26, 2018
@logmanoriginal
Copy link
Member

Merged. Thanks for adding the changes!

Please add some documentation to the Wiki if possible:
https://github.com/RSS-Bridge/rss-bridge/wiki/Actions

@Roliga
Copy link
Contributor Author

Roliga commented Nov 27, 2018

Sweet, thanks!

I added some documentation on the Actions page as well as a new page for the detectParameters function!

@yardenac
Copy link
Contributor

This is wonderful. A game-changer, IMO. Thank you so much for getting it done.

infominer33 pushed a commit to web-work-tools/rss-bridge that referenced this pull request Apr 17, 2020
* core: Add bridge parameter auto detection

This adds a new 'detect' action which accepts a URL from which an
appropriate bridge is selected and relevant parameters are extracted.
The user is then automatically redirected to the selected bridge.

For example to get a feed from: https://twitter.com/search?q=%23rss-bridge
we could send a request to:
'/?action=detect&format=Atom&url=twitter.com/search%3Fq%3D%2523rss-bridge'
which would redirect to:
'/?action=display&q=%23rss-bridge&bridge=Twitter&format=Atom'.

This auto detection happens on a per-bridge basis, so a new function
'detectParameters' is added to BridgeInterface which bridges may implement.
It takes a URL for an argument and returns a list of parameters that were
extracted, or null if the URL isn't relevant for the bridge.

* [TwitterBridge] Add parameter auto detection

* [BridgeAbstract] Add generic parameter detection

This adds generic "paramater detection" for bridges that don't have any
parameters defined. If the queried URL matches the URI defined in the
bridge (ignoring https://, www. and trailing /) an emtpy list of parameters is
returned.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New-Feature This is a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants