File: card.rb

package info (click to toggle)
mikutter 4.1.3%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 9,260 kB
  • sloc: ruby: 20,126; sh: 183; makefile: 19
file content (27 lines) | stat: -rw-r--r-- 702 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module Plugin::Mastodon
  # https://docs.joinmastodon.org/api/entities/#card
  class Card < Diva::Model
    register :mastodon_card, name: Plugin[:mastodon]._('Mastodonカード')

    field.uri :url, required: true
    field.string :title, required: true
    field.string :description, required: true
    field.uri :image
    field.string :type, required: true # one of "link", "photo", "video", "rich"
    field.string :author_name
    field.uri :author_url
    field.string :provider_name
    field.uri :provider_url
    field.string :html
    field.int :width
    field.int :height

    def path
      "/#{CGI.escape(url)}"
    end

    def inspect
      "mastodon-card(#{name})"
    end
  end
end