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