From e34944fcaa3269d3323bc0bcb9671feeb0c0ed1c Mon Sep 17 00:00:00 2001 From: b3yond Date: Sun, 27 Jan 2019 22:44:23 +0100 Subject: [PATCH 1/2] started splitting up the templates, wondering how to include them --- bots/mail/settings.tpl | 20 +++++++++ bots/mastodon/settings.tpl | 52 ++++++++++++++++++++++ bots/telegram/settings.tpl | 24 ++++++++++ bots/twitter/settings.tpl | 11 +++++ bots/twitterDMs/settings.tpl | 1 + frontend.py | 4 ++ template/settings.tpl | 86 ++++-------------------------------- 7 files changed, 120 insertions(+), 78 deletions(-) create mode 100644 bots/mail/settings.tpl create mode 100644 bots/mastodon/settings.tpl create mode 100644 bots/telegram/settings.tpl create mode 100644 bots/twitter/settings.tpl create mode 100644 bots/twitterDMs/settings.tpl diff --git a/bots/mail/settings.tpl b/bots/mail/settings.tpl new file mode 100644 index 0000000..4b01705 --- /dev/null +++ b/bots/mail/settings.tpl @@ -0,0 +1,20 @@ +% rebase('settings.tpl') + +
+

Edit your mail subscription page

+

+ There is also a page where users can subscribe to mail notifications: + Ticketfrei {{city}}. + You can change what your users will read there, and adjust it to your + needs. +

+

+ So this is the default text we suggest: +

+
+ + + +
+
+ diff --git a/bots/mastodon/settings.tpl b/bots/mastodon/settings.tpl new file mode 100644 index 0000000..f618e81 --- /dev/null +++ b/bots/mastodon/settings.tpl @@ -0,0 +1,52 @@ +% rebase('settings.tpl') + +
+

Log in with Mastodon

+
+ + + + + + + + + + + +
+
+ diff --git a/bots/telegram/settings.tpl b/bots/telegram/settings.tpl new file mode 100644 index 0000000..7b5f9a6 --- /dev/null +++ b/bots/telegram/settings.tpl @@ -0,0 +1,24 @@ +% rebase('settings.tpl') + +<% +# todo: hide this part, if there is already a telegram bot connected. +%> +
+

Connect with Telegram

+

+ If you have a Telegram account, you can register a bot there. Just + write to @botfather. There are detailed instructions on + + Bots for Telegram. +

+

+ The botfather will give you an API key - with the API key, Ticketfrei + can use the Telegram bot. Enter it here: +

+
+ + + +
+
+ diff --git a/bots/twitter/settings.tpl b/bots/twitter/settings.tpl new file mode 100644 index 0000000..5926c8f --- /dev/null +++ b/bots/twitter/settings.tpl @@ -0,0 +1,11 @@ +% rebase('settings.tpl') + + + + + + + + Log in with Twitter + + diff --git a/bots/twitterDMs/settings.tpl b/bots/twitterDMs/settings.tpl new file mode 100644 index 0000000..34fbdfe --- /dev/null +++ b/bots/twitterDMs/settings.tpl @@ -0,0 +1 @@ +% rebase('settings.tpl') diff --git a/frontend.py b/frontend.py index 7fbf975..f046dcd 100755 --- a/frontend.py +++ b/frontend.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import bottle +from os import listdir, path from bottle import get, post, redirect, request, response, view from config import config from db import db @@ -271,6 +272,9 @@ logger.addHandler(fh) application = bottle.default_app() bottle.install(SessionPlugin('/')) +for bot in listdir('bots'): + bottle.TEMPLATE_PATH.insert(0, path.join('bots', bot, 'settings.tpl')) + if __name__ == '__main__': bottle.run(host="0.0.0.0", port=config["web"]["port"]) else: diff --git a/template/settings.tpl b/template/settings.tpl index 66cf873..35935c1 100644 --- a/template/settings.tpl +++ b/template/settings.tpl @@ -7,86 +7,16 @@
Enable
% end - - - - - - - Log in with Twitter - - -
-

Log in with Mastodon

-
- - - - - - - - - - - -
-
- <% -# todo: hide this part, if there is already a telegram bot connected. + +# import all the settings templates from bots/*/settings.tpl +import os +bots = os.listdir('bots') + +for bot in bots: + include('/home/b3yond/git/ticketfrei/bots/' + bot + '/settings.tpl', csrf=csrf, city=city) + %> -
-

Connect with Telegram

-

- If you have a Telegram account, you can register a bot there. Just - write to @botfather. There are detailed instructions on - - Bots for Telegram. -

-

- The botfather will give you an API key - with the API key, Ticketfrei - can use the Telegram bot. Enter it here: -

-
- - - -
-

Edit your city page

From a27d47eb8bd73fb18dcbae2e07f64814b66db406 Mon Sep 17 00:00:00 2001 From: b3yond Date: Sun, 27 Jan 2019 23:08:59 +0100 Subject: [PATCH 2/2] templates from bots/*/ are correctly imported --- bots/mail/settings.tpl | 1 - bots/mastodon/settings.tpl | 1 - bots/telegram/settings.tpl | 1 - bots/twitter/settings.tpl | 1 - bots/twitterDMs/settings.tpl | 1 - 5 files changed, 5 deletions(-) diff --git a/bots/mail/settings.tpl b/bots/mail/settings.tpl index 4b01705..aa1e1ed 100644 --- a/bots/mail/settings.tpl +++ b/bots/mail/settings.tpl @@ -1,4 +1,3 @@ -% rebase('settings.tpl')

Edit your mail subscription page

diff --git a/bots/mastodon/settings.tpl b/bots/mastodon/settings.tpl index f618e81..4e36403 100644 --- a/bots/mastodon/settings.tpl +++ b/bots/mastodon/settings.tpl @@ -1,4 +1,3 @@ -% rebase('settings.tpl')

Log in with Mastodon

diff --git a/bots/telegram/settings.tpl b/bots/telegram/settings.tpl index 7b5f9a6..3939ced 100644 --- a/bots/telegram/settings.tpl +++ b/bots/telegram/settings.tpl @@ -1,4 +1,3 @@ -% rebase('settings.tpl') <% # todo: hide this part, if there is already a telegram bot connected. diff --git a/bots/twitter/settings.tpl b/bots/twitter/settings.tpl index 5926c8f..0847c23 100644 --- a/bots/twitter/settings.tpl +++ b/bots/twitter/settings.tpl @@ -1,4 +1,3 @@ -% rebase('settings.tpl') diff --git a/bots/twitterDMs/settings.tpl b/bots/twitterDMs/settings.tpl index 34fbdfe..e69de29 100644 --- a/bots/twitterDMs/settings.tpl +++ b/bots/twitterDMs/settings.tpl @@ -1 +0,0 @@ -% rebase('settings.tpl')