homesteading_helpers 0.0.2 → 0.0.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b50362479975ec52638b2eb14fb1c33547a826e9
|
4
|
+
data.tar.gz: d84edc9b3b17e409b9243f29ad1dc0aa69193dfb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb13b00be5b11efaccf5208ec19bb030d3336d29d0b44c88fe5ccb71090232fa9d96f7822fb4c1dd6639bd7b387ebd930bf21986e34817330c0ddca1c0dddd02
|
7
|
+
data.tar.gz: b79b9b619492b36208aa44821962ae0bb865d083783800a897726d0cff56326e851216413a2e9d2cdf58e32cbdb7bc91da15e694cac37d6f1505ca90ea2fc2a3
|
@@ -1,6 +1,83 @@
|
|
1
1
|
module HomesteadingHelpers
|
2
2
|
module ApplicationHelper
|
3
3
|
|
4
|
+
def shorturl_link_tag(post)
|
5
|
+
url = "http://#{setting :short_domain}"
|
6
|
+
|
7
|
+
if index_action?
|
8
|
+
url = "http://#{setting :short_domain}/#{setting :post_short_code}"
|
9
|
+
elsif show_action?
|
10
|
+
url = short_url(post)
|
11
|
+
end
|
12
|
+
|
13
|
+
tag(:link, id: "shortlink", rel: "shortlink", type: "text/html", href: url)
|
14
|
+
end
|
15
|
+
|
16
|
+
def short_url(post)
|
17
|
+
pieces = [setting(:post_short_code)]
|
18
|
+
|
19
|
+
pieces << Date.parse("#{post.year}/#{post.month}/#{post.day}").to_sxg
|
20
|
+
pieces << nth_of_day(post)
|
21
|
+
|
22
|
+
"http://#{setting :short_domain}/#{pieces.join}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def nth_of_day(post)
|
26
|
+
if post.is_a?(Note)
|
27
|
+
nth = Note.where(year: post.year,
|
28
|
+
month: post.month,
|
29
|
+
day: post.day).all.sort_by{|n| n.published_at}.index(post) + 1
|
30
|
+
else
|
31
|
+
nth = 1
|
32
|
+
end
|
33
|
+
|
34
|
+
nth.to_sxg
|
35
|
+
end
|
36
|
+
|
37
|
+
def canonical_url(post=nil)
|
38
|
+
if post.nil?
|
39
|
+
"http://#{setting :long_domain}"
|
40
|
+
else
|
41
|
+
# TODO refactor away from "note"
|
42
|
+
"http://#{setting :long_domain}/#{note_path(post)}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def rel_canonical_link_tag(post)
|
47
|
+
url = "http://#{setting :long_domain}"
|
48
|
+
if index_action?
|
49
|
+
url = "http://#{setting :long_domain}/#{setting(:post_type).pluralize.downcase}"
|
50
|
+
elsif show_action?
|
51
|
+
url = canonical_url(post)
|
52
|
+
end
|
53
|
+
|
54
|
+
tag(:link, id: "canonical", rel: "canonical", type: "text/html", href: url)
|
55
|
+
end
|
56
|
+
|
57
|
+
def page_description(post=nil)
|
58
|
+
page_description = setting(:site_description)
|
59
|
+
|
60
|
+
if index_action?
|
61
|
+
page_description = "#{setting(:post_type).pluralize.capitalize} by #{setting :author_name}"
|
62
|
+
elsif show_action?
|
63
|
+
page_description = post.content
|
64
|
+
end
|
65
|
+
|
66
|
+
page_description
|
67
|
+
end
|
68
|
+
|
69
|
+
def space
|
70
|
+
" "
|
71
|
+
end
|
72
|
+
|
73
|
+
def index_action?
|
74
|
+
action_name == "index"
|
75
|
+
end
|
76
|
+
|
77
|
+
def show_action?
|
78
|
+
action_name == "show"
|
79
|
+
end
|
80
|
+
|
4
81
|
def write_action?
|
5
82
|
unless controller_name == "settings"
|
6
83
|
action_name =~ /new|edit/
|
@@ -46,7 +123,7 @@ module HomesteadingHelpers
|
|
46
123
|
end
|
47
124
|
|
48
125
|
if @page_title
|
49
|
-
title << "
|
126
|
+
title << " - #{@page_title}"
|
50
127
|
end
|
51
128
|
|
52
129
|
title.html_safe
|
@@ -67,11 +144,59 @@ module HomesteadingHelpers
|
|
67
144
|
url = "http://#{url}"
|
68
145
|
end
|
69
146
|
|
70
|
-
|
147
|
+
rel = show_action? ? "in-reply-to external" : "external"
|
148
|
+
html << link_to(text, url, class: "u-in-reply-to h-cite", rel: rel).html_safe
|
71
149
|
end
|
72
150
|
|
73
151
|
html.join(" ").html_safe
|
74
152
|
end
|
75
153
|
|
154
|
+
def link_to_syndication(post)
|
155
|
+
html = content_tag(:p, "Also posted to")
|
156
|
+
|
157
|
+
links = []
|
158
|
+
|
159
|
+
external_silos.each do |external|
|
160
|
+
if post.respond_to?(external_silo_url_key(external)) &&
|
161
|
+
post.send(external_silo_url_key(external)) &&
|
162
|
+
!post.send(external_silo_url_key(external)).blank?
|
163
|
+
|
164
|
+
rel = "external "
|
165
|
+
rel << "syndication" if show_action?
|
166
|
+
|
167
|
+
links << content_tag(:li, link_to(external, post.send(external_silo_url_key(external)), rel: rel, class: "u-syndication"))
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
if links.blank?
|
172
|
+
space
|
173
|
+
else
|
174
|
+
html << content_tag(:ul, links.flatten.join.html_safe)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def external_silos
|
179
|
+
%w[
|
180
|
+
Facebook
|
181
|
+
Foursquare
|
182
|
+
Instagram
|
183
|
+
Medium
|
184
|
+
Tumblr
|
185
|
+
Twitter
|
186
|
+
Vimeo
|
187
|
+
Vine
|
188
|
+
WordPress
|
189
|
+
YouTube
|
190
|
+
]
|
191
|
+
end
|
192
|
+
|
193
|
+
def external_silo_url_key(name)
|
194
|
+
"#{name.downcase}_url".to_sym
|
195
|
+
end
|
196
|
+
|
197
|
+
def is_a_reply?(post)
|
198
|
+
!post.in_reply_to.blank?
|
199
|
+
end
|
200
|
+
|
76
201
|
end
|
77
202
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: homesteading_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane Becker
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-07-
|
12
|
+
date: 2014-07-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|