Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit839ce3a

Browse files
Dan thumbnail update (#1297)
1 parent8488230 commit839ce3a

File tree

11 files changed

+118
-55
lines changed

11 files changed

+118
-55
lines changed

‎pgml-dashboard/src/api/cms.rs

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ use rocket::{fs::NamedFile, http::uri::Origin, route::Route, State};
1212
use yaml_rust::YamlLoader;
1313

1414
usecrate::{
15-
components::cms::index_link::IndexLink,
15+
components::{cms::index_link::IndexLink, layouts::marketing::base::Theme, layouts::marketing::Base},
1616
guards::Cluster,
1717
responses::{ResponseOk,Template},
1818
templates::docs::*,
1919
utils::config,
2020
};
2121
use serde::{Deserialize,Serialize};
22+
use std::fmt;
2223

2324
lazy_static!{
2425
static refBLOG:Collection =Collection::new(
@@ -62,21 +63,31 @@ lazy_static! {
6263
);
6364
}
6465

65-
#[derive(PartialEq,Debug,Serialize,Deserialize)]
66+
#[derive(Debug,Serialize,Deserialize,Clone)]
6667
pubenumDocType{
6768
Blog,
6869
Docs,
6970
Careers,
7071
}
7172

73+
impl fmt::DisplayforDocType{
74+
fnfmt(&self,f:&mut fmt::Formatter) -> fmt::Result{
75+
matchself{
76+
DocType::Blog =>write!(f,"blog"),
77+
DocType::Docs =>write!(f,"docs"),
78+
DocType::Careers =>write!(f,"careers"),
79+
}
80+
}
81+
}
82+
7283
implFromStrforDocType{
7384
typeErr =();
7485

7586
fnfrom_str(s:&str) ->Result<DocType,Self::Err>{
7687
match s{
7788
"blog" =>Ok(DocType::Blog),
78-
"Doc" =>Ok(DocType::Docs),
79-
"Careers" =>Ok(DocType::Careers),
89+
"docs" =>Ok(DocType::Docs),
90+
"careers" =>Ok(DocType::Careers),
8091
_ =>Err(()),
8192
}
8293
}
@@ -97,12 +108,14 @@ pub struct Document {
97108
pubtoc_links:Vec<TocLink>,
98109
pubcontents:String,
99110
pubdoc_type:Option<DocType>,
111+
// url to thumbnail for social share
112+
pubthumbnail:Option<String>,
100113
}
101114

102115
// Gets document markdown
103116
implDocument{
104117
pubasyncfnfrom_path(path:&PathBuf) -> anyhow::Result<Document, std::io::Error>{
105-
warn!("path: {:?}", path);
118+
debug!("path: {:?}", path);
106119

107120
let regex = regex::Regex::new(r#".*/pgml-cms/([^"]*)/(.*)\.md"#).unwrap();
108121

@@ -130,6 +143,8 @@ impl Document {
130143
(None, contents)
131144
};
132145

146+
let default_image =".gitbook/assets/blog_image_placeholder.png";
147+
133148
// parse meta section
134149
let(description, image, featured, tags) =match meta{
135150
Some(meta) =>{
@@ -140,9 +155,13 @@ impl Document {
140155
};
141156

142157
let image =if meta["image"].is_badvalue(){
143-
Some(".gitbook/assets/blog_image_placeholder.png".to_string())
158+
Some(format!("/{}/{}", doc_type.clone().unwrap().to_string(), default_image))
144159
}else{
145-
Some(meta["image"].as_str().unwrap().to_string())
160+
Some(format!(
161+
"/{}/{}",
162+
doc_type.clone().unwrap().to_string().to_string(),
163+
meta["image"].as_str().unwrap()
164+
))
146165
};
147166

148167
let featured =if meta["featured"].is_badvalue(){
@@ -165,12 +184,23 @@ impl Document {
165184
}
166185
None =>(
167186
None,
168-
Some(".gitbook/assets/blog_image_placeholder.png".to_string()),
187+
Some(format!("/{}/{}", doc_type.clone().unwrap().to_string(), default_image)),
169188
false,
170189
Vec::new(),
171190
),
172191
};
173192

193+
let thumbnail =match&image{
194+
Some(image) =>{
195+
if image.contains(default_image){
196+
None
197+
}else{
198+
Some(format!("{}{}", config::site_domain(), image))
199+
}
200+
}
201+
None =>None,
202+
};
203+
174204
// Parse Markdown
175205
let arena =Arena::new();
176206
let root =parse_document(&arena,&contents,&crate::utils::markdown::options());
@@ -191,6 +221,7 @@ impl Document {
191221
toc_links,
192222
contents,
193223
doc_type,
224+
thumbnail,
194225
};
195226
Ok(document)
196227
}
@@ -419,8 +450,8 @@ impl Collection {
419450
let index =self.open_index(&doc.path);
420451

421452
letmut layout =crate::templates::Layout::new(&doc.title,Some(cluster));
422-
ifletSome(image) =&doc.image{
423-
layout.image(&config::asset_url(image.into()));
453+
ifletSome(image) =&doc.thumbnail{
454+
layout.image(&image);
424455
}
425456
ifletSome(description) =&doc.description{
426457
layout.description(description);
@@ -526,8 +557,12 @@ async fn get_docs(
526557

527558
#[get("/blog")]
528559
asyncfnblog_landing_page(cluster:&Cluster) ->Result<ResponseOk,crate::responses::NotFound>{
529-
let layout =crate::components::layouts::marketing::Base::new("Blog landing page",Some(cluster))
530-
.footer(cluster.context.marketing_footer.to_string());
560+
let layout =Base::new(
561+
"PostgresML blog landing page, home of technical tutorials, general updates and all things AI/ML.",
562+
Some(cluster),
563+
)
564+
.theme(Theme::Docs)
565+
.footer(cluster.context.marketing_footer.to_string());
531566

532567
Ok(ResponseOk(
533568
layout.render(

‎pgml-dashboard/src/components/cards/blog/article_preview/template.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"#,
1010
if meta.author_image.is_some() {
1111
format!(r#"
12-
<imgsrc="blog/{}"class="rounded-circle me-1 author-image"style="height: 3rem;">
12+
<imgsrc="blog/{}"class="rounded-circle me-1 author-image"style="height: 3rem;"alt="Author">
1313
"#, meta.author_image.clone().unwrap())} else {String::new() },
1414

1515
if meta.author.is_some() {
@@ -29,7 +29,7 @@
2929
<aclass="doc-card small-card d-flex"href="{}">
3030
<divclass="meta-layout type-default">
3131
{}
32-
<h6style="color: inherit">{}</h6>
32+
<h4style="color: inherit">{}</h4>
3333
{}
3434
</div>
3535
</a>
@@ -45,7 +45,7 @@ <h6 style="color: inherit">{}</h6>
4545
<% if card_type == String::from("featured") {%>
4646
<aclass="doc-card feature-card d-flex flex-column flex-xxl-row"href="<%- meta.path %>">
4747
<divclass="cover-image-container">
48-
<imgclass="cover-image w-100 h-100"src="<%- meta.image.clone().unwrap_or_else(|| String::new())%>">
48+
<imgclass="cover-image w-100 h-100"src="<%- meta.image.clone().unwrap_or_else(|| String::new())%>"alt="Article cover image">
4949
</div>
5050
<divclass="type-default d-flex align-items-center"style="flex: 2">
5151
<divclass="meta-layout">
@@ -65,7 +65,7 @@ <h2 style="color: inherit"><%- meta.title %></h2>
6565
<aclass="doc-card small-card d-xxl-flex d-none"style="background-image: url('<%- meta.image.clone().unwrap_or_else(|| String::new())%>')"href="<%- meta.path %>">
6666
<divclass="meta-layout type-show-image">
6767
<% if meta.tags.len()> 0 {%><divclass="eyebrow-text"><%- meta.tags[0].clone().to_uppercase() %></div><% }%>
68-
<h6style="color: inherit"><%- meta.title %></h6>
68+
<h4style="color: inherit"><%- meta.title %></h4>
6969
<%- foot %>
7070
</div>
7171
</a>
@@ -75,7 +75,7 @@ <h6 style="color: inherit"><%- meta.title %></h6>
7575

7676
<% } else if card_type == String::from("big") { %>
7777
<aclass="doc-card big-card d-xxl-flex d-none"style="background-image: url('<%- meta.image.clone().unwrap_or_else(|| String::new())%>')"href="<%- meta.path %>">
78-
<divclass="type-show-image h-100 align-items-center">
78+
<divclass="type-show-image h-100w-100align-items-center">
7979
<divclass="meta-layout"style="height: fit-content">
8080
<% if meta.tags.len()> 0 {%><divclass="eyebrow-text"><%- meta.tags[0].clone().to_uppercase() %></div><% } %>
8181
<h2style="color: inherit"><%- meta.title %></h2>
@@ -94,10 +94,10 @@ <h2 style="color: inherit"><%- meta.title %></h2>
9494

9595
<% } else if card_type == String::from("long") { %>
9696
<aclass="doc-card long-card d-xxl-flex d-none"href="<%- meta.path %>">
97-
<imgclass="cover-image"src="<%- meta.image.clone().unwrap_or_else(|| String::new())%>">
97+
<imgclass="cover-image"src="<%- meta.image.clone().unwrap_or_else(|| String::new())%>"alt="Article cover image">
9898
<divclass="meta-layout meta-container">
9999
<% if meta.tags.len()> 0 {%><divclass="eyebrow-text"><%- meta.tags[0].clone().to_uppercase() %></div><% }%>
100-
<h6style="color: inherit"><%- meta.title.clone() %></h6>
100+
<h4style="color: inherit"><%- meta.title.clone() %></h4>
101101
<%- foot %>
102102
</div>
103103
</a>

‎pgml-dashboard/src/components/carousel/carousel_controller.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default class extends Controller {
5656
}
5757

5858
cycle(){
59-
setInterval(()=>{
59+
this.interval=setInterval(()=>{
6060
// maintain paused state through entire loop
6161
letpaused=this.paused
6262

@@ -87,4 +87,8 @@ export default class extends Controller {
8787
}
8888
},1000)
8989
}
90+
91+
disconnect(){
92+
clearInterval(this.interval);
93+
}
9094
}

‎pgml-dashboard/src/components/layouts/head/template.html

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
<% use crate::utils::config; %>
1+
<%
2+
use crate::utils::config;
3+
4+
let thumbnail = image
5+
.unwrap_or_else(|| format!(r#"{}/static/images/homepage-social-share.webp"#, config::site_domain()));
6+
7+
let description = description
8+
.unwrap_or_else(|| String::from("Train and deploy models to make online predictions using only SQL, with an open source Postgres extension."));
9+
%>
210

311
<head>
412
<metacharset="utf-8">
@@ -7,23 +15,12 @@
715
<metaname="author"content="PostgresML">
816
<title><%= title %> – PostgresML</title>
917

10-
<% if description.is_some() { %>
11-
<metaname="description"content="<%= description.clone().unwrap() %>">
12-
<metaproperty="og:description"content="<%= description.clone().unwrap() %>">
13-
<metaname="twitter:description"content="<%= description.clone().unwrap() %>">
14-
<% } else { %>
15-
<metaname="description"content="Train and deploy models to make online predictions using only SQL, with an open source Postgres extension.">
16-
<metaproperty="og:description"content="Train and deploy models to make online predictions using only SQL, with an open source Postgres extension.">
17-
<metaname="twitter:description"content="Train and deploy models to make online predictions using only SQL, with an open source Postgres extension.">
18-
<% } %>
18+
<metaname="description"content="<%- description %>">
19+
<metaproperty="og:description"content="<%- description %>">
20+
<metaname="twitter:description"content="<%- description %>">
1921

20-
<% if image.is_some() { %>
21-
<metaproperty="og:image"content="<%= image.clone().unwrap() %>">
22-
<metaname="twitter:image"content="<%= image.clone().unwrap() %>">
23-
<% } else { %>
24-
<metaproperty="og:image"content="https://postgresml.org/dashboard/static/images/owl_gradient.png">
25-
<metaname="twitter:image"content="https://postgresml.org/dashboard/static/images/owl_gradient.png">
26-
<% } %>
22+
<metaproperty="og:image"content="<%- thumbnail %>">
23+
<metaname="twitter:image"content="<%- thumbnail %>">
2724

2825
<metaproperty="og:site_name"content="PostgresML">
2926
<metaproperty="og:type"content="website">

‎pgml-dashboard/src/components/layouts/marketing/base/mod.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@ use crate::models::User;
55
usecrate::Notification;
66
use pgml_components::component;
77
use sailfish::TemplateOnce;
8+
use std::fmt;
9+
10+
#[derive(Default,Clone)]
11+
pubenumTheme{
12+
#[default]
13+
Marketing,
14+
Docs,
15+
Product,
16+
}
17+
18+
impl fmt::DisplayforTheme{
19+
fnfmt(&self,f:&mut fmt::Formatter) -> fmt::Result{
20+
matchself{
21+
Theme::Marketing =>write!(f,"marketing"),
22+
Theme::Docs =>write!(f,"docs"),
23+
Theme::Product =>write!(f,"product"),
24+
}
25+
}
26+
}
827

928
#[derive(TemplateOnce,Default,Clone)]
1029
#[template(path ="layouts/marketing/base/template.html")]
@@ -14,6 +33,7 @@ pub struct Base {
1433
pubfooter:Option<String>,
1534
pubalert_banner:AlertBanner,
1635
pubuser:Option<User>,
36+
pubtheme:Theme,
1737
}
1838

1939
implBase{
@@ -65,6 +85,11 @@ impl Base {
6585
self
6686
}
6787

88+
pubfntheme(mutself,theme:Theme) ->Self{
89+
self.theme = theme;
90+
self
91+
}
92+
6893
pubfnrender<T>(mutself,template:T) ->String
6994
where
7095
T: sailfish::TemplateOnce,

‎pgml-dashboard/src/components/layouts/marketing/base/template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<%+ head %>
66

7-
<bodydata-bs-theme="dark"data-theme="marketing">
7+
<bodydata-bs-theme="dark"data-theme="<%- theme.to_string() %>">
88
<!-- No smooth scroll on initial page visit -->
99
<script>
1010
window.scroll({

‎pgml-dashboard/src/components/pages/blog/landing_page/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,12 @@ impl LandingPage {
3737
.await
3838
.unwrap();
3939

40-
let image =Some(format!("blog/{}", doc.image.unwrap()));
41-
4240
let meta =DocMeta{
4341
description: doc.description,
4442
author: doc.author,
4543
author_image: doc.author_image,
4644
date: doc.date,
47-
image,
45+
image: doc.image,
4846
featured: doc.featured,
4947
tags: doc.tags,
5048
title: doc.title,

‎pgml-dashboard/src/components/pages/blog/landing_page/template.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
<%+ feature_banner %>
2727
</div>
2828
<divclass="text-center d-flex flex-column gap-xxl-3 gap-1">
29-
<h1class="h1-big">Keep up with<spanclass="text-gradient-blue">our blog</span></h1>
30-
<pclass="m-auto body-large-text"style="max-width: 55rem;">Keep up with all our articles and news, here we upload news about PostgresML, features improvements,generalcontent about machine learningandmuch more. Join our newsletter and stay up to date!</p>
29+
<h1>PostgresML<spanclass="text-gradient-blue">Blog</span></h1>
30+
<pclass="m-auto body-large-text"style="max-width: 55rem;">Technical tutorials,generalupdatesandall things AI/ML.</p>
3131
</div>
3232

3333
<divclass="d-flex justify-content-center my-5">

‎pgml-dashboard/src/utils/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ pub fn asset_url(path: Cow<str>) -> String {
145145
}
146146
}
147147

148+
pubfnsite_domain() ->String{
149+
String::from("https://postgresml.org")
150+
}
151+
148152
fnenv_is_set(name:&str) ->bool{
149153
var(name).is_ok()
150154
}

‎pgml-dashboard/static/css/scss/themes/docs.scss

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[data-theme="docs"] {
22
--h1-big-font-size:80px;
33
--h1-font-size:64px;
4-
--h2-font-size:48px;
5-
--h3-font-size:40px;
6-
--h4-font-size:32px;
7-
--h5-font-size:24px;
8-
--h6-font-size:20px;
4+
--h2-font-size:40px;
5+
--h3-font-size:28px;
6+
--h4-font-size:22px;
7+
--h5-font-size:18px;
8+
--h6-font-size:16px;
99
--eyebrow-font-size:18px;
1010
--legal-font-size:12px;
1111
--body-large-font-size:20px;
@@ -14,11 +14,11 @@
1414

1515
--h1-big-line-height:84px;
1616
--h1-line-height:72px;
17-
--h2-line-height:54px;
18-
--h3-line-height:46px;
19-
--h4-line-height:36px;
20-
--h5-line-height:30px;
21-
--h6-line-height:24px;
17+
--h2-line-height:46px;
18+
--h3-line-height:32px;
19+
--h4-line-height:28px;
20+
--h5-line-height:24px;
21+
--h6-line-height:22px;
2222
--eyebrow-line-height:24px;
2323
--legal-line-height:16px;
2424
--body-large-line-height:26px;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp