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]
|
||||
master=true
|
||||
processes=1
|
||||
#socket=/tmp/woodwind.sock
|
||||
#chmod-socket=666
|
||||
http-socket=:3000
|
||||
socket=/tmp/woodwind.sock
|
||||
chmod-socket=666
|
||||
#http-socket=:3000
|
||||
module=woodwind.wsgi
|
||||
import=timers
|
||||
attach-daemon=rqworker high low
|
||||
|
|
|
@ -398,8 +398,8 @@ ul#navigation {
|
|||
.button-link a {
|
||||
padding: 0.5em;
|
||||
background-color: #353129;
|
||||
color: #ecebf0;
|
||||
border: 1px solid #ecebf0;
|
||||
color: #ECEBF0;
|
||||
border: 1px solid #ECEBF0;
|
||||
border-radius: 4px;
|
||||
display: inline-block; }
|
||||
|
||||
|
@ -432,8 +432,8 @@ article {
|
|||
article img, article video {
|
||||
max-width: 100%; }
|
||||
article header {
|
||||
color: #484a47;
|
||||
border-bottom: 1px solid #687d77;
|
||||
color: #484A47;
|
||||
border-bottom: 1px solid #687D77;
|
||||
margin-bottom: 0.5em;
|
||||
overflow: auto; }
|
||||
article header img {
|
||||
|
@ -502,9 +502,7 @@ button {
|
|||
vertical-align: middle; }
|
||||
|
||||
.syndication-toggle {
|
||||
display: block;
|
||||
margin-top: 0.25em;
|
||||
overflow: visible; }
|
||||
display: inline-block; }
|
||||
.syndication-toggle input {
|
||||
display: none; }
|
||||
.syndication-toggle label {
|
||||
|
@ -514,12 +512,9 @@ button {
|
|||
border-radius: 3px;
|
||||
background-color: #eee;
|
||||
margin: 0;
|
||||
width: 240px;
|
||||
text-align: left;
|
||||
font-weight: normal;
|
||||
font-size: 0.8em;
|
||||
overflow: visible;
|
||||
white-space: nowrap;
|
||||
font-size: 1em;
|
||||
color: #666;
|
||||
cursor: pointer; }
|
||||
.syndication-toggle label img {
|
||||
|
@ -530,16 +525,15 @@ button {
|
|||
color: #fff; }
|
||||
|
||||
.reply-area {
|
||||
text-align: center;
|
||||
margin-top: 0.5em; }
|
||||
.reply-area .reply-link {
|
||||
display: inline-block;
|
||||
padding: 0.2em;
|
||||
border: 1px solid #687d77;
|
||||
border: 1px solid #687D77;
|
||||
border-radius: 4px;
|
||||
background-color: #ecebf0;
|
||||
background-color: #ECEBF0;
|
||||
text-decoration: none;
|
||||
color: #484a47;
|
||||
color: #484A47;
|
||||
min-width: 50px;
|
||||
text-align: center; }
|
||||
|
||||
|
@ -552,3 +546,5 @@ button {
|
|||
max-height: 1.2em;
|
||||
min-width: 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 {
|
||||
display: block;
|
||||
margin-top: 0.25em;
|
||||
overflow: visible;
|
||||
display: inline-block;
|
||||
|
||||
input {
|
||||
display: none;
|
||||
|
@ -225,14 +227,9 @@ button {
|
|||
border-radius: 3px;
|
||||
background-color: #eee;
|
||||
margin: 0;
|
||||
width: 240px;
|
||||
text-align: left;
|
||||
|
||||
font-weight: normal;
|
||||
font-size: 0.8em;
|
||||
overflow: visible;
|
||||
white-space: nowrap;
|
||||
|
||||
font-size: 1em;
|
||||
color: #666;
|
||||
cursor: pointer;
|
||||
|
||||
|
@ -250,7 +247,6 @@ button {
|
|||
|
||||
|
||||
.reply-area {
|
||||
text-align: center;
|
||||
margin-top: 0.5em;
|
||||
|
||||
.reply-link {
|
||||
|
|
|
@ -12,10 +12,12 @@
|
|||
</div>
|
||||
<div class="syndication-toggles">
|
||||
{% for target in current_user.get_setting('syndicate-to', []) %}
|
||||
|
||||
<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 %} />
|
||||
<label for="sc-{{entry.id}}-{{loop.index}}"><img src="{{ target | favicon_for_url }}" alt="{{ target }}" /> {{ target | prettify_url }}</label>
|
||||
<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}}">{{ target | render_syndication_target }}</label>
|
||||
</div>
|
||||
|
||||
{% endfor %}
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -314,15 +314,31 @@ def update_micropub_syndicate_to():
|
|||
'q': 'syndicate-to',
|
||||
}, headers={
|
||||
'Authorization': 'Bearer ' + token,
|
||||
'Accept': 'application/json',
|
||||
})
|
||||
if resp.status_code // 100 != 2:
|
||||
flask.current_app.logger.warn(
|
||||
'Unexpected response querying micropub endpoint %s: %s',
|
||||
resp, resp.text)
|
||||
return
|
||||
syndicate_tos = pyquerystring.parse(resp.text).get('syndicate-to', [])
|
||||
if syndicate_tos and not isinstance(syndicate_tos, list):
|
||||
syndicate_tos = list(syndicate_tos)
|
||||
|
||||
flask.current_app.logger.debug('response from micropub endpoint: {}, {}',
|
||||
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)
|
||||
db.session.commit()
|
||||
|
||||
|
@ -689,11 +705,56 @@ def dedupe_copies(entries):
|
|||
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')
|
||||
def is_syndicated_to(entry, target):
|
||||
def same_domain(u1, 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(
|
||||
same_domain(syndurl, target)
|
||||
for syndurl in entry.get_property('syndication', []))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue