I needed to drop in some simple CSS on a website which happens to have 'private downloads' configured. I thought I'd use this module.

Problem is:
- with private downloads, file_directory_path() is an absolute path (which may be outside the web root)
- drupal_add_css() and drupal_add_js() expect a relative path.
(So the current behaviour is that you get lines like this in your HTML head:
link type="text/css" rel="stylesheet" media="all" href="//var/www/WHATEVER/customcssjs/css/custom.css?v" <- doesn't work so well :-) )

If we want to keep the path relative, we need to store the CSS/JS files somewhere in the web root => somewhere outside the 'files' path.

I modified the code to be able to do this... but thought I'd better disable that functionality by default, and make sure the users get a warning first. If your file system is set to private downloads, you now get a 'I know what I am doing' checkbox in the admin settings, which you need to tick.

Comments

gold’s picture

Status: Needs review » Needs work

I need this also. Just testing this patch and am getting the following;

[user@host ~/site/htdocs/sites/all/modules/customcssjs]$ !patch
patch -i customcssjs_private.patch 
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|=== modified file 'sites/all/modules/customcssjs/customcssjs.module'
|--- sites/all/modules/customcssjs/customcssjs.module	2010-08-13 21:06:05 +0000
|+++ sites/all/modules/customcssjs/customcssjs.module	2010-08-13 22:55:39 +0000
--------------------------
Patching file customcssjs.module using Plan A...
Hunk #1 failed at 32.
Hunk #2 succeeded at 92.
Hunk #3 succeeded at 129.
Hunk #4 failed at 137.
2 out of 4 hunks failed--saving rejects to customcssjs.module.rej
Hmm...  Ignoring the trailing garbage.
done

I'm assuming that this is due to differences between HEAD at the time of diffing and now.

I'll try and apply this manually and run a new cvs diff.

gold’s picture

Status: Needs work » Needs review
StatusFileSize
new4.77 KB

Okay, Can people test this one please?

I've got it working for private files by having customcssjs in the site root. This still isn't an ideal solution but it's working and I'm a little pushed for time to come up with a better option.

Cheers,
Gold