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.



374
375
376
# File 'lib/vortex_client.rb', line 374

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

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



369
370
371
# File 'lib/vortex_client.rb', line 369

def body
  @body
end

#dateObject

Returns the value of attribute date.



369
370
371
# File 'lib/vortex_client.rb', line 369

def date
  @date
end

#endDateObject

Returns the value of attribute endDate.



369
370
371
# File 'lib/vortex_client.rb', line 369

def endDate
  @endDate
end

#filenameObject

Returns the value of attribute filename.



369
370
371
# File 'lib/vortex_client.rb', line 369

def filename
  @filename
end

#introductionObject

Returns the value of attribute introduction.



369
370
371
# File 'lib/vortex_client.rb', line 369

def introduction
  @introduction
end

#locationObject

Returns the value of attribute location.



369
370
371
# File 'lib/vortex_client.rb', line 369

def location
  @location
end

#mapUrlObject

Returns the value of attribute mapUrl.



369
370
371
# File 'lib/vortex_client.rb', line 369

def mapUrl
  @mapUrl
end

#modifiedDateObject

Returns the value of attribute modifiedDate.



369
370
371
# File 'lib/vortex_client.rb', line 369

def modifiedDate
  @modifiedDate
end

#ownerObject

Returns the value of attribute owner.



369
370
371
# File 'lib/vortex_client.rb', line 369

def owner
  @owner
end

#publishedDateObject

Returns the value of attribute publishedDate.



369
370
371
# File 'lib/vortex_client.rb', line 369

def publishedDate
  @publishedDate
end

#startDateObject

Returns the value of attribute startDate.



369
370
371
# File 'lib/vortex_client.rb', line 369

def startDate
  @startDate
end

#tagsObject

Returns the value of attribute tags.



369
370
371
# File 'lib/vortex_client.rb', line 369

def tags
  @tags
end

#titleObject

Returns the value of attribute title.



369
370
371
# File 'lib/vortex_client.rb', line 369

def title
  @title
end

#urlObject

Returns the value of attribute url.



369
370
371
# File 'lib/vortex_client.rb', line 369

def url
  @url
end

Instance Method Details

#contentObject

TODO: Samme kode som i article… Bruk arv!



465
466
467
468
469
470
471
472
473
474
475
# File 'lib/vortex_client.rb', line 465

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



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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
# File 'lib/vortex_client.rb', line 397

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



378
379
380
# File 'lib/vortex_client.rb', line 378

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