cortex-snippets-client-ruby 0.4.4 → 0.5.0

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: df338b4f0e6a4346e27396bb9c6001ee5196fdc9
4
- data.tar.gz: f6946895f9c94d5befdb34e5f914bcf4ef748cb6
3
+ metadata.gz: 658d9c6e13da576bf96579154111e317484235b8
4
+ data.tar.gz: 9dd435e240feff3a30f943fd907a28baffda1af2
5
5
  SHA512:
6
- metadata.gz: 64b1f827bc5acca985818a4f091dbd35f5d129de68d24ac774c84f0b73e5417c02942021edc1eb8fb887a7b96116dc575ca8c80eee5ee5031c58438086750293
7
- data.tar.gz: 50f61236247d27e085d13ba24621e343ab99dc5db4d60e144f8601d03c4ae0c8629c7ced01026d77e283c0b54dcc33e7f993a2c899a1624c22247a2341aa104b
6
+ metadata.gz: 6804bad23b04cf563059415db5bb70fba149391d4eaedfe04946244befb9db8ab456e3cc5402d77df3bb47a70ef7bf9245ab1ded84625119ffcae7e1b96da701
7
+ data.tar.gz: a824953d79ef9714539883851e48c8f1e4622f52c68631340a7f86ec24ea3cf3fcbca546f7cd22b168f51389ebedc1190953f71f2f473804f6264a04e49d6048
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ Version History
2
+ ====
3
+ * All Version bumps are required to update this file as well!!
4
+ ----
5
+
6
+ * 0.5.0 - Auto-inject Client Helper into Views/Controllers. Pass through to Snippet tag entire set of HTML attributes. Implement new namespacing and support Bundler.require.
@@ -1,11 +1,11 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'cortex/snippets/version'
4
+ require 'cortex/snippets/client/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'cortex-snippets-client-ruby'
8
- spec.version = Cortex::Snippets::VERSION
8
+ spec.version = Cortex::Snippets::Client::VERSION
9
9
  spec.authors = ['CB Content Enablement']
10
10
  spec.email = ['ContentEnablementProductTeam@careerbuilder.com']
11
11
  spec.license = 'Apache-2.0'
@@ -0,0 +1,2 @@
1
+ require 'cortex/snippets/client'
2
+ require 'cortex/snippets/client/version'
@@ -1,3 +1,5 @@
1
+ require 'cortex/snippets/client/helper'
2
+ require 'cortex/snippets/client/railtie' if defined?(Rails)
1
3
  require 'cortex-client'
2
4
  require 'connection_pool'
3
5
  require 'addressable/template'
@@ -16,7 +18,7 @@ module Cortex
16
18
 
17
19
  def current_webpage(request)
18
20
  if defined?(Rails)
19
- Rails.cache.fetch("webpages/#{request_url(request)}", expires_in: 30.minutes) do
21
+ Rails.cache.fetch("webpages/#{request_url(request)}", expires_in: 30.minutes, race_condition_ttl: 10) do
20
22
  cortex_client.webpages.get_feed(request_url(request)).contents
21
23
  end
22
24
  else
@@ -24,8 +26,6 @@ module Cortex
24
26
  end
25
27
  end
26
28
 
27
- private
28
-
29
29
  def request_url(request)
30
30
  # TODO: Should be grabbing request URL in a framework-agnostic manner, but this is fine for now
31
31
  uri = Addressable::URI.parse(request.original_url)
@@ -0,0 +1,60 @@
1
+ module Cortex
2
+ module Snippets
3
+ module Client
4
+ module Helper
5
+ def snippet(options = {}, &block)
6
+ snippets = webpage[:snippets] || []
7
+ snippet = snippets.find { |snippet| snippet[:document][:name] == options[:id] }
8
+
9
+ if snippet.nil? || snippet[:document][:body].nil? || snippet[:document][:body].empty?
10
+ content_tag(:snippet, capture(&block), options)
11
+ else
12
+ content_tag(:snippet, snippet[:document][:body].html_safe, options)
13
+ end
14
+ end
15
+
16
+ def seo_title
17
+ webpage[:seo_title]
18
+ end
19
+
20
+ def seo_description
21
+ webpage[:seo_description]
22
+ end
23
+
24
+ def seo_keywords
25
+ webpage[:seo_keywords]
26
+ end
27
+
28
+ def noindex
29
+ webpage[:noindex]
30
+ end
31
+
32
+ def nofollow
33
+ webpage[:nofollow]
34
+ end
35
+
36
+ def noodp
37
+ webpage[:noodp]
38
+ end
39
+
40
+ def nosnippet
41
+ webpage[:nosnippet]
42
+ end
43
+
44
+ def noarchive
45
+ webpage[:noarchive]
46
+ end
47
+
48
+ def noimageindex
49
+ webpage[:noimageindex]
50
+ end
51
+
52
+ private
53
+
54
+ def webpage
55
+ Cortex::Snippets::Client::current_webpage(request)
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,17 @@
1
+ module Cortex
2
+ module Snippets
3
+ module Client
4
+ class Railtie < Rails::Railtie
5
+ initializer 'cortex-snippets-client.view_controller_helpers' do |app|
6
+ ActiveSupport.on_load :action_view do
7
+ include Helper
8
+ end
9
+
10
+ ActiveSupport.on_load :action_controller do
11
+ include Helper
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,7 @@
1
+ module Cortex
2
+ module Snippets
3
+ module Client
4
+ VERSION = '0.5.0'
5
+ end
6
+ end
7
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cortex-snippets-client-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - CB Content Enablement
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-13 00:00:00.000000000 Z
11
+ date: 2016-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cortex-client
@@ -104,6 +104,7 @@ files:
104
104
  - ".gitignore"
105
105
  - ".rspec"
106
106
  - ".travis.yml"
107
+ - CHANGELOG.md
107
108
  - Gemfile
108
109
  - LICENSE
109
110
  - README.md
@@ -111,11 +112,11 @@ files:
111
112
  - bin/console
112
113
  - bin/setup
113
114
  - cortex-snippets-client-ruby.gemspec
114
- - lib/cortex/snippets-client.rb
115
+ - lib/cortex-snippets-client-ruby.rb
115
116
  - lib/cortex/snippets/client.rb
116
- - lib/cortex/snippets/railtie.rb
117
- - lib/cortex/snippets/version.rb
118
- - lib/cortex/snippets/view_helpers.rb
117
+ - lib/cortex/snippets/client/helper.rb
118
+ - lib/cortex/snippets/client/railtie.rb
119
+ - lib/cortex/snippets/client/version.rb
119
120
  homepage: https://github.com/cortex-cms/cortex-snippets-client-ruby
120
121
  licenses:
121
122
  - Apache-2.0
@@ -136,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
137
  version: '0'
137
138
  requirements: []
138
139
  rubyforge_project:
139
- rubygems_version: 2.5.2
140
+ rubygems_version: 2.5.1
140
141
  signing_key:
141
142
  specification_version: 4
142
143
  summary: Provides loading of Cortex snippets for Ruby applications, with some Rails
@@ -1,4 +0,0 @@
1
- require 'cortex/snippets/version'
2
- require 'cortex/snippets/client'
3
- require 'cortex/snippets/view_helpers'
4
- require 'cortex/snippets/railtie' if defined?(Rails)
@@ -1,9 +0,0 @@
1
- module Cortex
2
- module Snippets
3
- class Railtie < Rails::Railtie
4
- initializer 'cortex.snippets.view_helpers' do
5
- ActiveSupport.on_load( :action_view ){ include ViewHelpers }
6
- end
7
- end
8
- end
9
- end
@@ -1,5 +0,0 @@
1
- module Cortex
2
- module Snippets
3
- VERSION = '0.4.4'
4
- end
5
- end
@@ -1,53 +0,0 @@
1
- module Cortex
2
- module Snippets
3
- module ViewHelpers
4
- def snippet(options = {}, &block)
5
- snippet = webpage[:snippets].find { |snippet| snippet.name == options[:id] }
6
-
7
- if snippet.nil? || snippet.empty?
8
- content_tag(:snippet, capture(&block), id: options[:id])
9
- else
10
- content_tag(:snippet, snippet, id: options[:id])
11
- end
12
- end
13
-
14
- def seo_title
15
- webpage[:seo_title]
16
- end
17
-
18
- def seo_description
19
- webpage[:seo_description]
20
- end
21
-
22
- def noindex
23
- webpage[:noindex]
24
- end
25
-
26
- def nofollow
27
- webpage[:nofollow]
28
- end
29
-
30
- def noodp
31
- webpage[:noodp]
32
- end
33
-
34
- def nosnippet
35
- webpage[:nosnippet]
36
- end
37
-
38
- def noarchive
39
- webpage[:noarchive]
40
- end
41
-
42
- def noimageindex
43
- webpage[:noimageindex]
44
- end
45
-
46
- private
47
-
48
- def webpage
49
- Client::current_webpage(request)
50
- end
51
- end
52
- end
53
- end