vortex_client 0.5.9 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.9
1
+ 0.6.0
@@ -5,11 +5,17 @@ include Vortex
5
5
  vortex = Vortex::Connection.new("https://vortex-dav.uio.no/")
6
6
  vortex.cd('/brukere/thomasfl/events/')
7
7
 
8
- collection = ArticleListingCollection.new(:url => 'my-collection', :title => 'My articles')
8
+ # Create standard folder
9
+ collection = Collection.new(:url => 'my-collection', :title => 'My articles')
9
10
  path = vortex.create(collection)
10
11
  puts "Created folder: " + path
11
12
 
13
+ # Create a folder that lists articles
14
+ collection = ArticleListingCollection.new(:url => 'my-collection', :title => 'My articles')
15
+ path = vortex.create(collection)
16
+ puts "Created folder: " + path
12
17
 
18
+ # Create a folder that lists events
13
19
  collection = EventListingCollection.new(:title => 'My events')
14
20
  path = vortex.create(collection)
15
21
  puts "Created folder: " + path
@@ -1,11 +1,10 @@
1
1
  require 'rubygems'
2
2
  require 'vortex_client'
3
- include Vortex
4
3
 
5
4
  vortex = Vortex::Connection.new("https://vortex-dav.uio.no/")
6
5
 
7
6
  vortex.cd('/brukere/thomasfl/nyheter/')
8
- article = HtmlArticle.new(:title => "My new title",
7
+ article = Vortex::StructuredArticle.new(:title => "Hello world",
9
8
  :introduction => "Short introduction",
10
9
  :body => "<p>Longer body</p>",
11
10
  :publishedDate => Time.now,
data/lib/vortex_client.rb CHANGED
@@ -438,7 +438,7 @@ module Vortex
438
438
  # Vortex article stored as JSON data.
439
439
  class StructuredArticle < HtmlArticle
440
440
 
441
- attr_accessor :title, :introduction, :body, :filename, :modifiedDate, :publishDate, :owner, :url, :picture, :hideAdditionalContent
441
+ attr_accessor :title, :introduction, :body, :filename, :modifiedDate, :publishDate, :owner, :url, :picture, :hideAdditionalContent, :tags
442
442
 
443
443
  # Create an article
444
444
  # Options:
@@ -470,6 +470,47 @@ module Vortex
470
470
 
471
471
 
472
472
  def content
473
+ properties = { }
474
+ if(body and body.size > 0)
475
+ properties = properties.merge(:content => body)
476
+ end
477
+
478
+ if(tags and tags.kind_of?(Array) and tags.size > 0)then
479
+ properties = properties.merge(:tags => tags)
480
+ end
481
+
482
+ if(author and author.size > 0)
483
+ properties = properties.merge(:author => author)
484
+ end
485
+ if(introduction and introduction.size > 0)
486
+ properties = properties.merge(:introduction => introduction)
487
+ end
488
+
489
+ if(picture)
490
+ properties = properties.merge(:picture => picture)
491
+ end
492
+
493
+ if(title)
494
+ properties = properties.merge(:title => title)
495
+ end
496
+
497
+ if(@hideAdditionalContent != nil)then
498
+ if(@hideAdditionalContent.kind_of?(FalseClass))
499
+ value = "false"
500
+ elsif(@hideAdditionalContent.kind_of?(TrueClass))then
501
+ value = "true"
502
+ elsif(@hideAdditionalContent.kind_of?(String))
503
+ value = @hideAdditionalContent
504
+ end
505
+ properties = properties.merge(:hideAdditionalContent => value)
506
+ end
507
+
508
+ json = { :resourcetype => "structured-article"}.merge(:properties => properties).to_json
509
+
510
+ return json
511
+ end
512
+
513
+ def zzzzz_content_old
473
514
  json = <<-EOF
474
515
  {
475
516
  "resourcetype": "structured-article",
@@ -482,6 +523,12 @@ module Vortex
482
523
  tmp_body = tmp_body.gsub(/\r/,"\\\r").gsub(/\n/,"\\\n").gsub(/\"/,"\\\"") ## .to_json
483
524
  json += " \"content\": \"#{tmp_body}\",\n"
484
525
  end
526
+
527
+ if(tags and tags.kind_of?(Array) and tags.size > 0)
528
+ json += " \"tags\": ,\n"
529
+ json += " \"" + tags.join("\"\n, \"") + "\"\n"
530
+ end
531
+
485
532
  if(author and author.size > 0)
486
533
  json += " \"author\": [\"#{author}\"],\n"
487
534
  end
@@ -513,12 +560,14 @@ module Vortex
513
560
  }
514
561
  EOF
515
562
 
563
+ # puts "DEBUG: json:" + json
564
+ # puts
565
+
516
566
  return json
517
567
  end
518
568
 
519
569
  def properties
520
570
  props = '<v:resourceType xmlns:v="vrtx">structured-article</v:resourceType>' +
521
- # '<v:xhtml10-type xmlns:v="vrtx">structured-article</v:xhtml10-type>' +
522
571
  '<v:userSpecifiedCharacterEncoding xmlns:v="vrtx">utf-8</v:userSpecifiedCharacterEncoding>' +
523
572
  '<d:getcontenttype>application/json</d:getcontenttype>'
524
573
 
@@ -542,19 +591,10 @@ module Vortex
542
591
  '<v:creationTime xmlns:v="vrtx">' + date + '</v:creationTime>'
543
592
  end
544
593
 
545
- if(picture)
546
- # props += '<v:picture xmlns:v="vrtx">' + picture + '</v:picture>'
547
- end
548
-
549
- if(title)
550
- # props += '<v:userTitle xmlns:v="vrtx">' + title + '</v:userTitle>'
551
- end
552
594
  if(owner)
553
595
  props += '<owner xmlns="vrtx">' + owner + '</owner>'
554
596
  end
555
- if(introduction and introduction != "")
556
- # props += '<introduction xmlns="vrtx">' + escape_html(introduction) + '</introduction>'
557
- end
597
+
558
598
  if(author and author != "")
559
599
  # props += '<v:authors xmlns:v="vrtx">' +
560
600
  # '<vrtx:values xmlns:vrtx="http://vortikal.org/xml-value-list">' +
@@ -563,14 +603,6 @@ module Vortex
563
603
  # '</v:authors>'
564
604
  end
565
605
 
566
- if(tags and tags.kind_of?(Array) and tags.size > 0)
567
- # props += '<v:tags xmlns:v="vrtx">' +
568
- # '<vrtx:values xmlns:vrtx="http://vortikal.org/xml-value-list">'
569
- # tags.each do |tag|
570
- # props += "<vrtx:value>#{tag}</vrtx:value>"
571
- # end
572
- # props += '</vrtx:values></v:tags>'
573
- end
574
606
  return props
575
607
  end
576
608
 
@@ -608,9 +640,7 @@ module Vortex
608
640
  end
609
641
 
610
642
  def properties()
611
- # props = "<v:resourceType xmlns:v=\"vrtx\">collection</v:resourceType>" +
612
- # "<v:collection-type xmlns:v=\"vrtx\">article-listing</v:collection-type>"
613
- props = ""
643
+ props = "<v:resourceType xmlns:v=\"vrtx\">collection</v:resourceType>"
614
644
  if(title and title != "")
615
645
  props += "<v:userTitle xmlns:v=\"vrtx\">#{title}</v:userTitle>"
616
646
  end
@@ -629,18 +659,18 @@ module Vortex
629
659
  #
630
660
  # Examaple:
631
661
  #
632
- # collection = ArticleListingCollection(:url => 'news')
633
- # collection = ArticleListingCollection(:foldername => 'news')
634
- # collection = ArticleListingCollection(:title => 'My articles')
635
- # collection = ArticleListingCollection(:title => 'My articles',
636
- # :foldername => 'articles',
637
- # :navigationTitle => 'Read articles')
662
+ # collection = ArticleListingCollection.new(:url => 'news')
663
+ # collection = ArticleListingCollection.new(:foldername => 'news')
664
+ # collection = ArticleListingCollection.new(:title => 'My articles')
665
+ # collection = ArticleListingCollection.new(:title => 'My articles',
666
+ # :foldername => 'articles',
667
+ # :navigationTitle => 'Read articles')
638
668
  class ArticleListingCollection < Collection
639
669
 
640
670
  def properties()
641
671
  props = super
642
- props += "<v:resourceType xmlns:v=\"vrtx\">article-listing</v:resourceType>" +
643
- "<v:collection-type xmlns:v=\"vrtx\">article-listing</v:collection-type>"
672
+ props += '<v:resourceType xmlns:v="vrtx">article-listing</v:resourceType>' +
673
+ '<v:collection-type xmlns:v="vrtx">article-listing</v:collection-type>'
644
674
  return props
645
675
  end
646
676
 
@@ -652,7 +682,7 @@ module Vortex
652
682
  def properties()
653
683
  props = super
654
684
  props += '<v:resourceType xmlns:v="vrtx">person-listing</v:resourceType>' +
655
- '<v:collection-type xmlns:v="vrtx">person-listing</v:collection-type>'
685
+ '<v:collection-type xmlns:v="vrtx">person-listing</v:collection-type>'
656
686
  return props
657
687
  end
658
688
 
@@ -664,8 +694,8 @@ module Vortex
664
694
 
665
695
  def properties()
666
696
  props = super
667
- props += "<v:resourceType xmlns:v=\"vrtx\">event-listing</v:resourceType>" +
668
- "<v:collection-type xmlns:v=\"vrtx\">event-listing</v:collection-type>"
697
+ props += '<v:resourceType xmlns:v="vrtx">event-listing</v:resourceType>' +
698
+ '<v:collection-type xmlns:v="vrtx">event-listing</v:collection-type>'
669
699
  return props
670
700
  end
671
701
 
@@ -6,9 +6,10 @@ class TestVortexClientUtils < Test::Unit::TestCase
6
6
 
7
7
  def setup
8
8
  if(not(@vortex))
9
- user = ENV['DAVUSER']
10
- pass = ENV['DAVPASS']
11
- @vortex = Connection.new("https://vortex-dav.uio.no/",user, pass)
9
+ # user = ENV['DAVUSER']
10
+ # pass = ENV['DAVPASS']
11
+ # @vortex = Connection.new("https://vortex-dav.uio.no/",user, pass)
12
+ @vortex = Connection.new("https://vortex-dav.uio.no/", :use_osx_keychain => true)
12
13
  end
13
14
  end
14
15
 
@@ -22,6 +23,18 @@ class TestVortexClientUtils < Test::Unit::TestCase
22
23
  article = Vortex::HtmlArticle.new(:title => "Sample Title 2",
23
24
  :introduction => "Sample introduction",
24
25
  :body => "<p>Hello world</p>",
26
+ :tags => ["Tag1", "Tag2"],
27
+ ## :date => Time.now,
28
+ :publishedDate => "05.01.2010 12:00",
29
+ :author => "Thomas Flemming")
30
+
31
+ @vortex.publish(article)
32
+ assert @vortex.exists?(url)
33
+
34
+ article = Vortex::StrucHtmlArticle.new(:title => "Sample Title 2",
35
+ :introduction => "Sample introduction",
36
+ :body => "<p>Hello world</p>",
37
+ :tags => ["Tag1", "Tag2"],
25
38
  ## :date => Time.now,
26
39
  :publishedDate => "05.01.2010 12:00",
27
40
  :author => "Thomas Flemming")
@@ -17,11 +17,9 @@ class TestVortexPerson < Test::Unit::TestCase
17
17
  end
18
18
  end
19
19
 
20
- def self.zshould(*args)
21
- end
22
-
23
- zshould "publish person presentation" do
20
+ should "publish person presentation" do
24
21
  @vortex.cd('/konv/personer_test/')
22
+
25
23
  person = Vortex::Person.new(:user => 'thomasfl',
26
24
  :image => '/brukere/thomasfl/thomasfl.jpg',
27
25
  :language => :english,
@@ -37,9 +35,14 @@ class TestVortexPerson < Test::Unit::TestCase
37
35
  should "publish default person presentation for scientists" do
38
36
  @vortex.cd('/konv/personer_test/')
39
37
 
38
+ collection = Vortex::PersonListingCollection.new(:foldername => '/konv/personer_test/scientific')
39
+
40
+ created_path = @vortex.create(collection)
41
+ @vortex.cd(created_path)
40
42
  person = Vortex::Person.new(:user => 'herman',
41
43
  :image => '/konv/personer_test/placeholder.jpg',
42
44
  :language => :english,
45
+ :url => '/konv/personer_test/scientific/index.html',
43
46
  :scientific => true)
44
47
 
45
48
  # puts person.content
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vortex_client
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 7
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
- - 5
8
- - 9
9
- version: 0.5.9
8
+ - 6
9
+ - 0
10
+ version: 0.6.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Thomas Flemming
@@ -21,9 +22,11 @@ dependencies:
21
22
  name: net_dav
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 11
27
30
  segments:
28
31
  - 0
29
32
  - 5
@@ -35,9 +38,11 @@ dependencies:
35
38
  name: highline
36
39
  prerelease: false
37
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
38
42
  requirements:
39
43
  - - ">="
40
44
  - !ruby/object:Gem::Version
45
+ hash: 1
41
46
  segments:
42
47
  - 1
43
48
  - 5
@@ -49,9 +54,11 @@ dependencies:
49
54
  name: thoughtbot-shoulda
50
55
  prerelease: false
51
56
  requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
52
58
  requirements:
53
59
  - - ">="
54
60
  - !ruby/object:Gem::Version
61
+ hash: 3
55
62
  segments:
56
63
  - 0
57
64
  version: "0"
@@ -108,23 +115,27 @@ rdoc_options:
108
115
  require_paths:
109
116
  - lib
110
117
  required_ruby_version: !ruby/object:Gem::Requirement
118
+ none: false
111
119
  requirements:
112
120
  - - ">="
113
121
  - !ruby/object:Gem::Version
122
+ hash: 3
114
123
  segments:
115
124
  - 0
116
125
  version: "0"
117
126
  required_rubygems_version: !ruby/object:Gem::Requirement
127
+ none: false
118
128
  requirements:
119
129
  - - ">="
120
130
  - !ruby/object:Gem::Version
131
+ hash: 3
121
132
  segments:
122
133
  - 0
123
134
  version: "0"
124
135
  requirements: []
125
136
 
126
137
  rubyforge_project:
127
- rubygems_version: 1.3.6
138
+ rubygems_version: 1.3.7
128
139
  signing_key:
129
140
  specification_version: 3
130
141
  summary: Vortex CMS client