ants 0.3.2 → 0.3.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f66e4d763a22d8eed7a9323c29e8b30ad44f546
4
- data.tar.gz: 790e6bee19b7a80e356216a1af640cfd6684e0ce
3
+ metadata.gz: 67ea0c217984b55a62704317801681d551960a2a
4
+ data.tar.gz: 195e4cd78e57449eb38b64497b8dd6dd9561413a
5
5
  SHA512:
6
- metadata.gz: d0c9d585a78cad4a53ac329509d21ff3348adadd46775ca703eb29d9c47a9bd3ed84c2d09111c02e18974fbd7acc5d4c5722751ecb2d1cca0531513fa135077e
7
- data.tar.gz: b7dfda81fa43859297f7b82428b496572cde42115b523bcf8443604c55ce13b6733557f5af05d74afecd359aaadc2ac62442f383ad6eaf203488682b63da3e64
6
+ metadata.gz: 048caf0cbfaf3775d26805bc2ca0c3e00d1e99a8ccdb19de3e480627f4baa279841da2c394d60662c051cf5bb146407ce178f9e8b21340113abe388032c589bd
7
+ data.tar.gz: 0fba1cc2d274a16ccfff22040e5b5fcac673c7915bbc0cad5497f91be740951f1ff3665fb196cb96ee64dbb4c0e7703038bd84e2901584a6f10e28c341a76f6b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ants (0.3.2)
4
+ ants (0.3.3)
5
5
  devise
6
6
  mongoid (>= 4.0)
7
7
  mongoid-slug (>= 4.0.0)
@@ -3,7 +3,7 @@ class @AntsSlugInput
3
3
  config =
4
4
  type: 'string'
5
5
  name: '_slug'
6
- label: 'Permalink'
6
+ label: 'Slug'
7
7
  placeholder: ''
8
8
  onInitialize: (input) ->
9
9
  if input.object && input.object._slugs.length
@@ -0,0 +1,16 @@
1
+ module ContentHelper
2
+ def content_meta_tags(object)
3
+ open_graph_tags = { title: object.meta_title,
4
+ description: object.meta_description,
5
+ url: object.canonical_url,
6
+ type: object.meta_type,
7
+ image: object.opengraph_image_url,
8
+ updated_time: object.updated_at.to_i }
9
+
10
+ set_meta_tags title: object.meta_title,
11
+ description: object.meta_description,
12
+ keywords: object.meta_keywords,
13
+ canonical: object.canonical_url,
14
+ og: open_graph_tags
15
+ end
16
+ end
data/lib/ants/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ants
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
data/lib/ants.rb CHANGED
@@ -16,6 +16,7 @@ module Ants
16
16
  require "concerns/ants/publication"
17
17
  require "concerns/ants/sorted_relations"
18
18
  require "concerns/ants/versions"
19
+ require "concerns/ants/content"
19
20
 
20
21
  require "constraints/redirects"
21
22
  end
@@ -0,0 +1,83 @@
1
+ module Ants
2
+ module Content
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ include Mongoid::Document
7
+ include Mongoid::Timestamps
8
+ include Mongoid::Search
9
+ include Ants::Id
10
+ include Ants::Slug
11
+ include Ants::Hideable
12
+ include Ants::Meta
13
+
14
+ ## Attributes
15
+ field :title
16
+ field :body_markdown
17
+ field :body_html
18
+
19
+ ## Validation
20
+ validates_presence_of :title
21
+
22
+ ## Search & Slug
23
+ search_in :title
24
+ slug :title
25
+
26
+ ## Helpers
27
+ def _list_item_title
28
+ title
29
+ end
30
+
31
+ def canonical_url
32
+ "#{protocole}#{host}/#{slug}"
33
+ end
34
+
35
+ def meta_type
36
+ 'article'
37
+ end
38
+
39
+ def meta_title
40
+ _meta_title.presence || title
41
+ end
42
+
43
+ def meta_description
44
+ _meta_description.presence || excerpt_text
45
+ end
46
+
47
+ def meta_keywords
48
+ _meta_keywords.presence
49
+ end
50
+
51
+ def opengraph_image_url
52
+ url = _opengraph_image_url.presence
53
+ if url
54
+ if !url.include?('//')
55
+ "#{protocole}#{host}#{url}"
56
+ else
57
+ url
58
+ end
59
+ else
60
+ ''
61
+ end
62
+ end
63
+
64
+ protected
65
+
66
+ def host
67
+ @host ||= ENV.fetch("HOST")
68
+ end
69
+
70
+ def protocole
71
+ @protocole ||= Rails.application.config.force_ssl ? "https://" : "http://"
72
+ end
73
+
74
+ private
75
+
76
+ def excerpt_text
77
+ ActionController::Base.helpers.strip_tags(excerpt_html).
78
+ gsub("\n", "").
79
+ gsub("\r", "") # ADD LIMIT HERE WITH TRUNCATION
80
+ end
81
+ end
82
+ end
83
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ants
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Kravets
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-20 00:00:00.000000000 Z
11
+ date: 2015-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
@@ -167,6 +167,7 @@ files:
167
167
  - app/controllers/admin/menus_controller.rb
168
168
  - app/controllers/admin/redirects_controller.rb
169
169
  - app/controllers/redirects_controller.rb
170
+ - app/helpers/content_helper.rb
170
171
  - app/helpers/menu_helper.rb
171
172
  - app/mailers/admin_user_mailer.rb
172
173
  - app/models/admin_user.rb
@@ -177,6 +178,7 @@ files:
177
178
  - lib/ants.rb
178
179
  - lib/ants/engine.rb
179
180
  - lib/ants/version.rb
181
+ - lib/concerns/ants/content.rb
180
182
  - lib/concerns/ants/featurable.rb
181
183
  - lib/concerns/ants/hideable.rb
182
184
  - lib/concerns/ants/id.rb