Skip to content

Commit

Permalink
Give Local Blogs a Page and RSS Feeds (#1459)
Browse files Browse the repository at this point in the history
- local blogs get their own dedicated page that lists their posts at https://ocaml.org/blog/[SOURCE_ID], as well as their own RSS feed at https://ocaml.org/blog/[SOURCE_ID]/feed.xml.
- For more clarity regarding the input format: we explicitly distinguish between the local blogs hosted on ocaml.org (they now live in the folder data/planet-local-blogs), and the external sources and individual posts (living in data/planet) when parsing.
  • Loading branch information
sabine authored Aug 22, 2023
1 parent d964447 commit 3fa1015
Show file tree
Hide file tree
Showing 32 changed files with 438 additions and 269 deletions.
68 changes: 0 additions & 68 deletions data/changelog/opam/2014-11-03-merlin-2-0-0-released.md

This file was deleted.

2 changes: 1 addition & 1 deletion data/changelog/opam/2023-05-31-opam-2-1-5.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ We are pleased to announce the patch release of [opam 2.1.5](https://github.com/

This opam release consists of [backported](https://github.com/ocaml/opam/issues/5444) bug & security fixes:

* Security issue: fix opam installing packages without checking their checksum when the local cache is corrupted in some case ([#5538](https://github.com/ocaml/opam/pull/5538)), you can find more information [there](/blog/security-in-opams-cache-handling-before-215).
* Security issue: fix opam installing packages without checking their checksum when the local cache is corrupted in some case ([#5538](https://github.com/ocaml/opam/pull/5538)), you can find more information [there](/blog/opam/opam-2-1-5-local-cache).
* Variables are now expanded in build-env (as for setenv) ([#5352](https://github.com/ocaml/opam/pull/5352))
* Correctly handle empty environment variable additions ([#5350](https://github.com/ocaml/opam/pull/5350))
* Skip empty environment variable additions ([#5350](https://github.com/ocaml/opam/pull/5350))
Expand Down
4 changes: 4 additions & 0 deletions data/planet-local-blogs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- id: opam
name: The Opam blog
description: |
Tips and Tricks, as well as beind-the-scenes updates from the Opam developers
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ title: "Deprecating opam 1.2.0"
authors: [ "Anil Madhavapeddy", "Louis Gesbert" ]
date: 2017-06-14T00:00:00-00:00
description: "Announcement of the deprecation of opam 1.2.0 in favour of 1.2.2"
source:
name: Opam blog
url: ""
---

Opam 1.2.0 will be actively deprecated in favour of opam 1.2.2, which now becomes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ title: "OPAM 1.2 and Travis CI"
authors: [ "Thomas Gazagnaire" ]
date: 2014-12-18T00:00:00-00:00
description: "OPAM 1.2 and Travis CI"
source:
name: Opam blog
url: ""
---

The [new pinning feature][pin] of OPAM 1.2 enables new interesting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ title: "Last stretch! Repository upgrade and opam 2.0.0 roadmap"
authors: [ "Raja Boujbel", "Louis Gesbert"]
date: 2018-08-02T00:00:00-00:00
description: "opam respository upgrade and opam 2.0.0 roadmap"
source:
name: Opam blog
url: ""
---

A few days ago, we released [opam 2.0.0~rc4](https://opam.ocaml.org/blog/opam-2-0-0-rc4/), and explained that this final release candidate was expected be promoted to 2.0.0, in sync with an upgrade to the [opam package repository](https://github.com/ocaml/opam-repository). So here are the details about this!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ title: "Security in opam's cache handling (before 2.1.5)"
authors: [ "Reynir", "Hannes"]
date: 2023-05-31T00:00:00-00:00
description: We are pleased that opam 2.1.5 has hit the road, since it contains a security fix since the local cache is considered trusted, and not all checksums are verified.
source:
name: Opam blog
url: ""
---

We are pleased that opam 2.1.5 has hit the road, since it contains a security fix since the local cache is considered trusted, and not all checksums are verified.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ title: "opam 2.0 tips"
authors: [ "Louis Gesbert" ]
date: 2019-03-12T00:00:00-00:00
description: "Some tips on the new features introduced in opam 2.0"
source:
name: Opam blog
url: ""
---

This blog post looks back on some of the improvements in opam 2.0, and gives
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ title: "new opam features: \"opam build\""
authors: [ "Louis Gesbert" ]
date: 2017-03-16T00:00:00-00:00
description: "Presentation of the opam build command introduced in opam 2.0"
source:
name: Opam blog
url: ""
---

> UPDATE: after discussions following this post, this feature was abandoned with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ title: "new opam features: more expressive dependencies"
authors: [ "Louis Gesbert" ]
date: 2017-05-11T00:00:00-00:00
description: "Presentation of the new opam 2.0 features"
source:
name: Opam blog
url: ""
---

This blog will cover yet another aspect of the improvements opam 2.0 has over opam 1.2. I may be a little more technical than previous issues, as it covers a feature directed specifically at packagers and repository maintainers, and regarding the package definition format.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ title: "Why we use OPAM for XenServer development"
authors: [ "Dave Scott" ]
date: 2015-02-18T00:00:00-00:00
description: "How and why OPAM is used at Xen."
source:
name: Opam blog
url: ""
---

*This is a guest post from an OPAM user about how they use it. If you would like to post
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ title: "new opam features: \"opam install <dir>\""
authors: [ "Louis Gesbert" ]
date: 2017-05-04T00:00:00-00:00
description: "Presentation of the new opam install <dir> feature introduced in opam 2.0"
source:
name: Opam blog
url: ""
---

After the [opam build](../opam-build) feature was announced followed a lot of discussions, mainly having to do with its interface, and misleading name. The base features it offered, though, were still widely asked for:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ title: "new opam features: local switches"
authors: [ "Louis Gesbert" ]
date: 2017-04-27T00:00:00-00:00
description: "Presentation of the local switches feature introduced in opam 2.0"
source:
name: Opam blog
url: ""
---

Among the areas we wanted to improve on for opam 2.0 was the handling of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ title: "Signing the OPAM repository"
authors: [ "Louis Gesbert", "Hannes Mehnert" ]
date: 2015-06-05T00:00:00-00:00
description: "Proposal for a secure distribution of OCaml packages"
source:
name: Opam blog
url: ""
---

> NOTE (September 2016): updated proposal from OCaml 2016 workshop is
Expand Down
1 change: 1 addition & 0 deletions dune
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
(target feed.xml)
(deps
(source_tree %{workspace_root}/data/planet)
(source_tree %{workspace_root}/data/planet-local-blogs)
(:ood_gen %{workspace_root}/tool/ood-gen/bin/gen.exe))
(action
(with-stdout-to
Expand Down
3 changes: 2 additions & 1 deletion src/global/url.ml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ let release v = "/releases/" ^ v
let workshops = "/workshops"
let workshop v = "/workshops/" ^ v
let blog = "/blog"
let blog_post v = "/blog/" ^ v
let blog_post source v = "/blog/" ^ source ^ "/" ^ v
let news = "/news"
let news_post v = "/news/" ^ v
let jobs = "/jobs"
Expand All @@ -69,6 +69,7 @@ let learn = "/docs"
let learn_get_started = "/docs/get-started"
let learn_language = "/docs/language"
let learn_guides = "/docs/guides"
let local_blog source = "/blog/" ^ source
let platform = "/docs/platform"
let ocaml_on_windows = "/docs/ocaml-on-windows"
let tutorial name = "/docs/" ^ name
Expand Down
13 changes: 11 additions & 2 deletions src/ocamlorg_data/data.ml
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,17 @@ end
module Planet = struct
include Planet

let featured = List.filter (fun x -> x.featured) all
let get_by_slug slug = List.find_opt (fun x -> String.equal slug x.slug) all
module Post = struct
include Planet.Post
end

module LocalBlog = struct
include Planet.LocalBlog

let get_by_id id = List.find_opt (fun x -> String.equal x.source.id id) all
end

let featured_posts = List.filter (fun (x : Post.t) -> x.featured) Post.all
end

module Opam_user = struct
Expand Down
45 changes: 28 additions & 17 deletions src/ocamlorg_data/data.mli
Original file line number Diff line number Diff line change
Expand Up @@ -263,26 +263,37 @@ module Watch : sig
end

module Planet : sig
module Source : sig
type t = { id : string option; name : string; url : string }
type source = {
id : string;
name : string;
url : string;
description : string;
}

module Post : sig
type t = {
title : string;
url : string option;
slug : string;
source : source;
description : string option;
authors : string list option;
date : string;
preview_image : string option;
featured : bool;
body_html : string;
}

val all : t list
end

type t = {
title : string;
slug : string;
source : Source.t;
description : string option;
authors : string list option;
url : string option;
date : string;
preview_image : string option;
featured : bool;
body_html : string;
}
module LocalBlog : sig
type t = { source : source; posts : Post.t list; rss_feed : string }

val featured : t list
val all : t list
val get_by_slug : string -> t option
val get_by_id : string -> t option
end

val featured_posts : Post.t list
end

module Opam_user : sig
Expand Down
4 changes: 4 additions & 0 deletions src/ocamlorg_frontend/dune
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@
(target learn.ml)
(action
(run %{bin:dream_eml} %{dep:learn.eml} --workspace %{workspace_root})))
(rule
(target local_blog.ml)
(action
(run %{bin:dream_eml} %{dep:local_blog.eml} --workspace %{workspace_root})))
(rule
(target install.ml)
(action
Expand Down
1 change: 1 addition & 0 deletions src/ocamlorg_frontend/ocamlorg_frontend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ let install = Install.render
let industrial_users = Industrial_users.render
let jobs = Jobs.render
let learn = Learn.render
let local_blog = Local_blog.render
let news = News.render
let news_post = News_post.render
let not_found = Not_found.render
Expand Down
24 changes: 12 additions & 12 deletions src/ocamlorg_frontend/pages/blog.eml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let render ~(featured : Data.Planet.t list) ~(planet : Data.Planet.t list) ~planet_pages_number ~planet_page ~(news : Data.News.t list) =
let render ~(featured : Data.Planet.Post.t list) ~(planet : Data.Planet.Post.t list) ~planet_pages_number ~planet_page ~(news : Data.News.t list) =
Layout.render
~title:"OCaml Blog"
~description:"Recent news and blog posts from the OCaml community."
Expand All @@ -10,17 +10,17 @@ Layout.render

<div class="grid grid-cols-1 md:grid-cols-3 gap-16">
<div class="col-span-2">
<h2 class="text-lg mt-0 font-semibold border-b border-current text-primary-600 pb-3">OCaml Community Blog</h2>
<h2 class="text-lg mt-0 font-semibold border-b border-current text-primary-600 pb-3">The OCaml Planet</h2>

<div class="mt-12 space-y-12">
<% featured |> List.iter (fun (item : Data.Planet.t) -> %>
<% featured |> List.iter (fun (item : Data.Planet.Post.t) -> %>
<div>
<div class="font-semibold text-lighter">FEATURED</div>
<div class="flex flex-col-reverse lg:flex-row lg:gap-12">
<div class="space-y-3 mt-6 lg:mt-0 flex flex-col flex-1">
<a href="<%s Option.value ~default:(Url.blog_post item.slug) item.url %>"
<a href="<%s Option.value ~default:(Url.blog_post item.source.id item.slug) item.url %>"
class="block text-xl font-semibold hover:text-primary-600"><%s item.title %></a>
<a href="<%s Option.value ~default:(Url.blog_post item.slug) item.url %>" class="text-lighter">
<a href="<%s Option.value ~default:(Url.blog_post item.source.id item.slug) item.url %>" class="text-lighter">
<%s Option.value ~default:"" item.description %>
</a>
<div class="text-lighter flex space-x-2.5 text-sm">
Expand All @@ -29,23 +29,23 @@ Layout.render
</div>
<% (match item.preview_image with | None -> %>
<div class="flex-none w-64">
<a href="<%s Option.value ~default:(Url.blog_post item.slug) item.url %>"><img class="w-full" src="<%s Ocamlorg_static.Asset.url "logo.svg" %>" alt="default logo"></a>
<a href="<%s Option.value ~default:(Url.blog_post item.source.id item.slug) item.url %>"><img class="w-full" src="<%s Ocamlorg_static.Asset.url "logo.svg" %>" alt="default logo"></a>
</div>
<% | Some image -> %>
<div class="flex-none w-64">
<a href="<%s Option.value ~default:(Url.blog_post item.slug) item.url %>"><img class="w-full" src="<%s image %>" alt=""></a>
<a href="<%s Option.value ~default:(Url.blog_post item.source.id item.slug) item.url %>"><img class="w-full" src="<%s image %>" alt=""></a>
</div>
<% ); %>
</div>
</div>
<% ); %>

<% planet |> List.iter (fun (item : Data.Planet.t) -> %>
<% planet |> List.iter (fun (item : Data.Planet.Post.t) -> %>
<div class="flex flex-col-reverse lg:flex-row lg:gap-12">
<div class="space-y-3 mt-6 lg:mt-0 flex flex-col flex-1">
<a href="<%s Option.value ~default:(Url.blog_post item.slug) item.url %>"
<a href="<%s Option.value ~default:(Url.blog_post item.source.id item.slug) item.url %>"
class="block text-xl font-semibold hover:text-primary-600"><%s item.title %></a>
<a href="<%s Option.value ~default:(Url.blog_post item.slug) item.url %>" class="text-lighter">
<a href="<%s Option.value ~default:(Url.blog_post item.source.id item.slug) item.url %>" class="text-lighter">
<%s Option.value ~default:"" item.description %>
</a>
<div class="text-lighter flex space-x-2.5 text-sm">
Expand All @@ -54,11 +54,11 @@ Layout.render
</div>
<% (match item.preview_image with | None -> %>
<div class="flex-none w-64">
<a href="<%s Option.value ~default:(Url.blog_post item.slug) item.url %>"><img class="w-full" src="<%s Ocamlorg_static.Asset.url "logo.svg" %>" alt="default logo"></a>
<a href="<%s Option.value ~default:(Url.blog_post item.source.id item.slug) item.url %>"><img class="w-full" src="<%s Ocamlorg_static.Asset.url "logo.svg" %>" alt="default logo"></a>
</div>
<% | Some image -> %>
<div class="flex-none w-64">
<a href="<%s Option.value ~default:(Url.blog_post item.slug) item.url %>"><img class="w-full" src="<%s image %>" alt=""></a>
<a href="<%s Option.value ~default:(Url.blog_post item.source.id item.slug) item.url %>"><img class="w-full" src="<%s image %>" alt=""></a>
</div>
<% ); %>
</div>
Expand Down
Loading

0 comments on commit 3fa1015

Please sign in to comment.