add releases page

This commit is contained in:
Nate 2021-09-17 14:59:02 -04:00
parent 105206aef1
commit 8cd16982b1
6 changed files with 85 additions and 31 deletions

View file

@ -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 std::sync::Arc;
use tide::http::mime; use tide::{http::mime};
pub fn add_routes(releases: &mut tide::Server<Arc<AppState>>) { pub fn add_routes(releases: &mut tide::Server<Arc<AppState>>) {
releases.at("/releases").get(get_releases); releases.at("/releases").get(get_releases);
} }
async fn get_releases(mut request: Request) -> tide::Result { async fn get_releases(mut request: Request) -> tide::Result {
let data = request.layout_data().await?;
#[derive(Serialize)]
struct ReleasesData {
#[serde(flatten)]
layout: Arc<LayoutData>,
releases: Option<Vec<Release>>,
}
let mut data = ReleasesData {
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) Ok(tide::Response::builder(200)
.body(request.state().render_template("releases.hbs", &data)?) .body(request.state().render_template("releases.hbs", &data)?)
.content_type(mime::HTML) .content_type(mime::HTML)
.build()) .build())
} }

View file

@ -1,7 +1,10 @@
article.prose {
margin-bottom: 2.5rem;
}
article.prose, article.prose,
.type-prose { .type-prose {
font-family: "Spectral", "Constantia", "Lucida Bright", "Lucidabright", "Lucida Serif", "Lucida", "DejaVu Serif", "Bitstream Vera Serif", "Liberation Serif", "Georgia", "serif", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", serif; font-family: "Spectral", "Constantia", "Lucida Bright", "Lucidabright", "Lucida Serif", "Lucida", "DejaVu Serif", "Bitstream Vera Serif", "Liberation Serif", "Georgia", "serif", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", serif;
margin-bottom: 2.5rem;
letter-spacing: -0.05rem; letter-spacing: -0.05rem;
} }

File diff suppressed because one or more lines are too long

View file

@ -2,13 +2,16 @@
// add .prose to any <article> to activate prose styles // add .prose to any <article> to activate prose styles
// or .type-prose to any element // or .type-prose to any element
article.prose {
margin-bottom: 2.5rem;
}
article.prose, article.prose,
.type-prose { .type-prose {
font-family: "Spectral", "Constantia", "Lucida Bright", "Lucidabright", font-family: "Spectral", "Constantia", "Lucida Bright", "Lucidabright",
"Lucida Serif", "Lucida", "DejaVu Serif", "Bitstream Vera Serif", "Lucida Serif", "Lucida", "DejaVu Serif", "Bitstream Vera Serif",
"Liberation Serif", "Georgia", "serif", "Apple Color Emoji", "Liberation Serif", "Georgia", "serif", "Apple Color Emoji",
"Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", serif; "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", serif;
margin-bottom: 2.5rem;
letter-spacing: -0.05rem; letter-spacing: -0.05rem;
h1, h1,

View file

@ -1,31 +1,34 @@
{{#> layout }} {{#> layout }}
<div class="container mx-auto max-w-screen-md p-10 pt-20"> <div class="max-w-screen-lg mx-auto text-main font-extralight p-20">
<h1 class="text-white text-4xl font-extralight mb-10">Releases</h1> {{#if current_user}}
<h1 class="font-display font-extralight mb-10">Releases</h1>
<p class="mt-5 leading-7">Currently Zed we are only shipping OS X builds of Zed.</p>
<p class="mt-5 leading-7">We are frequently shipping new versions, check back reguarly to get the most recent version. If you run into an issue you think we might not know about use the "new issue" links by the appropriate version to let us know about it.</p>
{{#if releases}} {{#if releases}}
<div class="container mx-auto py-12 px-8 md:px-12">
<ul class="mt-10 leading-7">
{{#each releases}} {{#each releases}}
<div class="md:flex md:flex-row mb-32 md:mb-12"> <li id="release-{{name}}" class="mb-5">
<div class="font-display mb-8 md:mb-0 md:text-right w-48"> <a class="text-lg" href="/releases/{{tag_name}}/{{assets.0.name}}">Zed {{name}}</a></h2>
<div class="text-2xl font-bold whitespace-nowrap"> <p class="text-gray-400">
VERSION {{name}} <a href="https://github.com/zed-industries/zed/releases/tag/{{tag_name}}">Release Notes</a>
</div> ·
<a class="text-md underline text-yellow-600 hover:text-yellow-700" <a href="https://github.com/zed-industries/zed/issues/new?labels=defect&title={{name}}+New+issue">New issue</a>
href="/releases/{{tag_name}}/{{assets.0.name}}"> </p>
DOWNLOAD </li>
</a>
</div>
<div
class="prose prose-lg xl:prose-xl border-t md:border-t-0 pt-8 md:border-l border-gray-400 md:ml-8 md:pl-8 md:pt-0 xl:ml-16 xl:pl-16 max-w-5xl font-body">
{{{body}}}
</div>
</div>
{{/each}} {{/each}}
</div> </ul>
{{/if}}
{{else}} {{else}}
<p>You can't access this without <a href=" /sign_in">logging in</a>.</p> <h1 class="font-display font-extralight mb-10">Hold it!</h1>
<p class="mt-5 leading-7">You can't access this without <a href=" /sign_in" class="underline mt-5 leading-7">logging in</a>.</p>
<p class="mt-5 leading-7">Try <a href="/community" class="underline mt-5 leading-7">joining our community</a> to get access to updates & releases.</p>
{{/if}} {{/if}}
</div> </div>

View file

@ -2,8 +2,11 @@
<div class="max-w-screen-lg mx-auto text-main font-extralight p-20"> <div class="max-w-screen-lg mx-auto text-main font-extralight p-20">
{{#if current_user}}
{{#if releases}} {{#if releases}}
<h1 class="font-display font-extralight mb-10">Updates</h1> <h1 class="font-display font-extralight mb-10">Updates</h1>
{{#each releases}} {{#each releases}}
<article id="{{name}}" class="prose"> <article id="{{name}}" class="prose">
<h2 class="font-display font-extralight">{{name}}&mdash;<a class="underline mt-5 leading-7" href="/releases/{{tag_name}}/{{assets.0.name}}">Download</a></h2> <h2 class="font-display font-extralight">{{name}}&mdash;<a class="underline mt-5 leading-7" href="/releases/{{tag_name}}/{{assets.0.name}}">Download</a></h2>
@ -15,11 +18,13 @@
</div> </div>
</article> </article>
{{/each}} {{/each}}
{{/if}}
{{else}} {{else}}
<h1>Hey!</h1> <h1 class="font-display font-extralight mb-10">Hold it!</h1>
<p>You can't access this without <a href=" /sign_in">logging in</a>.</p> <p class="mt-5 leading-7">You can't access this without <a href=" /sign_in" class="underline mt-5 leading-7">logging in</a>.</p>
<p class="mt-5 leading-7">Try <a href="/community" class="underline mt-5 leading-7">joining our community</a> to get access to updates & releases.</p>
{{/if}} {{/if}}
</div> </div>