middleman_mynewsdesk 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f0a588b7de22970c7d82e379df1ea0ddb478dc9
4
- data.tar.gz: 755c8dfc62f92b42f63c8362515add16f36d5843
3
+ metadata.gz: aaf400132528545cce35021c841b1958d2758aab
4
+ data.tar.gz: 9ea0333e81b78aacb3b7e163752da2503b26cfce
5
5
  SHA512:
6
- metadata.gz: 3c081145f9c7708459a5df8047371b33ea8efe258df7704d21bb386659270246281f7e570507a70b3fd955059dc88101885848f4f55ac0a81b85621c3143d3ef
7
- data.tar.gz: 3679c1db34f1da70362cc9fcd8b37d5d3296aa7464987d6cc2972922b1b829fe2333f25c57836ce2bb61d104a3d5149abd222e84dd2555bf8d0642992801c287
6
+ metadata.gz: 005dcbcabfbdd5ba9ae6d1af8076fae36f4ac555fe58d97c81dc2b8d261b101fe18ddfc2337edbf77f8dacd39ea2809e3d2a9699acb2763569f0a4704b1aa521
7
+ data.tar.gz: 340440fdc105b517db6468dfa5fc4417626e4936ba58b4bf3e12b011aeeba060b50ced3638a7ee939270a6ed606f2e6bcdd27874496362ba9ec3b51d7f08e343
@@ -6,6 +6,8 @@ require "middleman-core"
6
6
  # Extension namespace
7
7
  class Mynewsdesk < ::Middleman::Extension
8
8
  option :api_key, "api_key", "Mynewsdesk API key"
9
+ option :types_of_media, [:pressrelease], "Types of media to include"
10
+
9
11
  expose_to_config mynewsdesk_items: :mynewsdesk_items
10
12
  expose_to_template mynewsdesk_items: :mynewsdesk_items
11
13
 
@@ -20,8 +22,25 @@ class Mynewsdesk < ::Middleman::Extension
20
22
  @base_url = "https://www.mynewsdesk.com/services/pressroom/list/#{options.api_key}?format=json&limit=100"
21
23
  end
22
24
 
23
- def mynewsdesk_items(limit=20)
24
- @items ||= JSON.parse(HTTP.get(@base_url).to_s, object_class: RecursiveOpenStruct).items.item
25
- @items[0..limit-1]
25
+ def all_items_for(item)
26
+ items = []
27
+ 0.step(2000, 100) do |offset|
28
+ i = items_for_offset(item, offset)
29
+ items.concat i
30
+ break if i.length < 100
31
+ end
32
+ items
33
+ end
34
+
35
+ def items_for_offset(item, offset)
36
+ JSON.parse(HTTP.get("#{@base_url}&type_of_media=#{item}&offset=#{offset}").to_s, object_class: RecursiveOpenStruct).items.item
37
+ end
38
+
39
+ def mynewsdesk_items
40
+ @items ||= options.types_of_media.map do |item|
41
+ all_items_for(item)
42
+ end.flatten.sort { |a, b| Time.parse(b.published_at) <=> Time.parse(a.published_at) }
43
+
44
+ @items
26
45
  end
27
46
  end
@@ -3,7 +3,7 @@ $:.push File.expand_path('lib', __dir__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "middleman_mynewsdesk"
6
- s.version = "0.0.5"
6
+ s.version = "0.0.6"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Johan Halse"]
9
9
  s.email = ["johan.halse@varvet.com"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman_mynewsdesk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johan Halse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-17 00:00:00.000000000 Z
11
+ date: 2018-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman-core