mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-11 21:13:02 +00:00
add releases page
This commit is contained in:
parent
105206aef1
commit
8cd16982b1
6 changed files with 85 additions and 31 deletions
|
@ -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(releases: &mut tide::Server<Arc<AppState>>) {
|
||||
releases.at("/releases").get(get_releases);
|
||||
}
|
||||
|
||||
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)
|
||||
.body(request.state().render_template("releases.hbs", &data)?)
|
||||
.content_type(mime::HTML)
|
||||
.build())
|
||||
}
|
||||
}
|
|
@ -1,7 +1,10 @@
|
|||
article.prose {
|
||||
margin-bottom: 2.5rem;
|
||||
}
|
||||
|
||||
article.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;
|
||||
margin-bottom: 2.5rem;
|
||||
letter-spacing: -0.05rem;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -2,13 +2,16 @@
|
|||
// add .prose to any <article> to activate prose styles
|
||||
// or .type-prose to any element
|
||||
|
||||
article.prose {
|
||||
margin-bottom: 2.5rem;
|
||||
}
|
||||
|
||||
article.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;
|
||||
margin-bottom: 2.5rem;
|
||||
letter-spacing: -0.05rem;
|
||||
|
||||
h1,
|
||||
|
|
|
@ -1,31 +1,34 @@
|
|||
{{#> layout }}
|
||||
|
||||
<div class="container mx-auto max-w-screen-md p-10 pt-20">
|
||||
<h1 class="text-white text-4xl font-extralight mb-10">Releases</h1>
|
||||
<div class="max-w-screen-lg mx-auto text-main font-extralight p-20">
|
||||
{{#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}}
|
||||
<div class="container mx-auto py-12 px-8 md:px-12">
|
||||
|
||||
<ul class="mt-10 leading-7">
|
||||
{{#each releases}}
|
||||
<div class="md:flex md:flex-row mb-32 md:mb-12">
|
||||
<div class="font-display mb-8 md:mb-0 md:text-right w-48">
|
||||
<div class="text-2xl font-bold whitespace-nowrap">
|
||||
VERSION {{name}}
|
||||
</div>
|
||||
<a class="text-md underline text-yellow-600 hover:text-yellow-700"
|
||||
href="/releases/{{tag_name}}/{{assets.0.name}}">
|
||||
DOWNLOAD
|
||||
</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>
|
||||
<li id="release-{{name}}" class="mb-5">
|
||||
<a class="text-lg" href="/releases/{{tag_name}}/{{assets.0.name}}">Zed {{name}}</a></h2>
|
||||
<p class="text-gray-400">
|
||||
<a href="https://github.com/zed-industries/zed/releases/tag/{{tag_name}}">Release Notes</a>
|
||||
·
|
||||
<a href="https://github.com/zed-industries/zed/issues/new?labels=defect&title={{name}}+New+issue">New issue</a>
|
||||
</p>
|
||||
</li>
|
||||
{{/each}}
|
||||
</div>
|
||||
</ul>
|
||||
|
||||
{{/if}}
|
||||
|
||||
{{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}}
|
||||
</div>
|
||||
|
||||
|
|
|
@ -2,8 +2,11 @@
|
|||
|
||||
|
||||
<div class="max-w-screen-lg mx-auto text-main font-extralight p-20">
|
||||
{{#if current_user}}
|
||||
|
||||
{{#if releases}}
|
||||
<h1 class="font-display font-extralight mb-10">Updates</h1>
|
||||
|
||||
{{#each releases}}
|
||||
<article id="{{name}}" class="prose">
|
||||
<h2 class="font-display font-extralight">{{name}}—<a class="underline mt-5 leading-7" href="/releases/{{tag_name}}/{{assets.0.name}}">Download</a></h2>
|
||||
|
@ -15,11 +18,13 @@
|
|||
</div>
|
||||
</article>
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
|
||||
{{else}}
|
||||
|
||||
<h1>Hey!</h1>
|
||||
<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}}
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in a new issue