flask-construct-ui 0.13.0__tar.gz → 0.14.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/PKG-INFO +7 -1
  2. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/__init__.py +30 -0
  3. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/app_hooks.py +232 -8
  4. flask_construct_ui-0.14.0/flask_construct_ui/audit.py +1498 -0
  5. flask_construct_ui-0.14.0/flask_construct_ui/audit_display.py +336 -0
  6. flask_construct_ui-0.14.0/flask_construct_ui/audit_page.py +246 -0
  7. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/auth.py +55 -0
  8. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/base.py +322 -10
  9. flask_construct_ui-0.14.0/flask_construct_ui/bulk.py +161 -0
  10. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/capabilities.py +1 -1
  11. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/cli.py +52 -1
  12. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/components/__init__.py +16 -0
  13. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/components/content.py +61 -1
  14. flask_construct_ui-0.14.0/flask_construct_ui/components/dashboard.py +482 -0
  15. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/components/grid.py +7 -0
  16. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/components/kanban.py +8 -3
  17. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/components/live.py +36 -4
  18. flask_construct_ui-0.14.0/flask_construct_ui/components/timeline.py +94 -0
  19. flask_construct_ui-0.14.0/flask_construct_ui/confirm.py +232 -0
  20. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/contrast.py +74 -0
  21. flask_construct_ui-0.14.0/flask_construct_ui/crud.py +1140 -0
  22. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/crud_forms.py +41 -2
  23. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/data.py +62 -4
  24. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/data_sqlalchemy.py +63 -7
  25. flask_construct_ui-0.14.0/flask_construct_ui/files.py +555 -0
  26. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/grid.py +24 -10
  27. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/headless.py +76 -21
  28. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/icons.py +15 -0
  29. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/l10n/en/main.flt +165 -0
  30. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/l10n/sv/main.flt +158 -0
  31. flask_construct_ui-0.14.0/flask_construct_ui/language.py +278 -0
  32. flask_construct_ui-0.14.0/flask_construct_ui/list_sort.py +123 -0
  33. flask_construct_ui-0.14.0/flask_construct_ui/live.py +822 -0
  34. flask_construct_ui-0.14.0/flask_construct_ui/localized.py +376 -0
  35. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/navigation.py +18 -0
  36. flask_construct_ui-0.14.0/flask_construct_ui/presence.py +524 -0
  37. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/rcrud.py +141 -16
  38. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/resume.py +11 -0
  39. flask_construct_ui-0.14.0/flask_construct_ui/schema.py +1548 -0
  40. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/static/css/whitelabel.css +592 -0
  41. flask_construct_ui-0.14.0/flask_construct_ui/static/js/construct-core.min.js +2 -0
  42. flask_construct_ui-0.14.0/flask_construct_ui/static/js/construct-grid.min.js +1 -0
  43. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/static/js/kanban-dnd.js +23 -2
  44. flask_construct_ui-0.14.0/flask_construct_ui/templates/audit/page.html +66 -0
  45. flask_construct_ui-0.14.0/flask_construct_ui/templates/components/_presence_body.html +15 -0
  46. flask_construct_ui-0.14.0/flask_construct_ui/templates/components/alert.html +24 -0
  47. flask_construct_ui-0.14.0/flask_construct_ui/templates/components/badge.html +5 -0
  48. flask_construct_ui-0.14.0/flask_construct_ui/templates/components/button.html +29 -0
  49. flask_construct_ui-0.14.0/flask_construct_ui/templates/components/empty_state.html +9 -0
  50. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/components/grid.html +2 -2
  51. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/components/grid_layout.html +1 -1
  52. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/components/kanban.html +1 -1
  53. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/components/live_refresh.html +1 -0
  54. flask_construct_ui-0.14.0/flask_construct_ui/templates/components/presence.html +18 -0
  55. flask_construct_ui-0.14.0/flask_construct_ui/templates/components/progress.html +30 -0
  56. flask_construct_ui-0.14.0/flask_construct_ui/templates/components/stat.html +30 -0
  57. flask_construct_ui-0.14.0/flask_construct_ui/templates/components/timeline.html +29 -0
  58. flask_construct_ui-0.14.0/flask_construct_ui/templates/confirm/_form.html +40 -0
  59. flask_construct_ui-0.14.0/flask_construct_ui/templates/confirm/interstitial.html +44 -0
  60. flask_construct_ui-0.14.0/flask_construct_ui/templates/crud/_actions.html +92 -0
  61. flask_construct_ui-0.14.0/flask_construct_ui/templates/crud/_audit_changes.html +55 -0
  62. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/crud/_macros.html +314 -44
  63. flask_construct_ui-0.14.0/flask_construct_ui/templates/crud/_restore_form.html +10 -0
  64. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/crud/create.html +2 -2
  65. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/crud/edit.html +13 -5
  66. flask_construct_ui-0.14.0/flask_construct_ui/templates/crud/history.html +18 -0
  67. flask_construct_ui-0.14.0/flask_construct_ui/templates/crud/history_version.html +24 -0
  68. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/crud/listindex.html +50 -15
  69. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/crud/related_crud_tab_form.html +8 -5
  70. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/crud/related_crud_tab_list.html +16 -11
  71. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/crud/tab_view.html +1 -1
  72. flask_construct_ui-0.14.0/flask_construct_ui/templates/crud/trash.html +19 -0
  73. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/crud/view.html +12 -2
  74. flask_construct_ui-0.14.0/flask_construct_ui/templates/navbar/language.html +41 -0
  75. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/style/_menu.html +4 -4
  76. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/style/base_full.html +5 -0
  77. flask_construct_ui-0.14.0/flask_construct_ui/timezones.py +206 -0
  78. flask_construct_ui-0.14.0/flask_construct_ui/versioning.py +235 -0
  79. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui.egg-info/PKG-INFO +7 -1
  80. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui.egg-info/SOURCES.txt +30 -0
  81. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui.egg-info/requires.txt +9 -0
  82. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/pyproject.toml +15 -2
  83. flask_construct_ui-0.13.0/flask_construct_ui/crud.py +0 -529
  84. flask_construct_ui-0.13.0/flask_construct_ui/language.py +0 -131
  85. flask_construct_ui-0.13.0/flask_construct_ui/live.py +0 -255
  86. flask_construct_ui-0.13.0/flask_construct_ui/schema.py +0 -718
  87. flask_construct_ui-0.13.0/flask_construct_ui/static/js/construct-core.min.js +0 -2
  88. flask_construct_ui-0.13.0/flask_construct_ui/static/js/construct-grid.min.js +0 -1
  89. flask_construct_ui-0.13.0/flask_construct_ui/templates/components/button.html +0 -16
  90. flask_construct_ui-0.13.0/flask_construct_ui/templates/crud/_actions.html +0 -46
  91. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/LICENSE +0 -0
  92. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/README.md +0 -0
  93. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/components/calendar.py +0 -0
  94. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/components/chart.py +0 -0
  95. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/components/chart_native.py +0 -0
  96. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/components/core.py +0 -0
  97. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/components/layout.py +0 -0
  98. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/components/period.py +0 -0
  99. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/components/pivot.py +0 -0
  100. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/csrf.py +0 -0
  101. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/dragdrop.py +0 -0
  102. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/errors.py +0 -0
  103. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/flashes.py +0 -0
  104. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/forms.py +0 -0
  105. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/layout.py +0 -0
  106. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/menu.py +0 -0
  107. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/navbar.py +0 -0
  108. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/orgmode.py +0 -0
  109. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/pagination.py +0 -0
  110. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/py.typed +0 -0
  111. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/sanitize.py +0 -0
  112. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/static/css/grid.css +0 -0
  113. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/static/css/prosemirror-bundle.min.css +0 -0
  114. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/static/css/unpoly.min.css +0 -0
  115. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/static/designs/adminlte.css +0 -0
  116. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/static/designs/sandstone.css +0 -0
  117. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/static/fonts/bootstrap-icons/LICENSE.txt +0 -0
  118. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/static/fonts/bootstrap-icons/bootstrap-icons.min.css +0 -0
  119. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/static/fonts/bootstrap-icons/fonts/bootstrap-icons.woff +0 -0
  120. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/static/fonts/bootstrap-icons/fonts/bootstrap-icons.woff2 +0 -0
  121. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/static/fonts/material-symbols/LICENSE.txt +0 -0
  122. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/static/fonts/material-symbols/material-symbols-outlined.woff2 +0 -0
  123. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/static/fonts/material-symbols/material-symbols.css +0 -0
  124. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/static/fonts/material-symbols/names.txt +0 -0
  125. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/static/js/prosemirror-bundle.min.js +0 -0
  126. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/static/js/unpoly.min.js +0 -0
  127. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/components/_form_field.html +0 -0
  128. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/components/calendar.html +0 -0
  129. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/components/calendarmini.html +0 -0
  130. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/components/card.html +0 -0
  131. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/components/chart.html +0 -0
  132. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/components/chart_native.html +0 -0
  133. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/components/form.html +0 -0
  134. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/components/grid_notice.html +0 -0
  135. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/components/horizontal_layout.html +0 -0
  136. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/components/live.html +0 -0
  137. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/components/main.html +0 -0
  138. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/components/markup.html +0 -0
  139. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/components/period_nav.html +0 -0
  140. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/components/pivot_form.html +0 -0
  141. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/components/rich_text.html +0 -0
  142. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/components/table.html +0 -0
  143. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/components/tabs.html +0 -0
  144. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/components/text.html +0 -0
  145. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/components/vertical_layout.html +0 -0
  146. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/crud/_many_related_options.html +0 -0
  147. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/crud/_related_options.html +0 -0
  148. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/errors/error.html +0 -0
  149. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/errors/forbidden.html +0 -0
  150. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/navbar/notifications.html +0 -0
  151. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/navbar/search_results.html +0 -0
  152. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/structure/base.html +0 -0
  153. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/structure/public.html +0 -0
  154. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/style/_flashes.html +0 -0
  155. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/style/_footer.html +0 -0
  156. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/templates/style/base_partial.html +0 -0
  157. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/testing.py +0 -0
  158. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/urls.py +0 -0
  159. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui/validation.py +0 -0
  160. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui.egg-info/dependency_links.txt +0 -0
  161. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/flask_construct_ui.egg-info/top_level.txt +0 -0
  162. {flask_construct_ui-0.13.0 → flask_construct_ui-0.14.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: flask-construct-ui
3
- Version: 0.13.0
3
+ Version: 0.14.0
4
4
  Summary: A UI toolkit for Flask with CRUD and component features.
5
5
  Author-email: Olof Tjerngren <olof@tjerngren.net>
6
6
  License-Expression: LGPL-3.0-or-later
@@ -34,6 +34,12 @@ Provides-Extra: oidc
34
34
  Requires-Dist: flask-oidc; extra == "oidc"
35
35
  Provides-Extra: session
36
36
  Requires-Dist: flask-session[redis]; extra == "session"
37
+ Provides-Extra: valkey
38
+ Requires-Dist: valkey; extra == "valkey"
39
+ Provides-Extra: redis
40
+ Requires-Dist: redis; extra == "redis"
41
+ Provides-Extra: audit
42
+ Requires-Dist: diff-match-patch>=20241021; extra == "audit"
37
43
  Dynamic: license-file
38
44
 
39
45
  # Flask-Construct-UI
@@ -7,6 +7,8 @@ from .base import expose as expose
7
7
  from .base import list_action as list_action
8
8
  from .base import tab_action as tab_action
9
9
  from .base import edit_action as edit_action
10
+ from .base import page_action as page_action
11
+ from .base import bulk_action as bulk_action
10
12
  from .base import datasource as datasource
11
13
  from .base import livesource as livesource
12
14
  from .base import gridsource as gridsource
@@ -51,6 +53,8 @@ from .components import (
51
53
  PivotColumn as PivotColumn,
52
54
  PivotCell as PivotCell,
53
55
  PeriodNavComponent as PeriodNavComponent,
56
+ TimelineComponent as TimelineComponent,
57
+ TimelineItem as TimelineItem,
54
58
  )
55
59
 
56
60
  # Authentication & authorization
@@ -100,6 +104,7 @@ from .icons import (
100
104
  from .headless import (
101
105
  sse_event as sse_event,
102
106
  sse_response as sse_response,
107
+ last_event_id as last_event_id,
103
108
  live_attributes as live_attributes,
104
109
  live_container as live_container,
105
110
  )
@@ -109,12 +114,37 @@ from .live import (
109
114
  ChangeFeed as ChangeFeed,
110
115
  MemoryBroker as MemoryBroker,
111
116
  RedisBroker as RedisBroker,
117
+ ValkeyBroker as ValkeyBroker,
112
118
  SQLAlchemyChanges as SQLAlchemyChanges,
119
+ topic_name as topic_name,
113
120
  )
114
121
 
122
+ # Who else has a record open (see presence.py)
123
+ from .presence import (
124
+ MemoryPresenceStore as MemoryPresenceStore,
125
+ Presence as Presence,
126
+ PresenceStore as PresenceStore,
127
+ RedisPresenceStore as RedisPresenceStore,
128
+ presence_notice as presence_notice,
129
+ record_key as record_key,
130
+ )
131
+
132
+ # Audit history (see audit.py); `from flask_construct_ui import audit` also
133
+ # gives audit.actor(...) and audit.note(...).
134
+ from . import audit as audit
135
+ from .audit import AuditLog as AuditLog, audit_model as audit_model
136
+ from .audit_page import AuditPage as AuditPage
137
+
115
138
  # Declarative drag-and-drop attributes (see dragdrop.py)
116
139
  from .dragdrop import drag_attrs as drag_attrs, drop_attrs as drop_attrs
117
140
  from .errors import render_error as render_error
141
+ from .confirm import (
142
+ CONFIRM_FIELD as CONFIRM_FIELD,
143
+ Confirmation as Confirmation,
144
+ confirmation_page as confirmation_page,
145
+ is_confirmed as is_confirmed,
146
+ requires_confirmation as requires_confirmation,
147
+ )
118
148
 
119
149
  # HTML sanitizer (allowlist-based; for trusted-HTML surfaces such as
120
150
  # LiveComponent format="raw" and TextComponent format="html")
@@ -20,11 +20,24 @@ from .csrf import (
20
20
  generate_csrf_token,
21
21
  validate_csrf_token,
22
22
  )
23
+ from .files import DEFAULT_MAX_SIZE as UPLOAD_MAX_SIZE
24
+ from .files import DEFAULT_URL_MAX_AGE as FILE_URL_MAX_AGE
25
+ from .files import serve as serve_file
23
26
  from .flashes import render_flashes
24
27
  from .headless import live_attributes, live_container, sse_event, sse_response
25
28
  from .live import live_refresh
29
+ from .presence import presence_notice
26
30
  from .icons import render_icon
27
- from .navigation import resolve_next
31
+ from .language import choose_language, language_choices, offered_languages
32
+ from .localized import (
33
+ format_date,
34
+ format_datetime,
35
+ format_money,
36
+ format_number,
37
+ format_percent,
38
+ format_time,
39
+ )
40
+ from .navigation import MACHINE_ENDPOINTS, resolve_next
28
41
  from .pagination import DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE
29
42
  from .resume import DEFAULT_MAX_BYTES as RESUME_MAX_BYTES
30
43
  from .resume import DEFAULT_SKIP_FIELDS as RESUME_SKIP_FIELDS
@@ -36,6 +49,7 @@ from .resume import (
36
49
  resumed_values,
37
50
  )
38
51
  from .sanitize import sanitize_html
52
+ from .timezones import current_timezone, localtime_filter
39
53
  from .dragdrop import drag_attrs, drop_attrs
40
54
  from .urls import current_url, hidden_inputs, query_string
41
55
 
@@ -71,6 +85,30 @@ def set_config_defaults(construct, app):
71
85
  # ending; the browser reconnects at once. Bounds how long a worker is held
72
86
  # by a client that has gone away without a write to notice it by.
73
87
  app.config.setdefault("CONSTRUCT_LIVE_WAIT", 25)
88
+ # Who else has a record open (see presence.py). Off unless the app turns
89
+ # it on here or passes FlaskConstructUI(presence=...).
90
+ app.config.setdefault("CONSTRUCT_PRESENCE", False)
91
+ # File and image fields (see files.py). CONSTRUCT_UPLOAD_DIR is read
92
+ # when a file is first stored, so None means "<instance path>/uploads".
93
+ app.config.setdefault("CONSTRUCT_UPLOAD_DIR", None)
94
+ app.config.setdefault("CONSTRUCT_FILE_STORAGES", {})
95
+ app.config.setdefault("CONSTRUCT_UPLOAD_MAX_SIZE", UPLOAD_MAX_SIZE)
96
+ app.config.setdefault("CONSTRUCT_FILE_URL_MAX_AGE", FILE_URL_MAX_AGE)
97
+ # The zone DateTime values are shown and typed in when neither the app's
98
+ # timezone= hook nor the signed-in user names one; values are stored in
99
+ # UTC (see timezones.py).
100
+ app.config.setdefault("CONSTRUCT_TIMEZONE", "UTC")
101
+ # The reader's own choice of language (see language.py): which languages
102
+ # are offered (None = every catalog loaded), whether the navbar shows
103
+ # the switcher, and the cookie the choice is kept in. The switcher is
104
+ # opt-in: the library's own catalogs make every app bilingual, and an
105
+ # app whose labels are in one language should not offer a second.
106
+ app.config.setdefault("CONSTRUCT_LANGUAGES", None)
107
+ app.config.setdefault("CONSTRUCT_LANGUAGE_SWITCHER", False)
108
+ app.config.setdefault("CONSTRUCT_LANGUAGE_COOKIE", "construct_language")
109
+ # Language whose number/date formats localized.filters() use for a
110
+ # language missing from its table.
111
+ app.config.setdefault("CONSTRUCT_DISPLAY_LOCALE_FALLBACK", "en")
74
112
 
75
113
 
76
114
  def install_request_hooks(construct, app):
@@ -99,6 +137,13 @@ def install_request_hooks(construct, app):
99
137
  existing = response.headers.get("Vary", "")
100
138
  if "X-Up-Target" not in existing:
101
139
  response.headers["Vary"] = (existing + ", X-Up-Target").lstrip(", ")
140
+ # The page's language may come from the language cookie or the
141
+ # Accept-Language header; a shared cache must not serve one
142
+ # reader's language to another.
143
+ for header in ("Cookie", "Accept-Language"):
144
+ existing = response.headers.get("Vary", "")
145
+ if header not in existing:
146
+ response.headers["Vary"] = (existing + ", " + header).lstrip(", ")
102
147
  return response
103
148
 
104
149
  @app.after_request
@@ -149,6 +194,8 @@ def install_request_hooks(construct, app):
149
194
  or request.blueprint not in construct._blueprint_names
150
195
  ):
151
196
  return
197
+ if request.endpoint in PUBLIC_FEATURE_ENDPOINTS:
198
+ return
152
199
  page = construct._pages_by_endpoint.get(request.blueprint)
153
200
  method = (request.endpoint or "").split(".", 1)[-1]
154
201
  rule = (page._auth_rules.get(method) if page is not None else None) or {}
@@ -158,6 +205,11 @@ def install_request_hooks(construct, app):
158
205
  if rule.get("public") or (page_public and "groups" not in rule):
159
206
  return
160
207
  if not construct._auth.is_authenticated():
208
+ if request.endpoint in MACHINE_ENDPOINTS:
209
+ # The change feed: its EventSource closes on a non-200 and the
210
+ # page falls back to polling under "not updating" — see
211
+ # navigation.MACHINE_ENDPOINTS for why not a login challenge.
212
+ return "", 401, {"Cache-Control": "no-store"}
161
213
  return construct._auth.on_unauthenticated()
162
214
  groups = rule.get("groups") or (
163
215
  page.required_groups if page is not None else None
@@ -166,6 +218,11 @@ def install_request_hooks(construct, app):
166
218
  return construct._auth.on_forbidden()
167
219
 
168
220
 
221
+ #: Feature routes open to a reader who is not signed in. Choosing a language
222
+ #: only sets a cookie, and a login page has to be readable first.
223
+ PUBLIC_FEATURE_ENDPOINTS = frozenset({"construct_features.set_language"})
224
+
225
+
169
226
  def install_template_helpers(construct, app):
170
227
  """Jinja filters, globals and the ``construct`` context processor.
171
228
 
@@ -187,6 +244,21 @@ def install_template_helpers(construct, app):
187
244
  sanitize_html(md.render(s))
188
245
  ) # nosemgrep: explicit-unescape-with-markup # nosec B704
189
246
 
247
+ def ucfirst_filter(s):
248
+ """Upper-case the first character only.
249
+
250
+ Unlike ``str.capitalize()`` the rest is left alone, so a translation
251
+ such as "SSH Keys" is shown as written while a bare untranslated key
252
+ still gets a capital first letter.
253
+ """
254
+ if s is None:
255
+ return ""
256
+ s = str(s)
257
+ return s[:1].upper() + s[1:]
258
+
259
+ app.jinja_env.filters["ucfirst"] = ucfirst_filter
260
+ jinja_env.filters["ucfirst"] = ucfirst_filter
261
+
190
262
  @app.template_filter("orgmode")
191
263
  def orgmode_filter(s):
192
264
  if s is None:
@@ -218,10 +290,27 @@ def install_template_helpers(construct, app):
218
290
  user = construct._auth.current_user() if construct._auth is not None else None
219
291
  return {"construct": construct, "current_user": user}
220
292
 
293
+ # Time zones and localised display for an app's own templates; see
294
+ # timezones.py and localized.py.
295
+ zone_filters = {
296
+ "localtime": localtime_filter,
297
+ "format_number": format_number,
298
+ "format_money": format_money,
299
+ "format_percent": format_percent,
300
+ "format_date": format_date,
301
+ "format_time": format_time,
302
+ "format_datetime": format_datetime,
303
+ }
304
+ app.jinja_env.filters.update(zone_filters)
305
+ jinja_env.filters.update(zone_filters)
306
+
221
307
  app.jinja_env.globals.update(
308
+ timezone=current_timezone,
309
+ language_choices=language_choices,
222
310
  live_container=live_container,
223
311
  live_attributes=live_attributes,
224
312
  live_refresh=live_refresh,
313
+ presence_notice=presence_notice,
225
314
  csrf_field=csrf_field,
226
315
  csrf_token=generate_csrf_token,
227
316
  t=translate,
@@ -248,6 +337,8 @@ def install_template_helpers(construct, app):
248
337
  # so the CSRF helpers, translator and icon renderer must be registered
249
338
  # there too.
250
339
  jinja_env.globals.update(
340
+ timezone=current_timezone,
341
+ language_choices=language_choices,
251
342
  csrf_field=csrf_field,
252
343
  csrf_token=generate_csrf_token,
253
344
  t=translate,
@@ -258,6 +349,7 @@ def install_template_helpers(construct, app):
258
349
  drag_attrs=drag_attrs,
259
350
  drop_attrs=drop_attrs,
260
351
  live_refresh=live_refresh,
352
+ presence_notice=presence_notice,
261
353
  )
262
354
  if app.jinja_env.loader:
263
355
  jinja_env.loader = jinja2.ChoiceLoader(
@@ -288,12 +380,22 @@ def register_features_blueprint(construct):
288
380
  menu_url = "/menu"
289
381
  footer_url = "/footer"
290
382
  live_url = "/live/changes"
383
+ language_url = "/language"
384
+ files_url = "/files/<token>/<path:filename>"
385
+ presence_urls = {
386
+ "beat": "/presence/beat",
387
+ "wait": "/presence/wait",
388
+ "leave": "/presence/leave",
389
+ }
291
390
  if construct.enforce_trailing_slash:
391
+ presence_urls = {name: url + "/" for name, url in presence_urls.items()}
292
392
  search_url += "/"
293
393
  notifications_url += "/"
294
394
  menu_url += "/"
295
395
  footer_url += "/"
296
396
  live_url += "/"
397
+ language_url += "/"
398
+ files_url += "/"
297
399
 
298
400
  route_kwargs = {}
299
401
  if construct.strict_slashes is not None:
@@ -346,6 +448,26 @@ def register_features_blueprint(construct):
346
448
  footer_fragment=True,
347
449
  )
348
450
 
451
+ @features_bp.route(language_url, methods=["POST"], **route_kwargs)
452
+ def set_language():
453
+ # The language switcher: a plain POST form, so it works with
454
+ # JavaScript off. Stores the choice and goes back where it came
455
+ # from (`next`, checked like every other next= in the library).
456
+ code = request.form.get("language", "")
457
+ if code not in offered_languages():
458
+ return "", 400
459
+ from flask import redirect
460
+
461
+ target = resolve_next(construct.url)
462
+ return choose_language(redirect(target, 303), code)
463
+
464
+ @features_bp.route(files_url, **route_kwargs)
465
+ def file(token, filename):
466
+ # A stored file behind a signed, expiring link (see files.py). The
467
+ # link is only issued while rendering a record the reader may see;
468
+ # `filename` is only there so the browser names a download sensibly.
469
+ return serve_file(token)
470
+
349
471
  @features_bp.route(live_url, **route_kwargs)
350
472
  def live_changes():
351
473
  # The change feed behind live_refresh(); see live.py. Unconditional
@@ -358,24 +480,45 @@ def register_features_blueprint(construct):
358
480
  feed = construct.live
359
481
  if feed is None:
360
482
  return "", 404
483
+ #
484
+ # A `since` the broker did not issue (another MemoryBroker worker,
485
+ # the app before a restart) cannot be compared: the answer carries
486
+ # `refresh: false` and the page adopts the version without rendering.
487
+ #
488
+ # `topics` (comma-separated) is the marker's: the version asked about
489
+ # is then the one that moves only for changes to those topics.
361
490
  since = request.args.get("since", "")
491
+ topics = [t for t in request.args.get("topics", "").split(",") if t][:64]
362
492
  no_store = {"Cache-Control": "no-store"}
363
- if request.args.get("poll"):
364
- version = feed.version()
365
- if version is None:
366
- return jsonify(error="unavailable"), 503, no_store
367
- return jsonify(version=version), 200, no_store
368
493
  # Fail the request, not the stream, when the broker is down: an
369
494
  # EventSource only gives up (and the page falls back to polling and
370
495
  # shows "not updating") on a non-200 answer.
371
- if feed.version() is None:
496
+ try:
497
+ version = feed.version(topics) if topics else feed.version()
498
+ except ValueError: # a topic no marker of ours would have sent
499
+ return "", 400, no_store
500
+ if version is None:
501
+ if request.args.get("poll"):
502
+ return jsonify(error="unavailable"), 503, no_store
372
503
  return "", 503, no_store
504
+ adopt = {"version": version, "refresh": False}
505
+ known = feed.knows(since)
506
+ if request.args.get("poll"):
507
+ if not known:
508
+ return jsonify(adopt), 200, no_store
509
+ return jsonify(version=version), 200, no_store
373
510
  wait = float(current_app.config.get("CONSTRUCT_LIVE_WAIT", 25))
374
511
 
375
512
  def stream():
376
513
  yield "retry: 2000\n\n"
514
+ if not known:
515
+ yield sse_event("change", adopt)
516
+ return
377
517
  try:
378
- version = feed.wait(since, wait)
518
+ if topics:
519
+ version = feed.wait(since, wait, topics)
520
+ else:
521
+ version = feed.wait(since, wait)
379
522
  except Exception: # noqa: BLE001 - the client reconnects and sees the 503
380
523
  _log.warning("live: change feed failed mid-stream", exc_info=True)
381
524
  return
@@ -384,5 +527,86 @@ def register_features_blueprint(construct):
384
527
 
385
528
  return sse_response(stream())
386
529
 
530
+ register_presence_routes(construct, features_bp, presence_urls, route_kwargs)
531
+
387
532
  construct.app.register_blueprint(features_bp)
388
533
  construct._blueprint_names.add("construct_features")
534
+
535
+
536
+ def register_presence_routes(construct, features_bp, urls, route_kwargs):
537
+ """The three routes a presence notice's script talks to (see presence.py).
538
+
539
+ Unconditional, like the live feed's: ``construct.presence`` is decided per
540
+ request, so they 404 while presence is off. Each acts only on the visit a
541
+ signed token names (400 for one this app did not sign), and only for the
542
+ reader it was handed to (403 for anyone else).
543
+ """
544
+ no_store = {"Cache-Control": "no-store"}
545
+
546
+ def visit():
547
+ presence = construct.presence
548
+ if presence is None:
549
+ return None, ("", 404, no_store)
550
+ token = request.values.get("token", "")
551
+ named = presence.read_token(token) if token else None
552
+ if named is None:
553
+ return None, ("", 400, no_store)
554
+ # A visit is its reader's to keep or end: a token that leaked into
555
+ # another session (a shared link, a copied page) does nothing there.
556
+ reader = presence.reader()
557
+ if reader is None or reader[0] != named[2]:
558
+ return None, ("", 403, no_store)
559
+ return (presence, *named), None
560
+
561
+ @features_bp.route(urls["beat"], methods=["POST"], **route_kwargs)
562
+ def presence_beat():
563
+ # A heartbeat: keeps the visit alive and answers with the notice's
564
+ # body as it stands now, plus the version to wait from.
565
+ found, refused = visit()
566
+ if refused:
567
+ return refused
568
+ presence, key, tab, user_id, mode = found
569
+ others = presence.beat(key, tab, user_id, mode)
570
+ if others is None:
571
+ return "", 503, no_store
572
+ body = render_template(
573
+ "components/_presence_body.html", others=others, mode=mode
574
+ )
575
+ headers = dict(no_store)
576
+ headers["X-FCU-Presence-Version"] = presence.version(key) or ""
577
+ return body, 200, headers
578
+
579
+ @features_bp.route(urls["leave"], methods=["POST"], **route_kwargs)
580
+ def presence_leave():
581
+ found, refused = visit()
582
+ if refused:
583
+ return refused
584
+ presence, key, tab, user_id, _mode = found
585
+ presence.leave(key, tab, user_id)
586
+ return "", 204, no_store
587
+
588
+ @features_bp.route(urls["wait"], **route_kwargs)
589
+ def presence_wait():
590
+ # Ends with a `change` event once someone arrives, leaves or starts
591
+ # editing under the key; the page then sends a heartbeat to learn
592
+ # who. Quietly after CONSTRUCT_LIVE_WAIT seconds otherwise.
593
+ found, refused = visit()
594
+ if refused:
595
+ return refused
596
+ presence, key = found[0], found[1]
597
+ since = request.args.get("since", "")
598
+ if presence.version(key) is None:
599
+ return "", 503, no_store
600
+ wait = float(current_app.config.get("CONSTRUCT_LIVE_WAIT", 25))
601
+
602
+ def stream():
603
+ yield "retry: 5000\n\n"
604
+ try:
605
+ version = presence.wait(key, since, wait)
606
+ except Exception: # noqa: BLE001 - the client falls back to heartbeats
607
+ _log.warning("presence: wait failed mid-stream", exc_info=True)
608
+ return
609
+ if version != since:
610
+ yield sse_event("change", {"version": version})
611
+
612
+ return sse_response(stream())