NAME
HTML::Meta::Robots - A simple HTML meta tag "robots" generator.
VERSION
v0.3
SYNOPSIS
use HTML::Meta::Robots;
# Default "robots" as meta tag element.
my $robots = HTML::Meta::Robots->new;
print sprintf '<html><head>%s</head></html>', $robots->meta;
# Default "robots" as meta tag content.
my $robots = HTML::Meta::Robots->new;
printf '<html><head><meta name="robots" content="%s"/></head></html>', $robots->content;
# Do not "allow" creation of google snippets.
my $robots = HTML::Meta::Robots->new;
$robots->snippet(0);
# Do not "allow" creation of google snippets and indexing by the Yahoo crawler.
my $robots = HTML::Meta::Robots->new;
$robots->snippet(0);
$robots->ydir(0);
# on as one-liner:
$robots->snippet(0)->ydir(0);
# What is the indexing state of the Open Directory Project?
my $robots = HTML::Meta::Robots->new;
printf "It's %s\n", $robots->odp ? 'allowed' : 'denied';
DESCRIPTION
HTML::Meta::Robots is a simple helper object for generating HTML "robot" meta tags such as:
<meta name="robots" content="index,allow"/>
HTML::Meta::Robots currently supports the following "robots" attributes:
- (no)index
-
Allows or denies any search engine to index the page.
- (no)follow
-
Allows or denies any search engine to follow links on the page.
- (no)archive
-
Allows or denies the Internet Archive to cache the page.
- (no)odp
-
Allows or denies the Open Directory Project search engine to index the page.
- (no)ydir
-
Allows or denies the Yahoo search engine to index the page.
- (no)snippet
-
Allows or denies the Google search engine to display an abstract of the page and at the same time to cache the page.
Why don't use Moo(se)?
Yes, I could reduce a lot of the code by using Moo(se). However I decided to not use Moo(se) because of my own experience with "more strict" corporation. The problem is that some corporation have to review the code they use for security reasons including all dependencies. Some handlers require this in order to handle corporation data such as credit cards (PCI-DSS). Doing a security review is kind of boring and take a lot of valuable time for the corporation so I have written this Module with no-deps.
METHODS
new
Creates and returns a new HTML::Meta::Robots object. For example:
my $robots = HTML::Meta::Robots->new;
Optional parameters are:
- index => (1|0)
-
See "index" for details.
- follow => (1|0)
-
See "follow" for details.
- archive => (1|0)
-
See "archive" for details.
- odp => (1|0)
-
See "odp" for details.
- ydir => (1|0)
-
See "ydir" for details.
- snippet => (1|0)
-
See "snippet" for details.
index
Get or set the index state. For example:
# Retrieve index state:
my $state = $robots->index;
# Set index state to allow:
$robots->index(1);
# Set index state to deny:
$robots->index(0);
Note, that index
will apply its state to all the other attributes when called as setter!
follow
Get or set the follow state. For example:
# Retrieve follow state:
my $state = $robots->follow;
# Set follow state to allow:
$robots->follow(1);
# Set follow state to deny:
$robots->follow(0);
archive
Get or set the archive state. For example:
# Retrieve archive state:
my $state = $robots->archive;
# Set archive state to allow:
$robots->archive(1);
# Set follow state to deny:
$robots->archive(0);
open_directory_project
DEPRECATED - See "odp".
odp
Get or set the Open Directory Project state. For example:
# Retrieve archive state:
my $state = $robots->odp;
# Set open_directory_project state to allow:
$robots->odp(1);
# Set open_directory_project state to deny:
$robots->odp(0);
yahoo
DEPRECATED - See "odp".
ydir
Get or set the Yahoo state. For example:
# Retrieve yahoo state:
my $state = $robots->ydir;
# Set yahoo state to allow:
$robots->ydir(1);
# Set yahoo state to deny:
$robots->ydir(0);
snippet
Get or set the snippet state. For example:
# Retrieve snippet state:
my $state = $robots->snippet;
# Set snippet state to allow:
$robots->snippet(1);
# Set snippet state to deny:
$robots->snippet(0);
content
Returns the content part of an HTML robots meta tag. For example:
printf '<html><head><meta name="robots" content="%s"/></head></html>', $robots->content;
meta
Returns a string representing a full HTML robots meta tag. For example:
printf '<html><head>%s</head></html>', $robots->meta;
parse
Returns the content part of an HTML robots meta tag. For example:
my $content = 'noindex,follow,archive,odp,ydir,snippet';
my $robots = HTML::Meta::Robots->new->parse($content);
printf "%s is %sed\n", 'index', $robots->index ? 'allow' : 'deny';
printf "%s is %sed\n", 'follow', $robots->follow ? 'allow' : 'deny';
BUGS AND LIMITATIONS
Report bugs and feature requests as a GitHub Issue, please.
AUTHOR
But there are more people who have contributed to HTML::Meta::Robots:
LICENSE
HTML::Meta::Robots by BURNERSK is licensed under a Artistic 2.0 License.
COPYRIGHT
Copyright © 2013, BURNERSK. Some rights reserved.