Jump to content

Michael Fillier

Members
  • Posts

    17
  • Joined

  • Last visited

Profile Information

  • Gender
    Male
  • Location
    Toronto, Canada

Michael Fillier's Achievements

Jr. Member

Jr. Member (3/6)

3

Reputation

  1. It's dead simple to use, nice job. How difficult would it be to have the options saved to the db and made available as a variable? Then perhaps an "auto" checkbox that could be used in the theme like: <?php if($minify->auto) { echo $minify->files; else { ?> <!--Normal css and js references --> <?php } ?> Also, for the snippet, would it make more sense to include the path variables in the snippet, you must be using them while generating the snippet, but there will be path issues when working locally and then moving to production. <script type="text/javascript" src="<?php echo $config->urls->siteModules; ?>Minify/min/b=<?php echo $config->urls->templates?>scripts&f=jquery-1.4.2.min.js,main.js"></script> (I think this is a good idea, but $config->urls->templates includes a preceding slash, and is not loading the resource properly
  2. Thanks, I was wondering the best way to do that. Switching on the template in header.inc is a great solution. Taking a look at the module right now.
  3. In regards to your htaccess/rewrite for improving performance, Drupal has a module called boost (http://drupal.org/project/boost) that has been used on really large sites. It seems to be in line with what you are talking about and maybe you will find something in there that will help you with PW.
  4. A lot of good points here. One of the reasons I moved from Joomla to Drupal was because of how modules were handled. Joomla had tons of modules that all achieved nearly the same thing, this was no doubt a result of actually selling the modules. Developers are pitted against each other, in order to make you buy their product. I understand that competitiveness can lead to better products, but overall I just see it being a waste of effort. On the other hand Drupal is completely different in the sense that it is rare to find duplicate modules and they are FREE! I like that PW modules are hosted on git, but I think you should have separate pages on the PW site for each module, with a link to the git source. One thing I like about Drupal's site structure is that I can find any module via url by going to drupal.org/project/{module_name}. This makes it easy for me to lookup a module at any time. In addition, Drupal's "Issue Queue" is one of the best ways to get help with a module or find a solution to a problem. I am getting the point about PW's approach to minimize markup generation (took me a while). As I wrap my head around the possibilities for creating brochure sites, allowing me to design them my way, I really like it. Drupal's do-everything approach is great, but I don't find myself building sites that require "everything".
  5. Also, interested in checking out the module when you have it ready. Thanks.
  6. Building on this a bit, how about a field that works like the "related page" field, but for images. So I can reuse an image uploaded on one page's image field in another page's image field. Without having to upload it twice. Sort of like how the TinyMCE plugin allows you to use images from another page in the WYSIWYG, but for fields.
  7. I am starting to notice this, thanks for the encouragement and the continued advice.
  8. Fair enough. How do you currently handle having different css and javascript files on different pages?
  9. Since this is a common use case (I mean who doesn't like compressed, aggregated javascript and css?) I think it would be a good candidate for a module. Looking at minify further, perhaps we can use soma's concept and feed the files to minify. But since this approach will require a site builder to adapt their code to use config instead of plain old link and script tags, it is probably not favourable. I think most logical approach would be for the module to preg_match_all linked css and javascript files, serve the urls to minify and then replace the individual linked references with the minify'd references. Is there a hook that would let a module modify the page markup before rendering the page? Or would the approach I mentioned need to involve code in the theme.
  10. Just took a look at an older Drupal module that aggregated and compressed javascript, here is a code snippet: /** * Helper function to minify and gzip files. */ function _javascript_aggregator_minify($scripts) { // Only process it is JavaScript Optimization is enabled. if (variable_get('preprocess_js', 0)) { // Strip out the aggregated JavaScript file. $path_to_files_directory = base_path() . file_directory_path(); $pattern = "!(<script type=\"text\/javascript\" src=\"(.*?)$path_to_files_directory)(.*?)(\"(.*?)><\/script>)!"; if (preg_match_all($pattern, $scripts, $matches) > 0) { $aggregated_file_name = $matches[3][0]; $jsmin_file_name = $aggregated_file_name .'min.js'; // Construct the final JSMin file path. $jsmin_file_path = file_directory_path() . $jsmin_file_name; // Create the JSMinified file if it doesn't exist yet. if (!file_exists($jsmin_file_path)) { if (variable_get('javascript_aggregator_jsminplus', FALSE)) { // JSMin+ the contents of the aggregated file. require_once(drupal_get_path('module', 'javascript_aggregator') .'/jsminplus.php'); // Strip Byte Order Marks (BOM's) from the file, JSMin+ cannot parse these. $file = str_replace(pack("CCC", 0xef, 0xbb, 0xbf), "", file_get_contents(file_directory_path() . $aggregated_file_name)); $contents = JSMinPlus::minify($file); } else { // JSMin the contents of the aggregated file. require_once(drupal_get_path('module', 'javascript_aggregator') .'/jsmin.php'); $contents = JSMin::minify(file_get_contents(file_directory_path() . $aggregated_file_name)); } // Code comments containing copyright notices and licensing information // are stripped when the file is minified. GPL and most other open // source licenses require the license text to be included whenever the // file is distributed, so include a reference to the un-minified file. $contents = '// Minified using Javascript Aggregator - see '. $path_to_files_directory . $aggregated_file_name ." for original source including licensing information.\n". $contents; // GZip the JavaScript if required. $htaccess = file_directory_path() . '/js/.htaccess'; if (variable_get('javascript_aggregator_gzip', FALSE)) { // Create the GZip file if it doesn't already exist. if (!file_exists($jsmin_file_path .'.gz')) { file_save_data(gzencode($contents, 9), $jsmin_file_path .'.gz', FILE_EXISTS_REPLACE); } // Make sure the .htaccess file is active to handle GZipped JavaScript files. if (!variable_get('javascript_aggregator_no_htaccess', FALSE) && !file_exists($htaccess)) { $rewrite_base = base_path() . file_directory_path() .'/js/'; $htaccess_contents = <<<EOT <Files *.js.gz> AddEncoding x-gzip .gz ForceType text/javascript </Files> <IfModule mod_rewrite.c> RewriteEngine on RewriteBase $rewrite_base RewriteCond %{HTTP_USER_AGENT} !".*Safari.*" RewriteCond %{HTTP:Accept-encoding} gzip RewriteCond %{REQUEST_FILENAME}.gz -f RewriteRule ^(.*)\.js $1.js.gz [L,QSA] </IfModule> EOT; file_save_data($htaccess_contents, $htaccess, FILE_EXISTS_REPLACE); } } else { // Delete .htaccess file so *.gz files do not get served. if (file_exists($htaccess)) { file_delete($htaccess); } } // Save the contents to the JavaScript file. file_save_data($contents, $jsmin_file_path, FILE_EXISTS_REPLACE); } // Replace the aggregated file with the minified JavaScript file. $scripts = str_replace($aggregated_file_name, $jsmin_file_name, $scripts); } } return $scripts; } I am not a very experienced coder, so I want to know what your take is on this approach. The drupal module can be downloaded here: http://ftp.drupal.org/files/projects/javascript_aggregator-6.x-1.6.zip Maybe we could adapt this to processwire and expand its functionality to css files as well.
  11. Maybe I should actually create a site with processwire before making suggestions, seems like I am stuck in the Drupal state of mind still.
  12. In lieu of any real file management (discussion has already started: http://processwire.com/talk/topic/425-file-manager/) I think there should be a video field. Parsers for the most popular sharing sites, youtube being the big one. I have not really dug in to the api yet and my programming skills are pretty amateur, but I am going to take a look at the Flickr Field module and see if I can get any insight into starting off a video field.
  13. I think something that allows reusing files on an image field would be useful. Instead of just having a "upload" button on an image field, there could also be a "select" button that would allow you to select a file from the server. Perhaps this browsing could be done with a 3rd party tool. Any solution considered should be able to work for image fields and WYSIWYG. Drupal's media module allows you to upload any media file and adds it to the "library". Once there you can reuse it on any content page via a "select media" button. Then there is a plugin for ckeditor that allows you to embed media from the library in the body content. So you can use the media files in fields or wysiwyg. From there there is an module that extends the functionality by accepting youtube video urls. So you can add a youtube video to the library and use it wherever you want. Another CMS that handles media management extremely well is concrete5. Makes it easy to add photos and videos, you can organize them with categories and easily create galleries based on the categories. ckfinder is another file browser that integrates with ckeditor.
  14. I was not able to find anything in terms of css and javascript aggregation. Drupal does this wonderfully via a drupal_add_head() function that is used by themes and modules to add css and javascript to the head of the site. The theme then prints out a $head variable, instead of the hard-coded css and javascript includes. This allows you to enable a perfomance option of aggregation and compression. This then combines the files together, saves them on the server and links to the aggregated files instead of the individual files. This results in huge performance gains, especially if your site is using a css grid and any jquery plugins. Since each one comes with its own file and sometimes css styles. I will do some research into how Drupal processes the css and js files. But in the meantime, any feedback on where this fits into processwire would be appreciated.
  15. I think having multiple menus and tree structures is something to consider. It is pretty common for a site to have a main navigation, secondary navigation, user navigation and even footer navigation. Sometimes a site does not conform to a single menu structure. I think multiple menu trees and an api function to pull up the structure of the desired tree would be useful.
×
×
  • Create New...