georgedrummond_sinatra_helpers 0.0.4 → 0.0.5
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.
@@ -4,7 +4,24 @@ require "digest/md5"
|
|
4
4
|
module GeorgeDrummond
|
5
5
|
module Sinatra
|
6
6
|
module Helpers
|
7
|
-
# Creates the
|
7
|
+
# Creates the html for a mail_to link being given an email address and an optional text argument
|
8
|
+
#
|
9
|
+
# ==== Examples
|
10
|
+
#
|
11
|
+
# With only an email address provided
|
12
|
+
#
|
13
|
+
# mail_to("georgedrummond@gmail.com")
|
14
|
+
# # => <a href="mailto:georgedrummond@gmail.com" class="mailto">georgedrummond@gmail.com</a>
|
15
|
+
#
|
16
|
+
# With an optional text field provided
|
17
|
+
#
|
18
|
+
# mail_to("georgedrummond@gmail.com", "George Drummond")
|
19
|
+
# # => <a href="mailto:georgedrummond@gmail.com" class="mailto">George Drummond</a>
|
20
|
+
def mail_to(email, text=email)
|
21
|
+
"<a href=\"mailto:\"#{email}\" class=\"mailto\">#{text}</a>"
|
22
|
+
end
|
23
|
+
|
24
|
+
# Creates the gravatar (www.gravatar.com) html from the email address and arguments provided.
|
8
25
|
# If no size is specified then it defaults to 50x50px
|
9
26
|
#
|
10
27
|
# ==== Examples
|
@@ -18,7 +35,6 @@ module GeorgeDrummond
|
|
18
35
|
#
|
19
36
|
# gravatar_image("georgedrummond@gmail.com", 150)
|
20
37
|
# # => <img src="http://www.gravatar.com/avatar/d278a12b969a495ab16fdd942e748fe5?s=150" class="gravatar" />
|
21
|
-
#
|
22
38
|
def gravatar_image(email, size=50)
|
23
39
|
hash = Digest::MD5.hexdigest(email)
|
24
40
|
"<img src=\"http://www.gravatar.com/avatar/#{hash}?s=#{size}\" class=\"gravatar\" />"
|