Even more polish of the web experience
This commit is contained in:
parent
17070b30b3
commit
bd6684ea2a
@ -4,7 +4,7 @@ origin:
|
||||
store_dir_path: /tmp/domani_dev_env/origin
|
||||
domain:
|
||||
store_dir_path: /tmp/domani_dev_env/domain
|
||||
builtins:
|
||||
builtin_domains:
|
||||
domani-test.localhost:
|
||||
kind: git
|
||||
url: https://code.betamike.com/micropelago/domani.git
|
||||
|
@ -19,6 +19,7 @@ use crate::{domain, service, task_stack};
|
||||
struct BasePresenter<'a, T> {
|
||||
page_name: &'a str,
|
||||
form_method: &'a str,
|
||||
http_scheme: &'a str,
|
||||
data: T,
|
||||
}
|
||||
|
||||
@ -123,6 +124,13 @@ impl Service {
|
||||
self.serve(status_code, name, rendered.into())
|
||||
}
|
||||
|
||||
fn presenter_http_scheme(&self) -> &str {
|
||||
if self.config.http.https_addr.is_some() {
|
||||
return "https";
|
||||
}
|
||||
return "http";
|
||||
}
|
||||
|
||||
fn render_error_page(&self, status_code: u16, e: &str) -> Response<Body> {
|
||||
#[derive(Serialize)]
|
||||
struct Response<'a> {
|
||||
@ -135,6 +143,7 @@ impl Service {
|
||||
BasePresenter {
|
||||
page_name: "/error.html",
|
||||
form_method: self.config.http.form_method.as_str(),
|
||||
http_scheme: self.presenter_http_scheme(),
|
||||
data: &Response { error_msg: e },
|
||||
},
|
||||
)
|
||||
@ -158,6 +167,7 @@ impl Service {
|
||||
BasePresenter {
|
||||
page_name: name,
|
||||
form_method: self.config.http.form_method.as_str(),
|
||||
http_scheme: self.presenter_http_scheme(),
|
||||
data,
|
||||
},
|
||||
)
|
||||
@ -304,7 +314,7 @@ impl Service {
|
||||
return self.render_error_page(401, "Incorrect passphrase");
|
||||
}
|
||||
|
||||
let settings: domain::Settings = match args.url_encoded_domain_settings.try_into() {
|
||||
let settings: domain::Settings = match args.url_encoded_domain_settings.clone().try_into() {
|
||||
Ok(settings) => settings,
|
||||
Err(e) => {
|
||||
return self
|
||||
@ -320,25 +330,59 @@ impl Service {
|
||||
#[derive(Serialize)]
|
||||
struct Data {
|
||||
domain: domain::Name,
|
||||
url_encoded_domain_settings: util::UrlEncodedDomainSettings,
|
||||
passphrase: String,
|
||||
|
||||
error_msg: Option<String>,
|
||||
retryable: bool,
|
||||
}
|
||||
|
||||
let error_msg = match sync_result {
|
||||
Ok(_) => None,
|
||||
Err(domain::manager::SyncWithSettingsError::NotModifiable) => Some("This domain is not able to be configured, please contact the server administrator.".to_string()),
|
||||
Err(domain::manager::SyncWithSettingsError::InvalidURL) => Some("Fetching the git repository failed, please double check that you input the correct URL.".to_string()),
|
||||
Err(domain::manager::SyncWithSettingsError::InvalidBranchName) => Some("The git repository does not have a branch of the given name, please double check that you input the correct name.".to_string()),
|
||||
Err(domain::manager::SyncWithSettingsError::AlreadyInProgress) => Some("The configuration of your domain is still in progress, please refresh in a few minutes.".to_string()),
|
||||
Err(domain::manager::SyncWithSettingsError::ServiceDNSRecordsNotSet) => Some("None of the expected service DNS records were set on the domain. Please double check that you put the correct value on the record. If the value is correct, then most likely the updated records have not yet propagated. In this case you can refresh in a few minutes to try again.".to_string()),
|
||||
Err(domain::manager::SyncWithSettingsError::ChallengeTokenNotSet) => Some("The TXT record is not set correctly on the domain. Please double check that you put the correct value on the record. If the value is correct, then most likely the updated records have not yet propagated. In this case you can refresh in a few minutes to try again.".to_string()),
|
||||
Err(domain::manager::SyncWithSettingsError::Unexpected(e)) => Some(format!("An unexpected error occurred: {e}")),
|
||||
let (error_msg, retryable) = match sync_result {
|
||||
Ok(_) => (None, false),
|
||||
|
||||
Err(domain::manager::SyncWithSettingsError::NotModifiable) => {
|
||||
(Some("This domain is not allowed to be configured.".to_string()), false)
|
||||
}
|
||||
|
||||
Err(domain::manager::SyncWithSettingsError::InvalidURL) => (Some(
|
||||
"Fetching the git repository failed, please double check that you input the correct
|
||||
URL."
|
||||
.to_string(),
|
||||
), false),
|
||||
|
||||
Err(domain::manager::SyncWithSettingsError::InvalidBranchName) => (Some(
|
||||
"The git repository does not have a branch of the given name, please double check
|
||||
that you input the correct name."
|
||||
.to_string(),
|
||||
), false),
|
||||
|
||||
Err(domain::manager::SyncWithSettingsError::AlreadyInProgress) => {
|
||||
(Some("The configuration of your domain is still in progress.".to_string()), true)
|
||||
}
|
||||
|
||||
Err(domain::manager::SyncWithSettingsError::ServiceDNSRecordsNotSet) => (Some(
|
||||
"No routing record (A, AAAA, CNAME, etc...) was present on the nameserver."
|
||||
.to_string(),
|
||||
), true),
|
||||
|
||||
Err(domain::manager::SyncWithSettingsError::ChallengeTokenNotSet) => (Some(
|
||||
"The challenge record (TXT) was not present on the nameserver."
|
||||
.to_string(),
|
||||
), true),
|
||||
|
||||
Err(domain::manager::SyncWithSettingsError::Unexpected(e)) => {
|
||||
(Some(format!("An unexpected error occurred: {e}")), false)
|
||||
}
|
||||
};
|
||||
|
||||
self.render_page(
|
||||
"/domain_sync.html",
|
||||
Data {
|
||||
domain: args.domain,
|
||||
url_encoded_domain_settings: args.url_encoded_domain_settings,
|
||||
passphrase: args.passphrase,
|
||||
error_msg,
|
||||
retryable,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<h2>Configure DNS</h2>
|
||||
<h2>Configure Your Nameserver</h2>
|
||||
|
||||
<p>This step requires a passphrase that has been given to you by the
|
||||
administrator of the Domani server:</p>
|
||||
@ -18,7 +18,7 @@ administrator of the Domani server:</p>
|
||||
|
||||
</form>
|
||||
|
||||
<p>Next you will need to configure your DNS server to point to Domani. There are
|
||||
<p>Next you will need to configure your nameserver to point to Domani. There are
|
||||
two entries you will need to add. The first entry tells the Domani server that
|
||||
it is allowed to serve this domain with your given configuration:</p>
|
||||
|
||||
@ -59,12 +59,13 @@ query for your domain name. It can be <strong>one or more of</strong>:</p>
|
||||
</table>
|
||||
|
||||
{{ #if data.dns_records_have_cname }}
|
||||
<p>(Please note that not all DNS providers support putting a CNAME at the zone
|
||||
apex, while others support it via an alternative record type like ALIAS or
|
||||
ANAME.)</p>
|
||||
<p>(Please note that not all nameserver support using a CNAME in all cases,
|
||||
while others support it via an alternative record type like ALIAS or ANAME. If
|
||||
one of those are available they can be used instead.)</p>
|
||||
{{ /if }}
|
||||
|
||||
<p>Once both entries are installed, you can hit the following button to check
|
||||
your configuration and set up your domain.</p>
|
||||
your configuration and set up your domain. Note that this step may take a long
|
||||
time to complete, so if nothing happens immediately please don't panic.</p>
|
||||
|
||||
<input type="submit" value="Next" form="syncForm" />
|
||||
|
@ -3,11 +3,35 @@
|
||||
<p>Your domain is not yet set up.</p>
|
||||
<p>{{ data.error_msg }}</p>
|
||||
|
||||
{{#if data.retryable}}
|
||||
<p>
|
||||
It's very possible that you have input your nameserver records correctly, but
|
||||
that the changes haven't yet propagated to Domani. Propagation of nameserver
|
||||
changes can take up to a couple of hours. You can use the button below to retry.
|
||||
</p>
|
||||
|
||||
<form method="{{ form_method }}" action="/domain_sync.html" id="syncForm">
|
||||
<input name="domain" type="hidden" value="{{ data.domain }}" />
|
||||
<input name="passphrase" type="hidden" value="{{ data.passphrase }}" />
|
||||
{{ #each data.url_encoded_domain_settings }}
|
||||
<input name="{{ @key }}" type="hidden" value="{{ this }}" />
|
||||
{{ /each }}
|
||||
<input type="submit" value="Retry" />
|
||||
</form>
|
||||
{{/if}}
|
||||
|
||||
{{ else }}
|
||||
|
||||
<p>Congratulations! Your domain has been successfully configured. You can visit
|
||||
it at:</p>
|
||||
|
||||
<p><a href="http://{{ data.domain }}">http://{{ data.domain }}</a></p>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="{{ http_scheme }}://{{ data.domain }}">{{ http_scheme }}://{{ data.domain }}</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="gemini://{{ data.domain }}">gemini://{{ data.domain }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
{{/if}}
|
||||
|
@ -6,7 +6,7 @@ serving</p>
|
||||
<ul>
|
||||
{{ #each data.domains }}
|
||||
<li>
|
||||
<a href="https://{{ this }}">{{ this }}</a>
|
||||
<a href="{{ ../http_scheme }}://{{ this }}">{{ this }}</a>
|
||||
</li>
|
||||
{{ /each }}
|
||||
</ul>
|
||||
|
@ -6,7 +6,7 @@ use serde_with::{serde_as, NoneAsEmptyString};
|
||||
use crate::{domain, error::unexpected, origin};
|
||||
|
||||
#[serde_as]
|
||||
#[derive(Serialize, Deserialize, Default, Debug)]
|
||||
#[derive(Clone, Serialize, Deserialize, Default, Debug)]
|
||||
pub struct UrlEncodedDomainSettings {
|
||||
domain_setting_origin_descr_kind: String,
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user