CVS edit link for cbovard

Hello,
I am applying for a CVS account to submit a module that allows a people to use only one Twitter account with their drupal site. It is called Simple Tweet.
The existing Twitter module is very good, but seems like overkill for having one block pulling in Tweets from one twitter account.
I have posted a request in the Twitter module queue asking the maintainers about this here: http://drupal.org/node/702984
with no response except comments from people that are happy to use our code. There has been small feature requests to the module we have created. People seem to be happy because of it simplicity.

I have also posted here in the Contributed Module Group http://groups.drupal.org/node/50108 with no response.
I am happy to share the code, maintain this module and also create a Drupal 7 version.

I am currently hosting this module on Github here: http://github.com/cbovard/simple_tweet

Thank you for your time and consideration.

Chris Bovard

Comments

cbovard’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new4.69 KB

Hello,
Attached is a zip of the module Simple Tweet.

Thanks
chris

avpaderno’s picture

Status: Needs review » Needs work
Issue tags: +Module review

Hello, and thanks for applying for a CVS account. I am adding the review tags, and some volunteers will review your code, pointing out what needs to be changed.

As per http://drupal.org/cvs-application/requirements, the motivation message should be expanded to contain more details about the features of the proposed module, and it should include also a comparison with the existing solutions.
As reported in the requirements, the proposed module should not duplicate the work done in existing projects.

cbovard’s picture

Status: Needs work » Needs review

Hello and thanks for the consideration.

Overview of Simple Tweet
This project was developed because we found the Twitter Module (http://drupal.org/project/twitter) was too heavy of a module for a one person Website - Blog. We also found it hard to set up for a one person to use, to pull in tweets from one account.
We started to use custom php code in a block instead of using the Twitter module because of website performance.

Explanation of Simple Tweet Module
The Simple Tweet Module only uses one Twitter Account (as described above).
The module has 2 permission settings (Administer Simple Tweet and See Tweets).
The module will create: a block with one tweet; a block with a dynamic number of tweets set on the Simple Tweet Admin page (see below); and a page of recent tweets.
There is an administration page (admin/settings/simple-tweet). This will allow the user to: enter their Twitter login and password; number of tweets to show in multiple tweets block; Title of recent tweets page; Recent Tweets Page path; and more control over the date using the Date API (if enabled).
The cache needs to be cleared if the Recent Tweets page path changes.
The cron.php needs to be run in order to get tweets or update tweets.
We built this trying to keep it lean with out any extra table creation or deletion. We use the variable table for any of the values mentioned above.

Comparison of Existing Modules
Simple Tweet is a one account module as the Twitter module (http://drupal.org/project/twitter) is a multi-user account module.
Simple Tweet does not create any new table in the database as the Twitter module (http://drupal.org/project/twitter) does.
Simple Tweet does not post to new tweets to Twitter as the Twitter module (http://drupal.org/project/twitter) and the Tweet module (http://drupal.org/project/tweet) does.
Simple Tweet is easy to use and has good performance on shared hosting. The Twitter module (http://drupal.org/project/twitter)runs slower on shared hosting and is hard to get running for a one user twitter account.

Summary
This module is a great idea because it is simple. I have been using drupal for almost 4 years and have noticed there is some complex modules that 'do it all'. This is great but at times you only need a small part of the functionality of a module for a small website.
Sometimes a simple alternative is better.

Thank you for your time.

Chris Bovard

avpaderno’s picture

Just a little note on what reported on http://drupal.org/node/539608:

Module 'Foo' is just too complex so I have written a much simpler version. This is just straight duplication of functionality and applications like this will almost certainly be declined. It is worth remembering that many modules start out simple also and, over time, grow into more complex systems. If you have the know how to write a "simple version" from scratch rather than work out how a complex module works then maybe your effort would be better spent making the existing complex module easier to use (improve it's UI, write documentation, etc).

cbovard’s picture

Then we will continue to host it on Github.

Thank you for the clarification.

avpaderno’s picture

Status: Needs review » Closed (won't fix)
cbovard’s picture

Hello,
It has been brought to my attention that our module does not duplicate the Twitter module.

Here is the updated Motivational Message:

Overview of Simple Tweet
The Simple Tweet module is site centric module. It is designed to retrieve and display tweets from a single user's rss twitter feed.

Explanation of Simple Tweet Module

The Simple Tweet Module only uses one Twitter Account to get the RSS feed of Tweets. There is no authentication process.The Simple Tweet Module will not require the OAuth to use Twitter, as Twitter will deprecate Basic Auth June 30, 2010 - http://www.countdowntooauth.com/
The module has 2 permission settings (Administer Simple Tweet and See Tweets).

The module will create: a block with one tweet; a block with a dynamic number of tweets set on the Simple Tweet Admin page (see below); and a page of recent tweets.

There is an administration page (admin/settings/simple-tweet). This will allow the user to: enter their Twitter Username; their Twitter RSS feed; number of tweets to show in multiple tweets block; Title of recent tweets page; Recent Tweets Page path; and more control over the date using the Date API (if enabled).

The cache needs to be cleared if the Recent Tweets page path changes.

We built this trying to keep it lean with out any extra table creation or deletion. We use the variable table for any of the values mentioned above.

Comparison of Existing Modules

Simple Tweet is a one account - site centric module as the Twitter module (http://drupal.org/project/twitter) is user centric module.

Simple Tweet does not post to new tweets to Twitter as the Twitter module (http://drupal.org/project/twitter) and the Tweet module (http://drupal.org/project/tweet) are designed for users to submit and retrieve tweets. Their functionality is build around user account features.

Simple Tweet is easy to use and has good performance on shared hosting. The Twitter module (http://drupal.org/project/twitter) runs slower on shared hosting.

Summary
This module is small, very fast and does not need OAuth to get the user's Tweets.

There could be issues with the code (better ways to do things), so I am expecting that with the review of the code.

Thanks for your time.

Chris Bovard

cbovard’s picture

Status: Closed (won't fix) » Needs review
StatusFileSize
new6.42 KB

Here is our updated module.

cbovard’s picture

changed status

cbovard’s picture

StatusFileSize
new6.39 KB

Did a bunch of fixes and ran it through the Coder Module.

chazz’s picture

Thanks, had some problem with the module today

* warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 49: parser error : Entity 'rsaquo' not defined in .................../simple_tweet.module on line 204.
* warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]:

  • Home ›
  • in .................../simple_tweet.module on line 204.
    * warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in .................../simple_tweet.module on line 204.

    Will try the update now

    btw. Why this module doesn't have own project page?

    chazz’s picture

    I can also see similar error on your site maximumjazz...

    Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 49: parser error : Entity 'rsaquo' not defined in /home/wicec/public_html/maximumjazzmarketing.com/wp-content/plugins/twitter-friends/twitter_friends.php  on line 322
    
    Warning: simplexml_load_string() [function.simplexml-load-string]: <li class="first"><a href="http://twitter.com">Home &rsaquo;</a></li> in /home/wicec/public_html/maximumjazzmarketing.com/wp-content/plugins/twitter-friends/twitter_friends.php on line 322
    
    Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in /home/wicec/public_html/maximumjazzmarketing.com/wp-content/plugins/twitter-friends/twitter_friends.php on line 322
    
    Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 63: parser error : Entity 'copy' not defined in /home/wicec/public_html/maximumjazzmarketing.com/wp-content/plugins/twitter-friends/twitter_friends.php on line 322
    
    cbovard’s picture

    Hello,
    I checked out the maximumjazzmarketing.com site and this a wordpress site. I am not sure what your issue is.
    I just installed a fresh copy of this module and it works.
    Clear your cache!!!

    chris

    chazz’s picture

    I have notice this issue happen for logged users. It was working fine for a few days, I did not change nothing within module or my Twitter account. Cleared cache and installed new version dated 18 may. Instead of Tweeter block I can see errors:

    warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 49: parser error : Entity 'rsaquo' not defined in website/modules/simple_tweet/simple_tweet.module on line 204.
    warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: <li class="first"><a href="http://twitter.com">Home &rsaquo;</a></li> in website/modules/simple_tweet/simple_tweet.module on line 204.
    warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in website/modules/simple_tweet/simple_tweet.module on line 204.
    warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 63: parser error : Entity 'copy' not defined in website/modules/simple_tweet/simple_tweet.module on line 204.
    warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: <li class="first">&copy; 2010 Twitter</li> in website/modules/simple_tweet/simple_tweet.module on line 204.
    warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in website/modules/simple_tweet/simple_tweet.module on line 204.
    
    chazz’s picture

    Hmm just checked now and it is working fine so far... maybe there was a fault with Twitter?

    cbovard’s picture

    After I cleared my cache all worked.??
    not sure

    chris

    specialjyo’s picture

    I'm having an issue with this, the install is so simple that i'm hoping this is a common thing. I put the simple tweet block in play, and it just displays Thu, 01/01/1970 - 00:00 , i verified RSS feed and everything. Ideas?

    avpaderno’s picture

    Keep in mind this is not a project issue queue, nor a debugging session; the purpose of a CVS application is to verify if the code has security issues, uses the correct Drupal functions, follows the coding standards, and duplicates the work done in existing projects.

    avpaderno’s picture

    Status: Needs review » Needs work
    • The points reported in this review are not in order or importance / relevance.
    • Most of the times I report the code that present an issue. In such cases, the same error can be present in other parts of the code; the fact I don't report the same issue more than once doesn't mean the same issue is not present in different places.
    • Not all the reported points are application blockers; some of the points I report are simple suggestions to who applies for a CVS account. For a list of what is considered a blocker for the application approval, see CVS applications review, what to expect. Keep in mind the list is still under construction, and can be changed to adapt it to what has been found out during code review, or to make the list clearer to who applies for a CVS account.
    1. The version line needs to be removed from the .info file.
    2. function simple_tweet_uninstall() {
        // this will delete any of the varables created in the variable table
        db_query("DELETE FROM {variable} WHERE name LIKE 'simple_tweet_%'");
        cache_clear_all('variables', 'cache');
      }
      
      

      Deleting Drupal variables using a query that matches any Drupal variable with a name that starts with the module name would remove also the Drupal variables of other modules.

    3. Menu descriptions and titles, schema descriptions are not passed to t().
    4. function simple_tweet_perm() {
        return array('administer simple tweet', 'see tweets');
      }
      
      

      The second permission should be renamed see simple tweets, or the first permission should be renamed administer tweets.

    5. See http://drupal.org/coding-standards to understand how a module should be written. In particular, see how the code should be formatted.
    6.   $ch = curl_init($rss_url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        //exec curl
        $gettwit = curl_exec($ch);
      
      

      Why isn't the code using drupal_http_request()?

    7.     watchdog('simple_tweet', 'RSS Feed Error is: ' . curl_error($ch));
      
      

      Use a t()-placeholder.

    8.   $text = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $text);
        $text = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $text);
        $text = preg_replace("/@(\w+)/", "<a href=\"http://www.twitter.com/\\1\" target=\"_blank\">@\\1</a>", $text);
        $text = preg_replace("/#(\w+)/", "<a href=\"http://search.twitter.com/search?q=\\1\" target=\"_blank\">#\\1</a>", $text);
      
      

      Multiple calls to preg_replace() can be replaced by a single call.

    9.   else {
          $form['#prefix'] = '<p>' . t('For more control over date presentation insert the !date module.', array('!date' => l('Date API', 'http://www.drupal.org/project/date', array('absolute' => TRUE))));
        }
      
      

      l() should not be used together with t(). See the documentation for t(), where this code is reported to be wrong:

      $output .= t('<p>Go to the @contact-page.</p>', array('@contact-page' => l(t('contact page'), 'contact')));
      

      The correct code to use is the following:

      $output .= '<p>'. t('Go to the <a href="@contact-page">contact page</a>.', array('@contact-page' => url('contact'))) .'</p>';
      
    10.     '#field_prefix' => 'http://' . $_SERVER['SERVER_NAME'] . '/',
      
      

      There is a function that can be used to obtain the absolute URL of the front page.

    11. function simple_tweet_admin_settings_submit($form, &$form_state) {
        if (!$form_state['values']['simple_tweet_rss_url']) { 
          form_set_error('simple_tweet_rss_url', t('Please Enter the Twitter Users RSS URL!'));
        }
        if (!$form_state['values']['simple_tweet_username']) { 
          form_set_error('simple_tweet_username', t('Please Enter your Twitter Username'));
        } 
      }
      

      A form submission handler doesn't validate the values passed in the form; that is the task of a form validation handler.

    cbovard’s picture

    Hello,
    I need too update the code to use the Drupal Cache functions.
    Will provide an update as soon as I can.

    chris

    cbovard’s picture

    Hello,
    Also reviewing your list:
    Number 5, this module was run through the Coder Module. If you are going to reference a link on Coding Standards, then give an example.
    Number 10, Give the link to the function if you can.

    More to follow.

    Sincerely,
    chris

    avpaderno’s picture

    Status: Needs work » Closed (won't fix)

    Please read the following links as this is very important information about CVS applications.

    avpaderno’s picture

    Component: Miscellaneous » new project application
    Issue summary: View changes