~vesto/feedon

0e275f023095f58033fda045c22e695de16f3517 — Steve Gattuso 1 year, 6 months ago 44d2910
better adhearance to spec
M feedon/blueprints/feeds.py => feedon/blueprints/feeds.py +4 -2
@@ 9,9 9,11 @@ bp = Blueprint('feeds', __name__, url_prefix='/feeds')

@bp.route('/<int:user_id>/<password>/atom.xml')
def render_feed(user_id, password):
    user = db.User.get(user_id)
    timeline = user.timelines.where(db.Timeline.password == password).first()
    user = db.User.get_or_none(user_id)
    if user is None:
        abort(404)

    timeline = user.timelines.where(db.Timeline.password == password).first()
    if timeline is None:
        return abort(404)


M feedon/templates/feeds/atom.xml => feedon/templates/feeds/atom.xml +33 -36
@@ 1,40 1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
{% macro render_toot_content(toot, parent=false) %}
    {% if parent %}
        <summary>RT: {{ toot.content | striptags }}</summary>
    {% else %}
        <summary>{{ toot.content | striptags }}</summary>
    {% endif %}
    <content type="html">
        {% if parent %}
            <p>Boosted by {{parent.account.display_name}} (<a href="{{parent.account.url}}">{{parent.account.acct}})</a>:</p>
        {% endif %}
{%- macro render_toot_content(toot, parent=false) -%}
    {%- if parent -%}
        <p>Boosted by {{parent.account.display_name}} (<a href="{{parent.account.url}}">{{parent.account.acct}})</a>:</p>
    {%- endif -%}

        {% if toot.content %}
            <blockquote>
                {{toot.content | safe}}
            </blockquote>
        {% endif %}
        <p>- {{toot.account.display_name}} (<a href="{{toot.account.url}}">{{toot.account.acct}}</a>)</p>
    {% if toot.content %}
        <blockquote>
            {{toot.content | safe}}
        </blockquote>
    {% endif %}
    <p>- {{toot.account.display_name}} (<a href="{{toot.account.url}}">{{toot.account.acct}}</a>)</p>

        {% for attachment in toot.media_attachments %}
            {% if attachment.type == "image" %}
    {% for attachment in toot.media_attachments %}
        {% if attachment.type == "image" %}
            <p>
                <a href="{{attachment.remote_url}}">
                    <img src="{{attachment.preview_url}}" width="100%" />
                </a>
            </p>
            {% if attachment.description %}
                <p>
                    <a href="{{attachment.remote_url}}">
                        <img src="{{attachment.preview_url}}" width="100%" />
                    </a>
                    <i>{{attachment.description}}</i>
                </p>
                {% if attachment.description %}
                    <p>
                        <i>{{attachment.description}}</i>
                    </p>
                {% endif %}
            {% else %}
                <b>Attachment {{attachment.type}} not supported.</b>
            {% endif %}
        {% endfor %}
    </content>
{% endmacro %}
        {% else %}
            <b>Attachment {{attachment.type}} not supported.</b>
        {% endif %}
    {% endfor %}
{%- endmacro -%}
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>{{timeline.title}}</title>
    <id>{{base_url}}/feeds</id>


@@ 63,11 56,15 @@
        {% endif %}
        <published>{{toot.created_at}}</published>
		<updated>{{toot.created_at}}</updated>
        {% if toot.reblog %}
            {{render_toot_content(toot.reblog, toot)}}
        {% else %}
            {{render_toot_content(toot)}}
        {% endif %}
        <content type="html">
            {% filter forceescape %}
                {% if toot.reblog %}
                    {{render_toot_content(toot.reblog, toot)}}
                {% else %}
                    {{render_toot_content(toot)}}
                {% endif %}
            {% endfilter %}
        </content>
	</entry>
    {% endfor %}
</feed>

M feedon/templates/timelines/index.html => feedon/templates/timelines/index.html +1 -1
@@ 25,10 25,10 @@
              </div>
              <div class="timeline--details">
                  <input disabled type="text" value="{{timeline.rss_url()}}" />
                  <button class="timeline--copy" data-url="{{timeline.rss_url()}}" title="Copy to clipboard">📋</button>
                  <form method="POST" action="/timelines/{{timeline.id}}/regenerate-url">
                      <input type="submit" value="↻" title="Regenerate feed URL" />
                  </form>
                  <button class="timeline--copy" data-url="{{timeline.rss_url()}}" title="Copy to clipboard">📋</button>
              </div>
          </div>
      {% endfor %}