Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
Org Flux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stephen D
Org Flux
Commits
97053b87
Commit
97053b87
authored
2 years ago
by
Stephen D
Browse files
Options
Downloads
Patches
Plain Diff
hidden posts
parent
7f97b987
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/blog.rs
+3
-1
3 additions, 1 deletion
src/blog.rs
src/post.rs
+9
-0
9 additions, 0 deletions
src/post.rs
with
12 additions
and
1 deletion
src/blog.rs
+
3
−
1
View file @
97053b87
...
@@ -51,7 +51,9 @@ impl Blog {
...
@@ -51,7 +51,9 @@ impl Blog {
);
);
for
post
in
&
self
.posts
{
for
post
in
&
self
.posts
{
content
.push_str
(
&
post
.link
()
?
);
if
!
post
.hidden
{
content
.push_str
(
&
post
.link
()
?
);
}
}
}
content
.push_str
(
"</table>"
);
content
.push_str
(
"</table>"
);
...
...
This diff is collapsed.
Click to expand it.
src/post.rs
+
9
−
0
View file @
97053b87
...
@@ -14,6 +14,7 @@ use crate::{
...
@@ -14,6 +14,7 @@ use crate::{
#[derive(Eq)]
#[derive(Eq)]
pub
struct
Post
{
pub
struct
Post
{
pub
hidden
:
bool
,
pub
title
:
String
,
pub
title
:
String
,
pub
date
:
Option
<
NaiveDate
>
,
pub
date
:
Option
<
NaiveDate
>
,
pub
index
:
u32
,
pub
index
:
u32
,
...
@@ -139,6 +140,7 @@ impl PartialEq for Post {
...
@@ -139,6 +140,7 @@ impl PartialEq for Post {
}
}
struct
PostParser
{
struct
PostParser
{
hidden
:
bool
,
title
:
Option
<
String
>
,
title
:
Option
<
String
>
,
date
:
Option
<
NaiveDate
>
,
date
:
Option
<
NaiveDate
>
,
index
:
Option
<
u32
>
,
index
:
Option
<
u32
>
,
...
@@ -150,6 +152,7 @@ struct PostParser {
...
@@ -150,6 +152,7 @@ struct PostParser {
impl
PostParser
{
impl
PostParser
{
fn
new
(
base_path
:
&
Path
,
url
:
String
)
->
anyhow
::
Result
<
Self
>
{
fn
new
(
base_path
:
&
Path
,
url
:
String
)
->
anyhow
::
Result
<
Self
>
{
Ok
(
Self
{
Ok
(
Self
{
hidden
:
false
,
title
:
None
,
title
:
None
,
date
:
None
,
date
:
None
,
index
:
None
,
index
:
None
,
...
@@ -163,6 +166,10 @@ impl PostParser {
...
@@ -163,6 +166,10 @@ impl PostParser {
impl
Parser
<
Post
>
for
PostParser
{
impl
Parser
<
Post
>
for
PostParser
{
fn
start
(
&
mut
self
,
e
:
&
Element
)
->
anyhow
::
Result
<
()
>
{
fn
start
(
&
mut
self
,
e
:
&
Element
)
->
anyhow
::
Result
<
()
>
{
match
e
{
match
e
{
Element
::
Keyword
(
Keyword
{
key
,
..
})
if
key
==
"HIDDEN"
=>
{
self
.hidden
=
true
;
}
Element
::
Keyword
(
Keyword
{
key
,
value
,
..
})
if
key
==
"TITLE"
=>
{
Element
::
Keyword
(
Keyword
{
key
,
value
,
..
})
if
key
==
"TITLE"
=>
{
if
self
.title
.is_some
()
{
if
self
.title
.is_some
()
{
bail!
(
"Post has more than one title"
);
bail!
(
"Post has more than one title"
);
...
@@ -202,6 +209,7 @@ impl Parser<Post> for PostParser {
...
@@ -202,6 +209,7 @@ impl Parser<Post> for PostParser {
}
}
fn
render
(
self
)
->
anyhow
::
Result
<
Post
>
{
fn
render
(
self
)
->
anyhow
::
Result
<
Post
>
{
let
hidden
=
self
.hidden
;
let
title
=
self
.title
.context
(
"Could not find post title"
)
?
;
let
title
=
self
.title
.context
(
"Could not find post title"
)
?
;
let
date
=
self
.date
;
let
date
=
self
.date
;
let
index
=
self
.index
.unwrap_or
(
u32
::
MAX
);
let
index
=
self
.index
.unwrap_or
(
u32
::
MAX
);
...
@@ -209,6 +217,7 @@ impl Parser<Post> for PostParser {
...
@@ -209,6 +217,7 @@ impl Parser<Post> for PostParser {
let
url
=
self
.url
;
let
url
=
self
.url
;
Ok
(
Post
{
Ok
(
Post
{
hidden
,
title
,
title
,
date
,
date
,
index
,
index
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment