middleman-medium 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 18811a336a7eda3625d12e273d84f0364993a8b2591834a4731c8cd1b89a092d
4
+ data.tar.gz: d51129a7689f44c4e3a85e299f1980785751215ec7b8e2c88f3ef3cdfcc915ea
5
+ SHA512:
6
+ metadata.gz: 0fb113b84a92af61e6580cd04dce7300dab97c1d63517b61e922ed4344becad8f3b750b08451b6d3609f5c45c8900be6a516c8e3d0bfc3bf60cdfcab5d96ea2b
7
+ data.tar.gz: 0b429542cee569eb77dfb9e166b227733722dd8d65e0c7c7bb2ae6275bdd258aea5295c4e39babc13e2aa5797ca5a71ae5afd28befbba30bc5255747a5b53991
@@ -0,0 +1,50 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
@@ -0,0 +1,13 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install: gem install bundler -v 1.16.0.pre.2
6
+ deploy:
7
+ provider: rubygems
8
+ api_key:
9
+ secure: FL18oboOrUK8xa32WsL9eeyfNTwZP4+AOSehnFc/BOynqvMghfCB4amzEkPDIctXtr//75pA29VwM4LuzE5bMbEFnk3joO/GuSBEHOYC6pkECsQjqtOzmy1/3mWiAVRl8jmPSn7lu9PZF0ZJIUaBk7r8LCcIPSSq1nufmlX98hE++5LZobDPmHIQrzYpfPYRczOh3YkDuwaUn8Vw4iqsTlID0m5Qdy9L7mCrjF9W8FtPCo5qhSvcWPOGjOBR9hkM3ZK4h5J6GLrvNitCtGTAzSlDbVmvrOAVk8i/eR1uWfKzed/FQahLnc4YCU8n38MuWCpuYply+UXg10rQ+s6LsSni/IyDOL4Fv8fUHbqidRLD7xVmRJoltEpTAWwLbNFCsEa3hORt2wRLNJgt7Gj0KMS6PrpP5hsMI8ye8aS9fl98/2hgatBGIznjzYJ7hpr7w9HFWlcno1C664hKe4VrwREDLzH8eABCQkpzmFAqyuw8PY4Age9vc1YZg0zoHmg3I5xM515ja4csf23QvkjvINoo115GWhZvtNKnaPyoMuiyTgeUxHAk7e4k0024V1dQllH/c3Nmj7CXIQJKKYt2rK860yzjIy3bXDjnfJk9cW+7wIBAmZYOTahWvQJw0Re4gYr/dIkvPuv2845zVuGGfrekLgqEXGadBqAhlhuGMq4=
10
+ gem: middleman-medium
11
+ on:
12
+ tags: true
13
+ repo: cffiebigc/middleman-medium
data/Gemfile ADDED
@@ -0,0 +1,22 @@
1
+ # If you do not have OpenSSL installed, update
2
+ # the following line to use "http://" instead
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in middleman-medium.gemspec
6
+ gemspec
7
+
8
+ group :development, :test do
9
+ gem 'middleman-cli'
10
+ end
11
+
12
+ group :development do
13
+ gem 'rake'
14
+ gem 'rdoc'
15
+ gem 'yard'
16
+ end
17
+
18
+ group :test do
19
+ gem 'cucumber'
20
+ gem 'aruba'
21
+ gem 'rspec'
22
+ end
@@ -0,0 +1,156 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ middleman-medium (0.0.1)
5
+ middleman-core (~> 4.2, >= 4.2.1)
6
+ nokogiri (~> 1.8, >= 1.8.2)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (5.0.7)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 0.7, < 2)
14
+ minitest (~> 5.1)
15
+ tzinfo (~> 1.1)
16
+ addressable (2.5.2)
17
+ public_suffix (>= 2.0.2, < 4.0)
18
+ aruba (0.14.5)
19
+ childprocess (>= 0.6.3, < 0.10.0)
20
+ contracts (~> 0.9)
21
+ cucumber (>= 1.3.19)
22
+ ffi (~> 1.9.10)
23
+ rspec-expectations (>= 2.99)
24
+ thor (~> 0.19)
25
+ backports (3.11.3)
26
+ builder (3.2.3)
27
+ childprocess (0.9.0)
28
+ ffi (~> 1.0, >= 1.0.11)
29
+ coderay (1.1.2)
30
+ concurrent-ruby (1.0.5)
31
+ contracts (0.13.0)
32
+ cucumber (3.1.0)
33
+ builder (>= 2.1.2)
34
+ cucumber-core (~> 3.1.0)
35
+ cucumber-expressions (~> 5.0.4)
36
+ cucumber-wire (~> 0.0.1)
37
+ diff-lcs (~> 1.3)
38
+ gherkin (~> 5.0)
39
+ multi_json (>= 1.7.5, < 2.0)
40
+ multi_test (>= 0.1.2)
41
+ cucumber-core (3.1.0)
42
+ backports (>= 3.8.0)
43
+ cucumber-tag_expressions (~> 1.1.0)
44
+ gherkin (>= 5.0.0)
45
+ cucumber-expressions (5.0.18)
46
+ cucumber-tag_expressions (1.1.1)
47
+ cucumber-wire (0.0.1)
48
+ diff-lcs (1.3)
49
+ dotenv (2.4.0)
50
+ erubis (2.7.0)
51
+ execjs (2.7.0)
52
+ fast_blank (1.0.0)
53
+ fastimage (2.1.3)
54
+ ffi (1.9.23)
55
+ gherkin (5.0.0)
56
+ hamster (3.0.0)
57
+ concurrent-ruby (~> 1.0)
58
+ hashie (3.5.7)
59
+ i18n (0.7.0)
60
+ listen (3.0.8)
61
+ rb-fsevent (~> 0.9, >= 0.9.4)
62
+ rb-inotify (~> 0.9, >= 0.9.7)
63
+ memoist (0.16.0)
64
+ method_source (0.9.0)
65
+ middleman-cli (4.2.1)
66
+ thor (>= 0.17.0, < 2.0)
67
+ middleman-core (4.2.1)
68
+ activesupport (>= 4.2, < 5.1)
69
+ addressable (~> 2.3)
70
+ backports (~> 3.6)
71
+ bundler (~> 1.1)
72
+ contracts (~> 0.13.0)
73
+ dotenv
74
+ erubis
75
+ execjs (~> 2.0)
76
+ fast_blank
77
+ fastimage (~> 2.0)
78
+ hamster (~> 3.0)
79
+ hashie (~> 3.4)
80
+ i18n (~> 0.7.0)
81
+ listen (~> 3.0.0)
82
+ memoist (~> 0.14)
83
+ padrino-helpers (~> 0.13.0)
84
+ parallel
85
+ rack (>= 1.4.5, < 3)
86
+ sass (>= 3.4)
87
+ servolux
88
+ tilt (~> 2.0)
89
+ uglifier (~> 3.0)
90
+ mini_portile2 (2.3.0)
91
+ minitest (5.11.3)
92
+ multi_json (1.13.1)
93
+ multi_test (0.1.2)
94
+ nokogiri (1.8.2)
95
+ mini_portile2 (~> 2.3.0)
96
+ padrino-helpers (0.13.3.4)
97
+ i18n (~> 0.6, >= 0.6.7)
98
+ padrino-support (= 0.13.3.4)
99
+ tilt (>= 1.4.1, < 3)
100
+ padrino-support (0.13.3.4)
101
+ activesupport (>= 3.1)
102
+ parallel (1.12.1)
103
+ pry (0.11.3)
104
+ coderay (~> 1.1.0)
105
+ method_source (~> 0.9.0)
106
+ public_suffix (3.0.2)
107
+ rack (2.0.5)
108
+ rake (12.3.1)
109
+ rb-fsevent (0.10.3)
110
+ rb-inotify (0.9.10)
111
+ ffi (>= 0.5.0, < 2)
112
+ rdoc (6.0.4)
113
+ rspec (3.7.0)
114
+ rspec-core (~> 3.7.0)
115
+ rspec-expectations (~> 3.7.0)
116
+ rspec-mocks (~> 3.7.0)
117
+ rspec-core (3.7.1)
118
+ rspec-support (~> 3.7.0)
119
+ rspec-expectations (3.7.0)
120
+ diff-lcs (>= 1.2.0, < 2.0)
121
+ rspec-support (~> 3.7.0)
122
+ rspec-mocks (3.7.0)
123
+ diff-lcs (>= 1.2.0, < 2.0)
124
+ rspec-support (~> 3.7.0)
125
+ rspec-support (3.7.1)
126
+ sass (3.5.6)
127
+ sass-listen (~> 4.0.0)
128
+ sass-listen (4.0.0)
129
+ rb-fsevent (~> 0.9, >= 0.9.4)
130
+ rb-inotify (~> 0.9, >= 0.9.7)
131
+ servolux (0.13.0)
132
+ thor (0.20.0)
133
+ thread_safe (0.3.6)
134
+ tilt (2.0.8)
135
+ tzinfo (1.2.5)
136
+ thread_safe (~> 0.1)
137
+ uglifier (3.2.0)
138
+ execjs (>= 0.3.0, < 3)
139
+ yard (0.9.13)
140
+
141
+ PLATFORMS
142
+ ruby
143
+
144
+ DEPENDENCIES
145
+ aruba
146
+ cucumber
147
+ middleman-cli
148
+ middleman-medium!
149
+ pry (~> 0.11)
150
+ rake
151
+ rdoc
152
+ rspec
153
+ yard
154
+
155
+ BUNDLED WITH
156
+ 1.16.1
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Carlos Fiebig
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,53 @@
1
+ # middleman-medium
2
+ Fetches posts preview from Medium Feed
3
+
4
+ If what you need is to build a preview of you latest medium posts on your site this is the right middleman extension for you.
5
+
6
+ Just add it to your `config.rb` file like any other middleman extension.
7
+
8
+ ```ruby
9
+ activate :middleman_medium, source: 'https://blog.continuum.cl/feed'
10
+ ```
11
+
12
+ The source option must be the feed of your medium account, which normaly is
13
+ `https://medium.com/feed/YOUR-ACCOUNT`
14
+
15
+ The method `fetch_medium_posts` is exposed to the templates and return an array
16
+ of Hashes with the following structure:
17
+
18
+ ```ruby
19
+ [
20
+ {
21
+ title: "La verdadera experiencia de usuario",
22
+ date: 2018-05-23 17:18:33 +0000,
23
+ url: "https://blog.continuum.cl/la-verdadera-experiencia-de-usuario-4683f3f1236a? source=rss----d66605ce046d---4",
24
+ category: "continuous-delivery",
25
+ img: "https://cdn-images-1.medium.com/max/1024/1*CEEf5FiezbTxPLOmt4hntg.jpeg"
26
+ },
27
+ {
28
+ title:"Las 7 razones por las que falla un proyecto digital",
29
+ date: 2018-05-29 13:59:44 +0000,
30
+ url: "https://blog.continuum.cl/las-7-razones-por-las-que-falla-un-proyecto-digital-1de23ac573bb?source=rss----d66605ce046d---4",
31
+ category: "ux-research",
32
+ img: "https://cdn-images-1.medium.com/max/1024/1*CE_9F97oNWK0mN3ROT0Nhg.jpeg"
33
+ }
34
+ ]
35
+ ```
36
+
37
+ Receiving this Hash gives you the possibility to build the preview of the posts the way you want, here is an example using an `erb` template:
38
+
39
+ ```html
40
+ <div class="blogposts-grid">
41
+ <%- fetch_medium_posts.each do |post| %>
42
+ <div class="blogposts-grid-item">
43
+ <a href="<%= post[:url] %>" target="blank">
44
+ <div class="blogposts-item-image" style="background-image: url('<%= post[:img] %>')"></div>
45
+ <div class="blogposts-item-caption">
46
+ <h3><%= post[:title] %></h3>
47
+ <h6><%= post[:category] %></h6>
48
+ </div>
49
+ </a>
50
+ </div>
51
+ <% end %>
52
+ </div>
53
+ ```
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,6 @@
1
+ require "middleman-core"
2
+
3
+ Middleman::Extensions.register :middleman_medium do
4
+ require "middleman-medium/extension"
5
+ MediumExtension
6
+ end
@@ -0,0 +1,38 @@
1
+ # Require core library
2
+ require 'middleman-core'
3
+
4
+ # Extension namespace
5
+ class MediumExtension < ::Middleman::Extension
6
+ option :source, 'https://blog.continuum.cl/feed', 'https://medium.com/feed/your-account'
7
+ expose_to_template :fetch_medium_posts
8
+
9
+ def initialize(app, options_hash={}, &block)
10
+ super
11
+ require 'rss'
12
+ require 'nokogiri'
13
+ end
14
+
15
+ def fetch_medium_posts
16
+ medium_rss_to_hash(open(options.source).read)
17
+ end
18
+
19
+ def medium_rss_parser(feed)
20
+ posts = []
21
+ rss = RSS::Parser.parse(feed, false).items
22
+ rss.each do |item|
23
+ posts.push(rss_item_to_hash(item))
24
+ end
25
+ posts
26
+ end
27
+
28
+ def rss_item_to_hash(item)
29
+ document = Nokogiri::HTML.fragment(item.content_encoded)
30
+ {
31
+ title: item.title,
32
+ date: item.pubDate,
33
+ url: item.link,
34
+ category: item&.category&.content,
35
+ img: document&.search('img')&.first['src']
36
+ }
37
+ end
38
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "middleman-medium"
6
+ s.version = "0.0.1"
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Carlos Fiebig"]
9
+ s.email = ["cffiebigc@gmail.com"]
10
+ s.homepage = "https://github.com/cffiebigc/middleman-medium"
11
+ s.summary = %q{Fetches medium posts from feed}
12
+ s.description = %q{Fetches medium posts from feed to build a preview in your website}
13
+ s.license = "MIT"
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ # The version of middleman-core your extension depends on
20
+ s.add_runtime_dependency 'middleman-core', '~> 4.2', '>= 4.2.1'
21
+ s.add_runtime_dependency 'nokogiri', '~> 1.8', '>= 1.8.2'
22
+
23
+ s.add_development_dependency "rspec", '~> 3.7'
24
+ s.add_development_dependency "pry", '~> 0.11'
25
+ s.add_development_dependency "rake", '~> 12.3'
26
+ end
@@ -0,0 +1,15 @@
1
+ require 'bundler/setup'
2
+ require 'middleman-medium'
3
+ require 'pry'
4
+
5
+ RSpec.configure do |config|
6
+ # Enable flags like --only-failures and --next-failure
7
+ config.example_status_persistence_file_path = ".rspec_status"
8
+
9
+ # Disable RSpec exposing methods globally on `Module` and `main`
10
+ config.disable_monkey_patching!
11
+
12
+ config.expect_with :rspec do |c|
13
+ c.syntax = :expect
14
+ end
15
+ end
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: middleman-medium
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Carlos Fiebig
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-06-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: middleman-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.2'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 4.2.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '4.2'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 4.2.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: nokogiri
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.8'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 1.8.2
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '1.8'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 1.8.2
53
+ - !ruby/object:Gem::Dependency
54
+ name: rspec
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '3.7'
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '3.7'
67
+ - !ruby/object:Gem::Dependency
68
+ name: pry
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '0.11'
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '0.11'
81
+ - !ruby/object:Gem::Dependency
82
+ name: rake
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '12.3'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: '12.3'
95
+ description: Fetches medium posts from feed to build a preview in your website
96
+ email:
97
+ - cffiebigc@gmail.com
98
+ executables: []
99
+ extensions: []
100
+ extra_rdoc_files: []
101
+ files:
102
+ - ".gitignore"
103
+ - ".travis.yml"
104
+ - Gemfile
105
+ - Gemfile.lock
106
+ - LICENSE
107
+ - README.md
108
+ - Rakefile
109
+ - lib/middleman-medium.rb
110
+ - lib/middleman-medium/extension.rb
111
+ - middleman-medium.gemspec
112
+ - spec/spec_helper.rb
113
+ homepage: https://github.com/cffiebigc/middleman-medium
114
+ licenses:
115
+ - MIT
116
+ metadata: {}
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 2.7.7
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: Fetches medium posts from feed
137
+ test_files: []