Imported Upstream version 0.05
Xavier Guimard
11 years ago
0 | 0 | Revision history for HTML-RewriteAttributes |
1 | ||
2 | 0.05 Mon Oct 22 2012 | |
3 | Resources: Preserve the media attribute when inlining CSS | |
4 | Resources: Avoid uninitialized warnings by checking the attributes we expect | |
1 | 5 | |
2 | 6 | 0.04 Thu Nov 18 2010 |
3 | 7 | Resources: Ignore @import statements that appear in comments |
4 | 4 | inc/Module/Install/Fetch.pm |
5 | 5 | inc/Module/Install/Makefile.pm |
6 | 6 | inc/Module/Install/Metadata.pm |
7 | inc/Module/Install/ReadmeFromPod.pm | |
7 | 8 | inc/Module/Install/Win32.pm |
8 | 9 | inc/Module/Install/WriteAll.pm |
9 | 10 | lib/HTML/RewriteAttributes.pm |
11 | 12 | lib/HTML/RewriteAttributes/Resources.pm |
12 | 13 | Makefile.PL |
13 | 14 | MANIFEST This list of files |
15 | MANIFEST.SKIP | |
14 | 16 | META.yml |
17 | README | |
15 | 18 | t/000-synopsis.t |
16 | 19 | t/001-basic.t |
17 | 20 | t/002-resources.t |
23 | 26 | t/021-import.t |
24 | 27 | t/022-import-off.t |
25 | 28 | t/023-import-comment.t |
29 | SIGNATURE Public-key signature (added by MakeMaker) |
0 | ||
1 | #!start included /opt/perlbrew/perls/perl-5.14.1/lib/5.14.1/ExtUtils/MANIFEST.SKIP | |
2 | # Avoid version control files. | |
3 | \bRCS\b | |
4 | \bCVS\b | |
5 | \bSCCS\b | |
6 | ,v$ | |
7 | \B\.svn\b | |
8 | \B\.git\b | |
9 | \B\.gitignore\b | |
10 | \b_darcs\b | |
11 | \B\.cvsignore$ | |
12 | ||
13 | # Avoid VMS specific MakeMaker generated files | |
14 | \bDescrip.MMS$ | |
15 | \bDESCRIP.MMS$ | |
16 | \bdescrip.mms$ | |
17 | ||
18 | # Avoid Makemaker generated and utility files. | |
19 | \bMANIFEST\.bak | |
20 | \bMakefile$ | |
21 | \bblib/ | |
22 | \bMakeMaker-\d | |
23 | \bpm_to_blib\.ts$ | |
24 | \bpm_to_blib$ | |
25 | \bblibdirs\.ts$ # 6.18 through 6.25 generated this | |
26 | ||
27 | # Avoid Module::Build generated and utility files. | |
28 | \bBuild$ | |
29 | \b_build/ | |
30 | \bBuild.bat$ | |
31 | \bBuild.COM$ | |
32 | \bBUILD.COM$ | |
33 | \bbuild.com$ | |
34 | ||
35 | # Avoid temp and backup files. | |
36 | ~$ | |
37 | \.old$ | |
38 | \#$ | |
39 | \b\.# | |
40 | \.bak$ | |
41 | \.tmp$ | |
42 | \.# | |
43 | \.rej$ | |
44 | ||
45 | # Avoid OS-specific files/dirs | |
46 | # Mac OSX metadata | |
47 | \B\.DS_Store | |
48 | # Mac OSX SMB mount metadata files | |
49 | \B\._ | |
50 | ||
51 | # Avoid Devel::Cover and Devel::CoverX::Covered files. | |
52 | \bcover_db\b | |
53 | \bcovered\b | |
54 | ||
55 | # Avoid MYMETA files | |
56 | ^MYMETA\. | |
57 | #!end included /opt/perlbrew/perls/perl-5.14.1/lib/5.14.1/ExtUtils/MANIFEST.SKIP | |
58 | ||
59 | ||
60 | # Dist droppings | |
61 | ^MYMETA\. | |
62 | \.tar\.gz$ | |
63 | ||
64 | # ctags files | |
65 | ^\.tags |
2 | 2 | author: |
3 | 3 | - 'Shawn M Moore, C<< <sartak@bestpractical.com> >>' |
4 | 4 | build_requires: |
5 | ExtUtils::MakeMaker: 6.42 | |
5 | ExtUtils::MakeMaker: 6.36 | |
6 | 6 | configure_requires: |
7 | ExtUtils::MakeMaker: 6.42 | |
7 | ExtUtils::MakeMaker: 6.36 | |
8 | 8 | distribution_type: module |
9 | generated_by: 'Module::Install version 1.00' | |
9 | dynamic_config: 1 | |
10 | generated_by: 'Module::Install version 1.06' | |
10 | 11 | license: perl |
11 | 12 | meta-spec: |
12 | 13 | url: http://module-build.sourceforge.net/META-spec-v1.4.html |
23 | 24 | URI: 0 |
24 | 25 | resources: |
25 | 26 | license: http://dev.perl.org/licenses/ |
26 | version: 0.04 | |
27 | version: 0.05 |
2 | 2 | # Define metadata |
3 | 3 | name 'HTML-RewriteAttributes'; |
4 | 4 | all_from 'lib/HTML/RewriteAttributes.pm'; |
5 | readme_from 'lib/HTML/RewriteAttributes.pm'; | |
5 | 6 | |
6 | 7 | requires 'HTML::Parser'; |
7 | 8 | requires 'HTML::Entities'; |
8 | 9 | requires 'HTML::Tagset'; |
9 | 10 | requires 'URI'; |
10 | 11 | |
12 | sign; | |
11 | 13 | WriteAll; |
12 | 14 |
0 | NAME | |
1 | HTML::RewriteAttributes - concise attribute rewriting | |
2 | ||
3 | SYNOPSIS | |
4 | $html = HTML::RewriteAttributes->rewrite($html, sub { | |
5 | my ($tag, $attr, $value) = @_; | |
6 | ||
7 | # delete any attribute that mentions.. | |
8 | return if $value =~ /COBOL/i; | |
9 | ||
10 | $value =~ s/\brocks\b/rules/g; | |
11 | return $value; | |
12 | }); | |
13 | ||
14 | ||
15 | # writing some HTML email I see.. | |
16 | $html = HTML::RewriteAttributes::Resources->rewrite($html, sub { | |
17 | my $uri = shift; | |
18 | my $content = render_template($uri); | |
19 | my $cid = generate_cid_from($content); | |
20 | $mime->attach($cid => content); | |
21 | return "cid:$cid"; | |
22 | }); | |
23 | ||
24 | ||
25 | # up for some HTML::ResolveLink? | |
26 | $html = HTML::RewriteAttributes::Links->rewrite($html, "http://search.cpan.org"); | |
27 | ||
28 | # or perhaps HTML::LinkExtor? | |
29 | HTML::RewriteAttributes::Links->rewrite($html, sub { | |
30 | my ($tag, $attr, $value) = @_; | |
31 | push @links, $value; | |
32 | $value; | |
33 | }); | |
34 | ||
35 | DESCRIPTION | |
36 | "HTML::RewriteAttributes" is designed for simple yet powerful HTML | |
37 | attribute rewriting. | |
38 | ||
39 | You simply specify a callback to run for each attribute and we do the | |
40 | rest for you. | |
41 | ||
42 | This module is designed to be subclassable to make handling special | |
43 | cases eaiser. See the source for methods you can override. | |
44 | ||
45 | METHODS | |
46 | "new" | |
47 | You don't need to call "new" explicitly - it's done in "rewrite". It | |
48 | takes no arguments. | |
49 | ||
50 | "rewrite" HTML, callback -> HTML | |
51 | This is the main interface of the module. You pass in some HTML and a | |
52 | callback, the callback is invoked potentially many times, and you get | |
53 | back some similar HTML. | |
54 | ||
55 | The callback receives as arguments the tag name, the attribute name, and | |
56 | the attribute value (though subclasses may override this -- | |
57 | HTML::RewriteAttributes::Resources does). Return "undef" to remove the | |
58 | attribute, or any other value to set the value of the attribute. | |
59 | ||
60 | SEE ALSO | |
61 | HTML::Parser, HTML::ResolveLink, Email::MIME::CreateHTML, | |
62 | HTML::LinkExtor | |
63 | ||
64 | THANKS | |
65 | Some code was inspired by, and tests borrowed from, Miyagawa's | |
66 | HTML::ResolveLink. | |
67 | ||
68 | AUTHOR | |
69 | Shawn M Moore, "<sartak@bestpractical.com>" | |
70 | ||
71 | LICENSE | |
72 | Copyright 2008-2010 Best Practical Solutions, LLC. | |
73 | HTML::RewriteAttributes is distributed under the same terms as Perl | |
74 | itself. | |
75 |
0 | This file contains message digests of all files listed in MANIFEST, | |
1 | signed via the Module::Signature module, version 0.68. | |
2 | ||
3 | To verify the content in this distribution, first make sure you have | |
4 | Module::Signature installed, then type: | |
5 | ||
6 | % cpansign -v | |
7 | ||
8 | It will check each file's integrity, as well as the signature's | |
9 | validity. If "==> Signature verified OK! <==" is not displayed, | |
10 | the distribution may already have been compromised, and you should | |
11 | not run its Makefile.PL or Build.PL. | |
12 | ||
13 | -----BEGIN PGP SIGNED MESSAGE----- | |
14 | Hash: SHA1 | |
15 | ||
16 | SHA1 d0e286477b95832aa494f325113e7e320b44e73e Changes | |
17 | SHA1 944e15e3414d90d1e4fdb456b1c4a7efa0a7c8ca MANIFEST | |
18 | SHA1 45c5a75eda6089e9e23fad201b41f63b8c9bb504 MANIFEST.SKIP | |
19 | SHA1 bbd2da5709def05d6b55e4d829072610cdd3651a META.yml | |
20 | SHA1 710580665bac8a12510c1a1db12aa6f84e0a611f Makefile.PL | |
21 | SHA1 b79b7618ecea16ce2d48091efffd69d16f42005d README | |
22 | SHA1 8a924add836b60fb23b25c8506d45945e02f42f4 inc/Module/Install.pm | |
23 | SHA1 2d0fad3bf255f8c1e7e1e34eafccc4f595603ddc inc/Module/Install/Base.pm | |
24 | SHA1 f0e01fff7d73cd145fbf22331579918d4628ddb0 inc/Module/Install/Can.pm | |
25 | SHA1 7328966e4fda0c8451a6d3850704da0b84ac1540 inc/Module/Install/Fetch.pm | |
26 | SHA1 b62ca5e2d58fa66766ccf4d64574f9e1a2250b34 inc/Module/Install/Makefile.pm | |
27 | SHA1 1aa925be410bb3bfcd84a16985921f66073cc1d2 inc/Module/Install/Metadata.pm | |
28 | SHA1 a3cff7ab08b95ee312b7e9381eb72f42e309c842 inc/Module/Install/ReadmeFromPod.pm | |
29 | SHA1 e4196994fa75e98bdfa2be0bdeeffef66de88171 inc/Module/Install/Win32.pm | |
30 | SHA1 c3a6d0d5b84feb3280622e9599e86247d58b0d18 inc/Module/Install/WriteAll.pm | |
31 | SHA1 f3bae457e4bbec8afcf6abefea8161427308c1ce lib/HTML/RewriteAttributes.pm | |
32 | SHA1 50b0d8f9eaf6a40fd1e34bc2744d41d8a1b3a477 lib/HTML/RewriteAttributes/Links.pm | |
33 | SHA1 ba9643a4435368494357328454e4bb2a185d55a0 lib/HTML/RewriteAttributes/Resources.pm | |
34 | SHA1 5d97ad6516b8aea70d9979934492c8cbe7e88409 t/000-synopsis.t | |
35 | SHA1 ee0edb567e91ef5fc3df0e1c0771776b229e2aa2 t/001-basic.t | |
36 | SHA1 7fb822373f163cdb0fb54bd2a9f55dabe36e025f t/002-resources.t | |
37 | SHA1 3c749328abb70da542ca0e42602fb6456a9d9780 t/003-links.t | |
38 | SHA1 301b59c6176775286333388dc539d524f3ee1635 t/004-misc.t | |
39 | SHA1 3269dcbb500cb5d4905ed442c030fedac40bea34 t/005-links-code.t | |
40 | SHA1 c511d1917a9ea1e486e643193c8ca99e8522f11e t/010-resolvelink.t | |
41 | SHA1 a451823d4e5961b24202618b99cac7c79e641b05 t/020-inline-css.t | |
42 | SHA1 a901c2673f095455484bf8fe493768fe292e68fa t/021-import.t | |
43 | SHA1 33065c367ab56b3a7bcdd55afb920828f52086c3 t/022-import-off.t | |
44 | SHA1 5df911d7ef2cfb8566628153cd565c4da1aa723d t/023-import-comment.t | |
45 | -----BEGIN PGP SIGNATURE----- | |
46 | Version: GnuPG v1.4.11 (GNU/Linux) | |
47 | ||
48 | iD8DBQFQhcU4Hdv9ZfNcOAcRAgBmAJ9GyWI/6iOU7ONziG7rSq9NxUdCDQCfZFAO | |
49 | XXl0MHJLJLNol1vjzNI7o94= | |
50 | =ID9F | |
51 | -----END PGP SIGNATURE----- |
3 | 3 | use strict 'vars'; |
4 | 4 | use vars qw{$VERSION}; |
5 | 5 | BEGIN { |
6 | $VERSION = '1.00'; | |
6 | $VERSION = '1.06'; | |
7 | 7 | } |
8 | 8 | |
9 | 9 | # Suspend handler for "redefined" warnings |
2 | 2 | |
3 | 3 | use strict; |
4 | 4 | use Config (); |
5 | use File::Spec (); | |
6 | 5 | use ExtUtils::MakeMaker (); |
7 | 6 | use Module::Install::Base (); |
8 | 7 | |
9 | 8 | use vars qw{$VERSION @ISA $ISCORE}; |
10 | 9 | BEGIN { |
11 | $VERSION = '1.00'; | |
10 | $VERSION = '1.06'; | |
12 | 11 | @ISA = 'Module::Install::Base'; |
13 | 12 | $ISCORE = 1; |
14 | 13 | } |
28 | 27 | eval { require $mod; $pkg->VERSION($ver || 0); 1 }; |
29 | 28 | } |
30 | 29 | |
31 | # check if we can run some command | |
30 | # Check if we can run some command | |
32 | 31 | sub can_run { |
33 | 32 | my ($self, $cmd) = @_; |
34 | 33 | |
37 | 36 | |
38 | 37 | for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') { |
39 | 38 | next if $dir eq ''; |
40 | my $abs = File::Spec->catfile($dir, $_[1]); | |
39 | require File::Spec; | |
40 | my $abs = File::Spec->catfile($dir, $cmd); | |
41 | 41 | return $abs if (-x $abs or $abs = MM->maybe_command($abs)); |
42 | 42 | } |
43 | 43 | |
44 | 44 | return; |
45 | 45 | } |
46 | 46 | |
47 | # can we locate a (the) C compiler | |
47 | # Can our C compiler environment build XS files | |
48 | sub can_xs { | |
49 | my $self = shift; | |
50 | ||
51 | # Ensure we have the CBuilder module | |
52 | $self->configure_requires( 'ExtUtils::CBuilder' => 0.27 ); | |
53 | ||
54 | # Do we have the configure_requires checker? | |
55 | local $@; | |
56 | eval "require ExtUtils::CBuilder;"; | |
57 | if ( $@ ) { | |
58 | # They don't obey configure_requires, so it is | |
59 | # someone old and delicate. Try to avoid hurting | |
60 | # them by falling back to an older simpler test. | |
61 | return $self->can_cc(); | |
62 | } | |
63 | ||
64 | # Do we have a working C compiler | |
65 | my $builder = ExtUtils::CBuilder->new( | |
66 | quiet => 1, | |
67 | ); | |
68 | unless ( $builder->have_compiler ) { | |
69 | # No working C compiler | |
70 | return 0; | |
71 | } | |
72 | ||
73 | # Write a C file representative of what XS becomes | |
74 | require File::Temp; | |
75 | my ( $FH, $tmpfile ) = File::Temp::tempfile( | |
76 | "compilexs-XXXXX", | |
77 | SUFFIX => '.c', | |
78 | ); | |
79 | binmode $FH; | |
80 | print $FH <<'END_C'; | |
81 | #include "EXTERN.h" | |
82 | #include "perl.h" | |
83 | #include "XSUB.h" | |
84 | ||
85 | int main(int argc, char **argv) { | |
86 | return 0; | |
87 | } | |
88 | ||
89 | int boot_sanexs() { | |
90 | return 1; | |
91 | } | |
92 | ||
93 | END_C | |
94 | close $FH; | |
95 | ||
96 | # Can the C compiler access the same headers XS does | |
97 | my @libs = (); | |
98 | my $object = undef; | |
99 | eval { | |
100 | local $^W = 0; | |
101 | $object = $builder->compile( | |
102 | source => $tmpfile, | |
103 | ); | |
104 | @libs = $builder->link( | |
105 | objects => $object, | |
106 | module_name => 'sanexs', | |
107 | ); | |
108 | }; | |
109 | my $result = $@ ? 0 : 1; | |
110 | ||
111 | # Clean up all the build files | |
112 | foreach ( $tmpfile, $object, @libs ) { | |
113 | next unless defined $_; | |
114 | 1 while unlink; | |
115 | } | |
116 | ||
117 | return $result; | |
118 | } | |
119 | ||
120 | # Can we locate a (the) C compiler | |
48 | 121 | sub can_cc { |
49 | 122 | my $self = shift; |
50 | 123 | my @chunks = split(/ /, $Config::Config{cc}) or return; |
77 | 150 | |
78 | 151 | __END__ |
79 | 152 | |
80 | #line 156 | |
153 | #line 236 |
5 | 5 | |
6 | 6 | use vars qw{$VERSION @ISA $ISCORE}; |
7 | 7 | BEGIN { |
8 | $VERSION = '1.00'; | |
8 | $VERSION = '1.06'; | |
9 | 9 | @ISA = 'Module::Install::Base'; |
10 | 10 | $ISCORE = 1; |
11 | 11 | } |
7 | 7 | |
8 | 8 | use vars qw{$VERSION @ISA $ISCORE}; |
9 | 9 | BEGIN { |
10 | $VERSION = '1.00'; | |
10 | $VERSION = '1.06'; | |
11 | 11 | @ISA = 'Module::Install::Base'; |
12 | 12 | $ISCORE = 1; |
13 | 13 | } |
214 | 214 | require ExtUtils::MakeMaker; |
215 | 215 | |
216 | 216 | if ( $perl_version and $self->_cmp($perl_version, '5.006') >= 0 ) { |
217 | # MakeMaker can complain about module versions that include | |
218 | # an underscore, even though its own version may contain one! | |
219 | # Hence the funny regexp to get rid of it. See RT #35800 | |
220 | # for details. | |
221 | my $v = $ExtUtils::MakeMaker::VERSION =~ /^(\d+\.\d+)/; | |
222 | $self->build_requires( 'ExtUtils::MakeMaker' => $v ); | |
223 | $self->configure_requires( 'ExtUtils::MakeMaker' => $v ); | |
217 | # This previous attempted to inherit the version of | |
218 | # ExtUtils::MakeMaker in use by the module author, but this | |
219 | # was found to be untenable as some authors build releases | |
220 | # using future dev versions of EU:MM that nobody else has. | |
221 | # Instead, #toolchain suggests we use 6.59 which is the most | |
222 | # stable version on CPAN at time of writing and is, to quote | |
223 | # ribasushi, "not terminally fucked, > and tested enough". | |
224 | # TODO: We will now need to maintain this over time to push | |
225 | # the version up as new versions are released. | |
226 | $self->build_requires( 'ExtUtils::MakeMaker' => 6.59 ); | |
227 | $self->configure_requires( 'ExtUtils::MakeMaker' => 6.59 ); | |
224 | 228 | } else { |
225 | 229 | # Allow legacy-compatibility with 5.005 by depending on the |
226 | 230 | # most recent EU:MM that supported 5.005. |
227 | $self->build_requires( 'ExtUtils::MakeMaker' => 6.42 ); | |
228 | $self->configure_requires( 'ExtUtils::MakeMaker' => 6.42 ); | |
231 | $self->build_requires( 'ExtUtils::MakeMaker' => 6.36 ); | |
232 | $self->configure_requires( 'ExtUtils::MakeMaker' => 6.36 ); | |
229 | 233 | } |
230 | 234 | |
231 | 235 | # Generate the MakeMaker params |
240 | 244 | 'all_from' if you prefer) in Makefile.PL. |
241 | 245 | EOT |
242 | 246 | |
243 | $DB::single = 1; | |
244 | 247 | if ( $self->tests ) { |
245 | 248 | my @tests = split ' ', $self->tests; |
246 | 249 | my %seen; |
411 | 414 | |
412 | 415 | __END__ |
413 | 416 | |
414 | #line 541 | |
417 | #line 544 |
5 | 5 | |
6 | 6 | use vars qw{$VERSION @ISA $ISCORE}; |
7 | 7 | BEGIN { |
8 | $VERSION = '1.00'; | |
8 | $VERSION = '1.06'; | |
9 | 9 | @ISA = 'Module::Install::Base'; |
10 | 10 | $ISCORE = 1; |
11 | 11 | } |
150 | 150 | sub install_as_vendor { $_[0]->installdirs('vendor') } |
151 | 151 | |
152 | 152 | sub dynamic_config { |
153 | my $self = shift; | |
154 | unless ( @_ ) { | |
155 | warn "You MUST provide an explicit true/false value to dynamic_config\n"; | |
156 | return $self; | |
157 | } | |
158 | $self->{values}->{dynamic_config} = $_[0] ? 1 : 0; | |
153 | my $self = shift; | |
154 | my $value = @_ ? shift : 1; | |
155 | if ( $self->{values}->{dynamic_config} ) { | |
156 | # Once dynamic we never change to static, for safety | |
157 | return 0; | |
158 | } | |
159 | $self->{values}->{dynamic_config} = $value ? 1 : 0; | |
159 | 160 | return 1; |
161 | } | |
162 | ||
163 | # Convenience command | |
164 | sub static_config { | |
165 | shift->dynamic_config(0); | |
160 | 166 | } |
161 | 167 | |
162 | 168 | sub perl_version { |
169 | 175 | # Normalize the version |
170 | 176 | $version = $self->_perl_version($version); |
171 | 177 | |
172 | # We don't support the reall old versions | |
178 | # We don't support the really old versions | |
173 | 179 | unless ( $version >= 5.005 ) { |
174 | 180 | die "Module::Install only supports 5.005 or newer (use ExtUtils::MakeMaker)\n"; |
175 | 181 | } |
514 | 520 | 'GNU Free Documentation license' => 'unrestricted', 1, |
515 | 521 | 'GNU Affero General Public License' => 'open_source', 1, |
516 | 522 | '(?:Free)?BSD license' => 'bsd', 1, |
523 | 'Artistic license 2\.0' => 'artistic_2', 1, | |
517 | 524 | 'Artistic license' => 'artistic', 1, |
518 | 525 | 'Apache (?:Software )?license' => 'apache', 1, |
519 | 526 | 'GPL' => 'gpl', 1, |
549 | 556 | |
550 | 557 | sub _extract_bugtracker { |
551 | 558 | my @links = $_[0] =~ m#L<( |
552 | \Qhttp://rt.cpan.org/\E[^>]+| | |
553 | \Qhttp://github.com/\E[\w_]+/[\w_]+/issues| | |
554 | \Qhttp://code.google.com/p/\E[\w_\-]+/issues/list | |
559 | https?\Q://rt.cpan.org/\E[^>]+| | |
560 | https?\Q://github.com/\E[\w_]+/[\w_]+/issues| | |
561 | https?\Q://code.google.com/p/\E[\w_\-]+/issues/list | |
555 | 562 | )>#gx; |
556 | 563 | my %links; |
557 | 564 | @links{@links}=(); |
580 | 587 | sub requires_from { |
581 | 588 | my $self = shift; |
582 | 589 | my $content = Module::Install::_readperl($_[0]); |
583 | my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+([\d\.]+)/mg; | |
590 | my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+(v?[\d\.]+)/mg; | |
584 | 591 | while ( @requires ) { |
585 | 592 | my $module = shift @requires; |
586 | 593 | my $version = shift @requires; |
0 | #line 1 | |
1 | package Module::Install::ReadmeFromPod; | |
2 | ||
3 | use 5.006; | |
4 | use strict; | |
5 | use warnings; | |
6 | use base qw(Module::Install::Base); | |
7 | use vars qw($VERSION); | |
8 | ||
9 | $VERSION = '0.18'; | |
10 | ||
11 | sub readme_from { | |
12 | my $self = shift; | |
13 | return unless $self->is_admin; | |
14 | ||
15 | # Input file | |
16 | my $in_file = shift || $self->_all_from | |
17 | or die "Can't determine file to make readme_from"; | |
18 | ||
19 | # Get optional arguments | |
20 | my ($clean, $format, $out_file, $options); | |
21 | my $args = shift; | |
22 | if ( ref $args ) { | |
23 | # Arguments are in a hashref | |
24 | if ( ref($args) ne 'HASH' ) { | |
25 | die "Expected a hashref but got a ".ref($args)."\n"; | |
26 | } else { | |
27 | $clean = $args->{'clean'}; | |
28 | $format = $args->{'format'}; | |
29 | $out_file = $args->{'output_file'}; | |
30 | $options = $args->{'options'}; | |
31 | } | |
32 | } else { | |
33 | # Arguments are in a list | |
34 | $clean = $args; | |
35 | $format = shift; | |
36 | $out_file = shift; | |
37 | $options = \@_; | |
38 | } | |
39 | ||
40 | # Default values; | |
41 | $clean ||= 0; | |
42 | $format ||= 'txt'; | |
43 | ||
44 | # Generate README | |
45 | print "readme_from $in_file to $format\n"; | |
46 | if ($format =~ m/te?xt/) { | |
47 | $out_file = $self->_readme_txt($in_file, $out_file, $options); | |
48 | } elsif ($format =~ m/html?/) { | |
49 | $out_file = $self->_readme_htm($in_file, $out_file, $options); | |
50 | } elsif ($format eq 'man') { | |
51 | $out_file = $self->_readme_man($in_file, $out_file, $options); | |
52 | } elsif ($format eq 'pdf') { | |
53 | $out_file = $self->_readme_pdf($in_file, $out_file, $options); | |
54 | } | |
55 | ||
56 | if ($clean) { | |
57 | $self->clean_files($out_file); | |
58 | } | |
59 | ||
60 | return 1; | |
61 | } | |
62 | ||
63 | ||
64 | sub _readme_txt { | |
65 | my ($self, $in_file, $out_file, $options) = @_; | |
66 | $out_file ||= 'README'; | |
67 | require Pod::Text; | |
68 | my $parser = Pod::Text->new( @$options ); | |
69 | open my $out_fh, '>', $out_file or die "Could not write file $out_file:\n$!\n"; | |
70 | $parser->output_fh( *$out_fh ); | |
71 | $parser->parse_file( $in_file ); | |
72 | close $out_fh; | |
73 | return $out_file; | |
74 | } | |
75 | ||
76 | ||
77 | sub _readme_htm { | |
78 | my ($self, $in_file, $out_file, $options) = @_; | |
79 | $out_file ||= 'README.htm'; | |
80 | require Pod::Html; | |
81 | Pod::Html::pod2html( | |
82 | "--infile=$in_file", | |
83 | "--outfile=$out_file", | |
84 | @$options, | |
85 | ); | |
86 | # Remove temporary files if needed | |
87 | for my $file ('pod2htmd.tmp', 'pod2htmi.tmp') { | |
88 | if (-e $file) { | |
89 | unlink $file or warn "Warning: Could not remove file '$file'.\n$!\n"; | |
90 | } | |
91 | } | |
92 | return $out_file; | |
93 | } | |
94 | ||
95 | ||
96 | sub _readme_man { | |
97 | my ($self, $in_file, $out_file, $options) = @_; | |
98 | $out_file ||= 'README.1'; | |
99 | require Pod::Man; | |
100 | my $parser = Pod::Man->new( @$options ); | |
101 | $parser->parse_from_file($in_file, $out_file); | |
102 | return $out_file; | |
103 | } | |
104 | ||
105 | ||
106 | sub _readme_pdf { | |
107 | my ($self, $in_file, $out_file, $options) = @_; | |
108 | $out_file ||= 'README.pdf'; | |
109 | eval { require App::pod2pdf; } | |
110 | or die "Could not generate $out_file because pod2pdf could not be found\n"; | |
111 | my $parser = App::pod2pdf->new( @$options ); | |
112 | $parser->parse_from_file($in_file); | |
113 | open my $out_fh, '>', $out_file or die "Could not write file $out_file:\n$!\n"; | |
114 | select $out_fh; | |
115 | $parser->output; | |
116 | select STDOUT; | |
117 | close $out_fh; | |
118 | return $out_file; | |
119 | } | |
120 | ||
121 | ||
122 | sub _all_from { | |
123 | my $self = shift; | |
124 | return unless $self->admin->{extensions}; | |
125 | my ($metadata) = grep { | |
126 | ref($_) eq 'Module::Install::Metadata'; | |
127 | } @{$self->admin->{extensions}}; | |
128 | return unless $metadata; | |
129 | return $metadata->{values}{all_from} || ''; | |
130 | } | |
131 | ||
132 | 'Readme!'; | |
133 | ||
134 | __END__ | |
135 | ||
136 | #line 254 | |
137 |
5 | 5 | |
6 | 6 | use vars qw{$VERSION @ISA $ISCORE}; |
7 | 7 | BEGIN { |
8 | $VERSION = '1.00'; | |
8 | $VERSION = '1.06'; | |
9 | 9 | @ISA = 'Module::Install::Base'; |
10 | 10 | $ISCORE = 1; |
11 | 11 | } |
5 | 5 | |
6 | 6 | use vars qw{$VERSION @ISA $ISCORE}; |
7 | 7 | BEGIN { |
8 | $VERSION = '1.00'; | |
8 | $VERSION = '1.06'; | |
9 | 9 | @ISA = qw{Module::Install::Base}; |
10 | 10 | $ISCORE = 1; |
11 | 11 | } |
30 | 30 | # This is not enforced yet, but will be some time in the next few |
31 | 31 | # releases once we can make sure it won't clash with custom |
32 | 32 | # Module::Install extensions. |
33 | $VERSION = '1.00'; | |
33 | $VERSION = '1.06'; | |
34 | 34 | |
35 | 35 | # Storage for the pseudo-singleton |
36 | 36 | $MAIN = undef; |
450 | 450 | } |
451 | 451 | |
452 | 452 | sub _cmp ($$) { |
453 | _version($_[0]) <=> _version($_[1]); | |
453 | _version($_[1]) <=> _version($_[2]); | |
454 | 454 | } |
455 | 455 | |
456 | 456 | # Cloned from Params::Util::_CLASS |
466 | 466 | |
467 | 467 | 1; |
468 | 468 | |
469 | # Copyright 2008 - 2010 Adam Kennedy. | |
469 | # Copyright 2008 - 2012 Adam Kennedy. |
48 | 48 | my ($tag, $attr, $attrseq, $text) = @_; |
49 | 49 | |
50 | 50 | if ($self->{rewrite_inline_css_cb}) { |
51 | if ($tag eq 'link' && $attr->{type} eq 'text/css') { | |
51 | if ($tag eq 'link' and defined $attr->{type} and $attr->{type} eq 'text/css' and defined $attr->{href}) { | |
52 | 52 | my $content = $self->_import($attr->{href}); |
53 | 53 | if (defined $content) { |
54 | 54 | $content = $self->_handle_imports($content, $attr->{href}); |
55 | $self->{rewrite_html} .= "\n<style type=\"text/css\">\n<!--\n$content\n-->\n</style>\n"; | |
55 | $self->{rewrite_html} .= "\n<style type=\"text/css\""; | |
56 | $self->{rewrite_html} .= " media=\"$attr->{media}\"" if $attr->{media}; | |
57 | $self->{rewrite_html} .= ">\n<!--\n$content\n-->\n</style>\n"; | |
56 | 58 | return; |
57 | 59 | } |
58 | 60 | } |
59 | if ($tag eq 'style' && $attr->{type} eq 'text/css') { | |
61 | if ($tag eq 'style' and defined $attr->{type} and $attr->{type} eq 'text/css') { | |
60 | 62 | $self->{rewrite_look_for_style} = 1; |
61 | 63 | } |
62 | 64 | } |
5 | 5 | use Carp 'croak'; |
6 | 6 | use HTML::Entities 'encode_entities'; |
7 | 7 | |
8 | our $VERSION = '0.04'; | |
8 | our $VERSION = '0.05'; | |
9 | 9 | |
10 | 10 | sub new { |
11 | 11 | my $class = shift; |
7 | 7 | <html> |
8 | 8 | <head> |
9 | 9 | <link type="text/css" href="foo.css" /> |
10 | <link type="text/css" href="print.css" media="print" /> | |
10 | 11 | </head> |
11 | 12 | <body> |
12 | 13 | <img src="moose.jpg" /> |
44 | 45 | |
45 | 46 | is_deeply(\@seen_inline, [ |
46 | 47 | "foo.css", |
48 | "print.css", | |
47 | 49 | ]); |
48 | 50 | |
49 | 51 | is($rewrote, << "END", "rewrote the html correctly"); |
54 | 56 | <!-- |
55 | 57 | |
56 | 58 | /* foo.css */ |
59 | INLINED CSS | |
60 | --> | |
61 | </style> | |
62 | ||
63 | ||
64 | <style type="text/css" media="print"> | |
65 | <!-- | |
66 | ||
67 | /* print.css */ | |
57 | 68 | INLINED CSS |
58 | 69 | --> |
59 | 70 | </style> |