{{template "repo/settings/layout_head" (dict "ctxData" . "pageClass" "repository settings pages")}}
	<div class="user-main-content twelve wide column">
		<h4 class="ui top attached header">
			{{ctx.Locale.Tr "repo.settings.pages"}}
		</h4>
		<div class="ui attached segment">
			{{if .PagesEnabled}}
				<div class="ui positive message">
					<div class="header">{{ctx.Locale.Tr "repo.settings.pages.enabled"}}</div>
					<p>{{ctx.Locale.Tr "repo.settings.pages.enabled_desc"}}</p>
					<p><strong>{{ctx.Locale.Tr "repo.settings.pages.subdomain"}}:</strong> <a href="{{.PagesURL}}" target="_blank" rel="noopener noreferrer">{{.PagesURL}}</a></p>
				</div>

				<form class="ui form" method="post">
					<input type="hidden" name="action" value="update_template">
					<div class="field">
						<label>{{ctx.Locale.Tr "repo.settings.pages.template"}}</label>
						<select name="template" class="ui dropdown">
							{{range .PagesTemplates}}
							<option value="{{.}}" {{if eq $.PagesTemplate .}}selected{{end}}>{{.}}</option>
							{{end}}
						</select>
					</div>
					<div class="field">
						<button class="ui primary button">{{ctx.Locale.Tr "repo.settings.pages.update_template"}}</button>
					</div>
				</form>

				<div class="divider"></div>

				<form class="ui form" method="post">
					<input type="hidden" name="action" value="disable">
					<button class="ui red button">{{ctx.Locale.Tr "repo.settings.pages.disable"}}</button>
				</form>
			{{else}}
				<div class="ui info message">
					<div class="header">{{ctx.Locale.Tr "repo.settings.pages.not_enabled"}}</div>
					<p>{{ctx.Locale.Tr "repo.settings.pages.not_enabled_desc"}}</p>
				</div>

				<form class="ui form" method="post">
					<input type="hidden" name="action" value="enable">
					<div class="field">
						<label>{{ctx.Locale.Tr "repo.settings.pages.template"}}</label>
						<select name="template" class="ui dropdown">
							{{range .PagesTemplates}}
							<option value="{{.}}">{{.}}</option>
							{{end}}
						</select>
					</div>
					<div class="field">
						<button class="ui primary button">{{ctx.Locale.Tr "repo.settings.pages.enable"}}</button>
					</div>
				</form>
			{{end}}
		</div>

		{{if .PagesEnabled}}
		<h4 class="ui top attached header">
			{{ctx.Locale.Tr "repo.settings.pages.configuration"}}
		</h4>
		<div class="ui attached segment">
			<p>{{ctx.Locale.Tr "repo.settings.pages.config_desc"}}</p>
			<p>{{ctx.Locale.Tr "repo.settings.pages.config_file_hint"}}</p>
			<div class="ui secondary segment">
				<code>.gitea/landing.yaml</code>
			</div>
		</div>

		<h4 class="ui top attached header">
			{{ctx.Locale.Tr "repo.settings.pages.custom_domains"}}
		</h4>
		<div class="ui attached segment">
			<p>{{ctx.Locale.Tr "repo.settings.pages.custom_domains_desc"}}</p>

			{{if .PagesDomains}}
			<table class="ui table">
				<thead>
					<tr>
						<th>{{ctx.Locale.Tr "repo.settings.pages.domain"}}</th>
						<th>{{ctx.Locale.Tr "repo.settings.pages.status"}}</th>
						<th>{{ctx.Locale.Tr "repo.settings.pages.ssl"}}</th>
						<th></th>
					</tr>
				</thead>
				<tbody>
					{{range .PagesDomains}}
					<tr>
						<td>{{.Domain}}</td>
						<td>
							{{if .Verified}}
								<span class="ui green label">{{ctx.Locale.Tr "repo.settings.pages.verified"}}</span>
							{{else}}
								<span class="ui yellow label">{{ctx.Locale.Tr "repo.settings.pages.pending"}}</span>
							{{end}}
						</td>
						<td>
							{{if eq .SSLStatus "active"}}
								<span class="ui green label">{{ctx.Locale.Tr "repo.settings.pages.ssl_active"}}</span>
							{{else if eq .SSLStatus "pending"}}
								<span class="ui yellow label">{{ctx.Locale.Tr "repo.settings.pages.ssl_pending"}}</span>
							{{else}}
								<span class="ui grey label">{{ctx.Locale.Tr "repo.settings.pages.ssl_none"}}</span>
							{{end}}
						</td>
						<td class="tw-text-right">
							{{if and .Verified (eq .SSLStatus "pending")}}
							<form method="post" class="tw-inline-block">
								<input type="hidden" name="action" value="activate_ssl">
								<input type="hidden" name="domain_id" value="{{.ID}}">
								<button class="ui green tiny button">{{ctx.Locale.Tr "repo.settings.pages.activate_ssl"}}</button>
							</form>
							{{end}}
							{{if not .Verified}}
							<form method="post" class="tw-inline-block">
								<input type="hidden" name="action" value="verify_domain">
								<input type="hidden" name="domain_id" value="{{.ID}}">
								<button class="ui primary tiny button">{{ctx.Locale.Tr "repo.settings.pages.verify"}}</button>
							</form>
							{{end}}
							<form method="post" class="tw-inline-block">
								<input type="hidden" name="action" value="delete_domain">
								<input type="hidden" name="domain_id" value="{{.ID}}">
								<button class="ui red tiny button">{{ctx.Locale.Tr "remove"}}</button>
							</form>
						</td>
					</tr>
					{{if and .Verified (eq .SSLStatus "pending")}}
							<form method="post" class="tw-inline-block">
								<input type="hidden" name="action" value="activate_ssl">
								<input type="hidden" name="domain_id" value="{{.ID}}">
								<button class="ui green tiny button">{{ctx.Locale.Tr "repo.settings.pages.activate_ssl"}}</button>
							</form>
							{{end}}
							{{if not .Verified}}
					<tr>
						<td colspan="4">
							<div class="ui info message">
								<p>{{ctx.Locale.Tr "repo.settings.pages.verify_dns_hint"}}</p>
								<code>TXT _gitea-pages.{{.Domain}} {{.VerificationToken}}</code>
							</div>
						</td>
					</tr>
					{{end}}
					{{end}}
				</tbody>
			</table>
			{{end}}

			<form class="ui form" method="post">
				<input type="hidden" name="action" value="add_domain">
				<div class="inline field">
					<label>{{ctx.Locale.Tr "repo.settings.pages.add_domain"}}</label>
					<input name="domain" type="text" placeholder="example.com">
					<div class="field">
						<div class="ui checkbox">
							<input type="checkbox" name="ssl_external" id="ssl_external">
							<label for="ssl_external">{{ctx.Locale.Tr "repo.settings.pages.ssl_external"}}</label>
						</div>
						<p class="help">{{ctx.Locale.Tr "repo.settings.pages.ssl_external_desc"}}</p>
					</div>
					<button class="ui primary button">{{ctx.Locale.Tr "repo.settings.pages.add"}}</button>
				</div>
			</form>
		</div>
		{{end}}
	</div>
{{template "repo/settings/layout_footer" .}}
