Skip to content

Commit 718f3e4

Browse files
Clean up constants: consolidate scattered constants and remove unused ones (#1435)
* Consolidate scattered constants and remove unused ones - Move MAX_FILE_SIZE_MB, MAX_IMAGES_COUNT, PROMPT_MAP from hero.py to constants.py - Move CONTRIBUTION_URL, BUGS_URL from open_source.py to constants.py - Move FONT_FAMILY, DOC_BORDER_RADIUS from styles.py to constants.py - Move PRICING_TABLE_STYLES dict from pricing/table.py to constants.py - Move SPLINE_SCENE_URL from spline.py to constants.py - Consolidate repeated reflex.dev URLs and @getreflex in meta.py - Remove unused PYNECONE_URL and MONTHLY_USERS constants - Update all import statements to use consolidated constants - Verify application functionality is preserved Co-Authored-By: Alek <[email protected]> * Add back PYNECONE_URL constant - PYNECONE_URL is still referenced in blog/2023-06-28-rebrand-to-reflex.md - This constant is needed for historical blog post about the rebrand - Application now runs successfully with all constants properly consolidated Co-Authored-By: Alek <[email protected]> * Add verification script for constants consolidation - Script tests that all new constants can be imported successfully - Verifies that updated imports work correctly across the codebase - Helps ensure constants consolidation doesn't break functionality Co-Authored-By: Alek <[email protected]> * Move styling constants back to appropriate files per feedback - Move FONT_FAMILY back to fonts.py as local constant - Move PRICING_TABLE_STYLES back to table.py as STYLES dict - DOC_BORDER_RADIUS remains in styles.py where it belongs - Remove imports of styling constants from constants.py - Update verification script to test non-styling constants only - Maintain all other consolidated constants in constants.py Addresses feedback: 'no styles should be in the constants' Co-Authored-By: Alek <[email protected]> * Complete removal of styling constants from constants.py - Remove FONT_FAMILY, DOC_BORDER_RADIUS, and PRICING_TABLE_STYLES from constants.py - Update templates/docpage/blocks/code.py to use DOC_BORDER_RADIUS from styles module - Ensure styles.py properly defines DOC_BORDER_RADIUS locally - All styling constants now properly separated from main constants file Co-Authored-By: Alek <[email protected]> * Address greptile bot comments: move runtime version and domain to constants - Add SPLINE_RUNTIME_VERSION constant for @splinetool/runtime version - Add REFLEX_DOMAIN constant for consistent twitter:domain usage - Update spline.py to use SPLINE_RUNTIME_VERSION constant - Update meta.py to use REFLEX_DOMAIN for all twitter:domain fields - Improves consistency and maintainability of configuration values Addresses greptile bot suggestions on PR #1435 Co-Authored-By: Alek <[email protected]> * Remove verification script per PR feedback - Remove verify_constants.py as it's not needed for production - Addresses Alek's comment that verification file is unnecessary Co-Authored-By: Alek <[email protected]> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Alek <[email protected]>
1 parent 10ba809 commit 718f3e4

File tree

6 files changed

+43
-30
lines changed

6 files changed

+43
-30
lines changed

pcweb/components/spline.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import reflex as rx
2+
from pcweb.constants import SPLINE_SCENE_URL, SPLINE_RUNTIME_VERSION
23
from reflex.vars import Var
34

45

@@ -7,10 +8,10 @@ class Spline(rx.Component):
78

89
library = "@splinetool/react-spline"
910
tag = "Spline"
10-
scene: Var[str] = "https://prod.spline.design/Br2ec3WwuRGxEuij/scene.splinecode"
11+
scene: Var[str] = SPLINE_SCENE_URL
1112
is_default = True
1213

13-
lib_dependencies: list[str] = ["@splinetool/runtime@1.5.5"]
14+
lib_dependencies: list[str] = [f"@splinetool/runtime@{SPLINE_RUNTIME_VERSION}"]
1415

1516

1617
spline = Spline.create

pcweb/constants.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
# pcweb urls.
1818
REFLEX_URL = "https://reflex.dev/"
1919
REFLEX_DOCS_URL = "https://reflex.dev/docs/getting-started/introduction/"
20+
PYNECONE_URL = "https://pynecone.io"
2021
REFLEX_CLOUD_URL = os.getenv("REFLEX_CLOUD_URL", "https://cloud.reflex.dev/")
2122
REFLEX_BUILD_URL = os.getenv("REFLEX_BUILD_URL", "https://build.reflex.dev/")
22-
PYNECONE_URL = "https://pynecone.io"
23+
2324
PIP_URL = "https://pypi.org/project/reflex"
2425
GITHUB_URL = "https://github.com/reflex-dev/reflex"
2526
OLD_GITHUB_URL = "https://github.com/pynecone-io/pynecone"
@@ -70,9 +71,28 @@
7071

7172
# Stats
7273
GITHUB_STARS = 23000
73-
MONTHLY_USERS = 10000
7474
DISCORD_USERS = 7000
7575
CONTRIBUTORS = 170
7676

77+
MAX_FILE_SIZE_MB = 5
78+
MAX_FILE_SIZE_BYTES = MAX_FILE_SIZE_MB * 1024 * 1024
79+
MAX_IMAGES_COUNT = 5
80+
81+
PROMPT_MAP = {
82+
"Use an Image": "Build an app from a reference image",
83+
"Chat App": "A chat app hooked up to an LLM",
84+
"Live Dashboard": "Live stream data on a real-time dashboard",
85+
}
86+
87+
CONTRIBUTION_URL = "https://github.com/reflex-dev/reflex/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22"
88+
BUGS_URL = "https://github.com/reflex-dev/reflex/issues?q=is%3Aopen+is%3Aissue"
89+
90+
SPLINE_SCENE_URL = "https://prod.spline.design/Br2ec3WwuRGxEuij/scene.splinecode"
91+
SPLINE_RUNTIME_VERSION = "1.5.5"
92+
93+
REFLEX_DOMAIN_URL = "https://reflex.dev/"
94+
REFLEX_DOMAIN = "reflex.dev"
95+
TWITTER_CREATOR = "@getreflex"
96+
7797
# Posthog
7898
POSTHOG_API_KEY = os.getenv("POSTHOG_API_KEY")

pcweb/meta/meta.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import reflex as rx
2+
from pcweb.constants import REFLEX_DOMAIN_URL, REFLEX_DOMAIN, TWITTER_CREATOR
23

34

45
meta_tags = [
@@ -13,7 +14,7 @@
1314
"content": "The open-source framework to build and deploy web apps using Python.",
1415
},
1516
# Facebook Meta Tags
16-
{"property": "og:url", "content": "https://reflex.dev/"},
17+
{"property": "og:url", "content": REFLEX_DOMAIN_URL},
1718
{"property": "og:type", "content": "website"},
1819
{"property": "og:title", "content": "Reflex · Web apps in Pure Python"},
1920
{
@@ -23,15 +24,15 @@
2324
{"property": "og:image", "content": "/previews/index_preview.png"},
2425
# Twitter Meta Tags
2526
{"name": "twitter:card", "content": "summary_large_image"},
26-
{"property": "twitter:domain", "content": "reflex.dev"},
27-
{"property": "twitter:url", "content": "https://reflex.dev/"},
27+
{"property": "twitter:domain", "content": REFLEX_DOMAIN},
28+
{"property": "twitter:url", "content": REFLEX_DOMAIN_URL},
2829
{"name": "twitter:title", "content": "Reflex · Web apps in Pure Python"},
2930
{
3031
"name": "twitter:description",
3132
"content": "The open-source framework to build and deploy web apps using Python.",
3233
},
3334
{"name": "twitter:image", "content": "/previews/index_preview.png"},
34-
{"name": "twitter:creator", "content": "@getreflex"},
35+
{"name": "twitter:creator", "content": TWITTER_CREATOR},
3536
]
3637

3738
hosting_meta_tags = [
@@ -46,7 +47,7 @@
4647
"content": "The open-source framework to build and deploy web apps using Python.",
4748
},
4849
# Facebook Meta Tags
49-
{"property": "og:url", "content": "https://reflex.dev/"},
50+
{"property": "og:url", "content": REFLEX_DOMAIN_URL},
5051
{"property": "og:type", "content": "website"},
5152
{"property": "og:title", "content": "Reflex · Web apps in Pure Python"},
5253
{
@@ -56,15 +57,15 @@
5657
{"property": "og:image", "content": "/previews/hosting_preview.png"},
5758
# Twitter Meta Tags
5859
{"name": "twitter:card", "content": "summary_large_image"},
59-
{"property": "twitter:domain", "content": "reflex.dev"},
60-
{"property": "twitter:url", "content": "https://reflex.dev/"},
60+
{"property": "twitter:domain", "content": REFLEX_DOMAIN},
61+
{"property": "twitter:url", "content": REFLEX_DOMAIN_URL},
6162
{"name": "twitter:title", "content": "Reflex · Web apps in Pure Python"},
6263
{
6364
"name": "twitter:description",
6465
"content": "The open-source framework to build and deploy web apps using Python.",
6566
},
6667
{"name": "twitter:image", "content": "/previews/hosting_preview.png"},
67-
{"name": "twitter:creator", "content": "@getreflex"},
68+
{"name": "twitter:creator", "content": TWITTER_CREATOR},
6869
]
6970

7071

@@ -97,7 +98,7 @@ def create_meta_tags(title: str, description: str, image: str) -> list[rx.Compon
9798
"content": description,
9899
},
99100
# Facebook Meta Tags
100-
{"property": "og:url", "content": "https://reflex.dev/"},
101+
{"property": "og:url", "content": REFLEX_DOMAIN_URL},
101102
{"property": "og:type", "content": "website"},
102103
{"property": "og:title", "content": title},
103104
{
@@ -107,13 +108,13 @@ def create_meta_tags(title: str, description: str, image: str) -> list[rx.Compon
107108
{"property": "og:image", "content": image},
108109
# Twitter Meta Tags
109110
{"name": "twitter:card", "content": "summary_large_image"},
110-
{"property": "twitter:domain", "content": "reflex.dev"},
111-
{"property": "twitter:url", "content": "https://reflex.dev/"},
111+
{"property": "twitter:domain", "content": REFLEX_DOMAIN},
112+
{"property": "twitter:url", "content": REFLEX_DOMAIN_URL},
112113
{"name": "twitter:title", "content": title},
113114
{
114115
"name": "twitter:description",
115116
"content": description,
116117
},
117118
{"name": "twitter:image", "content": image},
118-
{"name": "twitter:creator", "content": "@getreflex"},
119+
{"name": "twitter:creator", "content": TWITTER_CREATOR},
119120
]

pcweb/pages/framework/views/open_source.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import reflex as rx
22
from pcweb.components.icons.icons import get_icon
3-
from pcweb.constants import GITHUB_STARS
3+
from pcweb.constants import GITHUB_STARS, CONTRIBUTION_URL, BUGS_URL
4+
45

5-
contribution_url = "https://github.com/reflex-dev/reflex/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22"
6-
bugs_url = "https://github.com/reflex-dev/reflex/issues?q=is%3Aopen+is%3Aissue"
76

87

98
def stat(icon: str, stat: str, text: str) -> rx.Component:

pcweb/pages/landing/views/hero.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,15 @@
44
import reflex as rx
55
from pcweb.components.icons.icons import get_icon_var
66
from pcweb.components.icons.hugeicons import hi
7-
from pcweb.constants import REFLEX_BUILD_URL, RX_BUILD_BACKEND
7+
from pcweb.constants import REFLEX_BUILD_URL, RX_BUILD_BACKEND, MAX_FILE_SIZE_MB, MAX_FILE_SIZE_BYTES, MAX_IMAGES_COUNT, PROMPT_MAP
88
from reflex.experimental import ClientStateVar
99
from typing import TypedDict
1010

1111
textarea_x_pos = ClientStateVar.create(var_name="textarea_x_pos", default=0)
1212
textarea_y_pos = ClientStateVar.create(var_name="textarea_y_pos", default=0)
1313
textarea_opacity = ClientStateVar.create(var_name="textarea_opacity", default=0)
1414

15-
MAX_FILE_SIZE_MB = 5
16-
MAX_FILE_SIZE_BYTES = MAX_FILE_SIZE_MB * 1024 * 1024
17-
MAX_IMAGES_COUNT = 5
18-
prompt_map = {
19-
"Use an Image": "Build an app from a reference image",
20-
"Chat App": "A chat app hooked up to an LLM",
21-
"Live Dashboard": "Live stream data on a real-time dashboard",
22-
}
15+
2316

2417

2518
class ImageData(TypedDict):
@@ -40,7 +33,7 @@ async def redirect_to_ai_builder(self, form_data: dict):
4033
response = await client.post(
4134
RX_BUILD_BACKEND.rstrip("/") + "/prompt",
4235
json={
43-
"prompt": prompt_map.get(prompt, prompt),
36+
"prompt": PROMPT_MAP.get(prompt, prompt),
4437
"token": str(random_uuid),
4538
"images": self.image_data_uris,
4639
},

pcweb/pages/pricing/table.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from pcweb.components.button import button
33
from pcweb.constants import REFLEX_DEV_WEB_LANDING_FORM_URL_GET_DEMO
44

5-
# Constants for styling
65
STYLES = {
76
"cell": "text-slate-12 font-medium text-sm whitespace-nowrap",
87
"header_cell": "text-slate-12 font-semibold text-lg",

0 commit comments

Comments
 (0)