Skip to content

Don't save or republish full OCaml Planet blog post content #3125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/ocamlorg_data/data_intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ module Blog = struct
authors : string list;
date : string;
preview_image : string option;
body_html : string;
}
end

Expand Down
13 changes: 4 additions & 9 deletions tool/ood-gen/lib/blog.ml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module Post = struct

let all_sources = Source.all ()

let of_metadata ~source ~body_html m : Data_intf.Blog.post option =
let of_metadata ~source m : Data_intf.Blog.post option =
if Option.value ~default:false m.ignore then None
else
Some
Expand Down Expand Up @@ -92,7 +92,6 @@ module Post = struct
authors = Option.value ~default:[] m.authors;
date = m.date;
preview_image = m.preview_image;
body_html;
}

let pp_meta ppf v =
Expand All @@ -102,14 +101,10 @@ module Post = struct
(metadata_to_yaml v |> Yaml.to_string
|> Result.get_ok ~error:(fun (`Msg m) -> Exn.Decode_error m))

let decode (fpath, (head, body_md)) =
let decode (fpath, (head, _)) =
let metadata =
metadata_of_yaml head |> Result.map_error (Utils.where fpath)
in
let body_html =
body_md |> Markdown.Content.of_string
|> Markdown.Content.render ~syntax_highlighting:true
in
let source =
match Str.split (Str.regexp_string "/") fpath with
| _ :: second :: _ -> (
Expand All @@ -128,7 +123,7 @@ module Post = struct
in
metadata
|> Result.map_error (Utils.where fpath)
|> Result.map (of_metadata ~source ~body_html)
|> Result.map (of_metadata ~source)

let all () : Data_intf.Blog.post list =
Utils.map_md_files decode "planet/*/*.md"
Expand Down Expand Up @@ -187,7 +182,7 @@ module Scraper = struct
ignore = None;
}
in
let s = Format.asprintf "%a\n%s\n" Post.pp_meta metadata content in
let s = Format.asprintf "%a" Post.pp_meta metadata in
let oc = open_out output_file in
Printf.fprintf oc "%s" s;
close_out oc)
Expand Down
4 changes: 3 additions & 1 deletion tool/ood-gen/lib/planet.ml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ module GlobalFeed = struct
())

let entry_of_post (post : Blog.post) =
let content = Syndic.Atom.Html (None, post.body_html) in
let content =
Syndic.Atom.Html (None, Option.value post.description ~default:"")
in
let url = Uri.of_string post.source.url in
let source : Syndic.Atom.source =
Syndic.Atom.source ~authors:[] ~id:url
Expand Down
Loading