summaryrefslogtreecommitdiff
path: root/src/web/app/common/scripts/get-post-summary.ls
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2016-12-29 07:49:51 +0900
committersyuilo <syuilotan@yahoo.co.jp>2016-12-29 07:49:51 +0900
commitb3f42e62af698a67c2250533c437569559f1fdf9 (patch)
treecdf6937576e99cccf85e6fa3aa8860a1173c7cfb /src/web/app/common/scripts/get-post-summary.ls
downloadsharkey-b3f42e62af698a67c2250533c437569559f1fdf9.tar.gz
sharkey-b3f42e62af698a67c2250533c437569559f1fdf9.tar.bz2
sharkey-b3f42e62af698a67c2250533c437569559f1fdf9.zip
Initial commit :four_leaf_clover:
Diffstat (limited to 'src/web/app/common/scripts/get-post-summary.ls')
-rw-r--r--src/web/app/common/scripts/get-post-summary.ls26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/web/app/common/scripts/get-post-summary.ls b/src/web/app/common/scripts/get-post-summary.ls
new file mode 100644
index 0000000000..0150d53004
--- /dev/null
+++ b/src/web/app/common/scripts/get-post-summary.ls
@@ -0,0 +1,26 @@
+get-post-summary = (post) ~>
+ summary = if post.text? then post.text else ''
+
+ # メディアが添付されているとき
+ if post.media?
+ summary += " (#{post.media.length}枚の画像)"
+
+ # 返信のとき
+ if post.reply_to_id?
+ if post.reply_to?
+ reply-summary = get-post-summary post.reply_to
+ summary += " RE: #{reply-summary}"
+ else
+ summary += " RE: ..."
+
+ # Repostのとき
+ if post.repost_id?
+ if post.repost?
+ repost-summary = get-post-summary post.repost
+ summary += " RP: #{repost-summary}"
+ else
+ summary += " RP: ..."
+
+ return summary.trim!
+
+module.exports = get-post-summary