Commit bf6a8a1a authored by Dries's avatar Dries

- Patch #1468582 by Schnitzel, lewisnyman, dcmouyard, alanburke, tstoeckler,...

- Patch #1468582 by Schnitzel, lewisnyman, dcmouyard, alanburke, tstoeckler, edward_or, janusman: Add mobile friendly meta tags to the html.tpl.php.
parent d4cf9121
...@@ -2546,6 +2546,9 @@ function template_preprocess_html(&$variables) { ...@@ -2546,6 +2546,9 @@ function template_preprocess_html(&$variables) {
$variables['head_title_array'] = $head_title; $variables['head_title_array'] = $head_title;
$variables['head_title'] = implode(' | ', $head_title); $variables['head_title'] = implode(' | ', $head_title);
// Display the html.tpl.php’s default mobile metatags for responsive design.
$variables['default_mobile_metatags'] = TRUE;
// Populate the page template suggestions. // Populate the page template suggestions.
if ($suggestions = theme_get_suggestions(arg(), 'html')) { if ($suggestions = theme_get_suggestions(arg(), 'html')) {
$variables['theme_hook_suggestions'] = $suggestions; $variables['theme_hook_suggestions'] = $suggestions;
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
* - slogan: The slogan of the site, if any, and if there is no title. * - slogan: The slogan of the site, if any, and if there is no title.
* - $head: Markup for the HEAD section (including meta tags, keyword tags, and * - $head: Markup for the HEAD section (including meta tags, keyword tags, and
* so on). * so on).
* - $default_mobile_metatags: TRUE if default mobile metatags for responsive
* design should be displayed.
* - $styles: Style tags necessary to import all CSS files for the page. * - $styles: Style tags necessary to import all CSS files for the page.
* - $scripts: Script tags necessary to load the JavaScript files and settings * - $scripts: Script tags necessary to load the JavaScript files and settings
* for the page. * for the page.
...@@ -43,6 +45,12 @@ ...@@ -43,6 +45,12 @@
<html<?php print $html_attributes; ?>> <html<?php print $html_attributes; ?>>
<head> <head>
<?php print $head; ?> <?php print $head; ?>
<?php if ($default_mobile_metatags): ?>
<meta name="MobileOptimized" content="width" />
<meta name="HandheldFriendly" content="true" />
<meta name="viewport" content="width=device-width" />
<meta http-equiv="cleartype" content="on" />
<?php endif; ?>
<title><?php print $head_title; ?></title> <title><?php print $head_title; ?></title>
<?php print $styles; ?> <?php print $styles; ?>
<?php print $scripts; ?> <?php print $scripts; ?>
......
...@@ -946,6 +946,47 @@ class AdminMetaTagTestCase extends DrupalWebTestCase { ...@@ -946,6 +946,47 @@ class AdminMetaTagTestCase extends DrupalWebTestCase {
} }
} }
class DefaultMobileMetaTagsTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Default mobile meta tags',
'description' => 'Confirm that the default mobile meta tags appear as expected.',
'group' => 'System'
);
}
function setUp() {
parent::setUp();
$this->default_metatags = array(
'MobileOptimized' => '<meta name="MobileOptimized" content="width" />',
'HandheldFriendly' => '<meta name="HandheldFriendly" content="true" />',
'viewport' => '<meta name="viewport" content="width=device-width" />',
'cleartype' => '<meta http-equiv="cleartype" content="on" />'
);
}
/**
* Verifies that the default mobile meta tags are added.
*/
public function testDefaultMetaTagsExist() {
$this->drupalGet('');
foreach ($this->default_metatags as $name => $metatag) {
$this->assertRaw($metatag, 'Default Mobile meta tag "' . $name . '" displayed properly.', t('System'));
}
}
/**
* Verifies that the default mobile meta tags can be removed.
*/
public function testRemovingDefaultMetaTags() {
module_enable(array('system_module_test'));
$this->drupalGet('');
foreach ($this->default_metatags as $name => $metatag) {
$this->assertNoRaw($metatag, 'Default Mobile meta tag "' . $name . '" removed properly.', t('System'));
}
}
}
/** /**
* Tests custom access denied functionality. * Tests custom access denied functionality.
*/ */
......
name = "System test"
description = "Provides hook implementations for testing System module functionality."
package = Testing
version = VERSION
core = 8.x
hidden = TRUE
<?php
/**
* @file
* Provides System module hook implementations for testing purposes.
*/
function system_module_test_preprocess_html(&$variables) {
$variables['default_mobile_metatags'] = FALSE;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment