Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/03/2018 in all areas

  1. I'm working on a module that makes easier to run tests, from within the admin. It's a process module and you can add pages anywhere in the admin and set each page a tests directory. So you can add new tester pages, or specify a path to an existing tests directory, see my TemplateLatteReplace module's tests in action on the screencap. Furthermore you can narrow the list of tests within a directory with URL parameters, to include only a few tests or exclude some. This may come handy if you don't want to run all the tests within a directory. Another handy feature is that you can re-run tests via ajax, that makes it easy to check whether your fixes are working (whether in "real" code or in test code).
    3 points
  2. I think just keep the dev version is fine. Gideon
    3 points
  3. @cb2004 I did this many years ago for a Textpattern site when I wanted to migrate the passwords from old style hashes to newer ones. I haven't got anything for PW, sorry. The methodology is pretty much what I laid out in the post above yours. Maybe others could advise you about the best hooks to use, but I'd guess at doing a before hook on session::authenticate(). Something like this in site/ready.php would be a start (totally untested)... wire('session')->addHookBefore('authenticate', function($event) { $user = $event->arguments(0); $pass = $event->arguments(1); $imported_md5_password_hash = trim($user->md5_field); // Is there a value for the imported md5 field? if ('' !== $imported_md5_password_hash) { // Yes! then create the md5 of what the user just typed in. // NB: You need to change this code so that the value generated here follows the algorithm for the generation of // the password set you imported. $md5 = md5($pass); // and see if it matches the stored value for this user if ($md5 === $imported_md5_password_hash) { // it does, so create and store the PW version of the $pass the user just typed in... $user->of(false); $user->pass = $pass; // @see https://github.com/processwire/processwire/blob/master/wire/core/User.php#L23 $user->md5_field = ''; // Clear the md5 field so this path is bypassed on next login. $user->save(); } } }); If the match on the MD5 hash works, it stores the PW-hashed version of the user's password and saves. As this is a before hook, and the password compare and replace happens here, I think that's all that should be needed. Of course, you still need to import those hashes into the "md5_field" above (rename as needed.) Adding an md5_field to the user template allows you to easily locate which users have updated and which haven't using normal PW selectors. YMMV - but I hope that starts you off in the right direction.
    3 points
  4. Update 2018-07-09: ProcessNetteTester module is available in the Modules Directory and on GitHub. This is a short tutorial on how to use Nette Tester with ProcessWire. As you will see it's very easy to setup and use and it's perfect for testing your code's functionality. With bootstrapping ProcessWire it's also possible to check the rendered markup of pages using the API, checking page properties, etc. It's also a great tool for module developers for writing better code. While there will be nothing extraordinary here that you couldn't find in Tester's docs this can serve as a good starting point. Prerequisites: PHP 5.6+ 01 Download Tester Go to https://github.com/nette/tester/releases and download the latest release (currently 2.0.2). Download from the link reading "Source code (zip)". You can use composer also if you wish. 02 Extract Tester files Create a new directory in your site root called "tester". Extract the zip downloaded here, so it should look like this: /site /tester/src /tester/tools /tester/appveyor.yml /tester/composer.json /tester/contributing.md /tester/license.md /tester/readme.md /wire ... 03 Create directory for test files Add a new directory in "/tester" called "tests". Tester recognizes "*.Test.php" and "*.phpt" files in the tests directory, recursively. 04 Create your first test In the "tests" directory create a new "MyTest.php" file. The first test is a very simple one that bootstraps ProcessWire and checks if the Home page name is "Home". This is not the smartest test but will show you the basics. Add this to "/tester/tests/MyTest.php": <?php namespace ProcessWire; use \Tester\Assert; use \Tester\DomQuery; use \Tester\TestCase; use \Tester\Environment; require __DIR__ . '/../src/bootstrap.php'; // load Tester require __DIR__ . '/../../index.php'; // bootstrap ProcessWire Environment::setup(); class MyTest extends TestCase { // first test (step 04) public function testHomeTitle() { $expected = 'Home'; // we expect the page title to be "Home" $actual = wire('pages')->get(1)->title; // check what's the actual title Assert::equal($expected, $actual); // check whether they are equal } // second test will go here (step 06) // third test will go here (step 07) } // run testing methods (new MyTest())->run(); I've added comment placeholders for the second and third tests that we will insert later. 05 Run Tester Tester can be run either from the command line or from the browser. The command line output is more verbose and colored while in the browser it's plain text only (see later). Running from the command line Navigate to the "/tester" directory in your console and execute this: php src/tester.php -C tests This will start "/tester/src/tester.php" and runs test files from the "/tester/tests" directory. The "-C" switch tells Tester to use the system-wide php ini file, that is required here because when bootstrapping ProcessWire you may run into errors (no php.ini file is used by default). You may load another ini file with the "-c <path>" (check the docs). If the title of your Home page is "Home" you should see this: If it's for example "Cats and Dogs", you should see this: Running from the browser First we need to create a new PHP file in ProcessWire's root, let's call it "testrunner.php". This is because ProcessWire doesn't allow to run PHP files from its "site" directory. The following code runs two test classes and produces a legible output. IRL you should probably iterate through directories to get test files (eg. with glob()), and of course it's better not allow tests go out to production. <?php ini_set('html_errors', false); header('Content-type: text/plain'); echo 'Starting tests.' . PHP_EOL; echo '--------------------------' . PHP_EOL; $file = __DIR__ . '/PATH_TO/FirstTest.php'; echo basename($file) . ' '; require $file; echo '[OK]' . PHP_EOL; $file = __DIR__ . '/PATH_TO/SecondTest.php'; echo basename($file) . ' '; require $file; echo '[OK]' . PHP_EOL; echo '--------------------------' . PHP_EOL; echo 'Tests finished.'; exit; Navigate to "DOMAIN/testrunner.php" in your browser to execute the file. If every test succeeds you should get this: If there are failed tests the execution stops and you can read the error message. If there were more tests (eg. ThirdTest), those won't be displayed under the failed test. 06 DOM test This test will check if a page with "basic-page" template has a "h1" element. We will create the page on the fly with ProcessWire's API. To keep things simple we will add the new test as a new method to our MyTest class. Add this block to the MyTest class: public function testBasicPageHeadline() { $p = new Page(); $p->template = 'basic-page'; $html = $p->render(); $dom = DomQuery::fromHtml($html); Assert::true($dom->has('h1')); } This will most likely be true but of course you can check for something more specific, for example "div#main". Note that we have used the DomQuery helper here (check the "use" statement on the top of the file). 07 Custom function test You will probably want to make sure your custom functions/methods will work as they should so let's write a test that demonstrates this. I don't want to complicate things so I'll check if the built-in "pageName" sanitizer works as expected. Add this to the myTest class: public function testPageNameSanitizer() { $expected = 'hello-world'; $actual = wire('sanitizer')->pageName('Hello world!', true); Assert::equal($expected, $actual); } This should also be true. Try to change the expected value if you are eager to see a failure message. 08 Next steps You can add more methods to the MyTest class or create new files in the "tests" directory. Check out the range of available Assertions and other features in the docs and see how they could help you writing more fail-safe code. Once you make a habit of writing tests you'll see how it can assist making your code more bulletproof and stable. Remember: test early, test often ? If you find out something useful or cool with Tester make sure to share.
    2 points
  5. Installing the zip (either from URL or Upload), rather than manually unzipping takes care of this stuff for you ?
    2 points
  6. @adrian @netcarver @horst, Thanks guys. There seems to be a problem. I don't know if I mucked up something server-side during maintenance or it's a GitHub thing. What's happening is that only one branch is getting saved, the one that was updated last. So, currently, only PW3 Master is available (you can tell by the folder pw3master here on the project page) since it was generated yesterday. The folders for the other branches are all missing. The next auto-update will be PW3 Dev, hence, it will wipe out pw3master folder. I will have a look at this when I get some time. I'm also wondering whether it is really worth maintaining PW2.7, 2.8 and 3 master? These docs are really for devs and my guess is that devs will most likely be using the latest and greatest PW version, i.e. PW dev. Any thoughts?
    2 points
  7. DEPRECATED If you are interested in the new version (commercial module launching in 2023) write me a PM --- Some of you might have followed the development of this module here: https://processwire.com/talk/topic/15524-previewdiscussion-rockdatatables/ . It is the successor of "RockDataTables" and requires RockFinder to get the data for the grid easily and efficiently. It uses the open source part of agGrid for grid rendering. WHY? ProcessWire is awesome for creating all kinds of custom backend applications, but where it is not so awesome in my opinion is when it comes to listing this data. Of course we have the built in page lister and we have ListerPro, but none of that solutions is capable of properly displaying large amounts of data, for example lists of revenues, aggregations, quick and easy sorts by the user, instant filter and those kind of features. RockGrid to the rescue ? Features/Highlights: 100k+ rows Instant (client side) filter, search, sort (different sort based on data type, eg "lower/greater than" for numbers, "contains" for strings) extendable via plugins (available plugins at the moment: fullscreen, csv export, reload, batch-processing of data, column sum/statistics, row selection) all the agGrid features (cell renderers, cell styling, pagination, column grouping etc) vanilla javascript, backend and frontend support (though not all plugins are working on the frontend yet and I don't plan to support it as long as I don't need it myself) Limitations: While there is an option to retrieve data via AJAX the actual processing of the grid (displaying, filtering, sorting) is done on the client side, meaning that you can get into troubles when handling really large datasets of several thousands of rows. agGrid should be one of the most performant grid options in the world (see the official example page with a 100k row example) and does a lot to prevent problems (such as virtual row rendering), but you should always have this limitation in mind as this is a major difference to the available lister options that do not have this limitation. Currently it only supports AdminThemeUikit and I don't plan to support any other admin theme. Download: https://gitlab.com/baumrock/FieldtypeRockGrid Installation: https://gitlab.com/baumrock/RockGrid/wikis/Installation Quikckstart: https://gitlab.com/baumrock/RockGrid/wikis/quickstart Further instructions: https://gitlab.com/baumrock/RockGrid/wikis/quickstart#further-instructions German Translation File: site--modules--fieldtyperockgrid--fieldtyperockgrid-module-php.json Changelog: https://gitlab.com/baumrock/FieldtypeRockGrid/raw/master/changelog.md Module status: alpha, License: MIT Note that every installation and uninstallation sends an anonymous google analytics event to my google analytics account. If you don't want that feel free to remove the appropriate lines of code before installation/uninstallation. Contribute: You can contribute to the development of this and other modules or just say thank you by testing, reporting issues and making PRs at gitlab liking this post buying me a drink: paypal.me/baumrock/5 liking my facebook page: facebook.com/baumrock hiring me for pw work: baumrock.com Support: Please note that this module might not be as easy and plug&play as many other modules. It needs a good understanding of agGrid (and JavaScript in general) and it likely needs some looks into the code to get all the options. Please understand that I can not provide free support for every request here in the forum. I try to answer all questions that might also help others or that might improve the module but for individual requests I offer paid support (please contact me via PM). Use Cases / Examples: Colored grid cells, Icons, Links etc. The Grid also has a "batcher" feature built in that helps communicating with the server via AJAX and managing resource intensive tasks in batches: Filters, PW panel links and instant reload on panel close: You can combine the grid with a chart library like I did with the (outdated) RockDataTables module:
    1 point
  8. This module allows users to subscribe and unsubscribe to a newsletter, it doesn't handle newsletter creation and delivery (I use a foreign service for this). There is one method to subscribe (by using a form) and there are two methods to unsubscribe (by using a form or by providing a link in the newsletter). Furthermore you can notify any person e.g. an administator via email when an user has subscribed/unsubscribed. For detailed information have a look at Github.
    1 point
  9. This week we've got a lot of updates on our core dev branch, including new features, issue resolutions and more. For starters, we've added support for making the Trash and Restore features available to non-superusers, along with related improvements. Plus we've got several new useful and interesting page traversal methods and properties added to our $page API. https://processwire.com/blog/posts/processwire-3.0.107-core-updates/
    1 point
  10. yes, i know, i'm talking about site profiles that require no coding https://modules.processwire.com/categories/site-profile/ and these:
    1 point
  11. Hi, ProcessWire does not compete with the WordPress market... Thank the lord. ProcessWire is for developers with basic to advanced knowladge who need a tool to make their vision a reality, easier. A framework. Much like jQuery. You must have some knowledge of JavaScript to fully understand jQuery. Just like if you were to develop for WordPress, you'll need PHP knowledge. Well, unless you are looking to sell themes. I don't know why a PHP developer would touch WordPress. ProcessWire's API is so much easier. So to answer your question, in ProcessWire you start here - http://php.net/docs.php then here - https://processwire.com/docs/ In WordPress you start here - https://wordpress.org/plugins/ then here - https://codex.wordpress.org/FAQ_My_site_was_hacked Edit: Notice how the 'My site was hacked' question was in the Frequently Asked Question section... Should it really be a frequently asked question? Because I don't think I've seen it asked once on the ProcessWire forum. Edit2: Most people here just use the blank profile and see the other profiles as bloat.
    1 point
  12. Thanks Adrian, but I don't think that's it. I'm not using the Functions API in that line but rather the shorter selector syntax that was introduced here: https://processwire.com/blog/posts/processwires-roadmap-in-2015/ $this->pages is the API $pages object - what Ryan calls "a Wire-derived object (alternate syntax)" in the blog post linked to above. And that should work because ultimately a custom action for AdminActions extends Wire. It all looks right when I do some debugging dumps: protected function executeAction($options) { $is_wire = $this instanceof Wire; bd($is_wire, 'is_wire'); bd($this->pages, 'this->pages'); //$p = $this->pages(1); } But when I uncomment the last line with the latest module update I get a different error: So somehow $this->pages($selector) is interpreted as being a (missing) method of Test. But I can use the same line in methods of other modules without a problem. Weird.
    1 point
  13. The problem was, that I did not rename the downloaded folder from Gitlab from "RockGrid-master" to "RockGrid". After doing this, it works
    1 point
  14. Thank you Bernhard for finally releasing this module. I can not wait to play with it and share improvements, if I have any. I really can think of many use cases where this grid would be mandatory because it offers so much possibilities.
    1 point
  15. Long shot, but I had this recently on the frontend - I was viewing the site via its IP address and I hadn't added this to the allowed hosts in the config.php file yet. As soon as I added, it loaded properly.
    1 point
  16. I just discovered the module today and it is very handy for my Cients <-> Contracts many_to_many relation. Now I can connect those from both ends. Works! Fantastic! Thank you very much for this time-saver.
    1 point
  17. No there's no way around this really, but my solution is the combination of these two modules: https://modules.processwire.com/modules/email-new-user/ With this, when a new user is created they are automatically assigned a password and this is sent to them via email. https://modules.processwire.com/modules/password-force-change/ This ensures that the next time they login they have to change their password. I think this combination is the easiest way to migrate large numbers of users to PW.
    1 point
  18. On such a large site I reckon it would be worth investing in some professional advice. https://processwire.com/api/modules/profiler-pro/ Besides the tool itself there is the valuable benefit of VIP support from Ryan:
    1 point
  19. Use Opcache to cache raw PHP Update your PHP version Use ListerPro to customize your listings, so you will use fewer server resources to list pages for every user.
    1 point
  20. Finally I was able to release RockGrid I decided to release it as MIT, so everybody can contribute and maybe use it for other great additions to ProcessWire. I think it's a great way of listing data and I can think of several situations where it would make the admin UI a lot better than it is now with our existing tools. For example @adrian s batch child editor could maybe benefit from such a tool? I don't know. Let's see what happens... The module is still alpha and not perfect... But it was also a lot of work and can't provide anything better than that at the moment. If anybody here can do it better: Please feel free to take over ? Thanks everybody for all the feedback here in this thread! Special thanks to @MrSnoozles for showing me agGrid and making me replace datatables ?
    1 point
  21. Building a website is not the problem. Running a business with it can become the problem. Collecting e-mail addresses, tracking visitors and monitoring visitor-behaviour, combining it with 3rd parties like Facebook and ad networks will be a much bigger thing now. Cookie permissions here, double-opt-in there, and so on... it will be much more challenging than before. Don't know anything special about sources in Spain, UK, US but here in Germany there are some lawyers offering (free and paid) help for all kinds of businesses. Just to name two I prefer: https://www.e-recht24.de/ and https://drschwenke.de/ And as always with legal stuff: lawyers are my one and only trusted source. Not other companies (like the one above) that offer checklists, guides and tutorials.
    1 point
  22. Works a treat. Just the fact, that the two tables in the database are redundant, is a bit sub optimal. I guess it is because of how the page field works? But I can live with that. Thank you.
    1 point
  23. This is what I'm doing, been on plain JS for months. Still trying to get my head round that damn prototypal inheritance. My JS progress is so slow it's unreal, I just don't seem to get it. If there was another option for web programming, I'd be skipping JS entirely.
    1 point
  24. Hi @microcipcip - thanks for a really great commentary on PW, what frontend devs are looking for, and how PW can fit those needs. I am really excited to see your integration of GraphQL into your ProcessVue site profile - definitely planning on using it on an upcoming project. Thanks again for all your great work on this.
    1 point
  25. I am glad that this project is helping ProcessWire getting more devs on board :). I just want to say that I wouldn't have been able to finish ProcessVue if it wasn't for the amazing ProcessWire community. I believe that the community truly is the biggest selling point for new users (like me). Before trying ProcessWire I used OctoberCMS for a while but when I was stuck I got 0 support from the forums, so...althought the CMS is based on the amazing Laravel framework, I just left! I think that ProcessWire is extremely powerful and flexible and with time will become the tool of choice for frontend developers, the new GraphQL module will also help on this direction. Droves of frontend developers are looking for a CMS like this, they just don't know it exists! The usual keywords they use when looking for a SPAs CMS is "Decoupled CMS" or "Headless CMS", and I believe that that's exactly what ProcessWire is for! Some frontend developers prefer to use NodeJS, but the learning curve is huge if you need it for a non trivial project, and the worst thing of all is that after two weeks ANY js tool you may have used is outdated. See for example how Angular has been replaced with React or Vue, and Gulp with Webpack. That doesn't mean that I am against improvements in this regard, I just feel that it's just too much for us poor frontend devs to cope with! ProcessWire is stable, easy to use and won't change API every week. BTW, after that I migrate ProcessVue to GraphQL I am also planning to add Auth0 login integration with JWT, as I think that login/signup is a common feature in SPAs. I am sure I'll have to annoy @Nurguly Ashyrov and the rest of ProcessWire community for getting it in sync with ProcessWire users, but the result should be quite useful
    1 point
  26. Cool stuff, @microcipcip! Please do write a tutorial when you have time. I am sure it will be useful to many of us in the community. Surely it will be for me . It seems like your boilerplate is not in a site profile format. Is there a reason for that? If not, consider using it, as it is a common way to distribute site boilerplate code and could make your work easier to reuse for PW people.
    1 point
×
×
  • Create New...