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
489 490 491 |
# File 'lib/vortex_client.rb', line 489 def initialize(={}) .each{|k,v|send("#{k}=",v)} end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
483 484 485 |
# File 'lib/vortex_client.rb', line 483 def body @body end |
#filename ⇒ Object
Returns the value of attribute filename.
483 484 485 |
# File 'lib/vortex_client.rb', line 483 def filename @filename end |
#hideAdditionalContent ⇒ Object
Returns the value of attribute hideAdditionalContent.
483 484 485 |
# File 'lib/vortex_client.rb', line 483 def hideAdditionalContent @hideAdditionalContent end |
#introduction ⇒ Object
Returns the value of attribute introduction.
483 484 485 |
# File 'lib/vortex_client.rb', line 483 def introduction @introduction end |
#modifiedDate ⇒ Object
Returns the value of attribute modifiedDate.
483 484 485 |
# File 'lib/vortex_client.rb', line 483 def modifiedDate @modifiedDate end |
#owner ⇒ Object
Returns the value of attribute owner.
483 484 485 |
# File 'lib/vortex_client.rb', line 483 def owner @owner end |
#picture ⇒ Object
Returns the value of attribute picture.
483 484 485 |
# File 'lib/vortex_client.rb', line 483 def picture @picture end |
#publishDate ⇒ Object
Returns the value of attribute publishDate.
483 484 485 |
# File 'lib/vortex_client.rb', line 483 def publishDate @publishDate end |
#tags ⇒ Object
Returns the value of attribute tags.
483 484 485 |
# File 'lib/vortex_client.rb', line 483 def @tags end |
#title ⇒ Object
Returns the value of attribute title.
483 484 485 |
# File 'lib/vortex_client.rb', line 483 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
483 484 485 |
# File 'lib/vortex_client.rb', line 483 def url @url end |
Instance Method Details
#content ⇒ Object
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 |
# File 'lib/vortex_client.rb', line 514 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
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 |
# File 'lib/vortex_client.rb', line 611 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
509 510 511 |
# File 'lib/vortex_client.rb', line 509 def to_s "#<Vortex::StructuredArticle "+instance_variables.collect{|var|var+": "+instance_variable_get(var).to_s}.join(",")+">" end |
#zzzzz_content_old ⇒ Object
555 556 557 558 559 560 561 562 563 564 565 566 567 568 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 608 609 |
# File 'lib/vortex_client.rb', line 555 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 |