Skip to content

Commit c78c8f1

Browse files
fix: Make outside users able to read tmp files (#2070)
Co-authored-by: Carson Sievert <[email protected]>
1 parent 5bd00b6 commit c78c8f1

File tree

11 files changed

+63
-2
lines changed

11 files changed

+63
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7171

7272
* `include_js()` and `include_css()` now work as expected when trying to include multiple files from the same directory. (#2069)
7373

74+
* `include_js()` and `include_css()` now correctly handle file permissions in multi-user settings. (#2061)
75+
7476
### Deprecations
7577

7678
* `ui.update_navs()` has been deprecated in favor of `ui.update_navset()`. (#2047)

shiny/ui/_include_helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,11 @@ def maybe_copy_files(path: Path | str, include_files: bool) -> tuple[str, str]:
217217

218218
# To avoid unnecessary work when the same file is included multiple times,
219219
# use a directory scoped by a hash of the file.
220-
tmpdir = os.path.join(tempfile.gettempdir(), "shiny_include_files", hash)
220+
tmpdir = os.path.join(tempfile.gettempdir(), f"shiny_include_{hash}")
221221
path_dest = os.path.join(tmpdir, os.path.basename(path))
222222

223223
# Since the hash/tmpdir should represent all the files in the path's directory,
224-
# we can simply return here
224+
# we can check if it exists to determine if we have a cache hit
225225
if os.path.exists(path_dest):
226226
return path_dest, hash
227227

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from pathlib import Path
2+
3+
from shiny import App, Inputs, Outputs, Session, ui
4+
5+
js_file = Path(__file__).parent / "customjs.js"
6+
css_file = Path(__file__).parent / "style.css"
7+
8+
# Define the UI
9+
app_ui = ui.page_fluid(
10+
ui.include_css(css_file, method="link"),
11+
ui.include_js(js_file, method="link"),
12+
ui.h1("Simple Shiny App with External CSS"),
13+
ui.div(
14+
ui.p("This is a simple Shiny app that demonstrates ui.include_css()"),
15+
ui.p("The styling comes from an external CSS file!"),
16+
class_="content",
17+
),
18+
)
19+
20+
21+
# Define the server
22+
def server(input: Inputs, output: Outputs, session: Session):
23+
pass
24+
25+
26+
# Create and run the app
27+
app = App(app_ui, server)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const newParagraph = document.createElement('p');
2+
newParagraph.textContent = 'Heyo!';
3+
document.body.appendChild(newParagraph);
4+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
body {
2+
background-color: #70bfef;
3+
font-family: Arial, sans-serif;
4+
}
5+
6+
h1 {
7+
color: black;
8+
border-bottom: 2px solid #4682b4;
9+
padding-bottom: 10px;
10+
}
11+
12+
.content {
13+
margin: 20px;
14+
padding: 15px;
15+
background-color: white;
16+
border-radius: 5px;
17+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
18+
}
19+

0 commit comments

Comments
 (0)