]> git.cworth.org Git - turbot/blobdiff - turbot/views.py
Revamp the Home page of our app to start looking like what we want
[turbot] / turbot / views.py
index 95b7b08d25ee741b214b532431a622d56b13a1ab..122d92ceff4ad43ee985808d2e4305951a0e5a48 100644 (file)
@@ -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"))
         ]
     }