diff --git a/woodwind/templates/_reply.jinja2 b/woodwind/templates/_reply.jinja2 index c4d17c9..669cf07 100644 --- a/woodwind/templates/_reply.jinja2 +++ b/woodwind/templates/_reply.jinja2 @@ -1,8 +1,7 @@ {% set settings = current_user.settings or {} %} -{% set replyMethod = settings.get('reply-method') %} - -{% if replyMethod == 'micropub' and current_user.micropub_endpoint %} +{% set reply_method = settings.get('reply-method') %} +{% if reply_method == 'micropub' and current_user.micropub_endpoint %}
@@ -22,14 +21,13 @@
- -{% elif replyMethod == 'indie-config' %} +{% elif reply_method == 'indie-config' %} {% for action in settings.get('indie-config-actions', []) %} {{ action | capitalize }} {% endfor %} -{% elif replyMethod == 'action-urls' %} +{% elif reply_method == 'action-urls' %} {% for action, url in settings.get('action-urls', []) %} {{ action | capitalize }} {% endfor %} diff --git a/woodwind/templates/settings.jinja2 b/woodwind/templates/settings.jinja2 index fbeff9c..19747cd 100644 --- a/woodwind/templates/settings.jinja2 +++ b/woodwind/templates/settings.jinja2 @@ -1,131 +1,26 @@ {% extends "base.jinja2" %} {% block body %}
- {% set reply_method = settings.get('reply-method') %} - -
- - - -
- -

Reply Mechanism

-

- - - Each post will have a Like and Reply button that will post content to your site directly via micropub. See Micropub for details. -

- -

- - - Clicking Like or Reply will invoke your web+action handler if registered. See indie-config for details. -

- -

- - - Configure Woodwind with your preferred web action handlers. The placeholder {url} will be replaced with the permalink URL of each entry. -

-
- - - -
-

Micropub

-

- Configure micropub credentials. -

- {% if current_user.micropub_endpoint or current_user.access_token %} - - -

- Reauthorize Micropub -

-

- Revoke Credentials -

- {% else %} -

- Authorize Micropub -

- {% endif %} -
- - - -
-

Indie-Config

-

- Select indie-config actions. -

- {% set selectedActions = settings.get('indie-config-actions', []) %} - -

- {% for action in ['like', 'favorite', 'reply', 'repost', 'bookmark'] %} -
- {% endfor %} -

-
- - -
-

Action URLs

-
- {% set actionUrls = settings.get('action-urls', {}) %} - {% for action, url in actionUrls %} - - - {% endfor %} - - - -
- - -
- - + + {% set reply_method = settings.get('reply-method') %} +

Reply Mechanism

+

+ + + Each post will have Like, Repost, and Reply buttons that will post content to your site directly via micropub. See Micropub for details. +

+

+ + + Clicking an indie-action link will invoke your web+action handler if registered. See indie-config for details. +

+

+ + + Manually configure your own web action handlers. The placeholder {url} will be replaced with the permalink URL of each entry. +

+
- - {% endblock body %} diff --git a/woodwind/templates/settings_action_urls.jinja2 b/woodwind/templates/settings_action_urls.jinja2 new file mode 100644 index 0000000..c1e4e2e --- /dev/null +++ b/woodwind/templates/settings_action_urls.jinja2 @@ -0,0 +1,36 @@ +{% extends "base.jinja2" %} +{% block body %} +
+
+ +

Action URLs

+

+ Manually configure your own web action handlers. The placeholder {url} will be replaced with the permalink URL of each entry. +

+
+ {% set actionUrls = settings.get('action-urls', {}) %} + {% for action, url in actionUrls %} + + + {% endfor %} + + + +
+
+ +
+
+ +
+

+
+
+ +{% endblock body %} diff --git a/woodwind/templates/settings_indie_config.jinja2 b/woodwind/templates/settings_indie_config.jinja2 new file mode 100644 index 0000000..7649123 --- /dev/null +++ b/woodwind/templates/settings_indie_config.jinja2 @@ -0,0 +1,22 @@ +{% extends "base.jinja2" %} +{% block body %} +
+
+ +

Indie-Config

+

+ Clicking an indie-action link will invoke your web+action handler if registered. See indie-config for details. +

+ {% set selectedActions = settings.get('indie-config-actions', []) %} + + {% for action in ['like', 'favorite', 'reply', 'repost', 'bookmark'] %} +
+ {% endfor %} + +
+
+{% endblock body %} diff --git a/woodwind/templates/settings_micropub.jinja2 b/woodwind/templates/settings_micropub.jinja2 new file mode 100644 index 0000000..8be5b31 --- /dev/null +++ b/woodwind/templates/settings_micropub.jinja2 @@ -0,0 +1,27 @@ +{% extends "base.jinja2" %} +{% block body %} +
+ +

Micropub

+

+ Each post will have Like, Repost, and Reply buttons that will post content to your site directly via micropub. See Micropub for details. +

+

+ Configure micropub credentials. +

+ {% if current_user.micropub_endpoint or current_user.access_token %} + + +

+ Reauthorize Micropub +

+

+ Revoke Credentials +

+ {% else %} +

+ Authorize Micropub +

+ {% endif %} +
+{% endblock body %} diff --git a/woodwind/views.py b/woodwind/views.py index 25d6495..f9b4ea4 100644 --- a/woodwind/views.py +++ b/woodwind/views.py @@ -115,21 +115,61 @@ def settings(): settings = dict(settings) reply_method = flask.request.form.get('reply-method') settings['reply-method'] = reply_method - - if reply_method == 'micropub': - pass - elif reply_method == 'indie-config': - settings['indie-config-actions'] = flask.request.form.getlist( - 'indie-config-action') - elif reply_method == 'action-urls': - zipped = zip( - flask.request.form.getlist('action'), - flask.request.form.getlist('action-url')) - settings['action-urls'] = [[k, v] for k, v in zipped if k and v] - flask_login.current_user.settings = settings db.session.commit() - return flask.render_template('settings.jinja2', settings=settings) + + next_page = '.settings' + if reply_method == 'micropub': + next_page = '.settings_micropub' + elif reply_method == 'indie-config': + next_page = '.settings_indie_config' + elif reply_method == 'action-urls': + next_page = '.settings_action_urls' + + return flask.redirect(flask.url_for(next_page)) + + +@views.route('/settings/micropub') +@flask_login.login_required +def settings_micropub(): + settings = flask_login.current_user.settings or {} + return flask.render_template('settings_micropub.jinja2', settings=settings) + + +@views.route('/settings/indie-config', methods=['GET', 'POST']) +@flask_login.login_required +def settings_indie_config(): + settings = flask_login.current_user.settings or {} + + if flask.request.method == 'GET': + return flask.render_template('settings_indie_config.jinja2', + settings=settings) + + settings = dict(settings) + settings['indie-config-actions'] = flask.request.form.getlist( + 'indie-config-action') + flask_login.current_user.settings = settings + print('new settings: ', settings) + db.session.commit() + return flask.redirect(flask.url_for('.index')) + + +@views.route('/settings/action-urls', methods=['GET', 'POST']) +@flask_login.login_required +def settings_action_urls(): + settings = flask_login.current_user.settings or {} + if flask.request.method == 'GET': + return flask.render_template('settings_action_urls.jinja2', + settings=settings) + + settings = dict(settings) + zipped = zip( + flask.request.form.getlist('action'), + flask.request.form.getlist('action-url')) + settings['action-urls'] = [[k, v] for k, v in zipped if k and v] + flask_login.current_user.settings = settings + db.session.commit() + return flask.redirect(flask.url_for('.index')) @views.route('/update_feed', methods=['POST'])