Class: Vortex::HtmlEvent

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

Overview

HtmlEvent: Event document. Article with location, map url, start and end dates.

Examples:

 event = Vortex::HtmlEvent.new(:title => "Sample Event 1",
                               :introduction => "Sample event introduction",
                               :body => "<p>Hello world</p>",
                               :startDate => Time.now, ## "22.01.2010 12:15",
                               :endDate =>  Time.now + 60*60, ## "22.01.2010 13:00",
                               :location => "Forskningsveien 3B",
                               :mapUrl => "http://maps.google.com/123",
                               :tags => ["vortex","testing"],
                               :publishedDate => "05.01.2010 12:00")
vortex.publish(event)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ HtmlEvent

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



333
334
335
# File 'lib/vortex_client.rb', line 333

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

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



328
329
330
# File 'lib/vortex_client.rb', line 328

def body
  @body
end

#dateObject

Returns the value of attribute date.



328
329
330
# File 'lib/vortex_client.rb', line 328

def date
  @date
end

#endDateObject

Returns the value of attribute endDate.



328
329
330
# File 'lib/vortex_client.rb', line 328

def endDate
  @endDate
end

#filenameObject

Returns the value of attribute filename.



328
329
330
# File 'lib/vortex_client.rb', line 328

def filename
  @filename
end

#introductionObject

Returns the value of attribute introduction.



328
329
330
# File 'lib/vortex_client.rb', line 328

def introduction
  @introduction
end

#locationObject

Returns the value of attribute location.



328
329
330
# File 'lib/vortex_client.rb', line 328

def location
  @location
end

#mapUrlObject

Returns the value of attribute mapUrl.



328
329
330
# File 'lib/vortex_client.rb', line 328

def mapUrl
  @mapUrl
end

#modifiedDateObject

Returns the value of attribute modifiedDate.



328
329
330
# File 'lib/vortex_client.rb', line 328

def modifiedDate
  @modifiedDate
end

#ownerObject

Returns the value of attribute owner.



328
329
330
# File 'lib/vortex_client.rb', line 328

def owner
  @owner
end

#publishedDateObject

Returns the value of attribute publishedDate.



328
329
330
# File 'lib/vortex_client.rb', line 328

def publishedDate
  @publishedDate
end

#startDateObject

Returns the value of attribute startDate.



328
329
330
# File 'lib/vortex_client.rb', line 328

def startDate
  @startDate
end

#tagsObject

Returns the value of attribute tags.



328
329
330
# File 'lib/vortex_client.rb', line 328

def tags
  @tags
end

#titleObject

Returns the value of attribute title.



328
329
330
# File 'lib/vortex_client.rb', line 328

def title
  @title
end

#urlObject

Returns the value of attribute url.



328
329
330
# File 'lib/vortex_client.rb', line 328

def url
  @url
end

Instance Method Details

#contentObject

TODO: Samme kode som i article… Bruk arv!



424
425
426
427
428
429
430
431
432
433
434
# File 'lib/vortex_client.rb', line 424

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



356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
# File 'lib/vortex_client.rb', line 356

def properties
  props = '<v:resourceType xmlns:v="vrtx">event</v:resourceType>' +
    '<v:xhtml10-type xmlns:v="vrtx">event</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(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


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

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

  if(@location and @location != "")
    props += '<v:location xmlns:v="vrtx">' + @location + '</v:location>'
  end
  if(@mapUrl and @mapUrl != "")
    props += '<v:mapurl xmlns:v="vrtx">' + @mapUrl + '</v:mapurl>'
  end
  return props
end

#to_sObject



337
338
339
# File 'lib/vortex_client.rb', line 337

def to_s
  "#<Vortex::HtmlEvent "+instance_variables.collect{|var|var+": "+instance_variable_get(var).to_s}.join(",")+">"
end