Jump to content

kongondo

PW-Moderators
  • Posts

    7,529
  • Joined

  • Last visited

  • Days Won

    160

Everything posted by kongondo

  1. That sounds like the recent talk on making it easier to version and export fields and templates, CI&CD, etc. I don't think. You can currently define (export) and import templates and fields using JSON (not JSON file, unless using its API). This feature has been around for a while. This was also pointed out in the aforementioned discussion. I'll see if I can find the link if that's what you are after?
  2. Not sure if this is the one...it is about translations..
  3. Unless something's changed, you are tied to having the file somewhere within /site/templates/ by default. Edit: I see you are providing an exception using $path...hmmm. So, it should work
  4. Aah. I see. In that case, yes, you are right. You will need a 3rd-party or custom PHP solution. I don't think there's currently a module in the Modules' directory to do this.
  5. Of course ?. You can still tag it as alpha even POC if you needed to.
  6. I'd suggest, no. If you mean uploading files, say one off...then grab a dedicated FTP client (yes, they can do SFTP as well) such as FileZilla or Cyberduck. I suggest you read up on FTP/SFTP, at least the basics, including transfer mode. Also consider whether uploading a zip file and unpacking it is better in your case. You will also need to know about file permissions as you may upload a file only for ProcessWire not to be able to access it due to server file permissions and ownerships :-). If you mean file uploads such as images to a ProcessWire page, then ignore above.
  7. Great! ?. I'd say this is the trivial bit. The repeater items already have your hx-attributes, so they should target the right repeater item. Alternatively, you can find out about the item in the this that you pass to htmx.process() above.,
  8. Here's a conversation on reddit whether Composer could be susceptible to a similar attack
  9. I meant composer as a package / dependency manager. It would also be vulnerable to a similar attack.
  10. Easiest is probably if you know the events repeater matrix is triggering. Have a look at this section in the htmx docs. https://htmx.org/docs/#3rd-party
  11. Where does this leave us with tools like composer?
  12. Another thing that could be happening is that your repeater matrix are being lazy loaded via Ajax. In this case, htmx 'will not see them' unless you re-trigger the hx-attributes.
  13. Just to confirm, this is apart from the SelectizeAll issue? Either way, htmx is so versatile. You can trigger hx-trigger using an Event. If you are able to listen to change on the RepeaterMatrix field, you can either use that event or fire a custom event to trigger your htmx hx-trigger. Can't elaborate further unless I see your implementation.
  14. Yeah, you are right. Good catch. This is why I suggested to strip the page bare - to rule out things one by one. Does this mean SelectizeAll module autoloads? Edit: I've checked. Yes, it autoloads.
  15. I've just checked and actually the version I tested on is 3.0.190. So, there must be something else going on in your install, unless we have different 3.0.190s. Maybe send me a copy of your latest measurement module so I can test on my 3.0.190. I don't have live preview though.
  16. What baffles me is that there is no error and no network activity. I expected at least one of these. Are you able to strip that page bare and leave only title and measurement fields then test?
  17. That was a different machine from this one but I think it was 3.0.184. Hmm..
  18. Jumplinks module? Not sure about its status though https://processwire.com/modules/process-jumplinks/
  19. Code for the above demo JavaScript Here we need to tell htmx that ProcessWire expects Ajax calls to send "X-Requested-With" // InputfieldMeasurement.js const InputfieldMeasurement = { initHTMXXRequestedWithXMLHttpRequest: function () { console.log("initHTMXXRequestedWithXMLHttpRequest - configRequest") document.body.addEventListener("htmx:configRequest", (event) => { event.detail.headers["X-Requested-With"] = "XMLHttpRequest" }) }, listenToHTMXRequests: function () { // before send - Just an example to show you where to hook BEFORE SEND htmx request htmx.on("htmx:beforeSend", function (event) { console.log("InputfieldMeasurement - listenToHTMXRequests - event", event) }) }, } /** * DOM ready * */ document.addEventListener("DOMContentLoaded", function (event) { if (typeof htmx !== "undefined") { // CHECK THAT htmx is available console.log("HTMX!") // init htmx with X-Requested-With InputfieldMeasurement.initHTMXXRequestedWithXMLHttpRequest() // just for testing InputfieldMeasurement.listenToHTMXRequests() } else { console.log("NO HTMX!") } }) PHP We are in InputfieldMeasurement.module We load htmx in init() We listen to htmx calls in render() We pass this to a handler testHTMX() Insider render() we listen to change on InputfieldSelect. Notice we don't add a trigger. htmx knows the type of event that a Select outputs <?php namespace ProcessWire; // BELOW, SNIPPETS OF THE RELEVANT CODE public function init() { parent::init(); // wire()->config->scripts->append("https://unpkg.com/htmx.org@1.7.0"); // LOAD htmx // I just prefer this syntax :-) $this->wire('config')->scripts->append("https://unpkg.com/htmx.org@1.7.0"); } public function ___render() { $name = $this->attr('name'); $field = $this->field; $page = $this->page; $value = $this->attr('value'); if (!$value || !$value->quantity) { $value = new Measurement($field->quantity); //bd($value, 'value'); } ##################### HTMX AJAX LISTENER $input = $this->wire('input'); $ajax = $this->wire('config')->ajax; // bd($ajax, __METHOD__ . ': $ajax at line #' . __LINE__); // bd($input->get('field'), __METHOD__ . ': $input->get(field) at line #' . __LINE__); if ($ajax && $input->get('field') == $this->attr('name')) { bd($ajax, __METHOD__ . ': $ajax at line #' . __LINE__); bd($input->get('field'), __METHOD__ . ': $input->get(field) at line #' . __LINE__); bd($input->get('id'), __METHOD__ . ': $input->get(id) at line #' . __LINE__); $out = $this->testHTMX(); echo $out; die(); } else { // @debug bd($ajax, __METHOD__ . ': $ajax - NO AJAX AND/OR WRONG INPUTFIELD - at line #' . __LINE__); } // >>>> MORE CODE HERE ... // ADD HTMX LISTENER TO 'measurement input Select' // unit $f = $this->modules->get("InputfieldSelect"); $f->label = $this->_("Unit"); $f->attr('name', "{$name}_unit"); $f->attr('value', $value->get('unit')); //bd($value, 'value'); bd($field->units, __METHOD__ . ': $field->units at line #' . __LINE__); foreach ($field->units as $unit) { $shortLabel = (isset($units[$unit]) && isset($units[$unit]['shortLabel'])) ? $units[$unit]['shortLabel'] : null; $alias = (isset($units[$unit]) && isset($units[$unit]['alias'])) ? $units[$unit]['alias'] : $unit; if ($shortLabel) $shortLabel = "($shortLabel)"; $f->addOption($unit, "$alias $shortLabel"); } $f->notes = $units[$value->get('unit')]->notes; $f->columnWidth = $colWidth; // ======== #### add HTMX #### $adminEditURL = $this->wire('config')->urls->admin . "page/edit/"; $adminEdit = "{$adminEditURL}?id={$this->page->id}&field={$name}"; bd($adminEditURL, __METHOD__ . ': $adminEditURL at line #' . __LINE__); bd($adminEdit, __METHOD__ . ': $adminEdit at line #' . __LINE__); // ------ $f->attr([ 'hx-get' => $adminEdit, // send get to to InputfieldMeasurement 'hx-target' => '#InputfieldMeasurementTestHTMXTarget', // our element to target with swap 'hx-swap' => 'innerHTML' // we'll swap the innerHTML (this is the default but it has never worked for me if not specified) ]); $inputfields->add($f); // ========= ### FOR HTMX DEMO ONLY ### $f = $this->modules->get("InputfieldMarkup"); $f->label = "InputfieldMeasurement Test HTMX"; $f->attr('id', "InputfieldMeasurementTestHTMX"); // we will swap the innerHTML of the div#InputfieldMeasurementTextHTMXTarget $out = "<div id='InputfieldMeasurementTestHTMXTarget'><h3>HTMX TARGET (will change when Unit changes)</h3></div>"; // $f->collapsed = Inputfield::collapsedYes; $f->value = $out; $f->columnWidth = 100; $inputfields->add($f); // >>>> MORE CODE ..... return $inputfields->render(); } private function testHTMX() { $dateAndTime = date("Y-F-d H:i:s"); $out = "<h3>We got that HTMX Call at {$dateAndTime}!</h3>"; return $out; }
  20. @MarkE It is working for me, in your module. I haven't tested in repeaters. I'll add the relevant code in a later post. Meanwhile, attached, the demo of it working. htmx_inputfield_measurement_22-03-18_16-26-08.mp4
  21. Yes. I am quite aware of this ?. It is your previous statement below that confused me: It seemed to suggest that your code was non-blocking. Just curious about this. Was your goal to give the current editor feedback or all editors who use the system? I mean, did you want the progress to show on different machines simultaneously on any ProcessWire backend page or just the current editor? I have a feeling this won't make sense so will just add. If I am Editor A and I am currently making edits. Across me sits Editor B. Editor B is not making edits. Maybe she is looking at the page tree. If Editor A makes changes and SSE kicks in, Editor B will see the progress on her machine. Was this your use case?
  22. Not foolproof https://stackoverflow.com/questions/56301138/how-to-check-whether-server-supports-http-2-in-javascript-on-browser
  23. Thanks. I have seen that article before (as well as similar posts in SO). It is very helpful. I didn't try the suggested fix since I suspected it might interfere with ProcessWire $session. I wanted to ask in the forums but forgot. Anyone knows if this would happen? I'll have a go and maybe also check if $session is affected.
  24. Here's the demo video showing the system lock. Let me know if you cannot watch it. Note, the system will lock even if the count is 10.
  25. Just tested. And I take back what I said. Your module also locks system resources. Admin and frontend don't load while the countdown is on. Locking happens on both front and backend pages, pages tree, fields, templates, etc. I have tested with both the 10 countdown and a 50 countdown. I'll see if I can get a video demo. So, back to my questions (not just directed at @bernhard) but the community. Are we able to to have SSE work without a module? Some people might just want this to work in ready.php without having to install a module. Are we able to have SSE that is totally event driven? I.e., a page is saved and the frontend gets notified. Are we able to have SSE that doesn't lock system resources? Maybe we should start a new topic?
×
×
  • Create New...