@@ -1,6 +1,9 @@
1package pagewriter
1package pagewriter
4+ // Import embed to allow importing default page templates
5 "html/template"
8 "html/template"
@@ -13,198 +16,13 @@ import (
14 errorTemplateName = "error.html"
17 errorTemplateName = "error.html"
15 signInTemplateName = "sign_in.html"
18 signInTemplateName = "sign_in.html"
17− defaultErrorTemplate = `{{define "error.html"}}
22+var defaultErrorTemplate string
19−<html lang="en" charset="utf-8">
21− <meta charset="utf-8">
22− <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
23− <title>{{.StatusCode}} {{.Title}}</title>
24− <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.1/css/bulma.min.css">
25− <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css">
27− <script type="text/javascript">
28− document.addEventListener('DOMContentLoaded', function() {
29− let cardToggles = document.getElementsByClassName('card-toggle');
30− for (let i = 0; i < cardToggles.length; i++) {
31− cardToggles[i].addEventListener('click', e => {
32− e.currentTarget.parentElement.parentElement.childNodes[3].classList.toggle('is-hidden');
43− margin: 1.25rem auto;
51− border: 1px solid #f0f0f0;
54− text-decoration: underline;
58−<body class="has-background-light">
59− <section class="section">
60− <div class="box block error-box has-text-centered">
61− <div class="status-code">{{.StatusCode}}</div>
63− <h1 class="subtitle is-1">{{.Title}}</h1>
67− <div id="more-info" class="block card is-fullwidth is-shadowless">
68− <header class="card-header is-shadowless">
69− <p class="card-header-title">More Info</p>
70− <a class="card-header-icon card-toggle">
71− <i class="fa fa-angle-down"></i>
74− <div class="card-content has-text-left is-hidden">
75− <div class="content">
85− <div class="columns">
87− <form method="GET" action="{{.Redirect}}">
88− <button type="submit" class="button is-danger is-fullwidth">Go back</button>
92− <form method="GET" action="{{.ProxyPrefix}}/sign_in">
93− <input type="hidden" name="rd" value="{{.Redirect}}">
94− <button type="submit" class="button is-primary is-fullwidth">Sign in</button>
103− <footer class="footer has-text-grey has-background-light is-size-7">
104− <div class="content has-text-centered">
105− {{ if eq .Footer "-" }}
106− {{ else if eq .Footer ""}}
107− <p>Secured with <a href="https://github.com/oauth2-proxy/oauth2-proxy#oauth2_proxy" class="has-text-grey">OAuth2 Proxy</a> version {{.Version}}</p>
118− defaultSignInTemplate = `{{define "sign_in.html"}}
120−<html lang="en" charset="utf-8">
122− <meta charset="utf-8">
123− <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
124− <title>Sign In</title>
125− <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.1/css/bulma.min.css">
133− margin: 1.25rem auto;
136− text-decoration: underline;
141− if (window.location.hash) {
143− var inputs = document.getElementsByName('rd');
144− for (var i = 0; i < inputs.length; i++) {
145− // Add hash, but make sure it is only added once
146− var idx = inputs[i].value.indexOf('#');
148− // Remove existing hash from URL
149− inputs[i].value = inputs[i].value.substr(0, idx);
151− inputs[i].value += window.location.hash;
157− <body class="has-background-light">
158− <section class="section">
159− <div class="box block sign-in-box has-text-centered">
160− <form method="GET" action="{{.ProxyPrefix}}/start">
161− <input type="hidden" name="rd" value="{{.Redirect}}">
162− {{ if .SignInMessage }}
163− <p class="block">{{.SignInMessage}}</p>
165− <button type="submit" class="button block is-primary">Sign in with {{.ProviderName}}</button>
168− {{ if .CustomLogin }}
171− <form method="POST" action="{{.ProxyPrefix}}/sign_in" class="block">
172− <input type="hidden" name="rd" value="{{.Redirect}}">
175− <label class="label" for="username">Username</label>
176− <div class="control">
177− <input class="input" type="email" placeholder="e.g. userx@example.com" name="username" id="username">
182− <label class="label" for="password">Password</label>
183− <div class="control">
184− <input class="input" type="password" placeholder="********" name="password" id="password">
187− <button class="button is-primary">Sign in</button>
193− <footer class="footer has-text-grey has-background-light is-size-7">
194− <div class="content has-text-centered">
195− {{ if eq .Footer "-" }}
196− {{ else if eq .Footer ""}}
197− <p>Secured with <a href="https://github.com/oauth2-proxy/oauth2-proxy#oauth2_proxy" class="has-text-grey">OAuth2 Proxy</a> version {{.Version}}</p>
204− </body>
24+//go:embed sign_in.html
205−</html>
25+var defaultSignInTemplate string
209// loadTemplates adds the Sign In and Error templates from the custom template
27// loadTemplates adds the Sign In and Error templates from the custom template
210// directory, or uses the defaults if they do not exist or the custom directory
28// directory, or uses the defaults if they do not exist or the custom directory