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

docs: Update docs with preferred way of displaying documents #2291 #2311

Merged
merged 3 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/examples/sample-document.pdf
Binary file not shown.
11 changes: 11 additions & 0 deletions website/docs/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@ async def serve(q: Q):

See `examples/file_stream.py` for a complete example.

## Rendering documents

Use `q.site.upload()` to upload document from your app to the Wave server (or see the following section for other ways for serving files). Use the returned paths in `ui.frame()` component.

```py
q.app.document_path, = await q.site.upload(['path/to/my/document.pdf'])
q.page['example'] = ui.form_card(box='1 1 7 7', items=[
ui.frame(path=document_path)
])
```

## Serving files directly from the Wave server

As an alternative to using the above `upload()` or `download()` mechanisms, you can make the Wave server (`waved`) directly serve the contents of one or more existing directories. If the Wave server and your app both have access to the directories on the file system, your app can simply create or copy files to the directories to make them accessible from web browsers.
Expand Down
10 changes: 10 additions & 0 deletions website/widgets/form/frame.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ q.page['example'] = ui.form_card(box='1 1 7 7', items=[
])
```

## With document

The frame is also a preffered way for displaying documents. Simply provide a path to the PDF file.

```py
q.page['example'] = ui.form_card(box='1 1 7 7', items=[
ui.frame(path='/assets/examples/sample-document.pdf')
])
```

## With custom HTML

For cases when you want to build the embedded page yourself, you can use the `content` attribute that
Expand Down
Loading