Skip to content

Commit 270baa7

Browse files
committed
Refactoring in links
1 parent 9dec72c commit 270baa7

File tree

10 files changed

+307
-158
lines changed

10 files changed

+307
-158
lines changed

MacroscopeConstants.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ public enum TextProcessingMode
6969
public const string NamedQueueDisplayHrefLang = "DisplayHrefLang";
7070
public const string NamedQueueDisplayErrors = "DisplayErrors";
7171
public const string NamedQueueDisplayRedirectsAudit = "DisplayRedirectsAudit";
72-
public const string NamedQueueDisplayLinks = "DisplayLinks";
72+
//public const string NamedQueueDisplayLinks = "DisplayLinks";
73+
public const string NamedQueueDisplayHyperlinks = "DisplayHyperlinks";
7374
public const string NamedQueueDisplayUriAnalysis = "DisplayUriAnalysis";
7475
public const string NamedQueueDisplayPageTitles = "DisplayPageTitles";
7576
public const string NamedQueueDisplayPageDescriptions = "DisplayPageDescriptions";

MacroscopeDocument/MacroscopeDocument.cs

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,16 @@ public partial class MacroscopeDocument : Macroscope
103103
private string Canonical;
104104
private Dictionary<string,MacroscopeHrefLang> HrefLang;
105105

106+
// Inbound links
107+
private Boolean ProcessInlinks;
108+
106109
// Outbound links to pages and linked assets to follow
107110
private Dictionary<string,MacroscopeOutlink> Outlinks;
108111

109-
// Outbound hypertext links
112+
// Inbound hypertext links
110113
private Boolean ProcessHyperlinksIn;
114+
115+
// Outbound hypertext links
111116
private MacroscopeHyperlinksOut HyperlinksOut;
112117

113118
private Dictionary<string,string> EmailAddresses;
@@ -129,7 +134,7 @@ public partial class MacroscopeDocument : Macroscope
129134
private int Depth;
130135

131136
// Delegate Functions
132-
private delegate void TimeDuration( Action ProcessMethod );
137+
private delegate void TimeDuration(Action ProcessMethod);
133138

134139
/**************************************************************************/
135140

@@ -233,6 +238,7 @@ private void InitializeDocument ( string Url )
233238
this.Canonical = "";
234239
this.HrefLang = new Dictionary<string,MacroscopeHrefLang> ( 1024 );
235240

241+
this.ProcessInlinks = false;
236242
this.Outlinks = new Dictionary<string,MacroscopeOutlink> ( 128 );
237243

238244
this.ProcessHyperlinksIn = false;
@@ -249,25 +255,25 @@ private void InitializeDocument ( string Url )
249255
this.Keywords = "";
250256
this.AltText = "";
251257

252-
this.Headings = new Dictionary<ushort,List<string>> () {
253-
{
258+
this.Headings = new Dictionary<ushort,List<string>> () { {
254259
1,
255260
new List<string> ( 16 )
256-
}, {
257-
2,
258-
new List<string> ( 16 )
259261
},
260262
{
261-
3,
263+
2,
262264
new List<string> ( 16 )
263265
}, {
264-
4,
266+
3,
265267
new List<string> ( 16 )
266268
},
267269
{
268-
5,
270+
4,
269271
new List<string> ( 16 )
270272
}, {
273+
5,
274+
new List<string> ( 16 )
275+
},
276+
{
271277
6,
272278
new List<string> ( 16 )
273279
}
@@ -819,6 +825,23 @@ public string GetDateModified ()
819825
return( this.DateModified.ToShortDateString() );
820826
}
821827

828+
/** Inlinks ***************************************************************/
829+
830+
public void SetProcessInlinks ()
831+
{
832+
this.ProcessInlinks = true;
833+
}
834+
835+
public void UnsetProcessInlinks ()
836+
{
837+
this.ProcessInlinks = false;
838+
}
839+
840+
public Boolean GetProcessInlinks ()
841+
{
842+
return( this.ProcessInlinks );
843+
}
844+
822845
/** Outlinks **************************************************************/
823846

824847
public Dictionary<string,MacroscopeOutlink> GetOutlinks ()

MacroscopeDocumentCollection/MacroscopeDocumentCollection.cs

Lines changed: 121 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public sealed class MacroscopeDocumentCollection : Macroscope
4545
private MacroscopeSearchIndex SearchIndex;
4646
private MacroscopeDeepKeywordAnalysis AnalyzeKeywords;
4747

48+
private Dictionary<string,MacroscopeInlink> StructInlinks;
4849
private Dictionary<string,MacroscopeHyperlinksIn> StructHyperlinksIn;
49-
private Dictionary<string,MacroscopeHyperlinksIn> StructlinksIn;
5050

5151
private Dictionary<string,Boolean> StatsHistory;
5252
private Dictionary<string,int> StatsHostnames;
@@ -88,6 +88,7 @@ public MacroscopeDocumentCollection ( MacroscopeJobMaster JobMaster )
8888

8989
this.AnalyzeKeywords = new MacroscopeDeepKeywordAnalysis ();
9090

91+
this.StructInlinks = new Dictionary<string,MacroscopeInlink> ( 1024 );
9192
this.StructHyperlinksIn = new Dictionary<string,MacroscopeHyperlinksIn> ( 1024 );
9293

9394
this.StatsHistory = new Dictionary<string,Boolean> ( 1024 );
@@ -281,6 +282,38 @@ public List<string> DocumentKeys ()
281282
return( lKeys );
282283
}
283284

285+
/** Inlinks ***************************************************************/
286+
287+
public MacroscopeInlink GetDocumentInlinks ( string Url )
288+
{
289+
290+
MacroscopeInlink Inlinks = null;
291+
292+
lock( this.StructInlinks )
293+
{
294+
295+
if( this.StructInlinks.ContainsKey( Url ) )
296+
{
297+
Inlinks = this.StructInlinks[ Url ];
298+
}
299+
300+
}
301+
302+
return( Inlinks );
303+
304+
}
305+
306+
public IEnumerable<string> IterateInlinks ()
307+
{
308+
lock( this.StructInlinks )
309+
{
310+
foreach( string Url in this.StructInlinks.Keys )
311+
{
312+
yield return Url;
313+
}
314+
}
315+
}
316+
284317
/** HyperlinksIn **********************************************************/
285318

286319
public MacroscopeHyperlinksIn GetDocumentHyperlinksIn ( string Url )
@@ -411,7 +444,18 @@ public void RecalculateDocCollection ()
411444
{
412445

413446
MacroscopeDocument msDoc = this.GetDocument( UrlTarget );
414-
447+
448+
/*
449+
try
450+
{
451+
this.RecalculateInlinks( msDoc );
452+
}
453+
catch( Exception ex )
454+
{
455+
this.DebugMsg( string.Format( "RecalculateInlinks: {0}", ex.Message ) );
456+
}
457+
*/
458+
415459
try
416460
{
417461
this.RecalculateHyperlinksIn( msDoc );
@@ -481,6 +525,78 @@ public void RecalculateDocCollection ()
481525

482526
}
483527

528+
/** Inlinks ***************************************************************/
529+
530+
/*
531+
private void RecalculateInlinks ( MacroscopeDocument msDoc )
532+
{
533+
534+
DebugMsg( string.Format( "RecalculateInlinks: {0} :: {1}", msDoc.GetProcessInlinks(), msDoc.GetUrl() ) );
535+
536+
if( msDoc.GetProcessInlinks() )
537+
{
538+
539+
DebugMsg( string.Format( "RecalculateInlinks: PROCESSING: {0}", msDoc.GetUrl() ) );
540+
541+
msDoc.UnsetProcessInlinks();
542+
543+
foreach( MacroscopeOutlink Outlink in msDoc.IterateOutlinks() )
544+
{
545+
546+
string Url = Outlink.GetAbsoluteUrl();
547+
MacroscopeInlink Inlink = null;
548+
549+
DebugMsg( string.Format( "RecalculateInlinks: URL SOURCE: {0}", msDoc.GetUrl() ) );
550+
DebugMsg( string.Format( "RecalculateInlinks: URL TARGET: {0}", Url ) );
551+
552+
if( Url == msDoc.GetUrl() )
553+
{
554+
DebugMsg( string.Format( "RecalculateInlinks: SELF: {0}", Url ) );
555+
continue;
556+
}
557+
558+
if( this.StructInlinks.ContainsKey( Url ) )
559+
{
560+
Inlink = this.StructInlinks[ Url ];
561+
}
562+
else
563+
{
564+
Inlink = new MacroscopeInlink ();
565+
this.StructInlinks.Add( Url, Inlink );
566+
}
567+
568+
if( Inlink != null )
569+
{
570+
571+
Inlink.Add(
572+
LinkType: HyperlinkOut.GetHyperlinkType(),
573+
Method: HyperlinkOut.GetMethod(),
574+
UrlOrigin: msDoc.GetUrl(),
575+
UrlTarget: Url,
576+
LinkText: HyperlinkOut.GetLinkText(),
577+
LinkTitle: HyperlinkOut.GetLinkTitle(),
578+
AltText: HyperlinkOut.GetAltText()
579+
);
580+
581+
}
582+
else
583+
{
584+
DebugMsg( string.Format( "RecalculateInlinks: NULL: {0}", msDoc.GetUrl() ) );
585+
}
586+
587+
}
588+
589+
}
590+
else
591+
{
592+
593+
DebugMsg( string.Format( "RecalculateInlinks: ALREADY PROCESSED: {0}", msDoc.GetUrl() ) );
594+
595+
}
596+
597+
}
598+
*/
599+
484600
/** Hyperlinks In *********************************************************/
485601

486602
private void RecalculateHyperlinksIn ( MacroscopeDocument msDoc )
@@ -510,14 +626,14 @@ private void RecalculateHyperlinksIn ( MacroscopeDocument msDoc )
510626
continue;
511627
}
512628

513-
if( StructHyperlinksIn.ContainsKey( Url ) )
629+
if( this.StructHyperlinksIn.ContainsKey( Url ) )
514630
{
515-
HyperlinksIn = StructHyperlinksIn[ Url ];
631+
HyperlinksIn = this.StructHyperlinksIn[ Url ];
516632
}
517633
else
518634
{
519635
HyperlinksIn = new MacroscopeHyperlinksIn ();
520-
StructHyperlinksIn.Add( Url, HyperlinksIn );
636+
this.StructHyperlinksIn.Add( Url, HyperlinksIn );
521637
}
522638

523639
if( HyperlinksIn != null )

MacroscopeForms/MacroscopeDisplay/MacroscopeDisplayViews/MacroscopeDisplayLinks.cs renamed to MacroscopeForms/MacroscopeDisplay/MacroscopeDisplayViews/MacroscopeDisplayHyperlinks.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,17 @@ You should have received a copy of the GNU General Public License
2424
*/
2525

2626
using System;
27-
using System.Text.RegularExpressions;
2827
using System.Drawing;
2928
using System.Windows.Forms;
3029

3130
namespace SEOMacroscope
3231
{
3332

3433
/// <summary>
35-
/// Description of MacroscopeDisplayLinks.
34+
/// Description of MacroscopeDisplayHyperlinks.
3635
/// </summary>
3736

38-
public sealed class MacroscopeDisplayLinks : MacroscopeDisplayListView
37+
public sealed class MacroscopeDisplayHyperlinks : MacroscopeDisplayListView
3938
{
4039

4140
/**************************************************************************/
@@ -44,15 +43,15 @@ public sealed class MacroscopeDisplayLinks : MacroscopeDisplayListView
4443

4544
/**************************************************************************/
4645

47-
public MacroscopeDisplayLinks ( MacroscopeMainForm MainForm, ListView lvListView )
46+
public MacroscopeDisplayHyperlinks ( MacroscopeMainForm MainForm, ListView lvListView )
4847
: base( MainForm, lvListView )
4948
{
5049

5150
this.SuppressDebugMsg = false;
5251

5352
this.MainForm = MainForm;
5453
this.lvListView = lvListView;
55-
this.UrlCount = this.MainForm.macroscopeOverviewTabPanelInstance.toolStripLabelLinksUrls;
54+
this.UrlCount = this.MainForm.macroscopeOverviewTabPanelInstance.toolStripLabelHyperlinksUrls;
5655

5756
if( this.MainForm.InvokeRequired )
5857
{

0 commit comments

Comments
 (0)