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 +4 -4
- data/lib/middleman_mynewsdesk/extension.rb +22 -3
- data/middleman_mynewsdesk.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aaf400132528545cce35021c841b1958d2758aab
|
4
|
+
data.tar.gz: 9ea0333e81b78aacb3b7e163752da2503b26cfce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
24
|
-
|
25
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2018-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: middleman-core
|