Class: Vortex::HtmlArticle

Inherits:
PlainFile show all
Defined in:
lib/vortex_client.rb,
lib/vortex_client.rb

Overview

Plain HTML files with title, introduction and keywords set as webdav properties.

Examples:

article = HtmlArticle.new(:title => "Sample Title",
                        :introduction => "Introduction",
                        :body => "<p>Hello world</p>")
vortex.publish(article)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ HtmlArticle

Create a new article of type html-article: plain html file with introduction stored as a webdav property.



161
162
163
# File 'lib/vortex_client.rb', line 161

def initialize(options={})
  options.each{|k,v|send("#{k}=",v)}
end

Instance Attribute Details

#authorObject

Returns the value of attribute author.



158
159
160
# File 'lib/vortex_client.rb', line 158

def author
  @author
end

#bodyObject

Returns the value of attribute body.



158
159
160
# File 'lib/vortex_client.rb', line 158

def body
  @body
end

#dateObject

Returns the value of attribute date.



158
159
160
# File 'lib/vortex_client.rb', line 158

def date
  @date
end

#filenameObject

Returns the value of attribute filename.



158
159
160
# File 'lib/vortex_client.rb', line 158

def filename
  @filename
end

#introductionObject

Returns the value of attribute introduction.



158
159
160
# File 'lib/vortex_client.rb', line 158

def introduction
  @introduction
end

#modifiedDateObject

Returns the value of attribute modifiedDate.



158
159
160
# File 'lib/vortex_client.rb', line 158

def modifiedDate
  @modifiedDate
end

#ownerObject

Returns the value of attribute owner.



158
159
160
# File 'lib/vortex_client.rb', line 158

def owner
  @owner
end

#publishedDateObject

Returns the value of attribute publishedDate.



158
159
160
# File 'lib/vortex_client.rb', line 158

def publishedDate
  @publishedDate
end

#tagsObject

Returns the value of attribute tags.



158
159
160
# File 'lib/vortex_client.rb', line 158

def tags
  @tags
end

#titleObject

Returns the value of attribute title.



158
159
160
# File 'lib/vortex_client.rb', line 158

def title
  @title
end

#urlObject

Returns the value of attribute url.



158
159
160
# File 'lib/vortex_client.rb', line 158

def url
  @url
end

Instance Method Details

#contentObject



233
234
235
236
237
238
239
240
241
242
243
# File 'lib/vortex_client.rb', line 233

def content
  content = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ' +
    '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' +
    '<html xmlns="http://www.w3.org/1999/xhtml"><head><title>' + title + '</title>' +
    ' <link href="http://www.uio.no/profil/kupu/kupucontentstyles.css" type="text/css" rel="stylesheet"/>' +
    '</head><body>'
  if(body)
    content += body
  end
  content += '</body></html>'
end

#propertiesObject



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/vortex_client.rb', line 180

def properties
  props = '<v:resourceType xmlns:v="vrtx">article</v:resourceType>' +
    '<v:xhtml10-type xmlns:v="vrtx">article</v:xhtml10-type>' +
    '<v:userSpecifiedCharacterEncoding xmlns:v="vrtx">utf-8</v:userSpecifiedCharacterEncoding>'

  if(@publishedDate and @publishedDate != "")
    if(@publishedDate.kind_of? Time)
      @publishedDate = @publishedDate.httpdate.to_s
    end
    props += '<v:published-date xmlns:v="vrtx">' + @publishedDate + '</v:published-date>'
  end

  if(date and date != "")
    if(date.kind_of? Time)
      date = @date.httpdate.to_s
    end
    if(@publishedDate == nil or @publishedDate != "")
      props += '<v:published-date xmlns:v="vrtx">' + date + '</v:published-date>'
    end
    props += '<d:getlastmodified>' + date + '</d:getlastmodified>' +
    '<v:contentLastModified xmlns:v="vrtx">' + date + '</v:contentLastModified>' +
    '<v:propertiesLastModified xmlns:v="vrtx">' + date + '</v:propertiesLastModified>' +
    '<v:creationTime xmlns:v="vrtx">' + date + '</v:creationTime>'
  end
  if(title)
    props += '<v:userTitle xmlns:v="vrtx">' + title + '</v:userTitle>'
  end
  if(owner)
    props += '<owner xmlns="vrtx">' + owner + '</owner>'
  end
  if(introduction and introduction != "")
    props += '<introduction xmlns="vrtx">' + introduction + '</introduction>'
  end
  if(author and author != "")
    props += '<v:authors xmlns:v="vrtx">' +
      '<vrtx:values xmlns:vrtx="http://vortikal.org/xml-value-list">' +
         '<vrtx:value>' + author + '</vrtx:value>' +
       '</vrtx:values>' +
    '</v:authors>'
  end

  if(tags and tags.kind_of?(Array) and tags.size > 0)
    props += '<v:tags xmlns:v="vrtx">' +
      '<vrtx:values xmlns:vrtx="http://vortikal.org/xml-value-list">'
    tags.each do |tag|
        props += "<vrtx:value>#{tag}</vrtx:value>"
    end
    props += '</vrtx:values></v:tags>'
  end

  return props
end