Class: Jekyll::ActivityPub::PublicKey

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

Overview

Public key

Instance Method Summary collapse

Methods included from Helper

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

Constructor Details

#initialize(site, actor, public_key, base = '', dir = '', name = 'pubkey.pem') ⇒ PublicKey

Initialize with default data

Parameters:

  • :site (Jekyll::Site)
  • :actor (Jekyll::ActivityPub::Actor)
  • :public_key (OpenSsl::Pkey::RSA)
  • :base (String)
  • :dir (String)
  • :name (String)


21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/jekyll/activity_pub/public_key.rb', line 21

def initialize(site, actor, public_key, base = '', dir = '', name = 'pubkey.pem')
  @context = StubContext.new(registers: { site: site })
  @actor = actor
  @public_key = public_key

  super(site, base, dir, name)

  actor.data['publicKey'] = self

  Notifier.public_key_url = data['id']

  trigger_hooks :post_init
end

Instance Method Details

#contentObject



43
44
45
# File 'lib/jekyll/activity_pub/public_key.rb', line 43

def content
  data['publicKeyPem']
end

#read_yamlObject



35
36
37
38
39
40
41
# File 'lib/jekyll/activity_pub/public_key.rb', line 35

def read_yaml(*)
  self.data = {
    'id' => "#{absolute_url(@actor.url)}#main-key",
    'owner' => absolute_url(@actor.url),
    'publicKeyPem' => @public_key.public_to_pem
  }
end