Blueprint suffers from the common problem that upgrades (especially via drush) tend to wipe the framework directory, breaking sites and necessitating a re-download. The Libraries API project has solved this problem. I'd be happy to submit a patch if y'all are open to using it, but don't want to waste my time if not. Please advise.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

designerbrent’s picture

I'd be interested in learning more about how this would work. What changes would be required in the code? Does that mean the theme would then become dependent on the Libraries API module?

acrollet’s picture

Hi there,

sorry, I forgot to subscribe to this queue, and only just checked back. Blueprint would indeed become dependent on the libraries API, here's the howto: http://drupal.org/node/735160

acrollet’s picture

Please see also: http://drupal.org/project/jquery

thanks,

Adrian

designerbrent’s picture

Status: Active » Postponed

I looked though the documentation for Libraries and while the concept looks interesting, I'm not sure I'm ready to introduce a module dependency into Blueprint as it will require a bit of additional custom code to account for the possibilities of the module missing since the "dependencies[] = libraries" tag doesn't work for themes, only modules.

If I'm missing the "how" on getting this done, i'd be interested here how it should be done and how it works with Themes, not just modules.

acrollet’s picture

Status: Postponed » Active

Hi there,

I can definitely sympathize with the dependency issue. I'm wondering if you would be willing to do one of two things:

a) use module_list() to check if the libraries API module is present and enabled, and if so check the libraries directory for blueprint if it's not present in the blueprint module's dir.
b) have an optional configuration setting that gives an alternate path to the library, stored in a variable.

Again, I'd be happy to code up a patch for either if you're open to the idea.

thanks,

Adrian

designerbrent’s picture

I'd certainly be interested if you want to code it.

seanr’s picture

Status: Active » Needs review
FileSize
1.65 KB

Just wrote a patch that appears to work fairly well. I'd love to see this get in. We have to refetch the dependencies every time we update a site - very annoying.

seanr’s picture

FileSize
1.09 KB

Ugh, just read #5, attached patch fixes that by using module_exists.

designerbrent’s picture

Status: Needs review » Needs work

Thanks seanr for the patches and acrollet for pushing this. I'm ready to do something about it soon. As it sits now, running drush updates causes the problem of deleting the Blueprint library folder when it is contained in the blueprint folder structure.

After giving it a bunch of thought and looking over the code of both the patches and the Libraries API module, what advantage do I gain by calling the Libraries module vs just looking in sites/libraries/* for the blueprint folder? It seems like less overhead to do that but I'd be happy to consider making use of the Libraries API. Am I missing some advantage?

acrollet’s picture

The biggest advantage I can think of right off is not having to hardcode paths - for one thing, libraries can exist in any of the following places: (and probably more)

sites/default/libraries
sites/all/libraries
profiles/{profile_name}/libraries
sites/com.example.www/libraries

thanks,

Adrian

designerbrent’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
5.36 KB

Ok, so here is what has been done:

  1. The Blueprint libraries have been moved out of the blueprint theme folder for good. A while back I moved them from the blueprint folder to a folder named framework inside the theme folder #660224: Restructuring the Blueprint Css folder but that proved to be too problematic with doing Drush updates because every time you did a Drush blueprint update, it would trash the framework folder. Now all you ahve to do is download the blueprint library once, put it in /sites/all/libraries/ and you are done.
  2. If you want to use the Libraries API project, these changes will also support that, allowing you to place your Blueprint framework files in any of the locations that Libraries API supports:
    • sites/default/libraries
    • sites/all/libraries
    • profiles/{profile_name}/libraries
    • sites/com.example.www/libraries

So while Blueprint will now support Libraries API, it is not required.

I'm attaching the patch of the changes made and am open to comments but will be committing it shortly as soon as I get it documented.

designerbrent’s picture

Status: Reviewed & tested by the community » Needs review

Opps. got the wrong status tag. I would love to have some of you look at it and am open for changes.

seanr’s picture

#11 looks pretty good to me.

susheel_c’s picture

subscribing... Will try this out on a fresh install in a day or two.

joelstein’s picture

Status: Needs review » Needs work

One thing I noticed is that the IE stylesheet needs the $base_path prepended. So, in page.tpl.php...

<link rel="stylesheet" href="<?php print $bp_library_path; ?>blueprint/ie.css" type="text/css" media="screen, projection">

...should be...

<link rel="stylesheet" href="<?php print $base_path . $bp_library_path; ?>blueprint/ie.css" type="text/css" media="screen, projection">
designerbrent’s picture

Thanks for catching that joelstein. I have committed that back to the Dev line.

joelstein’s picture

While we're still on this issue... on one of my projects, our designer built the design using a customized version of the Blueprint library (via Boks). In this case, it makes sense to keep the blueprint files within the sub-theme.

Is it possible to add one more check for the location of the Blueprint theme? I don't believe Libraries API will do this for us (the closest it gets is sites/default/libraries).

Jon Nunan’s picture

Doesn't this break the idea of being able to override any css file in the theme by simply declaring it in a sub-theme's .info file?

The following checks for over riding screen.css and print.css in the sub-themes 'css' directory before adding the library versions.

/**
 * Intercept template variables 
 *
 * @param $vars
 *   A sequential array of variables passed to the theme function.
 */
function blueprint_preprocess(&$variables, $hook) {
  global $theme_info;
  if (module_exists('libraries')) {
    $variables['bp_library_path'] = module_invoke('libraries', 'get_path', 'blueprint') .'/';
  }
  else {
    $variables['bp_library_path'] = 'sites/all/libraries/blueprint/';
  }
  // check to see if sub-theme has over-ridden these base css files
  if (!isset($theme_info->stylesheets['screen,projection']['css/screen.css'])) {
     drupal_add_css($variables['bp_library_path'] .'blueprint/screen.css', 'theme', 'screen,projection');
  }
  if (!isset($theme_info->stylesheets['print']['css/print.css'])) {
     drupal_add_css($variables['bp_library_path'] .'blueprint/print.css', 'theme', 'print');
  }
}