Jump to content

dragan

Members
  • Posts

    2,007
  • Joined

  • Last visited

  • Days Won

    21

Everything posted by dragan

  1. @BrendonKozThanks for the interesting write-up. Generally speaking, with maps or chart graphics, there are two main ways to ensure accessibility: One is described neatly in this article: https://css-tricks.com/accessible-svgs/#aa-interactive-images e.g. the use of role=group vs. role=img, using role=list role=listitem, tabindex etc. In your map, you could turn your three floor groups into three lists. The other strategy is to output an unstyled + visually hidden table or ul/ol somewhere that represents the floors and rooms/areas. You would then simply put aria-hidden=true on the entire SVG. This strategy is certainly the most efficient. However, if you want to enable focusing areas with the keyboard (for people who can't use the mouse), you'd have to alter your SVG further, like the above example.
  2. Thanks for sharing! We have taken over a trainwreck of a Craft site from another agency recently, and amongst a million other nuisances, the image resizer plugin they've chosen is end-of-life. Plus, the authors are fond of uploading huge images. I just might steal that line of code to bring the overall size down considerably...
  3. The future looks bright! I'm very excited about the preview edition of GitHub Copilot. Finally someone putting AI to good use. Some of these suggestions are downright scary, they're so great. Write some code, a comment, then hit TAB. Boom. This is like Intellisense, but on steroids, and then some. Anyone else tried it? Care to share your experiences?
  4. Perhaps you can use RockFinder and try a "group by" query.
  5. Try browser extensions? e.g. https://chrome.google.com/webstore/detail/office-editing-for-docs-s/gbkeegbaiigmenfmjfclcdgdpimamgkj
  6. As far as I understand, Headless CMS and SSG aren't the same thing really. So which one do you really want? If you'd like to use an SPA framework like React, you'd probably want headless. If you'd like to automagically create static pages, it's a typical SSG setup. For headless, I'd try the AppApi module. For SSG, I'd use Pro Cache. I'm not sure what to make of your example comparison with WP and taxonomies. In PW, you create your own taxonomy or data model. It's easy to create JSON output from your PW instance. Use URL segments, and handle each /json request to your own script. It's ridiculously easy to create JSON feeds (just a bunch of URLs that match your selector). Is that all you really need? Sorry if I misunderstand you, but there's way more to a headless CMS than just having a URL feed. Again, I don't get what you really want in the end. If you need static sites, what good are "JSON feeds" for you?
  7. Did you check server logs? I would try to delete everything inside site/assets/cache and try again. Put your site briefly into debug mode and see if you can spot anything, e.g. with Tracy Debugger.
  8. My IDE does ? PHPStorm has a tab that checks code comments starting with @todo - VSCode has probably something similar as a plugin I guess.
  9. What is an "external template"? You mean a regular frontend template? I'm not quite sure what you're asking: Reverse all child pages only? Or keep the page order as in the admin, but reverse the images per page only? If the latter, you could do something like: $imgs = $page->images; if ($imgs) { $gmi = array(); foreach ($imgs as $img) { array_push($gmi, array($img->url, $img->description, $img->title)); } $images = array_reverse($gmi); foreach ($images as $img) { $content .= "<h2>{$img[2]}</h2><img src='{$img[0]}' alt='{$img[1]}'>"; } } Basically just array_reverse()
  10. You could use CSS: https://processwire.com/talk/topic/20837-inputfield-repeater-matrix-item-duplicator/?do=findComment&comment=180498
  11. https://octo.github.com/projects/repo-visualization Interesting... This is PW's repo visualized: https://octo.github.com/projects/repo-visualization#explore-for-yourself (enter a repo and you'll get an interactive SVG)
  12. There's already a password reset module built into PW. 2FA can be disabled for any individual account as needed. I have a PW installation, where I activated 2FA for myself as superuser. Recently, my phone for some reason deleted several apps - one of them being Google Authenticator. I know how to reset a user password, but that won't help me in that particular situation. @ryan Is there an API method to deactivate 2FA for a certain user? In the docs, I only see $user->hasTfa().
  13. https://pdfmyurl.com/ claims to support HTML5 + CSS3, but I haven't tested it so far.
  14. Well, if you have the budget, you could use one of the commercial services out there which have an API. This article suggests using Chrome in headless mode, but I have no idea how difficult it is to install, and what the server requirements are: https://peterdev.pl/2019/01/11/picking-a-php-tool-to-generate-pdfs/
  15. Not sure if that's what you're after: In the JSON of your post (let's say it has ID 19199) -> https://yoursite.com/wp-json/wp/v2/posts/19199 you should see featured_media: 19360 this gives you the image details: -> https://yoursite.com/wp-json/wp/v2/media/19360
  16. @picarica Could you please use a more civilized language in here? I'm no PW forum admin, but I'm pretty sure the F*** word is not welcome here. If you have a problem with that particular module, you should post your question in the respective support forum instead:
  17. @modifiedcontent you can do $users->find("roles=superuser"); $users->find("roles=superuser")->first; yes, PW doesn't limit the number of superusers to just one single user.
  18. I don't think so... the trick with PW hooks is to find out which hook to use, and whether to use before or after. Page::loaded seems to be the wrong method to hook into for what you want to achieve. Here are some code-bits I used in the past, and they all work as expected (inside site/ready.php) $this->addHookAfter('Pages::saveReady', function (HookEvent $event) { $page = $event->arguments[0]; // ---------- $pages->addHookAfter("ProcessPageEdit::buildForm", function (HookEvent $event) { $page = $event->object->getPage(); $form = $event->return; // ---------- $this->addHookBefore('Pages::saved(template=invoice, parent=23444)', function(HookEvent $event) { $page = $event->arguments(0);
  19. That's where a proper IDE should kick in, to do its stuff (auto-suggest/auto-complete etc.). Mere text-editors can only do so much... With PW, that didn't really work so well for a long time. But if you enable the Functions API, and use page() instead of $page in your code, you'll get the hints in your working environment. /** * Allow core API variables to also be accessed as functions? * * Recommended. This enables API varibles like $pages to also be accessed as pages(), * as an example. And so on for most other core variables. * * Benefits are better type hinting, always in scope, and potentially shorter API calls. * See the file /wire/core/FunctionsAPI.php for details on these functions. * * @var bool * */ $config->useFunctionsAPI = true;
  20. Did you do any of that? Do you have Tracy Debugger installed? Do you have debug mode enabled? Did you check if you have any hooks activated that could block your code? Saying "it doesn't work" without trying to debug each line of code makes it difficult to find the culprit, and for those people trying to help you. We don't even know your PW version, or what modules you have installed. For starters, what happens if you simplify the code and enter a few lines directly in the Tracy console (e.g. just edit the bio field). Does it work or not?
  21. Well, insert debug code (Tracy's d($var) or plain print_r() etc.) to see if any of your variables/functions doesn't do what you think it should. body and fullname are certainly fields you have added to the user profile yourself, they're not part of the default user template. Perhaps you need to check those fields in the user template where it says "What fields can a user edit in their own profile?"
  22. Well, I just tested out this on PW 3.0.167, and it works as expected: $user_roles = user()->roles; $user_roles_count = count($user_roles); // make sure the current user has more than just default "guest" role if (($user_roles_count > 1) && !input()->post->ts) { $u_name = user()->name; $u_id = user()->id; $here = page()->url; $ts = time(); $form = <<<EOF <h1>Hello $u_name . Would you like to change your password?</h1> <form method="post" action="$here"> <label for="new_pass">New password: <input type="password" id="new_pass" name="new_pass" autocomplete="false"> </label> <label for="new_pass2">Confirm new password: <input type="password" id="new_pass2" name="new_pass2" autocomplete="false"> </label> <input type="hidden" id="uid" name="uid" autocomplete="false" value="$u_id"> <input type="hidden" id="uname" name="uname" autocomplete="false" value="$u_name"> <input type="hidden" id="ts" name="ts" autocomplete="false" value="$ts"> <button type="submit">Change your password</button> </form> EOF; echo $form; } if (input()->post->ts && input()->post->new_pass && input()->post->new_pass2 && input()->post->uid) { $out = ''; $errCount = 0; $form_uid = input()->post->uid; $form_uname = input()->post->uname; $curr_uid = user()->id; $curr_uname = user()->name; $form_new_pass = input()->post->new_pass; $form_new_pass2 = input()->post->new_pass2; $form_ts = (int)input()->post->ts; $max_time = 30 * 60; // 30 minutes // If the POST arrives a half hour later, something is probably fishy if ($form_ts < (time() - $max_time)) { $errCount++; $out = "It seems that it took you longer than 30 minutes to change your password - your request has been blocked due to security concerns. Please try again."; } // user has maybe manipulated the hidden form input fields if (($curr_uid != $form_uid) || ($curr_uname != $form_uname)) { $errCount++; $out = "Your request has been blocked due to security concerns. Please try again."; } // for added security, I would highly suggest to take this note seriously @ https://cheatsheet.processwire.com/user/user-properties/user-pass/ // "you will need to add your own complexity checks for passwords to ensure they meet a minimum length and character requirement." // I'm not sure if there is an API sanitizer method available for this purpose // below is just a basic check to ensure both pw-field values are identical if (($form_new_pass !== $form_new_pass2)) { $errCount++; $out = "Your new passwords do not match. Please try again."; } // If we've got that far, we're ready to update the user's PW if ($errCount < 1) { $user_page = users()->get($curr_uid); $user_page->of(false); $user_page->pass = $form_new_pass; $user_page->save(); $out = "Success! Your account has been updated with the new password you've chosen."; } echo $out; } If syntax like user()->roles doesn't work in your installation, you can either enable it in site/config.php ($config->useFunctionsAPI = true;) or re-write it with $user / $page / $input notation.
  23. First things I'd do: check PW logs check server error logs (Apache / PHP) inspect in the browser (JS errors) If you don't find any hints that way, you could see if it's a CSRF problem, or something to do with sessions. Switching to SessionHandlerDB can help (a core module). In one of my setups I had to put these two config values to false, when I encountered similar problems: $config->protectCSRF = false; $config->sessionFingerprint = false;
  24. It's weird that mySQL Workbench doesn't show any INNODB_FT_DEFAULT_STOPWORD table, just these three: That's with version 5.7.24 though. It seems strange that I don't see that table, but PW search works just fine. You could try to use the Migration Wizard from Workbench (with a local copy), perhaps you'll get more control with your import. But ultimately, since this is a system table, maybe you don't have enough rights to manipulate that anyway on your hosting setup.
×
×
  • Create New...