I see the module defines some input filters, but the level at which they are accessed is hidden to the user except at the view level. It would be very useful if this module were to create a default input format comprised of the two Twitter input filters (#hashtag and @username) as well as the URL filter.

By running tweets through the URL filter, users can easily add rel="nofollow" to links, which is a big step forward towards solving this issue: #444118: Add option to nofollow links. Similar "spam deterrent" options can be added to the #hashtag and @username filters.

Comments

WeRockYourWeb.com’s picture

Good idea. For now, I'm simply disabling the "turn to URL" feature in the view, so it only outputs a text URL (under Fields -> Twitter message text -> link URLs to their destinations).

erantone’s picture

Issue tags: +nofollow

Add "nofollow" to links from tweets.
To do that, install the module "nofollowlist" and configure it the way it's best for you.
Then, edit the file "twitter_views_field_handlers.inc" from the twitter module and add the code below marked with the comment "// -- add this --":


/**
 * Process Twitter-style @usernames and URLs before filtering XSS.
 */
class twitter_views_handler_field_xss extends views_handler_field {
  function option_definition() {
    $options = parent::option_definition();
    $options['link_urls'] = array('default' => TRUE);
    $options['link_usernames'] = array('default' => TRUE);
    $options['link_hashtags'] = array('default' => FALSE);
    $options['hashtags_url'] = array('default' => 'http://search.twitter.com/search?q=%23');
    $options['nofollow_links'] = array('default' => FALSE);  // <-- add this
    return $options;
  }

  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);
    $form['link_urls'] = array(
      '#title' => t('Link urls to their destinations'),
      '#type' => 'checkbox',
      '#default_value' => !empty($this->options['link_urls']),
    );
    $form['link_usernames'] = array(
      '#title' => t('Link Twitter @usernames to their Twitter.com urls'),
      '#type' => 'checkbox',
      '#default_value' => !empty($this->options['link_usernames']),
    );
    $form['link_hashtags'] = array(
      '#title' => t('Link Twitter #hashtags to another url'),
      '#type' => 'checkbox',
      '#default_value' => !empty($this->options['link_hashtags']),
    );
    $form['hashtags_url'] = array(
      '#type' => 'textfield',
      '#default_value' => $this->options['hashtags_url'],
      '#process' => array('views_process_dependency'),
      '#dependency' => array('edit-options-link-hashtags' => array(TRUE)),
    );
    // -- add this -->
    $form['nofollow_links'] = array(
      '#title' => t('Add rel="nofollow" to links'),
      '#type' => 'checkbox',
      '#default_value' => !empty($this->options['nofollow_links']),
    );

  }

  function render($values) {
    $value = $values->{$this->field_alias};
    if (!empty($this->options['link_urls'])) {
      $value = _filter_url($value, FILTER_DEFAULT);
    }
    if (!empty($this->options['link_usernames'])) {
      $value = twitter_link_filter($value);
    }
    if (!empty($this->options['link_hashtags']) && valid_url($this->options['hashtags_url'])) {
      $value = twitter_link_filter($value, '#', url($this->options['hashtags_url']));
    }
    // -- add this -->
    if (!empty($this->options['nofollow_links'])) {
      if (module_exists('nofollowlist'))
        $value = nofollowlist_filter("process", $delta = 0, $format = -1, $value);
    }

    return filter_xss($value);
  }
}


/**
 * Field handler to provide simple renderer that turns a URL into a clickable link.
 */
class twitter_views_handler_field_profile_image extends views_handler_field {
  function render($values) {
    $value = $values->{$this->field_alias};
    return theme('image', $value, '', '', array(), FALSE);
  }
}

Eric
www.imohoo.com.br

juampynr’s picture

Title: Add ability to assign an input format to Twitter feed items » Add rel="nofollow" and target="_blank" to all links within messages
Version: 6.x-2.3 » 7.x-4.x-dev
Status: Active » Fixed

I went through the easiest path and added an input format for adding target="_blank" and rel="nofollow" to all links within a message. Feel free to submit patches for improving it or backporting it to 6.x-4.x. Otherwise I am marking it as fixed.

http://drupalcode.org/project/twitter.git/commitdiff/e2bf6eb

Status: Fixed » Closed (fixed)
Issue tags: -nofollow

Automatically closed -- issue fixed for 2 weeks with no activity.