Jump to content

teppo

PW-Moderators
  • Posts

    3,259
  • Joined

  • Last visited

  • Days Won

    112

Everything posted by teppo

  1. Right – I might've misunderstood those posts, thought you were referring to the demo site. Probably just me not paying enough attention ? I've been doing JS related work recently, and found it really helpful how some libraries provide these interactive code blocks on promo sites and/or docs: "here's our example, here's what it does – try modifying it and see how that'll change things." Another use case are incomplete (or even empty) code blocks urging the user to figure out how to produce some predefined output from them. Personally I dislike learning from docs alone, so this approach provides the best of both worlds: docs so I don't feel like I have to figure everything out myself, and editable/executable code to give me the opportunity to learn things by doing (and making mistakes along the way) ? Now that you mention this, I've done that on a few occasions too. While this may be a bit of an edge case, it's a good example of how something that may seems like an issue at first (overriding API variables by accident) can also be a good thing once you know what you're doing ? (By the way, it seems that the wire-prefixed versions of these were missing from those lists of "all the different ways to access one API variable". Not sure how often people actually use wirePage() etc... but they've probably found their way to some projects out there. And, as is explained in the blog post introducing Functions API and in the FunctionsWireAPI.php file, this version has the advantage (over regular Functions API) of always being available.)
  2. I've been following this topic from the sidelines with mixed feelings. I've always considered ProcessWire's API exceptionally clean and easy to understand, and technically that hasn't changed, but I do find it confusing as well that there are so many ways to achieve essentially the same thing – except that some will only work on certain situations (bootstrap, templates, modules, multi-instance, ...) or may have performance benefits or perhaps won't be available on all sites depending on config settings, etc. I'm very eager to hear what you've got to say about this, and I'm hoping that it'll make everything crystal clear again ? --- Either way, the tab idea (different approaches in different tabs) is, in my opinion, awesome. Combined with per-tab instructions on where and how to use each approach (could be a tooltip with short summary and a link to full documentation page) this would be a huge improvement. If functions API calls are shorter, then show those by default – it won't take anything away from the marketing / functions API promotion perspective, and it may in fact give users a better understanding of what they're missing if they're not using the functions API. --- On a completely different topic, one thing I've been wondering is if it would make sense to provide some kind of "interactive editor" for the API features – "tweak the code and see the result here". I know, ProcessWire isn't a JavaScript app, and the API has loads of stuff that wouldn't make any sense to implement in JavaScript, but perhaps as some kind of a virtual box (not sure how one would set that up securely, though) or a limited scope JavaScript mock API with a set of mock data behind it? Just an idea for now.
  3. I don't think that there's an existing feature for this, but even if you could do this, I would still suggest not doing it. Usually it would be a better idea to display a smaller image in a bigger size in the front-end, rather than to make the end-user download a bigger image with essentially the same content ?
  4. teppo

    TDD in PW

    @flydev, thanks for linking that thread – I had already forgotten the whole thing. Will come in handy for a project I'm currently working on ? That being said, TDD or test-driven development is a pretty specific process: essentially you define what the app should do (success criteria), create tests based on that, and finally write code to fulfil those tests. Iterate this until you have a complete application. I haven't heard anyone developing ProcessWire stuff like that, but technically it's doable, although it obviously depends a lot on what you're actually building with ProcessWire. For most sites out there I'd argue that TDD probably isn't the easiest thing to pull off, or perhaps even the most sensible approach. In my opinion it's more suitable to application development. The front-end layer alone adds loads of complexity to the equation. I'd love to hear if anyone is actually doing this in our context though ?
  5. This part sounds somewhat curious. HTTP 1.1 request to /processwire (seems to work), then HTTP 2.0 request to /processwire/login (doesn't work) – is it possible that the server is not properly configured to handle HTTP/2? What happens if you directly request /processwire/login/, i.e. type it to the address bar instead of /processwire/? Also, just to clarify: when you enter /processwire/ you get the error for /processwire/login/ right away? You didn't even see the inputs for username and password? If so, it might also be that there's something in the site or browser cache that breaks things. If your site is using default session management, i.e. files on the disk, you could start by clearing /site/assets/sessions/ of any session files currently in there. Also make sure that there's nothing odd in your browser cache by clearing that as well, or opening the admin in an incognito tab or something similar. If you've enabled database sessions, you'd probably have to clear them manually from the related database table (haven't used this feature, so not sure how exactly). By the way, the certificate error doesn't sound too good either. Did you have a certificate set up on the old server, and can you set up one on the new one as well? Although this seems unlikely, one possibility is that the server isn't properly serving HTTPS content. This is somewhat off-topic, but it seems really strange that a hosting company (assuming that this is the case) moves the site to a new server without informing you, and without providing proper support, or even making sure that things work as expected after the move. When that kind of thing happens, you might be better off looking for a new hosting provider. Just saying.
  6. Here's another example from the VersionControlTests package: https://github.com/teppokoivula/VersionControlTests/blob/master/tests/VersionControlTest.php#L170:L179. It's in a PHPUnit test class so the syntax is a bit strange, but at least the last time I ran the tests this worked (though that was against PW 2.x.)
  7. Sadly I don't have an answer to the issue raised here, as I have only just started to play with ProcessWire and Docker, but I've got a very similar setup on a MacBook Pro (4 GB RAM and 6 CPU) for WordPress development – and I have to say that it's often painfully slow. This does seem to be a relatively common problem, at least for Mac users. That being said, I'm running a fairly non-standard and complex WordPress stack, so it may strictly speaking be something other than the WP core which is the root cause – ACF or any of the other plugins, something in the theme, etc.
  8. Thanks – I can see definite improvements already, and we can surely keep improving things after the initial launch as well! Regarding the target group I get what you're saying, but it's good to keep in mind that improved accessibility actually benefits us all – it's not (just) about catering for users with disabilities ? "While accessibility focuses on people with disabilities, many accessibility requirements also improve usability for everyone. Accessibility especially benefits people without disabilities who are in limiting situations, such as using the web on a mobile phone when visual attention is elsewhere, in bright sunlight, in a dark room, in a quiet environment, in a noisy environment, and in an emergency." (W3C WAI) My eyesight is way below average, and I can see a lot of artefacts and other signs of low quality in there. Just checking, but do you have a retina screen? Could be somehow related to resolution as well – I've got a 15" MacBook Pro with resolution set to "scaled" and "more space" set to the maximum value.
  9. +1, forgot to mention this one. WCAG AAA requires that line length is never more than 80 characters, but depending on the source comfortable range can be around 80..100 characters, and sometimes as high as 120. Anything above that is way too long considering readability, and I'd recommend not going past the 100 character (or glyph) mark.
  10. +1 to giving contrast more consideration. Overall the site could use a bit of brushing up in terms of accessibility – some quick observations: Providing a skip to main content link would be nice, and while we're at it, providing another one for certain long lists of items (such as the showcase items) could also be a good idea. At least on the home page the logo icon and the text next to it are separate links, but still lead to the same location – I'd recommend hiding one of them from keyboard / screen reader users. There are no focus styles for the top navigation, so keyboard navigation feels quite strange; the cursor seems to simply disappear somewhere. The search icon doesn't seem to have label for screen readers to read, so it's just "link: newsite". Same thing with the close icon for the search. One more keyboard navigation issue occurs once I reach the showcase section: again the cursor disappears, and I actually have to browse all items (even though visually nothing changes on the screen) before it reappears. This might've been mentioned already, but I for one keep getting the "home" link wrong, since (in some cases) the text link right next (which is visually connected to the logo and thus I would've expected it to lead to the home page as well) takes me somewhere else. This is one of those "oh, I see what you did there" cases: now that I've clicked the wrong link a couple of times I know how it works, but surprises like that don't exactly improve the overall experience ? Additionally I find it very confusing that the navigation hierarchy doesn't match content structure. For an example, if I choose "Docs" > "API Reference" from the navigation, I'm suddenly taken to another area of the site – and probably for that reason there's also no indication about where I currently am in the top navigation, since this new area isn't included in the navigation, even though it's hierarchically a top level page. Finally, I would recommend adding some sort of indication to navigation links that take the user out of current site. "Community" for an example is (a bit weirdly, in my opinion) linked to the Forum, which may come as a surprise to the visitor. I've always instructed clients to never, ever link to another site from their top navigation – but if we really have to do that, at least we should make it obvious what's happening ? .. and all that said, this is definitely an upgrade to the old site. Sure, there are rough edges, and I must agree with a lot that has been said in this topic, but I'm sure we'll figure it out. Great job, Ryan!
  11. As a one-off example of putting Sanitizer to work, I'm currently working on a module in which I convert template names to pascal case class names, so recently added $sanitizer->pascalCase() came in handy there. On the other hand, $sanitizer->pageName(), $sanitizer->selectorField(), and $sanitizer->selectorValue() are probably what I've used the most. Even if I know that ProcessWire has some sort of validation built-in, I much prefer to filter data before passing it to ProcessWire: not only does this provide an extra layer of safety, but it also allows me to display more helpful error messages to the end-user. $sanitizer->option() and $sanitizer->options() are also useful. They're basically shortcut methods to whitelisting values, and who doesn't need a whitelist every now and then? Some Sanitizer features are more about formatting, really: $sanitizer->truncate() is a good example of this, as it's basically creates excerpts of longer text. Definitely useful. All in all, it really depends on what you're doing with ProcessWire, where you're getting your input, and so on. If you're handling raw user input a lot, Sanitizer is particularly useful. Similarly if you tend to enforce more specific rules for your data (say, only allow specific values, or specific characters, etc.) you can get a lot out of Sanitizer. Personally I'm also a firm believer in the "defence in depth" practice: can't have too many layers of protection ? By the way, in your code you mention that Inputfields run Sanitizer methods. It's probably worth noting that Inputfields won't interfere while you're storing data over the API, and thus they won't prevent anything from being saved to the database either. Fieldtypes handle data storage, and Inputfield settings kick in when you edit that value in the Admin.
  12. First of all, I would recommend reconsidering your approach. ProcessWire's built-in admin is quite user-friendly, and building essentially the same thing on your own sounds like a lot of effort that you could use for something more beneficial. Not to mention that you'll have to be pretty careful to avoid any permission related issues etc. – all in all not something I would recommend unless you've got a really good reason for it. The answers to your questions, if you still choose to go this route, would depend on your needs: do you have multiple types of users with different fields, or are they all the same? What will these users edit – their own profile page, or something else? If it's their profile page, should it be publicly viewable? If not, how are you planning to control access – on a page by page basis, or based on groups, or something else entirely? ProcessWire supports multiple parents/templates for user pages, so that might be something you could look into: https://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users. Hope this helps a bit.
  13. $config->httpHost should return current domain (if it's included in the httpHosts setting) or the first domain from said setting if no match was found. Here's the related code for reference: https://github.com/processwire/processwire/blob/341342dc5b1c58012ae7cb26cffe2c57cd915552/wire/core/ProcessWire.php#L308-L323. If you're accessing your site with the dev domain and this domain is included in the httpHosts setting, that should be what this method returns. If not, I'd make sure that related settings are properly configured, and that your server works as expected (particularly in terms of SERVER_NAME and/or HTTP_HOST). I'm not entirely sure what you're referring to with the "edit multiple URLs in the code" part, but generally speaking I'd recommend using relative paths etc. instead of fully qualified domains. This way it doesn't really matter which domain you access your site from. It's possible that you were actually referring to something else, so feel free to clarify this part ? Edit: actually there's one more thing to keep in mind here, which is that ProcessWire prefers the ServerName value from the Apache VirtualHost block ($_SERVER['SERVER_NAME']) over the host header provided by the browser ($_SERVER['HTTP_HOST']) when determining httpHost. ServerName is used at least if Apache "UseCanonicalName" setting is "on", but this behaviour may apparently vary between different Apache versions. In this case the solution would be either disabling the UseCanonicalName setting, or creating separate VirtualHost blocks for all domains you want to use with ProcessWire.
  14. That isn't actually necessary; Process module execute methods don't have to be hookable. (Gadgetto, in case you haven't yet looked into the hook system, three underscores are only required if you want to make the function hookable – i.e. allow code in template files, modules, init.php / ready.php files within site directory, etc. to "hook" into their execution. Otherwise it's fine to leave them out.) On a loosely related note, you also don't have to set up your own PHP version comparison. You can define required PHP version with the "requires" setting ?
  15. Sorry to answer a question with another question, but is there a specific reason you want subscribers to be users? You mentioned being able to use the MODX permission system, but what do you use it for? While there's no technical reason why you couldn't make your subscribers ProcessWire users, the reason I'm asking is that unless there's a solid reason for it, I'd recommend not going that route. You'd essentially have to build an open registration system, where anyone can create new user accounts. While that isn't necessarily a problem in itself, coupled with any kind of permission related issue things could get very ugly very fast. That being said, depending on your needs you could use users, or you could create a custom template for your subscribers, or you could even create your own database table(s) – though that last option would likely not be preferable, considering that you wouldn't be able to benefit from ProcessWire's API. Whether you go with a custom template or choose to build upon built-in system users, I'd recommend looking into $pages->findMany(). Thousands of users / pages shouldn't be an issue.
  16. I'm not sure if it's still applicable, but there's an old module as well: https://modules.processwire.com/modules/pageimage-remove-variations/. Although I'm guessing that @horst already knew about it... ?
  17. Old discussion, but yeah – the plus sides of this kind of naming are that 1) it's a common practice across different systems (which makes it easy for new devs to grasp), and 2) that it's a very commonly typed function – not to mention one that you often see in front-end (or "view") part of a site or an app, and thus it's good to keep it nice and short . Expanding on the second point a bit, in the view side it often makes sense to have short function names, even if they're not particularly descriptive. Think of PHP's short echo tags (<?= ... ?>) or various tags implemented by templating languages: the point is to create minimal clutter, thus keeping view files clean and easy to follow ? --- Note: this thread is not related to module development per se, so I'm moving it to the Getting Started area of the forum.
  18. Admin note: since this is clearly not a support thread for a module, I'm moving the whole thread to the General Support area of the forum. Please note that Modules / Plugins is only intended for dedicated module support threads. Thanks!
  19. To be honest I'm a bit confused by your question (for an example I have no idea what you mean by "referring to mydomain/index.php" and how this relates to ProcessWire), but if you're trying to read a GET variable (mydomain/?u=value) in one of your template files then you can access it via $input->get->u. You can use $_GET['u'] as well since $input is mainly just a wrapper over GET / POST / COOKIE, but I'd recommend using $input in the context of ProcessWire ?
  20. Admin note: I'm moving this thread from the "Modules/Plugins" section to the "General Support" area of the forum. Please submit general / core / core module related questions to the General Support section instead of Modules/Plugins.
  21. @ryan, any chance you could set up a support forum thread for LoginRegister? Currently it doesn't have one, and these requests pile up in the Modules/Plugins area. Just trying to keep things nice and tidy here ?
  22. Note: I've just moved this thread from the "Modules/Plugins" section of the forum to the "General Support" section. "Modules/Plugins" is intended for dedicated module support threads, and general questions like this belong to other areas ?
  23. Browse to madewithlaravel.com and check out pretty much anything that doesn't manage data, and/or doesn't produce output. From the front page: Clockwork, Fractal, Vessel, etc. Also anything that is more "component", intended to be used within other applications, rather than a "full-blown application" itself ? Perhaps a more familiar example would be wireshell.pw. While it's not built using a WAF, it does make use of Symfony components. Could it be built using ProcessWire? In theory yes. Would it benefit from being powered by ProcessWire? Not really.
  24. What @LostKobrakai said. The short answer to "what can Laravel and Symfony do that PW cannot" is "nothing", but in my opinion that's not really the question you should be asking – rather you should ask what it is that they are better suited for than ProcessWire ? In my experience (based on other web application frameworks, not Laravel or Symfony specifically) the biggest day-to-day difference is exactly the general purpose nature of web application frameworks: ProcessWire is specialised to content management, hence it's a "content management framework" (CMF) rather than a "web application framework" (WAF). In some regards ProcessWire has more built-in stuff than WAF's, and in some regards it has less – just like LostKobrakai pointed out above ? Some examples of the differences include routing and project structure / application architecture: Although this might be changing, not too long ago it seemed that every PHP framework enforced MVC pattern, or at least recommended it. ProcessWire, on the other hand, doesn't (natively) include anything like that. The default, out-of-the-box approach ("output strategy") is a straightforward solution where single template file contains (or rather can contain – of course you can also split it into multiple include files) all the code required by said template. Similarly in ProcessWire URLs are by default routed to pages, and although custom routing is technically possible using URL segments, there's no real, robust routing library included, other than what Pages / PagesFiles / Process modules require to function properly. While it's true that you can build pretty much anything on top of ProcessWire (or WordPress, or Drupal, or any remotely flexible CMS/CMF for that matter), whether that's a good idea depends on a number of factors. For an example, if there's no content to manage – or the content you have requires a very specific type of structure or storage mechanism or something – a general purpose WAF may provide you with more suitable tools than most CMS/CMF platforms ? Just for the record, https://madewithlaravel.com/ has quite a few examples of stuff built with Laravel. Some could've made at least as much sense as ProcessWire projects, while others are clearly better suited for a WAF.
  25. Congrats on the new computer, Ryan. I'm assuming that this is related to moving onto the new dev setup, but it almost calls for one of those "yo dawg, we heard you like ..." meme pics, amirite? ?
×
×
  • Create New...