Skip to content

Commit

Permalink
Add default view mode to settings (#572)
Browse files Browse the repository at this point in the history
Signed-off-by: Sergio Castaño Arteaga <tegioz@icloud.com>
  • Loading branch information
tegioz authored Apr 15, 2024
1 parent dba3321 commit 1eedeff
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
9 changes: 9 additions & 0 deletions docs/config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -382,3 +382,12 @@ upcoming_event:
end: "2024-03-22"
banner_url: "https://www.cncf.io/wp-content/uploads/2024/01/kceu24_promo_2400x300.png"
details_url: "https://events.linuxfoundation.org/kubecon-cloudnativecon-europe/register/?utm_source=landscape&utm_medium=all&utm_campaign=kubeconeu24&utm_content=slim-banner"

# View mode (optional)
#
# This section allows customizing the default view mode of the landscape web
# application. The view mode can be set to either `grid` or `card`. When
# omitted, the default view mode is `grid`.
#
# view_mode: <grid|card>
#
8 changes: 7 additions & 1 deletion src/build/datasets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ mod base {
use crate::build::{
data::{self, AdditionalCategory, Category, CategoryName, ItemFeatured, LandscapeData},
guide::LandscapeGuide,
settings::{Colors, Footer, GridItemsSize, Group, Header, Images, LandscapeSettings, UpcomingEvent},
settings::{
Colors, Footer, GridItemsSize, Group, Header, Images, LandscapeSettings, UpcomingEvent, ViewMode,
},
};
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
Expand Down Expand Up @@ -113,6 +115,9 @@ mod base {

#[serde(skip_serializing_if = "Option::is_none")]
pub upcoming_event: Option<UpcomingEvent>,

#[serde(skip_serializing_if = "Option::is_none")]
pub view_mode: Option<ViewMode>,
}

impl Base {
Expand Down Expand Up @@ -140,6 +145,7 @@ mod base {
items: vec![],
members_category: settings.members_category.clone(),
upcoming_event: settings.upcoming_event.clone(),
view_mode: settings.view_mode.clone(),
};

// Update categories overridden in settings
Expand Down
11 changes: 11 additions & 0 deletions src/build/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ pub(crate) struct LandscapeSettings {

#[serde(skip_serializing_if = "Option::is_none")]
pub upcoming_event: Option<UpcomingEvent>,

#[serde(skip_serializing_if = "Option::is_none")]
pub view_mode: Option<ViewMode>,
}

impl LandscapeSettings {
Expand Down Expand Up @@ -630,3 +633,11 @@ pub(crate) struct UpcomingEvent {
pub banner_url: String,
pub details_url: String,
}

/// Default view mode used in the web application.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub(crate) enum ViewMode {
Grid,
Card,
}
9 changes: 9 additions & 0 deletions src/new/template/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,12 @@ screenshot_width: 1500
# banner_url: <URL> # Event banner image url (required, recommended dimensions: 2400x300)
# details_url: <URL> # Event details URL (required)
#

# View mode (optional)
#
# This section allows customizing the default view mode of the landscape web
# application. The view mode can be set to either `grid` or `card`. When
# omitted, the default view mode is `grid`.
#
# view_mode: <grid|card>
#

0 comments on commit 1eedeff

Please sign in to comment.