Jump to content

Tracy Debugger


adrian

Recommended Posts

Custom panels shipped with my own modules would be great 🙂 

Maybe Tracy could scan for /site/modules/***/TracyPanel***/ folders? So I could ship my module with two custom panels:

/site/modules/MyModule/TracyPanelFoo/Foo.php
/site/modules/MyModule/TracyPanelFoo/Foo.css
/site/modules/MyModule/TracyPanelFoo/Foo.js

/site/modules/MyModule/TracyPanelBar/Bar.php
/site/modules/MyModule/TracyPanelBar/Bar.css

// or like this?
/site/modules/MyModule/TracyPanels/Foo/Foo.php
/site/modules/MyModule/TracyPanels/Foo/Foo.css
/site/modules/MyModule/TracyPanels/Bar/Bar.php

thx again for this brilliant module!

  • Like 2
Link to comment
Share on other sites

13 hours ago, teppo said:

Sorry if this has been discussed already, there's so much stuff in this thread that I can't keep up anymore 😅

A bit offtop... Maybe such epic modules like Tracy Debugger (and AOS, and some else, probably) could get their own sub-forums under Modules/Plugins? Kind of like Padloper got its own under Vip Support? I am sure, it can be done and (arguably) would make it easier for people to find stuff. But would it make it easier for maintainers? What do you think, @adrian?

  • Like 5
Link to comment
Share on other sites

4 hours ago, Ivan Gretsky said:

A bit offtop... Maybe such epic modules like Tracy Debugger (and AOS, and some else, probably) could get their own sub-forums under Modules/Plugins? Kind of like Padloper got its own under Vip Support? I am sure, it can be done and (arguably) would make it easier for people to find stuff. But would it make it easier for maintainers? What do you think, @adrian?

I think it's probably good idea, but this is a request for @Pete and @ryan

  • Like 1
Link to comment
Share on other sites

@teppo and @bernhard Please try the attached main module file. With this version, you can simply add your panel to your module directory structure eg:

/site/modules/TestModule/TracyPanels/TestThirdPartyModule.php

Make sure the class name of the panel in this example is: TestThirdPartyModulePanel

That should be all you need.

Not super well tested so let me know if you find any problems or have any suggestions. If everything looks good, I'll commit the changes to the repo.

 

TracyDebugger.module.php

  • Like 5
Link to comment
Share on other sites

Hi @adrian could you please provide instructions how to add new panels and what code to use for the panel? I tried it with something like my helloworldpanel - the panel showed up in the panel selector panel but when I enabled it I got

Error
Class 'TestThirdPartyModulePanel' not found search►

 

Link to comment
Share on other sites

@bernhard - not sure what to say. If you have a file called TestThirdPartModule.php and that file contains a class named "TestThirdPartyModulePanel" then it should work fine.

Note that you can name the file and class whatever you want, so long as the class is the same as the file with the "Panel" suffix.

Link to comment
Share on other sites

On 9/19/2020 at 3:21 AM, adrian said:

Not super well tested so let me know if you find any problems or have any suggestions. If everything looks good, I'll commit the changes to the repo.

Just gave this a quick try, and so far everything seems to work for me. Copied HelloWorldPanel to /site/modules/Wireframe/TracyPanels/Wireframe.php, renamed the class to WireframePanel, and changed labels. So far so good — it's not doing anything sensible yet, but seems to load just fine.

Will report back once I've had time to actually make the panel useful... 😅

  • Like 3
Link to comment
Share on other sites

2 hours ago, teppo said:

Just gave this a quick try, and so far everything seems to work for me. Copied HelloWorldPanel to /site/modules/Wireframe/TracyPanels/Wireframe.php, renamed the class to WireframePanel, and changed labels. So far so good — it's not doing anything sensible yet, but seems to load just fine.

I would love to see a screenshot please as I am not sure I know what you folks are talking about 😉. Thanks!.

Link to comment
Share on other sites

1 minute ago, kongondo said:

I would love to see a screenshot please as I am not sure I know what you folks are talking about 😉. Thanks!.

It's just a way for other ProcessWire modules to add their own panels to Tracy's debug bar. The custom panel can display all sorts of relevant debug info, just like the core panels included with Tracy. Really it's up to module authors what they think would be useful info to display. 

I am also just working on the ability for these external module panels being able to inject settings into Tracy's main module settings so that users can customize the panel.

  • Like 2
Link to comment
Share on other sites

@teppo and @bernhard - new version attached. This lets you add module settings for your custom panels to Tracy's settings - you can add something like this to your panel class:

    public function addSettings() {
        $fieldset = $this->wire('modules')->get("InputfieldFieldset");
        $fieldset->attr('name+id', 'testThirdPartyModuleSettings');
        $fieldset->label = $this->_x('Test Third Party Module Settings', __FILE__);

        $f = $this->wire('modules')->get("InputfieldCheckbox");
        $f->attr('name', 'testThirdPartyModule_myCheckbox');
        $f->label = $this->_x('My Checkbox', __FILE__);
        $f->attr('checked', \TracyDebugger::getDataValue('testThirdPartyModule_myCheckbox') == '1' ? 'checked' : '');
        $fieldset->add($f);

        return $fieldset;
    }

The name of the field can be whatever you want, but I think you should prefix it with the class of the panel, eg: testThirdPartyModule_myCheckbox to avoid any conflicts with Tracy core panel settings. 

What do you guys think of this? Do you think there is a better way to implement? Would you rather store any needed settings in your module's settings instead?

Also, please note the name+id attribute in the fieldset - the value entered here should match the last parameter in the generatePanelFooter() method in your panel code. This links the cog icon at the bottom of your panel to the anchor link in Tracy's module settings.

TracyDebugger.module.php

  • Like 1
Link to comment
Share on other sites

@teppo and @bernhard - I am away this coming week so I have committed a new version of Tracy which includes the commits from above and a few additional fixes. Hopefully everything should be working properly now. Please test the new addSettings() method if you get a chance and if you need any additional changes to make things work, please feel free to modify Tracy as needed and send me a PR or let me know what else you need and I'll take care of it when I am back.

  • Like 2
Link to comment
Share on other sites

@adrian Hi Adrian, the latest version is throwing a warning if there are no external panels:

Quote

PHP Warning: Invalid argument supplied for foreach() in .../TracyDebugger/TracyDebugger.module.php:4079

I think this will only occur if there are no external panels, if the glob pattern is empty static::$externalPanels will be undefined (see TracyDebugger.module.php#L320-327). Should be fixed by initializing $externalPanels to an empty array (see L143). Thanks!

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Hi @adrian,

In the Mail Interceptor panel, special characters are scrambled in the From field:

2020-10-08_133751.png.108f5d3810a69de432030f2f1c4490b2.png

I think this might be glitch in the Mail Interceptor panel rather than a WireMail issue because the From value seems to render properly in my email client. But if it isn't a Tracy issue and is actually a WireMail problem I'd want to report it to Ryan. Could you take a look when you have a chance? Thanks.

Link to comment
Share on other sites

Hi @Robin S - I can see the reason and have a fix, although I am not sure how robust it is.

The background is that in July 2016, @tpr was having some issues with some email clients needing the From name to be mime header encoded. He gave me this code to fix things:
https://github.com/adrianbj/TracyDebugger/blob/81dbda3fccbe961680f9b7a6bb76f055bf41a06f/panels/MailInterceptorPanel.php#L27-L29

                // from @tpr - for dealing with encoded fromName which is necessary for some email clients
                if(function_exists('mb_decode_mimeheader')) {
                    $item['fromName'] = mb_decode_mimeheader($item['fromName']);
                }

But it looks like the issue is when there are special characters that aren't encoded, this is breaking things. My attempted fix is replacing that with:

                if(function_exists('mb_decode_mimeheader') && mb_detect_encoding($item['fromName']) != 'UTF-8') {
                    $item['fromName'] = mb_decode_mimeheader($item['fromName']);
                }

but again, I am not sure how robust that is - encoding is not my speciality 🙂

Can you test that change for me.

Also, does anyone else have any thoughts on a better way to do this? @teppo - you must deal with these sorts of characters in email headers - any tips?

  • Like 1
Link to comment
Share on other sites

On 10/8/2020 at 8:32 AM, adrian said:

Also, does anyone else have any thoughts on a better way to do this? @teppo - you must deal with these sorts of characters in email headers - any tips?

Sorry, this is not my area of expertise either. Used to deal with that a lot, but thankfully no longer — switching all email sending features to use services like Mailgun has made my life so much better 😉

Anyway, your solution seems reasonable. Only thing I'm wondering is whether it'd be better to specifically check for ASCII encoding with mb_detect_encoding(), instead of "not UTF-8"? It's a really small nuance, though.

  • Like 1
Link to comment
Share on other sites

On 10/10/2020 at 12:45 AM, teppo said:

Only thing I'm wondering is whether it'd be better to specifically check for ASCII encoding with mb_detect_encoding(), instead of "not UTF-8"?

Thanks for you input @teppo - I guess I went with this approach because I thought that there was a chance it could be encoded other non-UTF8 ways, not just ASCII, so I thought this was a safer approach, but again, I really don't like this stuff, so maybe I am still confused 🙂 Can you explain why you think your way would actually be better?

Link to comment
Share on other sites

2 hours ago, adrian said:

Can you explain why you think your way would actually be better?

It seems to me that the only case when we'd want mb_decode_mimeheader() to run is when the header is encoded, in which case it's always base64 or quoted-printable (AFAIK), and these are always (US-)ASCII. I'm not aware of any notable issues with current approach, though; most likely the "worst case" is that you'd pass something that doesn't need decoding to mb_decode_mimeheader(), and it seems like a major coincidence if this operation actually ends up scrambling the data.

Anyway, the gist is that if we're looking for ASCII strings, it's better to be specific 🙂

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

@adrian. Just an fyi,

I just upgraded tracy. Looking at the Adminer settings, it presents the check for update option. However, selecting that option returns the following error:

ProcessModule: Error reported by web service: That module is not currently tracked by the modules directory

Is it necessary to have the check for update option for adminer?

Link to comment
Share on other sites

4 minutes ago, rick said:

Looking at the Adminer settings, it presents the check for update option

That "Check for updates" option is a PW core thing - in my opinion this shouldn't show for child/helper modules that are shipped with a module, but that's a PW core issue and nothing I can change I'm afraid.

Link to comment
Share on other sites

37 minutes ago, adrian said:

a PW core thing - in my opinion this shouldn't show for child/helper modules that are shipped with a module,

@adrian. Is this currently possible though? Are you saying it is possible for ProcessWire to detect which modules are helper/child modules?

Link to comment
Share on other sites

  • adrian pinned and locked this topic
  • adrian unpinned and pinned this topic
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By monollonom
      (once again I was surprised to see a work of mine pop up in the newsletter, this time without even listing the module on PW modules website 😅. Thx @teppo !)
      FieldtypeQRCode
      Github: https://github.com/romaincazier/FieldtypeQRCode
      Modules directory: https://processwire.com/modules/fieldtype-qrcode/
      A simple fieldtype generating a QR Code from the public URL of the page, and more.
      Using the PHP library QR Code Generator by Kazuhiko Arase.

      Options
      In the field’s Details tab you can change between .gif or .svg formats. If you select .svg you will have the option to directly output the markup instead of a base64 image. SVG is the default.
      You can also change what is used to generate the QR code and even have several sources. The accepted sources (separated by a comma) are: httpUrl, editUrl, or the name of any text/URL/file/image field.
      If LanguageSupport is installed the compatible sources (httpUrl, text field, ...) will return as many QR codes as there are languages. Note however that when outputting on the front-end, only the languages visible to the user will be generated.
      Formatting
      Unformatted value
      When using $page->getUnformatted("qrcode_field") it returns an array with the following structure:
      [ [ "label" => string, // label used in the admin "qr" => string, // the qrcode image "source" => string, // the source, as defined in the configuration "text" => string // and the text used to generate the qrcode ], ... ] Formatted value
      The formatted value is an <img>/<svg> (or several right next to each other). There is no other markup.
      Should you need the same markup as in the admin you could use:
      $field = $fields->get("qrcode_field"); $field->type->markupValue($page, $field, $page->getUnformatted("qrcode_field")); But it’s a bit cumbersome, plus you need to import the FieldtypeQRCode's css/js. Best is to make your own markup using the unformatted value.
      Static QR code generator
      You can call FieldtypeQRCode::generateQRCode to generate any QR code you want. Its arguments are:
      string $text bool $svg Generate the QR code as svg instead of gif ? (default=true) bool $markup If svg, output its markup instead of a base64 ? (default=false) Hooks
      Please have a look at the source code for more details about the hookable functions.
      Examples
      $wire->addHookAfter("FieldtypeQRCode::getQRText", function($event) { $page = $event->arguments("page"); $event->return = $page->title; // or could be: $event->return = "Your custom text"; }) $wire->addHookAfter("FieldtypeQRCode::generateQRCodes", function($event) { $qrcodes = $event->return; // keep everything except the QR codes generated from editUrl foreach($qrcodes as $key => &$qrcode) { if($qrcode["source"] === "editUrl") { unset($qrcodes[$key]); } } unset($qrcode); $event->return = $qrcodes; })
    • By Sebi
      AppApiFile adds the /file endpoint to the AppApi routes definition. Makes it possible to query files via the api. 
      This module relies on the base module AppApi, which must be installed before AppApiFile can do its work.
      Features
      You can access all files that are uploaded at any ProcessWire page. Call api/file/route/in/pagetree?file=test.jpg to access a page via its route in the page tree. Alternatively you can call api/file/4242?file=test.jpg (e.g.,) to access a page by its id. The module will make sure that the page is accessible by the active user.
      The GET-param "file" defines the basename of the file which you want to get.
      The following GET-params (optional) can be used to manipulate an image:
      width height maxwidth maxheight cropX cropY Use GET-Param format=base64 to receive the file in base64 format.
    • By MarkE
      This fieldtype and inputfield bundle was built for storing measurement values within a field, rendering them in a variety of formats and converting them to other units or otherwise modifying them via the API.
      The API consists of a number of predefined functions, some of which include...
      render() for rendering the measurement object, valueAs() for converting the value to another unit value, convertTo() for converting the whole measurement object to different units, and add() and subtract() for for modifying the stored value by the value (converted as required) in another measurement. In the admin the inputfield includes a checkbox (which can be optionally disabled) for converting values on page save. For an example if a value was typed in as centimeters, the unit was changed to metres, and the page saved with this checkbox selected, said value would be automatically converted so that e.g. 170 cm becomes 1.7 m.

      A simple length field using Fieldtype Measurement and Inputfield Measurement.
      Combination units (e.g. feet and inches) are also supported.
      Please note that this module is 'proof of concept' at the moment - there are limited units available and quite a lot of code tidying to do. More units will be added shortly.
      See the GitHub at https://github.com/MetaTunes/FieldtypeMeasurement for full details and updates.
    • By tcnet
      File Manager for ProcessWire is a module to manager files and folders from the CMS backend. It supports creating, deleting, renaming, packing, unpacking, uploading, downloading and editing of files and folders. The integrated code editor ACE supports highlighting of all common programming languages.
      https://github.com/techcnet/ProcessFileManager

      Warning
      This module is probably the most powerful module. You might destroy your processwire installation if you don't exactly know what you doing. Be careful and use it at your own risk!
      ACE code editor
      This module uses ACE code editor available from: https://github.com/ajaxorg/ace

      Dragscroll
      This module uses the JavaScript dragscroll available from: http://github.com/asvd/dragscroll. Dragscroll adds the ability to drag the table horizontally with the mouse pointer.
      PHP File Manager
      This module uses a modified version of PHP File Manager available from: https://github.com/alexantr/filemanager
       
    • By tcnet
      This module implements the website live chat service from tawk.to. Actually the module doesn't have to do much. It just need to inserted a few lines of JavaScript just before the closing body tag </body> on each side. However, the module offers additional options to display the widget only on certain pages.
      Create an account
      Visit https://www.tawk.to and create an account. It's free! At some point you will reach a page where you can copy the required JavaScript-code.

      Open the module settings and paste the JavaScript-code into the field as shown below. Click "Submit" and that's all.

      Open the module settings
      The settings for this module are located int the menu Modules=>Configure=>LiveChatTawkTo.

       
×
×
  • Create New...