humanstxt.module in Humans.txt 8
Same filename and directory in other branches
Humanstxt module file.
File
humanstxt.moduleView source
<?php
/**
* @file
* Humanstxt module file.
*/
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
/**
* Implements hook_help().
*/
function humanstxt_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.humanstxt':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Helper module to place and manage a <em>humans.txt
</em> file in your site.') . '</p>';
$output .= '<p>' . t('For more information, visit the main site of the
project <a href=":url">Humans.txt</a>.', [
':url' => 'http://humanstxt.org/',
]) . '</p>';
$output .= '<p>' . t('You can see an example of the humans.txt file
<a href=":example">here</a>.', [
':example' => 'http://humanstxt.org/humans.txt',
]) . '</p>';
$output .= '<h3>' . t('Questions') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('What is humans.txt?') . '</dt>';
$output .= '<dd>' . t('It is an initiative for knowing the people behind a
website, Is a TXT file that contains information
about the different people who have contributed to
building the website.') . '</dd>';
$output .= '<dt>' . t('Who should I mention?') . '</dt>';
$output .= '<dd>' . t('Whoever you want to, provided they wish you to do
so. You can mention the developer, the designer,
the copywriter, the webmaster, the SEO, SEM or
SMO... As you can see, the number of people who may
take part of the creation of a site can be big, so
the list is almost endless.') . '</dd>';
$output .= '<dt>' . t('Internet is for humans...') . '</dt>';
$output .= '<dd>' . t('We are always saying that, but the only file we
generate is one full of additional information for
the searchbots: robots.txt. Then why not doing one
for ourselves?') . '</dd>';
$output .= '</dl>';
return $output;
}
}
/**
* Implements hook_page_attachments().
*/
function humanstxt_page_attachments(array &$attachments) {
// Check the current value of the config item to insert the link.
if (\Drupal::config('humanstxt.settings')
->get('display_link')) {
// Add a new head link tag.
// @see \Drupal\render_attached_test\Controller\RenderAttachedTestController::htmlHeaderLink
$attachments['#attached']['html_head_link'][] = [
[
'rel' => 'author',
'type' => 'text/plain',
'hreflang' => 'x-default',
'href' => Url::fromRoute('humanstxt.content', [], [
'absolute' => TRUE,
])
->toString(),
],
TRUE,
];
}
}
Functions
Name | Description |
---|---|
humanstxt_help | Implements hook_help(). |
humanstxt_page_attachments | Implements hook_page_attachments(). |