hub_helper.rb
1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
module CommunityHubPlugin::HubHelper
def post_css_classes(post_id, latest_post_id, oldest_post_id)
classes = "post"
if post_id == latest_post_id
classes += " latest"
end
if post_id == oldest_post_id
classes += " oldest"
end
classes
end
def mediator?(hub)
logged_in? && (hub.author.id == user.id || hub.mediators.include?(user.id)) ? true : false
end
def promoted?(hub, user_id)
logged_in? && (hub.author.id == user_id || hub.mediators.include?(user_id)) ? true : false
end
def pinned_message?(hub, message_id)
hub.pinned_messages.include?(message_id) ? true : false
end
def pinned_mediation?(hub, mediation_id)
hub.pinned_mediations.include?(mediation_id) ? true : false
end
def post_time(time)
if time
_('%{hour}:%{minutes}') % { :hour => time.hour, :minutes => time.strftime("%M") }
else
''
end
end
def embed_code(hub)
"<iframe width='425' height='350' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='#{url_for(hub.url)}'></iframe>"
end
end