Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
org-static
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-static
Commits
07849872
Commit
07849872
authored
2 years ago
by
Stephen D
Browse files
Options
Downloads
Patches
Plain Diff
video working. need to add the correct content type
parent
5a429edc
No related branches found
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
src/assets/style.css
+6
-0
6 additions, 0 deletions
src/assets/style.css
src/blog.rs
+9
-2
9 additions, 2 deletions
src/blog.rs
src/main.rs
+1
-0
1 addition, 0 deletions
src/main.rs
src/misc.rs
+42
-0
42 additions, 0 deletions
src/misc.rs
src/parser.rs
+7
-0
7 additions, 0 deletions
src/parser.rs
with
65 additions
and
2 deletions
src/assets/style.css
+
6
−
0
View file @
07849872
...
...
@@ -40,7 +40,13 @@ a:visited {
.header-container
{
display
:
flex
;
}
.header-date
{
white-space
:
nowrap
;
margin
:
1em
1em
1em
auto
;
}
img
,
video
{
max-width
:
100%
;
max-width
:
100%
;
}
This diff is collapsed.
Click to expand it.
src/blog.rs
+
9
−
2
View file @
07849872
...
...
@@ -2,12 +2,13 @@ use anyhow::Error;
use
std
::
collections
::
HashMap
;
use
warp
::
hyper
::
StatusCode
;
use
crate
::{
image
::
MyImage
,
load
::
load_from_path
,
post
::
Post
,
resp
::
Response
};
use
crate
::{
image
::
MyImage
,
load
::
load_from_path
,
misc
::
Misc
,
post
::
Post
,
resp
::
Response
};
pub
struct
Blog
{
//pages: Vec<Page>,
posts
:
Vec
<
Post
>
,
imgs
:
Vec
<
MyImage
>
,
misc
:
Vec
<
Misc
>
,
}
impl
Blog
{
...
...
@@ -20,7 +21,9 @@ impl Blog {
let
imgs
=
load_from_path
(
"assets/img"
,
""
)
?
;
Ok
(
Self
{
posts
,
imgs
})
let
misc
=
load_from_path
(
"assets/misc"
,
"misc"
)
?
;
Ok
(
Self
{
posts
,
imgs
,
misc
})
}
fn
home
(
&
self
)
->
Result
<
String
,
Error
>
{
...
...
@@ -77,6 +80,10 @@ impl TryFrom<Blog> for RenderedBlog {
pages
.insert
(
original_url
,
original
);
}
for
m
in
b
.misc
{
pages
.insert
(
m
.url
.clone
(),
m
.response
());
}
let
not_found
=
Response
::
html
(
dress_page
(
"Page not found"
,
include_str!
(
"assets/404.html"
),
...
...
This diff is collapsed.
Click to expand it.
src/main.rs
+
1
−
0
View file @
07849872
...
...
@@ -13,6 +13,7 @@ mod blog;
mod
date
;
mod
image
;
mod
load
;
mod
misc
;
mod
parser
;
mod
post
;
mod
resp
;
...
...
This diff is collapsed.
Click to expand it.
src/misc.rs
0 → 100644
+
42
−
0
View file @
07849872
use
std
::{
fs
::
File
,
io
::
Read
};
use
anyhow
::
Context
;
use
crate
::{
load
::
Loadable
,
resp
::
Response
,
util
::
slugify
};
pub
struct
Misc
{
pub
url
:
String
,
content_type
:
&
'static
str
,
data
:
Vec
<
u8
>
,
}
impl
Loadable
for
Misc
{
fn
load
(
path
:
&
std
::
path
::
Path
,
slug_prefix
:
&
str
)
->
anyhow
::
Result
<
Self
>
{
let
file_name
=
path
.file_name
()
.context
(
"Could not get file name"
)
?
.to_str
()
.context
(
"Could not convert filename into string"
)
?
.to_owned
();
let
url
=
slugify
(
&
format!
(
"/{slug_prefix}/{file_name}"
));
let
mut
data
=
vec!
[];
File
::
open
(
path
)
?
.read_to_end
(
&
mut
data
)
?
;
Ok
(
Self
{
data
,
content_type
:
"todo"
,
url
,
})
}
}
impl
Misc
{
pub
fn
response
(
self
)
->
Response
{
Response
{
content_type
:
self
.content_type
,
data
:
self
.data
,
}
}
}
This diff is collapsed.
Click to expand it.
src/parser.rs
+
7
−
0
View file @
07849872
use
anyhow
::
bail
;
use
anyhow
::
Context
;
use
anyhow
::
Error
;
use
orgize
::
elements
::
Keyword
;
use
orgize
::
elements
::
Link
;
use
orgize
::
elements
::
Timestamp
;
use
orgize
::{
...
...
@@ -89,6 +90,12 @@ impl HtmlHandler<Error> for CustomHtmlHandler {
Element
::
Link
(
Link
{
path
,
desc
})
if
desc
.is_none
()
=>
{
write!
(
w
,
r#"<a href="/img/{path}"><img src="/thumb/{path}">"#
)
?
;
}
Element
::
Keyword
(
Keyword
{
key
,
value
,
..
})
if
key
==
"VIDEO"
=>
{
write!
(
w
,
r#"<video controls="controls"><source src="{value}"></video>"#
)
?
;
}
// fallback to default handler
_
=>
self
.fallback
.start
(
w
,
element
)
?
,
}
...
...
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