Skip to content

Commit 69c7f79

Browse files
committed
remove blogs remnant
1 parent 5648122 commit 69c7f79

File tree

6 files changed

+59
-68
lines changed

6 files changed

+59
-68
lines changed

pgml-dashboard/src/api/cms.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ impl Collection {
100100
match node {
101101
Node::List(list) => {
102102
self.index = self.get_sub_links(&list).expect(
103-
format!("Could not parse list of index links: {summary_path:?}")
104-
.as_str(),
103+
format!("Could not parse list of index links: {summary_path:?}").as_str(),
105104
);
106105
break;
107106
}
@@ -172,7 +171,12 @@ impl Collection {
172171
Ok(links)
173172
}
174173

175-
async fn render<'a>(&self, path: &'a PathBuf, cluster: &Cluster, collection: &Collection) -> Result<ResponseOk, Status> {
174+
async fn render<'a>(
175+
&self,
176+
path: &'a PathBuf,
177+
cluster: &Cluster,
178+
collection: &Collection,
179+
) -> Result<ResponseOk, Status> {
176180
// Read to string0
177181
let contents = match tokio::fs::read_to_string(&path).await {
178182
Ok(contents) => {
@@ -245,11 +249,16 @@ impl Collection {
245249

246250
// Handle navigation
247251
// TODO organize this functionality in the collection to cleanup
248-
let index: Vec<IndexLink> = self.index.clone().iter_mut().map(|nav_link| {
249-
let mut nav_link = nav_link.clone();
250-
nav_link.should_open(&path);
251-
nav_link
252-
}).collect();
252+
let index: Vec<IndexLink> = self
253+
.index
254+
.clone()
255+
.iter_mut()
256+
.map(|nav_link| {
257+
let mut nav_link = nav_link.clone();
258+
nav_link.should_open(&path);
259+
nav_link
260+
})
261+
.collect();
253262

254263
let user = if cluster.context.user.is_anonymous() {
255264
None

pgml-dashboard/src/components/cms/index_link/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ impl IndexLink {
4646
pub fn should_open(&mut self, path: &std::path::Path) -> &mut Self {
4747
let path_prefix = path.with_extension("");
4848
let path_str = path_prefix.to_str().expect("must be a string");
49-
let suffix = path_str.replace(crate::utils::config::cms_dir().to_str().unwrap(), "").replace("README", "");
49+
let suffix = path_str
50+
.replace(crate::utils::config::cms_dir().to_str().unwrap(), "")
51+
.replace("README", "");
5052
if suffix.is_empty() {
5153
// special case for the index url that would otherwise match everything
5254
if self.href.is_empty() {

pgml-dashboard/src/components/navigation/navbar/marketing/template.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
let company_links = vec![
1515
StaticNavLink::new("About".to_string(), "/about".to_string()).icon("smart_toy"),
16+
StaticNavLink::new("Careers".to_string(), "/careers/".to_string()).icon("work")
1617
StaticNavLink::new("Contact".to_string(), "/contact".to_string()).icon("alternate_email")
1718
];
1819

pgml-dashboard/src/components/sections/footers/marketing_footer/mod.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,12 @@ impl MarketingFooter {
2222
],
2323
resources: vec![
2424
StaticNavLink::new("Documentation".into(), "/docs/".into()),
25-
StaticNavLink::new(
26-
"Blog".into(),
27-
"/blog/".into(),
28-
),
25+
StaticNavLink::new("Blog".into(), "/blog/".into()),
26+
],
27+
company: vec![
28+
StaticNavLink::new("Careers".into(), "/careers/".into()),
29+
StaticNavLink::new("Contact".into(), "mailto:team@postgresml.org".into()),
2930
],
30-
company: vec![StaticNavLink::new(
31-
"Contact".into(),
32-
"mailto:team@postgresml.org".into(),
33-
)],
3431
}
3532
}
3633

pgml-dashboard/src/utils/config.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ lazy_static! {
1111
}
1212

1313
struct Config {
14-
blogs_dir: PathBuf,
1514
cms_dir: PathBuf,
1615
deployment: String,
1716
dev_mode: bool,
@@ -70,7 +69,6 @@ impl Config {
7069
git_sha: env_string_required("GIT_SHA"),
7170
sentry_dsn: env_string_optional("SENTRY_DSN"),
7271
static_dir: env_path_default("DASHBOARD_STATIC_DIRECTORY", "static"),
73-
blogs_dir: env_path_default("DASHBOARD_CONTENT_DIRECTORY", "content"),
7472
cms_dir: env_path_default("DASHBOARD_CMS_DIRECTORY", "../pgml-docs"),
7573
search_index_dir: env_path_default("SEARCH_INDEX_DIRECTORY", "search_index"),
7674
render_errors: env_is_set("RENDER_ERRORS") || dev_mode,
@@ -105,10 +103,6 @@ pub fn static_dir<'a>() -> &'a Path {
105103
&CONFIG.static_dir
106104
}
107105

108-
pub fn blogs_dir<'a>() -> &'a Path {
109-
&CONFIG.blogs_dir
110-
}
111-
112106
pub fn cms_dir<'a>() -> &'a Path {
113107
&CONFIG.cms_dir
114108
}

pgml-dashboard/src/utils/markdown.rs

Lines changed: 33 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -536,31 +536,29 @@ where
536536
pub fn nest_relative_links(node: &mut markdown::mdast::Node, path: &PathBuf) {
537537
let _ = iter_mut_all(node, &mut |node| {
538538
match node {
539-
markdown::mdast::Node::Link(ref mut link) => {
540-
match Url::parse(&link.url) {
541-
Ok(url) => {
542-
if !url.has_host() {
543-
let mut url_path = url.path().to_string();
544-
let url_path_path = Path::new(&url_path);
545-
match url_path_path.extension() {
546-
Some(ext) => {
547-
if ext.to_str() == Some(".md") {
548-
let base = url_path_path.with_extension("");
549-
url_path = base.into_os_string().into_string().unwrap();
550-
}
551-
}
552-
_ => {
553-
warn!("not markdown path: {:?}", path)
539+
markdown::mdast::Node::Link(ref mut link) => match Url::parse(&link.url) {
540+
Ok(url) => {
541+
if !url.has_host() {
542+
let mut url_path = url.path().to_string();
543+
let url_path_path = Path::new(&url_path);
544+
match url_path_path.extension() {
545+
Some(ext) => {
546+
if ext.to_str() == Some(".md") {
547+
let base = url_path_path.with_extension("");
548+
url_path = base.into_os_string().into_string().unwrap();
554549
}
555550
}
556-
link.url = path.join(url_path).into_os_string().into_string().unwrap();
551+
_ => {
552+
warn!("not markdown path: {:?}", path)
553+
}
557554
}
558-
}
559-
Err(e) => {
560-
warn!("could not parse url in markdown: {}", e)
555+
link.url = path.join(url_path).into_os_string().into_string().unwrap();
561556
}
562557
}
563-
}
558+
Err(e) => {
559+
warn!("could not parse url in markdown: {}", e)
560+
}
561+
},
564562
_ => (),
565563
};
566564

@@ -623,26 +621,21 @@ pub fn get_title<'a>(root: &'a AstNode<'a>) -> anyhow::Result<String> {
623621
pub fn get_image<'a>(root: &'a AstNode<'a>) -> Option<String> {
624622
let re = regex::Regex::new(r#"<img src="([^"]*)" alt="([^"]*)""#).unwrap();
625623
let mut image = None;
626-
iter_nodes(root, &mut |node| {
627-
match &node.data.borrow().value {
628-
&NodeValue::HtmlBlock(ref html) => {
629-
match re.captures(&html.literal) {
630-
Some(c) => {
631-
if &c[2] != "Author" {
632-
image = Some(c[1].to_string());
633-
Ok(false)
634-
} else {
635-
Ok(true)
636-
}
637-
},
638-
None => {
639-
Ok(true)
640-
}
624+
iter_nodes(root, &mut |node| match &node.data.borrow().value {
625+
&NodeValue::HtmlBlock(ref html) => match re.captures(&html.literal) {
626+
Some(c) => {
627+
if &c[2] != "Author" {
628+
image = Some(c[1].to_string());
629+
Ok(false)
630+
} else {
631+
Ok(true)
641632
}
642633
}
643-
_ => Ok(true)
644-
}
645-
}).ok()?;
634+
None => Ok(true),
635+
},
636+
_ => Ok(true),
637+
})
638+
.ok()?;
646639
return image;
647640
}
648641

@@ -1328,13 +1321,8 @@ impl SearchIndex {
13281321
// TODO imrpove this .display().to_string()
13291322
let guides = glob::glob(&config::cms_dir().join("docs/**/*.md").display().to_string())
13301323
.expect("glob failed");
1331-
let blogs = glob::glob(
1332-
&config::blogs_dir()
1333-
.join("/blog/**/*.md")
1334-
.display()
1335-
.to_string(),
1336-
)
1337-
.expect("glob failed");
1324+
let blogs = glob::glob(&config::cms_dir().join("blog/**/*.md").display().to_string())
1325+
.expect("glob failed");
13381326
guides
13391327
.chain(blogs)
13401328
.map(|path| path.expect("glob path failed"))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy