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

Show all file content in iframes #172

Merged
merged 5 commits into from
Mar 18, 2024
Merged

Conversation

bloodearnest
Copy link
Member

@bloodearnest bloodearnest commented Mar 15, 2024

Fixes #142

This means changing the contents url for files to render csv/txt files
as html, and just serve up other files.

Also, I split the download parts of serve_file into its own function, as
serve_file is more complex, and the caching logic doesn't apply to
downloads.

Changed some test assertions to assert that the url to the content is
present, rather than the content itself.
This means we will return 304s if the file contents have not changed,
which means the browser cache will be used, and we don't need to render
the content. For larger files, especially csv or text, this avoids a lot
of work.

For content that we render (text and csv atm), the etag is a bit more
involved. We want the etag value to capture both the original file and
the template file that was used. This is so that if either changes, the
cache is invalid and the new content is served.

To do this, I added a micro rendering framework that ties the templating
together with the rendering, so that we can inspect the template and
check *before* doing the potentially expensive rendering.
This helps view larger files in detail
tests/integration/views/test_helpers.py Outdated Show resolved Hide resolved
tests/integration/views/test_helpers.py Outdated Show resolved Hide resolved

return wrapper

return decorator
Copy link
Contributor

Choose a reason for hiding this comment

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

Neat

@bloodearnest bloodearnest merged commit 39a8304 into main Mar 18, 2024
8 checks passed
@bloodearnest bloodearnest deleted the all-file-content-as-urls branch March 18, 2024 11:07
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.

Lazily load csv and text file content from direct url.
2 participants