support sending RSVPs to events in the feed
This commit is contained in:
parent
2786ab4770
commit
b3d2be2a2b
8 changed files with 57 additions and 20 deletions
|
@ -19,7 +19,11 @@ def publish():
|
||||||
'access_token': flask_login.current_user.access_token,
|
'access_token': flask_login.current_user.access_token,
|
||||||
}
|
}
|
||||||
|
|
||||||
if action == 'like':
|
if action.startswith('rsvp-'):
|
||||||
|
data['in-reply-to'] = target
|
||||||
|
data['content'] = content
|
||||||
|
data['rsvp'] = action.split('-', 1)[-1]
|
||||||
|
elif action == 'like':
|
||||||
data['like-of'] = target
|
data['like-of'] = target
|
||||||
elif action == 'repost':
|
elif action == 'repost':
|
||||||
data['repost-of'] = target
|
data['repost-of'] = target
|
||||||
|
|
|
@ -39,20 +39,30 @@ $(function(){
|
||||||
function submitMicropubForm(evt) {
|
function submitMicropubForm(evt) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
|
|
||||||
var form = $(this).closest('form');
|
var button = this;
|
||||||
|
var form = $(button).closest('form');
|
||||||
var replyArea = form.parent();
|
var replyArea = form.parent();
|
||||||
var endpoint = form.attr('action');
|
var endpoint = form.attr('action');
|
||||||
var responseArea = $('.micropub-response', replyArea);
|
var responseArea = $('.micropub-response', replyArea);
|
||||||
var formData = form.serializeArray();
|
var formData = form.serializeArray();
|
||||||
formData.push({name: this.name, value: this.value});
|
formData.push({name: button.name, value: button.value});
|
||||||
|
|
||||||
$.post(
|
$.post(
|
||||||
form.attr('action'),
|
endpoint,
|
||||||
formData,
|
formData,
|
||||||
function(result) {
|
function(result) {
|
||||||
if (Math.floor(result.code / 100) == 2) {
|
if (Math.floor(result.code / 100) == 2) {
|
||||||
responseArea.html('<a target="_blank" href="' + result.location + '">Success!</a>');
|
responseArea.html('<a target="_blank" href="' + result.location + '">Success!</a>');
|
||||||
$(".micropub-form textarea").val("");
|
$("textarea", form).val("");
|
||||||
|
|
||||||
|
if (button.value === 'rsvp-yes') {
|
||||||
|
$(".rsvps", form).html('✓ Going');
|
||||||
|
} else if (button.value === 'rsvp-maybe') {
|
||||||
|
$(".rsvps", form).html('? Interested');
|
||||||
|
} else if (button.value === 'rsvp-no') {
|
||||||
|
$(".rsvps", form).html('✗ Not Going');
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
responseArea.html('Failure');
|
responseArea.html('Failure');
|
||||||
}
|
}
|
||||||
|
|
|
@ -498,14 +498,17 @@ button {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
vertical-align: middle; }
|
vertical-align: middle; }
|
||||||
.micropub-form button {
|
.micropub-form button {
|
||||||
height: 24px;
|
|
||||||
width: 24px;
|
|
||||||
padding: 4px;
|
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
border: 0;
|
vertical-align: middle;
|
||||||
line-height: 1;
|
border: 0; }
|
||||||
vertical-align: middle; }
|
.micropub-form button.small {
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
padding: 4px;
|
||||||
|
line-height: 1; }
|
||||||
|
.micropub-form .rsvps {
|
||||||
|
text-align: center; }
|
||||||
|
|
||||||
.syndication-toggle {
|
.syndication-toggle {
|
||||||
display: inline-block; }
|
display: inline-block; }
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -206,13 +206,20 @@ button {
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
height: 24px;width: 24px;
|
|
||||||
padding: 4px;
|
|
||||||
background-color: #eee;
|
background-color: #eee;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
border: 0;
|
|
||||||
line-height: 1;
|
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
|
border: 0;
|
||||||
|
&.small {
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
padding: 4px;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.rsvps {
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -534,6 +534,10 @@ def hentry_to_entry(hentry, feed, backfill, now):
|
||||||
if value:
|
if value:
|
||||||
entry.set_property(prop, value)
|
entry.set_property(prop, value)
|
||||||
|
|
||||||
|
# set a flag for events so we can show RSVP buttons
|
||||||
|
if hentry.get('type') == 'event':
|
||||||
|
entry.set_property('event', True)
|
||||||
|
|
||||||
# does it look like a jam?
|
# does it look like a jam?
|
||||||
plain = hentry.get('content-plain')
|
plain = hentry.get('content-plain')
|
||||||
if plain and JAM_RE.match(plain):
|
if plain and JAM_RE.match(plain):
|
||||||
|
|
|
@ -4,11 +4,20 @@
|
||||||
{% if reply_method == 'micropub' and current_user.micropub_endpoint %}
|
{% if reply_method == 'micropub' and current_user.micropub_endpoint %}
|
||||||
<form class="micropub-form" action="{{ url_for('api.publish') }}" method="POST">
|
<form class="micropub-form" action="{{ url_for('api.publish') }}" method="POST">
|
||||||
<input type="hidden" name="target" value="{{ entry.permalink }}"/>
|
<input type="hidden" name="target" value="{{ entry.permalink }}"/>
|
||||||
|
|
||||||
|
{% if entry.get_property('event') %}
|
||||||
|
<div class="rsvps">
|
||||||
|
<button type="submit" name="action" value="rsvp-yes">Going</button>
|
||||||
|
<button type="submit" name="action" value="rsvp-maybe">Interested</button>
|
||||||
|
<button type="submit" name="action" value="rsvp-no">Not Going</button>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<textarea class="content" name="content"></textarea>
|
<textarea class="content" name="content"></textarea>
|
||||||
<button type="submit" name="action" value="reply"><i class="fa fa-reply"></i></button>
|
<button type="submit" name="action" value="reply" class="small"><i class="fa fa-reply"></i></button>
|
||||||
<button type="submit" name="action" value="repost"><i class="fa fa-retweet"></i></button>
|
<button type="submit" name="action" value="repost" class="small"><i class="fa fa-retweet"></i></button>
|
||||||
<button type="submit" name="action" value="like"><i class="fa fa-star"></i></button>
|
<button type="submit" name="action" value="like" class="small"><i class="fa fa-star"></i></button>
|
||||||
</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', []) %}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
{% if ws_topic %}
|
{% if ws_topic %}
|
||||||
<script>var WS_TOPIC = "{{ ws_topic }}";</script>
|
<script>var WS_TOPIC = "{{ ws_topic }}";</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<script src="{{url_for('static', filename='feed.js', version='2015-12-24')}}"></script>
|
<script src="{{url_for('static', filename='feed.js', version='2016-03-08')}}"></script>
|
||||||
|
|
||||||
{% if current_user and current_user.settings
|
{% if current_user and current_user.settings
|
||||||
and current_user.settings.get('reply-method') == 'indie-config' %}
|
and current_user.settings.get('reply-method') == 'indie-config' %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue