@@ -126,11 +126,21 @@ public void executeReport(Locale locale) throws MavenReportException {
126126 /**
127127 * @See https://maven.apache.org/doxia/developers/sink.html#How_to_inject_javascript_code_into_HTML
128128 */
129+
130+ SinkEventAttributeSet githubButtonJS = new SinkEventAttributeSet ();
131+ // githubButtonJS.addAttribute(SinkEventAttributes.TYPE, "text/javascript");
132+ // githubButtonJS.addAttribute("async", "");
133+ // githubButtonJS.addAttribute("defer", "");
134+ githubButtonJS .addAttribute (SinkEventAttributes .SRC , "https://buttons.github.io/buttons.js" );
135+
136+ String script = "script" ;
137+ mainSink .unknown (script , new Object [] {HtmlMarkup .TAG_TYPE_START }, githubButtonJS );
138+ mainSink .unknown (script , new Object [] {HtmlMarkup .TAG_TYPE_END }, null );
139+
129140 SinkEventAttributeSet googleChartImport = new SinkEventAttributeSet ();
130141 googleChartImport .addAttribute (SinkEventAttributes .TYPE , "text/javascript" );
131142 googleChartImport .addAttribute (SinkEventAttributes .SRC , "https://www.gstatic.com/charts/loader.js" );
132143
133- String script = "script" ;
134144 mainSink .unknown (script , new Object [] {HtmlMarkup .TAG_TYPE_START }, googleChartImport );
135145 mainSink .unknown (script , new Object [] {HtmlMarkup .TAG_TYPE_END }, null );
136146
@@ -154,7 +164,7 @@ public void executeReport(Locale locale) throws MavenReportException {
154164 // Heading 1
155165 mainSink .section1 ();
156166 mainSink .sectionTitle1 ();
157- mainSink .text ("God Class Report for " + projectName + " " + projectVersion );
167+ mainSink .text ("RefactorFirst Report for " + projectName + " " + projectVersion );
158168 mainSink .sectionTitle1_ ();
159169
160170 GitLogReader gitLogReader = new GitLogReader ();
@@ -257,6 +267,8 @@ public void executeReport(Locale locale) throws MavenReportException {
257267 mainSink .division (seriesChartDiv );
258268 mainSink .division_ ();
259269
270+ renderGitHubButtons (mainSink );
271+
260272 String legendHeading = "God Class Chart Legend:" ;
261273 String xAxis = "Effort to refactor to a non-God class" ;
262274 renderLegend (mainSink , legendHeading , xAxis );
@@ -365,6 +377,8 @@ public void executeReport(Locale locale) throws MavenReportException {
365377 mainSink .division_ ();
366378 writeGCBOGchartJs (rankedCBODisharmonies , cboPriority - 1 );
367379
380+ renderGitHubButtons (mainSink );
381+
368382 String legendHeading = "Highly Coupled Classes Chart Legend:" ;
369383 String xAxis = "Number of objects the class is coupled to" ;
370384 renderLegend (mainSink , legendHeading , xAxis );
@@ -446,7 +460,6 @@ private static void legendRow(Sink mainSink, String boldText, String explanation
446460 }
447461
448462 void drawTableHeaderCell (String cellText , Sink mainSink ) {
449- // TODO may need to use mainSink.tableHeaderCell(sinkAttributes)
450463 mainSink .tableHeaderCell ();
451464 mainSink .text (cellText );
452465 mainSink .tableHeaderCell_ ();
@@ -471,6 +484,79 @@ void drawTableCell(Object cellText, Sink mainSink) {
471484 mainSink .tableCell_ ();
472485 }
473486
487+ /*
488+ <a class="github-button" href="https://github.com/jimbethancourt/refactorfirst" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star jimbethancourt/refactorfirst on GitHub">Star</a>
489+ <a class="github-button" href="https://github.com/jimbethancourt/refactorfirst/fork" data-icon="octicon-repo-forked" data-size="large" data-show-count="true" aria-label="Fork jimbethancourt/refactorfirst on GitHub">Fork</a>
490+ <a class="github-button" href="https://github.com/jimbethancourt/refactorfirst/subscription" data-icon="octicon-eye" data-size="large" data-show-count="true" aria-label="Watch jimbethancourt/refactorfirst on GitHub">Watch</a>
491+ <a class="github-button" href="https://github.com/jimbethancourt/refactorfirst/issues" data-icon="octicon-issue-opened" data-size="large" data-show-count="false" aria-label="Issue jimbethancourt/refactorfirst on GitHub">Issue</a>
492+ <a class="github-button" href="https://github.com/sponsors/jimbethancourt" data-icon="octicon-heart" data-size="large" aria-label="Sponsor @jimbethancourt on GitHub">Sponsor</a>
493+ */
494+ void renderGitHubButtons (Sink mainSink ) {
495+ SinkEventAttributeSet alignCenter = new SinkEventAttributeSet ();
496+ alignCenter .addAttribute (SinkEventAttributes .ALIGN , "center" );
497+
498+ mainSink .division (alignCenter );
499+ mainSink .text ("Show RefactorFirst some ❤️" );
500+ mainSink .lineBreak ();
501+
502+ renderGitHubButton (
503+ mainSink ,
504+ "https://github.com/jimbethancourt/refactorfirst" ,
505+ "octicon-star" ,
506+ "true" ,
507+ "Star jimbethancourt/refactorfirst on GitHub" ,
508+ "Star" );
509+ renderGitHubButton (
510+ mainSink ,
511+ "https://github.com/jimbethancourt/refactorfirst/fork" ,
512+ "octicon-repo-forked" ,
513+ "true" ,
514+ "Fork jimbethancourt/refactorfirst on GitHub" ,
515+ "Fork" );
516+ renderGitHubButton (
517+ mainSink ,
518+ "https://github.com/jimbethancourt/refactorfirst/subscription" ,
519+ "octicon-eye" ,
520+ "true" ,
521+ "Watch jimbethancourt/refactorfirst on GitHub" ,
522+ "Watch" );
523+ renderGitHubButton (
524+ mainSink ,
525+ "https://github.com/jimbethancourt/refactorfirst/issue" ,
526+ "octicon-issue-opened" ,
527+ "false" ,
528+ "Issue jimbethancourt/refactorfirst on GitHub" ,
529+ "Issue" );
530+ renderGitHubButton (
531+ mainSink ,
532+ "https://github.com/jimbethancourt/refactorfirst/issue" ,
533+ "octicon-heart" ,
534+ "false" ,
535+ "Sponsor @jimbethancourt on GitHub" ,
536+ "Sponsor" );
537+
538+ mainSink .division_ ();
539+ }
540+
541+ private static void renderGitHubButton (
542+ Sink mainSink ,
543+ String url ,
544+ String dataIconValue ,
545+ String dataShowCount ,
546+ String ariaLabel ,
547+ String anchorText ) {
548+ SinkEventAttributeSet starButton = new SinkEventAttributeSet ();
549+ starButton .addAttribute (SinkEventAttributes .HREF , url );
550+ starButton .addAttribute ("class" , "github-button" );
551+ starButton .addAttribute ("data-icon" , dataIconValue );
552+ starButton .addAttribute ("data-size" , "large" );
553+ starButton .addAttribute ("data-show-count" , dataShowCount );
554+ starButton .addAttribute ("aria-label" , ariaLabel );
555+ mainSink .unknown ("a" , new Object [] {HtmlMarkup .TAG_TYPE_START }, starButton );
556+ mainSink .text (anchorText );
557+ mainSink .unknown ("a" , new Object [] {HtmlMarkup .TAG_TYPE_END }, null );
558+ }
559+
474560 // TODO: Move to another class to allow use by Gradle plugin
475561 void writeGodClassGchartJs (List <RankedDisharmony > rankedDisharmonies , int maxPriority ) {
476562 GraphDataGenerator graphDataGenerator = new GraphDataGenerator ();
0 commit comments