From 3a4a71d225243b0e27a5d6881731db3d213d7133 Mon Sep 17 00:00:00 2001 From: Kyle Mahan Date: Tue, 4 Aug 2015 08:08:18 -0700 Subject: [PATCH] pre-check micropub syndication targets when the entry is on the same silo, or has a u-syndication for that services --- woodwind/templates/_reply.jinja2 | 2 +- woodwind/views.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/woodwind/templates/_reply.jinja2 b/woodwind/templates/_reply.jinja2 index 669cf07..4ac6a67 100644 --- a/woodwind/templates/_reply.jinja2 +++ b/woodwind/templates/_reply.jinja2 @@ -13,7 +13,7 @@
{% for target in current_user.get_setting('syndicate-to', []) %} {% endfor %} diff --git a/woodwind/views.py b/woodwind/views.py index 8e31e3a..16220c7 100644 --- a/woodwind/views.py +++ b/woodwind/views.py @@ -609,3 +609,13 @@ def dedupe_copies(entries): entry._syndicated_copies = copies all_copies.update(copies) return [e for e in entries if e not in all_copies] + + +@views.app_template_test('syndicated_to') +def is_syndicated_to(entry, target): + def same_domain(u1, u2): + return domain_for_url(u1) == domain_for_url(u2) + + return same_domain(entry.permalink, target) or any( + same_domain(syndurl, target) + for syndurl in entry.get_property('syndication', []))