Class: Confluence::Page
Defined Under Namespace
Classes: Details, DetailsCollection
Constant Summary
collapse
- INVALID_TITLE_CHARS =
":@/\\|^#;[]{}<>"
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Findable
find
Methods inherited from Record
#[], #[]=, client, #client, client=, #labels, #labels=, record_attr_accessor, #record_id
Constructor Details
#initialize(hash) ⇒ Page
Returns a new instance of Page.
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
#details ⇒ Object
Returns the value of attribute details.
73
74
75
|
# File 'lib/confluence/page.rb', line 73
def details
@details
end
|
Instance Method Details
#add_attachment(filename, content_type, data = IO.read(filename), comment = "") ⇒ Object
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
|
#attachments ⇒ Object
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
|
#children(klass = self.class) ⇒ Object
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
|
#remove ⇒ Object
120
121
122
|
# File 'lib/confluence/page.rb', line 120
def remove
client.removePage(page_id)
end
|
#store(args = {}) ⇒ Object
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
|
#to_hash ⇒ Object
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
|