November 6th, 2009

Spam yourself. Spamalot or a spamalittle with DevelMailLog

I was upgrading The Watcher module to Drupal 7 today and found myself having to test a lot of email sending. Looking around in vain for a fake email system to log emails to the disk instead of sending them out into the interwebs to risk getting called the dreaded meat product, I decided to write one using the new pluggable mail system interface in Drupal 7.

Spam!

Previous versions of this have existed in the past, but I couldn’t find anything in devel currently. Here’s how it works. If you want to save your mails locally to files:

Step 1
Install Devel
Step 2
Apply this patch (until it gets committed) – Review here: http://drupal.org/node/625062.

cd sites/all/modules/devel
curl http://drupal.org/files/issues/develmail-625062-1.patch | patch -p0

Step 3
In your settings.php file:

$conf['mail_system'] = array('default-system', 'DevelMailLog');

That’s it!

Unless you set anything else mails are saved to files/mails/$to-$subject-$datetime.mail.txt

Example
Contact | My Site

Terminal — bash — 140×50

Bonus
You can change the directory with
variable_set(’devel_debug_mail_directory’, file_directory_path() . ‘/mails’);

Or the file format
variable_set(’devel_debug_mail_file_format’, ‘%to-%subject-%datetime.mail.txt’);

Till next time spammers…

August 6th, 2009

Plugin Manager in Core (part deux)

Sorry, long time no blog.

It’s been a crazy three months working on the Plugin Manager in Core project.

For those not acquainted, the plan is to make a GUI based installer / updater for Drupal modules and themes.

Available updates | dev7

We were almost done, and even had it all accessible

Then, some concerns were raised in the community about security and reliability. If you would like the US Library of Congress ref number for this discussion and the issues about Plugin Manager in D7, please contact me directly, I’ll notify you when they have finished building a computer fast enough to import them into their collection.

At any rate, here is the gist:

I, Adrian Rossouw, and probably some others are working to get something in by September 1st.

I’ve developed a specification, a backlog, and worked with Dries to finalize it’s acceptance.
Here is the something we are building:
Plugin manager for D7 code freeze spec.

I’ve also started out on a few of the issues, namely adding chmod support to FileTransfers, and moving the security sensitive operations to a separate file.

But there is a lot of other work to do, and we need all the help we can get. So if you’re interested in volunteering, comment here, or the main specification issue, email me, call me, show up at my house, whatever.

Also, come to my session at DrupalCon. I’ll also be trying to organize a BoF to talk about future plans.

Take care!
Jacob

March 17th, 2009

Acquia Search is rocking!

Just want to make a quick update and say that at long last my search project is on the internets and getting decent uptake.

Peter Wolanin and I presented at DrupalCon (don’t laugh too hard at me).

I think the reception so far has been great, and the servers have been champs :) We’re getting more and more signups every day.

One really cool one is Bryan from the CMS Report:
http://cmsreport.com/search/apachesolr_search/Drupal%20Search

If any of you out there want to find out how search can change how you build your sites and bring more people together with pages they need. Just click this link now:

http://acquia.com/products-services/acquia-search

A lot of people are excited but worried about trying out the free beta because we haven’t released any pricing, and something this cool will certainly cost more than a few pesos.

Well, fear not Drupalers, we’ve heard your call and are working on releasing some preliminary pricing soon. We wanted to wait until the beta got rolling a bit before we did this, but we want people to know we have a commitment to making this technology available to as wide an audience as possible. Stay tuned to my blog and/or the planet/acquia.com for more updates on this.

In the meantime, signup for the beta, it really only takes 15 minutes to setup and won’t break your site or lock you in at all. Please give us feedback! We know there are a few usability hiccups still in the signup process, and we’d love your input so we can fix ‘em. Thanks!

November 28th, 2008

What could search look like on d.o. and g.d.o

Robert Douglas, Peter Wolanin and I are scheming up what we hope to be a jaw dropping presentation of ApacheSolr + Drupal integration at DrupalCon DC. We’re going to show a prototype of d.o. and g.d.o hooked up the Apache Solr search server. We all know that d.o. and g.d.o. are notoriously hard to search through.

For instance, take this query:

http://drupal.org/search/node/views (searching for views).

Search | drupal.org
Uploaded with plasq’s Skitch!

Read the rest of this entry »

September 12th, 2008

Delhi Drupal Meetup Tomorrow!!

Sorry for the late notice folks, but I figured we should just try to make this happen:

Calling all drupal wale in Delhi!

We’re meeting at the offices of Srijan in Nehru place.

Directions and contact info are here:
http://groups.drupal.org/node/14727#comment-49495

and the node regarding them meetup (organized in about 3 days) is here:
http://groups.drupal.org/node/14727

There will certainly be 4-5 people there, so please do show up!

At present there is no formal agenda, but Srijan will be providing a projector so we can do some lightning talks, or watch a thrilling DrupalCon presentation or two :) Anyway, see you then.

All the best,
Jacob

September 2nd, 2008

How to – gzip compression between Drupal and nginx / apache

I was working on trying to speed up the transmission and reduce the bandwidth of a web service I’ve been building in EC2. I’m using nginx (en-JINN-ex) as my load balancer and the cloud because, it is awesome.

A little overview for people who have lives and think an HTTP Header is a football term:

When you send a request to a server via your browser a series of Headers(little variables) are sent across which tells the server what type of browser you are, what language you prefer, and a whole host of other interesting info.

When you get data back from the webserver, it also sends back some headers like the status of the request (200 is OK, 404 is a url with no content, etc), the length of the content, type of content, etc.

When a server is using mod_deflate or mod_gzip in apache (or The Gzip Module for Nginx), then it is capable of sending back its content in a compressed (gzipped) form. All modern browsers support transparent decryption on the browser side. What this means is that you see a normal HTML page which is 70k, but only 15 or 20k went over the pipe because of compression. Cool, right? Chances are it just happened as you saw this page.

Now how does a web server know you can accept gzip’d content? Well, you send one of those headers that looks like this:


Accept-Encoding: gzip,deflate

and the server responds with


Content-Encoding: gzip

By default, php does not transparently support gzip encoding, but it can be done. See the following:



if (function_exists('gzinflate')) {
        $gz_on = true;
    }

    if ($gz_on) {
    // Tells the drupal_http_request function to send this header over.
        $headers = array (
            'Accept-Encoding' => 'gzip,deflate',
        );
    }

    $return = drupal_http_request($url,$headers,'GET'); 

    // This checks to make sure that we actually got gzip'd content back
    if ($gz_on == true && stristr($return->headers['Content-Encoding'],'gzip')) {
        //First 10 chars are junk
        $string = substr($return->data, 10);
        $output = gzinflate($string);
    } else {
        $output = $return->data;
    }

Go ahead and try it with $gz_on false and true. You'll see that $return->data will have different lengths if it is compressed or not, but $output will be the same.

One caveat when working with nginx (this one hurt after 2 hrs):
From the nginx manual

Turns gzip compression on or off depending on the HTTP request version.

When HTTP version 1.0 is used, the Vary: Accept-Encoding header is not set. As this can lead to proxy cache corruption, consider adding it with add_header. Also note that the Content-Length header is not set when using either version. Keepalives will therefore be impossible with version 1.0, while for 1.1 it is handled by chunked transfers.

Drupal uses HTTP 1.0 for some reason... I don't know why it uses version 1.0, but I filed an issue about the same, because 1.1 is a lot better and pretty much ubiquitous IIRC.

Happy Header Hacking!

August 29th, 2008

Taking control of your block’s theme with blocktheme

I got en email from Bob Christenson over at mustard seed media:

  1. Thanking me for block theme (others deserve credit as well, see the Project Page )
  2. Pointing me to this wicked video tutorial on how to get it running for your site and what it does

More after the jump…
Read the rest of this entry »

August 12th, 2008

250k nodes working to save our habitat

I had the privilege of working with Srijan Technologies this spring on Drupal and Agile Development trainings for their team and helping them get Apache Solr kicking for the India Environmental Portal which just launched last week to much fanfare.

The site is based on Drupal 5 and features:

What is an environmental portal?

India Environmental Portal is an initiative of the Center for Society and the Environment, one of India’s oldest and most revered environmental NGOs. Here is an excerpt from their about page:

This is the age of environment. And to make a difference, in our lifestyle, in policy and in practice we need information, which is accessible, well categorized and easy to use. The India Environment Portal is our effort to put together a one-stop shop of all that you want to know about environment and development issues. Its politics is overt: to build open, networked and informed societies, who can use knowledge to make change…..

This is a people’s portal. It will actively collate and exchange data, research and information from people working in the field, in campaigns, in scientific institutions, in research and in industry.

I recommend checking out the about page to find out more about this exciting resource:
http://www.indiaenvironmentportal.org.in/content/about-us

Congratulations to Ipsita, Rahul, Syed, Shashank, and all the rest of the excellent team at Srijan!

And a special thanks to drunken monkey and Robert Douglass for their work to integrate Drupal and Apache Solr.

Some press about the launch

http://www.financialexpress.com/news/National-portal-on-environment/347761/

http://in.news.yahoo.com/43/20080811/812/tnl-national-online-portal-on-environmen.html

http://www.thehindu.com/holnus/002200808112067.htm

http://www.ecoearth.info/shared/reader/welcome.aspx?linkid=104697&keybold=climate%20forest%20environment%20warming

http://www.indiaprwire.com/businessnews/20080811/32685.htm

http://alootechie.net/content/indiaenvironmentportalorgin-launched-provide-environmental-information

August 6th, 2008

AdminRole 6.x released (finally)

Hey folks,

I finally got around to porting the Admin Role module to Drupal 6. Thanks for Pasqualle for getting the ball rolling on this and everyone else who contributed. Although certainly the simplest and smallest of my contributions to Drupal, Admin Role is by far the most well know and widely used. I’d really like to see it end up in core, because I think it is something people want… but perhaps there is a good reason not to.

The idea is that on many sites, you want more than one “super” administrator – that is, someone who can do anything. Unfortunately in Drupal, you cannot do this. The only way is to create a role such as “Admins” and then for every module you install, go to the permissions page, and check off all the little boxes to give permissions to that role. Adminrole simply does that for you whenever you add a new module.

I’ve marked the 6.x release a beta because I haven’t had any testing from the community yet, and only minimal testing from me, but I think it works great :)

For anyone out there using adminrole, please give it a whirl. Also note that I released a new version of the 5.x line last week.

Thanks to everyone who helped with these releases, in particular:

And thanks to CivicActions for partially funding the development of this module.

July 15th, 2008

How to handle urls for “mini sites” in panels 2

This post is about how to handle urls for portals or mini sites or groups where there are multiple subpages in a given area of the site.

I ran into a slightly puzzling problem this week while working with the Civicactions team in Mexico. We’re doing a project for a client who has a large site which is heavily focused on Organic Groups. We’re using panels 2 for the entire layout, and of course pathauto is also in use.

Here is the gist:

We have four node types which are og_node types. The types are:

  • Campaigns
  • Toolkits
  • And a couple others…

So using path auto, if I have a campaign about water conservation, the path is:

campaigns/water_conserve -> node/123

node/% is overriden by panels, and using the panels arguments, we’ve got different layouts depending on if a campaign type node is passed in or a toolkit type node. (campaigns and toolkits have different sidebars, and some other stuff as well).

Okay, so that works fine, however each campaign has their own blog and the URL should be:

campaigns/water_conserve/blog

This should load another panel override where the URL is node/%/blog, but the above url DOES NOT map to node/123/blog, because the path module does not recourse back in the URL to find a match. With the blocks module (who would want to use this anymore?), this was okay using visibility settings, but it’s not too great to do in panels (even with mini panels as blocks).

So how do we resolve this?

I see three equally bad options:

  1. Write a hook into node_save and write a ton of url_alias entries like campaigns/water_conserve/blog, campaigns/water_conserve/resources, campaigns/water_conserve/people, etc. The problem with this is that it creates cruft, and it could leave artifacts, and it requires constant maintenance of these path aliases as new ones are added.
  2. We include logic everywhere (in all views, blocks, etc) to actually look at the URL and determine if it should load or not…. That’s pretty bad
  3. We build a RESTful structure using a slight hack in our custom client module This means that we find out that campaigns/water_conserve == “node/37″ and assume that campaigns/water_conserve/blog == “node/37/blog” (see below).


function mymod_menu($may_cache = false) {

if (!$may_cache) {
    // $args
    // for each arg
    // remove the arg and see if the path that is left is in path auto
    // example:
    // campaigns/mycampaign/blog/superblog
    // first loop:
    //   is campaigns/mycampaign/blog in the alias table (no).
    // second loop:
    //  is campaigns/mycampaign in the alias table (yes) -> node/123
    //  set the path

  $arguments = explode('/', $_GET['q']);

  // Only limit this to a couple of url paths to keep it safe?
  if (in_array($arguments[0],array('campaign','toolkit','group','organization'))) {
    while ($removed_args[] = array_pop($arguments) ) {
      $test = implode("/",$arguments);
      if ($real_path = drupal_get_normal_path($test)) {
        $real_path .= '/' . implode('/',$removed_args);
        menu_set_active_item($real_path);

        break;
      }
    }
  }

}

I don’t love this either, but it seems to work just fine. Does anyone have a problem with this? Should it be an option in path? Does it even matter in D6?

How To find me

Telephone: +1 510.277.0891 | Email: jacobsingh at gmail daht calm

Solution Graphics