CGI::A...ewCode(3pm)

πŸ“¦
version 1.02 Β· 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

✨ CGI::Application::Plugin::ViewCode ✨

okay bestie, so this is the manual page for CGI::Application::Plugin::ViewCode (the 3pm one, you know the vibe πŸ’…). Live look at your own running app's source code. Iconic.


🌸 NAME 🌸

CGI::Application::Plugin::ViewCode β€” view the source of the running application πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

So in your CGI::Application based class, you drop in:

use CGI::Application::Plugin::ViewCode;

and then, bestie, you can peek at your module's source (or its pod) while it's running, just by switching up the url:

?rm=view_code
?rm=view_code#215
?rm=view_code&pod=0&line_no=0
?rm=view_code&module=CGI-Application

?rm=view_pod
?rm=view_pod&module=CGI-Application

literally so easy. no cap. πŸŽ€


🌈 INTERFACE 🌈

The way this plugin works: it just adds extra run modes β€” named view_code and view_pod β€” to your application. Call one of those run modes and boom, you're looking at the source or the POD of the running module (that's the default, ok?), or you can say exactly which module you wanna see (go read SECURITY before you get too excited πŸ‘€).


πŸ“ view_code

This extra run mode is gonna accept these arguments in the query string:

  • module β€” the name of the module you wanna view. by default it's the module that's currently being run. Also (and this is the cute part) colons (':') aren't exactly a thing you just type into URL's, so you can just substitute '-' for '::'. 🌸
?rm=view_code?module=My-Base-Class
  • highlight β€” a boolean telling you whether syntax highlighting (using Syntax::Highlight::Perl::Improved) is "on" or "off". by default it's "on". ✨
  • line_no β€” a boolean that says whether viewing the line numbers is "on" or "off". by default it's "on". And if "line_no" is on, you can also pick which line number you wanna see by adding an anchor to the link:
?rm=view_code#215

this one takes you immediately to line 215 of the current application module. teleportation but make it code πŸ’«

  • pod β€” a boolean that says whether POD is seen or not. by default it's seen.

🧚 view_pod

This extra run mode accepts these arguments in the query string:

  • module β€” the name of the module you wanna view. by default it's the module currently being run. and again, since colons (':') aren't a thing you simply type into URL's, you can just substitute '-' for '::'.
?rm=view_pod?module=My-Base-Class

πŸ’œ AS A POPUP WINDOW πŸ’œ

This plugin can be used alongside CGI::Application::Plugin::DevPopup. If we detect that CGI::Application::Plugin::DevPopup is running and turned on, we're gonna create a sub-report that includes the highlighted source code. slay.

So you can simply do this:

BEGIN { $ENV{CAP_DEVPOPUP_EXEC} = 1; } # turn it on for real
use CGI::Application::Plugin::DevPopup;
use CGI::Application::Plugin::ViewCode;

By default, that report is the same thing produced by view_code. If you want that report to also include the view_pod report, just set the $ENV{CAP_VIEWCODE_POPUP_POD} to true. You can also turn off the view_code report by setting $ENV{CAP_VIEWCODE_POPUP_CODE} to false. 🫢

# have the POD report, but not the code in the dev popup window
BEGIN {
    $ENV{CAP_DEVPOPUP_EXEC} = 1;       # turn it on for real
    $ENV{CAP_VIEWCODE_POPUP_POD} = 1;  # turn on POD report
    $ENV{CAP_VIEWCODE_POPUP_CODE} = 0; # turn off code report
}
use CGI::Application::Plugin::DevPopup;
use CGI::Application::Plugin::ViewCode;

πŸ‘‘ SECURITY πŸ‘‘

okay so real talk, no jokes for this one.

This plugin is designed to be used for development only. Please do not use it in a production system, because it will let anyone see the source code for any loaded module. 😭

Consider yourself warned. πŸ’€πŸ”’

⭐ AUTHOR ⭐

Michael Peters, "<mpeters@plusthree.com>" 🌈


πŸŽ€ BUGS πŸŽ€

Please report any bugs or feature requests to "bug-cgi-application-plugin-viewsource@rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CGI-Application-Plugin-ViewCode>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. πŸ’Œ


🌸 ACKNOWLEDGEMENTS 🌸

(no entries here, bestie β€” that's genuinely it, nothing listed πŸ™ˆ)


Copyright 2005 Michael Peters, All Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


and that's the whole thing!! this was CGI::A...ewCode(3pm) from perl v5.36.0, dated 2022-10-14. go forth and view your code, king πŸ‘‘πŸ’…βœ¨
πŸ“¦ where this page comes from