mirror of
https://tangled.org/evan.jarrett.net/at-container-registry
synced 2026-09-20 09:14:16 +00:00
fix url rendering in ui
This commit is contained in:
@@ -421,7 +421,7 @@ func initializeUI(config *configuration.Configuration, oauthApp *oauth.App, refr
|
||||
&uihandlers.HomeHandler{
|
||||
DB: database,
|
||||
Templates: templates,
|
||||
RegistryURL: baseURL,
|
||||
RegistryURL: uihandlers.TrimRegistryURL(baseURL),
|
||||
},
|
||||
)).Methods("GET")
|
||||
|
||||
@@ -429,7 +429,7 @@ func initializeUI(config *configuration.Configuration, oauthApp *oauth.App, refr
|
||||
&uihandlers.RecentPushesHandler{
|
||||
DB: database,
|
||||
Templates: templates,
|
||||
RegistryURL: baseURL,
|
||||
RegistryURL: uihandlers.TrimRegistryURL(baseURL),
|
||||
},
|
||||
)).Methods("GET")
|
||||
|
||||
@@ -440,13 +440,13 @@ func initializeUI(config *configuration.Configuration, oauthApp *oauth.App, refr
|
||||
authRouter.Handle("/images", &uihandlers.ImagesHandler{
|
||||
DB: database,
|
||||
Templates: templates,
|
||||
RegistryURL: baseURL,
|
||||
RegistryURL: uihandlers.TrimRegistryURL(baseURL),
|
||||
}).Methods("GET")
|
||||
|
||||
authRouter.Handle("/settings", &uihandlers.SettingsHandler{
|
||||
Templates: templates,
|
||||
Refresher: refresher,
|
||||
RegistryURL: baseURL,
|
||||
RegistryURL: uihandlers.TrimRegistryURL(baseURL),
|
||||
}).Methods("GET")
|
||||
|
||||
authRouter.Handle("/api/profile/default-hold", &uihandlers.UpdateDefaultHoldHandler{
|
||||
|
||||
@@ -71,7 +71,7 @@ func Templates() (*template.Template, error) {
|
||||
return string([]rune(s)[0])
|
||||
},
|
||||
|
||||
"trimPrefix": func(s, prefix string) string {
|
||||
"trimPrefix": func(prefix, s string) string {
|
||||
if len(s) >= len(prefix) && s[:len(prefix)] == prefix {
|
||||
return s[len(prefix):]
|
||||
}
|
||||
|
||||
@@ -59,12 +59,10 @@ func (h *SettingsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
PDSEndpoint string
|
||||
DefaultHold string
|
||||
}
|
||||
SessionExpiry time.Time
|
||||
Query string
|
||||
RegistryURL string
|
||||
}{
|
||||
User: user,
|
||||
SessionExpiry: time.Now().Add(24 * time.Hour), // TODO: Get from actual session
|
||||
Query: r.URL.Query().Get("q"),
|
||||
RegistryURL: h.RegistryURL,
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package handlers
|
||||
|
||||
import "strings"
|
||||
|
||||
// TrimRegistryURL removes http:// or https:// prefix from a URL
|
||||
// for use in Docker commands where only the host:port is needed
|
||||
func TrimRegistryURL(url string) string {
|
||||
url = strings.TrimPrefix(url, "https://")
|
||||
url = strings.TrimPrefix(url, "http://")
|
||||
return url
|
||||
}
|
||||
@@ -73,19 +73,19 @@
|
||||
<li>Configure Docker to use the helper. Add to <code>~/.docker/config.json</code>:
|
||||
<pre><code>{
|
||||
"credHelpers": {
|
||||
"{{ .RegistryURL | trimPrefix "http://" | trimPrefix "https://" }}": "atcr"
|
||||
"{{ .RegistryURL }}": "atcr"
|
||||
}
|
||||
}</code></pre>
|
||||
</li>
|
||||
<li>Run any Docker command:
|
||||
<pre><code>docker pull {{ .RegistryURL | trimPrefix "http://" | trimPrefix "https://" }}/{{ .Profile.Handle }}/myimage</code></pre>
|
||||
<pre><code>docker pull {{ .RegistryURL }}/{{ .Profile.Handle }}/myimage</code></pre>
|
||||
</li>
|
||||
<li>Browser will open for authorization - click Approve</li>
|
||||
<li>Done! Device is automatically authorized</li>
|
||||
</ol>
|
||||
|
||||
<div class="fallback-note">
|
||||
<strong>Fallback:</strong> Use app-password with <code>docker login {{ .RegistryURL | trimPrefix "http://" | trimPrefix "https://" }}</code> for quick start (no device tracking)
|
||||
<strong>Fallback:</strong> Use app-password with <code>docker login {{ .RegistryURL }}</code> for quick start (no device tracking)
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -108,22 +108,6 @@
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- OAuth Session Section -->
|
||||
<section class="settings-section">
|
||||
<h2>OAuth Session</h2>
|
||||
<div class="form-group">
|
||||
<label>Logged in as:</label>
|
||||
<span>{{ .Profile.Handle }}</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Session expires:</label>
|
||||
<time datetime="{{ .SessionExpiry.Format "2006-01-02T15:04:05Z07:00" }}">
|
||||
{{ .SessionExpiry.Format "2006-01-02 15:04:05 MST" }}
|
||||
</time>
|
||||
</div>
|
||||
<a href="/auth/oauth/login?return_to=/settings" class="btn-secondary">Re-authenticate</a>
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user