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
-
#content ⇒ String
Renders the data hash as a stringified JSON.
-
#generate_excerpt? ⇒ Boolean
There’s no excerpt to be generated.
-
#hook_owner ⇒ Symbol
(also: #type)
Simpler version of ActiveSupport::Inflector#underscore.
-
#locale ⇒ String
Detects locale.
-
#place_in_layout? ⇒ Boolean
Avoid.
-
#pruned_data ⇒ Hash
Removes empty values from data.
-
#render_with_liquid? ⇒ Boolean
Avoid.
-
#to_json(*args) ⇒ Object
JSONify this object.
-
#to_liquid ⇒ Jekyll::Drops::ActivityDrop
Convert into a dereferentiable object.
-
#trigger_hooks(hook_name, *args) ⇒ nil
Trigger hooks.
Instance Method Details
#content ⇒ String
Renders the data hash as a stringified JSON
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
55 56 57 |
# File 'lib/jekyll/activity_pub/helper.rb', line 55 def generate_excerpt? false end |
#hook_owner ⇒ Symbol Also known as: type
Simpler version of ActiveSupport::Inflector#underscore
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 |
#locale ⇒ String
Detects locale
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
65 66 67 |
# File 'lib/jekyll/activity_pub/helper.rb', line 65 def place_in_layout? false end |
#pruned_data ⇒ Hash
Removes empty values from data
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
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_liquid ⇒ Jekyll::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
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 |