Skip to content

Commit

Permalink
mob love
Browse files Browse the repository at this point in the history
  • Loading branch information
mightyiam committed Jun 1, 2024
1 parent 6991175 commit 0746ffa
Show file tree
Hide file tree
Showing 13 changed files with 137 additions and 21 deletions.
1 change: 1 addition & 0 deletions builder/src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ mod calendar;
pub(crate) mod home_page;
pub(crate) mod mob_page;
pub(crate) mod page_base;
pub(crate) mod redirect_page;
pub(crate) mod schema;

pub(crate) use calendar::Calendar;
Expand Down
1 change: 1 addition & 0 deletions builder/src/components/add_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ impl Render for AddPage {
.clone()
.into_page(
Some("Add".to_owned().into()),
None,
content,
classes!("flex", "flex-col", VERTICAL_GAP_CLASS),
components::page_base::PageDescription::from(format!(
Expand Down
1 change: 1 addition & 0 deletions builder/src/components/home_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ impl Render for HomePage {
};

let page = self.base.clone().into_page(
None,
None,
content,
classes!("flex", "flex-col", "gap-1"),
Expand Down
2 changes: 2 additions & 0 deletions builder/src/components/mob_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ impl Render for MobPage {
}
mob::Status::Full(join_content) => join_content.clone(),
mob::Status::Public(join_content) => Some(join_content.clone()),
mob::Status::Renamed(_id) => None,
mob::Status::Terminated(content) => content.clone(),
};

Expand Down Expand Up @@ -135,6 +136,7 @@ impl Render for MobPage {
.clone()
.into_page(
Some(self.mob.title().as_str().to_owned().into()),
None,
content,
classes!("flex", "flex-col", "gap-6"),
components::page_base::PageDescription::from(format!(
Expand Down
3 changes: 3 additions & 0 deletions builder/src/components/mob_page/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ impl Render for Status {
status_wrapper_true,
status_wrapper_false,
),
mob::Status::Renamed(_) => {
unreachable!()
}
mob::Status::Terminated(_) => (
status_wrapper_false,
status_wrapper_false,
Expand Down
7 changes: 7 additions & 0 deletions builder/src/components/page_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,15 @@ impl PageBase {
pub(crate) fn into_page(
self,
title: Option<PageTitle>,
head_content: Option<Markup>,
content: Markup,
content_classes: Classes,
description: PageDescription,
) -> Page {
Page {
base: self,
title,
head_content,
content,
content_classes,
description,
Expand All @@ -89,11 +91,13 @@ impl PageBase {
pub(crate) struct Page {
base: PageBase,
title: Option<PageTitle>,
head_content: Option<Markup>,
content: Markup,
content_classes: Classes,
description: PageDescription,
}

#[allow(clippy::too_many_lines)]
impl Render for Page {
fn render(&self) -> Markup {
const NAV_ICON_SIZE: u8 = 32;
Expand Down Expand Up @@ -146,6 +150,9 @@ impl Render for Page {
meta charset="utf-8";
meta name="description" content=(self.description);
meta name="viewport" content="width=device-width, initial-scale=1.0";
@if let Some(head_content) = &self.head_content {
(head_content)
}
link rel="stylesheet" href={ "/index.css?v=" (version) };
style {
@for font in fonts::ALL.as_slice() { (font) }
Expand Down
44 changes: 44 additions & 0 deletions builder/src/components/redirect_page.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
use maud::{html, Render};

use super::PageBase;

#[derive(Debug, Clone)]
pub(crate) struct RedirectPage {
base: PageBase,
target: String,
}

impl RedirectPage {
pub(crate) fn new(base: PageBase, target: String) -> Self {
Self { base, target }
}
}

impl Render for RedirectPage {
fn render(&self) -> maud::Markup {
let title = Some("Redirecting...".to_owned().into());

let head_content = Some(html! {
meta http-equiv="refresh" content=(format!("5; url={}", self.target));
});

let content = html! {
p {
"Redirecting to";
code { (self.target) };
"...";
}
};

let content_classes = classes!("flex", "justify-center", "items-center");

let description = format!("Redirect to {}...", self.target).to_owned().into();

let page =
self.base
.clone()
.into_page(title, head_content, content, content_classes, description);

page.render()
}
}
39 changes: 26 additions & 13 deletions builder/src/mob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,32 @@ impl Mob {
components::mob_page::event_content_template,
);

let base = components::PageBase::new(&mut expected_files, path.clone());

let page = components::mob_page::MobPage::new(
self,
links,
events,
base,
expected_files.insert_("/fullcalendar.js"),
expected_files.insert_("/rrule.js"),
expected_files.insert_("/fullcalendar_rrule.js"),
);

let bytes = page.render().0.into_bytes();
let markup = if let status::Status::Renamed(renamed_id) = self.status() {
let base = components::PageBase::new(&mut expected_files, path.clone());

let page = components::redirect_page::RedirectPage::new(
base,
format!("/mobs/{renamed_id}.html"),
);

page.render()
} else {
let base = components::PageBase::new(&mut expected_files, path.clone());

let page = components::mob_page::MobPage::new(
self,
links,
events,
base,
expected_files.insert_("/fullcalendar.js"),
expected_files.insert_("/rrule.js"),
expected_files.insert_("/fullcalendar_rrule.js"),
);

page.render()
};

let bytes = markup.render().0.into_bytes();

FileSpec::new(path, BytesSource::new(bytes, Some(expected_files)))
}
Expand Down
4 changes: 3 additions & 1 deletion builder/src/mob/id.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#[derive(Debug, Clone, derive_more::Display)]
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, derive_more::Display, Serialize, Deserialize)]
pub(crate) struct Id(String);

impl Id {
Expand Down
12 changes: 12 additions & 0 deletions builder/src/mob/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use crate::{markdown::Markdown, syn_helpers::Attribute};

pub(crate) use self::legend::Legend;

use super::id::Id;

#[derive(Debug, Clone, Serialize, Deserialize, Schema, AsRefStr, EnumVariantNames, CustomAttrs)]
#[attr(indicator: Option<char>)]
/// A mob's status
Expand Down Expand Up @@ -61,6 +63,16 @@ pub(crate) enum Status {
/// ```
#[attr(indicator = '⛲')]
Public(Markdown),
/// This mob has been renamed.
///
/// The value is the new name.
///
/// Example:
///
/// ```yaml
/// !Renamed "love"
/// ```
Renamed(Id),
/// This mob has been terminated.
///
/// The value may explain why.
Expand Down
7 changes: 6 additions & 1 deletion builder/src/pages/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ pub fn page() -> FileSpec {

let events = MOBS
.iter()
.filter(|mob| !matches!(mob.status(), mob::Status::Terminated(_)))
.filter(|mob| {
!matches!(
mob.status(),
mob::Status::Terminated(_) | mob::Status::Renamed(_)
)
})
.map(|mob| mob.events(&mut expected_files, event_content_template))
.collect::<Vec<_>>()
.into_iter()
Expand Down
30 changes: 30 additions & 0 deletions mobs/love.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
title: Mob Love
subtitle: A mob for eslint-config-love
participants:
- !Public
name: Shahar “Dawn” Or
social_url: https://twitter.com/mightyiam
avatar_url: https://avatars.githubusercontent.com/u/635591?v=4
- !Public
name: Rostislav Simonik
social_url: https://github.com/rostislav-simonik
avatar_url: https://avatars.githubusercontent.com/u/25525736?v=4
schedule:
- frequency: FREQ=WEEKLY;BYDAY=SA
timezone: Etc/UTC
start_date: 2024-06-01
start_time: 05:00
duration: 180
background_color: fuchsia
text_color: navy
freeform_copy: |
## What we do
We work on [eslint-config-love](https://github.com/mightyiam/eslint-config-love).
status: !Open |
## Join us
If you're interested in JavaScript, TypeScript and open source, consider applying to our mob.
For more details and application, see [this gist](https://gist.github.com/mightyiam/6618d6ae649dc26ef485a21ccfe1eb3e).
7 changes: 1 addition & 6 deletions mobs/standard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,4 @@ freeform_copy: |
We develop and maintain [JavaScript Standard Style](https://standardjs.com/).
status: !Open |
## Join us
If you're interested in JavaScript, TypeScript and open source project maintenance, consider applying to our mob.
For more details and application, see [this gist](https://gist.github.com/mightyiam/6618d6ae649dc26ef485a21ccfe1eb3e).
status: !Renamed "love"

0 comments on commit 0746ffa

Please sign in to comment.