Wedge

Public area => Bug reports => The Pub => Archived fixes => Topic started by: live627 on June 11th, 2013, 08:01 AM

Title: Plugin CSS isn't cached into its own subdir
Post by: live627 on June 11th, 2013, 08:01 AM
Tagging @Nao


Code: [Select]
@@ -430,7 +430,7 @@
  <link rel="stylesheet" href="' . $final_script . '">';
 }
 
-function add_plugin_css_file($plugin_name, $original_files = array(), $add_link = false)
+function add_plugin_css_file($plugin_name, $original_files = array(), $add_link = false, $ignore_files = array())
 {
  global $context, $settings, $theme, $boardurl, $pluginsdir, $board_info;
 
@@ -483,8 +483,11 @@
  $can_gzip = !empty($settings['enableCompressedData']) && function_exists('gzencode') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip');
  $ext = $can_gzip ? (we::is('safari') ? '.cgz' : '.css.gz') : '.css';
 
+ // Build the target folder from our skin's folder names and main file name. We don't need to show 'common-index-sections-extra-custom' in the main filename, though!
+ $target_folder = trim(implode('-', array_filter(array_diff($original_files, (array) 'common', $ignore_files))), '-');
+
  // Cache final file and retrieve its name.
- $final_script = $boardurl . '/css/' . wedge_cache_css_files('', $id, $latest_date, $files, $can_gzip, $ext, array('$plugindir' => $context['plugins_url'][$plugin_name]));
+ $final_script = $boardurl . '/css/' . wedge_cache_css_files($target_folder . ($target_folder ? '/' : ''), $id, $latest_date, $files, $can_gzip, $ext, array('$plugindir' => $context['plugins_url'][$plugin_name]));
 
  if ($final_script == $boardurl . '/css/')
  return false;
Title: Re: Plugin CSS isn't cached into its own subdir
Post by: Nao on June 13th, 2013, 10:49 AM
Bug fix or new feature..?

Also -- since my recent suffix rewrites, the plugin code is awfully in need of some love.
Title: Re: Plugin CSS isn't cached into its own subdir
Post by: live627 on June 13th, 2013, 10:34 PM
Bug fix.
Posted: June 13th, 2013, 10:28 PM

Code: [Select]
add_plugin_css_file('live627:awards', 'awards', true);

Before bug fix, file is

Code: [Select]
$cssdir/firefox21-929971

After

Code: [Select]
$cssdir/awards/firefox21-929971
Title: Re: Plugin CSS isn't cached into its own subdir
Post by: Nao on June 14th, 2013, 11:53 PM
Okay, it's on my local install, for now. ;)

I'm surprised the code isn't more broken actually, ah ah...
Maybe in the plugin JS equivalent, though....!
Title: Re: Plugin CSS isn't cached into its own subdir
Post by: Arantor on June 14th, 2013, 11:57 PM
Most of the reason for that is that the plugin CSS and JS files never got kept in step with the various improvements to the mainline functions, but I never knew what was best for backporting to the plugins to be honest.
Title: Re: Plugin CSS isn't cached into its own subdir
Post by: Nao on June 15th, 2013, 12:07 AM
Plus, the JS version underwent a really HEAVY rewrite recently, and I deliberately left the plugin version out, because I didn't deem it to be as important, considering it's unlikely many people would use @if / suffixes in their CSS for now, eh. I like risky situations, I guess..?!