Class: Jekyll::ActivityPub::Nodeinfo20

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

Overview

Points to site’s nodeinfo 2.0

Direct Known Subclasses

Nodeinfo21

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 = 'nodeinfo', name = version) ⇒ Nodeinfo20

Initialize with default data

Parameters:

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


23
24
25
26
27
28
29
# File 'lib/jekyll/activity_pub/nodeinfo_20.rb', line 23

def initialize(site, base = '', dir = 'nodeinfo', name = version)
  @context = StubContext.new(registers: { site: site })

  super(site, base, dir, name)

  trigger_hooks :post_init
end

Instance Method Details

#increase_local_posts_counter!nil

Returns:

  • (nil)


70
71
72
73
# File 'lib/jekyll/activity_pub/nodeinfo_20.rb', line 70

def increase_local_posts_counter!
  data['usage']['localPosts'] += 1
  nil
end

The nodeinfo file is expected to be at this location always

Returns:

  • (String)


57
58
59
# File 'lib/jekyll/activity_pub/nodeinfo_20.rb', line 57

def permalink
  "nodeinfo/#{version}.json"
end

#read_yamlObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/jekyll/activity_pub/nodeinfo_20.rb', line 31

def read_yaml(*)
  self.data = {
    'version' => version,
    'software' => {
      'name' => 'sutty-distributed-press',
      'version' => Jekyll::ActivityPub::VERSION
    },
    'protocols' => ['activitypub'],
    'services' => {},
    'openRegistrations' => false,
    'usage' => {
      'users' => {
        'total' => 1,
        'activeHalfyear' => 1,
        'activeMonth' => 1
      },
      'localPosts' => 0,
      'localComments' => 0
    },
    'metadata' => {}
  }
end

#to_jrdHash

Returns:

  • (Hash)


62
63
64
65
66
67
# File 'lib/jekyll/activity_pub/nodeinfo_20.rb', line 62

def to_jrd
  {
    'rel' => "http://nodeinfo.diaspora.software/ns/schema/#{version}",
    'href' => absolute_url(url)
  }
end

#versionObject



13
14
15
# File 'lib/jekyll/activity_pub/nodeinfo_20.rb', line 13

def version
  '2.0'
end