CVS edit link for cleaver
I wish to contribute a module I developed for the website Canweather.com. This module, tweetrss, takes an RSS feed and filters and formats it and posts it to twitter.com. It is dependent on the twitter module for all twitter-specific operations. It is also dependent on the core aggregator module for RSS feeds. Future enhancements may support feed module for more flexibility.
The filtering and formatting operation uses a hook to allow extendability.
The tweetrss module features regular expressions for filtering and formatting using the PHP function preg_replace(). Also included is a sample extension module, tweetrss_canweather, to demonstrate how tweetrss can be extended. The tweetrss_canweather module has a version of the logic used on canweather.com.
Comments
Comment #1
cleaver commentedComment #2
cleaver commentedComment #3
cleaver commentedExplanation of use of module.
Initial Setup:
1. configure Oauth and Twitter modules.
2. register application with twitter.com
3. add twitter oauth keys to twitter module.
4. add twitter account(s).
5. enable aggregator module and add some rss feeds.
Configure tweetrss module:
6. Add a feed: admin/settings/tweetrss/add
7. Select the twitter account and feed to be linked.
8. Select the filter type.
9. For the basic tweetrss filter type, write regular expressions for the filter and transformation of the feed.
10. Save.
11. Run cron. (for normal production use, cron must be called on schedule).
Adding some screenshots...
Comment #4
cleaver commentedLink to Github repo, if it makes review any easier:
http://github.com/cleaver/TweetRSS
Comment #5
avpadernoHello, and thanks for applying for a CVS account. I am adding the review tags, and some volunteers will review the code, pointing out what it needs to be changed.
Comment #6
avpadernohook_uninstall().What is the purpose of changing the value of that Drupal variable each time the module is enabled, or disabled? If the module is disabled, that Drupal variable is not even used.
t().Why is the code using a form builder, if there are no form fields?
Why isn't the code using
filter_xss()?Comment #7
cleaver commentedThanks for the time you put in on reviewing my module. I think I've addressed all the issues and I've attached an updated module.
The uninstall hook was there already
I have updated the code.
The Drupal variable is used to store an array containing a list of the available filter submodules. As add-on filter modules are enabled and disabled, this array will have elements added and removed. The array is used to generate a drop drop down in the edit screen--this is used to select the filter module to apply.
I did not use t(). As I understand it, D6 menu definitions should not use t(): http://drupal.org/node/103114 I think it throws a D5->D6 Coder error if you do use t().
I removed the debug level watchdog statements. Normally I would keep them for most logging systems, but Drupal seems to record all levels and only filters them on display.
Removed. This was a legacy of a previous version that allowed edit on the list page. It was no longer required.
This special function is required in order to sanitize a regex without corrupting it. The regex matches the XML of the RSS feed so it has to allow non-HTML tags. Additionally filter_xss() corrects mismatched tags, which could further corrupt the regex. The tweetrss_filter_xss() function keeps the check for code insertion.
I did some checking on modules that allow users to enter a regex and it looks like most will display it without any sanitizing. This module appears to have the most secure handling of regex values that I have seen in contrib.
Comment #8
avpadernoMenu descriptions and titles, as well as schema descriptions, are not passed to
t().The strings used as description should start with a capitalized word, end with a period, and contain a sentence (not a phrase).
I should have better reported what I meant: the module doesn't implement the code to remove the Drupal variables it defines in
hook_uninstall().In that case, the module should use a custom hook that allows filter submodules to report information about themselves.
Furthermore, it doesn't make sense for the main module to delete the Drupal variable it uses for that purpose to signal to itself that there are no filter submodules; since the main module is disabled, its code will not be executed, and it cannot verify if there are filter submodules.
Two modules cannot declare the same permission.
Why is the code checking only for English or French strings?
All those calls to
preg_replace()can be replaced by a single call.Why isn't the code using
drupal_write_record()?Comment #9
cleaver commentedThanks again kiamlaluno, for your review! I've made some further changes to my module, which I've described below...
The strings used as description should start with a capitalized word, end with a period, and contain a sentence (not a phrase).
Sorry, I didn't understand before. I've updated my source to remove the t() and make the comments more clear. I used the output from Schema module which curiously added the t(). I've made a note in the Schema module issue queue.
I should have better reported what I meant: the module doesn't implement the code to remove the Drupal variables it defines in hook_uninstall().
The Drupal variable is used to store an array containing a list of the available filter submodules. As add-on filter modules are enabled and disabled, this array will have elements added and removed. The array is used to generate a drop drop down in the edit screen--this is used to select the filter module to apply.
In that case, the module should use a custom hook that allows filter submodules to report information about themselves.
Furthermore, it doesn't make sense for the main module to delete the Drupal variable it uses for that purpose to signal to itself that there are no filter submodules; since the main module is disabled, its code will not be executed, and it cannot verify if there are filter submodules.
To simplify things, I got rid of the variable and used a hook. This let me delete the install file for the filter sub-module.
Removed.
This is a sample filter module to show how to use the hooks and was developed for a specific RSS feed, which is only in English and French. (It is the Canadian government Ministry of Environment.)
I took an exact copy of the core function, filter_xss() and removed the checks that would corrupt the regex. I was planning to keep it as close to the core function as possible so that I could improve it when the core function improves.
I changed the code to use this function.
I cleaned up a bit and it tests clean on Coder module. Not sure if I missed anything else...
On each round of changes I'm reducing the lines of code, so that is good...
Comment #10
avpadernoThank you for your contribution! I am going to update your account.
These are some recommended readings to help with excellent maintainership:
You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
I thank all the dedicated reviewers as well.
Comment #13
avpadernoComment #14
avpaderno