[Rt-commit] rtir branch 5.0/fix-external-tools-iframe created. 5.0.4-3-g9aba0fc5

BPS Git Server git at git.bestpractical.com
Tue Jun 27 17:35:10 UTC 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rtir".

The branch, 5.0/fix-external-tools-iframe has been created
        at  9aba0fc5cf520b3f43fea13d257f6a6f07d3a3e3 (commit)

- Log -----------------------------------------------------------------
commit 9aba0fc5cf520b3f43fea13d257f6a6f07d3a3e3
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Tue Jun 27 14:34:22 2023 -0300

    Add SiteAdvisor to External Tools
    
    Also add HTML::TreeBuilder::XPath to the list of dependencies.

diff --git a/Makefile.PL b/Makefile.PL
index d86f3b28..03121a74 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -34,6 +34,9 @@ requires('Parse::BooleanLogic');
 # Domain searching
 requires('Net::Domain::TLD');
 
+# Parse websites with External Tools
+requires('HTML::TreeBuilder::XPath');
+
 # for tests
 build_requires('Test::More');
 build_requires('File::Find');
diff --git a/html/RTIR/Tools/Elements/External/SiteAdvisor b/html/RTIR/Tools/Elements/External/SiteAdvisor
new file mode 100644
index 00000000..d7a8f276
--- /dev/null
+++ b/html/RTIR/Tools/Elements/External/SiteAdvisor
@@ -0,0 +1,86 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2023 Best Practical Solutions, LLC
+%#                                          <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<%ARGS>
+$q => undef
+</%ARGS>
+<%INIT>
+
+my $out = undef;
+
+if ($q) {
+    use LWP::UserAgent;
+    use HTML::TreeBuilder::XPath;
+    use Encode;
+
+    my $site = 'https://www.siteadvisor.com/sitereport.html?url=' . $q;
+    my $ua = LWP::UserAgent->new(env_proxy => 1);
+    my $response = $ua->get($site);
+
+    # Check if there is content
+    if ($response->is_success) {
+        my $tree = HTML::TreeBuilder::XPath->new_from_content($response->content);
+        $out = '<h3>'.$tree->findvalue(qw{//div[@class='status']/div/span[@class='text']});
+        $out .= ' ' .  $tree->findvalue(qw{//div[@class='status']/div/span[@class='rating']});
+        $out .= '<img height="80" src="https://www.siteadvisor.com';
+        $out .= $tree->findvalue(qw{//div[@class='status']/img/@src});
+        $out .= '"></h3>';
+
+        my @contents = $tree->findnodes(qw{//div[@class='content']});
+        foreach my $content (@contents) {
+            $out .= Encode::decode("UTF-8",$content->as_HTML('<>&'));
+        }
+    } else {
+        $out = 'Error: ' . $response->status_line;
+    }
+}
+</%INIT>
+% if ($q) {
+    <% $out |n %>
+% } else {
+    <% loc("No site informed") %>
+%}

commit 8dccc60df7da2f8efa89047cd195d71dbabec013
Author: Ronaldo Richieri <ronaldo at bestpractical.com>
Date:   Tue Jun 27 14:31:54 2023 -0300

    Remove Iframe research tools and add them as External tools
    
    Iframe research tools are not supported by modern browsers. We are
    replacing them with External tools, which will call the research tools
    from the RT server.

diff --git a/etc/RTIR_Config.pm b/etc/RTIR_Config.pm
index be018fe0..685a9a11 100644
--- a/etc/RTIR_Config.pm
+++ b/etc/RTIR_Config.pm
@@ -795,26 +795,20 @@ using the following mason components:
 
 =cut
 
-Set( @RTIRResearchTools, (qw(Traceroute Whois Iframe)));
+Set( @RTIRResearchTools, (qw(Traceroute Whois External)));
 
-=item C<$RTIRIframeResearchToolConfig>
+=item C<$RTIRExternalResearchToolConfig>
 
 One of the research tools available in RTIR allows you to
 configure a set of search URLs that incident handlers
-can use to open searches in IFRAMES.
-
-Entries are keyed by integer in the order you'd like to see
-them in the dropdown on the research page. Each entry consists
-of a hashref containing "FriendlyName" and "URL". The URLs will
-be evaluated to replace __SearchTerm__ with the user's current
-search term.
+can use to open searches in external tools.
 
 =cut
 
-Set($RTIRIframeResearchToolConfig, {
-    1 => { FriendlyName => 'Google', URL => 'https://encrypted.google.com/search?q=__SearchTerm__' },
-    2 => { FriendlyName => 'CVE', URL => 'http://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=__SearchTerm__'},
-    3 => { FriendlyName => 'McAfee SiteAdvisor', URL => 'http://www.siteadvisor.com/sites/__SearchTerm__'}
+Set($RTIRExternalResearchToolConfig, {
+    1 => { FriendlyName => 'Google', Element => 'Google' },
+    2 => { FriendlyName => 'CVE', Element => 'CVE'},
+    3 => { FriendlyName => 'McAfee SiteAdvisor', Element => 'SiteAdvisor'}
 } );
 
 =item C<$TracerouteCommand>
diff --git a/html/RTIR/Tools/Elements/ToolFormIframe b/html/RTIR/Tools/Elements/ToolFormExternal
similarity index 96%
rename from html/RTIR/Tools/Elements/ToolFormIframe
rename to html/RTIR/Tools/Elements/ToolFormExternal
index 6b5326cb..a774ae3b 100644
--- a/html/RTIR/Tools/Elements/ToolFormIframe
+++ b/html/RTIR/Tools/Elements/ToolFormExternal
@@ -78,6 +78,6 @@ $ResearchTool => ''
 </%args>
 <%INIT>
 my $unique_id = time().rand();
-$m->notes(rtir_research_iframe_id => $unique_id);
-my $research_tools = RT->Config->Get('RTIRIframeResearchToolConfig');
+$m->notes(rtir_research_external_id => $unique_id);
+my $research_tools = RT->Config->Get('RTIRExternalResearchToolConfig');
 </%INIT>
diff --git a/html/RTIR/Tools/Elements/ToolResultsIframe b/html/RTIR/Tools/Elements/ToolResultsExternal
similarity index 80%
rename from html/RTIR/Tools/Elements/ToolResultsIframe
rename to html/RTIR/Tools/Elements/ToolResultsExternal
index 323f11c0..4a666f6d 100644
--- a/html/RTIR/Tools/Elements/ToolResultsIframe
+++ b/html/RTIR/Tools/Elements/ToolResultsExternal
@@ -46,24 +46,13 @@
 %#
 %# END BPS TAGGED BLOCK }}}
 <h2><%loc($research_tools->{$ResearchTool}->{FriendlyName})%></h2>
-<iframe 
-    src="<%$url%>" 
-    name="rtir_research_<%$m->notes('rtir_research_iframe_id')%>" 
-    style="width: 100%; height: 70%;"></iframe>
+% $m->comp('External/' . $research_tools->{$ResearchTool}->{Element},
+%    q => $q);
 <%args>
 $q =>  undef
-$TicketType => undef
-$TicketObj => undef
 $ResearchTool => undef
 </%args>
 <%init>
 return unless ($ResearchTool);
-my $research_tools = RT->Config->Get('RTIRIframeResearchToolConfig');
-if (!$research_tools->{$ResearchTool}->{URL}) {
-    $RT::Logger->error(
-        "Couldn't find a URL for RTIR research tool $ResearchTool. You should check your RTIRIframeResearchToolConfig");
-    return;
-}
-my $url = $research_tools->{$ResearchTool}->{URL};
-$url =~ s/__SearchTerm__/$q/g;
+my $research_tools = RT->Config->Get('RTIRExternalResearchToolConfig');
 </%init>

-----------------------------------------------------------------------


hooks/post-receive
-- 
rtir


More information about the rt-commit mailing list