Skip to content

Commit b547fa0

Browse files
committed
Adding Status Code columns to Links and Hyperlinks overview panels
1 parent 008d3a7 commit b547fa0

File tree

7 files changed

+184
-169
lines changed

7 files changed

+184
-169
lines changed

SEOMacroscopeSeriesOne/src/MacroscopeForms/MacroscopeContextMenus/MacroscopeContextMenus.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public void CallbackCopySourceUrlClick ( object sender, EventArgs e )
229229

230230
/** -------------------------------------------------------------------- **/
231231

232-
public void CallbackCopyTargetClick ( object sender, EventArgs e )
232+
public void CallbackCopyTargetUrlClick ( object sender, EventArgs e )
233233
{
234234

235235
ToolStripMenuItem tsMenuItem = sender as ToolStripMenuItem;

SEOMacroscopeSeriesOne/src/MacroscopeForms/MacroscopeDisplay/MacroscopeDisplayViews/MacroscopeDisplayHyperlinks.cs

+23-6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ You should have received a copy of the GNU General Public License
2727
using System.Collections.Generic;
2828
using System.Drawing;
2929
using System.Windows.Forms;
30+
using System.Net;
3031

3132
namespace SEOMacroscope
3233
{
@@ -42,12 +43,13 @@ public sealed class MacroscopeDisplayHyperlinks : MacroscopeDisplayListView
4243

4344
private const int ColUrl = 0;
4445
private const int ColUrlTarget = 1;
45-
private const int ColDoFollow = 2;
46-
private const int ColLinkTarget = 3;
47-
private const int ColLinkAnchorTextLabel = 4;
48-
private const int ColLinkTitleLabel = 5;
49-
private const int ColAltTextLabel = 6;
50-
private const int ColRawTargetUrl = 7;
46+
private const int ColStatusCode= 2;
47+
private const int ColDoFollow = 3;
48+
private const int ColLinkTarget = 4;
49+
private const int ColLinkAnchorTextLabel = 5;
50+
private const int ColLinkTitleLabel = 6;
51+
private const int ColAltTextLabel = 7;
52+
private const int ColRawTargetUrl = 8;
5153

5254
private ToolStripLabel UrlCount;
5355

@@ -284,6 +286,7 @@ string Url
284286
string UrlTarget = HyperlinkOut.GetTargetUrl();
285287
string PairKey = string.Join( ":", UrlToDigest( Url ), UrlToDigest( UrlTarget ) );
286288
string LinkTarget = HyperlinkOut.GetLinkTarget();
289+
HttpStatusCode StatusCode = HttpStatusCode.Ambiguous;
287290
string LinkText = HyperlinkOut.GetAnchorText();
288291
string LinkTitle = HyperlinkOut.GetTitle();
289292
string AltText = HyperlinkOut.GetAltText();
@@ -296,6 +299,18 @@ string Url
296299

297300
string DoFollow = "No Follow";
298301

302+
try
303+
{
304+
if( DocCollection.ContainsDocument( Url: HyperlinkOut.GetLinkTarget() ) )
305+
{
306+
StatusCode = DocCollection.GetDocumentByUrl( Url: HyperlinkOut.GetLinkTarget() ).GetStatusCode();
307+
}
308+
}
309+
catch( Exception ex )
310+
{
311+
this.DebugMsg( ex.Message );
312+
}
313+
299314
if( HyperlinkOut.GetDoFollow() )
300315
{
301316
DoFollow = "Follow";
@@ -326,6 +341,7 @@ string Url
326341

327342
lvItem.SubItems[ ColUrl ].Text = Url;
328343
lvItem.SubItems[ ColUrlTarget ].Text = UrlTarget;
344+
lvItem.SubItems[ ColStatusCode ].Text = ((int)StatusCode).ToString();
329345
lvItem.SubItems[ ColDoFollow ].Text = DoFollow;
330346
lvItem.SubItems[ ColLinkTarget ].Text = LinkTarget;
331347
lvItem.SubItems[ ColLinkAnchorTextLabel ].Text = LinkTextLabel;
@@ -352,6 +368,7 @@ string Url
352368

353369
lvItem.SubItems[ ColUrl ].Text = Url;
354370
lvItem.SubItems.Add( UrlTarget );
371+
lvItem.SubItems.Add( ( (int) StatusCode ).ToString() );
355372
lvItem.SubItems.Add( DoFollow );
356373
lvItem.SubItems.Add( LinkTarget );
357374
lvItem.SubItems.Add( LinkTextLabel );

SEOMacroscopeSeriesOne/src/MacroscopeForms/MacroscopeDisplay/MacroscopeDisplayViews/MacroscopeDisplayLinks.cs

+40-16
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ You should have received a copy of the GNU General Public License
2727
using System.Collections.Generic;
2828
using System.Drawing;
2929
using System.Windows.Forms;
30+
using System.Net;
3031

3132
namespace SEOMacroscope
3233
{
@@ -40,6 +41,15 @@ public sealed class MacroscopeDisplayLinks : MacroscopeDisplayListView
4041

4142
/**************************************************************************/
4243

44+
private const int ColType = 0;
45+
private const int ColUrl = 1;
46+
private const int ColUrlTarget = 2;
47+
private const int ColStatusCode = 3;
48+
private const int ColDoFollow = 4;
49+
private const int ColAltTextLabel = 5;
50+
private const int ColRawSourceUrl = 6;
51+
private const int ColRawTargetUrl = 7;
52+
4353
private ToolStripLabel UrlCount;
4454

4555
/**************************************************************************/
@@ -354,14 +364,26 @@ string Url
354364
ListViewItem lvItem = null;
355365
string LinkType = Link.GetLinkType().ToString();
356366
string UrlTarget = Link.GetTargetUrl();
367+
HttpStatusCode StatusCode = HttpStatusCode.Ambiguous;
357368
string PairKey = string.Join( ":", UrlToDigest( Url: Url ), UrlToDigest( Url: UrlTarget ) );
358369
string DoFollow = "No Follow";
359370
string AltText = Link.GetAltText();
360371
string AltTextLabel = AltText;
361-
362372
string RawSourceUrl = Link.GetRawSourceUrl();
363373
string RawTargetUrl = Link.GetRawTargetUrl();
364374

375+
try
376+
{
377+
if( DocCollection.ContainsDocument( Url: Link.GetTargetUrl() ) )
378+
{
379+
StatusCode = DocCollection.GetDocumentByUrl( Url: Link.GetTargetUrl() ).GetStatusCode();
380+
}
381+
}
382+
catch( Exception ex )
383+
{
384+
this.DebugMsg( ex.Message );
385+
}
386+
365387
if( Link.GetDoFollow() )
366388
{
367389
DoFollow = "Follow";
@@ -390,13 +412,14 @@ string Url
390412

391413
lvItem = this.DisplayListView.Items[ PairKey ];
392414

393-
lvItem.SubItems[ 0 ].Text = LinkType;
394-
lvItem.SubItems[ 1 ].Text = Url;
395-
lvItem.SubItems[ 2 ].Text = UrlTarget;
396-
lvItem.SubItems[ 3 ].Text = DoFollow;
397-
lvItem.SubItems[ 4 ].Text = AltTextLabel;
398-
lvItem.SubItems[ 5 ].Text = RawSourceUrl;
399-
lvItem.SubItems[ 6 ].Text = RawTargetUrl;
415+
lvItem.SubItems[ ColType ].Text = LinkType;
416+
lvItem.SubItems[ ColUrl ].Text = Url;
417+
lvItem.SubItems[ ColUrlTarget ].Text = UrlTarget;
418+
lvItem.SubItems[ ColStatusCode ].Text = ( (int) StatusCode ).ToString();
419+
lvItem.SubItems[ ColDoFollow ].Text = DoFollow;
420+
lvItem.SubItems[ ColAltTextLabel ].Text = AltTextLabel;
421+
lvItem.SubItems[ ColRawSourceUrl ].Text = RawSourceUrl;
422+
lvItem.SubItems[ ColRawTargetUrl ].Text = RawTargetUrl;
400423

401424
}
402425
catch( Exception ex )
@@ -415,9 +438,10 @@ string Url
415438
lvItem.UseItemStyleForSubItems = false;
416439
lvItem.Name = PairKey;
417440

418-
lvItem.SubItems[ 0 ].Text = LinkType;
441+
lvItem.SubItems[ ColType ].Text = LinkType;
419442
lvItem.SubItems.Add( Url );
420443
lvItem.SubItems.Add( UrlTarget );
444+
lvItem.SubItems.Add( ( (int) StatusCode ).ToString() );
421445
lvItem.SubItems.Add( DoFollow );
422446
lvItem.SubItems.Add( AltTextLabel );
423447
lvItem.SubItems.Add( RawSourceUrl );
@@ -443,36 +467,36 @@ string Url
443467

444468
if( AllowedHosts.IsAllowedFromUrl( Url ) )
445469
{
446-
lvItem.SubItems[ 1 ].ForeColor = Color.Green;
470+
lvItem.SubItems[ ColUrl ].ForeColor = Color.Green;
447471
}
448472
else
449473
{
450-
lvItem.SubItems[ 1 ].ForeColor = Color.Gray;
474+
lvItem.SubItems[ ColUrl ].ForeColor = Color.Gray;
451475
}
452476

453477
if( AllowedHosts.IsAllowedFromUrl( UrlTarget ) )
454478
{
455-
lvItem.SubItems[ 2 ].ForeColor = Color.Green;
479+
lvItem.SubItems[ ColUrlTarget ].ForeColor = Color.Green;
456480
}
457481
else
458482
{
459-
lvItem.SubItems[ 2 ].ForeColor = Color.Gray;
483+
lvItem.SubItems[ ColUrlTarget ].ForeColor = Color.Gray;
460484
}
461485

462486
if( AllowedHosts.IsAllowedFromUrl( UrlTarget ) )
463487
{
464488
if( Link.GetDoFollow() )
465489
{
466-
lvItem.SubItems[ 3 ].ForeColor = Color.Green;
490+
lvItem.SubItems[ ColDoFollow ].ForeColor = Color.Green;
467491
}
468492
else
469493
{
470-
lvItem.SubItems[ 3 ].ForeColor = Color.Red;
494+
lvItem.SubItems[ ColDoFollow ].ForeColor = Color.Red;
471495
}
472496
}
473497
else
474498
{
475-
lvItem.SubItems[ 3 ].ForeColor = Color.Gray;
499+
lvItem.SubItems[ ColDoFollow ].ForeColor = Color.Gray;
476500
}
477501

478502
}

0 commit comments

Comments
 (0)