line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::LinkEmbedder::Link::Text::GistGithub; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Mojolicious::Plugin::LinkEmbedder::Link::Text::GistGithub - gist.github.com link |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 DESCRIPTION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
This class inherit from L. |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 OUTPUT HTML |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
This is an example output: |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$gist |
16
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
The number "42" is generated dynamically by this module. |
28
|
|
|
|
|
|
|
C<$gist> is the raw text from the gist. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
The GitHub stylesheet will not be included if the container document has |
31
|
|
|
|
|
|
|
already increased C. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
1
|
|
787
|
use Mojo::Base 'Mojolicious::Plugin::LinkEmbedder::Link::Text'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
16
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $ID = 0; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 media_id |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$str = $self->media_id; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Example C<$str>: "/username/123456789". |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
has media_id => sub { |
50
|
|
|
|
|
|
|
shift->url->path =~ m!^(/\w+/\w+)(?:\.js)?$! ? $1 : ''; |
51
|
|
|
|
|
|
|
}; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 provider_name |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
0
|
1
|
|
sub provider_name {'Github'} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 METHODS |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 to_embed |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Returns the HTML code for a script tag that writes the gist. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub to_embed { |
68
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
69
|
0
|
0
|
|
|
|
|
my $media_id = $self->media_id or return $self->SUPER::to_embed; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
$ID++; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
return $self->tag( |
74
|
|
|
|
|
|
|
div => (class => 'link-embedder text-gist-github', id => "link_embedder_text_gist_github_$ID"), |
75
|
|
|
|
|
|
|
sub { |
76
|
0
|
|
|
0
|
|
|
return <<"HERE"; |
77
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
HERE |
87
|
|
|
|
|
|
|
}, |
88
|
0
|
|
|
|
|
|
); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 AUTHOR |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Jan Henning Thorsen |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |