Skip to content

Commit

Permalink
♻️(back) render public site with vite keyword
Browse files Browse the repository at this point in the history
The vite framework is escaping the variable used in a django template.
Instead of using django template, we are doing a replace using a regex
on a specfic keyword
  • Loading branch information
lunika authored and AntoLC committed Dec 21, 2023
1 parent a7fae28 commit 5dc12c9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

<head>
<meta charset="utf-8" />
<link rel="icon" href="{{ static_base_url }}favicon.ico" />
<meta name="public-path" value="{{ static_base_url }}" />
<link rel="icon" href="/__static_base_url__/favicon.ico" />
<meta name="public-path" value="/__static_base_url__/" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Web site created using create-react-app" />
<link rel="apple-touch-icon" href="{{ static_base_url }}logo192.png" />
<link rel="manifest" href="{{ static_base_url }}manifest.json" />
<link rel="apple-touch-icon" href="/__static_base_url__/logo192.png" />
<link rel="manifest" href="/__static_base_url__/manifest.json" />
<title>React App</title>
<script defer="defer" src="/static/js/main.4b7d1848.js"></script>
<link href="/static/css/main.18b5b4a5.css" rel="stylesheet">
Expand Down
11 changes: 2 additions & 9 deletions src/backend/marsha/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,19 +200,12 @@ def get(self, request, *args, **kwargs):
content = re.sub(
r"/(static/css/main\..*\.css)", rf"{static_base_url}\1", content
)
content = re.sub(r"/__static_base_url__/", static_base_url, content)

engine = Engine.get_default()
template = engine.from_string(content)

return HttpResponse(
template.render(
Context(
{
"static_base_url": static_base_url,
}
)
)
)
return HttpResponse(template.render(Context()))
except FileNotFoundError:
logger.exception("Production build of app not found")
return HttpResponse(
Expand Down

0 comments on commit 5dc12c9

Please sign in to comment.