Bug 36333 - Remove all empty lines from template's output
Summary: Remove all empty lines from template's output
Status: Failed QA
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low normal (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-15 14:15 UTC by Jonathan Druart
Modified: 2024-04-01 15:44 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
This removes extra blank lines from the HTML page source for OPAC and staff interface pages. The HTML page source should now be more compact, which should make it easier to read. (The extra blank lines are caused by the way HTML output is generated by the Template Toolkit - it includes whitespace anywhere there is a template tag.)
Version(s) released in:


Attachments
Bug 36333: Remove empty lines from template's output (903 bytes, patch)
2024-03-15 14:20 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 36333: Remove empty lines from template's output (950 bytes, patch)
2024-03-15 20:50 UTC, David Nind
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2024-03-15 14:15:39 UTC
We have tried global TT CHOMP (see bug 20657) but it's not trivial and will introduce a lot of side-effects.

I would like to reduce the number of empty lines in a more secure way.
Comment 1 Jonathan Druart 2024-03-15 14:20:42 UTC
Created attachment 163242 [details] [review]
Bug 36333: Remove empty lines from template's output

This patch removes empty lines (containing only whitespaces) from the
output.

It does not have the intented result, we don't gain much in term of
size.
However the source is way cleaner and easier to read.
Comment 2 David Nind 2024-03-15 20:50:09 UTC
Created attachment 163279 [details] [review]
Bug 36333: Remove empty lines from template's output

This patch removes empty lines (containing only whitespaces) from the
output.

It does not have the intented result, we don't gain much in term of
size.
However the source is way cleaner and easier to read.

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 David Nind 2024-03-15 21:04:41 UTC
Testing notes (using KTD):

1. View the page source for some OPAC and staff interface pages (for example: home pages for staff interface and OPC, and the details page for a record).

2. Notice that there are a lot of empty lines.

3. Apply the patch.

4. Repeat step 1.

5. Now notice that the JTML page source is much more compact, with minimal extra blank lines.

Some examples:
- OPAC home page: before - 944 lines; after - 398 lines
- OPAC detail page (262 - Programming perl): before - 2487 lines; after - 1285 lines
- Staff interface home page: before - 1326 lines; after - 706 lines
- Staff detail page (262 - Programming perl): before - 2754 lines; after - 1837 lines

Example source for staff interface home page
============================================

Before
~~~~~~






<!DOCTYPE html>
<!-- TEMPLATE FILE: intranet-main.tt -->









<html lang="en">
<head>

<title>Koha staff interface</title>
<link href="/intranet-tmpl/prog/css/mainpage_23.1200007.css" type="text/css" rel="stylesheet">




After
~~~~~


<!DOCTYPE html>
<!-- TEMPLATE FILE: intranet-main.tt -->
<html lang="en">
<head>
<title>Koha staff interface</title>
<link rel="stylesheet" type="text/css" href="/intranet-tmpl/prog/css/mainpage_23.1200007.css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="csrf-token" content="2d7ba25b9f496ed95c17a4329ad494e72ed7fff2,3a063148798d7315f4ba188017bd48dad177740b,1710535727">
<meta name="generator" content="Koha 23.12.00" />
    <style id="antiClickjack">body{display:none !important;}</style>
<link rel="shortcut icon" href="/intranet-tmpl/prog/img/favicon.ico" type="image/x-icon" />
    <link type="text/css" rel="stylesheet" href="/intranet-tmpl/lib/jquery/jquery-ui-1.13.2.min_23.1200007.css">
<link type="text/css" rel="stylesheet" href="/intranet-tmpl/lib/bootstrap/bootstrap.min_23.1200007.css">
<link href="/intranet-tmpl/lib/bootstrap/bootstrap-theme.min_23.1200007.css" type="text/css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="/intranet-tmpl/lib/fontawesome/css/fontawesome.min_23.1200007.css">
<link href="/intranet-tmpl/lib/fontawesome/css/brands.min_23.1200007.css" type="text/css" rel="stylesheet">
<link href="/intranet-tmpl/lib/fontawesome/css/solid.min_23.1200007.css" type="text/css" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="/intranet-tmpl/lib/datatables/datatables.min_23.1200007.css">
<link href="/intranet-tmpl/prog/css/print_23.1200007.css" type="text/css" rel="stylesheet" media="print">
    <link type="text/css" rel="stylesheet" href="/intranet-tmpl/prog/css/staff-global_23.1200007.css">
<!-- local colors -->
<script type="module">
    import { APIClient } from '/intranet-tmpl/prog/js/fetch/api-client.js';
    window.APIClient = APIClient;
</script>
<script>
var Koha = {};
    var CAN_user_parameters_manage_column_config = 1;
</script>
Comment 4 David Cook 2024-03-17 23:20:47 UTC
I don't know about this. Surely this would accidentally remove empty lines in unexpected ways?
Comment 5 Jonathan Druart 2024-03-20 09:12:58 UTC Comment hidden (obsolete)
Comment 6 Jonathan Druart 2024-03-20 09:13:21 UTC
(In reply to David Cook from comment #4)
> I don't know about this. Surely this would accidentally remove empty lines
> in unexpected ways?

Maybe, I didn't find any. Did you? I guess it's an hard one to anticipate. We can push and see. Revert will be trivial if needed.
Comment 7 Nick Clemens (kidclamp) 2024-04-01 15:44:07 UTC
It silently removes blank lines from  notices and sysprefs :-(