Class: ConnectorsSdk::Confluence::Adapter::ContentNode
- Inherits:
-
Node
- Object
- Node
- ConnectorsSdk::Confluence::Adapter::ContentNode
show all
- Defined in:
- lib/connectors_sdk/confluence/adapter.rb
Instance Attribute Summary
Attributes inherited from Node
#base_url, #node, #permissions
Instance Method Summary
collapse
Methods inherited from Node
#initialize, #to_es_document
Instance Method Details
#body ⇒ Object
133
134
135
|
# File 'lib/connectors_sdk/confluence/adapter.rb', line 133
def body
text_from_html(node.body.export_view.value)
end
|
137
138
139
140
141
|
# File 'lib/connectors_sdk/confluence/adapter.rb', line 137
def
node.children&.&.results&.slice(0, MAX_CONTENT_COMMENTS_TO_INDEX)&.map do ||
text_from_html(.body.export_view.value)
end&.join("\n")
end
|
#description ⇒ Object
143
144
145
146
147
148
|
# File 'lib/connectors_sdk/confluence/adapter.rb', line 143
def description
[
node.space&.name,
node.ancestors&.map(&:title) ].flatten.select(&:present?).join('/')
end
|
#fields ⇒ Object
157
158
159
160
161
162
163
164
165
166
167
168
|
# File 'lib/connectors_sdk/confluence/adapter.rb', line 157
def fields
{
:description => description,
:body => body,
:comments => ,
:created_by => node.history&.createdBy&.displayName,
:project => node.space.try!(:[], :key),
:created_at => ConnectorsSdk::Base::Adapter.normalize_date(node.history&.createdDate),
:last_updated => ConnectorsSdk::Base::Adapter.normalize_date(node.history&.lastUpdated&.when)
}.merge(permissions_hash)
end
|
#id ⇒ Object
109
110
111
|
# File 'lib/connectors_sdk/confluence/adapter.rb', line 109
def id
Confluence::Adapter.confluence_content_id_to_es_id(node.id)
end
|
#path ⇒ Object
150
151
152
153
154
155
|
# File 'lib/connectors_sdk/confluence/adapter.rb', line 150
def path
[
description,
title
].select(&:present?).join('/')
end
|
#title ⇒ Object
125
126
127
|
# File 'lib/connectors_sdk/confluence/adapter.rb', line 125
def title
node.title
end
|
#type ⇒ Object
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/connectors_sdk/confluence/adapter.rb', line 113
def type
case node.type
when 'page'
node.type
when 'blogpost'
'blog post'
else
ConnectorsShared::ExceptionTracking.capture_message("Unknown confluence type: #{node.type}")
nil
end
end
|
#url ⇒ Object
129
130
131
|
# File 'lib/connectors_sdk/confluence/adapter.rb', line 129
def url
Addressable::URI.join(base_url, node._links.webui.gsub(LEADING_SLASH_REGEXP, '')).to_s
end
|