Jump to content

rot

Members
  • Posts

    26
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by rot

  1. Hi arjen! Yes, I am still using the module but with an old processwire install. I just never published it to the repository. Just send me the pull requests and I will recheck and finally publish the module. I did't find the time to do so when I first did it and then I just forgot. It would be a waste if it works fine and others don't find it.
  2. I changed the directory structure to conform with Processwire standards and renamed the module classname to FormDiceCapture to conform naming conventions. The version number has been increased to 0.1.1. In case you have the module installed you will have to change the calls to $modules->get('DiceCaptcha') to $modules->get('FormDiceCaptcha'). Sorry for any inconvenience caused by that. I though I might rather change that now than later when there is more users.
  3. I changed the directory layout to conform with Processwire module standards. To do so, the github repository had to be renamed. The version number was increased to 0.11 BTW: I asked myself if one should extend this module to allow for arbitrary class additions to parent elements. If there is the need for another selector that adds a class to an element based on the existence of a sub-element I could change the class to allow for that.
  4. So i would like to rename the Module to "FormDiceCapture" and rename the github repository. Is this OK to do? I assume hardly anybody has installed the modlue yet but it might break their update path? One can NOT create zip files of subdirectories. So the correct proces is to: set up a repository called "ProcessMakeCoffee" and put ProcessMakeCoffee.module into it
  5. Thanks for the reply. Unfortunately I did not really completely understand it. First there ist this CamelCase naming. The module directory and the "main" module should have that CategoryCamelCase.module name. Like ProcessMakeCoffee.module. I think I understood that one but I could not think of a good category for the DiceCapture. Maybe "Form" or something like that? On github the default zip file packs all file into a directory called like the "repository-name". So if you would set up a repository called "make-coffee" and then create a directory called "ProcessMakeCoffee" and put ProcessMakeCoffee.module into it The zip layout would be as follows: make-coffee ^-ProcessMakeCoffee ^-ProcessMakeCoffee.module Is this a good layout? Or should I rather: set up a repository called "ProcessMakeCoffee" and put ProcessMakeCoffee.module into it The zip layout would be as follows: ProcessMakeCoffee ^-ProcessMakeCoffee.module Maybe one can also create zip files from subdirectories on github. No idea about that. Else the repository name would have match. Should I rather use the first or the second project layout?
  6. Anyway I just updated the git files to 'version' => 10. Hope that solves the issue. One more question: I have the zip file pointing to a file that contains two subdirectories (s. https://github.com/romanseidl/dice-captcha/archive/master.zip) as the module is in a subdirectory. Is this a good thing to have?
  7. Oh. Sorry. Thanks for the info. What version should I set in the files to correspond to 0.1? 10? Or 0.1?
  8. I did not mean to criticise or offend you. Its great that you shared your work.I just did not understand what made you write the module and not use the other one from the intro provided with this post and thought it might be of help if you tried to answer that question here. I asked for the USP if you want to call it that way.
  9. Just a stupid question: What is the advantage over using the GUMP-based module?
  10. rot

    Integration needed

    What do you want to achieve? Integrate search results?
  11. I have also been considering to use a file for this kind of thing. Probably it would be the easiest way also to provide some kind of "safe transactions" as for my case this is about long running processes that might die somewhere in the making. But I could also write that to the db as I am using that anyway to get process config info. So I would have to set a start flag (in the db or to a file) and consider the job as dead if it doesn't reply within a certain amount of time.
  12. Concerning the locking issue: Is there even something like locking? Or am I just confused? As thre is no middleware (confuses me ) there should be no problem with setting such a module to singular and still serve multiple requests in paralell. All locking there is is in the db. Or am I wrong? I studied $modules->getModule() and it shows that : $modules->get tries to find the module in the WireArray of $modules that should contain all installed modules. Those who are on autoload have been initialized. If it is NOT singular it gets recreated. And if it has not been initialized (because it is not on autoload or not singular) it get initialized. This seem to imply that a module that is on autoload and not singular produces an autoload instance and then a new one for each $modules->get(). LazyCron is autoload but not singular and it hooks onto: $this->addHookAfter('ProcessPageView::finished', $this, 'afterPageView'); Maybe it is not important that it is not singular as LazyCron is should not be directly called but hooked: $this->addHook('LazyCron::every30Minutes', $this, 'myHook'); Also concerning the hook I looked at "Jumplinks" and this hooks to "Page not Found" which seems pretty nice for something that should try not to slow down the regular page view process: $this->addHookBefore('ProcessPageView::pageNotFound', $this, 'scanAndRedirect', array('priority' => 10)); Funny enough I could not find out what Jumplinks is doing in terms of liefecycle. Probably it is using the getMolduleInfo defaults and thus it is not singular (but is it autoload? i suppose it has to be)
  13. The problem was a database timeout. I fixed the timout problem by using the following to reconnect if needed. $data = $backup->run($web); //force reconnect if database has been lost due to long job runtime try { $this->setJobData($id, $data); } catch (Exception $e) { $this->modules->wire('database')->closeConnection(); $this->setJobData($id, $data); } Not the most beautiful solution. I would prefer to have a $db->ping() method as there was with mysqli. Maybe that would be a good extension to the DBO? I created a pull request: https://github.com/ryancramerdesign/ProcessWire/pull/1097 Its not dead important but I think it would be nice.
  14. max_execution_time is set (by calling set_time_limit() - it probably only works if the php setup allows so - ill have to check). You can set that in the admin:) The Script runs until it is nearly finished. Then I want to save the result (info the job was successful and the log) to the database. So its probably what you call a "summary". So maybe this is a seperate database timeout? Does processwire open a mysql connection for every request? Maybe that connection just dies after some minutes of doing nothing. There can always be more Like e.g. class based loggin in a LOG4J style. But more is not always better. At the moment I don't log to files by default (which might be a bad Idea considering the database timeouts...) but I used to log to an own log file.
  15. I use my own log file(s) by using the LogFile class. Is that all there is? There is this $this->message and $this->error functions. Maybe one should implement them too. At the moment I only implement log() and it does not forward to the Wire baseclass logger. I will look at LazyCron Thx. For the moment I seem to lose the database connection on long runninng jobs which is a problem because I want to save the results to the database: Exception: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away (in /home/.sites/306/site1268/web/wire/core/Modules.php line 2416) This error message was shown because you are logged in as a Superuser. Error has been logged.xception: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away (in /home/.sites/306/site1268/web/wire/core/Modules.php line 2416) This error message was shown because you are logged in as a Superuser. Error has been logged. Any ideas on how to avoid that?
  16. I spent way too much of my spare time with trying to produce an overly complex site backup module. Anyway - it is here in a pre-release state. I somehow have to get rid of the monster. Features: Use Storage Providers There are two base classes for Storage modules and three reference implementations: Remote Storage Driver This is a baseclass for construcing plug-in modules that allow to send data to a remote storage. You need to extend all abstract functions: connect, disconnect, upload and getConfigFieldset Implemented Examples Storage Mail Sends a backup as mail attachment. If the file size exceeds a set limit it will get split. It uses PHPMailer library as WireMail does not support attachments. @todo: For now this mails all in a single smtp session - maybe thats not so safe? Remote Directory Driver This is a baseclass for construcing plug-in modules that allow to send data to a remote storage and list and delete old files. You need to extend all abstract functions: connect, disconnect, upload, find, size, mdate, delete and getConfigFieldset. Implemented Examples Storage FTP Allows to connect to an ftp server and upload, list and delete files. Uses standard php ftp functions. Storage Google Drive Allows to connect to google drive server and upload, list and delete files. Uses the php google api. You have to create a Service account with the google developers console and add the key file to the plugin directory (or another directory if you specify a relative or absolute path to that file). s. https://developers.google.com/identity/protocols/OAuth2ServiceAccount#creatinganaccount I don't use the OAuth token process because it is not more secure. Once there is a renew token (which is necessary to avoid user interaction) it is as powerful and insecure as a keyfile. It is just more complex as it needs a callback url for registering. @todo? In case you can prove otherwise I will implement the callback registration. Run from the web or the command line It's allways better to have a regular cron job running. But sometimes you might need webcron Command Line You just need to call backup.php with the id of a backup job and it will be run Web Cron There is a token that starts the backup job from the web if passed as a url parameter. You can specify whether you want logging the http stream or not. You can also specify whether you want a job to be repeated within a certain timespan. This is for using unreliable webcron services by hitting the backup multiple times. @todo Consider integration of cron.pw @todo I use the init function of an automatically loaded module as a hook. This seems a bit strange. Is there better ways to do that? Log to mail, file and admin You can recieve logs by mail (on success or failure), log to a file and see log in a an admin page: Configure I built a admin interface that - besides the log viewer - features a list of jobs: and an editor for the job (which is too extensive to be described in detail): Dicussion I am not too sure on how to solve the issues indicated with @todo. My main concern are the hooking (init of an autoload module for the moment) and locking (none, no singleton for the moment). As for hooking I only know of the alternative of using a page where one would have (afaik) to use a special template as the admin template is secured or hook into the security functions (which would probably call for a singleton module). Concerning the locking issue I think it might be good if the Admin Class would lock if it is updateing something. For the moment this is the same class that runs the backups thus it would also lock the admin if there is a backup running. And it would lock the whole site if it is on autoload (as I use the init hook). Lastly I should reconsider the logging and maybe try to better integrate it with processwire logging. I would appreciate comments and suggestionsn on these issues. I appreciate your test results. Don't be took frutsrated if something goes wrong, this is at an early stage but afaik it should be running. Please find the modulle on: https://github.com/romanseidl/remote-backup
  17. I would like to use Googles OAuth method to securely authenticate for a google service. Anyway, to do so I would need for a URL on the site that gets redirected to the plugin. Is there a recommended way to do so? I could use some hook on a very low level? Or should something like this be avoided as it migh interfere with the pages and their hiearchy and e.g. set up a page for that (is that possible programmatically?)
  18. rot

    Backup

    Thanks for the reply! Is there documentation on how the "site-profile" looks like? It's kind of hard to figure out from the plugin. For the database backup: Thats no problem and worked fine.
  19. rot

    Backup

    I produced a module that: backups the db zips the site uploads the zip to google drive The module is not ready for publication yet as it has to be tested more thouroughly and the code has to be revised first. There is a question tha arised in the making of the module: Is there a documentation of the standard procedure on how to backup a site? I just used: WireDatabaseBackup wireZipFile to do so. I had to figure out which directories to include and whicht to omit. As I looked into exisitng modules I came accross "Site Profile Exporter". This one claims to produce a site profile which is easily reinstallable. I am not aware if this is really the case as the module is from 2012. But the ideas seems promising. Is this idea still existing? And if so is it documented? I could not really understand what "Site Profile Exporter" is doing as it is a bit of a mess in mixing presentation and business logic. Call me a middleware developer lost in a php publishing system but still I hate when people zip something in between of creating a form.
  20. I added a config interface for the num_dices and the image size. Beyond I added a version number to the module info.
  21. This could easily be the case. I think that DOM adds a memory overhead but it might be faster especially with more complicated searches. Hard to tell which choice is better with this. I sticked with Martijn Geerts' example and my slight preference for low memory usage over possible speed.
  22. Thanks for your comment! I considered that but I discarded it because i think that using DOM might add unneccesary overhead to a very simple filter. I don't know if this is the case but I suppose using regexp scales better. If anybody thinks this is not the case please let me know. P.S.: I don't know if you remember the good old SAX vs. DOM disccussions? Haven't seen any within the last years but they were very common at least within the java-xml community
  23. Ok great. I was not 100% sure if setting it to "single" would be the perfect solution as I'm still not too familiar with the module architecture. But it seems reasonable to me, and if it also seems reasonable to you then its fine. At least it works fine for me even when scaling 50 images in a row for a automatically generated slideshow. Thanks for the plugin, it produces way better results than the standard image plugin in terms of quality. BTW: I needed centred scaled down images that are not cropped and keep their proportions. Thus I had to add the following code: function galleryimage($image) { if(($image->width / $image->height) > (600 / 400)) return $image->pimLoad("gallery")->width(600)->canvas(600,400)->pimSave(); else $img = $image->pimLoad("gallery")->height(400)->canvas(600,400)->pimSave(); } Maybe you could add an option to scale that allows to keep proportions that way as this is something others might need too. Actually this task was the reason for me to choose pim as this is not done correctly by the standard scaling algorithm, it seems to produce images that are not centred when you add an image that has the correct width but not the correct height. So when calling this with an image of e.g. 600x300 i would get a reulting image where all the added vertical canvas is on the bottom or if i remeber correctly it just returned the orignal image even though it was of the wrong size. return $image->size(600, 400, array( 'upscaling' => true, 'cropping' => false, 'quality' => 97 )); But thats something for the core module developers maybe.
  24. I had the common css problem of not beeing able to format a link by its children. Thus I ended up producing a very simple Textformater: TextformatterImageLinkInterceptor Processwire Image Link Interceptor Module @copyright 2015, Roman Seidl based on HTML Image Interceptor Textformatter @copyright 2013, Martijn Geerts Licensed under GNU/GPL v2, see LICENSE.TXT This module simply adds a class to all images that ae contained in a link as the first child. Thus the following: <a href="/"> <img src="/site/assets/files/1/hansi.jpg" alt="Hansi"> </a> Should be filtered to be: <a class="imglink" href="/"> <img src="/site/assets/files/1/hansi.jpg" alt="Hansi"> </a> Github: https://github.com/romanseidl/TextformatterImageLinkInterceptor/blob/master/README.md Changelog 0.1.1 Changed the directory layout to conform with Processwire module standards. To do so, the github repository had to be renamed.
  25. I released a simple module: Processwire Dice Captcha Module This is a very simple captcha module. For more extensive information please read the REAMDE on github. If you want you can change the jpg files and adapt the size setting in the module accordingly. This should also increase security as if you use more complex images they will be harder to recognize. You can als change the number of dices asked for. Usage: <?php //Init Module $dice = $modules->get("FormDiceCaptcha"); //On submit check if the validation is correct if($input->post->submit) { //validate - the value is stored in the session if(!$dice->validate($input->post->captcha)) echo "<p class='error'>".__("Please check that you have completed all fields")."</p>"; else echo "Success!"; } ?> <form method="post" action="./"> <!--Show captcha --> <img src="$dice->captcha()"/> How much is the sum of the dices? <!--ask for sum --> <input type="text" name="captcha" value="$form[captcha]"/> <input type="submit" name="submit" value="submit"> </form> Github: https://github.com/romanseidl/FormDiceCaptcha Changelog 0.1.1 Changed the directory structure to conform with Processwire standards and renamed the module classname to FormDiceCapture to conform naming conventions. Also the github project had to be renamed. In case you have version 0.1.0 installed you will have to change the calls to $modules->get('DiceCaptcha') to $modules->get('FormDiceCaptcha') after updating to 0.1.1.
×
×
  • Create New...