szabesz Posted October 9, 2017 Posted October 9, 2017 6 minutes ago, adrian said: It could be very dangerous to store snippets directly in /site/ Outside of site document root could be one option. Sure, default .htaccess rules should be taken into account.
adrian Posted October 9, 2017 Author Posted October 9, 2017 7 minutes ago, bernhard said: i prefer to have a dedicated folder for code snippets inside the modules' folder ( /site/modules/mymodule/snippets ). Sorry if I am not quite getting this - are you suggesting then that I should force snippets for the Snippet Runner panel to be stored in /site/modules/TracyeDebugger/snippets/ ? Surely they will be overwritten when upgrading Tracy? 6 minutes ago, szabesz said: Outside of site document root could be one option. Sure, default .htaccess rules should be taken into account. Outside of document root is obviously safe, but if I allow full flexibility it will be up to you guys to add rules to the .htaccess to block direct access to these snippet files so they can't be run directly from the browser. That's why I'd prefer /site/templates/ or perhaps /site/assets/TracyDebugger/ as a base path. Anymore flexibility than that and I think we are asking for trouble. 1
bernhard Posted October 9, 2017 Posted October 9, 2017 2 minutes ago, adrian said: Sorry if I am not quite getting this - are you suggesting then that I should force snippets for the Snippet Runner panel to be stored in /site/modules/TracyeDebugger/snippets/ ? Surely they will be overwritten when upgrading Tracy? not if the folder is empty and excluded from git. or am i wrong here?
szabesz Posted October 9, 2017 Posted October 9, 2017 3 minutes ago, adrian said: Anymore flexibility than that and I think we are asking for trouble. I see. Actually, I can live with any of those you mentioned as safe so let's see what others have to say. 1
adrian Posted October 9, 2017 Author Posted October 9, 2017 4 minutes ago, bernhard said: not if the folder is empty and excluded from git. or am i wrong here? I think it depends on how you update modules. Manual overwrite of files would depend on whether you merge or replace when copying. I think if you use the PW Upgrade module it will replace /site/modules/TracyDebugger/ completely so the snippets directory would be lost / replaced with an empty one. I haven't tested this, but I think that's what happens. Either way, I think there are too many chances it will be lost. What do others think? 2
szabesz Posted October 9, 2017 Posted October 9, 2017 2 minutes ago, adrian said: I haven't tested this, but I think that's what happens. A module directory is renamed by prefixing it with a dot character and a new module directory is created upon extracting the zip file, as far as I know. 1
bernhard Posted October 9, 2017 Posted October 9, 2017 2 minutes ago, szabesz said: A module directory is renamed by prefixing it with a dot character and a new module directory is created upon extracting the zip file, as far as I know. you are right! thanks. than that's of course not possible. didn't think of that since i always updated my modules through git pull... so +1 for /site/assets/TracyDebugger/snippets Quote Anymore flexibility than that and I think we are asking for trouble. agree 2
adrian Posted October 9, 2017 Author Posted October 9, 2017 8 minutes ago, szabesz said: A module directory is renamed by prefixing it with a dot character and a new module directory is created upon extracting the zip file, as far as I know. Of course, wasn't thinking about the renaming with dot character prefix. This does of course mean that your snippets will end up in that archived version so you'd have to copy across with each upgrade. 1 minute ago, bernhard said: so +1 for /site/assets/TracyDebugger/snippets I was literally just writing this when your reply came through. This is safe from the files being run directly from the browser and we have a history of this approach with several other modules using this location. Done! 2
gmclelland Posted October 9, 2017 Posted October 9, 2017 IMHO.. I think it would be best to specify a default directory in site/templates/TracySnippets and allow an override in Tracy for the directory to use in site/templates. I wouldn't recommend snippets in /site/assets/TracyDebugger/snippets because that folder typically isn't versioned control whereas site/templates/ is version controlled. 1
adrian Posted October 9, 2017 Author Posted October 9, 2017 1 minute ago, gmclelland said: IMHO.. I think it would be best to specify a default directory in site/templates/TracySnippets and allow an override in Tracy for the directory to use in site/templates. I wouldn't recommend snippets in /site/assets/TracyDebugger/snippets because that folder typically isn't versioned control whereas site/templates/ is version controlled. Ok, I am going to provide two options (/site/assets/TracyDebugger/snippets/ and /site/templates/TracyDebugger/snippets/) - you can choose whichever you want from the config settings. I definitely see the version control issue, but semantically "assets" seems more appropriate, so you guys can decide what suits you better I like having the parent "TracyDebugger" rather than your suggested "TracySnippets" in case we end up with a need for another Tracy folder in the future - this way they are nested, rather that having them on the same level which I think will be cleaner. Hope that's ok with everyone 3
gmclelland Posted October 9, 2017 Posted October 9, 2017 Both would be probably be fine. I prefer everything to be in site/templates so I know I can copy that whole directory to another site if needed to get the same functionality. If snippets are uploaded to site/assets, I then have to change out of my working directory and hunt down specific folders in site/assets. I prefer to work in one primary directory (site/templates) without switching around if necessary. It saves time. The way I see it is: Does the module have to generate files? if yes, store the files in site/assets. If no, store the files in site/templates somewhere. Quote I like having the parent "TracyDebugger" rather than your suggested "TracySnippets" in case we end up with a need for another Tracy folder in the future - this way they are nested, rather that having them on the same level which I think will be cleaner. Hope that's ok with everyone Sounds good Thanks for all you do! 3
adrian Posted October 9, 2017 Author Posted October 9, 2017 2 minutes ago, gmclelland said: Thanks for all you do! And thank you guys for all the feedback - seriously, it makes it much easier - often the decisions on the best way to do something can take longer than the coding 4
adrian Posted October 10, 2017 Author Posted October 10, 2017 Major new version just released. There are quite a lot of changes and it fact it jumped two major point versions because I added two new panels. Here are the highlights! 1) New Snippets Runner panel - as discussed in the last few posts, this is similar to the Console panel, but all snippets are stored in the filesystem. By default they are stored in /site/templates/TracyDebugger/snippets/, but you can change that to /site/asets/TracyDebugger/snippets/ if you prefer. Running a loaded snippet grabs the latest version each time, so simply save in your code editor, switch to your browser and trigger Run. It has access to all PW variables and can reference the currently edited page etc, just like the Console panel. 2) New Request Info panel - this panel contains most of the info from the ProcessWire Info panel, but also adds the following: Server request (this is a dump of all items from $_SERVER Input GET, POST, & Cookies (these used to be in the Debug Mode panel, but I think this panel is more appropriate for them) PLEASE NOTE: This panel is set to be loaded by default when Tracy is installed, but if you are upgrading an existing Tracy install, you will need to manually add this to be loaded in the config settings. 3) Revised ProcessWire Info panel - this is now much simpler and now contains: API variables (with links to PW docs for each) Core classes (with links to PW docs for each) Config data (dump of $config var) Versions List (an easily copyable list of server and PW core and module versions) Admin Links (including Login, Logout, and Documentation Links 4) Revised Debug Mode panel - several elements moved to Request Info and ProcessWire Info panels. Most of these sections could justifiably belong on the Request Info panel, but I think you are less likely to use most of these on a regular basis - they are more technical than the sections in the Request Info panel. 5) Request Info and Debug Mode panels now load in Redirect and AJAX bars I limit the panels that show up on the Redirect and AJAX bars to ones that will have different content. For example, there is no point loading PHP Info, Captain Hook, etc for these additional bars. Part of my reason for splitting up the ProcessWire Info panel into the new Request Info panel is because there is no point having admin links etc being populated to the additional bars. So you'll see that the ProcessWire Info panel is not loaded for the additional bars, but the Request Info and Debug Mode panels are. Now you can see the details of each page request (whether it's a redirect or AJAX, or ordinary). The panel on the left is after a POST form submission on a regular PW page and the one on the right is an AJAX call to a non-PW PHP script which is why there is no "Page Info" section. In this case, you can see the details of the request via the "Server Request" section which shows: It also shows the GET and POST data for the request, and the edit link will open that /data/testajax.php file in your code editor. 6) Lots of other tweaks There are lots of other tweaks, but the one that might cause a few weird issues is the way the debug bar and panel styles are loaded. The Tracy core now makes this easier, but I have noticed some instances where the styles are not being applied. I think it always comes down to browser caching, but if you find that a hard reload doesn't fix things, please let me know and I'll investigate further. Feedback There are lots of changes in this version, so please let me know if you have any suggestions - did I mess with something that you loved, but now hate, or do you just have ideas for how something could be done better? Please let me know! 4 1
szabesz Posted October 10, 2017 Posted October 10, 2017 (edited) Thanks a million again One thing I've been struggling with ever since is these nice list of icons: 59 minutes ago, adrian said: 3) Revised ProcessWire Info panel - this is now much simpler and now contains: I keep spending a lot of time hovering over them, waiting for the tooltip to appear, that is I cannot seem to learn what is what. Could you please provide an option to turn them into a simple vertical list of icons+labels? Edited October 10, 2017 by szabesz typo 5
adrian Posted October 10, 2017 Author Posted October 10, 2017 7 hours ago, szabesz said: Thanks a million again One thing I've been struggling with ever since is these nice list of icons: I keep spending a lot of time hovering over them, waiting for the tooltip to appear, that is I cannot seem to learn what is what. Could you please provide an option to turn them into a simple vertical list of icons+labels? Ok, they are now a list of icons with labels by default with an option to turn off the labels in the module settings. Hope that helps! Of course if you are upgrading you will need to check the option. 8
Robin S Posted October 10, 2017 Posted October 10, 2017 13 hours ago, adrian said: Major new version just released. Wow, bumper update! Aside: I wonder which PW module has the highest version number? Tracy must be leading the field in terms of number of releases in any case. The Snippets panel is great - just what I was hoping for. Really handy having the keyboard shortcuts for run, and it's neat how the Run button gets focused after loading a snippet too. One thing though: would it possible to allow a namespace declaration inside snippets? I need that for IDE code completion but when I include it I get... Maybe Tracy could strip out any namespace declaration on the first line when it runs the snippet? 1
adrian Posted October 10, 2017 Author Posted October 10, 2017 4 minutes ago, Robin S said: Aside: I wonder which PW module has the highest version number? Tracy must be leading the field in terms of number of releases in any case. Yeah, it is certainly up there 4 minutes ago, Robin S said: The Snippets panel is great - just what I was hoping for. Really handy having the keyboard shortcuts for run, and it's neat how the Run button gets focused after loading a snippet too. Glad it's working well for you. The focusing of the Run button was initially to help with helping target the eventListener for the keyboard shortcut, but I found what I think it a better way without having conflicts if both the Console and Snippet Runner panels are open at once. Even after figuring this out, I decided to keep the focus of the Run button as a visual reminder that loading != running. 7 minutes ago, Robin S said: One thing though: would it possible to allow a namespace declaration inside snippets? Let me look into this - should be a pretty simple fix. 1
adrian Posted October 11, 2017 Author Posted October 11, 2017 @Robin S - please try the latest version which supports declared namespaces in both Snippet Runner and Console panels. 1
Robin S Posted October 11, 2017 Posted October 11, 2017 4 minutes ago, adrian said: please try the latest version Working perfectly, thanks. 2
adrian Posted October 11, 2017 Author Posted October 11, 2017 I've just made a few more tweaks so that now you can have mixed html and php in your snippet file. For example this: <p>Welcome to the <?=$page->name?> page!</p> will return: This might come in handy for testing snippets of template code if you use a direct output approach, or markup regions, or anything else where you are embedding php into HTML tags. The only downside is that now pure PHP snippet files must start with a php open tag. I think this is a quite acceptable compromise as I couldn't imagine writing code in my editor without it. You can also do this with the Console Panel, but you have to start the snippet with ?> to close the automatically added PHP tag, eg: ?> <p>Welcome to the <?=$page->name?> page!</p> This is because the Console Panel always adds an opening PHP tag if it doesn't find one - I think this is best here because it's nice to not have to manually add when doing a quick code test. Anyone have any thoughts on these new abilities - does anything seem illogical? 3
Robin S Posted October 11, 2017 Posted October 11, 2017 21 minutes ago, adrian said: Anyone have any thoughts on these new abilities I like 1
Robin S Posted October 11, 2017 Posted October 11, 2017 @adrian, I'm seeing an error in the back-end AJAX bar after I save a page. Tracy v4.6.4 1
adrian Posted October 11, 2017 Author Posted October 11, 2017 6 minutes ago, Robin S said: @adrian, I'm seeing an error in the back-end AJAX bar after I save a page. Tracy v4.6.4 Sorry about that - I am not seeing that, but I see where it's coming from. Please try 4.6.5 and let me know. PS Don't forget to enable the new Request Info panel which now contains most of the info from the old version of the PW Info panel 1
Robin S Posted October 11, 2017 Posted October 11, 2017 8 minutes ago, adrian said: Please try 4.6.5 and let me know All good now, thanks. 1
Recommended Posts