use Known's expanded syndicate-to style to clean up syndication targets
This commit is contained in:
parent
72b23fc7d6
commit
c1afad2529
6 changed files with 90 additions and 35 deletions
|
@ -1,9 +1,9 @@
|
||||||
[uwsgi]
|
[uwsgi]
|
||||||
master=true
|
master=true
|
||||||
processes=1
|
processes=1
|
||||||
#socket=/tmp/woodwind.sock
|
socket=/tmp/woodwind.sock
|
||||||
#chmod-socket=666
|
chmod-socket=666
|
||||||
http-socket=:3000
|
#http-socket=:3000
|
||||||
module=woodwind.wsgi
|
module=woodwind.wsgi
|
||||||
import=timers
|
import=timers
|
||||||
attach-daemon=rqworker high low
|
attach-daemon=rqworker high low
|
||||||
|
|
|
@ -398,8 +398,8 @@ ul#navigation {
|
||||||
.button-link a {
|
.button-link a {
|
||||||
padding: 0.5em;
|
padding: 0.5em;
|
||||||
background-color: #353129;
|
background-color: #353129;
|
||||||
color: #ecebf0;
|
color: #ECEBF0;
|
||||||
border: 1px solid #ecebf0;
|
border: 1px solid #ECEBF0;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
display: inline-block; }
|
display: inline-block; }
|
||||||
|
|
||||||
|
@ -432,8 +432,8 @@ article {
|
||||||
article img, article video {
|
article img, article video {
|
||||||
max-width: 100%; }
|
max-width: 100%; }
|
||||||
article header {
|
article header {
|
||||||
color: #484a47;
|
color: #484A47;
|
||||||
border-bottom: 1px solid #687d77;
|
border-bottom: 1px solid #687D77;
|
||||||
margin-bottom: 0.5em;
|
margin-bottom: 0.5em;
|
||||||
overflow: auto; }
|
overflow: auto; }
|
||||||
article header img {
|
article header img {
|
||||||
|
@ -502,9 +502,7 @@ button {
|
||||||
vertical-align: middle; }
|
vertical-align: middle; }
|
||||||
|
|
||||||
.syndication-toggle {
|
.syndication-toggle {
|
||||||
display: block;
|
display: inline-block; }
|
||||||
margin-top: 0.25em;
|
|
||||||
overflow: visible; }
|
|
||||||
.syndication-toggle input {
|
.syndication-toggle input {
|
||||||
display: none; }
|
display: none; }
|
||||||
.syndication-toggle label {
|
.syndication-toggle label {
|
||||||
|
@ -514,12 +512,9 @@ button {
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
width: 240px;
|
|
||||||
text-align: left;
|
text-align: left;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
font-size: 0.8em;
|
font-size: 1em;
|
||||||
overflow: visible;
|
|
||||||
white-space: nowrap;
|
|
||||||
color: #666;
|
color: #666;
|
||||||
cursor: pointer; }
|
cursor: pointer; }
|
||||||
.syndication-toggle label img {
|
.syndication-toggle label img {
|
||||||
|
@ -530,16 +525,15 @@ button {
|
||||||
color: #fff; }
|
color: #fff; }
|
||||||
|
|
||||||
.reply-area {
|
.reply-area {
|
||||||
text-align: center;
|
|
||||||
margin-top: 0.5em; }
|
margin-top: 0.5em; }
|
||||||
.reply-area .reply-link {
|
.reply-area .reply-link {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 0.2em;
|
padding: 0.2em;
|
||||||
border: 1px solid #687d77;
|
border: 1px solid #687D77;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
background-color: #ecebf0;
|
background-color: #ECEBF0;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: #484a47;
|
color: #484A47;
|
||||||
min-width: 50px;
|
min-width: 50px;
|
||||||
text-align: center; }
|
text-align: center; }
|
||||||
|
|
||||||
|
@ -552,3 +546,5 @@ button {
|
||||||
max-height: 1.2em;
|
max-height: 1.2em;
|
||||||
min-width: inherit;
|
min-width: inherit;
|
||||||
min-height: inherit; } }
|
min-height: inherit; } }
|
||||||
|
|
||||||
|
/*# sourceMappingURL=style.css.map */
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -209,10 +209,12 @@ button {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.syndication-toggles {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
.syndication-toggle {
|
.syndication-toggle {
|
||||||
display: block;
|
display: inline-block;
|
||||||
margin-top: 0.25em;
|
|
||||||
overflow: visible;
|
|
||||||
|
|
||||||
input {
|
input {
|
||||||
display: none;
|
display: none;
|
||||||
|
@ -225,14 +227,9 @@ button {
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
width: 240px;
|
|
||||||
text-align: left;
|
text-align: left;
|
||||||
|
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
font-size: 0.8em;
|
font-size: 1em;
|
||||||
overflow: visible;
|
|
||||||
white-space: nowrap;
|
|
||||||
|
|
||||||
color: #666;
|
color: #666;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
|
@ -250,7 +247,6 @@ button {
|
||||||
|
|
||||||
|
|
||||||
.reply-area {
|
.reply-area {
|
||||||
text-align: center;
|
|
||||||
margin-top: 0.5em;
|
margin-top: 0.5em;
|
||||||
|
|
||||||
.reply-link {
|
.reply-link {
|
||||||
|
|
|
@ -12,10 +12,12 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="syndication-toggles">
|
<div class="syndication-toggles">
|
||||||
{% for target in current_user.get_setting('syndicate-to', []) %}
|
{% for target in current_user.get_setting('syndicate-to', []) %}
|
||||||
|
|
||||||
<div class="syndication-toggle">
|
<div class="syndication-toggle">
|
||||||
<input id="sc-{{entry.id}}-{{loop.index}}" type="checkbox" name="syndicate-to[]" value="{{ target }}"{% if entry is syndicated_to(target) %} checked{% endif %} />
|
<input id="sc-{{entry.id}}-{{loop.index}}" type="checkbox" name="syndicate-to[]" value="{{ target | syndication_target_id }}"{% if entry is syndicated_to(target) %} checked{% endif %} />
|
||||||
<label for="sc-{{entry.id}}-{{loop.index}}"><img src="{{ target | favicon_for_url }}" alt="{{ target }}" /> {{ target | prettify_url }}</label>
|
<label for="sc-{{entry.id}}-{{loop.index}}">{{ target | render_syndication_target }}</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -314,15 +314,31 @@ def update_micropub_syndicate_to():
|
||||||
'q': 'syndicate-to',
|
'q': 'syndicate-to',
|
||||||
}, headers={
|
}, headers={
|
||||||
'Authorization': 'Bearer ' + token,
|
'Authorization': 'Bearer ' + token,
|
||||||
|
'Accept': 'application/json',
|
||||||
})
|
})
|
||||||
if resp.status_code // 100 != 2:
|
if resp.status_code // 100 != 2:
|
||||||
flask.current_app.logger.warn(
|
flask.current_app.logger.warn(
|
||||||
'Unexpected response querying micropub endpoint %s: %s',
|
'Unexpected response querying micropub endpoint %s: %s',
|
||||||
resp, resp.text)
|
resp, resp.text)
|
||||||
return
|
return
|
||||||
syndicate_tos = pyquerystring.parse(resp.text).get('syndicate-to', [])
|
|
||||||
if syndicate_tos and not isinstance(syndicate_tos, list):
|
flask.current_app.logger.debug('response from micropub endpoint: {}, {}',
|
||||||
syndicate_tos = list(syndicate_tos)
|
resp, resp.text)
|
||||||
|
|
||||||
|
content_type = resp.headers['content-type']
|
||||||
|
if content_type:
|
||||||
|
content_type = content_type.split(';', 1)[0]
|
||||||
|
|
||||||
|
if content_type == 'application/json':
|
||||||
|
blob = resp.json()
|
||||||
|
syndicate_tos = blob.get('syndicate-to-expanded')
|
||||||
|
if not syndicate_tos:
|
||||||
|
syndicate_tos = blob.get('syndicate-to')
|
||||||
|
else: # try to parse query string
|
||||||
|
syndicate_tos = pyquerystring.parse(resp.text).get('syndicate-to', [])
|
||||||
|
if isinstance(syndicate_tos, list):
|
||||||
|
syndicate_tos = list(syndicate_tos)
|
||||||
|
|
||||||
flask_login.current_user.set_setting('syndicate-to', syndicate_tos)
|
flask_login.current_user.set_setting('syndicate-to', syndicate_tos)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
@ -689,11 +705,56 @@ def dedupe_copies(entries):
|
||||||
return [e for e in entries if e not in all_copies]
|
return [e for e in entries if e not in all_copies]
|
||||||
|
|
||||||
|
|
||||||
|
def font_awesome_class_for_service(service):
|
||||||
|
service = service.lower()
|
||||||
|
if service == 'facebook':
|
||||||
|
return 'fa fa-facebook'
|
||||||
|
if service == 'twitter':
|
||||||
|
return 'fa fa-twitter'
|
||||||
|
if service == 'instagram':
|
||||||
|
return 'fa fa-instagram'
|
||||||
|
if service == 'flickr':
|
||||||
|
return 'fa fa-flickr'
|
||||||
|
if service == 'googleplus' or service == 'g+' or service == 'google plus' or service == 'google+':
|
||||||
|
return 'fa fa-google-plus'
|
||||||
|
if service == 'hacker news' or service == 'hackernews':
|
||||||
|
return 'fa fa-hacker-news'
|
||||||
|
if service == 'indienews':
|
||||||
|
return 'fa fa-newspaper-o'
|
||||||
|
if service == 'linkedin':
|
||||||
|
return 'fa fa-linkedin'
|
||||||
|
if service == 'foursquare' or service == 'swarm':
|
||||||
|
return 'fa fa-foursquare'
|
||||||
|
return 'fa fa-send'
|
||||||
|
|
||||||
|
|
||||||
|
@views.app_template_filter('syndication_target_id')
|
||||||
|
def syndication_target_id(target):
|
||||||
|
if isinstance(target, dict):
|
||||||
|
return target.get('id')
|
||||||
|
return target
|
||||||
|
|
||||||
|
|
||||||
|
@views.app_template_filter('render_syndication_target')
|
||||||
|
def render_syndication_target(target):
|
||||||
|
if isinstance(target, dict):
|
||||||
|
service = target.get('service')
|
||||||
|
name = target.get('name')
|
||||||
|
return '<i class="{}"></i> {}'.format(
|
||||||
|
font_awesome_class_for_service(service), name)
|
||||||
|
|
||||||
|
return '<img src="{}" alt="{}" /> {}'.format(
|
||||||
|
favicon_for_url(target), target, prettify_url(target))
|
||||||
|
|
||||||
|
|
||||||
@views.app_template_test('syndicated_to')
|
@views.app_template_test('syndicated_to')
|
||||||
def is_syndicated_to(entry, target):
|
def is_syndicated_to(entry, target):
|
||||||
def same_domain(u1, u2):
|
def same_domain(u1, u2):
|
||||||
return domain_for_url(u1) == domain_for_url(u2)
|
return domain_for_url(u1) == domain_for_url(u2)
|
||||||
|
|
||||||
|
if isinstance(target, dict):
|
||||||
|
return False # TODO
|
||||||
|
|
||||||
return same_domain(entry.permalink, target) or any(
|
return same_domain(entry.permalink, target) or any(
|
||||||
same_domain(syndurl, target)
|
same_domain(syndurl, target)
|
||||||
for syndurl in entry.get_property('syndication', []))
|
for syndurl in entry.get_property('syndication', []))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue