| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Slack::BlockKit 0.005; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: a toolkit for building Block Kit blocks for Slack |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
#pod =head1 OVERVIEW |
|
5
|
|
|
|
|
|
|
#pod |
|
6
|
|
|
|
|
|
|
#pod This library is only useful if you're using L<Slack|https://slack.com/>. |
|
7
|
|
|
|
|
|
|
#pod |
|
8
|
|
|
|
|
|
|
#pod Almost any time you want to send content to Slack and you want to end up in |
|
9
|
|
|
|
|
|
|
#pod front of a human, you will want to use Block Kit. You can get away without |
|
10
|
|
|
|
|
|
|
#pod using Block Kit if you're only sending plain text or "mrkdwn" text, but even |
|
11
|
|
|
|
|
|
|
#pod then, the lack of an escaping mechanism in mrkdwn can be a problem. |
|
12
|
|
|
|
|
|
|
#pod |
|
13
|
|
|
|
|
|
|
#pod The Block Kit system lets you build quite a few different pieces of |
|
14
|
|
|
|
|
|
|
#pod presentation, but it's fiddly and the error reporting is I<terrible> if you get |
|
15
|
|
|
|
|
|
|
#pod something wrong. This library is meant to make it I<easy> to write Block Kit |
|
16
|
|
|
|
|
|
|
#pod content, and to provide client-side validation of constructed blocks with |
|
17
|
|
|
|
|
|
|
#pod better (well, less awful) errors when you make a mistake. |
|
18
|
|
|
|
|
|
|
#pod |
|
19
|
|
|
|
|
|
|
#pod B<You probably want to start here>: L<Slack::BlockKit::Sugar>. This library |
|
20
|
|
|
|
|
|
|
#pod exports a bunch of functions that can be combined to produce valid Block Kit |
|
21
|
|
|
|
|
|
|
#pod structures. Each of those functions will produce an object, or maybe several. |
|
22
|
|
|
|
|
|
|
#pod You shouldn't really need to build any of those objects by hand, but you can. |
|
23
|
|
|
|
|
|
|
#pod To find more about the classes shipped with Slack::Block Kit, look at the docs |
|
24
|
|
|
|
|
|
|
#pod for the Sugar library and follow the links from there. |
|
25
|
|
|
|
|
|
|
#pod |
|
26
|
|
|
|
|
|
|
#pod =head1 SECRET ORIGINS |
|
27
|
|
|
|
|
|
|
#pod |
|
28
|
|
|
|
|
|
|
#pod This library was written to improve RJBS's Synergy chat bot. You can read more |
|
29
|
|
|
|
|
|
|
#pod about this process (and the bot) on L<his |
|
30
|
|
|
|
|
|
|
#pod blog|https://rjbs.cloud/blog/2024/06/slack-blockkit/>. |
|
31
|
|
|
|
|
|
|
#pod |
|
32
|
|
|
|
|
|
|
#pod =cut |
|
33
|
|
|
|
|
|
|
|
|
34
|
4
|
|
|
4
|
|
152683
|
use v5.36.0; |
|
|
4
|
|
|
|
|
11
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Boolean and set handling |
|
37
|
4
|
|
|
4
|
|
2460
|
use JSON::PP (); # to ensure that JSON::PP::true and ::false are populated |
|
|
4
|
|
|
|
|
67419
|
|
|
|
4
|
|
|
|
|
280
|
|
|
38
|
|
|
|
|
|
|
|
|
39
|
2
|
50
|
|
2
|
0
|
4
|
sub boolify ($val) { $val ? JSON::PP::true : JSON::PP::false } |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
18
|
|
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# The top-level collection object |
|
42
|
4
|
|
|
4
|
|
2115
|
use Slack::BlockKit::BlockCollection; |
|
|
4
|
|
|
|
|
77079
|
|
|
|
4
|
|
|
|
|
209
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Rich Text |
|
45
|
4
|
|
|
4
|
|
2873
|
use Slack::BlockKit::Block::RichText; |
|
|
4
|
|
|
|
|
74430
|
|
|
|
4
|
|
|
|
|
208
|
|
|
46
|
4
|
|
|
4
|
|
2597
|
use Slack::BlockKit::Block::RichText::Channel; |
|
|
4
|
|
|
|
|
1610
|
|
|
|
4
|
|
|
|
|
195
|
|
|
47
|
4
|
|
|
4
|
|
2791
|
use Slack::BlockKit::Block::RichText::Date; |
|
|
4
|
|
|
|
|
1773
|
|
|
|
4
|
|
|
|
|
203
|
|
|
48
|
4
|
|
|
4
|
|
2387
|
use Slack::BlockKit::Block::RichText::Emoji; |
|
|
4
|
|
|
|
|
1667
|
|
|
|
4
|
|
|
|
|
204
|
|
|
49
|
4
|
|
|
4
|
|
2504
|
use Slack::BlockKit::Block::RichText::Link; |
|
|
4
|
|
|
|
|
2094
|
|
|
|
4
|
|
|
|
|
216
|
|
|
50
|
4
|
|
|
4
|
|
2896
|
use Slack::BlockKit::Block::RichText::List; |
|
|
4
|
|
|
|
|
2006
|
|
|
|
4
|
|
|
|
|
241
|
|
|
51
|
4
|
|
|
4
|
|
2749
|
use Slack::BlockKit::Block::RichText::Preformatted; |
|
|
4
|
|
|
|
|
1641
|
|
|
|
4
|
|
|
|
|
250
|
|
|
52
|
4
|
|
|
4
|
|
2441
|
use Slack::BlockKit::Block::RichText::Quote; |
|
|
4
|
|
|
|
|
1724
|
|
|
|
4
|
|
|
|
|
184
|
|
|
53
|
4
|
|
|
4
|
|
2460
|
use Slack::BlockKit::Block::RichText::Section; |
|
|
4
|
|
|
|
|
1942
|
|
|
|
4
|
|
|
|
|
198
|
|
|
54
|
4
|
|
|
4
|
|
2811
|
use Slack::BlockKit::Block::RichText::Text; |
|
|
4
|
|
|
|
|
1714
|
|
|
|
4
|
|
|
|
|
187
|
|
|
55
|
4
|
|
|
4
|
|
2606
|
use Slack::BlockKit::Block::RichText::User; |
|
|
4
|
|
|
|
|
1868
|
|
|
|
4
|
|
|
|
|
195
|
|
|
56
|
4
|
|
|
4
|
|
2815
|
use Slack::BlockKit::Block::RichText::UserGroup; |
|
|
4
|
|
|
|
|
2014
|
|
|
|
4
|
|
|
|
|
216
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# Everything Else |
|
59
|
4
|
|
|
4
|
|
2741
|
use Slack::BlockKit::Block::Context; |
|
|
4
|
|
|
|
|
1981
|
|
|
|
4
|
|
|
|
|
217
|
|
|
60
|
4
|
|
|
4
|
|
2702
|
use Slack::BlockKit::Block::Divider; |
|
|
4
|
|
|
|
|
1919
|
|
|
|
4
|
|
|
|
|
245
|
|
|
61
|
4
|
|
|
4
|
|
2489
|
use Slack::BlockKit::Block::Header; |
|
|
4
|
|
|
|
|
1631
|
|
|
|
4
|
|
|
|
|
170
|
|
|
62
|
4
|
|
|
4
|
|
2468
|
use Slack::BlockKit::Block::Image; |
|
|
4
|
|
|
|
|
1663
|
|
|
|
4
|
|
|
|
|
177
|
|
|
63
|
4
|
|
|
4
|
|
2232
|
use Slack::BlockKit::Block::Markdown; |
|
|
4
|
|
|
|
|
1577
|
|
|
|
4
|
|
|
|
|
263
|
|
|
64
|
4
|
|
|
4
|
|
2373
|
use Slack::BlockKit::Block::Section; |
|
|
4
|
|
|
|
|
1880
|
|
|
|
4
|
|
|
|
|
201
|
|
|
65
|
4
|
|
|
4
|
|
4034
|
use Slack::BlockKit::CompObj::Text; |
|
|
4
|
|
|
|
|
2086
|
|
|
|
4
|
|
|
|
|
276
|
|
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=pod |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=encoding UTF-8 |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 NAME |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Slack::BlockKit - a toolkit for building Block Kit blocks for Slack |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 VERSION |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
version 0.005 |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 OVERVIEW |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This library is only useful if you're using L<Slack|https://slack.com/>. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Almost any time you want to send content to Slack and you want to end up in |
|
88
|
|
|
|
|
|
|
front of a human, you will want to use Block Kit. You can get away without |
|
89
|
|
|
|
|
|
|
using Block Kit if you're only sending plain text or "mrkdwn" text, but even |
|
90
|
|
|
|
|
|
|
then, the lack of an escaping mechanism in mrkdwn can be a problem. |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
The Block Kit system lets you build quite a few different pieces of |
|
93
|
|
|
|
|
|
|
presentation, but it's fiddly and the error reporting is I<terrible> if you get |
|
94
|
|
|
|
|
|
|
something wrong. This library is meant to make it I<easy> to write Block Kit |
|
95
|
|
|
|
|
|
|
content, and to provide client-side validation of constructed blocks with |
|
96
|
|
|
|
|
|
|
better (well, less awful) errors when you make a mistake. |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
B<You probably want to start here>: L<Slack::BlockKit::Sugar>. This library |
|
99
|
|
|
|
|
|
|
exports a bunch of functions that can be combined to produce valid Block Kit |
|
100
|
|
|
|
|
|
|
structures. Each of those functions will produce an object, or maybe several. |
|
101
|
|
|
|
|
|
|
You shouldn't really need to build any of those objects by hand, but you can. |
|
102
|
|
|
|
|
|
|
To find more about the classes shipped with Slack::Block Kit, look at the docs |
|
103
|
|
|
|
|
|
|
for the Sugar library and follow the links from there. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 PERL VERSION |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This module should work on any version of perl still receiving updates from |
|
108
|
|
|
|
|
|
|
the Perl 5 Porters. This means it should work on any version of perl |
|
109
|
|
|
|
|
|
|
released in the last two to three years. (That is, if the most recently |
|
110
|
|
|
|
|
|
|
released version is v5.40, then this module should work on both v5.40 and |
|
111
|
|
|
|
|
|
|
v5.38.) |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Although it may work on older versions of perl, no guarantee is made that the |
|
114
|
|
|
|
|
|
|
minimum required version will not be increased. The version may be increased |
|
115
|
|
|
|
|
|
|
for any reason, and there is no promise that patches will be accepted to |
|
116
|
|
|
|
|
|
|
lower the minimum required perl. |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 SECRET ORIGINS |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This library was written to improve RJBS's Synergy chat bot. You can read more |
|
121
|
|
|
|
|
|
|
about this process (and the bot) on L<his |
|
122
|
|
|
|
|
|
|
blog|https://rjbs.cloud/blog/2024/06/slack-blockkit/>. |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 AUTHOR |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Ricardo SIGNES <cpan@semiotic.systems> |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 CONTRIBUTOR |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=for stopwords Ricardo Signes |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Ricardo Signes <rjbs@semiotic.systems> |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This software is copyright (c) 2024 by Ricardo SIGNES. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
139
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |