Modify

Opened 8 months ago

Closed 7 months ago

#13954 closed defect (wontfix)

back-links section appears twice

Reported by: clemens Owned by: Jun Omae
Priority: normal Component: TracBackLinkPlugin
Severity: trivial Keywords: patch
Cc: Trac Release: 1.4

Description

The TracBackLinkPlugin (revision r17971) appears twice if the HTML file is saved to local file.

Background

This is a minor issue with Java-Script code which inserts HTML elements (such as the TracBackLinkPlugin section) into the DOM. If you use your browser to save the final HTML page to a file, then when viewing the produced HTML file the affected HTML fragment (TracBackLinkPlugin section) appears twice:

  1. as static HTML as written by the browser
  2. as dynamically (Java-Script) created HTML.

Of course this issue is not very critical. But sometimes people (like me) save TRAC ticket HTML files.

Patch

The issue is easy to fix. Java-Script shall simply check if the HTML sections to be inserted already exist. I am going to submit a simply patch.

TracBackLinkPlugin [17971] duplicate

Attachments (3)

backlinks_twice.png (92.9 KB) - added by clemens 8 months ago.
TracBackLinkPlugin [17971] duplicate
base.js.diff (848 bytes) - added by clemens 8 months ago.
This is a propose patch for #13954. The Java-Script code simply checks if the HTML section (i.e. #backlinks) to be inserted already exist in the DOM. We avoid inserting it a second time.
duplicated-section-anchors.png (12.1 KB) - added by Jun Omae 8 months ago.

Download all attachments as: .zip

Change History (7)

Changed 8 months ago by clemens

Attachment: backlinks_twice.png added

Changed 8 months ago by clemens

Attachment: base.js.diff added

This is a propose patch for #13954. The Java-Script code simply checks if the HTML section (i.e. #backlinks) to be inserted already exist in the DOM. We avoid inserting it a second time.

comment:1 Changed 8 months ago by clemens

Keywords: patch added

Changed 8 months ago by Jun Omae

comment:2 Changed 8 months ago by Jun Omae

Severity: normaltrivial

The issue is well known. Almost of web applications have the same issue. At least, section anchors in Trac are added twice on saved html file.

  • tracbacklink/htdocs/base.js

     
    1212        return;
    1313
    1414    var content = $('<div>').html(data.content).contents();
     15    var target;
     16    var method;
    1517    switch (data.type) {
    1618    case 'ticket':
    17         $('div#ticket').after(content);
     19        target = 'div#ticket';
     20        method = 'after';
    1821        break;
    1922    case 'wiki':
    20         $('div#content div.wikipage.searchable').after(content);
     23        target = 'div#content div.wikipage.searchable';
     24        method = 'after';
    2125        break;
    2226    case 'milestone':
    23         $('div#attachments').before(content);
     27        target = 'div#attachments';
     28        method = 'before';
    2429        break;
     30    default:
     31        return;
    2532    }
     33    target = $(target);
     34    if (target.siblings('div#backlinks').length !== 0)
     35        return;
     36    target[method](content);
    2637});

comment:3 Changed 8 months ago by Jun Omae

Also, Save a web page, complete feature doesn't save raw html.

comment:4 Changed 7 months ago by Jun Omae

Resolution: wontfix
Status: newclosed

That is a browser issue, not an issue of this plugin. I won't fix it.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.