Class: Vortex::StructuredArticle
- Inherits:
-
HtmlArticle
- Object
- Resource
- PlainFile
- HtmlArticle
- Vortex::StructuredArticle
- Defined in:
- lib/vortex_client.rb
Overview
Vortex article stored as JSON data.
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#hideAdditionalContent ⇒ Object
Returns the value of attribute hideAdditionalContent.
-
#introduction ⇒ Object
Returns the value of attribute introduction.
-
#modifiedDate ⇒ Object
Returns the value of attribute modifiedDate.
-
#owner ⇒ Object
Returns the value of attribute owner.
-
#picture ⇒ Object
Returns the value of attribute picture.
-
#publishDate ⇒ Object
Returns the value of attribute publishDate.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Attributes inherited from HtmlArticle
#author, #date, #publishedDate
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize(options = {}) ⇒ StructuredArticle
constructor
Create an article Options:.
- #properties ⇒ Object
- #to_s ⇒ Object
- #zzzzz_content_old ⇒ Object
Methods inherited from HtmlArticle
Constructor Details
#initialize(options = {}) ⇒ StructuredArticle
Create an article Options:
:title => "Title" mandatory
447 448 449 |
# File 'lib/vortex_client.rb', line 447 def initialize(={}) .each{|k,v|send("#{k}=",v)} end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
441 442 443 |
# File 'lib/vortex_client.rb', line 441 def body @body end |
#filename ⇒ Object
Returns the value of attribute filename.
441 442 443 |
# File 'lib/vortex_client.rb', line 441 def filename @filename end |
#hideAdditionalContent ⇒ Object
Returns the value of attribute hideAdditionalContent.
441 442 443 |
# File 'lib/vortex_client.rb', line 441 def hideAdditionalContent @hideAdditionalContent end |
#introduction ⇒ Object
Returns the value of attribute introduction.
441 442 443 |
# File 'lib/vortex_client.rb', line 441 def introduction @introduction end |
#modifiedDate ⇒ Object
Returns the value of attribute modifiedDate.
441 442 443 |
# File 'lib/vortex_client.rb', line 441 def modifiedDate @modifiedDate end |
#owner ⇒ Object
Returns the value of attribute owner.
441 442 443 |
# File 'lib/vortex_client.rb', line 441 def owner @owner end |
#picture ⇒ Object
Returns the value of attribute picture.
441 442 443 |
# File 'lib/vortex_client.rb', line 441 def picture @picture end |
#publishDate ⇒ Object
Returns the value of attribute publishDate.
441 442 443 |
# File 'lib/vortex_client.rb', line 441 def publishDate @publishDate end |
#tags ⇒ Object
Returns the value of attribute tags.
441 442 443 |
# File 'lib/vortex_client.rb', line 441 def @tags end |
#title ⇒ Object
Returns the value of attribute title.
441 442 443 |
# File 'lib/vortex_client.rb', line 441 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
441 442 443 |
# File 'lib/vortex_client.rb', line 441 def url @url end |
Instance Method Details
#content ⇒ Object
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 |
# File 'lib/vortex_client.rb', line 472 def content properties = { } if(body and body.size > 0) properties = properties.merge(:content => body) end if( and .kind_of?(Array) and .size > 0)then properties = properties.merge(:tags => ) end if( and .size > 0) properties = properties.merge(:author => ) end if(introduction and introduction.size > 0) properties = properties.merge(:introduction => introduction) end if(picture) properties = properties.merge(:picture => picture) end if(title) properties = properties.merge(:title => title) end if(@hideAdditionalContent != nil)then if(@hideAdditionalContent.kind_of?(FalseClass)) value = "false" elsif(@hideAdditionalContent.kind_of?(TrueClass))then value = "true" elsif(@hideAdditionalContent.kind_of?(String)) value = @hideAdditionalContent end properties = properties.merge(:hideAdditionalContent => value) end json = { :resourcetype => "structured-article"}.merge(:properties => properties).to_json return json end |
#properties ⇒ Object
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 |
# File 'lib/vortex_client.rb', line 569 def properties props = '<v:resourceType xmlns:v="vrtx">structured-article</v:resourceType>' + '<v:userSpecifiedCharacterEncoding xmlns:v="vrtx">utf-8</v:userSpecifiedCharacterEncoding>' + '<d:getcontenttype>application/json</d:getcontenttype>' if(@publishDate and @publishDate != "") if(@publishDate.kind_of? Time) @publishDate = @publishDate.httpdate.to_s end props += '<v:publish-date xmlns:v="vrtx">' + @publishDate + '</v:publish-date>' end if(date and date != "") if(date.kind_of? Time) date = @date.httpdate.to_s end if(@publishDate == nil or @publishDate != "") props += '<v:publish-date xmlns:v="vrtx">' + date + '</v:publish-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(owner) props += '<owner xmlns="vrtx">' + owner + '</owner>' end if( and != "") # 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 return props end |
#to_s ⇒ Object
467 468 469 |
# File 'lib/vortex_client.rb', line 467 def to_s "#<Vortex::StructuredArticle "+instance_variables.collect{|var|var+": "+instance_variable_get(var).to_s}.join(",")+">" end |
#zzzzz_content_old ⇒ Object
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 |
# File 'lib/vortex_client.rb', line 513 def zzzzz_content_old json = <<-EOF { "resourcetype": "structured-article", "properties": { EOF if(body and body.size > 0) tmp_body = body # Escape '"' and line shifts so html will be valid json data. tmp_body = tmp_body.gsub(/\r/,"\\\r").gsub(/\n/,"\\\n").gsub(/\"/,"\\\"") ## .to_json json += " \"content\": \"#{tmp_body}\",\n" end if( and .kind_of?(Array) and .size > 0) json += " \"tags\": ,\n" json += " \"" + .join("\"\n, \"") + "\"\n" end if( and .size > 0) json += " \"author\": [\"#{}\"],\n" end json += " \"title\": \"#{title}\",\n" if(introduction and introduction.size > 0) tmp_introduction = introduction tmp_introduction = tmp_introduction.gsub(/\r/,"\\\r") tmp_introduction = tmp_introduction.gsub(/\n/,"\\\n") tmp_introduction = tmp_introduction.gsub(/\"/,"\\\"") json += " \"introduction\": \"#{tmp_introduction}\",\n" end if(picture) json += " \"picture\": \"#{picture}\",\n" end if(@hideAdditionalContent != nil)then if(@hideAdditionalContent.kind_of?(FalseClass)) value = "false" elsif(@hideAdditionalContent.kind_of?(TrueClass))then value = "true" elsif(@hideAdditionalContent.kind_of?(String)) value = @hideAdditionalContent end json += <<-EOF "hideAdditionalContent": "#{value}" EOF end json += <<-EOF } } EOF # puts "DEBUG: json:" + json # puts return json end |