Class: Confluence::Page
- Inherits:
-
Record
- Object
- Record
- Confluence::Page
show all
- Extended by:
- Findable
- Defined in:
- lib/confluence/page.rb
Defined Under Namespace
Classes: Details, DetailsCollection
Constant Summary
- INVALID_TITLE_CHARS =
":@/\\|^#;[]{}<>"
Instance Attribute Summary (collapse)
Instance Method Summary
(collapse)
Constructor Details
- (Page) initialize(hash)
75
76
77
78
79
|
# File 'lib/confluence/page.rb', line 75
def initialize(hash)
super(hash)
@details = DetailsCollection.new(content)
end
|
Instance Attribute Details
- (Object) details
Returns the value of attribute details
73
74
75
|
# File 'lib/confluence/page.rb', line 73
def details
@details
end
|
Instance Method Details
- (Object) add_attachment(filename, content_type, data = IO.read(filename), comment = "")
124
125
126
127
128
|
# File 'lib/confluence/page.rb', line 124
def add_attachment(filename, content_type, data = IO.read(filename), = "")
attachment = Attachment.new :pageId => page_id, :fileName => filename, :contentType => content_type, :comment =>
attachment.data = data
attachment.store
end
|
- (Object) attachments
86
87
88
89
|
# File 'lib/confluence/page.rb', line 86
def attachments
attachments = client.getAttachments(page_id)
attachments.collect { |hash| Attachment.new(hash) } if attachments
end
|
- (Object) children(klass = self.class)
81
82
83
84
|
# File 'lib/confluence/page.rb', line 81
def children(klass = self.class)
children = client.getChildren(page_id)
children.collect { |hash| klass.find(:id => hash["id"]) } if children
end
|
- (Object) remove
120
121
122
|
# File 'lib/confluence/page.rb', line 120
def remove
client.removePage(page_id)
end
|
- (Object) store(args = {})
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/confluence/page.rb', line 91
def store(args = {})
unless self.version
existing_page = if page_id
Page.find :id => page_id
else
Page.find :space => space, :title => title
end
if existing_page
if args[:recreate_if_exists]
existing_page.remove
else
self.page_id = existing_page.page_id
self.version = existing_page.version
end
end
end
initialize(client.storePage(self.to_hash))
self
end
|
- (Object) to_hash
130
131
132
133
134
135
136
137
138
139
140
141
142
|
# File 'lib/confluence/page.rb', line 130
def to_hash
record_hash = super
record_hash["content"] ||= ""
record_hash["content"].insert(0, details.to_s)
record_hash
end
|