constants.ml 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. (* https://www.w3.org/TR/activitypub/#retrieving-objects *)
  2. module ContentType = struct
  3. let _app_act_json = "application/activity+json" (* can we phase this out in favour of app_jlda *)
  4. let app_atom_xml = "application/atom+xml"
  5. let _app_ld_json = "application/ld+json"
  6. (* https://macgirvin.com/item/67716c6f-1226-4a10-8c04-cc7a70a24cbc *)
  7. let app_jlda = {|application/ld+json; profile="https://www.w3.org/ns/activitystreams"|}
  8. let app_jrd = "application/jrd+json"
  9. let app_json = "application/json" (* mostly webfinger rfc7033 jrd only *)
  10. let text_html = "text/html"
  11. let text_xml = "text/xml"
  12. let any = "*/*"
  13. let content_types = [
  14. _app_act_json, `JSON;
  15. app_atom_xml, `ATOM;
  16. _app_ld_json, `JSON;
  17. app_jlda, `JSON;
  18. app_jrd, `JSON;
  19. app_json, `JSON;
  20. text_html, `HTML;
  21. text_xml, `XML;
  22. any, `HTML;
  23. ]
  24. (*
  25. let of_string content_type =
  26. List.find_opt
  27. (fun (str, _) ->
  28. String.prefix ~pre:str content_type) content_types
  29. |> Option.map snd
  30. *)
  31. end
  32. (* RFC7033 *)
  33. module Webfinger = struct
  34. let json_rd = "application/jrd+json"
  35. let self_rel = "self"
  36. let ostatus_rel = "http://ostatus.org/schema/1.0/subscribe"
  37. let profile_page = "http://webfinger.net/rel/profile-page"
  38. let alternate = "alternate"
  39. end
  40. (* https://www.w3.org/TR/activitystreams-core/ *)
  41. module ActivityStreams = struct
  42. let ns_as = "https://www.w3.org/ns/activitystreams"
  43. let ns_sec = "https://w3id.org/security/v1"
  44. let public = Uri.of_string "https://www.w3.org/ns/activitystreams#Public"
  45. let und = Some "und"
  46. let context lang =
  47. "@context", `A [
  48. `String ns_as;
  49. `String ns_sec;
  50. `O [
  51. (* https://docs.joinmastodon.org/spec/activitypub/#schema *)
  52. ("schema", `String "http://schema.org#");
  53. ("PropertyValue", `String "schema:PropertyValue");
  54. ("value", `String "schema:value");
  55. ("@language", `String lang); (* undefined. BCP47 https://www.w3.org/TR/activitystreams-core/#naturalLanguageValues *)
  56. ]
  57. ]
  58. end