Spaces:
Paused
Paused
Commit
·
1316726
1
Parent(s):
e312d3c
Initial setup of Writer Framework
Browse files- hub/README.md +3 -0
- hub/__pycache__/main.cpython-310.pyc +0 -0
- hub/main.py +40 -0
- hub/pyproject.toml +15 -0
- hub/static/README.md +8 -0
- hub/static/favicon.png +0 -0
- hub/ui.json +146 -0
hub/README.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
This app was created using Writer Framework.
|
| 2 |
+
|
| 3 |
+
To learn more about it, visit https://dev.writer.com/framework
|
hub/__pycache__/main.cpython-310.pyc
ADDED
|
Binary file (923 Bytes). View file
|
|
|
hub/main.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import writer as wf
|
| 2 |
+
|
| 3 |
+
# This is a placeholder to get you started or refresh your memory.
|
| 4 |
+
# Delete it or adapt it as necessary.
|
| 5 |
+
# Documentation is available at https://dev.writer.com/framework
|
| 6 |
+
|
| 7 |
+
# Shows in the log when the app starts
|
| 8 |
+
print("Hello world!")
|
| 9 |
+
|
| 10 |
+
# Its name starts with _, so this function won't be exposed
|
| 11 |
+
def _update_message(state):
|
| 12 |
+
is_even = state["counter"] % 2 == 0
|
| 13 |
+
message = ("+Even" if is_even else "-Odd")
|
| 14 |
+
state["message"] = message
|
| 15 |
+
|
| 16 |
+
def decrement(state):
|
| 17 |
+
state["counter"] -= 1
|
| 18 |
+
_update_message(state)
|
| 19 |
+
|
| 20 |
+
def increment(state):
|
| 21 |
+
state["counter"] += 1
|
| 22 |
+
# Shows in the log when the event handler is run
|
| 23 |
+
print("The counter has been incremented.")
|
| 24 |
+
_update_message(state)
|
| 25 |
+
|
| 26 |
+
# Initialise the state
|
| 27 |
+
|
| 28 |
+
# "_my_private_element" won't be serialised or sent to the frontend,
|
| 29 |
+
# because it starts with an underscore
|
| 30 |
+
|
| 31 |
+
initial_state = wf.init_state({
|
| 32 |
+
"my_app": {
|
| 33 |
+
"title": "MY APP"
|
| 34 |
+
},
|
| 35 |
+
"_my_private_element": 1337,
|
| 36 |
+
"message": None,
|
| 37 |
+
"counter": 26,
|
| 38 |
+
})
|
| 39 |
+
|
| 40 |
+
_update_message(initial_state)
|
hub/pyproject.toml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[tool.poetry]
|
| 2 |
+
name = "writer-framework-default"
|
| 3 |
+
version = "0.1.0"
|
| 4 |
+
description = ""
|
| 5 |
+
authors = ["Your Name <[email protected]>"]
|
| 6 |
+
readme = "README.md"
|
| 7 |
+
|
| 8 |
+
[tool.poetry.dependencies]
|
| 9 |
+
python = "^3.10.0"
|
| 10 |
+
writer = {version = "^0.6.0"}
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
[build-system]
|
| 14 |
+
requires = ["poetry-core"]
|
| 15 |
+
build-backend = "poetry.core.masonry.api"
|
hub/static/README.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Serving static files
|
| 2 |
+
|
| 3 |
+
You can use this folder to store files which will be served statically in the "/static" route.
|
| 4 |
+
|
| 5 |
+
This is useful to store images and other files which will be served directly to the user of your application.
|
| 6 |
+
|
| 7 |
+
For example, if you store an image named "myimage.jpg" in this folder, it'll be accessible as "static/my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"
|
| 4 |
+
},
|
| 5 |
+
"components": {
|
| 6 |
+
"root": {
|
| 7 |
+
"id": "root",
|
| 8 |
+
"type": "root",
|
| 9 |
+
"content": {
|
| 10 |
+
"appName": "My App"
|
| 11 |
+
},
|
| 12 |
+
"isCodeManaged": false,
|
| 13 |
+
"position": 0,
|
| 14 |
+
"handlers": {}
|
| 15 |
+
},
|
| 16 |
+
"c0f99a9e-5004-4e75-a6c6-36f17490b134": {
|
| 17 |
+
"id": "c0f99a9e-5004-4e75-a6c6-36f17490b134",
|
| 18 |
+
"type": "page",
|
| 19 |
+
"content": {
|
| 20 |
+
"pageMode": "compact"
|
| 21 |
+
},
|
| 22 |
+
"isCodeManaged": false,
|
| 23 |
+
"position": 0,
|
| 24 |
+
"parentId": "root",
|
| 25 |
+
"handlers": {}
|
| 26 |
+
},
|
| 27 |
+
"bebc5fe9-63a7-46a7-b0fa-62303555cfaf": {
|
| 28 |
+
"id": "bebc5fe9-63a7-46a7-b0fa-62303555cfaf",
|
| 29 |
+
"type": "header",
|
| 30 |
+
"content": {
|
| 31 |
+
"text": "@{my_app.title}"
|
| 32 |
+
},
|
| 33 |
+
"isCodeManaged": false,
|
| 34 |
+
"position": 0,
|
| 35 |
+
"parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134",
|
| 36 |
+
"handlers": {}
|
| 37 |
+
},
|
| 38 |
+
"28d3885b-0fb8-4d41-97c6-978540015431": {
|
| 39 |
+
"id": "28d3885b-0fb8-4d41-97c6-978540015431",
|
| 40 |
+
"type": "section",
|
| 41 |
+
"content": {
|
| 42 |
+
"title": "",
|
| 43 |
+
"containerShadow": "0px 4px 11px -12px #000000"
|
| 44 |
+
},
|
| 45 |
+
"isCodeManaged": false,
|
| 46 |
+
"position": 1,
|
| 47 |
+
"parentId": "c0f99a9e-5004-4e75-a6c6-36f17490b134",
|
| 48 |
+
"handlers": {}
|
| 49 |
+
},
|
| 50 |
+
"9556c0e3-8584-4ac9-903f-908a775a33ec": {
|
| 51 |
+
"id": "9556c0e3-8584-4ac9-903f-908a775a33ec",
|
| 52 |
+
"type": "button",
|
| 53 |
+
"content": {
|
| 54 |
+
"text": " Increment",
|
| 55 |
+
"icon": "arrow_upward"
|
| 56 |
+
},
|
| 57 |
+
"isCodeManaged": false,
|
| 58 |
+
"position": 1,
|
| 59 |
+
"parentId": "0d05bc9f-1655-4d0b-bc9b-c2f4c71a5117",
|
| 60 |
+
"handlers": {
|
| 61 |
+
"click": "increment"
|
| 62 |
+
}
|
| 63 |
+
},
|
| 64 |
+
"51d1554e-1b88-461c-9353-1419cba0053a": {
|
| 65 |
+
"id": "51d1554e-1b88-461c-9353-1419cba0053a",
|
| 66 |
+
"type": "button",
|
| 67 |
+
"content": {
|
| 68 |
+
"text": "Decrement",
|
| 69 |
+
"icon": "arrow_downward"
|
| 70 |
+
},
|
| 71 |
+
"isCodeManaged": false,
|
| 72 |
+
"position": 0,
|
| 73 |
+
"parentId": "0d05bc9f-1655-4d0b-bc9b-c2f4c71a5117",
|
| 74 |
+
"handlers": {
|
| 75 |
+
"click": "decrement"
|
| 76 |
+
}
|
| 77 |
+
},
|
| 78 |
+
"0d05bc9f-1655-4d0b-bc9b-c2f4c71a5117": {
|
| 79 |
+
"id": "0d05bc9f-1655-4d0b-bc9b-c2f4c71a5117",
|
| 80 |
+
"type": "horizontalstack",
|
| 81 |
+
"content": {
|
| 82 |
+
"contentHAlign": "center"
|
| 83 |
+
},
|
| 84 |
+
"isCodeManaged": false,
|
| 85 |
+
"position": 0,
|
| 86 |
+
"parentId": "f3777e75-3659-4d44-8ef7-aeec0d06855b",
|
| 87 |
+
"handlers": {}
|
| 88 |
+
},
|
| 89 |
+
"172a14df-f73a-44fa-8fb1-e8648e7d32d2": {
|
| 90 |
+
"id": "172a14df-f73a-44fa-8fb1-e8648e7d32d2",
|
| 91 |
+
"type": "metric",
|
| 92 |
+
"content": {
|
| 93 |
+
"metricValue": "@{counter}",
|
| 94 |
+
"note": "@{message}",
|
| 95 |
+
"name": "Counter"
|
| 96 |
+
},
|
| 97 |
+
"isCodeManaged": false,
|
| 98 |
+
"position": 0,
|
| 99 |
+
"parentId": "c2519671-9ce7-44e7-ba4e-b0efda9cb20e",
|
| 100 |
+
"handlers": {}
|
| 101 |
+
},
|
| 102 |
+
"d4a5e62c-c6fe-49c4-80d4-33862af8727d": {
|
| 103 |
+
"id": "d4a5e62c-c6fe-49c4-80d4-33862af8727d",
|
| 104 |
+
"type": "columns",
|
| 105 |
+
"content": {},
|
| 106 |
+
"isCodeManaged": false,
|
| 107 |
+
"position": 0,
|
| 108 |
+
"parentId": "28d3885b-0fb8-4d41-97c6-978540015431",
|
| 109 |
+
"handlers": {}
|
| 110 |
+
},
|
| 111 |
+
"f3777e75-3659-4d44-8ef7-aeec0d06855b": {
|
| 112 |
+
"id": "f3777e75-3659-4d44-8ef7-aeec0d06855b",
|
| 113 |
+
"type": "column",
|
| 114 |
+
"content": {
|
| 115 |
+
"title": "",
|
| 116 |
+
"width": "1",
|
| 117 |
+
"contentHAlign": "center",
|
| 118 |
+
"contentVAlign": "center"
|
| 119 |
+
},
|
| 120 |
+
"isCodeManaged": false,
|
| 121 |
+
"position": 2,
|
| 122 |
+
"parentId": "d4a5e62c-c6fe-49c4-80d4-33862af8727d",
|
| 123 |
+
"handlers": {}
|
| 124 |
+
},
|
| 125 |
+
"c2519671-9ce7-44e7-ba4e-b0efda9cb20e": {
|
| 126 |
+
"id": "c2519671-9ce7-44e7-ba4e-b0efda9cb20e",
|
| 127 |
+
"type": "column",
|
| 128 |
+
"content": {
|
| 129 |
+
"width": "1"
|
| 130 |
+
},
|
| 131 |
+
"isCodeManaged": false,
|
| 132 |
+
"position": 0,
|
| 133 |
+
"parentId": "d4a5e62c-c6fe-49c4-80d4-33862af8727d",
|
| 134 |
+
"handlers": {}
|
| 135 |
+
},
|
| 136 |
+
"d4a71819-7444-4083-a1c7-7995452a7abf": {
|
| 137 |
+
"id": "d4a71819-7444-4083-a1c7-7995452a7abf",
|
| 138 |
+
"type": "separator",
|
| 139 |
+
"content": {},
|
| 140 |
+
"isCodeManaged": false,
|
| 141 |
+
"position": 1,
|
| 142 |
+
"parentId": "d4a5e62c-c6fe-49c4-80d4-33862af8727d",
|
| 143 |
+
"handlers": {}
|
| 144 |
+
}
|
| 145 |
+
}
|
| 146 |
+
}
|