HTML-LinkList-0.1701 000755 001750 001751 0 12641340604 12617 5 ustar 00kat kat 000000 000000 README 100644 001750 001751 61553 12641340604 13612 0 ustar 00kat kat 000000 000000 HTML-LinkList-0.1701 NAME
HTML::LinkList - Create a 'smart' list of HTML links.
SYNOPSIS
use HTML::LinkList qw(link_list);
# default formatting
my $html_links = link_list(current_url=>$url,
urls=>\@links_in_order,
labels=>\%labels,
descriptions=>\%desc);
# paragraph with ' :: ' separators
my $html_links = link_list(current_url=>$url,
urls=>\@links_in_order,
labels=>\%labels,
descriptions=>\%desc,
links_head=>'
',
links_foot=>'
',
pre_item=>'',
post_item=>''
pre_active_item=>'',
post_active_item=>'',
item_sep=>" :: ");
# multi-level list
my $html_links = link_tree(
current_url=>$url,
link_tree=>\@list_of_lists,
labels=>\%labels,
descriptions=>\%desc);
DESCRIPTION
This module contains a number of functions for taking sets of URLs and
labels and creating suitably formatted HTML. These links are "smart"
because, if given the url of the current page, if any of the links in
the list equal it, that item in the list will be formatted as a special
label, not as a link; this is a Good Thing, since the user would be
confused by clicking on a link back to the current page.
While many website systems have plugins for "smart" navbars, they are
specialized for that system only, and can't be reused elsewhere,
forcing people to reinvent the wheel. I hereby present one wheel, free
to be reused by anybody; just the simple functions, a backend, which
can be plugged into whatever system you want.
The default format for the HTML is to make an unordered list, but there
are many options, enabling one to have a flatter layout with any
separators you desire, or a more complicated list with differing
formats for different levels.
The "link_list" function uses a simple list of links -- good for a
simple navbar.
The "link_tree" function takes a set of nested links and makes the HTML
for them -- good for making a table of contents, or a more complicated
navbar.
The "full_tree" function takes a list of paths and makes a full tree of
all the pages and index-pages in those paths -- good for making a site
map.
The "breadcrumb_trail" function takes a url and makes a "breadcrumb
trail" from it.
The "nav_tree" function creates a set of nested links to be used as a
multi-level navbar; one can give it a list of paths (as for full_tree)
and it will only show the links related to the current URL.
FUNCTIONS
To export a function, add it to the 'use' call.
use HTML::LinkList qw(link_list);
To export all functions do:
use HTML::LinkList ':all';
link_list
$links = link_list(
current_url=>$url,
urls=>\@links_in_order,
labels=>\%labels,
descriptions=>\%desc,
pre_desc=>' ',
post_desc=>'',
links_head=>'',
pre_item=>'',
post_item=>''
pre_active_item=>'',
post_active_item=>'',
item_sep=>"\n");
Generates a simple list of links, from list of urls (and optional
labels) taking into account of the "current" URL.
This provides a large number of options to customize the appearance of
the list. The default setup is for a simple UL list, but setting the
options can enable you to make it something other than a list
altogether, or add in CSS styles or classes to make it look just like
you want.
Required:
urls
The urls in the order you want them displayed. If this list is empty,
then nothing will be generated.
Options:
current_url
The link to the current page. If one of the links equals this, then
that is deemed to be the "active" link and is just displayed as a
label rather than a link.
descriptions
Optional hash of descriptions, to put next to the links. The keys of
this hash are the urls.
hide_ext
If a site is hiding link extensions (such as using MultiViews with
Apache) you may wish to hide the extensions (while using the full
URLs to check various things). (default: 0 (false))
item_sep
String to put between items.
labels
A hash whose keys are links and whose values are labels. These are
the labels for the links; if no label is given, then the last part of
the link is used for the label, with some formatting.
links_head
String to begin the list with.
links_foot
String to end the list with.
pre_desc
String to prepend to each description.
post_desc
String to append to each description.
pre_item
String to prepend to each item.
post_item
String to append to each item.
pre_active_item
An additional string to put in front of each "active" item, after
pre_item. The "active" item is the link which matches 'current_url'.
pre_item_active
INSTEAD of the "pre_item" string, use this string for active items
post_active_item
An additional string to append to each active item, before post_item.
prefix_url
A prefix to prepend to all the links. (default: empty string)
link_tree
$links = link_tree(
current_url=>$url,
link_tree=>\@list_of_lists,
labels=>\%labels,
descriptions=>\%desc,
pre_desc=>' ',
post_desc=>'',
links_head=>'',
subtree_head=>'',
pre_item=>'',
post_item=>''
pre_active_item=>'',
post_active_item=>'',
item_sep=>"\n",
tree_sep=>"\n",
formats=>\%formats);
Generates nested lists of links from a list of lists of links. This is
useful for things such as table-of-contents or site maps.
By default, this will return UL lists, but this is highly configurable.
Required:
link_tree
A list of lists of urls, in the order you want them displayed. If a
url is not in this list, it will not be displayed.
Options:
current_url
The link to the current page. If one of the links equals this, then
that is deemed to be the "active" link and is just displayed as a
label rather than a link.
descriptions
Optional hash of descriptions, to put next to the links. The keys of
this hash are the urls.
exclude_root_parent
If this is true, then the "current_parent" display options are not
used for the "root" ("/") path, it isn't counted as a "parent" of the
current_url.
formats
A reference to a hash containing advanced format settings. For
example:
my %formats = (
# level 1 and onwards
'1' => {
tree_head=>"",
tree_foot=>"
\n",
},
# level 2 and onwards
'2' => {
tree_head=>"\n",
},
# level 3 and onwards
'3' => {
pre_item=>'(',
post_item=>')',
item_sep=>",\n",
tree_sep=>' -> ',
tree_head=>"
\n",
tree_foot=>"",
}
);
The formats hash enables you to control the formatting on a per-level
basis. Each key of the hash corresponds to a level-number; the
sub-hashes contain format arguments which will apply from that level
onwards. If an argument isn't given in the sub-hash, then it will
fall back to the previous level (or to the default, if there is no
setting for that format-argument for a previous level).
The only difference between the names of the arguments in the
sub-hash and in the global format arguments is that instead of
'subtree_head' and subtree_foot' it uses 'tree_head' and 'tree_foot'.
hide_ext
If a site is hiding link extensions (such as using MultiViews with
Apache) you may wish to hide the extensions (while using the full
URLs to check various things). (default: 0 (false))
item_sep
The string to separate each item.
labels
A hash whose keys are links and whose values are labels. These are
the labels for the links; if no label is given, then the last part of
the link is used for the label, with some formatting.
links_head
The string to prepend the top-level tree with. (default: )
links_foot
The string to append to the top-level tree. (default:
)
pre_desc
String to prepend to each description.
post_desc
String to append to each description.
pre_item
String to prepend to each item. (default: )
post_item
String to append to each item. (default: )
pre_active_item
An additional string to put in front of each "active" item, after
pre_item. The "active" item is the link which matches 'current_url'.
(default: )
pre_item_active
INSTEAD of the "pre_item" string, use this string for active items
post_active_item
An additional string to append to each active item, before post_item.
(default: )
pre_current_parent
An additional string to put in front of a link which is a parent of
the 'current_url' link, after pre_item.
pre_item_current_parent
INSTEAD of the "pre_item" string, use this for links which are
parents of the 'current_url' link.
post_current_parent
An additional string to append to a link which is a parent of the
'current_url' link, before post_item.
prefix_url
A prefix to prepend to all the links. (default: empty string)
subtree_head
The string to prepend to lower-level trees. (default: )
subtree_foot
The string to append to lower-level trees. (default:
)
tree_sep
The string to separate each tree.
full_tree
$links = full_tree(
paths=>\@list_of_paths,
labels=>\%labels,
descriptions=>\%desc,
hide=>$hide_regex,
nohide=>$nohide_regex,
start_depth=>0,
end_depth=>0,
top_level=>0,
preserve_order=>0,
preserve_paths=>0,
...
);
Given a set of paths this will generate a tree of links in the style of
link_tree. This will figure out all the intermediate paths and
construct the nested structure for you, clustering parents and children
together.
The formatting options are as for "link_tree".
Required:
paths
A reference to a list of paths: that is, URLs relative to the top of
the site.
For example, if the full URL is http://www.example.com/foo.html then
the path is /foo.html
If the full URL is http://www.example.com/~frednurk/foo.html then the
path is /foo.html
This does not require that every possible path be given; all the
intermediate paths will be figured out from the list.
Options:
append_list
Array of paths to append to the top-level links. They are used as-is,
and are not part of the processing done to the "paths" list of paths.
(see "prepend_list")
descriptions
Optional hash of descriptions, to put next to the links. The keys of
this hash are the paths.
end_depth
End your tree at this depth. If zero, then go all the way. (see
"start_depth")
exclude_root_parent
If this is true, then the "current_parent" display options are not
used for the "root" ("/") path, it isn't counted as a "parent" of the
current_url.
hide
If the path matches this string, don't include it in the tree.
hide_ext
If a site is hiding link extensions (such as using MultiViews with
Apache) you may wish to hide the extensions (while using the full
URLs to check various things). (default: 0 (false))
labels
Hash containing replacement labels for one or more paths. If no label
is given for '/' (the root path) then 'Home' will be used.
last_subtree_head
The string to prepend to the last lower-level tree. Only used if
end_depth is not zero.
last_subtree_foot
The string to append to the last lower-level tree. Only used if
end_depth is not zero.
nohide
If the path matches this string, it will be included even if it
matches the 'hide' string.
prefix_url
A prefix to prepend to all the links. (default: empty string)
prepend_list
Array of paths to prepend to the top-level links. They are used
as-is, and are not part of the processing done to the "paths" list of
paths.
preserve_order
Preserve the ordering of the paths in the input list of paths;
otherwise the links will be sorted alphabetically. Note that if
preserve_order is true, the structure is at the whims of the order of
the original list of paths, and so could end up odd-looking.
(default: false)
preserve_paths
Do not extract intermediate paths or reorder the input list of paths.
This speeds things up, but assumes that the input paths are complete
and in good order. (default: false)
start_depth
Start your tree at this depth. Zero is the root, level 1 is the
files/sub-folders in the root, and so on. (default: 0)
top_level
Decide which level is the "top" level. Useful when you set the
start_depth to something greater than 1.
breadcrumb_trail
$links = breadcrumb_trail(
current_url=>$url,
labels=>\%labels,
descriptions=>\%desc,
links_head=>'',
links_foot=>"\n
",
subtree_head=>'',
subtree_foot=>"\n",
pre_item=>'',
post_item=>'',
pre_active_item=>'',
post_active_item=>'',
item_sep=>"\n",
tree_sep=>' > ',
...
);
Given the current url, make a breadcrumb trail from it. By default,
this is laid out with '>' separators, but it can be set up to give a
nested set of UL lists (as for "full_tree").
The formatting options are as for "link_tree".
Required:
current_url
The current url to be made into a breadcrumb-trail.
Options:
descriptions
Optional hash of descriptions, to put next to the links. The keys of
this hash are the urls.
exclude_root_parent
If this is true, then the "current_parent" display options are not
used for the "root" ("/") path, it isn't counted as a "parent" of the
current_url.
hide_ext
If a site is hiding link extensions (such as using MultiViews with
Apache) you may wish to hide the extensions (while using the full
URLs to check various things). (default: 0 (false))
labels
Hash containing replacement labels for one or more URLS. If no label
is given for '/' (the root path) then 'Home' will be used.
nav_tree
$links = nav_tree(
paths=>\@list_of_paths,
labels=>\%labels,
current_url=>$url,
hide=>$hide_regex,
nohide=>$nohide_regex,
preserve_order=>1,
descriptions=>\%desc,
...
);
This takes a list of links, and the current URL, and makes a nested
navigation tree, consisting of (a) the top-level links (b) the links
leading to the current URL (c) the links on the same level as the
current URL, (d) the related links just above this level, depending on
whether this is an index-page or a content page.
Optionally one can hide links which match match the 'hide' option.
The formatting options are as for "link_tree", with some additions.
Required:
current_url
The link to the current page. If one of the links equals this, then
that is deemed to be the "active" link and is just displayed as a
label rather than a link. This is also used to determine which links
to show and which ones to filter out.
paths
A reference to a list of paths: that is, URLs relative to the top of
the site.
For example, if the full URL is http://www.example.com/foo.html then
the path is /foo.html
This does not require that every possible path be given; all the
intermediate paths will be figured out from the list.
Options:
append_list
Array of paths to append to the top-level links. They are used as-is,
and are not part of the processing done to the "paths" list of paths.
(see "prepend_list")
descriptions
Optional hash of descriptions, to put next to the links. The keys of
this hash are the paths.
end_depth
End your tree at this depth. If zero, then go all the way. By default
this is set to the depth of the current_url.
exclude_root_parent
If this is true, then the "current_parent" display options are not
used for the "root" ("/") path, it isn't counted as a "parent" of the
current_url.
hide
If a path matches this string, don't include it in the tree.
hide_ext
If a site is hiding link extensions (such as using MultiViews with
Apache) you may wish to hide the extensions (while using the full
URLs to check various things). (default: 0 (false))
labels
Hash containing replacement labels for one or more paths. If no label
is given for '/' (the root path) then 'Home' will be used.
last_subtree_head
The string to prepend to the last lower-level tree.
last_subtree_foot
The string to append to the last lower-level tree.
nohide
If the path matches this string, it will be included even if it
matches the 'hide' string.
prefix_url
A prefix to prepend to all the links. (default: empty string)
prepend_list
Array of paths to prepend to the top-level links. They are used
as-is, and are not part of the processing done to the "paths" list of
paths.
preserve_order
Preserve the ordering of the paths in the input list of paths;
otherwise the links will be sorted alphabetically. (default: true)
preserve_paths
Do not extract intermediate paths or reorder the input list of paths.
This speeds things up, but assumes that the input paths are complete
and in good order. (default: false)
start_depth
Start your tree at this depth. Zero is the root, level 1 is the
files/sub-folders in the root, and so on. (default: 1)
top_level
Decide which level is the "top" level. Useful when you set the
start_depth to something greater than 1.
Private Functions
These functions cannot be exported.
make_item
$item = make_item( this_label=>$label, this_link=>$link, hide_ext=>0,
current_url=>$url, current_parents=>\%current_parents,
descriptions=>\%desc, format=>\%format, );
%format = ( pre_desc=>' ', post_desc=>'', pre_item=>'',
post_item=>'' pre_active_item=>'', post_active_item=>'',
pre_current_parent=>'', post_current_parent=>'',
item_sep=>"\n"); );
Format a link item.
See "link_list" for the formatting options.
this_label
The label of the required link. If there is no label, this uses the
base-name of the last part of the link, capitalizing it and replacing
underscores and dashes with spaces.
this_link
The URL of the required link.
current_url
The link to the current page. If one of the links equals this, then
that is deemed to be the "active" link and is just displayed as a
label rather than a link.
current_parents
URLs of the parents of the current item.
descriptions
Optional hash of descriptions, to put next to the links. The keys of
this hash are the links (not the labels).
defer_post_item
Don't add the 'post_item' string if this is true. (needed for nested
lists) (default: false)
no_link
Don't make a link for this, just a label.
make_canonical
my $new_url = make_canonical($url);
Make a URL canonical; remove the 'index.*' and add on a needed '/' --
this assumes that directory names never have a '.' in them.
get_index_path
my $new_url = get_index_path($url);
Get the "index" part of this path. That is, if this path is not for an
index-page, then get the parent index-page path for this path. (Removes
the trailing slash).
get_index_parent
my $new_url = get_index_parent($url);
Get the parent of the "index" part of this path. (Removes the trailing
slash).
path_depth
my $depth = path_depth($url);
Calculate the "depth" of the given path.
link_is_active
if (link_is_active(this_link=>$link, current_url=>$url))
...
Check if the given link is "active", that is, if it matches the
'current_url'.
traverse_lol
$links = traverse_lol(\@list_of_lists, labels=>\%labels,
tree_depth=>$depth current_format=>\%format, ... );
Traverse the list of lists (of urls) to produce a nested collection of
links.
This consumes the list_of_lists!
extract_all_paths
my @all_paths = extract_all_paths(paths=>\@paths, preserve_order=>0);
Extract all possible paths out of a list of paths. Thus, if one has
/foo/bar/baz.html
then that would make
/ /foo/ /foo/bar/ /foo/bar/baz.html
If 'preserve_order' is true, this preserves the ordering of the paths
in the input list; otherwise the output paths are sorted
alphabetically.
extract_current_parents
my %current_parents = extract_current_parents(current_url=>$url,
exclude_root_parent=>0);
Extract the "parent" paths of the current url
/foo/bar/baz.html
then that would make
/ /foo/ /foo/bar/
If 'exclude_root_parent' is true, then the '/' is excluded from the
list of parents.
build_lol
my @lol = build_lol(
paths=>\@paths,
current_url=>$url,
navbar_type=>'',
);
Build a list of lists of paths, given a simple list of paths. Assumes
that this list has already been filtered.
paths
Reference to list of paths; this is consumed.
filter_out_paths
my @filtered_paths = filter_out_paths(
paths=>\@paths,
current_url=>$url,
hide=>$hide,
nohide=>$nohide,
start_depth=>$start_depth,
end_depth=>$end_depth,
top_level=>$top_level,
navbar_type=>'',
);
Filter out the paths we don't want from our list of paths. Returns a
list of the paths we want.
make_default_format
my %default_format = make_default_format(%args);
Make the default format hash from the args. Returns a hash of format
options.
make_extra_formats
my %formats = make_extra_formats(%args);
Transforms the subtree_head and subtree_foot into the "formats" method
of formatting. Returns a hash of hashes of format options.
REQUIRES
Test::More
INSTALLATION
To install this module, run the following commands:
perl Build.PL
./Build
./Build test
./Build install
Or, if you're on a platform (like DOS or Windows) that doesn't like the
"./" notation, you can do this:
perl Build.PL
perl Build
perl Build test
perl Build install
In order to install somewhere other than the default, such as in a
directory under your home directory, like "/home/fred/perl" go
perl Build.PL --install_base /home/fred/perl
as the first step instead.
This will install the files underneath /home/fred/perl.
You will then need to make sure that you alter the PERL5LIB variable to
find the modules.
Therefore you will need to change the PERL5LIB variable to add
/home/fred/perl/lib
PERL5LIB=/home/fred/perl/lib:${PERL5LIB}
SEE ALSO
perl(1).
BUGS
Please report any bugs or feature requests to the author.
AUTHOR
Kathryn Andersen (RUBYKAT)
perlkat AT katspace dot com
http://www.katspace.com/tools/html_linklist/
COPYRIGHT AND LICENCE
Copyright (c) 2006 by Kathryn Andersen
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
LICENSE 100644 001750 001751 43671 12641340604 13740 0 ustar 00kat kat 000000 000000 HTML-LinkList-0.1701 This software is copyright (c) 2016 by Kathryn Andersen.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
Terms of the Perl programming language system itself
a) the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any
later version, or
b) the "Artistic License"
--- The GNU General Public License, Version 1, February 1989 ---
This software is Copyright (c) 2016 by Kathryn Andersen.
This is free software, licensed under:
The GNU General Public License, Version 1, February 1989
GNU GENERAL PUBLIC LICENSE
Version 1, February 1989
Copyright (C) 1989 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The license agreements of most software companies try to keep users
at the mercy of those companies. By contrast, our General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. The
General Public License applies to the Free Software Foundation's
software and to any other program whose authors commit to using it.
You can use it for your programs, too.
When we speak of free software, we are referring to freedom, not
price. Specifically, the General Public License is designed to make
sure that you have the freedom to give away or sell copies of free
software, that you receive source code or can get it if you want it,
that you can change the software or use pieces of it in new free
programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of a such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must tell them their rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any program or other work which
contains a notice placed by the copyright holder saying it may be
distributed under the terms of this General Public License. The
"Program", below, refers to any such program or work, and a "work based
on the Program" means either the Program or any work containing the
Program or a portion of it, either verbatim or with modifications. Each
licensee is addressed as "you".
1. You may copy and distribute verbatim copies of the Program's source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and
disclaimer of warranty; keep intact all the notices that refer to this
General Public License and to the absence of any warranty; and give any
other recipients of the Program a copy of this General Public License
along with the Program. You may charge a fee for the physical act of
transferring a copy.
2. You may modify your copy or copies of the Program or any portion of
it, and copy and distribute such modifications under the terms of Paragraph
1 above, provided that you also do the following:
a) cause the modified files to carry prominent notices stating that
you changed the files and the date of any change; and
b) cause the whole of any work that you distribute or publish, that
in whole or in part contains the Program or any part thereof, either
with or without modifications, to be licensed at no charge to all
third parties under the terms of this General Public License (except
that you may choose to grant warranty protection to some or all
third parties, at your option).
c) If the modified program normally reads commands interactively when
run, you must cause it, when started running for such interactive use
in the simplest and most usual way, to print or display an
announcement including an appropriate copyright notice and a notice
that there is no warranty (or else, saying that you provide a
warranty) and that users may redistribute the program under these
conditions, and telling the user how to view a copy of this General
Public License.
d) You may charge a fee for the physical act of transferring a
copy, and you may at your option offer warranty protection in
exchange for a fee.
Mere aggregation of another independent work with the Program (or its
derivative) on a volume of a storage or distribution medium does not bring
the other work under the scope of these terms.
3. You may copy and distribute the Program (or a portion or derivative of
it, under Paragraph 2) in object code or executable form under the terms of
Paragraphs 1 and 2 above provided that you also do one of the following:
a) accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of
Paragraphs 1 and 2 above; or,
b) accompany it with a written offer, valid for at least three
years, to give any third party free (except for a nominal charge
for the cost of distribution) a complete machine-readable copy of the
corresponding source code, to be distributed under the terms of
Paragraphs 1 and 2 above; or,
c) accompany it with the information you received as to where the
corresponding source code may be obtained. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form alone.)
Source code for a work means the preferred form of the work for making
modifications to it. For an executable file, complete source code means
all the source code for all modules it contains; but, as a special
exception, it need not include source code for modules which are standard
libraries that accompany the operating system on which the executable
file runs, or for standard header files or definitions files that
accompany that operating system.
4. You may not copy, modify, sublicense, distribute or transfer the
Program except as expressly provided under this General Public License.
Any attempt otherwise to copy, modify, sublicense, distribute or transfer
the Program is void, and will automatically terminate your rights to use
the Program under this License. However, parties who have received
copies, or rights to use copies, from you under this General Public
License will not have their licenses terminated so long as such parties
remain in full compliance.
5. By copying, distributing or modifying the Program (or any work based
on the Program) you indicate your acceptance of this license to do so,
and all its terms and conditions.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the original
licensor to copy, distribute or modify the Program subject to these
terms and conditions. You may not impose any further restrictions on the
recipients' exercise of the rights granted herein.
7. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of the license which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
the license, you may choose any version ever published by the Free Software
Foundation.
8. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to humanity, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.
To do so, attach the following notices to the program. It is safest to
attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
Copyright (C) 19yy
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19xx name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the
appropriate parts of the General Public License. Of course, the
commands you use may be called something other than `show w' and `show
c'; they could even be mouse-clicks or menu items--whatever suits your
program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
program `Gnomovision' (a program to direct compilers to make passes
at assemblers) written by James Hacker.
, 1 April 1989
Ty Coon, President of Vice
That's all there is to it!
--- The Artistic License 1.0 ---
This software is Copyright (c) 2016 by Kathryn Andersen.
This is free software, licensed under:
The Artistic License 1.0
The Artistic License
Preamble
The intent of this document is to state the conditions under which a Package
may be copied, such that the Copyright Holder maintains some semblance of
artistic control over the development of the package, while giving the users of
the package the right to use and distribute the Package in a more-or-less
customary fashion, plus the right to make reasonable modifications.
Definitions:
- "Package" refers to the collection of files distributed by the Copyright
Holder, and derivatives of that collection of files created through
textual modification.
- "Standard Version" refers to such a Package if it has not been modified,
or has been modified in accordance with the wishes of the Copyright
Holder.
- "Copyright Holder" is whoever is named in the copyright or copyrights for
the package.
- "You" is you, if you're thinking about copying or distributing this Package.
- "Reasonable copying fee" is whatever you can justify on the basis of media
cost, duplication charges, time of people involved, and so on. (You will
not be required to justify it to the Copyright Holder, but only to the
computing community at large as a market that must bear the fee.)
- "Freely Available" means that no fee is charged for the item itself, though
there may be fees involved in handling the item. It also means that
recipients of the item may redistribute it under the same conditions they
received it.
1. You may make and give away verbatim copies of the source form of the
Standard Version of this Package without restriction, provided that you
duplicate all of the original copyright notices and associated disclaimers.
2. You may apply bug fixes, portability fixes and other modifications derived
from the Public Domain or from the Copyright Holder. A Package modified in such
a way shall still be considered the Standard Version.
3. You may otherwise modify your copy of this Package in any way, provided that
you insert a prominent notice in each changed file stating how and when you
changed that file, and provided that you do at least ONE of the following:
a) place your modifications in the Public Domain or otherwise make them
Freely Available, such as by posting said modifications to Usenet or an
equivalent medium, or placing the modifications on a major archive site
such as ftp.uu.net, or by allowing the Copyright Holder to include your
modifications in the Standard Version of the Package.
b) use the modified Package only within your corporation or organization.
c) rename any non-standard executables so the names do not conflict with
standard executables, which must also be provided, and provide a separate
manual page for each non-standard executable that clearly documents how it
differs from the Standard Version.
d) make other distribution arrangements with the Copyright Holder.
4. You may distribute the programs of this Package in object code or executable
form, provided that you do at least ONE of the following:
a) distribute a Standard Version of the executables and library files,
together with instructions (in the manual page or equivalent) on where to
get the Standard Version.
b) accompany the distribution with the machine-readable source of the Package
with your modifications.
c) accompany any non-standard executables with their corresponding Standard
Version executables, giving the non-standard executables non-standard
names, and clearly documenting the differences in manual pages (or
equivalent), together with instructions on where to get the Standard
Version.
d) make other distribution arrangements with the Copyright Holder.
5. You may charge a reasonable copying fee for any distribution of this
Package. You may charge any fee you choose for support of this Package. You
may not charge a fee for this Package itself. However, you may distribute this
Package in aggregate with other (possibly commercial) programs as part of a
larger (possibly commercial) software distribution provided that you do not
advertise this Package as a product of your own.
6. The scripts and library files supplied as input to or produced as output
from the programs of this Package do not automatically fall under the copyright
of this Package, but belong to whomever generated them, and may be sold
commercially, and may be aggregated with this Package.
7. C or perl subroutines supplied by you and linked into this Package shall not
be considered part of this Package.
8. The name of the Copyright Holder may not be used to endorse or promote
products derived from this software without specific prior written permission.
9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
The End
Changes 100644 001750 001751 2614 12641340604 14176 0 ustar 00kat kat 000000 000000 HTML-LinkList-0.1701 Revision History for HTML-LinkList
==================================
v0.1701 2016-01-01
------------------
* 2016-01-01 10:58:19 +1100
tweaking dist.ini
* 2015-05-05 11:14:32 +1000
Dist::Zilla stuff.
* 2015-05-05 11:11:09 +1000
version bump
* 2015-05-05 11:08:35 +1000
Fixing some compatibility Dist::Zilla stuff.
* 2013-09-14 11:49:20 +1000
added [ReportVersions::Tiny]
* 2012-02-06 00:32:05 +1100
added a ConfirmRelease test
* 2011-02-21 16:57:32 +1100
Disabled Progressive Critic tests.
* 2011-02-21 16:37:27 +1100
Fixed Dist::Zilla version setting.
* 2011-02-21 16:34:11 +1100
Tweaking Dist::Zilla config.
* 2011-02-21 16:30:46 +1100
Changing build system over to Dist::Zilla.
* 2011-02-21 13:09:53 +1100
fixed warnings
* 2011-02-21 13:07:33 +1100
Links with Mixed Caps, don't decase the labels.
* 2011-02-18 13:18:59 +1100
New formatting options: pre_item_active + pre_item_current_parent
* 2010-07-02 19:48:46 +1000
updated MANIFEST.SKIP for git
* 2010-02-26 16:52:36 +1100
removed nofilter_paths option
* 2010-02-26 16:50:33 +1100
Improved algorithm for deeper nested navbars
* 2010-01-04 12:54:58 +1100
not a released version
* 2010-01-04 12:54:34 +1100
added nofilter_paths option
* 2009-12-16 17:01:27 +1100
Slight speed improvements; also added .gitignore
====================================
End of changes in the last 1000 days
====================================
META.yml 100644 001750 001751 1325 12641340604 14152 0 ustar 00kat kat 000000 000000 HTML-LinkList-0.1701 ---
abstract: "Create a 'smart' list of HTML links."
author:
- 'Kathryn Andersen'
build_requires:
ExtUtils::MakeMaker: '0'
File::Spec: '0'
IO::Handle: '0'
IPC::Open3: '0'
Module::Build: '0.28'
Test::More: '0'
perl: '5.006'
configure_requires:
Module::Build: '0.28'
dynamic_config: 0
generated_by: 'Dist::Zilla version 5.036, CPAN::Meta::Converter version 2.143240'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: HTML-LinkList
requires:
Data::Dumper: '0'
Exporter: '0'
strict: '0'
warnings: '0'
resources:
homepage: https://github.com/rubykat/HTML-LinkList
repository: https://github.com/rubykat/HTML-LinkList.git
version: '0.1701'
Build.PL 100644 001750 001751 2463 12641340604 14201 0 ustar 00kat kat 000000 000000 HTML-LinkList-0.1701
# This file was automatically generated by Dist::Zilla::Plugin::ModuleBuild v5.036.
use strict;
use warnings;
use Module::Build 0.28;
my %module_build_args = (
"build_requires" => {
"Module::Build" => "0.28"
},
"configure_requires" => {
"Module::Build" => "0.28"
},
"dist_abstract" => "Create a 'smart' list of HTML links.",
"dist_author" => [
"Kathryn Andersen"
],
"dist_name" => "HTML-LinkList",
"dist_version" => "0.1701",
"license" => "perl",
"module_name" => "HTML::LinkList",
"recommends" => {},
"recursive_test_files" => 1,
"requires" => {
"Data::Dumper" => 0,
"Exporter" => 0,
"strict" => 0,
"warnings" => 0
},
"script_files" => [],
"test_requires" => {
"ExtUtils::MakeMaker" => 0,
"File::Spec" => 0,
"IO::Handle" => 0,
"IPC::Open3" => 0,
"Test::More" => 0,
"perl" => "5.006"
}
);
my %fallback_build_requires = (
"ExtUtils::MakeMaker" => 0,
"File::Spec" => 0,
"IO::Handle" => 0,
"IPC::Open3" => 0,
"Module::Build" => "0.28",
"Test::More" => 0,
"perl" => "5.006"
);
unless ( eval { Module::Build->VERSION(0.4004) } ) {
delete $module_build_args{test_requires};
$module_build_args{build_requires} = \%fallback_build_requires;
}
my $build = Module::Build->new(%module_build_args);
$build->create_build_script;
MANIFEST 100644 001750 001751 711 12641340604 14010 0 ustar 00kat kat 000000 000000 HTML-LinkList-0.1701 # This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.036.
Build.PL
Changes
LICENSE
MANIFEST
MANIFEST.SKIP
META.yml
OldChanges
README
README.mkdn
lib/HTML/LinkList.pm
t/00-compile.t
t/00-report-prereqs.dd
t/00-report-prereqs.t
t/10_link_list.t
t/20_link_tree.t
t/30_full_tree.t
t/40_breadcrumb_trail.t
t/50_nav_tree.t
t/release-distmeta.t
t/release-has-version.t
t/release-pod-coverage.t
t/release-pod-syntax.t
t/release-portability.t
OldChanges 100644 001750 001751 14236 12641340604 14660 0 ustar 00kat kat 000000 000000 HTML-LinkList-0.1701 Revision history for HTML-LinkList
==================================
0.1503 Sun 07 September 2008
----------------------------
* (2008-09-07) A few tweaks with TODO and Changes.
0.1502 Sun 07 September 2008
----------------------------
* (2008-09-07) Make the Build make a traditional Makefile.PL
* (2008-09-07) Tweak to improve prettifying links.
0.1501 Sat 26 May 2007
----------------------
* (26 May 2007) fix formats
Fixed a bug in the advanced formats stuff.
0.15 Tue 22 May 2007
--------------------
* (22 May 2007) advanced formats
Added "formats" option for advanced formatting.
0.14 Sat 19 May 2007
--------------------
* (19 May 2007) uneven lists
Enable this to deal with lists of lists where the first item
isn't a normal item, but a sub-list, but the next item is a normal
item.
0.13 Mon 11 September 2006
--------------------------
* (11 Sep 2006) hide_ext
Added the 'hide_ext' option, to hide extensions of files in
links (useful for MultiViews sites).
0.12 Tue 23 May 2006
--------------------
* (23 May 2006) description improvements
Added 'pre_desc' and 'post_desc' options to enable one to
put a string before and after the descriptions.
0.11 Thu 20 April 2006
----------------------
* (20 Apr 2006) preserve_paths option
Added the 'preserve_paths' option; if this is true, then the
input paths are not sorted, nor do they have intermediate paths extracted.
This speeds things up slightly, and can be useful if you already have a full
list of paths and don't need to do that processing on it again.
0.1002 Mon 17 April 2006
------------------------
* (17 Apr 2006) navbar fix
If there are paths that are too similar, such as one subdir
in a directory being called "foo", and another called "foobar", then
it would pick up the foobar stuff in foo when it shouldn't.
0.1001 Thu 13 April 2006
------------------------
* (12 Apr 2006) fixed nohide bug
The 'nohide' option was being ignored in some circumstances.
0.10 Sat 01 April 2006
----------------------
* (1 Apr 2006) breadcrumb-navbar
Added a hybrid breadcrumb-navbar: nav_tree(navbar_type=>'breadcrumb')
which starts off like a breadcrumb-trail, showing the parent(s) of
the current URL, but also showing the current level, not just the current
URL. Useful in situations where you don't want a full-blown navigation
tree.
0.09 Thu 16 March 2006
----------------------
* (16 Mar 2006) documentation tweaking
* (16 Mar 2006) exclude_root_parent
Added the 'exclude_root_parent' option, which excludes the root "/"
path from being counted as a "parent" to the current_url when using the
'pre_current_parent' and 'post_current_parent' options.
This can be useful if you want to use those options but don't
want the root/Home link to be displayed differently.
* (16 Mar 2006) prepend_list and append_list
Added new options (to 'full_tree', 'nav_tree') 'prepend_list'
and 'append_list' which enable you to prepend or append a list of links
to be added to your "top level" as-is.
* (16 Mar 2006) removed nav_bar
Removed the 'nav_bar' function because it was horrible and made
yucky navbars. With use of CSS and choice of levels and separators, the
'nav_tree' should be sufficient, since while the UL list is the default,
it can be set up to use paragraphs and so on.
0.08 Thu 16 February 2006
-------------------------
* (16 Feb 2006) top_level option
Added a new 'top_level' option, useful for starting a navigation
tree further down its hierarchy.
0.07 Thu 02 February 2006
-------------------------
* (2 Feb 2006) depth fixes
- enabled start_depth and end_depth to be changed for nav_tree
without wierdness happening. It used to be that end_depth was ignored,
and if start_depth was anything other than 1, one would get too many links.
* (25 Jan 2006) empty lists
Added a check to see that the generated list wasn't empty;
before this, it would *always* put on the list_head and list_foot
stuff even if there was nothing there. Which meant that you
could end up with something like which is Not Nice.
* (25 Jan 2006) parent_item_sep
Added the 'parent_item_sep' parameter to 'nav_bar'.
0.0601 Thu 19 January 2006
--------------------------
* (19 Jan 2006) corrected error in changelog
0.06 Thu 19 January 2006
------------------------
* (19 Jan 2006) mostly nav_bar
- added new function nav_bar, which does an across-the-top navbar
- added new option 'nohide' to override 'hide'
- renamed a number of options
- restructured the way some things were done
0.0502 Tue 17 January 2006
--------------------------
* (17 Jan 2006) futher correction to navbar
This time fer shure!
0.0501 Tue 17 January 2006
--------------------------
* (17 Jan 2006) corrected navbar error
My feature enhancement... didn't do what I thought it did. Oops.
0.05 Tue 17 January 2006
------------------------
* (17 Jan 2006) improved navbar
Now the navbar shows the next level up when the current page
is not an index page; the siblings of its parent.
0.04 Fri 13 January 2006
------------------------
* (13 Jan 2006) improved nav_tree
Revamped the logic and the options to make nav_tree more sensible
and simpler to use.
* (12 Jan 2006) nomenclature
Stop referring to directories; they're index pages.
Renamed 'dir_tree' to 'full_tree'.
0.03 Thu 12 January 2006
------------------------
* (12 Jan 2006) renames,additions,nav_tree
- renamed breadcrumb_tree to breadcrumb_trail
- added the 'preserve_order' option to dir_tree
- added new function 'nav_tree' to make a nested navbar
- updated documentation
- fixes and tweaks
0.02 Wed 11 January 2006
------------------------
* (11 Jan 2006) breadcrumb_tree
Added the 'breadcrumb_tree' function which makes a breadcrumb
trail from the current_url.
* (11 Jan 2006) minor fixes
Made the checking of the 'current_url' better.
0.01 Mon 09 January 2006
------------------------
* (9 Jan 2006) tweaking documentation
* (9 Jan 2006) commit tweaking
The ModDevAid stuff needed to not try to chmod non-existant scripts.
* (9 Jan 2006) fixing tests
Just some minor bugs with the tests.
* (9 Jan 2006) initial checkin
README.mkdn 100644 001750 001751 57431 12641340604 14542 0 ustar 00kat kat 000000 000000 HTML-LinkList-0.1701 # NAME
HTML::LinkList - Create a 'smart' list of HTML links.
# VERSION
version 0.1701
# SYNOPSIS
use HTML::LinkList qw(link_list);
# default formatting
my $html_links = link_list(current_url=>$url,
urls=>\@links_in_order,
labels=>\%labels,
descriptions=>\%desc);
# paragraph with ' :: ' separators
my $html_links = link_list(current_url=>$url,
urls=>\@links_in_order,
labels=>\%labels,
descriptions=>\%desc,
links_head=>'',
links_foot=>'
',
pre_item=>'',
post_item=>''
pre_active_item=>'',
post_active_item=>'',
item_sep=>" :: ");
# multi-level list
my $html_links = link_tree(
current_url=>$url,
link_tree=>\@list_of_lists,
labels=>\%labels,
descriptions=>\%desc);
# DESCRIPTION
This module contains a number of functions for taking sets of URLs and
labels and creating suitably formatted HTML. These links are "smart"
because, if given the url of the current page, if any of the links in
the list equal it, that item in the list will be formatted as a special
label, not as a link; this is a Good Thing, since the user would be
confused by clicking on a link back to the current page.
While many website systems have plugins for "smart" navbars, they are
specialized for that system only, and can't be reused elsewhere, forcing
people to reinvent the wheel. I hereby present one wheel, free to be
reused by anybody; just the simple functions, a backend, which can be
plugged into whatever system you want.
The default format for the HTML is to make an unordered list, but there
are many options, enabling one to have a flatter layout with any
separators you desire, or a more complicated list with differing
formats for different levels.
The "link\_list" function uses a simple list of links -- good for a
simple navbar.
The "link\_tree" function takes a set of nested links and makes the HTML
for them -- good for making a table of contents, or a more complicated
navbar.
The "full\_tree" function takes a list of paths and makes a full tree of
all the pages and index-pages in those paths -- good for making a site
map.
The "breadcrumb\_trail" function takes a url and makes a "breadcrumb trail"
from it.
The "nav\_tree" function creates a set of nested links to be
used as a multi-level navbar; one can give it a list of paths
(as for full\_tree) and it will only show the links related
to the current URL.
# FUNCTIONS
To export a function, add it to the 'use' call.
use HTML::LinkList qw(link_list);
To export all functions do:
use HTML::LinkList ':all';
## link\_list
$links = link_list(
current_url=>$url,
urls=>\@links_in_order,
labels=>\%labels,
descriptions=>\%desc,
pre_desc=>' ',
post_desc=>'',
links_head=>'',
pre_item=>'',
post_item=>''
pre_active_item=>'',
post_active_item=>'',
item_sep=>"\n");
Generates a simple list of links, from list of urls
(and optional labels) taking into account of the "current" URL.
This provides a large number of options to customize the appearance
of the list. The default setup is for a simple UL list, but setting
the options can enable you to make it something other than a list
altogether, or add in CSS styles or classes to make it look just
like you want.
Required:
- urls
The urls in the order you want them displayed. If this list
is empty, then nothing will be generated.
Options:
- current\_url
The link to the current page. If one of the links equals this,
then that is deemed to be the "active" link and is just displayed
as a label rather than a link.
- descriptions
Optional hash of descriptions, to put next to the links. The keys
of this hash are the urls.
- hide\_ext
If a site is hiding link extensions (such as using MultiViews with
Apache) you may wish to hide the extensions (while using the full URLs
to check various things). (default: 0 (false))
- item\_sep
String to put between items.
- labels
A hash whose keys are links and whose values are labels.
These are the labels for the links; if no label
is given, then the last part of the link is used
for the label, with some formatting.
- links\_head
String to begin the list with.
- links\_foot
String to end the list with.
- pre\_desc
String to prepend to each description.
- post\_desc
String to append to each description.
- pre\_item
String to prepend to each item.
- post\_item
String to append to each item.
- pre\_active\_item
An additional string to put in front of each "active" item, after pre\_item.
The "active" item is the link which matches 'current\_url'.
- pre\_item\_active
INSTEAD of the "pre\_item" string, use this string for active items
- post\_active\_item
An additional string to append to each active item, before post\_item.
- prefix\_url
A prefix to prepend to all the links. (default: empty string)
## link\_tree
$links = link_tree(
current_url=>$url,
link_tree=>\@list_of_lists,
labels=>\%labels,
descriptions=>\%desc,
pre_desc=>' ',
post_desc=>'',
links_head=>'',
subtree_head=>'',
pre_item=>'',
post_item=>''
pre_active_item=>'',
post_active_item=>'',
item_sep=>"\n",
tree_sep=>"\n",
formats=>\%formats);
Generates nested lists of links from a list of lists of links.
This is useful for things such as table-of-contents or
site maps.
By default, this will return UL lists, but this is highly
configurable.
Required:
- link\_tree
A list of lists of urls, in the order you want them displayed.
If a url is not in this list, it will not be displayed.
Options:
- current\_url
The link to the current page. If one of the links equals this,
then that is deemed to be the "active" link and is just displayed
as a label rather than a link.
- descriptions
Optional hash of descriptions, to put next to the links. The keys
of this hash are the urls.
- exclude\_root\_parent
If this is true, then the "current\_parent" display options are
not used for the "root" ("/") path, it isn't counted as a "parent"
of the current\_url.
- formats
A reference to a hash containing advanced format settings. For example:
my %formats = (
# level 1 and onwards
'1' => {
tree_head=>"",
tree_foot=>"
\n",
},
# level 2 and onwards
'2' => {
tree_head=>"\n",
},
# level 3 and onwards
'3' => {
pre_item=>'(',
post_item=>')',
item_sep=>",\n",
tree_sep=>' -> ',
tree_head=>"
\n",
tree_foot=>"",
}
);
The formats hash enables you to control the formatting on a per-level basis.
Each key of the hash corresponds to a level-number; the sub-hashes contain
format arguments which will apply from that level onwards. If an argument
isn't given in the sub-hash, then it will fall back to the previous level
(or to the default, if there is no setting for that format-argument
for a previous level).
The only difference between the names of the arguments in the sub-hash and
in the global format arguments is that instead of 'subtree\_head' and subtree\_foot'
it uses 'tree\_head' and 'tree\_foot'.
- hide\_ext
If a site is hiding link extensions (such as using MultiViews with
Apache) you may wish to hide the extensions (while using the full URLs
to check various things). (default: 0 (false))
- item\_sep
The string to separate each item.
- labels
A hash whose keys are links and whose values are labels.
These are the labels for the links; if no label
is given, then the last part of the link is used
for the label, with some formatting.
- links\_head
The string to prepend the top-level tree with.
(default: )
- links\_foot
The string to append to the top-level tree.
(default:
)
- pre\_desc
String to prepend to each description.
- post\_desc
String to append to each description.
- pre\_item
String to prepend to each item.
(default: )
- post\_item
String to append to each item.
(default: )
- pre\_active\_item
An additional string to put in front of each "active" item, after pre\_item.
The "active" item is the link which matches 'current\_url'.
(default: )
- pre\_item\_active
INSTEAD of the "pre\_item" string, use this string for active items
- post\_active\_item
An additional string to append to each active item, before post\_item.
(default: )
- pre\_current\_parent
An additional string to put in front of a link which is a parent
of the 'current\_url' link, after pre\_item.
- pre\_item\_current\_parent
INSTEAD of the "pre\_item" string, use this for links which are parents
of the 'current\_url' link.
- post\_current\_parent
An additional string to append to a link which is a parent
of the 'current\_url' link, before post\_item.
- prefix\_url
A prefix to prepend to all the links. (default: empty string)
- subtree\_head
The string to prepend to lower-level trees.
(default: )
- subtree\_foot
The string to append to lower-level trees.
(default:
)
- tree\_sep
The string to separate each tree.
## full\_tree
$links = full_tree(
paths=>\@list_of_paths,
labels=>\%labels,
descriptions=>\%desc,
hide=>$hide_regex,
nohide=>$nohide_regex,
start_depth=>0,
end_depth=>0,
top_level=>0,
preserve_order=>0,
preserve_paths=>0,
...
);
Given a set of paths this will generate a tree of links in the style of
_link\_tree_. This will figure out all the intermediate paths and construct
the nested structure for you, clustering parents and children together.
The formatting options are as for ["link\_tree"](#link_tree).
Required:
- paths
A reference to a list of paths: that is, URLs relative to the top
of the site.
For example, if the full URL is http://www.example.com/foo.html
then the path is /foo.html
If the full URL is http://www.example.com/~frednurk/foo.html
then the path is /foo.html
This does not require that every possible path be given; all the intermediate
paths will be figured out from the list.
Options:
- append\_list
Array of paths to append to the top-level links. They are used
as-is, and are not part of the processing done to the "paths" list
of paths. (see ["prepend\_list"](#prepend_list))
- descriptions
Optional hash of descriptions, to put next to the links. The keys
of this hash are the paths.
- end\_depth
End your tree at this depth. If zero, then go all the way.
(see ["start\_depth"](#start_depth))
- exclude\_root\_parent
If this is true, then the "current\_parent" display options are
not used for the "root" ("/") path, it isn't counted as a "parent"
of the current\_url.
- hide
If the path matches this string, don't include it in the tree.
- hide\_ext
If a site is hiding link extensions (such as using MultiViews with
Apache) you may wish to hide the extensions (while using the full URLs
to check various things). (default: 0 (false))
- labels
Hash containing replacement labels for one or more paths.
If no label is given for '/' (the root path) then 'Home' will
be used.
- last\_subtree\_head
The string to prepend to the last lower-level tree.
Only used if end\_depth is not zero.
- last\_subtree\_foot
The string to append to the last lower-level tree.
Only used if end\_depth is not zero.
- nohide
If the path matches this string, it will be included even if it matches
the 'hide' string.
- prefix\_url
A prefix to prepend to all the links. (default: empty string)
- prepend\_list
Array of paths to prepend to the top-level links. They are used
as-is, and are not part of the processing done to the "paths" list
of paths.
- preserve\_order
Preserve the ordering of the paths in the input list of paths;
otherwise the links will be sorted alphabetically. Note that if
preserve\_order is true, the structure is at the whims of the order
of the original list of paths, and so could end up odd-looking.
(default: false)
- preserve\_paths
Do not extract intermediate paths or reorder the input list of paths.
This speeds things up, but assumes that the input paths are complete
and in good order.
(default: false)
- start\_depth
Start your tree at this depth. Zero is the root, level 1 is the
files/sub-folders in the root, and so on.
(default: 0)
- top\_level
Decide which level is the "top" level. Useful when you
set the start\_depth to something greater than 1.
## breadcrumb\_trail
$links = breadcrumb_trail(
current_url=>$url,
labels=>\%labels,
descriptions=>\%desc,
links_head=>'',
links_foot=>"\n
",
subtree_head=>'',
subtree_foot=>"\n",
pre_item=>'',
post_item=>'',
pre_active_item=>'',
post_active_item=>'',
item_sep=>"\n",
tree_sep=>' > ',
...
);
Given the current url, make a breadcrumb trail from it.
By default, this is laid out with '>' separators, but it can
be set up to give a nested set of UL lists (as for ["full\_tree"](#full_tree)).
The formatting options are as for ["link\_tree"](#link_tree).
Required:
- current\_url
The current url to be made into a breadcrumb-trail.
Options:
- descriptions
Optional hash of descriptions, to put next to the links. The keys
of this hash are the urls.
- exclude\_root\_parent
If this is true, then the "current\_parent" display options are
not used for the "root" ("/") path, it isn't counted as a "parent"
of the current\_url.
- hide\_ext
If a site is hiding link extensions (such as using MultiViews with
Apache) you may wish to hide the extensions (while using the full URLs
to check various things). (default: 0 (false))
- labels
Hash containing replacement labels for one or more URLS.
If no label is given for '/' (the root path) then 'Home' will
be used.
## nav\_tree
$links = nav_tree(
paths=>\@list_of_paths,
labels=>\%labels,
current_url=>$url,
hide=>$hide_regex,
nohide=>$nohide_regex,
preserve_order=>1,
descriptions=>\%desc,
...
);
This takes a list of links, and the current URL, and makes a nested navigation
tree, consisting of (a) the top-level links (b) the links leading to the
current URL (c) the links on the same level as the current URL,
(d) the related links just above this level, depending on whether
this is an index-page or a content page.
Optionally one can hide links which match match the 'hide' option.
The formatting options are as for ["link\_tree"](#link_tree), with some additions.
Required:
- current\_url
The link to the current page. If one of the links equals this, then that
is deemed to be the "active" link and is just displayed as a label rather
than a link. This is also used to determine which links to show and which
ones to filter out.
- paths
A reference to a list of paths: that is, URLs relative to the top
of the site.
For example, if the full URL is http://www.example.com/foo.html
then the path is /foo.html
This does not require that every possible path be given; all the intermediate
paths will be figured out from the list.
Options:
- append\_list
Array of paths to append to the top-level links. They are used
as-is, and are not part of the processing done to the "paths" list
of paths. (see ["prepend\_list"](#prepend_list))
- descriptions
Optional hash of descriptions, to put next to the links. The keys
of this hash are the paths.
- end\_depth
End your tree at this depth. If zero, then go all the way.
By default this is set to the depth of the current\_url.
- exclude\_root\_parent
If this is true, then the "current\_parent" display options are
not used for the "root" ("/") path, it isn't counted as a "parent"
of the current\_url.
- hide
If a path matches this string, don't include it in the tree.
- hide\_ext
If a site is hiding link extensions (such as using MultiViews with
Apache) you may wish to hide the extensions (while using the full URLs
to check various things). (default: 0 (false))
- labels
Hash containing replacement labels for one or more paths.
If no label is given for '/' (the root path) then 'Home' will
be used.
- last\_subtree\_head
The string to prepend to the last lower-level tree.
- last\_subtree\_foot
The string to append to the last lower-level tree.
- nohide
If the path matches this string, it will be included even if it matches
the 'hide' string.
- prefix\_url
A prefix to prepend to all the links. (default: empty string)
- prepend\_list
Array of paths to prepend to the top-level links. They are used
as-is, and are not part of the processing done to the "paths" list
of paths.
- preserve\_order
Preserve the ordering of the paths in the input list of paths;
otherwise the links will be sorted alphabetically.
(default: true)
- preserve\_paths
Do not extract intermediate paths or reorder the input list of paths.
This speeds things up, but assumes that the input paths are complete
and in good order.
(default: false)
- start\_depth
Start your tree at this depth. Zero is the root, level 1 is the
files/sub-folders in the root, and so on.
(default: 1)
- top\_level
Decide which level is the "top" level. Useful when you
set the start\_depth to something greater than 1.
# Private Functions
These functions cannot be exported.
## make\_item
$item = make\_item(
this\_label=>$label,
this\_link=>$link,
hide\_ext=>0,
current\_url=>$url,
current\_parents=>\\%current\_parents,
descriptions=>\\%desc,
format=>\\%format,
);
%format = (
pre\_desc=>' ',
post\_desc=>'',
pre\_item=>'',
post\_item=>''
pre\_active\_item=>'',
post\_active\_item=>'',
pre\_current\_parent=>'',
post\_current\_parent=>'',
item\_sep=>"\\n");
);
Format a link item.
See ["link\_list"](#link_list) for the formatting options.
- this\_label
The label of the required link. If there is no label,
this uses the base-name of the last part of the link,
capitalizing it and replacing underscores and dashes with spaces.
- this\_link
The URL of the required link.
- current\_url
The link to the current page. If one of the links equals this,
then that is deemed to be the "active" link and is just displayed
as a label rather than a link.
- current\_parents
URLs of the parents of the current item.
- descriptions
Optional hash of descriptions, to put next to the links. The keys
of this hash are the links (not the labels).
- defer\_post\_item
Don't add the 'post\_item' string if this is true.
(needed for nested lists)
(default: false)
- no\_link
Don't make a link for this, just a label.
## make\_canonical
my $new\_url = make\_canonical($url);
Make a URL canonical; remove the 'index.\*' and add on a needed
'/' -- this assumes that directory names never have a '.' in them.
## get\_index\_path
my $new\_url = get\_index\_path($url);
Get the "index" part of this path. That is, if this path
is not for an index-page, then get the parent index-page
path for this path.
(Removes the trailing slash).
## get\_index\_parent
my $new\_url = get\_index\_parent($url);
Get the parent of the "index" part of this path.
(Removes the trailing slash).
## path\_depth
my $depth = path\_depth($url);
Calculate the "depth" of the given path.
## link\_is\_active
if (link_is_active(this_link=>$link, current_url=>$url))
...
Check if the given link is "active", that is, if it
matches the 'current\_url'.
## traverse\_lol
$links = traverse\_lol(\\@list\_of\_lists,
labels=>\\%labels,
tree\_depth=>$depth
current\_format=>\\%format,
...
);
Traverse the list of lists (of urls) to produce
a nested collection of links.
This consumes the list\_of\_lists!
## extract\_all\_paths
my @all\_paths = extract\_all\_paths(paths=>\\@paths,
preserve\_order=>0);
Extract all possible paths out of a list of paths.
Thus, if one has
/foo/bar/baz.html
then that would make
/
/foo/
/foo/bar/
/foo/bar/baz.html
If 'preserve\_order' is true, this preserves the ordering of
the paths in the input list; otherwise the output paths
are sorted alphabetically.
## extract\_current\_parents
my %current_parents = extract_current_parents(current_url=>$url,
exclude_root_parent=>0);
Extract the "parent" paths of the current url
/foo/bar/baz.html
then that would make
/
/foo/
/foo/bar/
If 'exclude\_root\_parent' is true, then the '/' is excluded from the
list of parents.
## build\_lol
my @lol = build_lol(
paths=>\@paths,
current_url=>$url,
navbar_type=>'',
);
Build a list of lists of paths, given a simple list of paths.
Assumes that this list has already been filtered.
- paths
Reference to list of paths; this is consumed.
## filter\_out\_paths
my @filtered_paths = filter_out_paths(
paths=>\@paths,
current_url=>$url,
hide=>$hide,
nohide=>$nohide,
start_depth=>$start_depth,
end_depth=>$end_depth,
top_level=>$top_level,
navbar_type=>'',
);
Filter out the paths we don't want from our list of paths.
Returns a list of the paths we want.
## make\_default\_format
my %default_format = make_default_format(%args);
Make the default format hash from the args.
Returns a hash of format options.
## make\_extra\_formats
my %formats = make_extra_formats(%args);
Transforms the subtree\_head and subtree\_foot into the "formats"
method of formatting.
Returns a hash of hashes of format options.
# REQUIRES
Test::More
# INSTALLATION
To install this module, run the following commands:
perl Build.PL
./Build
./Build test
./Build install
Or, if you're on a platform (like DOS or Windows) that doesn't like the
"./" notation, you can do this:
perl Build.PL
perl Build
perl Build test
perl Build install
In order to install somewhere other than the default, such as
in a directory under your home directory, like "/home/fred/perl"
go
perl Build.PL --install_base /home/fred/perl
as the first step instead.
This will install the files underneath /home/fred/perl.
You will then need to make sure that you alter the PERL5LIB variable to
find the modules.
Therefore you will need to change the PERL5LIB variable to add
/home/fred/perl/lib
PERL5LIB=/home/fred/perl/lib:${PERL5LIB}
# SEE ALSO
perl(1).
# BUGS
Please report any bugs or feature requests to the author.
# AUTHOR
Kathryn Andersen (RUBYKAT)
perlkat AT katspace dot com
http://www.katspace.com/tools/html_linklist/
# COPYRIGHT AND LICENCE
Copyright (c) 2006 by Kathryn Andersen
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
MANIFEST.SKIP 100644 001750 001751 542 12641340604 14557 0 ustar 00kat kat 000000 000000 HTML-LinkList-0.1701 # Version control files and dirs.
\bRCS\b
\bCVS\b
,v$
^_darcs/
^\.git/
^\.gitignore$
# Dev
^\.todo$
^dist.ini$
# distro files
^HTML-LinkList-*
# ExtUtils::MakeMaker generated files and dirs.
^Makefile$
^blib/
^blibdirs$
^pm_to_blib$
^MakeMaker-\d
# Module::Build
^Build$
^_build/
# Temp, old, vi and emacs files.
~$
\.old$
^#.*#$
^\.#
\.swp$
\.bak$
t 000755 001750 001751 0 12641340604 13003 5 ustar 00kat kat 000000 000000 HTML-LinkList-0.1701 00-compile.t 100644 001750 001751 2121 12641340604 15171 0 ustar 00kat kat 000000 000000 HTML-LinkList-0.1701/t use 5.006;
use strict;
use warnings;
# this test was generated with Dist::Zilla::Plugin::Test::Compile 2.052
use Test::More;
plan tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
my @module_files = (
'HTML/LinkList.pm'
);
# no fake home requested
my $inc_switch = -d 'blib' ? '-Mblib' : '-Ilib';
use File::Spec;
use IPC::Open3;
use IO::Handle;
open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!";
my @warnings;
for my $lib (@module_files)
{
# see L
my $stderr = IO::Handle->new;
my $pid = open3($stdin, '>&STDERR', $stderr, $^X, $inc_switch, '-e', "require q[$lib]");
binmode $stderr, ':crlf' if $^O eq 'MSWin32';
my @_warnings = <$stderr>;
waitpid($pid, 0);
is($?, 0, "$lib loaded ok");
if (@_warnings)
{
warn @_warnings;
push @warnings, @_warnings;
}
}
is(scalar(@warnings), 0, 'no warnings found')
or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING};
50_nav_tree.t 100644 001750 001751 31735 12641340604 15470 0 ustar 00kat kat 000000 000000 HTML-LinkList-0.1701/t # testing nav_tree
use strict;
use Test::More tests => 26;
use HTML::LinkList qw(nav_tree);
#=====================================================================
sub make_test_html {
my %args = (
test_name=>'nav_tree',
test_count=>0,
link_html=>'',
ok_str=>'',
@_
);
if ($args{link_html} ne $args{ok_str})
{
my $test_file = "${args{test_name}}${args{test_count}}.html";
open(HTML, ">", $test_file)
or die "could not open $test_file for writing";
print HTML<
$args{test_name}
$args{test_name}
Got:
$args{link_html}
Wanted:
$args{ok_str}