Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by gRegor

  1. Late reply here, but I have some PHPunit tests in my IndieAuth module: https://github.com/gRegorLove/ProcessWire-IndieAuth/tree/main/ProcessIndieAuth/tests bootstrap.php: loads the Composer dependencies and ProcessWire via its index.php ClientIdTest.php: I think this file is older and needs to be updated, but it still gives an idea how I load the module and test methods within it. ServerTest.php: newer file which shows testing additional classes in the module. In this instance, this is like any generic PHPunit testing since that class is static methods and isn't calling ProcessWire methods.
  2. Just pushed a bug fix: During install it now adds the role "indieauth". Assign this role to any users that should be able to authenticate / authorize IndieAuth clients. The README has been updated accordingly.
  3. I have slowly but surely been working on an IndieAuth module for ProcessWire. IndieAuth lets you sign in to applications using your domain name and grant access to read/write to your site. I initially set up a version of this in 2016. My understanding of IndieAuth was limited at the time and it really only let you use IndieAuth to sign into your own site. There are some interesting possibilities there, but it was premature. (I'm making this separate thread to clearly separate them.) So what does this module actually do? 1. Authentication: When you visit a site like indielogin.com and enter your domain name, you will be taken to your ProcessWire admin area to approve the request. If you approve the request, you will be returned to the site and logged in as your domain name. 2. Authorization: When you visit an application like Quill, it needs to also get your permission to post to your site. You will be taken to your ProcessWire admin area to approve the request and the scopes that the app is requesting (create, update, delete, etc.). If you approve the request, you will be returned to the app, logged in as your domain name, and the app will have an access token for your site. Features Browse the applications you have granted access tokens to. See when each one was granted, last used, and will expire. Revoke any application’s access tokens Set the default expiration period for new access tokens. The initial default is 14 days. During authorization, confirm and change the scopes granted to the application. For example, an app may request “create” and “delete” scopes, but you can grant only “create.” During authorization, you can also choose to grant an access token with no expiration Try it out! I have been testing the new module and think it is almost ready to release in the ProcessWire modules directory. I would like to have a few more people beta test it and provide feedback first, though. If you’re interested, follow these steps: Download ProcessWire IndieAuth from Github and follow the instructions there to install it Test Authentication: visit indielogin.com and enter your domain name. Follow the prompts to authenticate and you should end up back on indielogin.com with a success message. Test Authorization: visit Quill and enter your domain name. Follow the prompts, noting the additional fields for scopes and expiration. After successfully authorizing, you should end up back on Quill with a success message. Go back to the ProcessWire admin area of your site. Visit Access > IndieAuth and you should see an entry for the access you just granted to Quill. Optionally test access tokens To test access tokens, you will need a module that accepts them. I have set up a minimal Micropub module for that purpose. All it does currently is verify the access token and shows a debugging message indicating the request was received. Follow the instructions to install the Micropub module. Go back to Quill and try to post a short note to your site. Quill is expected to respond with “Something went wrong,” but scroll down and the section labelled Micropub response should show “Debugging: Micropub request received.” If you see that, it means the Micropub module successfully received and verified the access token! The Micropub module will eventually be fully functional so you can publish to your site using a variety of Micropub clients, but that is a separate project that is going to take me some more time. I wanted to get the IndieAuth module out there instead of waiting to release both at the same time. More information If you’re interested in more details on IndieAuth, I recommend “OAuth for the Open Web” by Aaron Parecki. If you are interested in implementing IndieAuth in your project, see the IndieAuth specification. Originally published: https://gregorlove.com/2021/10/indieauth-for-processwire-development/
  4. In case you are still experiencing this, it appears it is related to the server upgrade, a mod_security issue, not ProcessWire. I just ran into this myself and my searching led to an acquaintance's similar issue in this post. I filed a support ticket with DH and expect they'll get it fixed shortly. It is probably a per-domain or per-account issue, so I'd suggest contacting support if you haven't already.
  5. Hi Robert, I just replied over there as well. The additional detail here of "Call to a member function render() on null" does point to a few possibilities that I'd check in order: 1) FieldtypeWebmention is installed? 2) Template has a field of that type 3) Field name matches what's used in your code.
  6. @isellsoap Glad you like it. Let me know if you have any questions.
  7. This looks awesome! I was considering a similar advanced DateTime module that would store the UTC offset in addition to the timestamp, so in the UI you could select the date, time, and timezone. I might try this out and see if I can extend it for that purpose.
  8. That sounds like an odd server setup. $config->path->assets should give you the full path. Glad you got it working, though.
  9. For redirection (PRG), you can use http://processwire.com/api/ref/session/redirect/ Since you're using POST values in your selectors, you should sanitize them first. To customize the selector based on which fields are submitted in the POST, I would do something like this: $temp = []; if ( $input->post->product_brand_name ) { $temp[] = 'product_brand_name=' . $sanitizer->selectorValue($input->post->product_brand_name); } if ( $input->post->product_type ) { $temp[] = 'product_type=' . $sanitizer->selectorValue($input->post->product_type); } // ... and so on $selector = implode(',', $temp);
  10. PW's `$session` stores data in `$_SESSION` but it's "namespaced" in the array. E.g. `$session->value` != `$_SESSION['value']` I'd recommend using the PW `$session` if possible instead of mixing and matching with `$_SESSION`. In PW3 you can also use `$input->requestMethod()` for request method checks. https://processwire.com/api/ref/session/ https://processwire.com/api/ref/input/
  11. Oops, I made a mistake in the directory update! I linked to the PW2 zip file instead of the PW3 zip file. If you tried to install this on PW3 using the "Add Module From Directory" option between yesterday's announcement and just now, please uninstall and try installing it fresh. The directory is updated now to point to the correct zip file. If you're on a PW2 site, the instructions in the release post are still correct.
  12. This works for me when hooked in ready.php (see below). It looks like if you're hooking within a template include, it's too late in the ProcessWire startup / page delivery process. That's what @kongondo was referring to with "too late". It's more than just the order of the includes in the template file, or whether your script exits instead of continues. Here's the code that worked for me in /site/ready.php: <?php namespace ProcessWire; function hookPath(HookEvent $event) { echo sprintf('The path is: %s', $event->return); exit; } $wire->addHookAfter('Page::path', 'hookPath'); I still think hooking like this to perform a redirect might be overkill for what you described in your last post.
  13. I'm trying out these hooks myself to see if I can get them working, however based on your latest post I might suggest a different approach. If you have URLs that are going to have that many query parameters and lots of variants, you might be better off writing code to process them using the `$input->get` variables and then redirect to the correct page using `$session->redirect()`. I presume if the query parameters have different values, they'll go to different destinations. Alternately, if these are a lot of legacy URLs that you want redirected to new canonical pages, putting those redirects directly in .htaccess with mod_rewrite might be better (or using a redirect URLs plugin).
  14. Version 2.0.0 is finally here and supports ProcessWire 3! Release post: https://gregorlove.com/2018/05/webmention-for-processwire-update/ Modules directory: https://modules.processwire.com/modules/webmention/ Update to support ProcessWire 3.x Update php-mf2 library to version 0.4.x Improve verification of source linking to target Fix delete webmention bug Fix webmention author display in admin Fix WebmentionList render() method If you're still on ProcessWire 2, you're not forgotten. :] Check the release post for more details. As usual, if you are using this plugin I would love to hear from you. Feel free to send webmentions to the release post linked above.
  15. Aha, that makes sense. For now I'll make a note the field should be entered in uppercase, then I'll use strtoupper() when building my selector. Thanks!
  16. I've done a simple version of this by hashing the file's modified time: $js_version = md5(filemtime($config->paths->assets . 'js/script.js')); echo sprintf('<script src="%sjs/script.js?v=%s"></script>', $config->urls->assets, $js_version);
  17. I understand from the selectors documentation: I have a repeater field `promo_codes` consisting of text field `title` and an integer field `number1`. I'm running a find: $page->promo_codes->find('title=gmtest'); The database column collation is `utf8_general_ci` so I would expect this to work, but it only works when I match the case exactly ("GMTEST"). This is on PW 3.0.42. Any ideas? Is there an exception for finds on repeater fields?
  18. I'm working on a PW 3.x version of the module in this branch: https://github.com/gRegorLove/ProcessWire-Webmention/tree/master-pw3. It's in beta currently; it should generally work, but if you run into any problems, let me know. Also, I realized it was not obvious that the webmention endpoint requires a template file in order for this plugin to work. Otherwise the endpoint would return 404 to any requests. I've added a sample template file here and info in the README: https://github.com/gRegorLove/ProcessWire-Webmention/blob/master/Webmention/extras/site/templates/webmention-endpoint.php I hope to release 1.1.4 soon along with an official PW3 version.
  19. I'm running into this too, with my Webmentions module on a fresh install (the FieldTypeWebmention I based a lot on this comments module). Best I can tell, the issue seems to be that when you add a field, getDatabaseSchema is called for the first time. Since there is no $field->schemaVersion set at that point, it tries to run the first ALTER TABLE query before the field's table has been created. Update: I think I've found a solution. In getDatabaseSchema I first set a boolean: $table_exists = in_array($field->getTable(), $this->database->getTables()); Then any schema upgrades can be inside an if/else conditional: if ( $table_exists ) { # update to schema version 1 if ( $current_schema_version < 1 ) { # perform schema updates } } else { $field->schemaVersion = self::SCHEMA_VERSION; $field->save(); } I'm also tracking the current schema version in the class constant SCHEMA_VERSION. Hopefully this helps other developers. Feedback is welcome!
  20. FYI: I noticed when I was updating my Webmention plugin in the directory last night that 2.8 wasn't an option under compatibility.
  21. Version 1.1.3 is out: http://modules.processwire.com/modules/webmention/ Fixed fatal error on install (thanks @Jason Huck!) Improved validation of source, target, and vouch parameters Enabled sending webmentions to links that have been removed from a post Added hookable methods for image caching Fixed handling of HTTP 410 Gone responses This works on version 2.6, 2.7, and 2.8. It does not work on on 3.x yet. I'll make a branch with a 3.x compatible version soon, though. As usual, if you're using this plugin I'd love to hear from you. Feel free to send webmentions to this post: https://gregorlove.com/2017/03/webmention-for-processwire-update/
  22. @Jason Huck So sorry for the delay in reply. I somehow missed the notifications for responses here. Are you still experiencing the problems on 2.7 or 2.8? I will try doing some fresh installs on those as well as 3.x. It's not explicitly set up for 3.x yet, but it should be easy for me to add the namespaces and have a 3.x-ready version.
  23. Just wanted to share what I ended up doing. After a lot of digging and various attempts (see github), I gave up on having the documentation sub-pages show up in the sidebar. That means I was able to move the documentation pages elsewhere. I've been in the habit of having a page Backend Tools which doesn't have a template (so not available to the public) and store groups of pages there for things like Page-select options. I added a sub-page there Documentation Pages which allows children with template Documentation. The Documentation template just has a title and body field. Then in my ProcessDocumentation module, the ___execute() method shows a list of all the Documentation pages, linking to them with the format: ./view/[page-name]. Then the __executeView() method verifies the page-name is valid and if so, returns the documentation page's body field, so it shows up in the admin theme. There's still a link to the main documentation page in the sidebar, which I think is good enough. Voila.
  24. I realized that's possible, but hadn't considered it much as an option. Since the documentation we're setting up is for doing specific tasks in the admin area, it seems a bit clunky to send them to a front-end page and then they have to return to the admin. I appreciate the idea, though!
  • Create New...