Class: Jekyll::ActivityPub::InstanceV1

Inherits:
Page
  • Object
show all
Includes:
Helper
Defined in:
lib/jekyll/activity_pub/instance_v1.rb

Overview

Points to site’s metadata

Direct Known Subclasses

InstanceV2

Instance Method Summary collapse

Methods included from Helper

#content, #generate_excerpt?, #hook_owner, #locale, #place_in_layout?, #pruned_data, #render_with_liquid?, #to_json, #to_liquid, #trigger_hooks

Constructor Details

#initialize(site, base = '', dir = 'api/v1', name = 'instance') ⇒ InstanceV1

Initialize with default data

Parameters:

  • :site (Jekyll::Site)
  • :base (String)
  • :dir (String)
  • :name (String)


19
20
21
22
23
24
25
# File 'lib/jekyll/activity_pub/instance_v1.rb', line 19

def initialize(site, base = '', dir = 'api/v1', name = 'instance')
  @context = StubContext.new(registers: { site: site })

  super(site, base, dir, name)

  trigger_hooks :post_init
end

Instance Method Details

#increase_last_status!(last_status) ⇒ Object



96
97
98
# File 'lib/jekyll/activity_pub/instance_v1.rb', line 96

def increase_last_status!(last_status)
  self.last_status_at = last_status if !last_status_at || last_status_at < last_status
end

#increase_local_posts_counter!Object



90
91
92
93
94
# File 'lib/jekyll/activity_pub/instance_v1.rb', line 90

def increase_local_posts_counter!
  data['stats']['status_count'] += 1
  data['contact_account']['statuses_count'] += 1
  nil
end

#output_extObject



31
32
33
# File 'lib/jekyll/activity_pub/instance_v1.rb', line 31

def output_ext
  '.json'
end


27
28
29
# File 'lib/jekyll/activity_pub/instance_v1.rb', line 27

def permalink
  'api/v1/instance/'
end

#read_yamlObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/jekyll/activity_pub/instance_v1.rb', line 35

def read_yaml(*)
  self.data = {
    'uri' => hostname,
    'title' => public_name,
    'short_description' => summary,
    'description' => summary,
    'email' => email,
    'version' => Jekyll::ActivityPub::VERSION,
    'urls' => {},
    'stats' => {
      'user_count' => 1,
      'status_count' => 0,
      'domain_count' => 1
    },
    'thumbnail' => conditional_absolute_url(avatar),
    'languages' => languages,
    'registrations' => false,
    'approval_required' => false,
    'invites_enabled' => false,
    'configuration' => {
      'accounts' => {},
      'statuses' => {},
      'media_attachments' => {},
      'polls' => {}
    },
    'contact_account' => {
      'id' => 1,
      'username' => username,
      'acct' => username,
      'display_name' => public_name,
      'locked' => false,
      'bot' => false,
      'discoverable' => true,
      'group' => false,
      'created_at' => published.xmlschema,
      'note' => summary,
      'url' => site.config['url'],
      'uri' => site.config['url'],
      'avatar' => conditional_absolute_url(avatar),
      'avatar_static' => conditional_absolute_url(avatar),
      'header' => conditional_absolute_url(header),
      'header_static' => conditional_absolute_url(header),
      'followers_count' => 0,
      'following_count' => 0,
      'statuses_count' => 0,
      'last_status_at' => nil,
      'noindex' => false,
      'emojis' => [],
      'roles' => [],
      'fields' => []
    },
    'rules' => []
  }
end