ahernp / django-feedreader

RSS Aggregator
BSD 3-Clause "New" or "Revised" License
90 stars 29 forks source link

feed_list.html functionality moved to a html select box for mobile browser usage #4

Closed alexkelley closed 7 years ago

alexkelley commented 9 years ago

I was wondering if anyone has modified the feed list functionality to reside in a select box. My goal is to allow for a better experience on a mobile browser. My thought is to use a select box populated from the list of feeds and being able to change the displayed feeds by selecting an item. I have the select box with the feeds populating it now but I need to trigger the page change. I don't want to break the "Mark as Read" functionality either but I do want to move the feed polling to a cron job so advice on that would be awesome too.

ahernp commented 9 years ago

Interesting idea. I only use the feedreader in desktop browsers and delete feeds I am no longer interested in reading.

You should be able to refresh the list of items displayed by doing a an AJAX call which is sent the ID of the item you selected: /feedreader/?feed_id=10

There is already a poll_feeds command (https://github.com/ahernp/django-feedreader/blob/master/feedreader/management/commands/poll_feeds.py) which I run via cron using the following:

17 * * * * /home/ahernp/.virtualenvs/ahernp/bin/python /home/ahernp/code /django-ahernp/ahernp/manage.py poll_feeds >> /home/ahernp/cron.log 2>&1

alexkelley commented 9 years ago

From your suggestion, I figured out how to change the displayed feed in a mobile browser without having to have the side navigation tree. Here's the select box code that I got working the way I was envisioning:

<select id="feeds" name="feed_select" onChange="window.open(this.options[this.selectedIndex].value,'_top')">

   <option value="{% url 'feedreader:feed_list' %}">All Entries</option>

{% for group in group_list %}
   <option value="{% url 'feedreader:feed_list' %}?group_id={{ group.id }}"
       {% if group.name == entries_header %}selected="selected"{% endif %}>
__All {{ group.name }}__</option>

{% for feed in group.feed_set.all %}
   <option value="{% url 'feedreader:feed_list' %}?feed_id={{ feed.id }}"
{% if feed.title == entries_header %}selected="selected"{% endif %}>
{{ feed.title }}</option>
{% endfor %}

{% endfor %}

</select>

I used double underscores in front and behind the group name just to visually break up the list of options in the select box. It works but there's probably a more elegant solution.

I also got the automatic polling working. Thanks!