diff --git a/fitvids.module b/fitvids.module
index 205284a..da6ef7d 100644
--- a/fitvids.module
+++ b/fitvids.module
@@ -8,6 +8,8 @@
define("FITVIDS_DEFAULT_REGIONS", 'body');
define("FITVIDS_PLUGIN_URL", 'https://raw.github.com/davatron5000/FitVids.js/master/jquery.fitvids.js');
define("FITVIDS_PLUGIN_FILENAME", 'jquery.fitvids.js');
+define('FITVIDS_PATHS_NOTLISTED', 0);
+define('FITVIDS_PATHS_LISTED', 1);
/**
* Implements hook_help().
@@ -77,6 +79,7 @@ function fitvids_form($form, &$form_state) {
// Is the library installed?
$path = libraries_get_path('fitvids') . '/jquery.fitvids.js';
$installed = file_exists($path);
+ $fitvids_paths = variable_get('fitvids_paths', '');
if (!$installed) {
$message = t('You need to download the FitVids.js jQuery plugin to use this module. Download it from !fitvids-site and copy it to !fitvids-library/!fitvids-filename.', array(
'!fitvids-site' => l(t('here'), FITVIDS_PLUGIN_URL),
@@ -107,6 +110,30 @@ function fitvids_form($form, &$form_state) {
'#description' => t('Only YouTube, Vimeo and Kickstarter are supported by default, but you can tell FitVids about videos from other sites by adding the domain of the player.
E.g., "http://www.dailymotion.com". Use a new line for each URL. You don\'t need to add trailing slashes.'),
);
+ $form['fitvids_path_control'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Pages'),
+ '#collapsible' => TRUE,
+ '#collapsed' => !$fitvids_paths,
+ );
+
+ $form['fitvids_path_control']['fitvids_paths_visibility'] = array(
+ '#type' => 'radios',
+ '#title' => t('Add FitVids to specific pages'),
+ '#default_value' => variable_get('fitvids_paths_visibility', FITVIDS_PATHS_NOTLISTED),
+ '#options' => array(
+ FITVIDS_PATHS_NOTLISTED => t('All pages except those listed'),
+ FITVIDS_PATHS_LISTED => t('Only the listed pages'),
+ ),
+ );
+
+ $form['fitvids_path_control']['fitvids_paths'] = array(
+ '#type' => 'textarea',
+ '#rows' => 3,
+ '#description' => t("Specify pages by using their paths. Enter one path per line. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '')),
+ '#default_value' => $fitvids_paths,
+ );
+
$form['fitvids_simplifymarkup'] = array(
'#type' => 'checkbox',
'#title' => t('Simplify media_youtube and media_vimeo markup'),
@@ -131,7 +158,16 @@ function fitvids_page_build(&$page) {
return;
}
- // TODO User should be able to choose which paths this should/shouldn't run on
+ // Is the page explicitly excluded or not in the list of allowed paths?
+ $path_control = variable_get('fitvids_paths_visibility', FITVIDS_PATHS_NOTLISTED);
+ $fitvids_paths = strtolower(variable_get('fitvids_paths', ''));
+ $current_path = drupal_strtolower(drupal_get_path_alias($_GET['q']));
+ $paths_match = drupal_match_path($current_path, $fitvids_paths);
+ if ($paths_match && $path_control == FITVIDS_PATHS_NOTLISTED ||
+ !$paths_match && $path_control == FITVIDS_PATHS_LISTED) {
+ return;
+ }
+
// Add the library reference
drupal_add_js($path, array(