Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
013fd7151e | ||
|
|
99b29bb09f | ||
|
|
b08e1af139 | ||
|
|
c1cdc53187 | ||
|
|
4fee02ab82 | ||
|
|
405bb98185 |
Generated
+1
-1
@@ -2948,7 +2948,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "portal"
|
name = "portal"
|
||||||
version = "0.3.23"
|
version = "0.3.26"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"arc-swap",
|
"arc-swap",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "portal"
|
name = "portal"
|
||||||
version = "0.3.24"
|
version = "0.3.27"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
|
|||||||
+17
-9
@@ -1,5 +1,5 @@
|
|||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
use leptos_meta::{provide_meta_context, HashedStylesheet, Html, MetaTags, Title};
|
use leptos_meta::{provide_meta_context, HashedStylesheet, Html, MetaTags, Stylesheet, Title};
|
||||||
use leptos_router::{
|
use leptos_router::{
|
||||||
components::{Route, Router, Routes},
|
components::{Route, Router, Routes},
|
||||||
hooks::{use_location, use_navigate, use_query_map},
|
hooks::{use_location, use_navigate, use_query_map},
|
||||||
@@ -79,8 +79,20 @@ pub fn App() -> impl IntoView {
|
|||||||
});
|
});
|
||||||
provide_context(Lang(lang));
|
provide_context(Lang(lang));
|
||||||
|
|
||||||
|
// A content-shipped stylesheet (site.yaml `stylesheet:`) layered
|
||||||
|
// after the default one - leptos_meta appends it at the MetaTags
|
||||||
|
// slot, which the shell places after HashedStylesheet, so content
|
||||||
|
// rules win at equal specificity.
|
||||||
|
let custom_css = Memo::new(move |_| {
|
||||||
|
site.get()
|
||||||
|
.and_then(|r| r.ok())
|
||||||
|
.and_then(|s| s.stylesheet)
|
||||||
|
.map(|p| format!("/site/{p}"))
|
||||||
|
});
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<Html attr:lang=move || lang.get()/>
|
<Html attr:lang=move || lang.get()/>
|
||||||
|
{move || custom_css.get().map(|href| view! { <Stylesheet id="site-custom" href=href/> })}
|
||||||
<Suspense fallback=|| ()>
|
<Suspense fallback=|| ()>
|
||||||
{move || {
|
{move || {
|
||||||
site.get()
|
site.get()
|
||||||
@@ -575,14 +587,10 @@ fn Hero(title: String, description: String, landing: bool, site: SiteConfig, cur
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
let has_module = module.is_some();
|
let has_module = module.is_some();
|
||||||
// Light theme inverts white-stroke wordmarks to ink. The house
|
// Light theme can invert a white-stroke wordmark to ink. Default:
|
||||||
// mark and the sibling-site marks are all white-stroke SVGs; a
|
// only the built-in house mark inverts; a content-shipped logo
|
||||||
// raster logo is a client brand and keeps its colors.
|
// keeps its colours unless site.yaml opts in with wordmark_invert.
|
||||||
let house_wordmark = site
|
let house_wordmark = site.wordmark_invert.unwrap_or(site.wordmark.is_none());
|
||||||
.wordmark
|
|
||||||
.as_deref()
|
|
||||||
.map(|w| w.ends_with(".svg"))
|
|
||||||
.unwrap_or(true);
|
|
||||||
let wordmark = site.wordmark.clone().unwrap_or_else(|| "/wordmark.svg".to_string());
|
let wordmark = site.wordmark.clone().unwrap_or_else(|| "/wordmark.svg".to_string());
|
||||||
// Clamped server-side too, but belt and braces for the inline style.
|
// Clamped server-side too, but belt and braces for the inline style.
|
||||||
let wordmark_style = site
|
let wordmark_style = site
|
||||||
|
|||||||
+29
-2
@@ -446,6 +446,12 @@ pub struct Requirement {
|
|||||||
/// `ResourceSpec` mechanism a `Feature.resource` uses.
|
/// `ResourceSpec` mechanism a `Feature.resource` uses.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub resource: Option<ResourceSpec>,
|
pub resource: Option<ResourceSpec>,
|
||||||
|
/// `type: select` only - a static list of options, as an
|
||||||
|
/// alternative to a `resource`. Each string is both the option's
|
||||||
|
/// stored value and its label. Faithful to the ancestor format's
|
||||||
|
/// inline enums.
|
||||||
|
#[serde(default)]
|
||||||
|
pub options: Vec<String>,
|
||||||
/// `type: select` only - which field in each item is the option's
|
/// `type: select` only - which field in each item is the option's
|
||||||
/// stable id. Defaults to trying `_id` then `id`.
|
/// stable id. Defaults to trying `_id` then `id`.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
@@ -517,6 +523,12 @@ pub struct SiteConfig {
|
|||||||
/// `None` falls back to `/wordmark.svg`.
|
/// `None` falls back to `/wordmark.svg`.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub wordmark: Option<String>,
|
pub wordmark: Option<String>,
|
||||||
|
/// Whether to invert the wordmark in light theme. `None` inverts
|
||||||
|
/// only the built-in house wordmark (a white-stroke SVG); a
|
||||||
|
/// content-shipped logo keeps its own colours unless it sets this
|
||||||
|
/// true (e.g. a sibling site's white-stroke mark).
|
||||||
|
#[serde(default)]
|
||||||
|
pub wordmark_invert: Option<bool>,
|
||||||
/// Wordmark display height in rem (0.5–6.0). `None` keeps the
|
/// Wordmark display height in rem (0.5–6.0). `None` keeps the
|
||||||
/// stylesheet's default. Raster logos look best at or below their
|
/// stylesheet's default. Raster logos look best at or below their
|
||||||
/// intrinsic pixel height.
|
/// intrinsic pixel height.
|
||||||
@@ -527,6 +539,11 @@ pub struct SiteConfig {
|
|||||||
/// `None` means "en"; unknown codes fall back to English per key.
|
/// `None` means "en"; unknown codes fall back to English per key.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub lang: Option<String>,
|
pub lang: Option<String>,
|
||||||
|
/// A content-repo-relative CSS file (e.g. "custom.css") layered
|
||||||
|
/// *after* the default stylesheet, so it overrides. Served
|
||||||
|
/// same-origin at `/site/<path>`; plain path only.
|
||||||
|
#[serde(default)]
|
||||||
|
pub stylesheet: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub hero: HeroConfig,
|
pub hero: HeroConfig,
|
||||||
}
|
}
|
||||||
@@ -582,6 +599,13 @@ impl SiteConfig {
|
|||||||
}
|
}
|
||||||
other => anyhow::bail!("site.yaml: hero.kind {other:?} is not one of plain | module"),
|
other => anyhow::bail!("site.yaml: hero.kind {other:?} is not one of plain | module"),
|
||||||
}
|
}
|
||||||
|
if let Some(sheet) = &self.stylesheet {
|
||||||
|
if !is_safe_site_path(sheet) || !sheet.ends_with(".css") {
|
||||||
|
anyhow::bail!(
|
||||||
|
"site.yaml: stylesheet {sheet:?} must be a plain repo-relative .css path"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1192,9 +1216,12 @@ pub fn validate_questions(
|
|||||||
.collect();
|
.collect();
|
||||||
for feature in &alternative.features {
|
for feature in &alternative.features {
|
||||||
for requirement in &feature.requirements {
|
for requirement in &feature.requirements {
|
||||||
if requirement.kind == "select" && requirement.resource.is_none() {
|
if requirement.kind == "select"
|
||||||
|
&& requirement.resource.is_none()
|
||||||
|
&& requirement.options.is_empty()
|
||||||
|
{
|
||||||
anyhow::bail!(
|
anyhow::bail!(
|
||||||
"question {:?} alternative {:?} feature {:?}: requirement {:?} is type: select but declares no resource to select from",
|
"question {:?} alternative {:?} feature {:?}: requirement {:?} is type: select but declares neither a resource nor inline options",
|
||||||
question.id, alternative.name, feature.name, requirement.name
|
question.id, alternative.name, feature.name, requirement.name
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,16 @@ pub async fn get_requirement_options(
|
|||||||
.iter()
|
.iter()
|
||||||
.find(|r| r.name == requirement_name)
|
.find(|r| r.name == requirement_name)
|
||||||
.ok_or_else(|| ServerFnError::new("unknown requirement"))?;
|
.ok_or_else(|| ServerFnError::new("unknown requirement"))?;
|
||||||
|
// Inline options: return them as {id,label} objects, the shape the
|
||||||
|
// SelectField renders, without touching a resource.
|
||||||
|
if !requirement.options.is_empty() {
|
||||||
|
let items: Vec<serde_json::Value> = requirement
|
||||||
|
.options
|
||||||
|
.iter()
|
||||||
|
.map(|o| serde_json::json!({ "id": o, "label": o }))
|
||||||
|
.collect();
|
||||||
|
return Ok(serde_json::Value::Array(items));
|
||||||
|
}
|
||||||
let resource = requirement
|
let resource = requirement
|
||||||
.resource
|
.resource
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|||||||
Reference in New Issue
Block a user