Class: Jekyll::ActivityPub::Create
- Inherits:
-
Page
- Object
- Page
- Jekyll::ActivityPub::Create
- Includes:
- Helper
- Defined in:
- lib/jekyll/activity_pub/create.rb
Overview
Represents a Create activity
Direct Known Subclasses
Constant Summary collapse
- DATE_ATTRIBUTE =
Where is the date stored
'published'
Instance Attribute Summary collapse
- #actor ⇒ Object readonly
- #object ⇒ Object readonly
Instance Method Summary collapse
- #date ⇒ Time
-
#initialize(site, actor, object) ⇒ Create
constructor
Initialize with default data.
- #read_yaml ⇒ Object
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
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
#actor ⇒ Object (readonly)
19 20 21 |
# File 'lib/jekyll/activity_pub/create.rb', line 19 def actor @actor end |
#object ⇒ Object (readonly)
16 17 18 |
# File 'lib/jekyll/activity_pub/create.rb', line 16 def object @object end |
Instance Method Details
#date ⇒ Time
59 60 61 |
# File 'lib/jekyll/activity_pub/create.rb', line 59 def date @date ||= Time.parse(object.data[DATE_ATTRIBUTE]) end |
#read_yaml ⇒ Object
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 |