diff --git a/server/src/updates.rs b/server/src/updates.rs index b53989f4d3..acd3558fb4 100644 --- a/server/src/updates.rs +++ b/server/src/updates.rs @@ -1,15 +1,55 @@ -use crate::{AppState, Request, RequestExt}; +use crate::{ + auth::RequestExt as _, github::Release, AppState, LayoutData, Request, RequestExt as _, +}; +use comrak::ComrakOptions; +use serde::{Serialize}; use std::sync::Arc; -use tide::http::mime; +use tide::{http::mime}; pub fn add_routes(updates: &mut tide::Server>) { updates.at("/updates").get(get_updates); } async fn get_updates(mut request: Request) -> tide::Result { - let data = request.layout_data().await?; + + #[derive(Serialize)] + struct UpdatesData { + #[serde(flatten)] + layout: Arc, + releases: Option>, + } + + let mut data = UpdatesData { + layout: request.layout_data().await?, + releases: None, + }; + + if let Some(user) = request.current_user().await? { + if user.is_insider { + data.releases = Some( + request + .state() + .repo_client + .releases() + .await? + .into_iter() + .filter_map(|mut release| { + if release.draft { + None + } else { + let mut options = ComrakOptions::default(); + options.render.unsafe_ = true; // Allow raw HTML in the markup. We control these release notes anyway. + release.body = comrak::markdown_to_html(&release.body, &options); + Some(release) + } + }) + .collect(), + ); + } + } + Ok(tide::Response::builder(200) .body(request.state().render_template("updates.hbs", &data)?) .content_type(mime::HTML) .build()) -} +} \ No newline at end of file diff --git a/server/templates/home.hbs b/server/templates/home.hbs index ee2b5328c4..274c621d87 100644 --- a/server/templates/home.hbs +++ b/server/templates/home.hbs @@ -1,6 +1,6 @@ {{#> layout }} -
+

Meet Zed—A lightning fast code editor written natively in Rust.

Level up your development process with: @@ -11,8 +11,14 @@

  • the ability to rewind time to any point
  • -

    Early access to Zed will open up mid-2022 for small teams and individuals. Be the first to know.

    -

    Read our story.

    +

    Early access to Zed will open up mid-2022 for small teams and individuals.

    + Be the first to know. + +

    We started Zed for ourselves—To bring joy back to writing code every day.

    +

    Modern text editors have forgotten the core tentants of software – speed and reliability first, features second.

    +

    While we are building Zed from the ground up built for collaboration, we are putting in the time to ensure every feature we build is performant and rock solid.

    +

    New software tends to overpromise and underdeliver—Our goal with Zed is to start small and impress with a singular focus on developer experience.

    + Read our story.
    {{/layout}} \ No newline at end of file diff --git a/server/templates/partials/layout.hbs b/server/templates/partials/layout.hbs index 3dda95815c..0f5e9588b1 100644 --- a/server/templates/partials/layout.hbs +++ b/server/templates/partials/layout.hbs @@ -22,9 +22,9 @@ - -
    -