<commit_before>package multipass

import "html/template"

const (
	loginPage = iota
	tokenInvalidPage
	tokenSentPage
	continueOrSignoutPage
)

type page struct {
	PJAX        bool
	Page        int
	NextURL     string
	LoginPath   string
	SignoutPath string
}

func loadTemplates() (*template.Template, error) {
	tmpl := template.New("")
	template.Must(tmpl.New("head").Parse(`<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="description" content="Multipass">
	<title>Multipass</title>
	<style>{{ template "style" }}</style>
</head>
<body>`))

	template.Must(tmpl.New("tail").Parse(`</body></html>`))

	template.Must(tmpl.New("loginform").Parse(`
<form action="{{ .LoginPath }}" method=POST class="login-form">
	<input type=hidden name=url value="{{ .NextURL }}" />
	<input type=text name=handle placeholder="Your handle ..." />
	<input type=submit value="Submit" class="btn btn-default">
</form>`))

	template.Must(tmpl.New("signoutform").Parse(`
<form action="{{ .SignoutPath }}" method=POST class="login-form">
	<input type=hidden name=url value="{{ .NextURL }}" />
	<input type=submit value="Signout" class="btn btn-danger">
</form>`))

	template.Must(tmpl.New("page").Parse(`
	{{ if ne .PJAX true }}{{ template "head"}}{{end}}
<div class="wrapper">
	<section>
		<article class="login-box">
			<h1>Multipass</h1>
		{{ if eq .Page 0 }}
			{{ template "loginform" . }}
			<p class="notice">This resource is protected. Submit your handle to gain access.</p>
		{{ else if eq .Page 1 }}
			<p class="notice">Your access token has expired or is invalid. Submit your handle to request a one.</p>
			{{ template "loginform" . }}
			<p class="notice">This resource is protected.</p>
		{{ else if eq .Page 2 }}
			<p>A message with an access token was sent to your handle; Follow the login link in the message to gain access.</p>
		{{ else if eq .Page 3 }}
			<p class="notice">Continue to access the private resource or signout.</p>
			<a href="{{ .NextURL }}" class="btn btn-success">Continue</a>
			{{ template "signoutform" . }}
			<p class="notice">This resource is protected.</p>
		{{ else }}
			<p>Default page</p>
		{{ end }}
		</article>
	</section>
</div>
{{ if ne .PJAX true }}{{ template "tail" }}{{ end }}`))

	template.Must(tmpl.New("style").Parse(`
* {
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	box-sizing: border-box;
}
article, aside, details, figcaption, figure, footer, header, hgroup,
main, nav, section, summary {
	display: block;
}
body {
	margin: 0;
}
.wrapper {
	display: -webkit-flex;
	-webkit-flex-direction: column;
}
.login-box {
	width: 480px;
	margin: 4rem auto;
	text-align: center;
	padding: 1rem 0;
	border: solid .16rem #0d8eba;
	border-radius: .8rem;
	padding: 1rem 2rem;
	background-color: #fff;
}
.login-box h1 {
	font-family: sans-serif;
	font-size: 3rem;
	color: #444;
}
.login-form {
}
.login-form input {
}
.login-form input[type=text] {
	font-size: 1.2rem;
	padding: 0 1rem;
	border-color: #ddd;
	color: #444;
	margin: .6rem 0;
	width: 100%;
	height: 2.8rem;
	border-radius: .4rem;
	border-style: solid;
	border-width: .16rem;
}
.login-form input[type=submit] {
}
.btn {
	font-family: sans-serif;
	font-size: 1.2rem;
	margin: 1rem 0;
	padding: .5rem 1rem;
	width: 100%;
	height: 2.8rem;
	border-radius: .4rem;
	border-style: solid;
	border-width: .16rem;
	text-transform: uppercase;
	color: #fff;
	height: 3rem;
	cursor: pointer;
}
a.btn {
	text-decoration: none;<commit_msg>Fix text alignment on HTML buttons<commit_after>package multipass

import "html/template"

const (
	loginPage = iota
	tokenInvalidPage
	tokenSentPage
	continueOrSignoutPage
)

type page struct {
	PJAX        bool
	Page        int
	NextURL     string
	LoginPath   string
	SignoutPath string
}

func loadTemplates() (*template.Template, error) {
	tmpl := template.New("")
	template.Must(tmpl.New("head").Parse(`<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="description" content="Multipass">
	<title>Multipass</title>
	<style>{{ template "style" }}</style>
</head>
<body>`))

	template.Must(tmpl.New("tail").Parse(`</body></html>`))

	template.Must(tmpl.New("loginform").Parse(`
<form action="{{ .LoginPath }}" method=POST class="login-form">
	<input type=hidden name=url value="{{ .NextURL }}" />
	<input type=text name=handle placeholder="Your handle ..." />
	<input type=submit value="Submit" class="btn btn-default">
</form>`))

	template.Must(tmpl.New("signoutform").Parse(`
<form action="{{ .SignoutPath }}" method=POST class="login-form">
	<input type=hidden name=url value="{{ .NextURL }}" />
	<input type=submit value="Signout" class="btn btn-danger">
</form>`))

	template.Must(tmpl.New("page").Parse(`
	{{ if ne .PJAX true }}{{ template "head"}}{{end}}
<div class="wrapper">
	<section>
		<article class="login-box">
			<h1>Multipass</h1>
		{{ if eq .Page 0 }}
			{{ template "loginform" . }}
			<p class="notice">This resource is protected. Submit your handle to gain access.</p>
		{{ else if eq .Page 1 }}
			<p class="notice">Your access token has expired or is invalid. Submit your handle to request a one.</p>
			{{ template "loginform" . }}
			<p class="notice">This resource is protected.</p>
		{{ else if eq .Page 2 }}
			<p>A message with an access token was sent to your handle; Follow the login link in the message to gain access.</p>
		{{ else if eq .Page 3 }}
			<p class="notice">Continue to access the private resource or signout.</p>
			<a href="{{ .NextURL }}" class="btn btn-success">Continue</a>
			{{ template "signoutform" . }}
			<p class="notice">This resource is protected.</p>
		{{ else }}
			<p>Default page</p>
		{{ end }}
		</article>
	</section>
</div>
{{ if ne .PJAX true }}{{ template "tail" }}{{ end }}`))

	template.Must(tmpl.New("style").Parse(`
* {
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	box-sizing: border-box;
}
article, aside, details, figcaption, figure, footer, header, hgroup,
main, nav, section, summary {
	display: block;
}
body {
	margin: 0;
}
.wrapper {
	display: -webkit-flex;
	-webkit-flex-direction: column;
}
.login-box {
	width: 480px;
	margin: 4rem auto;
	text-align: center;
	padding: 1rem 0;
	border: solid .16rem #0d8eba;
	border-radius: .8rem;
	padding: 1rem 2rem;
	background-color: #fff;
}
.login-box h1 {
	font-family: sans-serif;
	font-size: 3rem;
	color: #444;
}
.login-form {
}
.login-form input {
}
.login-form input[type=text] {
	font-size: 1.2rem;
	padding: 0 1rem;
	border-color: #ddd;
	color: #444;
	margin: .6rem 0;
	width: 100%;
	height: 2.8rem;
	border-radius: .4rem;
	border-style: solid;
	border-width: .16rem;
}
.login-form input[type=submit] {
}
.btn {
	font-family: sans-serif;
	font-size: 1.2rem;
	line-height: 2rem;
	margin: 1rem 0;
	padding: .5rem 1rem;
	width: 100%;
	height: 2.8rem;
	border-radius: .4rem;
	border-style: solid;
	border-width: .16rem;
	text-transform: uppercase;
	color: #fff;
	height: 3rem;
	cursor: pointer;
}
a.btn {
	text-decoration: none;
{'fraction_non_alphanumeric': 0.17850453825097248, 'fraction_numerical': 0.01685636075493445, 'mean_word_length': 4.0524017467248905, 'pattern_counts': {'":': 0, '<': 95, '<?xml version=': 0, '>': 95, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5848236', 'n_tokens_mistral': 2712, 'n_tokens_neox': 2515, 'n_words': 664}