Customize Lookup.html

Hello !

I’m trying to add a field on the RTIR Lookup.html page with Callbacks, but it doesn’t work. I must have missed something…

I’m trying to add a field that, when I put in a URL or IP, redirects me to the “Countermeasure” ticket search, which may or may not contain the URL or IP. But it’s not displayed.

The content of the Callback file :

<form action="Lookup.html" method="get" target="_blank">
  <div class="form-row">
    <div class="col-2">
      <span class="current-value form-control"><%loc('Blocked :')%>:</span>
    </div>
% foreach my $arg ( grep exists $ARGS{$_}, @PassArguments ) {
    <input type="hidden" name="<% $arg %>" value="<% $ARGS{ $arg } %>" />
% }
    <div class="col-4">
      <input class="form-control" type="text" name="q" value="<% $q %>" />
    </div>
    <div class="col-auto">
      <input class="form-control btn btn-primary button" type="submit" value="<%loc('Go')%>" />
    </div>
  </div>
</form>
<%args>
$q => ''
@PassArguments => ()
</%args>

The name of the file is ToolFormBlock and his location inside the docker container is /opt/rt5/local/html/Callbacks/Blocker/Tools/Lookup.html.

For information, I use the FireFart docker image of RTIR.

I’m not an RTIR user so I can’t help with this one specifically, but just to check: have you flushed the Mason cache? Also make sure that the callback name ToolFormBlock matches the case of the callback in the Lookup.html code.

How can I flush the Mason cache ?

Depends on where you’ve got things installed, but if your installation is like our RT5 installs its probably in /opt/rt5/var/mason_data/obj. We have a local script called kickrt that removes this and also restarts the web and database servers Just In Case:

#!/bin/bash

rm -rf /opt/rt5/var/mason_data/obj; 
service httpd stop; 
service mysqld restart;
service httpd start;

Hi !

As said in my first post, RTIR is containerized in a Docker container.

And so, as I’m using volumes to add a Callback file, I use the script provided by FireFart to restart the containers:

#!/bin/bash

# this only restarts prod without pulling in new images

set -euf -o pipefail

export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1
export COMPOSE_PROFILES=full

DIR="${BASH_SOURCE%/*}"
if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
. "$DIR/bash_functions.sh"

check_files

fix_file_perms

docker compose -f docker-compose.yml stop
docker compose -f docker-compose.yml rm -f -v -s
docker compose -f docker-compose.yml up -d --remove-orphans
docker image prune -f

I’ve looked in the code of Lookup.html and I can’t find much related to the formatting of the Callback file name : https://github.com/bestpractical/rtir/blob/5.0-trunk/html/RTIR/Tools/Lookup.html.

The only place I can find anything related to filename formatting is in this particular file: https://github.com/bestpractical/rtir/blob/5.0-trunk/html/RTIR/Tools/Elements/Tools

With this code :

<%INIT>
my $tools = RT->Config->Get('RTIRResearchTools') || ();
</%INIT>

<div class="row">
  <div class="col-6">
% for my $tool (@$tools) {
%     if ($m->comp_exists('ToolForm' . $tool)) {
%         $m->comp('ToolForm' . $tool, %ARGS);
%    }
% }
  </div>
</div>

% unless ( $ARGS{ HideResults } ) {
<br>
<div class="row">
  <div class="col-12">
<%perl>
for my $tool (@$tools) {
    if ($m->comp_exists('ToolResults' . $tool)) {
        $m->comp('ToolResults' . $tool, %ARGS);
    }
}
</%perl>
  </div>
</div>
% }

I might be misunderstanding what you doing here, but a quick peek at that link you supplied for Lookup.html doesn’t appear to include a Callback named ToolFormBlock? Looks like the options you have are BeforeCurrent, AfterCurrent, BeforeTools or AfterTools. You need to call your file one of those I think.

In that case, I don’t understand how I can have ToolFormTraceroute and ToolFormWhois on the Lookup.html page…

Knowing that in my Docker container, it’s the same structure as in the github repositories.

I’d guess (and remember I don’t use RTIR!) that might be because those two do appear as components in the same directory - rtir/html/RTIR/Tools/Elements at 5.0-trunk · bestpractical/rtir · GitHub

I can’t see ToolFormBlock in there?

This is normal that you can’t see ToolFormBlock in there, that’s because this is the official repository of RTIR from BestPractical.