Skip to content

Commit

Permalink
Add RootURL to site template paths and APIs.
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Nov 12, 2023
1 parent a06998c commit 8f214a0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
3 changes: 2 additions & 1 deletion admin/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="{{ .Consts.RootURL }}/admin/static/grid.css?v={{ .AssetVer }}">
<link rel="stylesheet" type="text/css" href="{{ .Consts.RootURL }}/admin/static/style.css?v={{ .AssetVer }}">

<link rel="shortcut icon" href="{{ .Consts.RootURL }}/admin/static/favicon.png?v={{ .AssetVer }}" type="image/x-icon" />

<script>window._ROOT_URL = "{{ .Consts.RootURL }}";</script>
<script defer src="{{ .Consts.RootURL }}/admin/static/main.js?v={{ .AssetVer }}"></script>
<script defer src="{{ .Consts.RootURL }}/admin/static/alpine.js?v={{ .AssetVer }}"></script>
</head>
Expand Down
18 changes: 9 additions & 9 deletions site/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />

<link rel="shortcut icon" href="/static/favicon.png?v={{ .AssetVer }}" type="image/x-icon" />
<link href="/static/flexit.css?v={{ .AssetVer }}" rel="stylesheet" type="text/css" />
<link href="/static/style.css?v={{ .AssetVer }}" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="{{ .Consts.RootURL }}/static/favicon.png?v={{ .AssetVer }}" type="image/x-icon" />
<link href="{{ .Consts.RootURL }}/static/flexit.css?v={{ .AssetVer }}" rel="stylesheet" type="text/css" />
<link href="{{ .Consts.RootURL }}/static/style.css?v={{ .AssetVer }}" rel="stylesheet" type="text/css" />
</head>
<body class="{{ if eq .Data.PageName "/"}}home{{ end }}">
<div class="container wrap box">
<header class="header">
<div class="row">
<div class="logo four columns">
<a href="/"><img src="/static/logo.svg?v={{ .AssetVer }}" alt="Dictionary logo" /></a>
<a href="{{ .Consts.RootURL }}"><img src="{{ .Consts.RootURL }}/static/logo.svg?v={{ .AssetVer }}" alt="Dictionary logo" /></a>
<h3 class="intro">
{{- .L.T "public.subTitle" -}}
</h3>
Expand All @@ -46,11 +46,11 @@ <h3 class="intro">
</a>
{{ end }}
</div>
<form class="search-form" method="get" action="/dictionary/english/malayalam">
<form class="search-form" method="get" action="{{ .Consts.RootURL }}/dictionary/english/malayalam">
<div>
<input autofocus autocomplete="off" required placeholder=""
type="text" id="q" name="q" value="{{ if .Data.Query }}{{ .Data.Query.Query }}{{ end }}" />
<button type="submit"><img src="/static/search.svg" alt="{{- .L.T "public.btnSearch" -}}" /></button>
<button type="submit"><img src="{{ .Consts.RootURL }}/static/search.svg" alt="{{- .L.T "public.btnSearch" -}}" /></button>
</div>
</form>
</div>
Expand All @@ -61,13 +61,13 @@ <h3 class="intro">
{{ define "footer" }}
<nav class="nav">
{{ if .Consts.EnableSubmissions }}
<a href="/submit">{{- .L.T "public.submitEntry" -}}</a>
<a href="{{ $.Consts.RootURL }}/submit">{{- .L.T "public.submitEntry" -}}</a>
{{ end }}
{{ if .Consts.EnableGlossary }}
{{ range $d := .Dicts }}
{{ $from := index $d 0}}
{{ $to := index $d 1}}
<a href="/glossary/{{ $from.ID }}/{{ $to.ID }}/*" class="tab">
<a href="{{ $.Consts.RootURL }}/glossary/{{ $from.ID }}/{{ $to.ID }}/*" class="tab">
{{ $.L.Ts "public.glossary" "lang" $from.Name }}
</a>
{{ end }}
Expand All @@ -77,7 +77,7 @@ <h3 class="intro">
<footer class="footer">
<a href="https://dict.press">Powered by dictpress</a>
</footer>
<script src="/static/main.js?v={{ .AssetVer }}"></script>
<script src="{{ .Consts.RootURL }}/static/main.js?v={{ .AssetVer }}"></script>

<form class="box form-comments" data-success="{{ .L.T "public.suggestSubmitted" }}">
<div>
Expand Down
2 changes: 1 addition & 1 deletion site/glossary-words.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h2>{{ $.L.T "public.noResultsTitle" }}</h2>
{{ else }}
<ul class="noul words">
{{ range $i, $w := $g.Words }}
<li><a href="/dictionary/{{ UnicodeURL $g.FromLang }}/{{ UnicodeURL $g.ToLang }}/{{ UnicodeURL $w.Content }}">{{ $w.Content }}</a></li>
<li><a href="{{ .Consts.RootURL }}/dictionary/{{ UnicodeURL $g.FromLang }}/{{ UnicodeURL $g.ToLang }}/{{ UnicodeURL $w.Content }}">{{ $w.Content }}</a></li>
{{ end }}
</ul>
{{ end }}
Expand Down
2 changes: 1 addition & 1 deletion site/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function search(q) {

// Handle form submission.
form.onsubmit = () => {
fetch("/api/submissions/comments", {
fetch(`${window._ROOT_URL}/api/submissions/comments`, {
method: "POST",
headers: {
"Content-Type": "application/json"
Expand Down

0 comments on commit 8f214a0

Please sign in to comment.