David Karich

Module: AIOM+ (All In One Minify) for CSS, LESS, JS and HTML

175 posts in this topic

i've just created a pull request that makes it possible to modify less variables. it also adds a check if the js/css file exists and throws a note either in console if tracy is installed or in the processwire log.

that's how you can modify your less variables:

<?php
$config->styles->append('less/theme.less');
$lessVars = array(
    'tm-primary-bg' => '#568AEA',
    'background-image' => 'url("' . $page->backgroundimage->url . '")',
);
?>
<link rel="stylesheet" href="<?php echo AIOM::CSS($config->styles->unique(), $lessVars); ?>">

https://github.com/FlipZoomMedia/ProcessWire-AIOM-All-In-One-Minify/pull/57

3 people like this

Share this post


Link to post
Share on other sites

I've installed the module and it works fine.

But:

When I set Development Mode to "yes" the files get combined. Is there a way to disable this? I cannot track the root css files this way...

Share this post


Link to post
Share on other sites

you'd need to make some function to output the individual assets, for example when an admin is logged in..

(very basic example)
 

if($user->isLoggedin) {
  listAssets($stylesheets);
} else {
  echo AllInOneMinify::CSS($stylesheets));
}

that's how i do it..

4 people like this

Share this post


Link to post
Share on other sites

Uh now I understand the question..development mode is just disabling minification and caching..maybe file "seperation" could be included as separate option, I for myself like files being concatenated while uncompressed for development..and if I really don't now which file a line belongs to I just Sublime search in all files and done.. ;-)

Share this post


Link to post
Share on other sites
5 hours ago, Macrura said:

 


if($user->isLoggedin) {
  listAssets($stylesheets);
} else {
  echo AllInOneMinify::CSS($stylesheets));
}

 

My conditional is:

$skipMinify = $config->debug || $user->isSuperuser() ? true : false;

 

1 person likes this

Share this post


Link to post
Share on other sites

@horst How about this?

$skipMinify = $config->debug || $user->isSuperuser();

5 people like this

Share this post


Link to post
Share on other sites

:o OMG. I shouldn't post in the morning before the first cup of coffee. :)

 

4 people like this

Share this post


Link to post
Share on other sites
3 hours ago, tpr said:

@horst How about this?

$skipMinify = $config->debug || $user->isSuperuser();

Where does this code snippet go?

Right now I am using this code in my header which is not very professional but it works ;-)

	<? if ($config->debug) { ?>
		<link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates?>styles/styles.css" />
	<? }
	else { ?>
		<link rel="stylesheet" type="text/css" href="<?php echo AIOM::CSS('styles/styles.css'); ?>" />
	<? } ?>

 

Share this post


Link to post
Share on other sites

For me, it goes here:

// condition
<?php if ($config->debug) { ?>

// condition as variable
<?php
$skipMinify = $config->debug || $user->isSuperuser();
if ($skipMinify) { ?>

// or, if you have only one occurence in your code where you check this condition, 
// ommit the temorary variable and write it direct into the condition
<?php if ($config->debug || $user->isSuperuser()) { ?>

$config->debug is true when developing, and additionally I use superuser condition for later, when in production mode!

2 people like this

Share this post


Link to post
Share on other sites

PHP 7.1 is returning a:

A non well formed numeric value encountered on line 713 notice

because you are relying on PHP's auto int casting.

I didn't do a thorough check to see if this is ok, but so far it's working for me:

$_timestamp = ((int)$_timestamp + $file['last_modified']);

 

1 person likes this

Share this post


Link to post
Share on other sites
On 11/25/2015 at 5:17 PM, Russ Parker said:

Any ideas how to stop it minifying the spaces in CSS calc?

having a problem with this as well, any solutions ?

Share this post


Link to post
Share on other sites

Hi.

Is it possible to disable HTML minifing or activate "Developement mode" from config file? 

Thanks 

Share this post


Link to post
Share on other sites

Hi,

first I couldn't install the module on a 3.0.47 installation, I've added  namespace ProcessWire;, which did the trick, but then I have this:

Error: Class 'ProcessWire\RecursiveDirectoryIterator' not found (line 658 of /public_html/site/modules/AllInOneMinify/AllInOneMinify.module)

Kind Regards!

Share this post


Link to post
Share on other sites
On 18.11.2016 at 4:48 PM, Zeka said:

Hi.

Is it possible to disable HTML minifing or activate "Developement mode" from config file? 

Thanks 

Not directly, but I had the same "problem" and now I do it this way:

// when debug mode is ON -> do not compress the styles 
if ($config->debug) { ?>
	<link rel="stylesheet" type="text/css" href="/path/to/css/..."/>
<? } else { ?>
	<link rel="stylesheet" type="text/css" href="<?php echo AIOM::CSS(/path/to/css/...); ?>"/>
<? }

 

1 person likes this

Share this post


Link to post
Share on other sites
13 hours ago, videokid said:

Hi,

first I couldn't install the module on a 3.0.47 installation, I've added  namespace ProcessWire;, which did the trick, but then I have this:


Error: Class 'ProcessWire\RecursiveDirectoryIterator' not found (line 658 of /public_html/site/modules/AllInOneMinify/AllInOneMinify.module)

Kind Regards!

you either leave the namespace or need to prepend all php function like RecursiveDirectoryIterator with an \ backslash like \RecursiveDirectoryIterator so it knows this function is not in the ProcessWire but in the root namespace..

2 people like this

Share this post


Link to post
Share on other sites

Yes,

I left the ' namespace Processwire ' and added the backslash, and that did the trick!

Thank you!

Share this post


Link to post
Share on other sites
On 19.01.2017 at 11:06 AM, Stefanowitsch said:

Not directly, but I had the same "problem" and now I do it this way:


// when debug mode is ON -> do not compress the styles 
if ($config->debug) { ?>
	<link rel="stylesheet" type="text/css" href="/path/to/css/..."/>
<? } else { ?>
	<link rel="stylesheet" type="text/css" href="<?php echo AIOM::CSS(/path/to/css/...); ?>"/>
<? }

 

 
 

@Stefanowitsch Thanks for tip, but it isn't relative to HTML minifying.

Share this post


Link to post
Share on other sites

I just found a collision cache file naming issue if all files have the same modified timestamp regardless of the array contents.

Simple fix to ensure the filename itself is included in the MD5($_timestamp)

$_timestamp = ($_timestamp + $file['last_modified'] . basename($file['absolute_path']));

https://github.com/FlipZoomMedia/ProcessWire-AIOM-All-In-One-Minify/issues/64

Share this post


Link to post
Share on other sites

Wanted to let you know, that I had some issues with AOIM running php 7.

Error messages were generated because of non well formed numeric values.
Maybe the issues are bound to my hosting environment. The following changes resolved them

Changend line 775 in /site/modules/AllInOneMinify/lib/cssmin.php to:

return intval($size);

Changed line 713 in site/modules/AllInOneMinify/AllInOneMinify.module to

$_timestamp = intval($_timestamp . $file['last_modified']);

 

1 person likes this

Share this post


Link to post
Share on other sites

Just a detail: Why are these br tags visible in the module config?

Sth. changed in Processwire?

aiombr.png

Share this post


Link to post
Share on other sites

Hi all,

I'm using the AIOM+ module for speeding up my page. My website is using SSL.

In the module there's the option for domain sharding. Without SSL it's working perfectly, but as soon as I access the website via SSL it's not working. Seems like the Option "Domain sharding (SSL)" is beeing totally ignored.

Is there anybody with the same problem?

Thanks!
Dennis

Share this post


Link to post
Share on other sites

Just wanted to add another report of non-well formed numeric values occurring with PHP 7 (specifically 7.1.7). Pmichaelis' solution works, but only allowed the caching of a single CSS and JS file for my entire site, while Adrian's (several posts above) works and allows for several of each. That said, AIOM still breaks when a template calls for a file that hasn't been previously generated with either of those solutions and remains so even on a reload when a cached file should be available. To get that original page working, I need to jump to a different page using that template (which renders correctly) and then back to the original page.

Edit: ...and by break, I mean it adds a string error message (with some HTML) to the SRC path for each item in your array, so the browser tries to load the CSS or JS file at a URL consisting of multiple error messages followed by the correct path in one epically long string.

1 person likes this

Share this post


Link to post
Share on other sites
On 21. 5. 2017 at 1:21 PM, theo said:

Just a detail: Why are these br tags visible in the module config?

Sth. changed in Processwire?

aiombr.png

    

...
$field->entityEncodeText = false; //add this to allow html markup
$field->description.= sprintf(__('Cached files: %s | Used space: %s'), $_cacheInfo['numberOfFiles'], $_cacheInfo['bytesTotal']);
...

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By alexcapes
      Hi,
      I have an issue when using the SmartyPants Typographer text formatter.
      If the text has an HTML tag (such as italics) straight after the quotation mark, it reverses it. 
      So for example:

      This only seems to occur when an HTML tag is placed at the beginning. 
      Does anyone know how this could be corrected? 
    • By benbyf
      Done quite a bit of Googling and haven't quite worked out how one would create a field of type repeater and add fields to it via the API in a module. Anyone have any links or examples?
    • By benbyf
      HELLO!
      I've been working on a user messaging module which I am nearly ready to release as version 1.
      Currently I have the below functionality and I'm looking for feedback to what other things may be useful for people looking to add user to user messaging on their sites.
      compose message to one or more users known to PW js to enable tag based UI display of user names input on compose message form display all message threads with reply forms reply to message thread displaying each user name by each message in the thread display "unread" when a thread has new content that hasnt been seen by current user delete or unpublish message thread (configurable) display total message thread count display total unread threads (threads that have new replies that the current user has not seen) delete all message threads and associated data (not meant for the users to have access to) road map
      send email to user on new message to a thread they are included in
    • By louisstephens
      So I was working on a module and trying to include a library (so I could use it across the site) using $modules->get('myModule'); . However, When I go to include the library folder (modeled after the LibFlourish module created some time ago). I keep getting: 
      site/modules/MyModule/libraryName/ProcessWire\filetoinclude.php This comes with an error notifying that "failed to open stream: No such file or directory in ...".. Is ProcessWire supposed to be in the include url, or is there a way around this? Sorry, I am quite new to working with my own modules.
       
      I just noticed the sub forum regarding Development, if someone could move this to the correct area I would appreciate it.
    • By louisstephens
      I wasn't quite sure where to post this, as this is a question regarding the module (sorry if it is in the wrong place). I was wondering if anyone has used the Email to Page module and figured out a way to "move" incoming css to another field, or how to render the css so the message just renders utilizing the css. 
      Right now all of the message contents get dropped into a textarea field and display in a template as a jumbled mess. Perhaps I am missing a formatting option in the text area field to render the css and html.