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

Feature request: Follow author #1213

Open
kottkrig opened this issue Oct 29, 2021 · 1 comment
Open

Feature request: Follow author #1213

kottkrig opened this issue Oct 29, 2021 · 1 comment

Comments

@kottkrig
Copy link
Contributor

As a reader on a Superdesk Publisher website, I would like to be able to follow my favourite authors on that website.

Possible solutions/implementations

From a templating standpoint we would need the following for it to work.

  1. Submit a post request to connect an Author with the current app.user.
  2. List articles based on the authors that a user follows.

Let's start with the first point. Submit a POST request to a (new) Controller.

Form template

I propose that we, in templates, use forms to POST to a new "follow_author" endpoint. Similar to what we already do for user login. The receiving controller would connect the author from the form with the currently logged in user.

It might look something like this:

{% if app.user %}
	<form action="{{ path('follow_author') }}" method="POST">
	    <input type="hidden" name="_author" value="{{ author.id }}" />
	    <input type="submit" value="Follow author" />
	</form>
{% else %}
	<button type="button" disabled>Follow Author</button>
	(You must login to follow an author)
{% endif %}

List followed articles

The listing of articles might look different based on what implementation we choose for the backend. I see two primary alternatives.

Alternative A – new loader

The simplest solution of the two alternatives. A new loader that can load the followed articles. Perhaps from a new table swp_user_author that holds the many-to-many relationship between a user and its subscribed authors.

In twig it could look something like this:

{% if app.user %}
	<ul>
	{% gimmelist followedArticle from followedArticles with { user: app.user } %}
		<li>{{ followedArticle.article.title }}</li>
	{% endgimmelist %}
	</ul>
{% endif %}

Alternative B – new type of content list

A more flexible and robust solution might be to create a new type of content list. A FollowList. Similar to the current ContentList templating-wise. It could possibly also be cached similarly to content lists.

An added benefit to a generic FollowList is that it isn't bound to only follow authors. In the future, a user could possibly follow keywords, routes or genres.

{% gimme followList with { user: app.user } %}
    {% cache 'followed-articles' { gen: followList } %}
    <ul>
    {% gimmelist item from followListItems with { followList: contentList } %}
        <li>{{ item.content.title }}</li> <!-- Article title -->
	{% endgimmelist %}
    </ul>
    {% endcache %}
{% endgimme %}
@takeit
Copy link
Contributor

takeit commented Mar 29, 2022

@kottkrig the second solution sounds good, but not sure if you would have to extend it by adding user to it and if that won't affect existing content lists. If not, I would go for it, otherwise let's stick to alternative 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants