-
Notifications
You must be signed in to change notification settings - Fork 1.7k
use images from integration docs package instead of github #6435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
packages/reflex-site-shared/src/reflex_site_shared/integrations.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| """Helpers for resolving integration logo asset URLs from the local integrations_docs package.""" | ||
|
|
||
| from pathlib import Path | ||
| from typing import Literal | ||
|
|
||
| import integrations_docs | ||
| from reflex_base import constants | ||
| from reflex_base.config import get_config | ||
| from reflex_base.environment import EnvironmentVariables | ||
| from reflex_base.utils.decorator import once | ||
|
|
||
|
|
||
| @once | ||
| def _integrations_logos_url() -> str: | ||
| """Symlink the integrations_docs logos into assets/external and return the public URL. | ||
|
|
||
| Returns: | ||
| The public frontend URL prefix for the integrations_docs logos directory. | ||
|
|
||
| Raises: | ||
| RuntimeError: If the integrations_docs logos directory cannot be found. | ||
| """ | ||
| src = Path(integrations_docs.__file__).parent / "images" / "logos" | ||
| if not src.is_dir(): | ||
| msg = f"integrations_docs logos directory not found at {src}" | ||
| raise RuntimeError(msg) | ||
| relative_path = f"/{constants.Dirs.EXTERNAL_APP_ASSETS}/integrations_docs/logos/" | ||
| if not EnvironmentVariables.REFLEX_BACKEND_ONLY.get(): | ||
| dst = ( | ||
| Path.cwd() | ||
| / constants.Dirs.APP_ASSETS | ||
| / constants.Dirs.EXTERNAL_APP_ASSETS | ||
| / "integrations_docs" | ||
| / "logos" | ||
| ) | ||
| dst.parent.mkdir(parents=True, exist_ok=True) | ||
| if not dst.is_symlink() or dst.resolve() != src.resolve(): | ||
| if dst.is_symlink() or dst.exists(): | ||
| dst.unlink() | ||
| dst.symlink_to(src) | ||
| return get_config().prepend_frontend_path(relative_path) | ||
|
|
||
|
|
||
| def format_integration_name(integration_name: str) -> str: | ||
| """Normalize an integration name into the slug used by its logo filename. | ||
|
|
||
| Args: | ||
| integration_name: The human-readable integration name. | ||
|
|
||
| Returns: | ||
| The lowercase, underscore-separated slug. | ||
| """ | ||
| return integration_name.lower().replace(" ", "_") | ||
|
|
||
|
|
||
| def get_integration_logo_url( | ||
| integration_name: str, theme: Literal["light", "dark"] | ||
| ) -> str: | ||
| """Build the public URL for an integration logo SVG. | ||
|
|
||
| Args: | ||
| integration_name: The human-readable integration name. | ||
| theme: The color theme variant to load. | ||
|
|
||
| Returns: | ||
| The public URL for the SVG logo. | ||
| """ | ||
| return f"{_integrations_logos_url()}{theme}/{format_integration_name(integration_name)}.svg" | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.