From: Carl Worth Date: Tue, 13 Oct 2020 19:57:44 +0000 (-0700) Subject: Revamp the Home page of our app to start looking like what we want X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=b541485c6ca914d01f09cb62a82dbb3ef6ed6ece;p=turbot Revamp the Home page of our app to start looking like what we want This gets rid of the original placeholder blocks which I had gotten from a tutorial and replaces it with placeholders that look more like what we are going to want, (a list of hunts and a button to create a new hunt). While doing this, we provide some utility functions to create blocks to reduce the amount of boilerplate we need while constructing these things. --- diff --git a/turbot/views.py b/turbot/views.py index 95b7b08..122d92c 100644 --- a/turbot/views.py +++ b/turbot/views.py @@ -1,3 +1,33 @@ +def text(body): + return { + "text": { + "type": "mrkdwn", + "text": body + } + } + +def section(block): + return { + "type": "section", + **block + } + +def actions(*elements): + return { + "type": "actions", + "elements": list(elements) + } + +def button(label): + return { + "type": "button", + "text": { + "type": "plain_text", + "text": label, + "emoji": True + } + } + def home(user_id, body): """Returns a view to be published as the turbot home tab for user_id @@ -8,33 +38,7 @@ def home(user_id, body): return { "type": "home", "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "A simple stack of blocks for the simple sample Block Kit Home tab." - } - }, - { - "type": "actions", - "elements": [ - { - "type": "button", - "text": { - "type": "plain_text", - "text": "Action A", - "emoji": True - } - }, - { - "type": "button", - "text": { - "type": "plain_text", - "text": "Action B", - "emoji": True - } - } - ] - } + section(text("This is (or soon will be) a list of available puzzle hunts)")), + actions(button("New hunt")) ] }