Skip to content
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

Add support of initializing the extension on a Blueprint #25

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

AlexJMohr
Copy link

@AlexJMohr AlexJMohr commented Nov 22, 2024

Closes #24

Adds support for initializing the extension on a Blueprint.

Work in progress, wanted to get your input on a few things.

Adds support for initializing the extension on a `Blueprint`.
flask_inertia/inertia.py Outdated Show resolved Hide resolved
flask_inertia/inertia.py Outdated Show resolved Hide resolved
flask_inertia/inertia.py Outdated Show resolved Hide resolved
flask_inertia/inertia.py Outdated Show resolved Hide resolved
tests/python/test_blueprint.py Outdated Show resolved Hide resolved
flask_inertia/inertia.py Show resolved Hide resolved
flask_inertia/inertia.py Outdated Show resolved Hide resolved
@CoultonF
Copy link

I tested out this change on a blueprint, and one thing to consider is that the template folder of a blueprint may not be tied to the current app template folder. In version.py this code should be changed to accommodate the blueprint as well.

def get_asset_version() -> str:
    """Calculate asset version to allow Inertia to automatically make a full page visit in case of changes."""
    template_path = os.path.join(
        current_app.root_path,
        current_app.template_folder,
        current_app.config["INERTIA_TEMPLATE"],
    )
return hashlib.sha256(bytes_content).hexdigest()

@AlexJMohr
Copy link
Author

I tested out this change on a blueprint, and one thing to consider is that the template folder of a blueprint may not be tied to the current app template folder. In version.py this code should be changed to accommodate the blueprint as well.

def get_asset_version() -> str:
    """Calculate asset version to allow Inertia to automatically make a full page visit in case of changes."""
    template_path = os.path.join(
        current_app.root_path,
        current_app.template_folder,
        current_app.config["INERTIA_TEMPLATE"],
    )
return hashlib.sha256(bytes_content).hexdigest()

Addressed in 85c6165 but it's untested (blocked by #26)

@AlexJMohr AlexJMohr requested a review from j0ack January 13, 2025 20:01
Copy link
Owner

@j0ack j0ack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes seems good to me.

Could you also add a dedicated paragraph in the documentation adding the new feature (index.rst -> Configuration) and in the README ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incremental Adoption Support
3 participants