| 1 |
|
| 2 |
|
| 3 |
module Plugin::Activity |
| 4 |
class Activity < Diva::Model |
| 5 |
extend Memoist |
| 6 |
|
| 7 |
include Diva::Model::MessageMixin |
| 8 |
include Diva::Model::UserMixin |
| 9 |
|
| 10 |
register :activity, name: "Activity" |
| 11 |
|
| 12 |
field.string :description, required: true |
| 13 |
field.string :title, required: true |
| 14 |
field.has :icon, Diva::Model |
| 15 |
field.bool :related |
| 16 |
field.string :plugin_slug |
| 17 |
field.time :date, required: true |
| 18 |
field.string :kind, required: true |
| 19 |
field.string :identity |
| 20 |
field.has :children, [Diva::Model] |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
ンを表示するため |
| 25 |
def profile_image_url |
| 26 |
icon || ::Skin.get_path('activity.png') |
| 27 |
end |
| 28 |
|
| 29 |
def plugin |
| 30 |
self[:plugin] || Plugin[plugin_slug] |
| 31 |
end |
| 32 |
|
| 33 |
def title |
| 34 |
self[:title].tr("\n", "") |
| 35 |
end |
| 36 |
|
| 37 |
def children |
| 38 |
self[:children] || [] |
| 39 |
end |
| 40 |
|
| 41 |
示するため |
| 42 |
def name |
| 43 |
title |
| 44 |
end |
| 45 |
|
| 46 |
示するため |
| 47 |
def created |
| 48 |
date |
| 49 |
end |
| 50 |
|
| 51 |
def host |
| 52 |
kind.gsub('_', '-') |
| 53 |
end |
| 54 |
|
| 55 |
memoize def path |
| 56 |
if identity |
| 57 |
identity |
| 58 |
elsif children.empty? |
| 59 |
'/' + SecureRandom.uuid |
| 60 |
else |
| 61 |
children.inject('/'){|memo,child| memo + Digest::MD5.hexdigest(child.uri.to_s) + '/' } |
| 62 |
end |
| 63 |
end |
| 64 |
end |
| 65 |
end |