diff --git a/metatag_facebook/metatag_facebook.module b/metatag_facebook/metatag_facebook.module index 5ecdf50..d4942cb 100644 --- a/metatag_facebook/metatag_facebook.module +++ b/metatag_facebook/metatag_facebook.module @@ -13,6 +13,13 @@ function metatag_facebook_ctools_plugin_api($owner, $api) { } } +/** + * Implements hook_preprocess_html(). + */ +function metatag_facebook_preprocess_html(&$variables) { + $variables['rdf_namespaces'] .= "\n xmlns:fb=\"http://ogp.me/ns/fb#\""; +} + /* fb:admins fb:app_id diff --git a/metatag_opengraph/metatag_opengraph.metatag.inc b/metatag_opengraph/metatag_opengraph.metatag.inc index c1101be..46d58b5 100644 --- a/metatag_opengraph/metatag_opengraph.metatag.inc +++ b/metatag_opengraph/metatag_opengraph.metatag.inc @@ -40,8 +40,11 @@ function metatag_opengraph_metatag_bundled_config_alter(array &$configs) { case 'node': $config->config += array( + 'article:modified_time' => array('value' => '[node:changed:custom:c]'), + 'article:published_time' => array('value' => '[node:created:custom:c]'), 'og:description' => array('value' => '[node:summary]'), 'og:title' => array('value' => '[node:title]'), + 'og:updated_time' => array('value' => '[node:changed:custom:c]'), ); break; @@ -56,6 +59,7 @@ function metatag_opengraph_metatag_bundled_config_alter(array &$configs) { $config->config += array( 'og:title' => array('value' => '[user:name]'), 'og:type' => array('value' => 'profile'), + 'profile:username' => array('value' => '[user:name]'), ); if (variable_get('user_pictures')) { $config->config += array( @@ -92,26 +96,14 @@ function metatag_opengraph_metatag_info() { $weight = 25; $info['tags']['og:site_name'] = array( - 'label' => t('Open Graph site name'), + 'label' => t('Site name'), 'description' => t('A human-readable name for your site, e.g., IMDb.'), 'context' => array('global'), 'weight' => ++$weight, ) + $tag_info_defaults; - $info['tags']['og:title'] = array( - 'label' => t('Open Graph title'), - 'description' => t('The title of your object as it should appear within the graph, e.g., The Rock.'), - 'weight' => ++$weight, - ) + $tag_info_defaults; - - $info['tags']['og:description'] = array( - 'label' => t('Open Graph description'), - 'description' => t('A one to two sentence description of your page.'), - 'weight' => ++$weight, - ) + $tag_info_defaults; - $info['tags']['og:type'] = array( - 'label' => t('Open Graph type'), + 'label' => t('Content type'), 'description' => t('The type of your object, e.g., movie.'), 'weight' => ++$weight, 'form' => array( @@ -119,6 +111,18 @@ function metatag_opengraph_metatag_info() { '#options' => _metatag_opengraph_type_options(), '#empty_option' => t('- None -'), ), + 'devel_generate' => array( + 'type' => 'select', + ), + ) + $tag_info_defaults; + + $info['tags']['og:url'] = array( + 'label' => t('Page URL'), + 'description' => t('The canonical URL of your object that will be used as its permanent ID in the graph, e.g., http://www.imdb.com/title/tt0117500/.'), + 'weight' => ++$weight, + 'devel_generate' => array( + 'type' => 'canonical', + ), ) + $tag_info_defaults; if (module_exists('select_or_other')) { @@ -130,19 +134,63 @@ function metatag_opengraph_metatag_info() { $info['tags']['og:type']['form']['#element_validate'] = array('select_or_other_element_validate'); } + $info['tags']['og:title'] = array( + 'label' => t('Content title'), + 'description' => t('The title of your object as it should appear within the graph, e.g., The Rock.'), + 'weight' => ++$weight, + ) + $tag_info_defaults; + + $info['tags']['og:determiner'] = array( + 'label' => t('Content title determiner'), + 'description' => t("The word that appears before the content's title in a sentence. The default ignores this value, the 'Automatic' value should be sufficient if this is actually needed."), + 'weight' => ++$weight, + 'form' => array( + '#type' => 'select', + '#options' => array( + 'auto' => 'Automatic', + 'a' => 'A', + 'an' => 'An', + 'the' => 'The', + ), + '#empty_option' => t('- Ignore -'), + ), + 'devel_generate' => array( + 'type' => 'select', + ), + ) + $tag_info_defaults; + + $info['tags']['og:description'] = array( + 'label' => t('Content description'), + 'description' => t('A one to two sentence description of your page.'), + 'weight' => ++$weight, + ) + $tag_info_defaults; + + // Basic tags. + $info['tags']['og:updated_time'] = array( + 'label' => t('Content modification date & time'), + 'description' => t("The date this content was last modified, with an optional time value. Needs to be in ISO 8601 format. Can be the same as the 'Article modification date' tag."), + 'weight' => ++$weight, + ) + $tag_info_defaults; + + $info['tags']['og:see_also'] = array( + 'label' => t('See also'), + 'description' => t('URLs to related content.'), + 'multiple' => TRUE, + 'weight' => ++$weight, + ) + $tag_info_defaults; + $info['tags']['og:image'] = array( - 'label' => t('Open Graph image'), - 'description' => t('An image URL which should represent your object within the graph. The image must be at least 50px by 50px and have a maximum aspect ratio of 3:1. Supports PNG, JPEG and GIF formats.'), + 'label' => t('Image URL'), + 'description' => t('The URL of an image which should represent your object within the graph. The image must be at least 50px by 50px and have a maximum aspect ratio of 3:1. Supports PNG, JPEG and GIF formats.'), 'multiple' => TRUE, 'weight' => ++$weight, 'devel_generate' => array( 'type' => 'image', ), ) + $tag_info_defaults; - $info['tags']['og:image:secure_url'] = array( - 'label' => t('Open Graph secure image'), - 'description' => t('A secure (HTTPS) image URL which should represent your object within the graph. The image must be at least 50px by 50px and have a maximum aspect ratio of 3:1. Supports PNG, JPEG and GIF formats. All "http://" URLs will automatically be converted to "https://".'), + 'label' => t('Secure image URL'), + 'description' => t('The secure URL (HTTPS) of an image which should represent your object within the graph. The image must be at least 50px by 50px and have a maximum aspect ratio of 3:1. Supports PNG, JPEG and GIF formats. All "http://" URLs will automatically be converted to "https://".'), 'multiple' => TRUE, 'secure' => TRUE, 'weight' => ++$weight, @@ -150,25 +198,40 @@ function metatag_opengraph_metatag_info() { 'type' => 'image', ), ) + $tag_info_defaults; - - $info['tags']['og:url'] = array( - 'label' => t('Open Graph URL'), - 'description' => t('The canonical URL of your object that will be used as its permanent ID in the graph, e.g., http://www.imdb.com/title/tt0117500/.'), + $info['tags']['og:image:type'] = array( + 'label' => t('Image type'), + 'description' => t('The type of image referenced above. Should be either "image/gif" for a GIF image, "image/jpeg" for a JPG/JPEG image, or "image/png" for a PNG image.'), + 'multiple' => TRUE, + 'weight' => ++$weight, + ) + $tag_info_defaults; + $info['tags']['og:image:width'] = array( + 'label' => t('Image width'), + 'description' => t('The width of the above image(s). Note: if both the unsecured and secured images are provided, they should both be the same size.'), + 'multiple' => TRUE, + 'weight' => ++$weight, + 'devel_generate' => array( + 'type' => 'image', + ), + ) + $tag_info_defaults; + $info['tags']['og:image:height'] = array( + 'label' => t('Image height'), + 'description' => t('The height of the above image(s). Note: if both the unsecured and secured images are provided, they should both be the same size.'), + 'multiple' => TRUE, 'weight' => ++$weight, 'devel_generate' => array( - 'type' => 'canonical', + 'type' => 'image', ), ) + $tag_info_defaults; $info['tags']['og:latitude'] = array( - 'label' => t('Open Graph Latitude'), + 'label' => t('Latitude'), 'weight' => ++$weight, 'devel_generate' => array( 'type' => 'float', ), ) + $tag_info_defaults; $info['tags']['og:longitude'] = array( - 'label' => t('Open Graph Longitude'), + 'label' => t('Longitude'), 'weight' => ++$weight, 'devel_generate' => array( 'type' => 'float', @@ -176,42 +239,42 @@ function metatag_opengraph_metatag_info() { ) + $tag_info_defaults; $info['tags']['og:street-address'] = array( - 'label' => t('Open Graph Street Address'), + 'label' => t('Street address'), 'weight' => ++$weight, ) + $tag_info_defaults; $info['tags']['og:locality'] = array( - 'label' => t('Open Graph Locality'), + 'label' => t('Locality'), 'weight' => ++$weight, ) + $tag_info_defaults; $info['tags']['og:region'] = array( - 'label' => t('Open Graph Region'), + 'label' => t('Region'), 'weight' => ++$weight, ) + $tag_info_defaults; $info['tags']['og:postal-code'] = array( - 'label' => t('Open Graph Postal Code'), + 'label' => t('Postal/ZIP code'), 'weight' => ++$weight, ) + $tag_info_defaults; $info['tags']['og:country-name'] = array( - 'label' => t('Open Graph Country Name'), + 'label' => t('Country name'), 'weight' => ++$weight, ) + $tag_info_defaults; $info['tags']['og:email'] = array( - 'label' => t('Open Graph Email'), + 'label' => t('Email'), 'weight' => ++$weight, 'devel_generate' => array( 'type' => 'email', ), ) + $tag_info_defaults; $info['tags']['og:phone_number'] = array( - 'label' => t('Open Graph Phone Number'), + 'label' => t('Phone number'), 'weight' => ++$weight, 'devel_generate' => array( 'type' => 'phone', ), ) + $tag_info_defaults; $info['tags']['og:fax_number'] = array( - 'label' => t('Open Graph Fax Number'), + 'label' => t('Fax number'), 'weight' => ++$weight, 'devel_generate' => array( 'type' => 'phone', @@ -219,24 +282,55 @@ function metatag_opengraph_metatag_info() { ) + $tag_info_defaults; $info['tags']['og:locale'] = array( - 'label' => t('Open Graph Locale'), - 'description' => 'The locale these tags are marked up in. Of the format language_TERRITORY. Default is en_US.', + 'label' => t('Locale'), + 'description' => 'The locale these tags are marked up in, must be in the format language_TERRITORY. Default is en_US.', 'weight' => ++$weight, 'devel_generate' => array( 'maxlength' => 1, ), ) + $tag_info_defaults; + $info['tags']['og:locale:alternate'] = array( + 'label' => t('Alternative locales'), + 'description' => 'Other locales this content is available in, must be in the format language_TERRITORY, e.g. "fr_FR".', + 'weight' => ++$weight, + 'multiple' => TRUE, + 'devel_generate' => array( + 'maxlength' => 1, + ), + ) + $tag_info_defaults; + + $info['tags']['og:audio'] = array( + 'label' => t('Audio URL'), + 'description' => t('The URL to an audio file that complements this object.'), + 'weight' => ++$weight, + 'devel_generate' => array( + 'type' => 'url', + ), + ) + $tag_info_defaults; + $info['tags']['og:audio:secure_url'] = array( + 'label' => t('Audio secure URL'), + 'description' => t('The secure URL to an audio file that complements this object. All "http://" URLs will automatically be converted to "https://".'), + 'weight' => ++$weight, + 'devel_generate' => array( + 'type' => 'url', + ), + ) + $tag_info_defaults; + $info['tags']['og:audio:type'] = array( + 'label' => t('Audio type'), + 'description' => t('The MIME type of the audio file. Examples include "application/mp3" for an MP3 file.'), + 'weight' => ++$weight, + ) + $tag_info_defaults; $info['tags']['og:video'] = array( - 'label' => t('Open Graph Video URL'), - 'description' => t('A URL to a video file that complements this object.'), + 'label' => t('Video URL'), + 'description' => t('The URL to a video file that complements this object.'), 'weight' => ++$weight, 'devel_generate' => array( 'type' => 'url', ), ) + $tag_info_defaults; $info['tags']['og:video:secure_url'] = array( - 'label' => t('Open Graph Video Secure URL'), + 'label' => t('Video secure URL'), 'description' => t('A URL to a video file that complements this object using the HTTPS protocol. All "http://" URLs will automatically be converted to "https://".'), 'secure' => TRUE, 'weight' => ++$weight, @@ -245,7 +339,7 @@ function metatag_opengraph_metatag_info() { ), ) + $tag_info_defaults; $info['tags']['og:video:width'] = array( - 'label' => t('Open Graph Video Width'), + 'label' => t('Video width'), 'description' => t('The width of the video.'), 'weight' => ++$weight, 'devel_generate' => array( @@ -253,7 +347,7 @@ function metatag_opengraph_metatag_info() { ), ) + $tag_info_defaults; $info['tags']['og:video:height'] = array( - 'label' => t('Open Graph Video Height'), + 'label' => t('Video height'), 'description' => t('The height of the video.'), 'weight' => ++$weight, 'devel_generate' => array( @@ -261,17 +355,94 @@ function metatag_opengraph_metatag_info() { ), ) + $tag_info_defaults; $info['tags']['og:video:type'] = array( - 'label' => t('Open Graph Video Type'), - 'description' => t('The type of the video file.'), - 'weight' => ++$weight, - 'form' => array( - '#type' => 'select', - '#options' => array( - 'application/x-shockwave-flash' => 'Flash - playable directly from the feed', - 'text/html' => 'Separate HTML page', - ), - '#empty_option' => t('- None -'), - ), + 'label' => t('Video type'), + 'description' => t('The MIME type of the video file. Examples include "application/x-shockwave-flash" for a Flash video, or "text/html" if this is a standalone web page containing a video.'), + 'weight' => ++$weight, + ) + $tag_info_defaults; + + // For the "article" og:type. + $info['tags']['article:author'] = array( + 'label' => t('Article author'), + 'description' => t("Links an article to an author's Facebook profile, should be either URLs to the author's profile page or their Facebook profile IDs."), + 'multiple' => TRUE, + 'weight' => ++$weight, + ) + $tag_info_defaults; + $info['tags']['article:publisher'] = array( + 'label' => t('Article publisher'), + 'description' => t("Links an article to a publisher's Facebook page."), + 'weight' => ++$weight, + ) + $tag_info_defaults; + $info['tags']['article:section'] = array( + 'label' => t('Article section'), + 'description' => t('The primary section of this website the content belongs to.'), + 'weight' => ++$weight, + ) + $tag_info_defaults; + $info['tags']['article:tag'] = array( + 'label' => t('Article tag(s)'), + 'description' => t('Appropriate keywords for this content.'), + 'multiple' => TRUE, + 'weight' => ++$weight, + ) + $tag_info_defaults; + $info['tags']['article:published_time'] = array( + 'label' => t('Article publication date & time'), + 'description' => t("The date this content was published on, with an optional time value. Needs to be in ISO 8601 format."), + 'weight' => ++$weight, + ) + $tag_info_defaults; + $info['tags']['article:modified_time'] = array( + 'label' => t('Article modification date & time'), + 'description' => t("The date this content was last modified, with an optional time value. Needs to be in ISO 8601 format."), + 'weight' => ++$weight, + ) + $tag_info_defaults; + $info['tags']['article:expiration_time'] = array( + 'label' => t('Article expiration date & time'), + 'description' => t("The date this content will expire, with an optional time value. Needs to be in ISO 8601 format."), + 'weight' => ++$weight, + ) + $tag_info_defaults; + + // For the "book" og:type. + $info['tags']['book:author'] = array( + 'label' => t("Book's author"), + 'description' => t("Links to the book's author's Facebook profile, should be either URLs to the author's profile page or their Facebook profile IDs."), + 'multiple' => TRUE, + 'weight' => ++$weight, + ) + $tag_info_defaults; + $info['tags']['book:isbn'] = array( + 'label' => t("Book's ISBN"), + 'description' => t("The book's International Standard Book Number, which may be in one of several formats."), + 'weight' => ++$weight, + ) + $tag_info_defaults; + $info['tags']['book:release_date'] = array( + 'label' => t('Book release date'), + 'description' => t("The date this content will expire, with an optional time value. Needs to be in ISO 8601 format."), + 'weight' => ++$weight, + ) + $tag_info_defaults; + $info['tags']['book:tag'] = array( + 'label' => t('Book tags'), + 'description' => t('Appropriate keywords for this book.'), + 'multiple' => TRUE, + 'weight' => ++$weight, + ) + $tag_info_defaults; + + // For the "profile" og:type. + $info['tags']['profile:first_name'] = array( + 'label' => t('First name'), + 'description' => t("The first name of the person who's Profile page this is."), + 'weight' => ++$weight, + ) + $tag_info_defaults; + $info['tags']['profile:last_name'] = array( + 'label' => t('Last name'), + 'description' => t("The person's last name."), + 'weight' => ++$weight, + ) + $tag_info_defaults; + $info['tags']['profile:username'] = array( + 'label' => t('Username'), + 'description' => t("A pseudonym / alias of this person."), + 'weight' => ++$weight, + ) + $tag_info_defaults; + $info['tags']['profile:gender'] = array( + 'label' => t('Gender'), + 'description' => t("Any of Facebook's allowed gender values should be allowed, the initial two being 'male' and 'female'."), + 'weight' => ++$weight, ) + $tag_info_defaults; return $info; diff --git a/metatag_opengraph/metatag_opengraph.module b/metatag_opengraph/metatag_opengraph.module index 67c3457..78bd4be 100644 --- a/metatag_opengraph/metatag_opengraph.module +++ b/metatag_opengraph/metatag_opengraph.module @@ -9,6 +9,16 @@ function metatag_opengraph_preprocess_html(&$variables) { if (!module_exists('rdf')) { $variables['rdf_namespaces'] .= "\n xmlns:og=\"http://ogp.me/ns#\""; } + + // @TODO Would it be worth dynamically identifying whether these should be + // added, or just output them all? + + // Need an extra namespace for the "article" tags. + $variables['rdf_namespaces'] .= "\n xmlns:article=\"http://ogp.me/ns/article#\""; + // Need an extra namespace for the "book" tags. + $variables['rdf_namespaces'] .= "\n xmlns:book=\"http://ogp.me/ns/book#\""; + // Need an extra namespace for the "profile" tags. + $variables['rdf_namespaces'] .= "\n xmlns:profile=\"http://ogp.me/ns/profile#\""; } /**