Forward the edit-state when redirecting to renamed articles.
This improves usability with noscript
This commit is contained in:
parent
e92c9695be
commit
a81a568ee2
2 changed files with 15 additions and 10 deletions
|
@ -14,14 +14,18 @@ impl TemporaryRedirectResource {
|
||||||
Self { location }
|
Self { location }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_slug<S: AsRef<str>>(slug: S) -> Self {
|
pub fn from_slug<S: AsRef<str>>(slug: S, edit: bool) -> Self {
|
||||||
Self {
|
let base =
|
||||||
location:
|
|
||||||
if slug.as_ref().is_empty() {
|
if slug.as_ref().is_empty() {
|
||||||
"."
|
"."
|
||||||
} else {
|
} else {
|
||||||
slug.as_ref()
|
slug.as_ref()
|
||||||
}.to_owned()
|
};
|
||||||
|
|
||||||
|
let tail = if edit { "?edit" } else { "" };
|
||||||
|
|
||||||
|
Self {
|
||||||
|
location: format!("{}{}", base, tail)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,16 +220,17 @@ impl WikiLookup {
|
||||||
return Box::new(finished(None));
|
return Box::new(finished(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let edit = query == Some("edit");
|
||||||
|
|
||||||
// Normalize all user-generated slugs:
|
// Normalize all user-generated slugs:
|
||||||
let slugified_slug = slugify(&slug);
|
let slugified_slug = slugify(&slug);
|
||||||
if slugified_slug != slug {
|
if slugified_slug != slug {
|
||||||
return Box::new(finished(Some(
|
return Box::new(finished(Some(
|
||||||
Box::new(TemporaryRedirectResource::from_slug(slugified_slug)) as BoxResource
|
Box::new(TemporaryRedirectResource::from_slug(slugified_slug, edit)) as BoxResource
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
let state = self.state.clone();
|
let state = self.state.clone();
|
||||||
let edit = query == Some("edit");
|
|
||||||
let slug = slug.into_owned();
|
let slug = slug.into_owned();
|
||||||
|
|
||||||
use state::SlugLookup;
|
use state::SlugLookup;
|
||||||
|
@ -240,7 +241,7 @@ impl WikiLookup {
|
||||||
SlugLookup::Hit { article_id, revision } =>
|
SlugLookup::Hit { article_id, revision } =>
|
||||||
Box::new(ArticleResource::new(state, article_id, revision, edit)) as BoxResource,
|
Box::new(ArticleResource::new(state, article_id, revision, edit)) as BoxResource,
|
||||||
SlugLookup::Redirect(slug) =>
|
SlugLookup::Redirect(slug) =>
|
||||||
Box::new(TemporaryRedirectResource::from_slug(slug)) as BoxResource,
|
Box::new(TemporaryRedirectResource::from_slug(slug, edit)) as BoxResource,
|
||||||
})))
|
})))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue