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 +4 -4
- data/Gemfile.lock +1 -1
- data/app/assets/javascripts/ants/slug.coffee +1 -1
- data/app/helpers/content_helper.rb +16 -0
- data/lib/ants/version.rb +1 -1
- data/lib/ants.rb +1 -0
- data/lib/concerns/ants/content.rb +83 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67ea0c217984b55a62704317801681d551960a2a
|
4
|
+
data.tar.gz: 195e4cd78e57449eb38b64497b8dd6dd9561413a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 048caf0cbfaf3775d26805bc2ca0c3e00d1e99a8ccdb19de3e480627f4baa279841da2c394d60662c051cf5bb146407ce178f9e8b21340113abe388032c589bd
|
7
|
+
data.tar.gz: 0fba1cc2d274a16ccfff22040e5b5fcac673c7915bbc0cad5497f91be740951f1ff3665fb196cb96ee64dbb4c0e7703038bd84e2901584a6f10e28c341a76f6b
|
data/Gemfile.lock
CHANGED
@@ -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
data/lib/ants.rb
CHANGED
@@ -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.
|
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-
|
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
|