Module: Jekyll::ActivityPub::Helper

Extended by:
Forwardable
Includes:
Filters::URLFilters
Included in:
Activity, Actor, Create, Delete, HostMeta, Image, InstanceV1, InstanceV2, Link, Nodeinfo, Nodeinfo20, OrderedCollection, OrderedCollectionPage, PropertyValue, PublicKey, WebFinger
Defined in:
lib/jekyll/activity_pub/helper.rb

Overview

Container for common tools

Defined Under Namespace

Classes: StubContext

Instance Method Summary collapse

Instance Method Details

#contentString

Renders the data hash as a stringified JSON

Returns:

  • (String)


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

def content
  pruned_data.to_json
end

#generate_excerpt?Boolean

There’s no excerpt to be generated

Returns:

  • (Boolean)


55
56
57
# File 'lib/jekyll/activity_pub/helper.rb', line 55

def generate_excerpt?
  false
end

#hook_ownerSymbol Also known as: type

Simpler version of ActiveSupport::Inflector#underscore

stackoverflow.com/a/1510078

Returns:

  • (Symbol)

See Also:

  • Convertible


84
85
86
# File 'lib/jekyll/activity_pub/helper.rb', line 84

def hook_owner
  @hook_owner ||= self.class.name.split('::').last.gsub(/(.)([A-Z])/, '\1_\2').downcase.to_sym
end

#localeString

Detects locale

Returns:

  • (String)


93
94
95
96
97
98
99
100
# File 'lib/jekyll/activity_pub/helper.rb', line 93

def locale
  return @locale if defined? @locale

  @locale   = site.config['locale']
  @locale ||= ENV['LANG']&.split('.', 2)&.first

  @locale = @locale&.tr('_', '-')
end

#place_in_layout?Boolean

Avoid

Returns:

  • (Boolean)


65
66
67
# File 'lib/jekyll/activity_pub/helper.rb', line 65

def place_in_layout?
  false
end

#pruned_dataHash

Removes empty values from data

Returns:

  • (Hash)


34
35
36
37
38
# File 'lib/jekyll/activity_pub/helper.rb', line 34

def pruned_data
  data.reject do |_, v|
    v.nil? || (v.respond_to?(:empty?) && v.empty?)
  end
end

#render_with_liquid?Boolean

Avoid

Returns:

  • (Boolean)


60
61
62
# File 'lib/jekyll/activity_pub/helper.rb', line 60

def render_with_liquid?
  false
end

#to_json(*args) ⇒ Object

JSONify this object



48
49
50
# File 'lib/jekyll/activity_pub/helper.rb', line 48

def to_json(*args)
  pruned_data.to_json(*args)
end

#to_liquidJekyll::Drops::ActivityDrop

Convert into a dereferentiable object



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

def to_liquid
  @to_liquid ||=
    begin
      require 'jekyll/drops/activity_drop'

      Jekyll::Drops::ActivityDrop.new(self)
    end
end

#trigger_hooks(hook_name, *args) ⇒ nil

Trigger hooks

Parameters:

  • :hook_name (Symbol)
  • :args (any)

Returns:

  • (nil)


74
75
76
# File 'lib/jekyll/activity_pub/helper.rb', line 74

def trigger_hooks(hook_name, *args)
  Jekyll::Hooks.trigger hook_owner, hook_name.to_sym, self, *args
end