Jump to content

matjazp

Members
  • Posts

    722
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by matjazp

  1. Just to be sure: head -c 3 .htaccess | hexdump -C doesn't show ef bb bf? Did you restart apache after change?
  2. Double check your .htacces file as it looks like UTF-8 BOM issue.
  3. It would be helpfull if we could see your template files and includes (like footer.inc), I suspect there's still some mistake there - Oculi plus vident quam oculus
  4. You changed the ownership of files, what are their permissions? Is apache really running as www-data user/group? Anything useful in /var/log/apache2/error.log ? Maybe this could be helpful: http://askubuntu.com/questions/767504/permissions-problems-with-var-www-html-and-my-own-home-directory-for-a-website
  5. Could you try simple if/else instead of ternary: if($small) $template = new TemplateFile($config->paths->templates . "markup/events.inc"); else $template = new TemplateFile($config->paths->templates . "markup/event.inc");
  6. Sorry for troubles. Please upgrade to 1.0.6 if that fixes it (just uploaded to github).
  7. https://github.com/processwire/processwire-issues/issues/110
  8. Yes, this is how my site config.php looks like: /** * Installer: File Permission Configuration * */ $config->chmodDir = '0770'; // permission for directories created by ProcessWire $config->chmodFile = '0660'; // permission for files created by ProcessWire $config->fileCompilerOptions = array( 'chmodFile' => $config->chmodFile, 'chmodDir' => $config->chmodDir, ); That's an installer issue, it should add those two settings in /install.php after line 716.
  9. When FileCompiler,php compiles a file, the permissions on the compiled file/directory at /site/assets/cache/FileCompiler/... is not correct. It's 0644 and not what I've set in /site/config.php with $config->chmodDir and $config->chmodFile I can overcome this by puting this in /site/config.php: $config->fileCompilerOptions = array( 'chmodFile' => $config->chmodFile, 'chmodDir' => $config->chmodDir, ); Now, I see that there is $config->fileCompilerOptions in /wire/config.php: $config->fileCompilerOptions = array( 'siteOnly' => false, // only allow compilation of files in /site/ directory 'showNotices' => true, // show notices about compiled files to superuser when logged in 'logNotices' => true, // log notices about compiled files and maintenance to file-compiler.txt log. 'chmodFile' => $config->chmodFile, // mode to use for created files, i.e. "0644" 'chmodDir' => $config->chmodDir, // mode to use for created directories, i.e. "0755" 'exclusions' => array(), // exclude filenames or paths that start with any of these 'extensions' => array('php', 'module', 'inc'), // file extensions we compile 'cachePath' => $config->paths->cache . 'FileCompiler/', // path where compiled files are stored ); But, isn't /wire/config.php read first, and then /site/config.php and thus my config settings are ignored? I guess it's expected that we should set specific fileCompilerOptions but I think it could be misleading if we setup proper chmod in /site/config.php and expect that this would be honoured?
  10. I did Please use the latest version from github.
  11. Just before commit to GH I added /*NoCompile*/ option introduced in lasted PW dev and somehow added dot, don't know why I hope I didn't break other things... It's working fine on windows with php 7.1, tried on linux with php 7.0 and got an error. I just pushed a fix for that. Thx for reporting. Optimizers on linux: I can't make instructions on how to install them, since there are so many flavors of *x, but it looks like apt-get is now some sort of standard.
  12. I made some changes in v1.0.4 (just uploaded to GH). At the bottom at the module config you can see what is the path being search for local optimizers (executables) and which optimizers have been found. If optimizer is not found, then it's skipped. I extended the search path so you can put optipng, jpegoptim and gifsicle on the root of PW ($config->paths->root) on templates directory ($config->paths->templates) and assets directory ($config->paths->assets). If you have shell access then you can install all three mentioned optimizers with apt-get install optipng jpegoptim gifsicle Hope that helps.
  13. Hi, sorry for the late reply. I'm using OptimizerFactory library and that's how it works. Quick workaround would be changing the source code in the library, so that only one optimizer would run. Open /site/modules/AutoSmush/image-optimizer/src/ImageOptimizer/OptimizerFactory.php and change to this: $this->optimizers['png'] = new ChainOptimizer(array( $this->optimizers['optipng'], //reversed the order so optipng is first $this->optimizers['pngquant'], $this->optimizers['pngcrush'], $this->optimizers['advpng'] //)); ), true); //if true, just first optimizer will run, if false all optimizers will run I'll see what I can do, since others that are using this library has similar problems. Author of the library does not response to this issue, but we will find a solution. It might take some time though.
  14. It's meant to be, but it's not. Take this one: https://github.com/matjazpotocnik/DynamicRoles Edit on 3. Jan 2018: updated my version of droles with fixes for GH issues 14 and 16.
  15. jpegoptim_bin is just for jpegoptim, the other options are: optipng_bin pngquant_bin pngcrush_bin pngout_bin gifsicle_bin jpegtran_bin Would it help if you could enter the paths in the module settings page?
  16. It looks like executable is not found because it's not within the PATH. Do php -r "print getenv('PATH');" from shell or phpinfo(); from php and check for environment variable PATH. Make sure that jpegoptim (and others) are on the path. You could also check what shell is executed: echo shell_exec("echo $0"); It's possible that it's sh and not bash You may need to use the putenv command or determine whether your path needs to be set in /etc/profile, ~/.profile or ~/.bashrc in order for it to be picked up by the user runing php. Some versions of apache read configuration from /etc/apache2/envvars . You can set environment vars locally within a VirtualHost config using SetEnv. Or it might help if you put putenv('PATH=/your/path'); somewhere in the php, just for the test. You could also set the path of jpegoptim (and other binaries) by modifying optimizeSettings in AutoSmush.module: $this->optimizeSettings = array( 'ignore_errors' => false, //in production could be set to true 'jpegtran_options' => array('-optimize', '-progressive', '-copy', ' all'), 'jpegoptim_options' => array('--preserve', '--all-progressive', '--strip-none', '-T' . self::JPG_QUALITY_THRESHOLD), 'optipng_options' => array('-i0', '-o2', '-quiet', '-preserve'), 'advpng_options' => array('-z', '-3', '-q'), 'jpegoptim_bin' => '/path/to/jpegoptim', <== add this line ); All this is specific to the environment, so I can't give detail instructions on how to make "Local tools" to work. I'm also not a linux user, I tested tools on windows. Let me know how it goes.
  17. Oh! End $event->arguments[0] being the current rendered file ... Cute Thx for the hint!
  18. I'm after InputfieldFile::renderItem where $event->return is markup. I've updated the function so it works for Pageimage and Pagefile: /** * Returns Pageimage or Pagefile object from file path * getPageimageOrPagefileFromPath('/site/assets/files/1234/file.jpg'); // returns either Pageimage or Pagefile object * getPageimageOrPagefileFromPath('/site/assets/files/1234/file.txt'); // returns Pagefile object * getPageimageOrPagefileFromPath('/site/assets/files/1234/none.txt'); // returns null * * @param straing $filename full path to the file eg. /site/assets/files/1234/file.jpg * @param Page|null $page if null, page will be contructed based on id present in the file path * @return Pagefile|Pageimage|null * */ function getPageimageOrPagefileFromPath($filename, $page = null) { if(is_null($page)) { $id = (int) explode('/', str_replace(wire('config')->urls->files, '', $filename))[0]; $page = wire('pages')->get($id); } if(!$page->id) return null; // throw new WireException('Invalid page id'); $basename = basename($filename); // get file field types, that includes image file type $field = new Field(); $field->type = wire('modules')->get('FieldtypeFile'); $fieldtypes = $field->type->getCompatibleFieldtypes($field)->getItems(); $selector = 'type=' . implode('|', array_keys($fieldtypes)); //foreach(wire('fields')->find($selector) as $field) { foreach($page->fields->find($selector) as $field) { $files = $page->getUnformatted($field->name); if($files) { $file = $files[$basename]; if($file) return $file; // match found, return Pagefile or Pageimage //check for image variations foreach($files as $file) { //if(method_exists($file, "getVariations")) { if($file instanceof Pageimage) { $variation = $file->getVariations()->get($basename); if($variation) return $variation; // match found, return Pageimage } } } } return null; // no match }
  19. function getPageimage ($filename) { $f = str_replace(wire('config')->urls->files, '', $filename); $id = explode("/", $f)[0]; // get image field types $img = new Field(); $img->type = wire("modules")->get("FieldtypeImage"); $fieldtypes = $img->type->getCompatibleFieldtypes($img)->getItems(); unset($fieldtypes["FieldtypeFile"]); $selector = "type=" . implode("|", array_keys($fieldtypes)); foreach (wire('fields')->find($selector) as $field) { foreach (wire('pages')->find("$field>0, include=all") as $page) { $images = $page->getUnformatted($field->name); $pageimage = $images[basename($filename)]; // check should be performed that this image actually reside on the right page if($pageimage !== false) { if($page->id == $id) return $pageimage; // we have a match } } return null; // no match } var_dump(getPageimage('/site/assets/files/1087/img18.jpg')); // Pageimage object var_dump(getPageimage('/site/assets/files/1087/nonexistant.jpg')); // null EDIT: I should grab id from filename and search for image fields on that page only... I could also find image fieldtypes on the page itself...
  20. Yes, you would need a field and a page and I don't have that ...
  21. Nope, tried that before, page object need to be saved first.. Not this time, I'm in hook, but with markup only. I just believed that a function/method like $myfileobject = WiregetPagefile('/site/assets/files/1234/myfile.txt'); or $myfileobject = $page->getPagefile('/site/assets/files/1234/myfile.txt'); exist somewhere in the core or in core module.
  22. Thanx Robin (and Lostkobrakai) for you answers. It would work, but then I would need existing page. Ok, this was just an idea on how to crate fake Pagefile Let's try this more realistic approach: how to get Pagefile object if I don't know the field name file is attached to? I have page id so I could do $p=$pages->get($id); Now I would need to iterate through Pagefile fields on that page and on each field check if myfile matches. I was hoping for more elegant solution...
  23. I don't have $my_files_field. I know that Pagefiles are "connected" to the page that has FieldtypeFile, but I actually don't want to add a file to the page, I just want to create a Pagefile object, that has basename, filename, ext, size, url, httpUrl etc. methods/properties.
  24. How to create Pagefile or Pageimage knowing only file url, like /site/assets/files/1234/file.txt
  25. Module: Auto Smush PDF https://github.com/matjazpotocnik/AutoSmushPDF Compress PDF files automatically on upload, manually by clicking the link for each file and in bulk mode for all PDF files. In Automatic mode PDF files that are uploaded are automatically compressed. In Manual mode "Compress" link will be present. This allows manual compression of the individual PDF file. In Bulk mode all PDF files can be compressed in one click. Will process PDF files sitewide, use with caution! Using https://labstack.com/, free (at the moment) online web service that provides compressing of PDF files. There is no limit in file size and no limit on number of uploaded PDF's. No privacy policy available. EDIT April 30 2017: This module is not working anymore as Labstack removed support for pdf compression.
×
×
  • Create New...