Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
David Declerck
www
Commits
f0b1f908
Commit
f0b1f908
authored
Sep 17, 2021
by
Dario Pinto
Browse files
Add title support with lambdasoup, change article to md source
parent
64fa0e2f
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
251 additions
and
290 deletions
+251
-290
dune-project
dune-project
+3
-1
ocpsite.opam
ocpsite.opam
+1
-0
src/content/blog/generating_static_and_portable_executables_with_ocaml.md
.../generating_static_and_portable_executables_with_ocaml.md
+220
-271
src/content/index.md
src/content/index.md
+1
-1
src/dune
src/dune
+1
-1
src/server.ml
src/server.ml
+25
-16
No files found.
dune-project
View file @
f0b1f908
...
@@ -20,4 +20,6 @@
...
@@ -20,4 +20,6 @@
(ubase
(ubase
(>= 0.04))
(>= 0.04))
(markup
(markup
(>= 1.0.2))))
(>= 1.0.2))
(lambdasoup
(>= 0.7.2))))
ocpsite.opam
View file @
f0b1f908
...
@@ -9,6 +9,7 @@ depends: [
...
@@ -9,6 +9,7 @@ depends: [
"omd" {>= "2.0.0~alpha2"}
"omd" {>= "2.0.0~alpha2"}
"ubase" {>= "0.04"}
"ubase" {>= "0.04"}
"markup" {>= "1.0.2"}
"markup" {>= "1.0.2"}
"lambdasoup" {>= "0.7.2"}
]
]
build: [
build: [
["dune" "subst"] {pinned}
["dune" "subst"] {pinned}
...
...
src/content/blog/generating_static_and_portable_executables_with_ocaml.md
View file @
f0b1f908
This diff is collapsed.
Click to expand it.
src/content/index.md
View file @
f0b1f908
...
@@ -114,7 +114,7 @@ We cater to very specific needs. For example, we can translate a “black box”
...
@@ -114,7 +114,7 @@ We cater to very specific needs. For example, we can translate a “black box”
<hr
class=
"featurette-divider"
>
<hr
class=
"featurette-divider"
>
<h
1
class=
"page-subtitle"
align=
"center"
>
You're in good company
</h
1
>
<h
2
class=
"page-subtitle"
align=
"center"
>
You're in good company
</h
2
>
<br
/>
<br
/>
<br
/>
<br
/>
...
...
src/dune
View file @
f0b1f908
(executable
(executable
(public_name server)
(public_name server)
(modules content server template blog blog_content)
(modules content server template blog blog_content)
(libraries dream omd ubase markup))
(libraries dream omd ubase markup
lambdasoup
))
(rule
(rule
(targets template.ml)
(targets template.ml)
...
...
src/server.ml
View file @
f0b1f908
...
@@ -30,6 +30,15 @@ let given_article path =
...
@@ -30,6 +30,15 @@ let given_article path =
Some
(
header
^
(
Omd
.
of_string
article
.
content
|>
Omd
.
to_html
))
Some
(
header
^
(
Omd
.
of_string
article
.
content
|>
Omd
.
to_html
))
end
end
open
Soup
let
title
content
=
try
let
soup
=
content
|>
parse
in
soup
$
"h1"
|>
R
.
leaf_text
with
|
Failure
_e
->
"Harnessing Cutting-Edge Technologies"
let
()
=
let
()
=
Dream
.
run
~
interface
:
"0.0.0.0"
Dream
.
run
~
interface
:
"0.0.0.0"
@@
Dream
.
logger
@@
Dream
.
logger
...
@@ -40,39 +49,39 @@ let () =
...
@@ -40,39 +49,39 @@ let () =
match
page
"index"
with
match
page
"index"
with
|
None
->
Dream
.
empty
`Not_Found
|
None
->
Dream
.
empty
`Not_Found
|
Some
content
->
|
Some
content
->
Dream
.
html
let
title
=
title
content
in
(
Template
.
render_unsafe
~
lang
:
"en"
~
title
:
"title"
~
content
)
)
Dream
.
html
(
Template
.
render_unsafe
~
lang
:
"en"
~
title
~
content
)
)
;
Dream
.
get
"/blog/category"
(
fun
_request
->
;
Dream
.
get
"/blog/category"
(
fun
_request
->
let
content
=
Blog
.
category_home
in
let
content
=
Blog
.
category_home
in
Dream
.
html
let
title
=
title
content
in
(
Template
.
render_unsafe
~
lang
:
"en"
~
title
:
"Categories"
~
content
)
)
Dream
.
html
(
Template
.
render_unsafe
~
lang
:
"en"
~
title
~
content
)
)
;
Dream
.
get
"/blog/category/:cat"
(
fun
request
->
;
Dream
.
get
"/blog/category/:cat"
(
fun
request
->
let
content
=
Blog
.
given_category
(
Dream
.
param
"cat"
request
)
in
let
content
=
Blog
.
given_category
(
Dream
.
param
"cat"
request
)
in
Dream
.
html
let
title
=
title
content
in
(
Template
.
render_unsafe
~
lang
:
"en"
~
title
:
"Category"
~
content
)
)
Dream
.
html
(
Template
.
render_unsafe
~
lang
:
"en"
~
title
~
content
)
)
;
Dream
.
get
"/blog/authors"
(
fun
_request
->
;
Dream
.
get
"/blog/authors"
(
fun
_request
->
let
content
=
Blog
.
authors_home
in
let
content
=
Blog
.
authors_home
in
Dream
.
html
let
title
=
title
content
in
(
Template
.
render_unsafe
~
lang
:
"en"
~
title
:
"Authors"
~
content
)
)
Dream
.
html
(
Template
.
render_unsafe
~
lang
:
"en"
~
title
~
content
)
)
;
Dream
.
get
"/blog/authors/:author"
(
fun
request
->
;
Dream
.
get
"/blog/authors/:author"
(
fun
request
->
let
content
=
Blog
.
given_author
(
Dream
.
param
"author"
request
)
in
let
content
=
Blog
.
given_author
(
Dream
.
param
"author"
request
)
in
Dream
.
html
let
title
=
title
content
in
(
Template
.
render_unsafe
~
lang
:
"en"
~
title
:
"Author"
~
content
)
)
Dream
.
html
(
Template
.
render_unsafe
~
lang
:
"en"
~
title
~
content
)
)
;
Dream
.
get
"/blog/:title"
(
fun
request
->
;
Dream
.
get
"/blog/:title"
(
fun
request
->
match
given_article
(
Dream
.
param
"title"
request
)
with
match
given_article
(
Dream
.
param
"title"
request
)
with
|
None
->
Dream
.
empty
`Not_Found
|
None
->
Dream
.
empty
`Not_Found
|
Some
content
->
|
Some
content
->
Dream
.
html
let
title
=
title
content
in
(
Template
.
render_unsafe
~
lang
:
"en"
~
title
:
"title"
~
content
)
)
Dream
.
html
(
Template
.
render_unsafe
~
lang
:
"en"
~
title
~
content
)
)
;
Dream
.
get
"/blog"
(
fun
_request
->
;
Dream
.
get
"/blog"
(
fun
_request
->
let
content
=
Blog
.
home_page
in
let
content
=
Blog
.
home_page
in
Dream
.
html
let
title
=
title
content
in
(
Template
.
render_unsafe
~
lang
:
"en"
~
title
:
"title"
~
content
)
)
Dream
.
html
(
Template
.
render_unsafe
~
lang
:
"en"
~
title
~
content
)
)
;
Dream
.
get
"/:page"
(
fun
request
->
;
Dream
.
get
"/:page"
(
fun
request
->
match
page
(
Dream
.
param
"page"
request
)
with
match
page
(
Dream
.
param
"page"
request
)
with
|
None
->
Dream
.
empty
`Not_Found
|
None
->
Dream
.
empty
`Not_Found
|
Some
content
->
|
Some
content
->
Dream
.
html
let
title
=
title
content
in
(
Template
.
render_unsafe
~
lang
:
"en"
~
title
:
"title"
~
content
)
)
Dream
.
html
(
Template
.
render_unsafe
~
lang
:
"en"
~
title
~
content
)
)
]
]
@@
Dream
.
not_found
@@
Dream
.
not_found
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment