Class: Jekyll::ActivityPub::Create

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

Overview

Represents a Create activity

Direct Known Subclasses

Update

Constant Summary collapse

DATE_ATTRIBUTE =

Where is the date stored

'published'

Instance Attribute Summary collapse

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, actor, object) ⇒ Create

Initialize with default data

Parameters:



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/jekyll/activity_pub/create.rb', line 26

def initialize(site, actor, object)
  @context = StubContext.new(registers: { site: site })
  @object = object
  @actor = actor

  dest = Pathname.new(object.destination(site.dest)).relative_path_from(site.dest)
  name = "#{date.to_i}.jsonld"
  dir = File.join(
    File.dirname(dest),
    File.basename(dest, '.jsonld'),
    type.downcase
  )

  super(site, '', dir, name)

  trigger_hooks :post_init
end

Instance Attribute Details

#actorObject (readonly)

Parameters:



19
20
21
# File 'lib/jekyll/activity_pub/create.rb', line 19

def actor
  @actor
end

#objectObject (readonly)

Parameters:



16
17
18
# File 'lib/jekyll/activity_pub/create.rb', line 16

def object
  @object
end

Instance Method Details

#dateTime

Returns:

  • (Time)


59
60
61
# File 'lib/jekyll/activity_pub/create.rb', line 59

def date
  @date ||= Time.parse(object.data[DATE_ATTRIBUTE])
end

#read_yamlObject



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/jekyll/activity_pub/create.rb', line 44

def read_yaml(*)
  @data = {
    '@context' => 'https://www.w3.org/ns/activitystreams',
    'type' => type,
    'id' => absolute_url(url),
    'actor' => absolute_url(actor.url),
    'published' => object.data[DATE_ATTRIBUTE],
    'to' => object.data['to'],
    'cc' => object.data['cc'],
    'object' => object.data,
    'inReplyTo' => object.data['in_reply_to']
  }
end