diff options
author | Akshay <[email protected]> | 2024-11-22 19:48:31 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2024-11-22 19:48:31 +0000 |
commit | 622c5fee25e7d86914d343ca3f873dc4bd55ffad (patch) | |
tree | 6543c2ef3499eecee3842f433599aaae6c4c2f14 /src/mixins/postUtils.pug | |
parent | 3551ff7a202ad60362888888c42f88b37e32fc59 (diff) |
rework invite and admins a bit
Diffstat (limited to 'src/mixins/postUtils.pug')
-rw-r--r-- | src/mixins/postUtils.pug | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/mixins/postUtils.pug b/src/mixins/postUtils.pug new file mode 100644 index 0000000..4f480b6 --- /dev/null +++ b/src/mixins/postUtils.pug | |||
@@ -0,0 +1,39 @@ | |||
1 | - | ||
2 | function isPostGallery(p) { | ||
3 | return (p.is_gallery && p.is_gallery == true); | ||
4 | } | ||
5 | - | ||
6 | function isPostImage(p) { | ||
7 | return (p.post_hint == "image" && p.thumbnail && p.thumbnail != "self" && p.thumbnail != "default"); | ||
8 | } | ||
9 | - | ||
10 | function isPostVideo(p) { | ||
11 | return (p.post_hint == "hosted:video"); | ||
12 | } | ||
13 | - | ||
14 | function isPostLink(p) { | ||
15 | return (p.post_hint == "link"); | ||
16 | } | ||
17 | - | ||
18 | function imgExt(p, id) { | ||
19 | var metadata = p.media_metadata; | ||
20 | if (metadata[id].status == 'valid') { | ||
21 | return stripPrefix(metadata[id].m, "image/"); | ||
22 | } else { | ||
23 | // dosent matter | ||
24 | return 'jpg'; | ||
25 | } | ||
26 | } | ||
27 | - | ||
28 | function postGalleryItems(p) { | ||
29 | if (p.gallery_data && p.gallery_data.items) { | ||
30 | return p.gallery_data.items.map((item, idx) => ({ | ||
31 | id: item.media_id, | ||
32 | url: `https://i.redd.it/${item.media_id}.${imgExt(p, item.media_id)}`, | ||
33 | total: p.gallery_data.items.length, | ||
34 | idx: idx+1, | ||
35 | })); | ||
36 | } else { | ||
37 | return null; | ||
38 | } | ||
39 | } | ||