json.go 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
  2. // SPDX-License-Identifier: Apache-2.0
  3. package json // import "miniflux.app/v2/internal/reader/json"
  4. // JSON Feed specs:
  5. // https://www.jsonfeed.org/version/1.1/
  6. // https://www.jsonfeed.org/version/1/
  7. type JSONFeed struct {
  8. // Version is the URL of the version of the format the feed uses.
  9. // This should appear at the very top, though we recognize that not all JSON generators allow for ordering.
  10. Version string `json:"version"`
  11. // Title is the name of the feed, which will often correspond to the name of the website.
  12. Title string `json:"title"`
  13. // HomePageURL is the URL of the resource that the feed describes.
  14. // This resource may or may not actually be a “home” page, but it should be an HTML page.
  15. HomePageURL string `json:"home_page_url"`
  16. // FeedURL is the URL of the feed, and serves as the unique identifier for the feed.
  17. FeedURL string `json:"feed_url"`
  18. // Description provides more detail, beyond the title, on what the feed is about.
  19. Description string `json:"description"`
  20. // IconURL is the URL of an image for the feed suitable to be used in a timeline, much the way an avatar might be used.
  21. IconURL string `json:"icon"`
  22. // FaviconURL is the URL of an image for the feed suitable to be used in a source list. It should be square and relatively small.
  23. FaviconURL string `json:"favicon"`
  24. // Authors specifies one or more feed authors. The author object has several members.
  25. Authors []JSONAuthor `json:"authors"` // JSON Feed v1.1
  26. // Author specifies the feed author. The author object has several members.
  27. // JSON Feed v1 (deprecated)
  28. Author JSONAuthor `json:"author"`
  29. // Language is the primary language for the feed in the format specified in RFC 5646.
  30. // The value is usually a 2-letter language tag from ISO 639-1, optionally followed by a region tag. (Examples: en or en-US.)
  31. Language string `json:"language"`
  32. // Expired is a boolean value that specifies whether or not the feed is finished.
  33. Expired bool `json:"expired"`
  34. // Items is an array, each representing an individual item in the feed.
  35. Items []JSONItem `json:"items"`
  36. // Hubs describes endpoints that can be used to subscribe to real-time notifications from the publisher of this feed.
  37. Hubs []JSONHub `json:"hubs"`
  38. }
  39. type JSONAuthor struct {
  40. // Author's name.
  41. Name string `json:"name"`
  42. // Author's website URL (Blog or micro-blog).
  43. WebsiteURL string `json:"url"`
  44. // Author's avatar URL.
  45. AvatarURL string `json:"avatar"`
  46. }
  47. type JSONHub struct {
  48. // Type defines the protocol used to talk with the hub: "rssCloud" or "WebSub".
  49. Type string `json:"type"`
  50. // URL is the location of the hub.
  51. URL string `json:"url"`
  52. }
  53. type JSONItem struct {
  54. // Unique identifier for the item.
  55. // Ideally, the id is the full URL of the resource described by the item, since URLs make great unique identifiers.
  56. ID string `json:"id"`
  57. // URL of the resource described by the item.
  58. URL string `json:"url"`
  59. // ExternalURL is the URL of a page elsewhere.
  60. // This is especially useful for linkblogs.
  61. // If url links to where you’re talking about a thing, then external_url links to the thing you’re talking about.
  62. ExternalURL string `json:"external_url"`
  63. // Title of the item (optional).
  64. // Microblog items in particular may omit titles.
  65. Title string `json:"title"`
  66. // ContentHTML is the HTML body of the item.
  67. ContentHTML string `json:"content_html"`
  68. // ContentText is the text body of the item.
  69. ContentText string `json:"content_text"`
  70. // Summary is a plain text sentence or two describing the item.
  71. Summary string `json:"summary"`
  72. // ImageURL is the URL of the main image for the item.
  73. ImageURL string `json:"image"`
  74. // BannerImageURL is the URL of an image to use as a banner.
  75. BannerImageURL string `json:"banner_image"`
  76. // DatePublished is the date the item was published.
  77. DatePublished string `json:"date_published"`
  78. // DateModified is the date the item was modified.
  79. DateModified string `json:"date_modified"`
  80. // Language is the language of the item.
  81. Language string `json:"language"`
  82. // Authors is an array of JSONAuthor.
  83. Authors []JSONAuthor `json:"authors"`
  84. // Author is a JSONAuthor.
  85. // JSON Feed v1 (deprecated)
  86. Author JSONAuthor `json:"author"`
  87. // Tags is an array of strings.
  88. Tags []string `json:"tags"`
  89. // Attachments is an array of JSONAttachment.
  90. Attachments []JSONAttachment `json:"attachments"`
  91. }
  92. type JSONAttachment struct {
  93. // URL of the attachment.
  94. URL string `json:"url"`
  95. // MIME type of the attachment.
  96. MimeType string `json:"mime_type"`
  97. // Title of the attachment.
  98. Title string `json:"title"`
  99. // Size of the attachment in bytes.
  100. Size int64 `json:"size_in_bytes"`
  101. // Duration of the attachment in seconds.
  102. Duration int `json:"duration_in_seconds"`
  103. }