Imported Upstream version 0.1701
Lucas Kanashiro
8 years ago
0 | ||
1 | # This file was automatically generated by Dist::Zilla::Plugin::ModuleBuild v5.036. | |
0 | 2 | use strict; |
1 | 3 | use warnings; |
2 | use Module::Build; | |
3 | 4 | |
4 | my $builder = Module::Build->new( | |
5 | module_name => 'HTML::LinkList', | |
6 | license => 'perl', | |
7 | dist_author => 'Kathryn Andersen', | |
8 | dist_version_from => 'lib/HTML/LinkList.pm', | |
9 | requires => { | |
10 | # module requirements here | |
5 | use Module::Build 0.28; | |
11 | 6 | |
12 | }, | |
13 | build_requires => { | |
14 | 'Test::More' => 0, | |
15 | }, | |
16 | create_makefile_pl => 'traditional', | |
17 | # add_to_cleanup => [ 'HTML-LinkList-*' ], | |
7 | ||
8 | my %module_build_args = ( | |
9 | "build_requires" => { | |
10 | "Module::Build" => "0.28" | |
11 | }, | |
12 | "configure_requires" => { | |
13 | "Module::Build" => "0.28" | |
14 | }, | |
15 | "dist_abstract" => "Create a 'smart' list of HTML links.", | |
16 | "dist_author" => [ | |
17 | "Kathryn Andersen" | |
18 | ], | |
19 | "dist_name" => "HTML-LinkList", | |
20 | "dist_version" => "0.1701", | |
21 | "license" => "perl", | |
22 | "module_name" => "HTML::LinkList", | |
23 | "recommends" => {}, | |
24 | "recursive_test_files" => 1, | |
25 | "requires" => { | |
26 | "Data::Dumper" => 0, | |
27 | "Exporter" => 0, | |
28 | "strict" => 0, | |
29 | "warnings" => 0 | |
30 | }, | |
31 | "script_files" => [], | |
32 | "test_requires" => { | |
33 | "ExtUtils::MakeMaker" => 0, | |
34 | "File::Spec" => 0, | |
35 | "IO::Handle" => 0, | |
36 | "IPC::Open3" => 0, | |
37 | "Test::More" => 0, | |
38 | "perl" => "5.006" | |
39 | } | |
18 | 40 | ); |
19 | 41 | |
20 | $builder->create_build_script(); | |
42 | ||
43 | my %fallback_build_requires = ( | |
44 | "ExtUtils::MakeMaker" => 0, | |
45 | "File::Spec" => 0, | |
46 | "IO::Handle" => 0, | |
47 | "IPC::Open3" => 0, | |
48 | "Module::Build" => "0.28", | |
49 | "Test::More" => 0, | |
50 | "perl" => "5.006" | |
51 | ); | |
52 | ||
53 | ||
54 | unless ( eval { Module::Build->VERSION(0.4004) } ) { | |
55 | delete $module_build_args{test_requires}; | |
56 | $module_build_args{build_requires} = \%fallback_build_requires; | |
57 | } | |
58 | ||
59 | my $build = Module::Build->new(%module_build_args); | |
60 | ||
61 | $build->create_build_script; |
0 | Revision history for HTML-LinkList | |
0 | Revision History for HTML-LinkList | |
1 | 1 | ================================== |
2 | 2 | |
3 | 0.1503 Sun 07 September 2008 | |
4 | ---------------------------- | |
3 | v0.1701 2016-01-01 | |
4 | ------------------ | |
5 | 5 | |
6 | * (2008-09-07) A few tweaks with TODO and Changes. | |
6 | * 2016-01-01 10:58:19 +1100 | |
7 | tweaking dist.ini | |
8 | * 2015-05-05 11:14:32 +1000 | |
9 | Dist::Zilla stuff. | |
10 | * 2015-05-05 11:11:09 +1000 | |
11 | version bump | |
12 | * 2015-05-05 11:08:35 +1000 | |
13 | Fixing some compatibility Dist::Zilla stuff. | |
14 | * 2013-09-14 11:49:20 +1000 | |
15 | added [ReportVersions::Tiny] | |
16 | * 2012-02-06 00:32:05 +1100 | |
17 | added a ConfirmRelease test | |
18 | * 2011-02-21 16:57:32 +1100 | |
19 | Disabled Progressive Critic tests. | |
20 | * 2011-02-21 16:37:27 +1100 | |
21 | Fixed Dist::Zilla version setting. | |
22 | * 2011-02-21 16:34:11 +1100 | |
23 | Tweaking Dist::Zilla config. | |
24 | * 2011-02-21 16:30:46 +1100 | |
25 | Changing build system over to Dist::Zilla. | |
26 | * 2011-02-21 13:09:53 +1100 | |
27 | fixed warnings | |
28 | * 2011-02-21 13:07:33 +1100 | |
29 | Links with Mixed Caps, don't decase the labels. | |
30 | * 2011-02-18 13:18:59 +1100 | |
31 | New formatting options: pre_item_active + pre_item_current_parent | |
32 | * 2010-07-02 19:48:46 +1000 | |
33 | updated MANIFEST.SKIP for git | |
34 | * 2010-02-26 16:52:36 +1100 | |
35 | removed nofilter_paths option | |
36 | * 2010-02-26 16:50:33 +1100 | |
37 | Improved algorithm for deeper nested navbars | |
38 | * 2010-01-04 12:54:58 +1100 | |
39 | not a released version | |
40 | * 2010-01-04 12:54:34 +1100 | |
41 | added nofilter_paths option | |
42 | * 2009-12-16 17:01:27 +1100 | |
43 | Slight speed improvements; also added .gitignore | |
7 | 44 | |
8 | 0.1502 Sun 07 September 2008 | |
9 | ---------------------------- | |
10 | ||
11 | * (2008-09-07) Make the Build make a traditional Makefile.PL | |
12 | * (2008-09-07) Tweak to improve prettifying links. | |
13 | ||
14 | 0.1501 Sat 26 May 2007 | |
15 | ---------------------- | |
16 | ||
17 | * (26 May 2007) fix formats | |
18 | Fixed a bug in the advanced formats stuff. | |
19 | ||
20 | 0.15 Tue 22 May 2007 | |
21 | -------------------- | |
22 | ||
23 | * (22 May 2007) advanced formats | |
24 | Added "formats" option for advanced formatting. | |
25 | ||
26 | 0.14 Sat 19 May 2007 | |
27 | -------------------- | |
28 | ||
29 | * (19 May 2007) uneven lists | |
30 | Enable this to deal with lists of lists where the first item | |
31 | isn't a normal item, but a sub-list, but the next item is a normal | |
32 | item. | |
33 | ||
34 | 0.13 Mon 11 September 2006 | |
35 | -------------------------- | |
36 | ||
37 | * (11 Sep 2006) hide_ext | |
38 | Added the 'hide_ext' option, to hide extensions of files in | |
39 | links (useful for MultiViews sites). | |
40 | ||
41 | 0.12 Tue 23 May 2006 | |
42 | -------------------- | |
43 | ||
44 | * (23 May 2006) description improvements | |
45 | Added 'pre_desc' and 'post_desc' options to enable one to | |
46 | put a string before and after the descriptions. | |
47 | ||
48 | 0.11 Thu 20 April 2006 | |
49 | ---------------------- | |
50 | ||
51 | * (20 Apr 2006) preserve_paths option | |
52 | Added the 'preserve_paths' option; if this is true, then the | |
53 | input paths are not sorted, nor do they have intermediate paths extracted. | |
54 | This speeds things up slightly, and can be useful if you already have a full | |
55 | list of paths and don't need to do that processing on it again. | |
56 | ||
57 | 0.1002 Mon 17 April 2006 | |
58 | ------------------------ | |
59 | ||
60 | * (17 Apr 2006) navbar fix | |
61 | If there are paths that are too similar, such as one subdir | |
62 | in a directory being called "foo", and another called "foobar", then | |
63 | it would pick up the foobar stuff in foo when it shouldn't. | |
64 | ||
65 | 0.1001 Thu 13 April 2006 | |
66 | ------------------------ | |
67 | ||
68 | * (12 Apr 2006) fixed nohide bug | |
69 | The 'nohide' option was being ignored in some circumstances. | |
70 | ||
71 | 0.10 Sat 01 April 2006 | |
72 | ---------------------- | |
73 | ||
74 | * (1 Apr 2006) breadcrumb-navbar | |
75 | Added a hybrid breadcrumb-navbar: nav_tree(navbar_type=>'breadcrumb') | |
76 | which starts off like a breadcrumb-trail, showing the parent(s) of | |
77 | the current URL, but also showing the current level, not just the current | |
78 | URL. Useful in situations where you don't want a full-blown navigation | |
79 | tree. | |
80 | ||
81 | 0.09 Thu 16 March 2006 | |
82 | ---------------------- | |
83 | ||
84 | * (16 Mar 2006) documentation tweaking | |
85 | ||
86 | * (16 Mar 2006) exclude_root_parent | |
87 | Added the 'exclude_root_parent' option, which excludes the root "/" | |
88 | path from being counted as a "parent" to the current_url when using the | |
89 | 'pre_current_parent' and 'post_current_parent' options. | |
90 | This can be useful if you want to use those options but don't | |
91 | want the root/Home link to be displayed differently. | |
92 | ||
93 | * (16 Mar 2006) prepend_list and append_list | |
94 | Added new options (to 'full_tree', 'nav_tree') 'prepend_list' | |
95 | and 'append_list' which enable you to prepend or append a list of links | |
96 | to be added to your "top level" as-is. | |
97 | ||
98 | * (16 Mar 2006) removed nav_bar | |
99 | Removed the 'nav_bar' function because it was horrible and made | |
100 | yucky navbars. With use of CSS and choice of levels and separators, the | |
101 | 'nav_tree' should be sufficient, since while the UL list is the default, | |
102 | it can be set up to use paragraphs and so on. | |
103 | ||
104 | 0.08 Thu 16 February 2006 | |
105 | ------------------------- | |
106 | ||
107 | * (16 Feb 2006) top_level option | |
108 | Added a new 'top_level' option, useful for starting a navigation | |
109 | tree further down its hierarchy. | |
110 | ||
111 | 0.07 Thu 02 February 2006 | |
112 | ------------------------- | |
113 | ||
114 | * (2 Feb 2006) depth fixes | |
115 | - enabled start_depth and end_depth to be changed for nav_tree | |
116 | without wierdness happening. It used to be that end_depth was ignored, | |
117 | and if start_depth was anything other than 1, one would get too many links. | |
118 | ||
119 | * (25 Jan 2006) empty lists | |
120 | Added a check to see that the generated list wasn't empty; | |
121 | before this, it would *always* put on the list_head and list_foot | |
122 | stuff even if there was nothing there. Which meant that you | |
123 | could end up with something like <ul></ul> which is Not Nice. | |
124 | ||
125 | * (25 Jan 2006) parent_item_sep | |
126 | Added the 'parent_item_sep' parameter to 'nav_bar'. | |
127 | ||
128 | 0.0601 Thu 19 January 2006 | |
129 | -------------------------- | |
130 | ||
131 | * (19 Jan 2006) corrected error in changelog | |
132 | ||
133 | 0.06 Thu 19 January 2006 | |
134 | ------------------------ | |
135 | ||
136 | * (19 Jan 2006) mostly nav_bar | |
137 | - added new function nav_bar, which does an across-the-top navbar | |
138 | - added new option 'nohide' to override 'hide' | |
139 | - renamed a number of options | |
140 | - restructured the way some things were done | |
141 | ||
142 | 0.0502 Tue 17 January 2006 | |
143 | -------------------------- | |
144 | ||
145 | * (17 Jan 2006) futher correction to navbar | |
146 | This time fer shure! | |
147 | ||
148 | 0.0501 Tue 17 January 2006 | |
149 | -------------------------- | |
150 | ||
151 | * (17 Jan 2006) corrected navbar error | |
152 | My feature enhancement... didn't do what I thought it did. Oops. | |
153 | ||
154 | 0.05 Tue 17 January 2006 | |
155 | ------------------------ | |
156 | ||
157 | * (17 Jan 2006) improved navbar | |
158 | Now the navbar shows the next level up when the current page | |
159 | is not an index page; the siblings of its parent. | |
160 | ||
161 | 0.04 Fri 13 January 2006 | |
162 | ------------------------ | |
163 | ||
164 | * (13 Jan 2006) improved nav_tree | |
165 | Revamped the logic and the options to make nav_tree more sensible | |
166 | and simpler to use. | |
167 | ||
168 | * (12 Jan 2006) nomenclature | |
169 | Stop referring to directories; they're index pages. | |
170 | Renamed 'dir_tree' to 'full_tree'. | |
171 | ||
172 | 0.03 Thu 12 January 2006 | |
173 | ------------------------ | |
174 | ||
175 | * (12 Jan 2006) renames,additions,nav_tree | |
176 | - renamed breadcrumb_tree to breadcrumb_trail | |
177 | - added the 'preserve_order' option to dir_tree | |
178 | - added new function 'nav_tree' to make a nested navbar | |
179 | - updated documentation | |
180 | - fixes and tweaks | |
181 | ||
182 | 0.02 Wed 11 January 2006 | |
183 | ------------------------ | |
184 | ||
185 | * (11 Jan 2006) breadcrumb_tree | |
186 | Added the 'breadcrumb_tree' function which makes a breadcrumb | |
187 | trail from the current_url. | |
188 | ||
189 | * (11 Jan 2006) minor fixes | |
190 | Made the checking of the 'current_url' better. | |
191 | ||
192 | 0.01 Mon 09 January 2006 | |
193 | ------------------------ | |
194 | ||
195 | * (9 Jan 2006) tweaking documentation | |
196 | ||
197 | * (9 Jan 2006) commit tweaking | |
198 | The ModDevAid stuff needed to not try to chmod non-existant scripts. | |
199 | ||
200 | * (9 Jan 2006) fixing tests | |
201 | Just some minor bugs with the tests. | |
202 | ||
203 | * (9 Jan 2006) initial checkin | |
45 | ==================================== | |
46 | End of changes in the last 1000 days | |
47 | ==================================== |
0 | This software is copyright (c) 2016 by Kathryn Andersen. | |
1 | ||
2 | This is free software; you can redistribute it and/or modify it under | |
3 | the same terms as the Perl 5 programming language system itself. | |
4 | ||
5 | Terms of the Perl programming language system itself | |
6 | ||
7 | a) the GNU General Public License as published by the Free | |
8 | Software Foundation; either version 1, or (at your option) any | |
9 | later version, or | |
10 | b) the "Artistic License" | |
11 | ||
12 | --- The GNU General Public License, Version 1, February 1989 --- | |
13 | ||
14 | This software is Copyright (c) 2016 by Kathryn Andersen. | |
15 | ||
16 | This is free software, licensed under: | |
17 | ||
18 | The GNU General Public License, Version 1, February 1989 | |
19 | ||
20 | GNU GENERAL PUBLIC LICENSE | |
21 | Version 1, February 1989 | |
22 | ||
23 | Copyright (C) 1989 Free Software Foundation, Inc. | |
24 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
25 | ||
26 | Everyone is permitted to copy and distribute verbatim copies | |
27 | of this license document, but changing it is not allowed. | |
28 | ||
29 | Preamble | |
30 | ||
31 | The license agreements of most software companies try to keep users | |
32 | at the mercy of those companies. By contrast, our General Public | |
33 | License is intended to guarantee your freedom to share and change free | |
34 | software--to make sure the software is free for all its users. The | |
35 | General Public License applies to the Free Software Foundation's | |
36 | software and to any other program whose authors commit to using it. | |
37 | You can use it for your programs, too. | |
38 | ||
39 | When we speak of free software, we are referring to freedom, not | |
40 | price. Specifically, the General Public License is designed to make | |
41 | sure that you have the freedom to give away or sell copies of free | |
42 | software, that you receive source code or can get it if you want it, | |
43 | that you can change the software or use pieces of it in new free | |
44 | programs; and that you know you can do these things. | |
45 | ||
46 | To protect your rights, we need to make restrictions that forbid | |
47 | anyone to deny you these rights or to ask you to surrender the rights. | |
48 | These restrictions translate to certain responsibilities for you if you | |
49 | distribute copies of the software, or if you modify it. | |
50 | ||
51 | For example, if you distribute copies of a such a program, whether | |
52 | gratis or for a fee, you must give the recipients all the rights that | |
53 | you have. You must make sure that they, too, receive or can get the | |
54 | source code. And you must tell them their rights. | |
55 | ||
56 | We protect your rights with two steps: (1) copyright the software, and | |
57 | (2) offer you this license which gives you legal permission to copy, | |
58 | distribute and/or modify the software. | |
59 | ||
60 | Also, for each author's protection and ours, we want to make certain | |
61 | that everyone understands that there is no warranty for this free | |
62 | software. If the software is modified by someone else and passed on, we | |
63 | want its recipients to know that what they have is not the original, so | |
64 | that any problems introduced by others will not reflect on the original | |
65 | authors' reputations. | |
66 | ||
67 | The precise terms and conditions for copying, distribution and | |
68 | modification follow. | |
69 | ||
70 | GNU GENERAL PUBLIC LICENSE | |
71 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |
72 | ||
73 | 0. This License Agreement applies to any program or other work which | |
74 | contains a notice placed by the copyright holder saying it may be | |
75 | distributed under the terms of this General Public License. The | |
76 | "Program", below, refers to any such program or work, and a "work based | |
77 | on the Program" means either the Program or any work containing the | |
78 | Program or a portion of it, either verbatim or with modifications. Each | |
79 | licensee is addressed as "you". | |
80 | ||
81 | 1. You may copy and distribute verbatim copies of the Program's source | |
82 | code as you receive it, in any medium, provided that you conspicuously and | |
83 | appropriately publish on each copy an appropriate copyright notice and | |
84 | disclaimer of warranty; keep intact all the notices that refer to this | |
85 | General Public License and to the absence of any warranty; and give any | |
86 | other recipients of the Program a copy of this General Public License | |
87 | along with the Program. You may charge a fee for the physical act of | |
88 | transferring a copy. | |
89 | ||
90 | 2. You may modify your copy or copies of the Program or any portion of | |
91 | it, and copy and distribute such modifications under the terms of Paragraph | |
92 | 1 above, provided that you also do the following: | |
93 | ||
94 | a) cause the modified files to carry prominent notices stating that | |
95 | you changed the files and the date of any change; and | |
96 | ||
97 | b) cause the whole of any work that you distribute or publish, that | |
98 | in whole or in part contains the Program or any part thereof, either | |
99 | with or without modifications, to be licensed at no charge to all | |
100 | third parties under the terms of this General Public License (except | |
101 | that you may choose to grant warranty protection to some or all | |
102 | third parties, at your option). | |
103 | ||
104 | c) If the modified program normally reads commands interactively when | |
105 | run, you must cause it, when started running for such interactive use | |
106 | in the simplest and most usual way, to print or display an | |
107 | announcement including an appropriate copyright notice and a notice | |
108 | that there is no warranty (or else, saying that you provide a | |
109 | warranty) and that users may redistribute the program under these | |
110 | conditions, and telling the user how to view a copy of this General | |
111 | Public License. | |
112 | ||
113 | d) You may charge a fee for the physical act of transferring a | |
114 | copy, and you may at your option offer warranty protection in | |
115 | exchange for a fee. | |
116 | ||
117 | Mere aggregation of another independent work with the Program (or its | |
118 | derivative) on a volume of a storage or distribution medium does not bring | |
119 | the other work under the scope of these terms. | |
120 | ||
121 | 3. You may copy and distribute the Program (or a portion or derivative of | |
122 | it, under Paragraph 2) in object code or executable form under the terms of | |
123 | Paragraphs 1 and 2 above provided that you also do one of the following: | |
124 | ||
125 | a) accompany it with the complete corresponding machine-readable | |
126 | source code, which must be distributed under the terms of | |
127 | Paragraphs 1 and 2 above; or, | |
128 | ||
129 | b) accompany it with a written offer, valid for at least three | |
130 | years, to give any third party free (except for a nominal charge | |
131 | for the cost of distribution) a complete machine-readable copy of the | |
132 | corresponding source code, to be distributed under the terms of | |
133 | Paragraphs 1 and 2 above; or, | |
134 | ||
135 | c) accompany it with the information you received as to where the | |
136 | corresponding source code may be obtained. (This alternative is | |
137 | allowed only for noncommercial distribution and only if you | |
138 | received the program in object code or executable form alone.) | |
139 | ||
140 | Source code for a work means the preferred form of the work for making | |
141 | modifications to it. For an executable file, complete source code means | |
142 | all the source code for all modules it contains; but, as a special | |
143 | exception, it need not include source code for modules which are standard | |
144 | libraries that accompany the operating system on which the executable | |
145 | file runs, or for standard header files or definitions files that | |
146 | accompany that operating system. | |
147 | ||
148 | 4. You may not copy, modify, sublicense, distribute or transfer the | |
149 | Program except as expressly provided under this General Public License. | |
150 | Any attempt otherwise to copy, modify, sublicense, distribute or transfer | |
151 | the Program is void, and will automatically terminate your rights to use | |
152 | the Program under this License. However, parties who have received | |
153 | copies, or rights to use copies, from you under this General Public | |
154 | License will not have their licenses terminated so long as such parties | |
155 | remain in full compliance. | |
156 | ||
157 | 5. By copying, distributing or modifying the Program (or any work based | |
158 | on the Program) you indicate your acceptance of this license to do so, | |
159 | and all its terms and conditions. | |
160 | ||
161 | 6. Each time you redistribute the Program (or any work based on the | |
162 | Program), the recipient automatically receives a license from the original | |
163 | licensor to copy, distribute or modify the Program subject to these | |
164 | terms and conditions. You may not impose any further restrictions on the | |
165 | recipients' exercise of the rights granted herein. | |
166 | ||
167 | 7. The Free Software Foundation may publish revised and/or new versions | |
168 | of the General Public License from time to time. Such new versions will | |
169 | be similar in spirit to the present version, but may differ in detail to | |
170 | address new problems or concerns. | |
171 | ||
172 | Each version is given a distinguishing version number. If the Program | |
173 | specifies a version number of the license which applies to it and "any | |
174 | later version", you have the option of following the terms and conditions | |
175 | either of that version or of any later version published by the Free | |
176 | Software Foundation. If the Program does not specify a version number of | |
177 | the license, you may choose any version ever published by the Free Software | |
178 | Foundation. | |
179 | ||
180 | 8. If you wish to incorporate parts of the Program into other free | |
181 | programs whose distribution conditions are different, write to the author | |
182 | to ask for permission. For software which is copyrighted by the Free | |
183 | Software Foundation, write to the Free Software Foundation; we sometimes | |
184 | make exceptions for this. Our decision will be guided by the two goals | |
185 | of preserving the free status of all derivatives of our free software and | |
186 | of promoting the sharing and reuse of software generally. | |
187 | ||
188 | NO WARRANTY | |
189 | ||
190 | 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY | |
191 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN | |
192 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES | |
193 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED | |
194 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
195 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS | |
196 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE | |
197 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, | |
198 | REPAIR OR CORRECTION. | |
199 | ||
200 | 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING | |
201 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR | |
202 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, | |
203 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING | |
204 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED | |
205 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY | |
206 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER | |
207 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE | |
208 | POSSIBILITY OF SUCH DAMAGES. | |
209 | ||
210 | END OF TERMS AND CONDITIONS | |
211 | ||
212 | Appendix: How to Apply These Terms to Your New Programs | |
213 | ||
214 | If you develop a new program, and you want it to be of the greatest | |
215 | possible use to humanity, the best way to achieve this is to make it | |
216 | free software which everyone can redistribute and change under these | |
217 | terms. | |
218 | ||
219 | To do so, attach the following notices to the program. It is safest to | |
220 | attach them to the start of each source file to most effectively convey | |
221 | the exclusion of warranty; and each file should have at least the | |
222 | "copyright" line and a pointer to where the full notice is found. | |
223 | ||
224 | <one line to give the program's name and a brief idea of what it does.> | |
225 | Copyright (C) 19yy <name of author> | |
226 | ||
227 | This program is free software; you can redistribute it and/or modify | |
228 | it under the terms of the GNU General Public License as published by | |
229 | the Free Software Foundation; either version 1, or (at your option) | |
230 | any later version. | |
231 | ||
232 | This program is distributed in the hope that it will be useful, | |
233 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
234 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
235 | GNU General Public License for more details. | |
236 | ||
237 | You should have received a copy of the GNU General Public License | |
238 | along with this program; if not, write to the Free Software | |
239 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA | |
240 | ||
241 | ||
242 | Also add information on how to contact you by electronic and paper mail. | |
243 | ||
244 | If the program is interactive, make it output a short notice like this | |
245 | when it starts in an interactive mode: | |
246 | ||
247 | Gnomovision version 69, Copyright (C) 19xx name of author | |
248 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. | |
249 | This is free software, and you are welcome to redistribute it | |
250 | under certain conditions; type `show c' for details. | |
251 | ||
252 | The hypothetical commands `show w' and `show c' should show the | |
253 | appropriate parts of the General Public License. Of course, the | |
254 | commands you use may be called something other than `show w' and `show | |
255 | c'; they could even be mouse-clicks or menu items--whatever suits your | |
256 | program. | |
257 | ||
258 | You should also get your employer (if you work as a programmer) or your | |
259 | school, if any, to sign a "copyright disclaimer" for the program, if | |
260 | necessary. Here a sample; alter the names: | |
261 | ||
262 | Yoyodyne, Inc., hereby disclaims all copyright interest in the | |
263 | program `Gnomovision' (a program to direct compilers to make passes | |
264 | at assemblers) written by James Hacker. | |
265 | ||
266 | <signature of Ty Coon>, 1 April 1989 | |
267 | Ty Coon, President of Vice | |
268 | ||
269 | That's all there is to it! | |
270 | ||
271 | ||
272 | --- The Artistic License 1.0 --- | |
273 | ||
274 | This software is Copyright (c) 2016 by Kathryn Andersen. | |
275 | ||
276 | This is free software, licensed under: | |
277 | ||
278 | The Artistic License 1.0 | |
279 | ||
280 | The Artistic License | |
281 | ||
282 | Preamble | |
283 | ||
284 | The intent of this document is to state the conditions under which a Package | |
285 | may be copied, such that the Copyright Holder maintains some semblance of | |
286 | artistic control over the development of the package, while giving the users of | |
287 | the package the right to use and distribute the Package in a more-or-less | |
288 | customary fashion, plus the right to make reasonable modifications. | |
289 | ||
290 | Definitions: | |
291 | ||
292 | - "Package" refers to the collection of files distributed by the Copyright | |
293 | Holder, and derivatives of that collection of files created through | |
294 | textual modification. | |
295 | - "Standard Version" refers to such a Package if it has not been modified, | |
296 | or has been modified in accordance with the wishes of the Copyright | |
297 | Holder. | |
298 | - "Copyright Holder" is whoever is named in the copyright or copyrights for | |
299 | the package. | |
300 | - "You" is you, if you're thinking about copying or distributing this Package. | |
301 | - "Reasonable copying fee" is whatever you can justify on the basis of media | |
302 | cost, duplication charges, time of people involved, and so on. (You will | |
303 | not be required to justify it to the Copyright Holder, but only to the | |
304 | computing community at large as a market that must bear the fee.) | |
305 | - "Freely Available" means that no fee is charged for the item itself, though | |
306 | there may be fees involved in handling the item. It also means that | |
307 | recipients of the item may redistribute it under the same conditions they | |
308 | received it. | |
309 | ||
310 | 1. You may make and give away verbatim copies of the source form of the | |
311 | Standard Version of this Package without restriction, provided that you | |
312 | duplicate all of the original copyright notices and associated disclaimers. | |
313 | ||
314 | 2. You may apply bug fixes, portability fixes and other modifications derived | |
315 | from the Public Domain or from the Copyright Holder. A Package modified in such | |
316 | a way shall still be considered the Standard Version. | |
317 | ||
318 | 3. You may otherwise modify your copy of this Package in any way, provided that | |
319 | you insert a prominent notice in each changed file stating how and when you | |
320 | changed that file, and provided that you do at least ONE of the following: | |
321 | ||
322 | a) place your modifications in the Public Domain or otherwise make them | |
323 | Freely Available, such as by posting said modifications to Usenet or an | |
324 | equivalent medium, or placing the modifications on a major archive site | |
325 | such as ftp.uu.net, or by allowing the Copyright Holder to include your | |
326 | modifications in the Standard Version of the Package. | |
327 | ||
328 | b) use the modified Package only within your corporation or organization. | |
329 | ||
330 | c) rename any non-standard executables so the names do not conflict with | |
331 | standard executables, which must also be provided, and provide a separate | |
332 | manual page for each non-standard executable that clearly documents how it | |
333 | differs from the Standard Version. | |
334 | ||
335 | d) make other distribution arrangements with the Copyright Holder. | |
336 | ||
337 | 4. You may distribute the programs of this Package in object code or executable | |
338 | form, provided that you do at least ONE of the following: | |
339 | ||
340 | a) distribute a Standard Version of the executables and library files, | |
341 | together with instructions (in the manual page or equivalent) on where to | |
342 | get the Standard Version. | |
343 | ||
344 | b) accompany the distribution with the machine-readable source of the Package | |
345 | with your modifications. | |
346 | ||
347 | c) accompany any non-standard executables with their corresponding Standard | |
348 | Version executables, giving the non-standard executables non-standard | |
349 | names, and clearly documenting the differences in manual pages (or | |
350 | equivalent), together with instructions on where to get the Standard | |
351 | Version. | |
352 | ||
353 | d) make other distribution arrangements with the Copyright Holder. | |
354 | ||
355 | 5. You may charge a reasonable copying fee for any distribution of this | |
356 | Package. You may charge any fee you choose for support of this Package. You | |
357 | may not charge a fee for this Package itself. However, you may distribute this | |
358 | Package in aggregate with other (possibly commercial) programs as part of a | |
359 | larger (possibly commercial) software distribution provided that you do not | |
360 | advertise this Package as a product of your own. | |
361 | ||
362 | 6. The scripts and library files supplied as input to or produced as output | |
363 | from the programs of this Package do not automatically fall under the copyright | |
364 | of this Package, but belong to whomever generated them, and may be sold | |
365 | commercially, and may be aggregated with this Package. | |
366 | ||
367 | 7. C or perl subroutines supplied by you and linked into this Package shall not | |
368 | be considered part of this Package. | |
369 | ||
370 | 8. The name of the Copyright Holder may not be used to endorse or promote | |
371 | products derived from this software without specific prior written permission. | |
372 | ||
373 | 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED | |
374 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF | |
375 | MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
376 | ||
377 | The End | |
378 |
0 | # This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.036. | |
0 | 1 | Build.PL |
1 | Makefile.PL | |
2 | 2 | Changes |
3 | LICENSE | |
3 | 4 | MANIFEST |
4 | 5 | MANIFEST.SKIP |
5 | META.yml # Will be created by "make dist" | |
6 | META.yml | |
7 | OldChanges | |
6 | 8 | README |
7 | TODO | |
9 | README.mkdn | |
8 | 10 | lib/HTML/LinkList.pm |
9 | t/00_dist.t | |
10 | t/01_load.t | |
11 | t/pod-coverage.t | |
12 | t/pod.t | |
11 | t/00-compile.t | |
12 | t/00-report-prereqs.dd | |
13 | t/00-report-prereqs.t | |
13 | 14 | t/10_link_list.t |
14 | 15 | t/20_link_tree.t |
15 | 16 | t/30_full_tree.t |
16 | 17 | t/40_breadcrumb_trail.t |
17 | 18 | t/50_nav_tree.t |
18 | ||
19 | t/release-distmeta.t | |
20 | t/release-has-version.t | |
21 | t/release-pod-coverage.t | |
22 | t/release-pod-syntax.t | |
23 | t/release-portability.t |
2 | 2 | \bCVS\b |
3 | 3 | ,v$ |
4 | 4 | ^_darcs/ |
5 | ^\.git/ | |
6 | ^\.gitignore$ | |
5 | 7 | |
6 | # ModDevAid | |
7 | ^version.txt$ | |
8 | ^old_version.txt$ | |
9 | ^darcs_prebuild.pl$ | |
10 | ^mod_devaid.conf$ | |
8 | # Dev | |
9 | ^\.todo$ | |
10 | ^dist.ini$ | |
11 | 11 | |
12 | 12 | # distro files |
13 | 13 | ^HTML-LinkList-* |
18 | 18 | ^blibdirs$ |
19 | 19 | ^pm_to_blib$ |
20 | 20 | ^MakeMaker-\d |
21 | ||
21 | ||
22 | 22 | # Module::Build |
23 | 23 | ^Build$ |
24 | 24 | ^_build/ |
25 | ||
25 | ||
26 | 26 | # Temp, old, vi and emacs files. |
27 | 27 | ~$ |
28 | 28 | \.old$ |
0 | 0 | --- |
1 | abstract: "Create a 'smart' list of HTML links." | |
2 | author: | |
3 | - 'Kathryn Andersen' | |
4 | build_requires: | |
5 | ExtUtils::MakeMaker: '0' | |
6 | File::Spec: '0' | |
7 | IO::Handle: '0' | |
8 | IPC::Open3: '0' | |
9 | Module::Build: '0.28' | |
10 | Test::More: '0' | |
11 | perl: '5.006' | |
12 | configure_requires: | |
13 | Module::Build: '0.28' | |
14 | dynamic_config: 0 | |
15 | generated_by: 'Dist::Zilla version 5.036, CPAN::Meta::Converter version 2.143240' | |
16 | license: perl | |
17 | meta-spec: | |
18 | url: http://module-build.sourceforge.net/META-spec-v1.4.html | |
19 | version: '1.4' | |
1 | 20 | name: HTML-LinkList |
2 | version: 0.1503 | |
3 | author: | |
4 | - Kathryn Andersen | |
5 | abstract: Create a 'smart' list of HTML links. | |
6 | license: perl | |
21 | requires: | |
22 | Data::Dumper: '0' | |
23 | Exporter: '0' | |
24 | strict: '0' | |
25 | warnings: '0' | |
7 | 26 | resources: |
8 | license: http://dev.perl.org/licenses/ | |
9 | build_requires: | |
10 | Test::More: 0 | |
11 | provides: | |
12 | HTML::LinkList: | |
13 | file: lib/HTML/LinkList.pm | |
14 | version: 0.1503 | |
15 | generated_by: Module::Build version 0.2808 | |
16 | meta-spec: | |
17 | url: http://module-build.sourceforge.net/META-spec-v1.2.html | |
18 | version: 1.2 | |
27 | homepage: https://github.com/rubykat/HTML-LinkList | |
28 | repository: https://github.com/rubykat/HTML-LinkList.git | |
29 | version: '0.1701' |
0 | # Note: this file was auto-generated by Module::Build::Compat version 0.03 | |
1 | use ExtUtils::MakeMaker; | |
2 | WriteMakefile | |
3 | ( | |
4 | 'PL_FILES' => {}, | |
5 | 'INSTALLDIRS' => 'site', | |
6 | 'NAME' => 'HTML::LinkList', | |
7 | 'EXE_FILES' => [], | |
8 | 'VERSION_FROM' => 'lib/HTML/LinkList.pm', | |
9 | 'PREREQ_PM' => { | |
10 | 'Test::More' => 0 | |
11 | } | |
12 | ) | |
13 | ; |
0 | Revision history for HTML-LinkList | |
1 | ================================== | |
2 | ||
3 | 0.1503 Sun 07 September 2008 | |
4 | ---------------------------- | |
5 | ||
6 | * (2008-09-07) A few tweaks with TODO and Changes. | |
7 | ||
8 | 0.1502 Sun 07 September 2008 | |
9 | ---------------------------- | |
10 | ||
11 | * (2008-09-07) Make the Build make a traditional Makefile.PL | |
12 | * (2008-09-07) Tweak to improve prettifying links. | |
13 | ||
14 | 0.1501 Sat 26 May 2007 | |
15 | ---------------------- | |
16 | ||
17 | * (26 May 2007) fix formats | |
18 | Fixed a bug in the advanced formats stuff. | |
19 | ||
20 | 0.15 Tue 22 May 2007 | |
21 | -------------------- | |
22 | ||
23 | * (22 May 2007) advanced formats | |
24 | Added "formats" option for advanced formatting. | |
25 | ||
26 | 0.14 Sat 19 May 2007 | |
27 | -------------------- | |
28 | ||
29 | * (19 May 2007) uneven lists | |
30 | Enable this to deal with lists of lists where the first item | |
31 | isn't a normal item, but a sub-list, but the next item is a normal | |
32 | item. | |
33 | ||
34 | 0.13 Mon 11 September 2006 | |
35 | -------------------------- | |
36 | ||
37 | * (11 Sep 2006) hide_ext | |
38 | Added the 'hide_ext' option, to hide extensions of files in | |
39 | links (useful for MultiViews sites). | |
40 | ||
41 | 0.12 Tue 23 May 2006 | |
42 | -------------------- | |
43 | ||
44 | * (23 May 2006) description improvements | |
45 | Added 'pre_desc' and 'post_desc' options to enable one to | |
46 | put a string before and after the descriptions. | |
47 | ||
48 | 0.11 Thu 20 April 2006 | |
49 | ---------------------- | |
50 | ||
51 | * (20 Apr 2006) preserve_paths option | |
52 | Added the 'preserve_paths' option; if this is true, then the | |
53 | input paths are not sorted, nor do they have intermediate paths extracted. | |
54 | This speeds things up slightly, and can be useful if you already have a full | |
55 | list of paths and don't need to do that processing on it again. | |
56 | ||
57 | 0.1002 Mon 17 April 2006 | |
58 | ------------------------ | |
59 | ||
60 | * (17 Apr 2006) navbar fix | |
61 | If there are paths that are too similar, such as one subdir | |
62 | in a directory being called "foo", and another called "foobar", then | |
63 | it would pick up the foobar stuff in foo when it shouldn't. | |
64 | ||
65 | 0.1001 Thu 13 April 2006 | |
66 | ------------------------ | |
67 | ||
68 | * (12 Apr 2006) fixed nohide bug | |
69 | The 'nohide' option was being ignored in some circumstances. | |
70 | ||
71 | 0.10 Sat 01 April 2006 | |
72 | ---------------------- | |
73 | ||
74 | * (1 Apr 2006) breadcrumb-navbar | |
75 | Added a hybrid breadcrumb-navbar: nav_tree(navbar_type=>'breadcrumb') | |
76 | which starts off like a breadcrumb-trail, showing the parent(s) of | |
77 | the current URL, but also showing the current level, not just the current | |
78 | URL. Useful in situations where you don't want a full-blown navigation | |
79 | tree. | |
80 | ||
81 | 0.09 Thu 16 March 2006 | |
82 | ---------------------- | |
83 | ||
84 | * (16 Mar 2006) documentation tweaking | |
85 | ||
86 | * (16 Mar 2006) exclude_root_parent | |
87 | Added the 'exclude_root_parent' option, which excludes the root "/" | |
88 | path from being counted as a "parent" to the current_url when using the | |
89 | 'pre_current_parent' and 'post_current_parent' options. | |
90 | This can be useful if you want to use those options but don't | |
91 | want the root/Home link to be displayed differently. | |
92 | ||
93 | * (16 Mar 2006) prepend_list and append_list | |
94 | Added new options (to 'full_tree', 'nav_tree') 'prepend_list' | |
95 | and 'append_list' which enable you to prepend or append a list of links | |
96 | to be added to your "top level" as-is. | |
97 | ||
98 | * (16 Mar 2006) removed nav_bar | |
99 | Removed the 'nav_bar' function because it was horrible and made | |
100 | yucky navbars. With use of CSS and choice of levels and separators, the | |
101 | 'nav_tree' should be sufficient, since while the UL list is the default, | |
102 | it can be set up to use paragraphs and so on. | |
103 | ||
104 | 0.08 Thu 16 February 2006 | |
105 | ------------------------- | |
106 | ||
107 | * (16 Feb 2006) top_level option | |
108 | Added a new 'top_level' option, useful for starting a navigation | |
109 | tree further down its hierarchy. | |
110 | ||
111 | 0.07 Thu 02 February 2006 | |
112 | ------------------------- | |
113 | ||
114 | * (2 Feb 2006) depth fixes | |
115 | - enabled start_depth and end_depth to be changed for nav_tree | |
116 | without wierdness happening. It used to be that end_depth was ignored, | |
117 | and if start_depth was anything other than 1, one would get too many links. | |
118 | ||
119 | * (25 Jan 2006) empty lists | |
120 | Added a check to see that the generated list wasn't empty; | |
121 | before this, it would *always* put on the list_head and list_foot | |
122 | stuff even if there was nothing there. Which meant that you | |
123 | could end up with something like <ul></ul> which is Not Nice. | |
124 | ||
125 | * (25 Jan 2006) parent_item_sep | |
126 | Added the 'parent_item_sep' parameter to 'nav_bar'. | |
127 | ||
128 | 0.0601 Thu 19 January 2006 | |
129 | -------------------------- | |
130 | ||
131 | * (19 Jan 2006) corrected error in changelog | |
132 | ||
133 | 0.06 Thu 19 January 2006 | |
134 | ------------------------ | |
135 | ||
136 | * (19 Jan 2006) mostly nav_bar | |
137 | - added new function nav_bar, which does an across-the-top navbar | |
138 | - added new option 'nohide' to override 'hide' | |
139 | - renamed a number of options | |
140 | - restructured the way some things were done | |
141 | ||
142 | 0.0502 Tue 17 January 2006 | |
143 | -------------------------- | |
144 | ||
145 | * (17 Jan 2006) futher correction to navbar | |
146 | This time fer shure! | |
147 | ||
148 | 0.0501 Tue 17 January 2006 | |
149 | -------------------------- | |
150 | ||
151 | * (17 Jan 2006) corrected navbar error | |
152 | My feature enhancement... didn't do what I thought it did. Oops. | |
153 | ||
154 | 0.05 Tue 17 January 2006 | |
155 | ------------------------ | |
156 | ||
157 | * (17 Jan 2006) improved navbar | |
158 | Now the navbar shows the next level up when the current page | |
159 | is not an index page; the siblings of its parent. | |
160 | ||
161 | 0.04 Fri 13 January 2006 | |
162 | ------------------------ | |
163 | ||
164 | * (13 Jan 2006) improved nav_tree | |
165 | Revamped the logic and the options to make nav_tree more sensible | |
166 | and simpler to use. | |
167 | ||
168 | * (12 Jan 2006) nomenclature | |
169 | Stop referring to directories; they're index pages. | |
170 | Renamed 'dir_tree' to 'full_tree'. | |
171 | ||
172 | 0.03 Thu 12 January 2006 | |
173 | ------------------------ | |
174 | ||
175 | * (12 Jan 2006) renames,additions,nav_tree | |
176 | - renamed breadcrumb_tree to breadcrumb_trail | |
177 | - added the 'preserve_order' option to dir_tree | |
178 | - added new function 'nav_tree' to make a nested navbar | |
179 | - updated documentation | |
180 | - fixes and tweaks | |
181 | ||
182 | 0.02 Wed 11 January 2006 | |
183 | ------------------------ | |
184 | ||
185 | * (11 Jan 2006) breadcrumb_tree | |
186 | Added the 'breadcrumb_tree' function which makes a breadcrumb | |
187 | trail from the current_url. | |
188 | ||
189 | * (11 Jan 2006) minor fixes | |
190 | Made the checking of the 'current_url' better. | |
191 | ||
192 | 0.01 Mon 09 January 2006 | |
193 | ------------------------ | |
194 | ||
195 | * (9 Jan 2006) tweaking documentation | |
196 | ||
197 | * (9 Jan 2006) commit tweaking | |
198 | The ModDevAid stuff needed to not try to chmod non-existant scripts. | |
199 | ||
200 | * (9 Jan 2006) fixing tests | |
201 | Just some minor bugs with the tests. | |
202 | ||
203 | * (9 Jan 2006) initial checkin |
0 | ||
1 | ==== NAME ==== | |
2 | ||
3 | HTML::LinkList - Create a 'smart' list of HTML links. | |
4 | ||
5 | ||
6 | ==== VERSION ==== | |
7 | ||
8 | This describes version ``0.1503'' of HTML::LinkList. | |
9 | ||
10 | ||
11 | ==== DESCRIPTION ==== | |
12 | ||
13 | This module contains a number of functions for taking sets of URLs and | |
14 | labels and creating suitably formatted HTML. These links are "smart" | |
15 | because, if given the url of the current page, if any of the links in the | |
16 | list equal it, that item in the list will be formatted as a special label, | |
17 | not as a link; this is a Good Thing, since the user would be confused by | |
18 | clicking on a link back to the current page. | |
19 | ||
20 | While many website systems have plugins for "smart" navbars, they are | |
21 | specialized for that system only, and can't be reused elsewhere, forcing | |
22 | people to reinvent the wheel. I hereby present one wheel, free to be reused | |
23 | by anybody; just the simple functions, a backend, which can be plugged into | |
24 | whatever system you want. | |
25 | ||
26 | The default format for the HTML is to make an unordered list, but there are | |
27 | many options, enabling one to have a flatter layout with any separators you | |
28 | desire, or a more complicated list with differing formats for different | |
29 | levels. | |
30 | ||
31 | The "link_list" function uses a simple list of links -- good for a simple | |
32 | navbar. | |
33 | ||
34 | The "link_tree" function takes a set of nested links and makes the HTML for | |
35 | them -- good for making a table of contents, or a more complicated navbar. | |
36 | ||
37 | The "full_tree" function takes a list of paths and makes a full tree of all | |
38 | the pages and index-pages in those paths -- good for making a site map. | |
39 | ||
40 | The "breadcrumb_trail" function takes a url and makes a "breadcrumb trail" | |
41 | from it. | |
42 | ||
43 | The "nav_tree" function creates a set of nested links to be used as a | |
44 | multi-level navbar; one can give it a list of paths (as for full_tree) and | |
45 | it will only show the links related to the current URL. | |
46 | ||
47 | ||
48 | ==== REQUIRES ==== | |
49 | ||
50 | Test::More | |
51 | ||
52 | ||
53 | ==== INSTALLATION ==== | |
54 | ||
55 | To install this module, run the following commands: | |
56 | ||
57 | perl Build.PL | |
58 | ./Build | |
59 | ./Build test | |
60 | ./Build install | |
61 | ||
62 | Or, if you're on a platform (like DOS or Windows) that doesn't like the "./" | |
63 | notation, you can do this: | |
64 | ||
65 | perl Build.PL | |
66 | perl Build | |
67 | perl Build test | |
68 | perl Build install | |
69 | ||
70 | In order to install somewhere other than the default, such as in a directory | |
71 | under your home directory, like "/home/fred/perl" go | |
72 | ||
73 | perl Build.PL --install_base /home/fred/perl | |
74 | ||
75 | as the first step instead. | |
76 | ||
77 | This will install the files underneath /home/fred/perl. | |
78 | ||
79 | You will then need to make sure that you alter the PERL5LIB variable to find | |
80 | the modules. | |
81 | ||
82 | Therefore you will need to change the PERL5LIB variable to add | |
83 | /home/fred/perl/lib | |
84 | ||
85 | PERL5LIB=/home/fred/perl/lib:${PERL5LIB} | |
86 | ||
87 | ||
88 | ==== AUTHOR ==== | |
89 | ||
90 | Kathryn Andersen (RUBYKAT) | |
91 | perlkat AT katspace dot com | |
92 | http://www.katspace.com/tools/html_linklist/ | |
93 | ||
94 | ||
95 | ==== COPYRIGHT AND LICENCE ==== | |
96 | ||
97 | Copyright (c) 2006 by Kathryn Andersen | |
98 | ||
99 | This program is free software; you can redistribute it and/or modify it | |
100 | under the same terms as Perl itself. | |
101 | ||
0 | NAME | |
1 | ||
2 | HTML::LinkList - Create a 'smart' list of HTML links. | |
3 | ||
4 | SYNOPSIS | |
5 | ||
6 | use HTML::LinkList qw(link_list); | |
7 | ||
8 | # default formatting | |
9 | my $html_links = link_list(current_url=>$url, | |
10 | urls=>\@links_in_order, | |
11 | labels=>\%labels, | |
12 | descriptions=>\%desc); | |
13 | ||
14 | # paragraph with ' :: ' separators | |
15 | my $html_links = link_list(current_url=>$url, | |
16 | urls=>\@links_in_order, | |
17 | labels=>\%labels, | |
18 | descriptions=>\%desc, | |
19 | links_head=>'<p>', | |
20 | links_foot=>'</p>', | |
21 | pre_item=>'', | |
22 | post_item=>'' | |
23 | pre_active_item=>'<em>', | |
24 | post_active_item=>'</em>', | |
25 | item_sep=>" :: "); | |
26 | ||
27 | # multi-level list | |
28 | my $html_links = link_tree( | |
29 | current_url=>$url, | |
30 | link_tree=>\@list_of_lists, | |
31 | labels=>\%labels, | |
32 | descriptions=>\%desc); | |
33 | ||
34 | DESCRIPTION | |
35 | ||
36 | This module contains a number of functions for taking sets of URLs and | |
37 | labels and creating suitably formatted HTML. These links are "smart" | |
38 | because, if given the url of the current page, if any of the links in | |
39 | the list equal it, that item in the list will be formatted as a special | |
40 | label, not as a link; this is a Good Thing, since the user would be | |
41 | confused by clicking on a link back to the current page. | |
42 | ||
43 | While many website systems have plugins for "smart" navbars, they are | |
44 | specialized for that system only, and can't be reused elsewhere, | |
45 | forcing people to reinvent the wheel. I hereby present one wheel, free | |
46 | to be reused by anybody; just the simple functions, a backend, which | |
47 | can be plugged into whatever system you want. | |
48 | ||
49 | The default format for the HTML is to make an unordered list, but there | |
50 | are many options, enabling one to have a flatter layout with any | |
51 | separators you desire, or a more complicated list with differing | |
52 | formats for different levels. | |
53 | ||
54 | The "link_list" function uses a simple list of links -- good for a | |
55 | simple navbar. | |
56 | ||
57 | The "link_tree" function takes a set of nested links and makes the HTML | |
58 | for them -- good for making a table of contents, or a more complicated | |
59 | navbar. | |
60 | ||
61 | The "full_tree" function takes a list of paths and makes a full tree of | |
62 | all the pages and index-pages in those paths -- good for making a site | |
63 | map. | |
64 | ||
65 | The "breadcrumb_trail" function takes a url and makes a "breadcrumb | |
66 | trail" from it. | |
67 | ||
68 | The "nav_tree" function creates a set of nested links to be used as a | |
69 | multi-level navbar; one can give it a list of paths (as for full_tree) | |
70 | and it will only show the links related to the current URL. | |
71 | ||
72 | FUNCTIONS | |
73 | ||
74 | To export a function, add it to the 'use' call. | |
75 | ||
76 | use HTML::LinkList qw(link_list); | |
77 | ||
78 | To export all functions do: | |
79 | ||
80 | use HTML::LinkList ':all'; | |
81 | ||
82 | link_list | |
83 | ||
84 | $links = link_list( | |
85 | current_url=>$url, | |
86 | urls=>\@links_in_order, | |
87 | labels=>\%labels, | |
88 | descriptions=>\%desc, | |
89 | pre_desc=>' ', | |
90 | post_desc=>'', | |
91 | links_head=>'<ul>', | |
92 | links_foot=>'</ul>', | |
93 | pre_item=>'<li>', | |
94 | post_item=>'</li>' | |
95 | pre_active_item=>'<em>', | |
96 | post_active_item=>'</em>', | |
97 | item_sep=>"\n"); | |
98 | ||
99 | Generates a simple list of links, from list of urls (and optional | |
100 | labels) taking into account of the "current" URL. | |
101 | ||
102 | This provides a large number of options to customize the appearance of | |
103 | the list. The default setup is for a simple UL list, but setting the | |
104 | options can enable you to make it something other than a list | |
105 | altogether, or add in CSS styles or classes to make it look just like | |
106 | you want. | |
107 | ||
108 | Required: | |
109 | ||
110 | urls | |
111 | ||
112 | The urls in the order you want them displayed. If this list is empty, | |
113 | then nothing will be generated. | |
114 | ||
115 | Options: | |
116 | ||
117 | current_url | |
118 | ||
119 | The link to the current page. If one of the links equals this, then | |
120 | that is deemed to be the "active" link and is just displayed as a | |
121 | label rather than a link. | |
122 | ||
123 | descriptions | |
124 | ||
125 | Optional hash of descriptions, to put next to the links. The keys of | |
126 | this hash are the urls. | |
127 | ||
128 | hide_ext | |
129 | ||
130 | If a site is hiding link extensions (such as using MultiViews with | |
131 | Apache) you may wish to hide the extensions (while using the full | |
132 | URLs to check various things). (default: 0 (false)) | |
133 | ||
134 | item_sep | |
135 | ||
136 | String to put between items. | |
137 | ||
138 | labels | |
139 | ||
140 | A hash whose keys are links and whose values are labels. These are | |
141 | the labels for the links; if no label is given, then the last part of | |
142 | the link is used for the label, with some formatting. | |
143 | ||
144 | links_head | |
145 | ||
146 | String to begin the list with. | |
147 | ||
148 | links_foot | |
149 | ||
150 | String to end the list with. | |
151 | ||
152 | pre_desc | |
153 | ||
154 | String to prepend to each description. | |
155 | ||
156 | post_desc | |
157 | ||
158 | String to append to each description. | |
159 | ||
160 | pre_item | |
161 | ||
162 | String to prepend to each item. | |
163 | ||
164 | post_item | |
165 | ||
166 | String to append to each item. | |
167 | ||
168 | pre_active_item | |
169 | ||
170 | An additional string to put in front of each "active" item, after | |
171 | pre_item. The "active" item is the link which matches 'current_url'. | |
172 | ||
173 | pre_item_active | |
174 | ||
175 | INSTEAD of the "pre_item" string, use this string for active items | |
176 | ||
177 | post_active_item | |
178 | ||
179 | An additional string to append to each active item, before post_item. | |
180 | ||
181 | prefix_url | |
182 | ||
183 | A prefix to prepend to all the links. (default: empty string) | |
184 | ||
185 | link_tree | |
186 | ||
187 | $links = link_tree( | |
188 | current_url=>$url, | |
189 | link_tree=>\@list_of_lists, | |
190 | labels=>\%labels, | |
191 | descriptions=>\%desc, | |
192 | pre_desc=>' ', | |
193 | post_desc=>'', | |
194 | links_head=>'<ul>', | |
195 | links_foot=>'</ul>', | |
196 | subtree_head=>'<ul>', | |
197 | subtree_foot=>'</ul>', | |
198 | pre_item=>'<li>', | |
199 | post_item=>'</li>' | |
200 | pre_active_item=>'<em>', | |
201 | post_active_item=>'</em>', | |
202 | item_sep=>"\n", | |
203 | tree_sep=>"\n", | |
204 | formats=>\%formats); | |
205 | ||
206 | Generates nested lists of links from a list of lists of links. This is | |
207 | useful for things such as table-of-contents or site maps. | |
208 | ||
209 | By default, this will return UL lists, but this is highly configurable. | |
210 | ||
211 | Required: | |
212 | ||
213 | link_tree | |
214 | ||
215 | A list of lists of urls, in the order you want them displayed. If a | |
216 | url is not in this list, it will not be displayed. | |
217 | ||
218 | Options: | |
219 | ||
220 | current_url | |
221 | ||
222 | The link to the current page. If one of the links equals this, then | |
223 | that is deemed to be the "active" link and is just displayed as a | |
224 | label rather than a link. | |
225 | ||
226 | descriptions | |
227 | ||
228 | Optional hash of descriptions, to put next to the links. The keys of | |
229 | this hash are the urls. | |
230 | ||
231 | exclude_root_parent | |
232 | ||
233 | If this is true, then the "current_parent" display options are not | |
234 | used for the "root" ("/") path, it isn't counted as a "parent" of the | |
235 | current_url. | |
236 | ||
237 | formats | |
238 | ||
239 | A reference to a hash containing advanced format settings. For | |
240 | example: | |
241 | ||
242 | my %formats = ( | |
243 | # level 1 and onwards | |
244 | '1' => { | |
245 | tree_head=>"<ol>", | |
246 | tree_foot=>"</ol>\n", | |
247 | }, | |
248 | # level 2 and onwards | |
249 | '2' => { | |
250 | tree_head=>"<ul>", | |
251 | tree_foot=>"</ul>\n", | |
252 | }, | |
253 | # level 3 and onwards | |
254 | '3' => { | |
255 | pre_item=>'(', | |
256 | post_item=>')', | |
257 | item_sep=>",\n", | |
258 | tree_sep=>' -> ', | |
259 | tree_head=>"<br/>\n", | |
260 | tree_foot=>"", | |
261 | } | |
262 | ); | |
263 | ||
264 | The formats hash enables you to control the formatting on a per-level | |
265 | basis. Each key of the hash corresponds to a level-number; the | |
266 | sub-hashes contain format arguments which will apply from that level | |
267 | onwards. If an argument isn't given in the sub-hash, then it will | |
268 | fall back to the previous level (or to the default, if there is no | |
269 | setting for that format-argument for a previous level). | |
270 | ||
271 | The only difference between the names of the arguments in the | |
272 | sub-hash and in the global format arguments is that instead of | |
273 | 'subtree_head' and subtree_foot' it uses 'tree_head' and 'tree_foot'. | |
274 | ||
275 | hide_ext | |
276 | ||
277 | If a site is hiding link extensions (such as using MultiViews with | |
278 | Apache) you may wish to hide the extensions (while using the full | |
279 | URLs to check various things). (default: 0 (false)) | |
280 | ||
281 | item_sep | |
282 | ||
283 | The string to separate each item. | |
284 | ||
285 | labels | |
286 | ||
287 | A hash whose keys are links and whose values are labels. These are | |
288 | the labels for the links; if no label is given, then the last part of | |
289 | the link is used for the label, with some formatting. | |
290 | ||
291 | links_head | |
292 | ||
293 | The string to prepend the top-level tree with. (default: <ul>) | |
294 | ||
295 | links_foot | |
296 | ||
297 | The string to append to the top-level tree. (default: </ul>) | |
298 | ||
299 | pre_desc | |
300 | ||
301 | String to prepend to each description. | |
302 | ||
303 | post_desc | |
304 | ||
305 | String to append to each description. | |
306 | ||
307 | pre_item | |
308 | ||
309 | String to prepend to each item. (default: <li>) | |
310 | ||
311 | post_item | |
312 | ||
313 | String to append to each item. (default: </li>) | |
314 | ||
315 | pre_active_item | |
316 | ||
317 | An additional string to put in front of each "active" item, after | |
318 | pre_item. The "active" item is the link which matches 'current_url'. | |
319 | (default: <em>) | |
320 | ||
321 | pre_item_active | |
322 | ||
323 | INSTEAD of the "pre_item" string, use this string for active items | |
324 | ||
325 | post_active_item | |
326 | ||
327 | An additional string to append to each active item, before post_item. | |
328 | (default: </em>) | |
329 | ||
330 | pre_current_parent | |
331 | ||
332 | An additional string to put in front of a link which is a parent of | |
333 | the 'current_url' link, after pre_item. | |
334 | ||
335 | pre_item_current_parent | |
336 | ||
337 | INSTEAD of the "pre_item" string, use this for links which are | |
338 | parents of the 'current_url' link. | |
339 | ||
340 | post_current_parent | |
341 | ||
342 | An additional string to append to a link which is a parent of the | |
343 | 'current_url' link, before post_item. | |
344 | ||
345 | prefix_url | |
346 | ||
347 | A prefix to prepend to all the links. (default: empty string) | |
348 | ||
349 | subtree_head | |
350 | ||
351 | The string to prepend to lower-level trees. (default: <ul>) | |
352 | ||
353 | subtree_foot | |
354 | ||
355 | The string to append to lower-level trees. (default: </ul>) | |
356 | ||
357 | tree_sep | |
358 | ||
359 | The string to separate each tree. | |
360 | ||
361 | full_tree | |
362 | ||
363 | $links = full_tree( | |
364 | paths=>\@list_of_paths, | |
365 | labels=>\%labels, | |
366 | descriptions=>\%desc, | |
367 | hide=>$hide_regex, | |
368 | nohide=>$nohide_regex, | |
369 | start_depth=>0, | |
370 | end_depth=>0, | |
371 | top_level=>0, | |
372 | preserve_order=>0, | |
373 | preserve_paths=>0, | |
374 | ... | |
375 | ); | |
376 | ||
377 | Given a set of paths this will generate a tree of links in the style of | |
378 | link_tree. This will figure out all the intermediate paths and | |
379 | construct the nested structure for you, clustering parents and children | |
380 | together. | |
381 | ||
382 | The formatting options are as for "link_tree". | |
383 | ||
384 | Required: | |
385 | ||
386 | paths | |
387 | ||
388 | A reference to a list of paths: that is, URLs relative to the top of | |
389 | the site. | |
390 | ||
391 | For example, if the full URL is http://www.example.com/foo.html then | |
392 | the path is /foo.html | |
393 | ||
394 | If the full URL is http://www.example.com/~frednurk/foo.html then the | |
395 | path is /foo.html | |
396 | ||
397 | This does not require that every possible path be given; all the | |
398 | intermediate paths will be figured out from the list. | |
399 | ||
400 | Options: | |
401 | ||
402 | append_list | |
403 | ||
404 | Array of paths to append to the top-level links. They are used as-is, | |
405 | and are not part of the processing done to the "paths" list of paths. | |
406 | (see "prepend_list") | |
407 | ||
408 | descriptions | |
409 | ||
410 | Optional hash of descriptions, to put next to the links. The keys of | |
411 | this hash are the paths. | |
412 | ||
413 | end_depth | |
414 | ||
415 | End your tree at this depth. If zero, then go all the way. (see | |
416 | "start_depth") | |
417 | ||
418 | exclude_root_parent | |
419 | ||
420 | If this is true, then the "current_parent" display options are not | |
421 | used for the "root" ("/") path, it isn't counted as a "parent" of the | |
422 | current_url. | |
423 | ||
424 | hide | |
425 | ||
426 | If the path matches this string, don't include it in the tree. | |
427 | ||
428 | hide_ext | |
429 | ||
430 | If a site is hiding link extensions (such as using MultiViews with | |
431 | Apache) you may wish to hide the extensions (while using the full | |
432 | URLs to check various things). (default: 0 (false)) | |
433 | ||
434 | labels | |
435 | ||
436 | Hash containing replacement labels for one or more paths. If no label | |
437 | is given for '/' (the root path) then 'Home' will be used. | |
438 | ||
439 | last_subtree_head | |
440 | ||
441 | The string to prepend to the last lower-level tree. Only used if | |
442 | end_depth is not zero. | |
443 | ||
444 | last_subtree_foot | |
445 | ||
446 | The string to append to the last lower-level tree. Only used if | |
447 | end_depth is not zero. | |
448 | ||
449 | nohide | |
450 | ||
451 | If the path matches this string, it will be included even if it | |
452 | matches the 'hide' string. | |
453 | ||
454 | prefix_url | |
455 | ||
456 | A prefix to prepend to all the links. (default: empty string) | |
457 | ||
458 | prepend_list | |
459 | ||
460 | Array of paths to prepend to the top-level links. They are used | |
461 | as-is, and are not part of the processing done to the "paths" list of | |
462 | paths. | |
463 | ||
464 | preserve_order | |
465 | ||
466 | Preserve the ordering of the paths in the input list of paths; | |
467 | otherwise the links will be sorted alphabetically. Note that if | |
468 | preserve_order is true, the structure is at the whims of the order of | |
469 | the original list of paths, and so could end up odd-looking. | |
470 | (default: false) | |
471 | ||
472 | preserve_paths | |
473 | ||
474 | Do not extract intermediate paths or reorder the input list of paths. | |
475 | This speeds things up, but assumes that the input paths are complete | |
476 | and in good order. (default: false) | |
477 | ||
478 | start_depth | |
479 | ||
480 | Start your tree at this depth. Zero is the root, level 1 is the | |
481 | files/sub-folders in the root, and so on. (default: 0) | |
482 | ||
483 | top_level | |
484 | ||
485 | Decide which level is the "top" level. Useful when you set the | |
486 | start_depth to something greater than 1. | |
487 | ||
488 | breadcrumb_trail | |
489 | ||
490 | $links = breadcrumb_trail( | |
491 | current_url=>$url, | |
492 | labels=>\%labels, | |
493 | descriptions=>\%desc, | |
494 | links_head=>'<p>', | |
495 | links_foot=>"\n</p>", | |
496 | subtree_head=>'', | |
497 | subtree_foot=>"\n", | |
498 | pre_item=>'', | |
499 | post_item=>'', | |
500 | pre_active_item=>'<em>', | |
501 | post_active_item=>'</em>', | |
502 | item_sep=>"\n", | |
503 | tree_sep=>' > ', | |
504 | ... | |
505 | ); | |
506 | ||
507 | Given the current url, make a breadcrumb trail from it. By default, | |
508 | this is laid out with '>' separators, but it can be set up to give a | |
509 | nested set of UL lists (as for "full_tree"). | |
510 | ||
511 | The formatting options are as for "link_tree". | |
512 | ||
513 | Required: | |
514 | ||
515 | current_url | |
516 | ||
517 | The current url to be made into a breadcrumb-trail. | |
518 | ||
519 | Options: | |
520 | ||
521 | descriptions | |
522 | ||
523 | Optional hash of descriptions, to put next to the links. The keys of | |
524 | this hash are the urls. | |
525 | ||
526 | exclude_root_parent | |
527 | ||
528 | If this is true, then the "current_parent" display options are not | |
529 | used for the "root" ("/") path, it isn't counted as a "parent" of the | |
530 | current_url. | |
531 | ||
532 | hide_ext | |
533 | ||
534 | If a site is hiding link extensions (such as using MultiViews with | |
535 | Apache) you may wish to hide the extensions (while using the full | |
536 | URLs to check various things). (default: 0 (false)) | |
537 | ||
538 | labels | |
539 | ||
540 | Hash containing replacement labels for one or more URLS. If no label | |
541 | is given for '/' (the root path) then 'Home' will be used. | |
542 | ||
543 | nav_tree | |
544 | ||
545 | $links = nav_tree( | |
546 | paths=>\@list_of_paths, | |
547 | labels=>\%labels, | |
548 | current_url=>$url, | |
549 | hide=>$hide_regex, | |
550 | nohide=>$nohide_regex, | |
551 | preserve_order=>1, | |
552 | descriptions=>\%desc, | |
553 | ... | |
554 | ); | |
555 | ||
556 | This takes a list of links, and the current URL, and makes a nested | |
557 | navigation tree, consisting of (a) the top-level links (b) the links | |
558 | leading to the current URL (c) the links on the same level as the | |
559 | current URL, (d) the related links just above this level, depending on | |
560 | whether this is an index-page or a content page. | |
561 | ||
562 | Optionally one can hide links which match match the 'hide' option. | |
563 | ||
564 | The formatting options are as for "link_tree", with some additions. | |
565 | ||
566 | Required: | |
567 | ||
568 | current_url | |
569 | ||
570 | The link to the current page. If one of the links equals this, then | |
571 | that is deemed to be the "active" link and is just displayed as a | |
572 | label rather than a link. This is also used to determine which links | |
573 | to show and which ones to filter out. | |
574 | ||
575 | paths | |
576 | ||
577 | A reference to a list of paths: that is, URLs relative to the top of | |
578 | the site. | |
579 | ||
580 | For example, if the full URL is http://www.example.com/foo.html then | |
581 | the path is /foo.html | |
582 | ||
583 | This does not require that every possible path be given; all the | |
584 | intermediate paths will be figured out from the list. | |
585 | ||
586 | Options: | |
587 | ||
588 | append_list | |
589 | ||
590 | Array of paths to append to the top-level links. They are used as-is, | |
591 | and are not part of the processing done to the "paths" list of paths. | |
592 | (see "prepend_list") | |
593 | ||
594 | descriptions | |
595 | ||
596 | Optional hash of descriptions, to put next to the links. The keys of | |
597 | this hash are the paths. | |
598 | ||
599 | end_depth | |
600 | ||
601 | End your tree at this depth. If zero, then go all the way. By default | |
602 | this is set to the depth of the current_url. | |
603 | ||
604 | exclude_root_parent | |
605 | ||
606 | If this is true, then the "current_parent" display options are not | |
607 | used for the "root" ("/") path, it isn't counted as a "parent" of the | |
608 | current_url. | |
609 | ||
610 | hide | |
611 | ||
612 | If a path matches this string, don't include it in the tree. | |
613 | ||
614 | hide_ext | |
615 | ||
616 | If a site is hiding link extensions (such as using MultiViews with | |
617 | Apache) you may wish to hide the extensions (while using the full | |
618 | URLs to check various things). (default: 0 (false)) | |
619 | ||
620 | labels | |
621 | ||
622 | Hash containing replacement labels for one or more paths. If no label | |
623 | is given for '/' (the root path) then 'Home' will be used. | |
624 | ||
625 | last_subtree_head | |
626 | ||
627 | The string to prepend to the last lower-level tree. | |
628 | ||
629 | last_subtree_foot | |
630 | ||
631 | The string to append to the last lower-level tree. | |
632 | ||
633 | nohide | |
634 | ||
635 | If the path matches this string, it will be included even if it | |
636 | matches the 'hide' string. | |
637 | ||
638 | prefix_url | |
639 | ||
640 | A prefix to prepend to all the links. (default: empty string) | |
641 | ||
642 | prepend_list | |
643 | ||
644 | Array of paths to prepend to the top-level links. They are used | |
645 | as-is, and are not part of the processing done to the "paths" list of | |
646 | paths. | |
647 | ||
648 | preserve_order | |
649 | ||
650 | Preserve the ordering of the paths in the input list of paths; | |
651 | otherwise the links will be sorted alphabetically. (default: true) | |
652 | ||
653 | preserve_paths | |
654 | ||
655 | Do not extract intermediate paths or reorder the input list of paths. | |
656 | This speeds things up, but assumes that the input paths are complete | |
657 | and in good order. (default: false) | |
658 | ||
659 | start_depth | |
660 | ||
661 | Start your tree at this depth. Zero is the root, level 1 is the | |
662 | files/sub-folders in the root, and so on. (default: 1) | |
663 | ||
664 | top_level | |
665 | ||
666 | Decide which level is the "top" level. Useful when you set the | |
667 | start_depth to something greater than 1. | |
668 | ||
669 | Private Functions | |
670 | ||
671 | These functions cannot be exported. | |
672 | ||
673 | make_item | |
674 | ||
675 | $item = make_item( this_label=>$label, this_link=>$link, hide_ext=>0, | |
676 | current_url=>$url, current_parents=>\%current_parents, | |
677 | descriptions=>\%desc, format=>\%format, ); | |
678 | ||
679 | %format = ( pre_desc=>' ', post_desc=>'', pre_item=>'<li>', | |
680 | post_item=>'</li>' pre_active_item=>'<em>', post_active_item=>'</em>', | |
681 | pre_current_parent=>'<em>', post_current_parent=>'</em>', | |
682 | item_sep=>"\n"); ); | |
683 | ||
684 | Format a link item. | |
685 | ||
686 | See "link_list" for the formatting options. | |
687 | ||
688 | this_label | |
689 | ||
690 | The label of the required link. If there is no label, this uses the | |
691 | base-name of the last part of the link, capitalizing it and replacing | |
692 | underscores and dashes with spaces. | |
693 | ||
694 | this_link | |
695 | ||
696 | The URL of the required link. | |
697 | ||
698 | current_url | |
699 | ||
700 | The link to the current page. If one of the links equals this, then | |
701 | that is deemed to be the "active" link and is just displayed as a | |
702 | label rather than a link. | |
703 | ||
704 | current_parents | |
705 | ||
706 | URLs of the parents of the current item. | |
707 | ||
708 | descriptions | |
709 | ||
710 | Optional hash of descriptions, to put next to the links. The keys of | |
711 | this hash are the links (not the labels). | |
712 | ||
713 | defer_post_item | |
714 | ||
715 | Don't add the 'post_item' string if this is true. (needed for nested | |
716 | lists) (default: false) | |
717 | ||
718 | no_link | |
719 | ||
720 | Don't make a link for this, just a label. | |
721 | ||
722 | make_canonical | |
723 | ||
724 | my $new_url = make_canonical($url); | |
725 | ||
726 | Make a URL canonical; remove the 'index.*' and add on a needed '/' -- | |
727 | this assumes that directory names never have a '.' in them. | |
728 | ||
729 | get_index_path | |
730 | ||
731 | my $new_url = get_index_path($url); | |
732 | ||
733 | Get the "index" part of this path. That is, if this path is not for an | |
734 | index-page, then get the parent index-page path for this path. (Removes | |
735 | the trailing slash). | |
736 | ||
737 | get_index_parent | |
738 | ||
739 | my $new_url = get_index_parent($url); | |
740 | ||
741 | Get the parent of the "index" part of this path. (Removes the trailing | |
742 | slash). | |
743 | ||
744 | path_depth | |
745 | ||
746 | my $depth = path_depth($url); | |
747 | ||
748 | Calculate the "depth" of the given path. | |
749 | ||
750 | link_is_active | |
751 | ||
752 | if (link_is_active(this_link=>$link, current_url=>$url)) | |
753 | ... | |
754 | ||
755 | Check if the given link is "active", that is, if it matches the | |
756 | 'current_url'. | |
757 | ||
758 | traverse_lol | |
759 | ||
760 | $links = traverse_lol(\@list_of_lists, labels=>\%labels, | |
761 | tree_depth=>$depth current_format=>\%format, ... ); | |
762 | ||
763 | Traverse the list of lists (of urls) to produce a nested collection of | |
764 | links. | |
765 | ||
766 | This consumes the list_of_lists! | |
767 | ||
768 | extract_all_paths | |
769 | ||
770 | my @all_paths = extract_all_paths(paths=>\@paths, preserve_order=>0); | |
771 | ||
772 | Extract all possible paths out of a list of paths. Thus, if one has | |
773 | ||
774 | /foo/bar/baz.html | |
775 | ||
776 | then that would make | |
777 | ||
778 | / /foo/ /foo/bar/ /foo/bar/baz.html | |
779 | ||
780 | If 'preserve_order' is true, this preserves the ordering of the paths | |
781 | in the input list; otherwise the output paths are sorted | |
782 | alphabetically. | |
783 | ||
784 | extract_current_parents | |
785 | ||
786 | my %current_parents = extract_current_parents(current_url=>$url, | |
787 | exclude_root_parent=>0); | |
788 | ||
789 | Extract the "parent" paths of the current url | |
790 | ||
791 | /foo/bar/baz.html | |
792 | ||
793 | then that would make | |
794 | ||
795 | / /foo/ /foo/bar/ | |
796 | ||
797 | If 'exclude_root_parent' is true, then the '/' is excluded from the | |
798 | list of parents. | |
799 | ||
800 | build_lol | |
801 | ||
802 | my @lol = build_lol( | |
803 | paths=>\@paths, | |
804 | current_url=>$url, | |
805 | navbar_type=>'', | |
806 | ); | |
807 | ||
808 | Build a list of lists of paths, given a simple list of paths. Assumes | |
809 | that this list has already been filtered. | |
810 | ||
811 | paths | |
812 | ||
813 | Reference to list of paths; this is consumed. | |
814 | ||
815 | filter_out_paths | |
816 | ||
817 | my @filtered_paths = filter_out_paths( | |
818 | paths=>\@paths, | |
819 | current_url=>$url, | |
820 | hide=>$hide, | |
821 | nohide=>$nohide, | |
822 | start_depth=>$start_depth, | |
823 | end_depth=>$end_depth, | |
824 | top_level=>$top_level, | |
825 | navbar_type=>'', | |
826 | ); | |
827 | ||
828 | Filter out the paths we don't want from our list of paths. Returns a | |
829 | list of the paths we want. | |
830 | ||
831 | make_default_format | |
832 | ||
833 | my %default_format = make_default_format(%args); | |
834 | ||
835 | Make the default format hash from the args. Returns a hash of format | |
836 | options. | |
837 | ||
838 | make_extra_formats | |
839 | ||
840 | my %formats = make_extra_formats(%args); | |
841 | ||
842 | Transforms the subtree_head and subtree_foot into the "formats" method | |
843 | of formatting. Returns a hash of hashes of format options. | |
844 | ||
845 | REQUIRES | |
846 | ||
847 | Test::More | |
848 | ||
849 | INSTALLATION | |
850 | ||
851 | To install this module, run the following commands: | |
852 | ||
853 | perl Build.PL | |
854 | ./Build | |
855 | ./Build test | |
856 | ./Build install | |
857 | ||
858 | Or, if you're on a platform (like DOS or Windows) that doesn't like the | |
859 | "./" notation, you can do this: | |
860 | ||
861 | perl Build.PL | |
862 | perl Build | |
863 | perl Build test | |
864 | perl Build install | |
865 | ||
866 | In order to install somewhere other than the default, such as in a | |
867 | directory under your home directory, like "/home/fred/perl" go | |
868 | ||
869 | perl Build.PL --install_base /home/fred/perl | |
870 | ||
871 | as the first step instead. | |
872 | ||
873 | This will install the files underneath /home/fred/perl. | |
874 | ||
875 | You will then need to make sure that you alter the PERL5LIB variable to | |
876 | find the modules. | |
877 | ||
878 | Therefore you will need to change the PERL5LIB variable to add | |
879 | /home/fred/perl/lib | |
880 | ||
881 | PERL5LIB=/home/fred/perl/lib:${PERL5LIB} | |
882 | ||
883 | SEE ALSO | |
884 | ||
885 | perl(1). | |
886 | ||
887 | BUGS | |
888 | ||
889 | Please report any bugs or feature requests to the author. | |
890 | ||
891 | AUTHOR | |
892 | ||
893 | Kathryn Andersen (RUBYKAT) | |
894 | perlkat AT katspace dot com | |
895 | http://www.katspace.com/tools/html_linklist/ | |
896 | ||
897 | COPYRIGHT AND LICENCE | |
898 | ||
899 | Copyright (c) 2006 by Kathryn Andersen | |
900 | ||
901 | This program is free software; you can redistribute it and/or modify it | |
902 | under the same terms as Perl itself. | |
903 |
0 | # NAME | |
1 | ||
2 | HTML::LinkList - Create a 'smart' list of HTML links. | |
3 | ||
4 | # VERSION | |
5 | ||
6 | version 0.1701 | |
7 | ||
8 | # SYNOPSIS | |
9 | ||
10 | use HTML::LinkList qw(link_list); | |
11 | ||
12 | # default formatting | |
13 | my $html_links = link_list(current_url=>$url, | |
14 | urls=>\@links_in_order, | |
15 | labels=>\%labels, | |
16 | descriptions=>\%desc); | |
17 | ||
18 | # paragraph with ' :: ' separators | |
19 | my $html_links = link_list(current_url=>$url, | |
20 | urls=>\@links_in_order, | |
21 | labels=>\%labels, | |
22 | descriptions=>\%desc, | |
23 | links_head=>'<p>', | |
24 | links_foot=>'</p>', | |
25 | pre_item=>'', | |
26 | post_item=>'' | |
27 | pre_active_item=>'<em>', | |
28 | post_active_item=>'</em>', | |
29 | item_sep=>" :: "); | |
30 | ||
31 | # multi-level list | |
32 | my $html_links = link_tree( | |
33 | current_url=>$url, | |
34 | link_tree=>\@list_of_lists, | |
35 | labels=>\%labels, | |
36 | descriptions=>\%desc); | |
37 | ||
38 | # DESCRIPTION | |
39 | ||
40 | This module contains a number of functions for taking sets of URLs and | |
41 | labels and creating suitably formatted HTML. These links are "smart" | |
42 | because, if given the url of the current page, if any of the links in | |
43 | the list equal it, that item in the list will be formatted as a special | |
44 | label, not as a link; this is a Good Thing, since the user would be | |
45 | confused by clicking on a link back to the current page. | |
46 | ||
47 | While many website systems have plugins for "smart" navbars, they are | |
48 | specialized for that system only, and can't be reused elsewhere, forcing | |
49 | people to reinvent the wheel. I hereby present one wheel, free to be | |
50 | reused by anybody; just the simple functions, a backend, which can be | |
51 | plugged into whatever system you want. | |
52 | ||
53 | The default format for the HTML is to make an unordered list, but there | |
54 | are many options, enabling one to have a flatter layout with any | |
55 | separators you desire, or a more complicated list with differing | |
56 | formats for different levels. | |
57 | ||
58 | The "link\_list" function uses a simple list of links -- good for a | |
59 | simple navbar. | |
60 | ||
61 | The "link\_tree" function takes a set of nested links and makes the HTML | |
62 | for them -- good for making a table of contents, or a more complicated | |
63 | navbar. | |
64 | ||
65 | The "full\_tree" function takes a list of paths and makes a full tree of | |
66 | all the pages and index-pages in those paths -- good for making a site | |
67 | map. | |
68 | ||
69 | The "breadcrumb\_trail" function takes a url and makes a "breadcrumb trail" | |
70 | from it. | |
71 | ||
72 | The "nav\_tree" function creates a set of nested links to be | |
73 | used as a multi-level navbar; one can give it a list of paths | |
74 | (as for full\_tree) and it will only show the links related | |
75 | to the current URL. | |
76 | ||
77 | # FUNCTIONS | |
78 | ||
79 | To export a function, add it to the 'use' call. | |
80 | ||
81 | use HTML::LinkList qw(link_list); | |
82 | ||
83 | To export all functions do: | |
84 | ||
85 | use HTML::LinkList ':all'; | |
86 | ||
87 | ## link\_list | |
88 | ||
89 | $links = link_list( | |
90 | current_url=>$url, | |
91 | urls=>\@links_in_order, | |
92 | labels=>\%labels, | |
93 | descriptions=>\%desc, | |
94 | pre_desc=>' ', | |
95 | post_desc=>'', | |
96 | links_head=>'<ul>', | |
97 | links_foot=>'</ul>', | |
98 | pre_item=>'<li>', | |
99 | post_item=>'</li>' | |
100 | pre_active_item=>'<em>', | |
101 | post_active_item=>'</em>', | |
102 | item_sep=>"\n"); | |
103 | ||
104 | Generates a simple list of links, from list of urls | |
105 | (and optional labels) taking into account of the "current" URL. | |
106 | ||
107 | This provides a large number of options to customize the appearance | |
108 | of the list. The default setup is for a simple UL list, but setting | |
109 | the options can enable you to make it something other than a list | |
110 | altogether, or add in CSS styles or classes to make it look just | |
111 | like you want. | |
112 | ||
113 | Required: | |
114 | ||
115 | - urls | |
116 | ||
117 | The urls in the order you want them displayed. If this list | |
118 | is empty, then nothing will be generated. | |
119 | ||
120 | Options: | |
121 | ||
122 | - current\_url | |
123 | ||
124 | The link to the current page. If one of the links equals this, | |
125 | then that is deemed to be the "active" link and is just displayed | |
126 | as a label rather than a link. | |
127 | ||
128 | - descriptions | |
129 | ||
130 | Optional hash of descriptions, to put next to the links. The keys | |
131 | of this hash are the urls. | |
132 | ||
133 | - hide\_ext | |
134 | ||
135 | If a site is hiding link extensions (such as using MultiViews with | |
136 | Apache) you may wish to hide the extensions (while using the full URLs | |
137 | to check various things). (default: 0 (false)) | |
138 | ||
139 | - item\_sep | |
140 | ||
141 | String to put between items. | |
142 | ||
143 | - labels | |
144 | ||
145 | A hash whose keys are links and whose values are labels. | |
146 | These are the labels for the links; if no label | |
147 | is given, then the last part of the link is used | |
148 | for the label, with some formatting. | |
149 | ||
150 | - links\_head | |
151 | ||
152 | String to begin the list with. | |
153 | ||
154 | - links\_foot | |
155 | ||
156 | String to end the list with. | |
157 | ||
158 | - pre\_desc | |
159 | ||
160 | String to prepend to each description. | |
161 | ||
162 | - post\_desc | |
163 | ||
164 | String to append to each description. | |
165 | ||
166 | - pre\_item | |
167 | ||
168 | String to prepend to each item. | |
169 | ||
170 | - post\_item | |
171 | ||
172 | String to append to each item. | |
173 | ||
174 | - pre\_active\_item | |
175 | ||
176 | An additional string to put in front of each "active" item, after pre\_item. | |
177 | The "active" item is the link which matches 'current\_url'. | |
178 | ||
179 | - pre\_item\_active | |
180 | ||
181 | INSTEAD of the "pre\_item" string, use this string for active items | |
182 | ||
183 | - post\_active\_item | |
184 | ||
185 | An additional string to append to each active item, before post\_item. | |
186 | ||
187 | - prefix\_url | |
188 | ||
189 | A prefix to prepend to all the links. (default: empty string) | |
190 | ||
191 | ## link\_tree | |
192 | ||
193 | $links = link_tree( | |
194 | current_url=>$url, | |
195 | link_tree=>\@list_of_lists, | |
196 | labels=>\%labels, | |
197 | descriptions=>\%desc, | |
198 | pre_desc=>' ', | |
199 | post_desc=>'', | |
200 | links_head=>'<ul>', | |
201 | links_foot=>'</ul>', | |
202 | subtree_head=>'<ul>', | |
203 | subtree_foot=>'</ul>', | |
204 | pre_item=>'<li>', | |
205 | post_item=>'</li>' | |
206 | pre_active_item=>'<em>', | |
207 | post_active_item=>'</em>', | |
208 | item_sep=>"\n", | |
209 | tree_sep=>"\n", | |
210 | formats=>\%formats); | |
211 | ||
212 | Generates nested lists of links from a list of lists of links. | |
213 | This is useful for things such as table-of-contents or | |
214 | site maps. | |
215 | ||
216 | By default, this will return UL lists, but this is highly | |
217 | configurable. | |
218 | ||
219 | Required: | |
220 | ||
221 | - link\_tree | |
222 | ||
223 | A list of lists of urls, in the order you want them displayed. | |
224 | If a url is not in this list, it will not be displayed. | |
225 | ||
226 | Options: | |
227 | ||
228 | - current\_url | |
229 | ||
230 | The link to the current page. If one of the links equals this, | |
231 | then that is deemed to be the "active" link and is just displayed | |
232 | as a label rather than a link. | |
233 | ||
234 | - descriptions | |
235 | ||
236 | Optional hash of descriptions, to put next to the links. The keys | |
237 | of this hash are the urls. | |
238 | ||
239 | - exclude\_root\_parent | |
240 | ||
241 | If this is true, then the "current\_parent" display options are | |
242 | not used for the "root" ("/") path, it isn't counted as a "parent" | |
243 | of the current\_url. | |
244 | ||
245 | - formats | |
246 | ||
247 | A reference to a hash containing advanced format settings. For example: | |
248 | ||
249 | my %formats = ( | |
250 | # level 1 and onwards | |
251 | '1' => { | |
252 | tree_head=>"<ol>", | |
253 | tree_foot=>"</ol>\n", | |
254 | }, | |
255 | # level 2 and onwards | |
256 | '2' => { | |
257 | tree_head=>"<ul>", | |
258 | tree_foot=>"</ul>\n", | |
259 | }, | |
260 | # level 3 and onwards | |
261 | '3' => { | |
262 | pre_item=>'(', | |
263 | post_item=>')', | |
264 | item_sep=>",\n", | |
265 | tree_sep=>' -> ', | |
266 | tree_head=>"<br/>\n", | |
267 | tree_foot=>"", | |
268 | } | |
269 | ); | |
270 | ||
271 | The formats hash enables you to control the formatting on a per-level basis. | |
272 | Each key of the hash corresponds to a level-number; the sub-hashes contain | |
273 | format arguments which will apply from that level onwards. If an argument | |
274 | isn't given in the sub-hash, then it will fall back to the previous level | |
275 | (or to the default, if there is no setting for that format-argument | |
276 | for a previous level). | |
277 | ||
278 | The only difference between the names of the arguments in the sub-hash and | |
279 | in the global format arguments is that instead of 'subtree\_head' and subtree\_foot' | |
280 | it uses 'tree\_head' and 'tree\_foot'. | |
281 | ||
282 | - hide\_ext | |
283 | ||
284 | If a site is hiding link extensions (such as using MultiViews with | |
285 | Apache) you may wish to hide the extensions (while using the full URLs | |
286 | to check various things). (default: 0 (false)) | |
287 | ||
288 | - item\_sep | |
289 | ||
290 | The string to separate each item. | |
291 | ||
292 | - labels | |
293 | ||
294 | A hash whose keys are links and whose values are labels. | |
295 | These are the labels for the links; if no label | |
296 | is given, then the last part of the link is used | |
297 | for the label, with some formatting. | |
298 | ||
299 | - links\_head | |
300 | ||
301 | The string to prepend the top-level tree with. | |
302 | (default: <ul>) | |
303 | ||
304 | - links\_foot | |
305 | ||
306 | The string to append to the top-level tree. | |
307 | (default: </ul>) | |
308 | ||
309 | - pre\_desc | |
310 | ||
311 | String to prepend to each description. | |
312 | ||
313 | - post\_desc | |
314 | ||
315 | String to append to each description. | |
316 | ||
317 | - pre\_item | |
318 | ||
319 | String to prepend to each item. | |
320 | (default: <li>) | |
321 | ||
322 | - post\_item | |
323 | ||
324 | String to append to each item. | |
325 | (default: </li>) | |
326 | ||
327 | - pre\_active\_item | |
328 | ||
329 | An additional string to put in front of each "active" item, after pre\_item. | |
330 | The "active" item is the link which matches 'current\_url'. | |
331 | (default: <em>) | |
332 | ||
333 | - pre\_item\_active | |
334 | ||
335 | INSTEAD of the "pre\_item" string, use this string for active items | |
336 | ||
337 | - post\_active\_item | |
338 | ||
339 | An additional string to append to each active item, before post\_item. | |
340 | (default: </em>) | |
341 | ||
342 | - pre\_current\_parent | |
343 | ||
344 | An additional string to put in front of a link which is a parent | |
345 | of the 'current\_url' link, after pre\_item. | |
346 | ||
347 | - pre\_item\_current\_parent | |
348 | ||
349 | INSTEAD of the "pre\_item" string, use this for links which are parents | |
350 | of the 'current\_url' link. | |
351 | ||
352 | - post\_current\_parent | |
353 | ||
354 | An additional string to append to a link which is a parent | |
355 | of the 'current\_url' link, before post\_item. | |
356 | ||
357 | - prefix\_url | |
358 | ||
359 | A prefix to prepend to all the links. (default: empty string) | |
360 | ||
361 | - subtree\_head | |
362 | ||
363 | The string to prepend to lower-level trees. | |
364 | (default: <ul>) | |
365 | ||
366 | - subtree\_foot | |
367 | ||
368 | The string to append to lower-level trees. | |
369 | (default: </ul>) | |
370 | ||
371 | - tree\_sep | |
372 | ||
373 | The string to separate each tree. | |
374 | ||
375 | ## full\_tree | |
376 | ||
377 | $links = full_tree( | |
378 | paths=>\@list_of_paths, | |
379 | labels=>\%labels, | |
380 | descriptions=>\%desc, | |
381 | hide=>$hide_regex, | |
382 | nohide=>$nohide_regex, | |
383 | start_depth=>0, | |
384 | end_depth=>0, | |
385 | top_level=>0, | |
386 | preserve_order=>0, | |
387 | preserve_paths=>0, | |
388 | ... | |
389 | ); | |
390 | ||
391 | Given a set of paths this will generate a tree of links in the style of | |
392 | _link\_tree_. This will figure out all the intermediate paths and construct | |
393 | the nested structure for you, clustering parents and children together. | |
394 | ||
395 | The formatting options are as for ["link\_tree"](#link_tree). | |
396 | ||
397 | Required: | |
398 | ||
399 | - paths | |
400 | ||
401 | A reference to a list of paths: that is, URLs relative to the top | |
402 | of the site. | |
403 | ||
404 | For example, if the full URL is http://www.example.com/foo.html | |
405 | then the path is /foo.html | |
406 | ||
407 | If the full URL is http://www.example.com/~frednurk/foo.html | |
408 | then the path is /foo.html | |
409 | ||
410 | This does not require that every possible path be given; all the intermediate | |
411 | paths will be figured out from the list. | |
412 | ||
413 | Options: | |
414 | ||
415 | - append\_list | |
416 | ||
417 | Array of paths to append to the top-level links. They are used | |
418 | as-is, and are not part of the processing done to the "paths" list | |
419 | of paths. (see ["prepend\_list"](#prepend_list)) | |
420 | ||
421 | - descriptions | |
422 | ||
423 | Optional hash of descriptions, to put next to the links. The keys | |
424 | of this hash are the paths. | |
425 | ||
426 | - end\_depth | |
427 | ||
428 | End your tree at this depth. If zero, then go all the way. | |
429 | (see ["start\_depth"](#start_depth)) | |
430 | ||
431 | - exclude\_root\_parent | |
432 | ||
433 | If this is true, then the "current\_parent" display options are | |
434 | not used for the "root" ("/") path, it isn't counted as a "parent" | |
435 | of the current\_url. | |
436 | ||
437 | - hide | |
438 | ||
439 | If the path matches this string, don't include it in the tree. | |
440 | ||
441 | - hide\_ext | |
442 | ||
443 | If a site is hiding link extensions (such as using MultiViews with | |
444 | Apache) you may wish to hide the extensions (while using the full URLs | |
445 | to check various things). (default: 0 (false)) | |
446 | ||
447 | - labels | |
448 | ||
449 | Hash containing replacement labels for one or more paths. | |
450 | If no label is given for '/' (the root path) then 'Home' will | |
451 | be used. | |
452 | ||
453 | - last\_subtree\_head | |
454 | ||
455 | The string to prepend to the last lower-level tree. | |
456 | Only used if end\_depth is not zero. | |
457 | ||
458 | - last\_subtree\_foot | |
459 | ||
460 | The string to append to the last lower-level tree. | |
461 | Only used if end\_depth is not zero. | |
462 | ||
463 | - nohide | |
464 | ||
465 | If the path matches this string, it will be included even if it matches | |
466 | the 'hide' string. | |
467 | ||
468 | - prefix\_url | |
469 | ||
470 | A prefix to prepend to all the links. (default: empty string) | |
471 | ||
472 | - prepend\_list | |
473 | ||
474 | Array of paths to prepend to the top-level links. They are used | |
475 | as-is, and are not part of the processing done to the "paths" list | |
476 | of paths. | |
477 | ||
478 | - preserve\_order | |
479 | ||
480 | Preserve the ordering of the paths in the input list of paths; | |
481 | otherwise the links will be sorted alphabetically. Note that if | |
482 | preserve\_order is true, the structure is at the whims of the order | |
483 | of the original list of paths, and so could end up odd-looking. | |
484 | (default: false) | |
485 | ||
486 | - preserve\_paths | |
487 | ||
488 | Do not extract intermediate paths or reorder the input list of paths. | |
489 | This speeds things up, but assumes that the input paths are complete | |
490 | and in good order. | |
491 | (default: false) | |
492 | ||
493 | - start\_depth | |
494 | ||
495 | Start your tree at this depth. Zero is the root, level 1 is the | |
496 | files/sub-folders in the root, and so on. | |
497 | (default: 0) | |
498 | ||
499 | - top\_level | |
500 | ||
501 | Decide which level is the "top" level. Useful when you | |
502 | set the start\_depth to something greater than 1. | |
503 | ||
504 | ## breadcrumb\_trail | |
505 | ||
506 | $links = breadcrumb_trail( | |
507 | current_url=>$url, | |
508 | labels=>\%labels, | |
509 | descriptions=>\%desc, | |
510 | links_head=>'<p>', | |
511 | links_foot=>"\n</p>", | |
512 | subtree_head=>'', | |
513 | subtree_foot=>"\n", | |
514 | pre_item=>'', | |
515 | post_item=>'', | |
516 | pre_active_item=>'<em>', | |
517 | post_active_item=>'</em>', | |
518 | item_sep=>"\n", | |
519 | tree_sep=>' > ', | |
520 | ... | |
521 | ); | |
522 | ||
523 | Given the current url, make a breadcrumb trail from it. | |
524 | By default, this is laid out with '>' separators, but it can | |
525 | be set up to give a nested set of UL lists (as for ["full\_tree"](#full_tree)). | |
526 | ||
527 | The formatting options are as for ["link\_tree"](#link_tree). | |
528 | ||
529 | Required: | |
530 | ||
531 | - current\_url | |
532 | ||
533 | The current url to be made into a breadcrumb-trail. | |
534 | ||
535 | Options: | |
536 | ||
537 | - descriptions | |
538 | ||
539 | Optional hash of descriptions, to put next to the links. The keys | |
540 | of this hash are the urls. | |
541 | ||
542 | - exclude\_root\_parent | |
543 | ||
544 | If this is true, then the "current\_parent" display options are | |
545 | not used for the "root" ("/") path, it isn't counted as a "parent" | |
546 | of the current\_url. | |
547 | ||
548 | - hide\_ext | |
549 | ||
550 | If a site is hiding link extensions (such as using MultiViews with | |
551 | Apache) you may wish to hide the extensions (while using the full URLs | |
552 | to check various things). (default: 0 (false)) | |
553 | ||
554 | - labels | |
555 | ||
556 | Hash containing replacement labels for one or more URLS. | |
557 | If no label is given for '/' (the root path) then 'Home' will | |
558 | be used. | |
559 | ||
560 | ## nav\_tree | |
561 | ||
562 | $links = nav_tree( | |
563 | paths=>\@list_of_paths, | |
564 | labels=>\%labels, | |
565 | current_url=>$url, | |
566 | hide=>$hide_regex, | |
567 | nohide=>$nohide_regex, | |
568 | preserve_order=>1, | |
569 | descriptions=>\%desc, | |
570 | ... | |
571 | ); | |
572 | ||
573 | This takes a list of links, and the current URL, and makes a nested navigation | |
574 | tree, consisting of (a) the top-level links (b) the links leading to the | |
575 | current URL (c) the links on the same level as the current URL, | |
576 | (d) the related links just above this level, depending on whether | |
577 | this is an index-page or a content page. | |
578 | ||
579 | Optionally one can hide links which match match the 'hide' option. | |
580 | ||
581 | The formatting options are as for ["link\_tree"](#link_tree), with some additions. | |
582 | ||
583 | Required: | |
584 | ||
585 | - current\_url | |
586 | ||
587 | The link to the current page. If one of the links equals this, then that | |
588 | is deemed to be the "active" link and is just displayed as a label rather | |
589 | than a link. This is also used to determine which links to show and which | |
590 | ones to filter out. | |
591 | ||
592 | - paths | |
593 | ||
594 | A reference to a list of paths: that is, URLs relative to the top | |
595 | of the site. | |
596 | ||
597 | For example, if the full URL is http://www.example.com/foo.html | |
598 | then the path is /foo.html | |
599 | ||
600 | This does not require that every possible path be given; all the intermediate | |
601 | paths will be figured out from the list. | |
602 | ||
603 | Options: | |
604 | ||
605 | - append\_list | |
606 | ||
607 | Array of paths to append to the top-level links. They are used | |
608 | as-is, and are not part of the processing done to the "paths" list | |
609 | of paths. (see ["prepend\_list"](#prepend_list)) | |
610 | ||
611 | - descriptions | |
612 | ||
613 | Optional hash of descriptions, to put next to the links. The keys | |
614 | of this hash are the paths. | |
615 | ||
616 | - end\_depth | |
617 | ||
618 | End your tree at this depth. If zero, then go all the way. | |
619 | By default this is set to the depth of the current\_url. | |
620 | ||
621 | - exclude\_root\_parent | |
622 | ||
623 | If this is true, then the "current\_parent" display options are | |
624 | not used for the "root" ("/") path, it isn't counted as a "parent" | |
625 | of the current\_url. | |
626 | ||
627 | - hide | |
628 | ||
629 | If a path matches this string, don't include it in the tree. | |
630 | ||
631 | - hide\_ext | |
632 | ||
633 | If a site is hiding link extensions (such as using MultiViews with | |
634 | Apache) you may wish to hide the extensions (while using the full URLs | |
635 | to check various things). (default: 0 (false)) | |
636 | ||
637 | - labels | |
638 | ||
639 | Hash containing replacement labels for one or more paths. | |
640 | If no label is given for '/' (the root path) then 'Home' will | |
641 | be used. | |
642 | ||
643 | - last\_subtree\_head | |
644 | ||
645 | The string to prepend to the last lower-level tree. | |
646 | ||
647 | - last\_subtree\_foot | |
648 | ||
649 | The string to append to the last lower-level tree. | |
650 | ||
651 | - nohide | |
652 | ||
653 | If the path matches this string, it will be included even if it matches | |
654 | the 'hide' string. | |
655 | ||
656 | - prefix\_url | |
657 | ||
658 | A prefix to prepend to all the links. (default: empty string) | |
659 | ||
660 | - prepend\_list | |
661 | ||
662 | Array of paths to prepend to the top-level links. They are used | |
663 | as-is, and are not part of the processing done to the "paths" list | |
664 | of paths. | |
665 | ||
666 | - preserve\_order | |
667 | ||
668 | Preserve the ordering of the paths in the input list of paths; | |
669 | otherwise the links will be sorted alphabetically. | |
670 | (default: true) | |
671 | ||
672 | - preserve\_paths | |
673 | ||
674 | Do not extract intermediate paths or reorder the input list of paths. | |
675 | This speeds things up, but assumes that the input paths are complete | |
676 | and in good order. | |
677 | (default: false) | |
678 | ||
679 | - start\_depth | |
680 | ||
681 | Start your tree at this depth. Zero is the root, level 1 is the | |
682 | files/sub-folders in the root, and so on. | |
683 | (default: 1) | |
684 | ||
685 | - top\_level | |
686 | ||
687 | Decide which level is the "top" level. Useful when you | |
688 | set the start\_depth to something greater than 1. | |
689 | ||
690 | # Private Functions | |
691 | ||
692 | These functions cannot be exported. | |
693 | ||
694 | ## make\_item | |
695 | ||
696 | $item = make\_item( | |
697 | this\_label=>$label, | |
698 | this\_link=>$link, | |
699 | hide\_ext=>0, | |
700 | current\_url=>$url, | |
701 | current\_parents=>\\%current\_parents, | |
702 | descriptions=>\\%desc, | |
703 | format=>\\%format, | |
704 | ); | |
705 | ||
706 | %format = ( | |
707 | pre\_desc=>' ', | |
708 | post\_desc=>'', | |
709 | pre\_item=>'<li>', | |
710 | post\_item=>'</li>' | |
711 | pre\_active\_item=>'<em>', | |
712 | post\_active\_item=>'</em>', | |
713 | pre\_current\_parent=>'<em>', | |
714 | post\_current\_parent=>'</em>', | |
715 | item\_sep=>"\\n"); | |
716 | ); | |
717 | ||
718 | Format a link item. | |
719 | ||
720 | See ["link\_list"](#link_list) for the formatting options. | |
721 | ||
722 | - this\_label | |
723 | ||
724 | The label of the required link. If there is no label, | |
725 | this uses the base-name of the last part of the link, | |
726 | capitalizing it and replacing underscores and dashes with spaces. | |
727 | ||
728 | - this\_link | |
729 | ||
730 | The URL of the required link. | |
731 | ||
732 | - current\_url | |
733 | ||
734 | The link to the current page. If one of the links equals this, | |
735 | then that is deemed to be the "active" link and is just displayed | |
736 | as a label rather than a link. | |
737 | ||
738 | - current\_parents | |
739 | ||
740 | URLs of the parents of the current item. | |
741 | ||
742 | - descriptions | |
743 | ||
744 | Optional hash of descriptions, to put next to the links. The keys | |
745 | of this hash are the links (not the labels). | |
746 | ||
747 | - defer\_post\_item | |
748 | ||
749 | Don't add the 'post\_item' string if this is true. | |
750 | (needed for nested lists) | |
751 | (default: false) | |
752 | ||
753 | - no\_link | |
754 | ||
755 | Don't make a link for this, just a label. | |
756 | ||
757 | ## make\_canonical | |
758 | ||
759 | my $new\_url = make\_canonical($url); | |
760 | ||
761 | Make a URL canonical; remove the 'index.\*' and add on a needed | |
762 | '/' -- this assumes that directory names never have a '.' in them. | |
763 | ||
764 | ## get\_index\_path | |
765 | ||
766 | my $new\_url = get\_index\_path($url); | |
767 | ||
768 | Get the "index" part of this path. That is, if this path | |
769 | is not for an index-page, then get the parent index-page | |
770 | path for this path. | |
771 | (Removes the trailing slash). | |
772 | ||
773 | ## get\_index\_parent | |
774 | ||
775 | my $new\_url = get\_index\_parent($url); | |
776 | ||
777 | Get the parent of the "index" part of this path. | |
778 | (Removes the trailing slash). | |
779 | ||
780 | ## path\_depth | |
781 | ||
782 | my $depth = path\_depth($url); | |
783 | ||
784 | Calculate the "depth" of the given path. | |
785 | ||
786 | ## link\_is\_active | |
787 | ||
788 | if (link_is_active(this_link=>$link, current_url=>$url)) | |
789 | ... | |
790 | ||
791 | Check if the given link is "active", that is, if it | |
792 | matches the 'current\_url'. | |
793 | ||
794 | ## traverse\_lol | |
795 | ||
796 | $links = traverse\_lol(\\@list\_of\_lists, | |
797 | labels=>\\%labels, | |
798 | tree\_depth=>$depth | |
799 | current\_format=>\\%format, | |
800 | ... | |
801 | ); | |
802 | ||
803 | Traverse the list of lists (of urls) to produce | |
804 | a nested collection of links. | |
805 | ||
806 | This consumes the list\_of\_lists! | |
807 | ||
808 | ## extract\_all\_paths | |
809 | ||
810 | my @all\_paths = extract\_all\_paths(paths=>\\@paths, | |
811 | preserve\_order=>0); | |
812 | ||
813 | Extract all possible paths out of a list of paths. | |
814 | Thus, if one has | |
815 | ||
816 | /foo/bar/baz.html | |
817 | ||
818 | then that would make | |
819 | ||
820 | / | |
821 | /foo/ | |
822 | /foo/bar/ | |
823 | /foo/bar/baz.html | |
824 | ||
825 | If 'preserve\_order' is true, this preserves the ordering of | |
826 | the paths in the input list; otherwise the output paths | |
827 | are sorted alphabetically. | |
828 | ||
829 | ## extract\_current\_parents | |
830 | ||
831 | my %current_parents = extract_current_parents(current_url=>$url, | |
832 | exclude_root_parent=>0); | |
833 | ||
834 | Extract the "parent" paths of the current url | |
835 | ||
836 | /foo/bar/baz.html | |
837 | ||
838 | then that would make | |
839 | ||
840 | / | |
841 | /foo/ | |
842 | /foo/bar/ | |
843 | ||
844 | If 'exclude\_root\_parent' is true, then the '/' is excluded from the | |
845 | list of parents. | |
846 | ||
847 | ## build\_lol | |
848 | ||
849 | my @lol = build_lol( | |
850 | paths=>\@paths, | |
851 | current_url=>$url, | |
852 | navbar_type=>'', | |
853 | ); | |
854 | ||
855 | Build a list of lists of paths, given a simple list of paths. | |
856 | Assumes that this list has already been filtered. | |
857 | ||
858 | - paths | |
859 | ||
860 | Reference to list of paths; this is consumed. | |
861 | ||
862 | ## filter\_out\_paths | |
863 | ||
864 | my @filtered_paths = filter_out_paths( | |
865 | paths=>\@paths, | |
866 | current_url=>$url, | |
867 | hide=>$hide, | |
868 | nohide=>$nohide, | |
869 | start_depth=>$start_depth, | |
870 | end_depth=>$end_depth, | |
871 | top_level=>$top_level, | |
872 | navbar_type=>'', | |
873 | ); | |
874 | ||
875 | Filter out the paths we don't want from our list of paths. | |
876 | Returns a list of the paths we want. | |
877 | ||
878 | ## make\_default\_format | |
879 | ||
880 | my %default_format = make_default_format(%args); | |
881 | ||
882 | Make the default format hash from the args. | |
883 | Returns a hash of format options. | |
884 | ||
885 | ## make\_extra\_formats | |
886 | ||
887 | my %formats = make_extra_formats(%args); | |
888 | ||
889 | Transforms the subtree\_head and subtree\_foot into the "formats" | |
890 | method of formatting. | |
891 | Returns a hash of hashes of format options. | |
892 | ||
893 | # REQUIRES | |
894 | ||
895 | Test::More | |
896 | ||
897 | # INSTALLATION | |
898 | ||
899 | To install this module, run the following commands: | |
900 | ||
901 | perl Build.PL | |
902 | ./Build | |
903 | ./Build test | |
904 | ./Build install | |
905 | ||
906 | Or, if you're on a platform (like DOS or Windows) that doesn't like the | |
907 | "./" notation, you can do this: | |
908 | ||
909 | perl Build.PL | |
910 | perl Build | |
911 | perl Build test | |
912 | perl Build install | |
913 | ||
914 | In order to install somewhere other than the default, such as | |
915 | in a directory under your home directory, like "/home/fred/perl" | |
916 | go | |
917 | ||
918 | perl Build.PL --install_base /home/fred/perl | |
919 | ||
920 | as the first step instead. | |
921 | ||
922 | This will install the files underneath /home/fred/perl. | |
923 | ||
924 | You will then need to make sure that you alter the PERL5LIB variable to | |
925 | find the modules. | |
926 | ||
927 | Therefore you will need to change the PERL5LIB variable to add | |
928 | /home/fred/perl/lib | |
929 | ||
930 | PERL5LIB=/home/fred/perl/lib:${PERL5LIB} | |
931 | ||
932 | # SEE ALSO | |
933 | ||
934 | perl(1). | |
935 | ||
936 | # BUGS | |
937 | ||
938 | Please report any bugs or feature requests to the author. | |
939 | ||
940 | # AUTHOR | |
941 | ||
942 | Kathryn Andersen (RUBYKAT) | |
943 | perlkat AT katspace dot com | |
944 | http://www.katspace.com/tools/html_linklist/ | |
945 | ||
946 | # COPYRIGHT AND LICENCE | |
947 | ||
948 | Copyright (c) 2006 by Kathryn Andersen | |
949 | ||
950 | This program is free software; you can redistribute it and/or modify it | |
951 | under the same terms as Perl itself. |
0 | TODO list for HTML-LinkList | |
1 | =========================== | |
2 | 1. add accesskeys option; e.g. accesskey="h" for Home | |
3 | Added:07/09/08, 16:53 Priority: medium | |
4 | ||
5 |
0 | 0 | package HTML::LinkList; |
1 | $HTML::LinkList::VERSION = '0.1701'; | |
1 | 2 | use strict; |
2 | 3 | use warnings; |
3 | 4 | |
7 | 8 | |
8 | 9 | =head1 VERSION |
9 | 10 | |
10 | This describes version B<0.1503> of HTML::LinkList. | |
11 | ||
12 | =cut | |
13 | ||
14 | our $VERSION = '0.1503'; | |
11 | version 0.1701 | |
15 | 12 | |
16 | 13 | =head1 SYNOPSIS |
17 | 14 | |
223 | 220 | |
224 | 221 | An additional string to put in front of each "active" item, after pre_item. |
225 | 222 | The "active" item is the link which matches 'current_url'. |
223 | ||
224 | =item pre_item_active | |
225 | ||
226 | INSTEAD of the "pre_item" string, use this string for active items | |
226 | 227 | |
227 | 228 | =item post_active_item |
228 | 229 | |
262 | 263 | } |
263 | 264 | my %format = (exists $args{format} |
264 | 265 | ? %{$args{format}} |
265 | : ( | |
266 | pre_item=>$args{pre_item}, | |
267 | post_item=>$args{post_item}, | |
268 | pre_active_item=>$args{pre_active_item}, | |
269 | post_active_item=>$args{post_active_item}, | |
270 | pre_current_parent=>$args{pre_current_parent}, | |
271 | post_current_parent=>$args{post_current_parent}, | |
272 | pre_desc=>$args{pre_desc}, | |
273 | post_desc=>$args{post_desc}, | |
274 | item_sep=>$args{item_sep}, | |
275 | )); | |
266 | : make_default_format(%args)); | |
276 | 267 | # correct the current_url |
277 | 268 | $args{current_url} = make_canonical($args{current_url}); |
278 | 269 | my %current_parents = extract_current_parents(%args); |
442 | 433 | The "active" item is the link which matches 'current_url'. |
443 | 434 | (default: <em>) |
444 | 435 | |
436 | =item pre_item_active | |
437 | ||
438 | INSTEAD of the "pre_item" string, use this string for active items | |
439 | ||
445 | 440 | =item post_active_item |
446 | 441 | |
447 | 442 | An additional string to append to each active item, before post_item. |
451 | 446 | |
452 | 447 | An additional string to put in front of a link which is a parent |
453 | 448 | of the 'current_url' link, after pre_item. |
449 | ||
450 | =item pre_item_current_parent | |
451 | ||
452 | INSTEAD of the "pre_item" string, use this for links which are parents | |
453 | of the 'current_url' link. | |
454 | 454 | |
455 | 455 | =item post_current_parent |
456 | 456 | |
1021 | 1021 | |
1022 | 1022 | # correct the current_url |
1023 | 1023 | $args{current_url} = make_canonical($args{current_url}); |
1024 | my $current_is_index = ($args{current_url} =~ m#/$#); | |
1024 | my $current_is_index = ($args{current_url} =~ m!/$!o); | |
1025 | 1025 | my %current_parents = extract_current_parents(%args); |
1026 | 1026 | |
1027 | # set the end depth if isn't already set | |
1027 | # set the end depth if is not already set | |
1028 | 1028 | # if this is an index-page, then make the depth its depth + 1 |
1029 | 1029 | # if this is a content-page, make the depth its depth |
1030 | 1030 | my $current_url_depth = path_depth($args{current_url}); |
1156 | 1156 | if (!$label) |
1157 | 1157 | { |
1158 | 1158 | $label = $link if !$label; |
1159 | if ($link =~ /([-\w]+)\.\w+$/) # file | |
1159 | if ($link =~ /([-\w]+)\.\w+$/o) # file | |
1160 | 1160 | { |
1161 | 1161 | $label = $1; |
1162 | 1162 | } |
1163 | elsif ($link =~ /([-\w]+)\/?$/) # dir | |
1163 | elsif ($link =~ /([-\w]+)\/?$/o) # dir | |
1164 | 1164 | { |
1165 | 1165 | $label = $1; |
1166 | 1166 | } |
1167 | 1167 | else # give up |
1168 | 1168 | { |
1169 | 1169 | $label = $link; |
1170 | $label =~ s#/# :: #g; | |
1170 | $label =~ s#/# :: #go; | |
1171 | 1171 | } |
1172 | 1172 | |
1173 | 1173 | # prettify |
1174 | $label =~ s#_# #g; | |
1175 | $label =~ s#-# #g; | |
1176 | $label =~ s/([-\w]+)/\u\L$1/g; | |
1174 | $label =~ s#_# #go; | |
1175 | $label =~ s#-# #go; | |
1176 | $label =~ s/(\b[a-z][-\w]+)/\u\L$1/go; | |
1177 | 1177 | } |
1178 | 1178 | # if we are hiding the extensions of files |
1179 | 1179 | # we need to display an extensionless link |
1181 | 1181 | my $display_link = $link; |
1182 | 1182 | if ($args{hide_ext}) |
1183 | 1183 | { |
1184 | if ($link =~ /(.*)\.[-\w]+$/) # file | |
1184 | if ($link =~ /(.*)\.[-\w]+$/o) # file | |
1185 | 1185 | { |
1186 | 1186 | $display_link = $1; |
1187 | 1187 | } |
1199 | 1199 | if (link_is_active(this_link=>$link, |
1200 | 1200 | current_url=>$args{current_url})) |
1201 | 1201 | { |
1202 | $item = join('', $format{pre_item}, | |
1202 | $item = join('', $format{pre_item_active}, | |
1203 | 1203 | $format{pre_active_item}, |
1204 | 1204 | $label, |
1205 | 1205 | $format{post_active_item}, |
1216 | 1216 | and exists $args{current_parents}->{$link} |
1217 | 1217 | and $args{current_parents}->{$link}) |
1218 | 1218 | { |
1219 | $item = join('', $format{pre_item}, | |
1219 | $item = join('', $format{pre_item_current_parent}, | |
1220 | 1220 | $format{pre_current_parent}, |
1221 | 1221 | '<a href="', $prefix_url, $display_link, '">', |
1222 | 1222 | $label, '</a>', |
1249 | 1249 | my $url = shift; |
1250 | 1250 | |
1251 | 1251 | return $url if (!$url); |
1252 | if ($url =~ m#^(/)index\.\w+$#) | |
1252 | if ($url =~ m{^/index\.\w+$}o) | |
1253 | { | |
1254 | $url = '/'; | |
1255 | } | |
1256 | elsif ($url =~ m{^(.*/)index\.\w+$}o) | |
1253 | 1257 | { |
1254 | 1258 | $url = $1; |
1255 | 1259 | } |
1256 | elsif ($url =~ m#^(.*/)index\.\w+$#) | |
1257 | { | |
1258 | $url = $1; | |
1259 | } | |
1260 | elsif ($url =~ m#/[-\w]+$#) # no dots; a directory | |
1261 | { | |
1262 | $url .= '/'; # add the slash | |
1260 | elsif ($url =~ m{/[-\w]+$}o) # no dots; a directory | |
1261 | { | |
1262 | $url = join('', $url, '/'); # add the slash | |
1263 | 1263 | } |
1264 | 1264 | return $url; |
1265 | 1265 | } # make_canonical |
1279 | 1279 | |
1280 | 1280 | return $url if (!$url); |
1281 | 1281 | $url = make_canonical($url); |
1282 | if ($url =~ m#^(.*)/[-\w]+\.\w+$#) | |
1282 | if ($url =~ m{^(.*)/[-\w]+\.\w+$}o) | |
1283 | 1283 | { |
1284 | 1284 | $url = $1; |
1285 | 1285 | } |
1286 | elsif ($url ne '/') | |
1287 | { | |
1288 | $url =~ s#/$##; | |
1286 | elsif ($url ne '/' and $url =~ m{/$}o) | |
1287 | { | |
1288 | chop $url; | |
1289 | 1289 | } |
1290 | 1290 | return $url; |
1291 | 1291 | } # get_index_path |
1303 | 1303 | |
1304 | 1304 | return $url if (!$url); |
1305 | 1305 | $url = get_index_path($url); |
1306 | if ($url =~ m#^(.*)/[-\w]+$#) | |
1306 | if ($url =~ m#^(.*)/[-\w]+$#o) | |
1307 | 1307 | { |
1308 | 1308 | $url = $1; |
1309 | 1309 | } |
1321 | 1321 | my $url = shift; |
1322 | 1322 | |
1323 | 1323 | return 0 if ($url eq '/'); # root is zero |
1324 | $url =~ s#/$##; # remove trailing / | |
1325 | $url =~ s#^/##; # remove leading / | |
1326 | my @url = split('/', $url); | |
1327 | return scalar @url; | |
1324 | if ($url =~ m!/$!o) # remove trailing / | |
1325 | { | |
1326 | chop $url; | |
1327 | } | |
1328 | return scalar ($url =~ tr!/!/!); | |
1328 | 1329 | } # path_depth |
1329 | 1330 | |
1330 | 1331 | =head2 link_is_active |
1342 | 1343 | current_url=>'', |
1343 | 1344 | @_ |
1344 | 1345 | ); |
1346 | # if there is no current link, is not active. | |
1347 | return 0 if (!$args{current_url}); | |
1348 | ||
1345 | 1349 | my $link = make_canonical($args{this_link}); |
1346 | my $current_url = $args{current_url}; | |
1347 | ||
1348 | # if there is no current link, is not active. | |
1349 | return 0 if (!$current_url); | |
1350 | ||
1351 | return 1 if ($link eq $current_url); | |
1350 | ||
1351 | return 1 if ($link eq $args{current_url}); | |
1352 | 1352 | return 0; |
1353 | 1353 | |
1354 | 1354 | } # link_is_active |
1585 | 1585 | my $path = $paths_ref->[0]; |
1586 | 1586 | my $can_path = make_canonical($path); |
1587 | 1587 | my $path_depth = path_depth($can_path); |
1588 | my $path_is_index = ($can_path =~ m#/$#); | |
1588 | my $path_is_index = ($can_path =~ m#/$#o); | |
1589 | 1589 | if ($path_depth == $depth) |
1590 | 1590 | { |
1591 | 1591 | shift @{$paths_ref}; # use this path |
1673 | 1673 | my $paths_ref = $args{paths}; |
1674 | 1674 | my $hide = $args{hide}; |
1675 | 1675 | my $nohide = $args{nohide}; |
1676 | my $current_url_depth = path_depth($args{current_url}); | |
1677 | my $current_url_is_index = ($args{current_url} =~ m#/$#); | |
1678 | # the current-url dir is the current url without the filename | |
1679 | my $current_index_path = get_index_path($args{current_url}); | |
1680 | my $current_index_path_depth = path_depth($current_index_path); | |
1681 | my $current_index_parent = get_index_parent($args{current_url}); | |
1682 | ||
1683 | my @wantedpaths = (); | |
1676 | ||
1677 | my %canon_paths = (); | |
1678 | my @wantedpaths1 = (); | |
1679 | my %path_depth = (); | |
1680 | ||
1681 | # filter out common things | |
1682 | # remember canonical paths and path depths | |
1684 | 1683 | foreach my $path (@{$paths_ref}) |
1685 | 1684 | { |
1686 | 1685 | my $can_path = make_canonical($path); |
1687 | 1686 | my $path_depth = path_depth($can_path); |
1688 | my $path_is_index = ($can_path =~ m#/$#); | |
1689 | 1687 | if ($hide and $nohide |
1690 | 1688 | and not($path =~ /$nohide/) |
1691 | 1689 | and $path =~ /$hide/) |
1705 | 1703 | { |
1706 | 1704 | # skip this one |
1707 | 1705 | } |
1708 | # a breadcrumb-navbar shows the parent, self, | |
1709 | # and the children of dirs or siblings of non-dirs | |
1710 | elsif ($args{navbar_type} eq 'breadcrumb' | |
1711 | and $args{current_url} | |
1712 | and !( | |
1713 | ($path_depth <= $current_url_depth | |
1714 | and $args{current_url} =~ /^$path/) | |
1715 | or ( | |
1716 | $path eq $args{current_url} | |
1717 | ) | |
1718 | or ( | |
1719 | $current_url_is_index | |
1720 | and $path_depth >= $current_url_depth | |
1721 | and $path =~ /^$current_index_path\// | |
1722 | ) | |
1723 | or ( | |
1724 | !$current_url_is_index | |
1725 | and $path_depth >= $current_url_depth | |
1726 | and $path =~ /^$current_index_parent\// | |
1727 | ) | |
1728 | ) | |
1729 | ) | |
1730 | { | |
1731 | # skip this one | |
1732 | } | |
1733 | # a navbar shows the parent, the children | |
1734 | # and the current level | |
1735 | # and the top level (if we are starting at $top_level) | |
1736 | # and the siblings of one's parent if one is a contents-page | |
1737 | # or siblings of oneself if one is an index-page | |
1738 | elsif (($args{navbar_type} | |
1739 | or $args{do_navbar}) # backwards compatibility | |
1740 | and $args{current_url} | |
1741 | and !( | |
1742 | ($path_depth <= $current_url_depth | |
1743 | and $args{current_url} =~ /^$path/) | |
1744 | or ( | |
1745 | $path eq $args{current_url} | |
1746 | ) | |
1747 | or ( | |
1748 | $path_depth >= $current_url_depth | |
1749 | and $path =~ /^$current_index_path\// | |
1750 | ) | |
1751 | or ( | |
1752 | $args{start_depth} == $args{top_level} | |
1753 | and $path_depth == $args{start_depth} | |
1754 | ) | |
1755 | or ( | |
1756 | !$current_url_is_index | |
1757 | and $path_depth == $current_url_depth - 1 | |
1758 | and $path =~ /^$current_index_parent\// | |
1759 | ) | |
1760 | or ( | |
1761 | $current_url_is_index | |
1762 | and $path_depth == $current_url_depth | |
1763 | and $path =~ /^$current_index_parent\// | |
1764 | ) | |
1765 | ) | |
1766 | ) | |
1767 | { | |
1768 | # skip this one | |
1769 | } | |
1770 | 1706 | else |
1771 | 1707 | { |
1772 | # keep this path | |
1773 | push @wantedpaths, $path; | |
1774 | } | |
1708 | $path_depth{$path} = $path_depth; | |
1709 | $canon_paths{$path} = $can_path; | |
1710 | push @wantedpaths1, $path; | |
1711 | } | |
1712 | } | |
1713 | ||
1714 | my @wantedpaths = (); | |
1715 | if ($args{current_url}) | |
1716 | { | |
1717 | my $current_url = $args{current_url}; | |
1718 | my $current_url_depth = path_depth($args{current_url}); | |
1719 | my $current_url_is_index = ($args{current_url} =~ m{/$}o); | |
1720 | ||
1721 | my $parent = make_canonical($current_url_is_index | |
1722 | ? get_index_parent($args{current_url}) | |
1723 | : get_index_path($args{current_url}) | |
1724 | ); | |
1725 | my $parent_depth = path_depth($parent); | |
1726 | my $grandparent = ($parent_depth == 1 | |
1727 | ? '/' | |
1728 | : make_canonical(get_index_parent($parent))); | |
1729 | my $greatgrandparent = ($parent_depth <= 1 | |
1730 | ? '' | |
1731 | : ($parent_depth == 2 | |
1732 | ? '/' | |
1733 | : make_canonical(get_index_parent($grandparent)) | |
1734 | ) | |
1735 | ); | |
1736 | my $current_index_path = get_index_path($args{current_url}); | |
1737 | my $current_index_parent = get_index_parent($args{current_url}); | |
1738 | ||
1739 | if ($args{navbar_type} eq 'breadcrumb') | |
1740 | { | |
1741 | foreach my $path (@wantedpaths1) | |
1742 | { | |
1743 | my $pd = $path_depth{$path}; | |
1744 | # a breadcrumb-navbar shows the parent, self, | |
1745 | # and the children the parent | |
1746 | if ($pd <= $current_url_depth | |
1747 | and $args{current_url} =~ /^$path/) | |
1748 | { | |
1749 | push @wantedpaths, $path; | |
1750 | } | |
1751 | elsif ($path eq $args{current_url}) | |
1752 | { | |
1753 | push @wantedpaths, $path; | |
1754 | } | |
1755 | elsif ($pd >= $current_url_depth | |
1756 | and $path =~ m{^${current_url}}) | |
1757 | { | |
1758 | push @wantedpaths, $path; | |
1759 | } | |
1760 | elsif ($parent | |
1761 | and $pd >= $current_url_depth | |
1762 | and $path =~ m{^$parent}) | |
1763 | { | |
1764 | push @wantedpaths, $path; | |
1765 | } | |
1766 | } | |
1767 | } | |
1768 | elsif ($args{navbar_type} or $args{do_navbar}) | |
1769 | { | |
1770 | # Rules for navbars: | |
1771 | # * if I am a leaf node, see my (great)uncles and siblings | |
1772 | # * if have children, use the same data as my parent, | |
1773 | # plus my immediate children | |
1774 | foreach my $path (@wantedpaths1) | |
1775 | { | |
1776 | my $pd = $path_depth{$path}; | |
1777 | if ($pd > $current_url_depth + 1) | |
1778 | { | |
1779 | next; | |
1780 | } | |
1781 | if ($pd == $current_url_depth + 1 | |
1782 | and $path =~ m{^${current_url}}) | |
1783 | { | |
1784 | push @wantedpaths, $path; | |
1785 | } | |
1786 | elsif ($pd == $current_url_depth | |
1787 | and $path =~ m{^${parent}}) | |
1788 | { | |
1789 | push @wantedpaths, $path; | |
1790 | } | |
1791 | elsif ($grandparent | |
1792 | and $pd == $parent_depth | |
1793 | and $path =~ m{^$grandparent}) | |
1794 | { | |
1795 | push @wantedpaths, $path; | |
1796 | } | |
1797 | elsif ($greatgrandparent | |
1798 | and $pd == $parent_depth - 1 | |
1799 | and $path =~ m{^$greatgrandparent}) | |
1800 | { | |
1801 | push @wantedpaths, $path; | |
1802 | } | |
1803 | } | |
1804 | } | |
1805 | else | |
1806 | { | |
1807 | push @wantedpaths, @wantedpaths1; | |
1808 | } | |
1809 | } | |
1810 | else | |
1811 | { | |
1812 | push @wantedpaths, @wantedpaths1; | |
1775 | 1813 | } |
1776 | 1814 | return @wantedpaths; |
1777 | 1815 | } # filter_out_paths |
1815 | 1853 | tree_sep=>$args{tree_sep}, |
1816 | 1854 | tree_head=>$args{links_head}, |
1817 | 1855 | tree_foot=>$args{links_foot}, |
1856 | pre_item_active=>($args{pre_item_active} | |
1857 | ? $args{pre_item_active} | |
1858 | : $args{pre_item}), | |
1859 | pre_item_current_parent=> | |
1860 | ($args{pre_item_current_parent} | |
1861 | ? $args{pre_item_current_parent} | |
1862 | : $args{pre_item}), | |
1818 | 1863 | ); |
1819 | 1864 | return %default_format; |
1820 | 1865 | } # make_default_format |
1839 | 1884 | last_subtree_foot=>"\n</ul>", |
1840 | 1885 | pre_item=>'<li>', |
1841 | 1886 | post_item=>'</li>', |
1887 | pre_item_active=>'<li>', | |
1888 | pre_item_current_parent=>'<li>', | |
1842 | 1889 | pre_active_item=>'<em>', |
1843 | 1890 | post_active_item=>'</em>', |
1844 | 1891 | pre_current_parent=>'', |
0 | use 5.006; | |
1 | use strict; | |
2 | use warnings; | |
3 | ||
4 | # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.052 | |
5 | ||
6 | use Test::More; | |
7 | ||
8 | plan tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0); | |
9 | ||
10 | my @module_files = ( | |
11 | 'HTML/LinkList.pm' | |
12 | ); | |
13 | ||
14 | ||
15 | ||
16 | # no fake home requested | |
17 | ||
18 | my $inc_switch = -d 'blib' ? '-Mblib' : '-Ilib'; | |
19 | ||
20 | use File::Spec; | |
21 | use IPC::Open3; | |
22 | use IO::Handle; | |
23 | ||
24 | open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; | |
25 | ||
26 | my @warnings; | |
27 | for my $lib (@module_files) | |
28 | { | |
29 | # see L<perlfaq8/How can I capture STDERR from an external command?> | |
30 | my $stderr = IO::Handle->new; | |
31 | ||
32 | my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-e', "require q[$lib]"); | |
33 | binmode $stderr, ':crlf' if $^O eq 'MSWin32'; | |
34 | my @_warnings = <$stderr>; | |
35 | waitpid($pid, 0); | |
36 | is($?, 0, "$lib loaded ok"); | |
37 | ||
38 | if (@_warnings) | |
39 | { | |
40 | warn @_warnings; | |
41 | push @warnings, @_warnings; | |
42 | } | |
43 | } | |
44 | ||
45 | ||
46 | ||
47 | is(scalar(@warnings), 0, 'no warnings found') | |
48 | or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING}; | |
49 | ||
50 |
0 | do { my $x = { | |
1 | 'build' => { | |
2 | 'requires' => { | |
3 | 'Module::Build' => '0.28' | |
4 | } | |
5 | }, | |
6 | 'configure' => { | |
7 | 'requires' => { | |
8 | 'Module::Build' => '0.28' | |
9 | } | |
10 | }, | |
11 | 'develop' => { | |
12 | 'requires' => { | |
13 | 'Pod::Coverage::TrustPod' => '0', | |
14 | 'Test::CPAN::Meta' => '0', | |
15 | 'Test::Pod' => '1.41', | |
16 | 'Test::Pod::Coverage' => '1.08' | |
17 | } | |
18 | }, | |
19 | 'runtime' => { | |
20 | 'requires' => { | |
21 | 'Data::Dumper' => '0', | |
22 | 'Exporter' => '0', | |
23 | 'strict' => '0', | |
24 | 'warnings' => '0' | |
25 | } | |
26 | }, | |
27 | 'test' => { | |
28 | 'recommends' => { | |
29 | 'CPAN::Meta' => '2.120900' | |
30 | }, | |
31 | 'requires' => { | |
32 | 'ExtUtils::MakeMaker' => '0', | |
33 | 'File::Spec' => '0', | |
34 | 'IO::Handle' => '0', | |
35 | 'IPC::Open3' => '0', | |
36 | 'Test::More' => '0', | |
37 | 'perl' => '5.006' | |
38 | } | |
39 | } | |
40 | }; | |
41 | $x; | |
42 | }⏎ |
0 | #!perl | |
1 | ||
2 | use strict; | |
3 | use warnings; | |
4 | ||
5 | # This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.021 | |
6 | ||
7 | use Test::More tests => 1; | |
8 | ||
9 | use ExtUtils::MakeMaker; | |
10 | use File::Spec; | |
11 | ||
12 | # from $version::LAX | |
13 | my $lax_version_re = | |
14 | qr/(?: undef | (?: (?:[0-9]+) (?: \. | (?:\.[0-9]+) (?:_[0-9]+)? )? | |
15 | | | |
16 | (?:\.[0-9]+) (?:_[0-9]+)? | |
17 | ) | (?: | |
18 | v (?:[0-9]+) (?: (?:\.[0-9]+)+ (?:_[0-9]+)? )? | |
19 | | | |
20 | (?:[0-9]+)? (?:\.[0-9]+){2,} (?:_[0-9]+)? | |
21 | ) | |
22 | )/x; | |
23 | ||
24 | # hide optional CPAN::Meta modules from prereq scanner | |
25 | # and check if they are available | |
26 | my $cpan_meta = "CPAN::Meta"; | |
27 | my $cpan_meta_pre = "CPAN::Meta::Prereqs"; | |
28 | my $HAS_CPAN_META = eval "require $cpan_meta; $cpan_meta->VERSION('2.120900')" && eval "require $cpan_meta_pre"; ## no critic | |
29 | ||
30 | # Verify requirements? | |
31 | my $DO_VERIFY_PREREQS = 1; | |
32 | ||
33 | sub _max { | |
34 | my $max = shift; | |
35 | $max = ( $_ > $max ) ? $_ : $max for @_; | |
36 | return $max; | |
37 | } | |
38 | ||
39 | sub _merge_prereqs { | |
40 | my ($collector, $prereqs) = @_; | |
41 | ||
42 | # CPAN::Meta::Prereqs object | |
43 | if (ref $collector eq $cpan_meta_pre) { | |
44 | return $collector->with_merged_prereqs( | |
45 | CPAN::Meta::Prereqs->new( $prereqs ) | |
46 | ); | |
47 | } | |
48 | ||
49 | # Raw hashrefs | |
50 | for my $phase ( keys %$prereqs ) { | |
51 | for my $type ( keys %{ $prereqs->{$phase} } ) { | |
52 | for my $module ( keys %{ $prereqs->{$phase}{$type} } ) { | |
53 | $collector->{$phase}{$type}{$module} = $prereqs->{$phase}{$type}{$module}; | |
54 | } | |
55 | } | |
56 | } | |
57 | ||
58 | return $collector; | |
59 | } | |
60 | ||
61 | my @include = qw( | |
62 | ||
63 | ); | |
64 | ||
65 | my @exclude = qw( | |
66 | ||
67 | ); | |
68 | ||
69 | # Add static prereqs to the included modules list | |
70 | my $static_prereqs = do 't/00-report-prereqs.dd'; | |
71 | ||
72 | # Merge all prereqs (either with ::Prereqs or a hashref) | |
73 | my $full_prereqs = _merge_prereqs( | |
74 | ( $HAS_CPAN_META ? $cpan_meta_pre->new : {} ), | |
75 | $static_prereqs | |
76 | ); | |
77 | ||
78 | # Add dynamic prereqs to the included modules list (if we can) | |
79 | my ($source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; | |
80 | if ( $source && $HAS_CPAN_META ) { | |
81 | if ( my $meta = eval { CPAN::Meta->load_file($source) } ) { | |
82 | $full_prereqs = _merge_prereqs($full_prereqs, $meta->prereqs); | |
83 | } | |
84 | } | |
85 | else { | |
86 | $source = 'static metadata'; | |
87 | } | |
88 | ||
89 | my @full_reports; | |
90 | my @dep_errors; | |
91 | my $req_hash = $HAS_CPAN_META ? $full_prereqs->as_string_hash : $full_prereqs; | |
92 | ||
93 | # Add static includes into a fake section | |
94 | for my $mod (@include) { | |
95 | $req_hash->{other}{modules}{$mod} = 0; | |
96 | } | |
97 | ||
98 | for my $phase ( qw(configure build test runtime develop other) ) { | |
99 | next unless $req_hash->{$phase}; | |
100 | next if ($phase eq 'develop' and not $ENV{AUTHOR_TESTING}); | |
101 | ||
102 | for my $type ( qw(requires recommends suggests conflicts modules) ) { | |
103 | next unless $req_hash->{$phase}{$type}; | |
104 | ||
105 | my $title = ucfirst($phase).' '.ucfirst($type); | |
106 | my @reports = [qw/Module Want Have/]; | |
107 | ||
108 | for my $mod ( sort keys %{ $req_hash->{$phase}{$type} } ) { | |
109 | next if $mod eq 'perl'; | |
110 | next if grep { $_ eq $mod } @exclude; | |
111 | ||
112 | my $file = $mod; | |
113 | $file =~ s{::}{/}g; | |
114 | $file .= ".pm"; | |
115 | my ($prefix) = grep { -e File::Spec->catfile($_, $file) } @INC; | |
116 | ||
117 | my $want = $req_hash->{$phase}{$type}{$mod}; | |
118 | $want = "undef" unless defined $want; | |
119 | $want = "any" if !$want && $want == 0; | |
120 | ||
121 | my $req_string = $want eq 'any' ? 'any version required' : "version '$want' required"; | |
122 | ||
123 | if ($prefix) { | |
124 | my $have = MM->parse_version( File::Spec->catfile($prefix, $file) ); | |
125 | $have = "undef" unless defined $have; | |
126 | push @reports, [$mod, $want, $have]; | |
127 | ||
128 | if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META && $type eq 'requires' ) { | |
129 | if ( $have !~ /\A$lax_version_re\z/ ) { | |
130 | push @dep_errors, "$mod version '$have' cannot be parsed ($req_string)"; | |
131 | } | |
132 | elsif ( ! $full_prereqs->requirements_for( $phase, $type )->accepts_module( $mod => $have ) ) { | |
133 | push @dep_errors, "$mod version '$have' is not in required range '$want'"; | |
134 | } | |
135 | } | |
136 | } | |
137 | else { | |
138 | push @reports, [$mod, $want, "missing"]; | |
139 | ||
140 | if ( $DO_VERIFY_PREREQS && $type eq 'requires' ) { | |
141 | push @dep_errors, "$mod is not installed ($req_string)"; | |
142 | } | |
143 | } | |
144 | } | |
145 | ||
146 | if ( @reports ) { | |
147 | push @full_reports, "=== $title ===\n\n"; | |
148 | ||
149 | my $ml = _max( map { length $_->[0] } @reports ); | |
150 | my $wl = _max( map { length $_->[1] } @reports ); | |
151 | my $hl = _max( map { length $_->[2] } @reports ); | |
152 | ||
153 | if ($type eq 'modules') { | |
154 | splice @reports, 1, 0, ["-" x $ml, "", "-" x $hl]; | |
155 | push @full_reports, map { sprintf(" %*s %*s\n", -$ml, $_->[0], $hl, $_->[2]) } @reports; | |
156 | } | |
157 | else { | |
158 | splice @reports, 1, 0, ["-" x $ml, "-" x $wl, "-" x $hl]; | |
159 | push @full_reports, map { sprintf(" %*s %*s %*s\n", -$ml, $_->[0], $wl, $_->[1], $hl, $_->[2]) } @reports; | |
160 | } | |
161 | ||
162 | push @full_reports, "\n"; | |
163 | } | |
164 | } | |
165 | } | |
166 | ||
167 | if ( @full_reports ) { | |
168 | diag "\nVersions for all modules listed in $source (including optional ones):\n\n", @full_reports; | |
169 | } | |
170 | ||
171 | if ( @dep_errors ) { | |
172 | diag join("\n", | |
173 | "\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n", | |
174 | "The following REQUIRED prerequisites were not satisfied:\n", | |
175 | @dep_errors, | |
176 | "\n" | |
177 | ); | |
178 | } | |
179 | ||
180 | pass; | |
181 | ||
182 | # vim: ts=4 sts=4 sw=4 et: |
0 | # Test distribution before release | |
1 | # Optional for end users if Test::Distribution not installed | |
2 | ||
3 | use Test::More; | |
4 | ||
5 | BEGIN { | |
6 | eval { | |
7 | require Test::Distribution; | |
8 | }; | |
9 | if($@) { | |
10 | plan skip_all => "Test::Distribution not installed"; | |
11 | } | |
12 | else { | |
13 | import Test::Distribution; | |
14 | } | |
15 | } |
0 | use Test::More tests => 1; | |
1 | ||
2 | BEGIN { | |
3 | use_ok( 'HTML::LinkList' ); | |
4 | } | |
5 | ||
6 | diag( "Testing HTML::LinkList ${HTML::LinkList::VERSION}" ); |
0 | 0 | # testing full_tree |
1 | 1 | use strict; |
2 | use Test::More tests => 10; | |
2 | use Test::More tests => 12; | |
3 | 3 | |
4 | 4 | use HTML::LinkList qw(full_tree); |
5 | 5 | |
15 | 15 | '/tray/nav.html' => 'Navigation', |
16 | 16 | '/foo/bar/baz.html' => 'Bazzy', |
17 | 17 | ); |
18 | my $test_count = 0; | |
18 | 19 | |
19 | 20 | my $link_html = ''; |
20 | 21 | # default, no current |
22 | $test_count++; | |
21 | 23 | $link_html = full_tree(labels=>\%labels, |
22 | 24 | paths=>\@links); |
23 | ok($link_html, "(1) default; links HTML"); | |
25 | ok($link_html, "($test_count) default; links HTML"); | |
24 | 26 | |
25 | 27 | my $ok_str = ''; |
26 | 28 | $ok_str = '<ul><li><a href="/">Home</a> |
38 | 40 | </ul></li> |
39 | 41 | </ul>'; |
40 | 42 | |
41 | is($link_html, $ok_str, "(1) default; values match"); | |
43 | is($link_html, $ok_str, "($test_count) default; values match"); | |
42 | 44 | |
43 | 45 | # start_depth |
46 | $test_count++; | |
44 | 47 | $link_html = full_tree(labels=>\%labels, |
45 | 48 | paths=>\@links, |
46 | 49 | start_depth=>1); |
47 | ok($link_html, "(2) start_depth=1; links HTML"); | |
50 | ok($link_html, "($test_count) start_depth=1; links HTML"); | |
48 | 51 | |
49 | 52 | $ok_str = '<ul><li><a href="/bringle/">Bringle</a></li> |
50 | 53 | <li><a href="/foo/">Foo</a> |
59 | 62 | </ul></li> |
60 | 63 | </ul>'; |
61 | 64 | |
62 | is($link_html, $ok_str, "(2) start_depth=1; values match"); | |
65 | is($link_html, $ok_str, "($test_count) start_depth=1; values match"); | |
63 | 66 | |
64 | 67 | # start_depth and end_depth |
68 | $test_count++; | |
65 | 69 | $link_html = full_tree(labels=>\%labels, |
66 | 70 | paths=>\@links, |
67 | 71 | start_depth=>1, |
68 | 72 | end_depth=>2); |
69 | ok($link_html, "(3) start_depth=1, end_depth=2; links HTML"); | |
73 | ok($link_html, "($test_count) start_depth=1, end_depth=2; links HTML"); | |
70 | 74 | |
71 | 75 | $ok_str = '<ul><li><a href="/bringle/">Bringle</a></li> |
72 | 76 | <li><a href="/foo/">Foo</a> |
79 | 83 | </ul></li> |
80 | 84 | </ul>'; |
81 | 85 | |
82 | is($link_html, $ok_str, "(3) start_depth=1, end_depth=2; values match"); | |
86 | is($link_html, $ok_str, "($test_count) start_depth=1, end_depth=2; values match"); | |
83 | 87 | |
84 | 88 | # preserve_order, no current |
89 | $test_count++; | |
85 | 90 | $link_html = full_tree(labels=>\%labels, |
86 | 91 | paths=>\@links, |
87 | 92 | preserve_order=>1); |
88 | ok($link_html, "(4) preserve_order; links HTML"); | |
93 | ok($link_html, "($test_count) preserve_order; links HTML"); | |
89 | 94 | |
90 | 95 | $ok_str = ''; |
91 | 96 | $ok_str = '<ul><li><a href="/">Home</a> |
103 | 108 | </ul></li> |
104 | 109 | </ul>'; |
105 | 110 | |
106 | is($link_html, $ok_str, "(4) preserve_order; values match"); | |
111 | is($link_html, $ok_str, "($test_count) preserve_order; values match"); | |
107 | 112 | |
108 | 113 | # differing formats, no current |
114 | $test_count++; | |
109 | 115 | my %formats = ( |
110 | 116 | '1' => { |
111 | 117 | tree_head=>"<ol>", |
129 | 135 | paths=>\@links, |
130 | 136 | formats=>\%formats, |
131 | 137 | preserve_order=>1); |
132 | ok($link_html, "(5) formats; links HTML"); | |
138 | ok($link_html, "($test_count) formats; links HTML"); | |
133 | 139 | |
134 | 140 | $ok_str = '<ul><li><a href="/">Home</a> |
135 | 141 | <ol><li><a href="/foo/">Foo</a> |
145 | 151 | </li> |
146 | 152 | </ul>'; |
147 | 153 | |
148 | is($link_html, $ok_str, "(5) formats; values match"); | |
154 | is($link_html, $ok_str, "($test_count) formats; values match"); | |
149 | 155 | |
156 | # Mixed caps in links | |
157 | $test_count++; | |
158 | @links = qw( | |
159 | /foo/bar/baz.html | |
160 | /fooish.html | |
161 | /bringle/ | |
162 | /tray/nav.html | |
163 | /tray/tea_tray.html | |
164 | /industry/TLA_foo.html | |
165 | /industry/TLA_Bar.html | |
166 | ); | |
167 | %labels = ( | |
168 | '/tray/nav.html' => 'Navigation', | |
169 | ); | |
170 | $link_html = full_tree(labels=>\%labels, | |
171 | paths=>\@links); | |
172 | ok($link_html, "($test_count) Mixed caps; links HTML"); | |
173 | ||
174 | $ok_str = | |
175 | '<ul><li><a href="/">Home</a> | |
176 | <ul><li><a href="/bringle/">Bringle</a></li> | |
177 | <li><a href="/foo/">Foo</a> | |
178 | <ul><li><a href="/foo/bar/">Bar</a> | |
179 | <ul><li><a href="/foo/bar/baz.html">Baz</a></li> | |
180 | </ul></li> | |
181 | </ul></li> | |
182 | <li><a href="/fooish.html">Fooish</a></li> | |
183 | <li><a href="/industry/">Industry</a> | |
184 | <ul><li><a href="/industry/TLA_Bar.html">TLA Bar</a></li> | |
185 | <li><a href="/industry/TLA_foo.html">TLA Foo</a></li> | |
186 | </ul></li> | |
187 | <li><a href="/tray/">Tray</a> | |
188 | <ul><li><a href="/tray/nav.html">Navigation</a></li> | |
189 | <li><a href="/tray/tea_tray.html">Tea Tray</a></li> | |
190 | </ul></li> | |
191 | </ul></li> | |
192 | </ul>'; | |
193 | ||
194 | ||
195 | is($link_html, $ok_str, "($test_count) Mixed caps; values match"); |
0 | 0 | # testing nav_tree |
1 | 1 | use strict; |
2 | use Test::More tests => 22; | |
2 | use Test::More tests => 26; | |
3 | 3 | |
4 | 4 | use HTML::LinkList qw(nav_tree); |
5 | 5 | |
353 | 353 | test_count=>$test_count); |
354 | 354 | } |
355 | 355 | |
356 | # more current_parent stuff | |
357 | $test_count++; | |
358 | $link_html = nav_tree(labels=>\%labels, | |
359 | paths=>\@links, | |
360 | prepend_list=>[qw(/)], | |
361 | exclude_root_parent=>1, | |
362 | pre_item_current_parent=>'<li class="parent">', | |
363 | current_url=>'/products/crewing/'); | |
364 | ok($link_html, "($test_count) more links; pre_item_current_parent; links HTML"); | |
365 | ||
366 | $ok_str = '<ul><li><a href="/">Home</a></li> | |
367 | <li><a href="/about/">About</a></li> | |
368 | <li class="parent"><a href="/products/">Products</a> | |
369 | <ul><li><a href="/products/operations_control/">Operations Control</a></li> | |
370 | <li><em>Crewing</em> | |
371 | <ul><li><a href="/products/crewing/Crew_Rostering.pdf">Crew Rostering</a></li> | |
372 | </ul></li> | |
373 | <li><a href="/products/maintenance/">Maintenance</a></li> | |
374 | </ul></li> | |
375 | <li><a href="/solutions/">Solutions</a></li> | |
376 | <li><a href="/services/">Services</a></li> | |
377 | <li><a href="/news/">News</a></li> | |
378 | </ul>'; | |
379 | is($link_html, $ok_str, "($test_count) more links; pre_item_current_parent; values match"); | |
380 | ||
381 | # make an example html file of the difference | |
382 | if ($link_html ne $ok_str) | |
383 | { | |
384 | make_test_html(link_html=>$link_html, | |
385 | ok_str=>$ok_str, | |
386 | test_count=>$test_count); | |
387 | } | |
388 | ||
356 | 389 | # |
357 | 390 | # even more complicated links |
358 | 391 | # |
409 | 442 | ok_str=>$ok_str, |
410 | 443 | test_count=>$test_count); |
411 | 444 | } |
445 | ||
446 | # lower level | |
447 | $test_count++; | |
448 | $link_html = nav_tree(labels=>\%labels, | |
449 | paths=>\@links, | |
450 | start_depth=>2, | |
451 | top_level=>2, | |
452 | current_url=>'/dunes/products/operations_control/Airpac.html'); | |
453 | ok($link_html, "($test_count) start_depth=2, top_level=2; lower level links HTML"); | |
454 | ||
455 | $ok_str = '<ul><li><a href="/dunes/about/">About</a></li> | |
456 | <li><a href="/dunes/products/">Products</a> | |
457 | <ul><li><a href="/dunes/products/operations_control/">Operations Control</a> | |
458 | <ul><li><em>Airpac</em></li> | |
459 | <li><a href="/dunes/products/operations_control/Airpac_Overview.pdf">Airpac Overview</a></li> | |
460 | </ul></li> | |
461 | <li><a href="/dunes/products/crewing/">Crewing</a></li> | |
462 | <li><a href="/dunes/products/maintenance/">Maintenance</a></li> | |
463 | </ul></li> | |
464 | <li><a href="/dunes/solutions/">Solutions</a></li> | |
465 | <li><a href="/dunes/services/">Services</a></li> | |
466 | <li><a href="/dunes/news/">News</a></li> | |
467 | </ul>'; | |
468 | is($link_html, $ok_str, "($test_count) start_depth=2, top_level=2; values match"); | |
469 | ||
470 | # make an example html file of the difference | |
471 | if ($link_html ne $ok_str) | |
472 | { | |
473 | make_test_html(link_html=>$link_html, | |
474 | ok_str=>$ok_str, | |
475 | test_count=>$test_count); | |
476 | } |
0 | #!perl -T | |
1 | ||
2 | use Test::More; | |
3 | eval "use Test::Pod::Coverage 1.04"; | |
4 | plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@; | |
5 | all_pod_coverage_ok(); |
0 | #!perl -T | |
1 | ||
2 | use Test::More; | |
3 | eval "use Test::Pod 1.14"; | |
4 | plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; | |
5 | all_pod_files_ok(); |
0 | #!perl | |
1 | ||
2 | BEGIN { | |
3 | unless ($ENV{RELEASE_TESTING}) { | |
4 | require Test::More; | |
5 | Test::More::plan(skip_all => 'these tests are for release candidate testing'); | |
6 | } | |
7 | } | |
8 | ||
9 | # This file was automatically generated by Dist::Zilla::Plugin::MetaTests. | |
10 | ||
11 | use Test::CPAN::Meta; | |
12 | ||
13 | meta_yaml_ok(); |
0 | #!perl | |
1 | ||
2 | BEGIN { | |
3 | unless ($ENV{RELEASE_TESTING}) { | |
4 | require Test::More; | |
5 | Test::More::plan(skip_all => 'these tests are for release candidate testing'); | |
6 | } | |
7 | } | |
8 | ||
9 | ||
10 | use Test::More; | |
11 | ||
12 | eval "use Test::HasVersion"; | |
13 | plan skip_all => "Test::HasVersion required for testing version numbers" | |
14 | if $@; | |
15 | all_pm_version_ok(); |
0 | #!perl | |
1 | ||
2 | BEGIN { | |
3 | unless ($ENV{RELEASE_TESTING}) { | |
4 | require Test::More; | |
5 | Test::More::plan(skip_all => 'these tests are for release candidate testing'); | |
6 | } | |
7 | } | |
8 | ||
9 | # This file was automatically generated by Dist::Zilla::Plugin::PodCoverageTests. | |
10 | ||
11 | use Test::Pod::Coverage 1.08; | |
12 | use Pod::Coverage::TrustPod; | |
13 | ||
14 | all_pod_coverage_ok({ coverage_class => 'Pod::Coverage::TrustPod' }); |
0 | #!perl | |
1 | ||
2 | BEGIN { | |
3 | unless ($ENV{RELEASE_TESTING}) { | |
4 | require Test::More; | |
5 | Test::More::plan(skip_all => 'these tests are for release candidate testing'); | |
6 | } | |
7 | } | |
8 | ||
9 | # This file was automatically generated by Dist::Zilla::Plugin::PodSyntaxTests. | |
10 | use Test::More; | |
11 | use Test::Pod 1.41; | |
12 | ||
13 | all_pod_files_ok(); |
0 | #!perl | |
1 | ||
2 | BEGIN { | |
3 | unless ($ENV{RELEASE_TESTING}) { | |
4 | require Test::More; | |
5 | Test::More::plan(skip_all => 'these tests are for release candidate testing'); | |
6 | } | |
7 | } | |
8 | ||
9 | ||
10 | use strict; | |
11 | use warnings; | |
12 | ||
13 | use Test::More; | |
14 | ||
15 | eval 'use Test::Portability::Files'; | |
16 | plan skip_all => 'Test::Portability::Files required for testing portability' | |
17 | if $@; | |
18 | ||
19 | run_tests(); |