1
+ /*
2
+ * Copyright 2003-2014 the original author or authors.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ /**
18
+ * A template which generates an HTML report from the bincompat XML report
19
+ */
20
+ modelTypes = {
21
+ String title
22
+ String baseline
23
+ String archive
24
+ Map<String ,Map<String ,List<String > > > violations
25
+ }
26
+
27
+ def severityMapping = [
28
+ error : ' danger' ,
29
+ warning : ' warning' ,
30
+ info : ' info' ,
31
+ ignore : ' success'
32
+ ]
33
+
34
+ yieldUnescaped ' <!DOCTYPE html>'
35
+
36
+
37
+ html {
38
+ head {
39
+ meta ' charset' : " utf-8"
40
+ meta ' http-equiv' : " content-type" , content : " text/html; charset=utf-8"
41
+ meta ' http-equiv' : " X-UA-Compatible" , content : " IE=edge"
42
+ meta name : " viewport" , content : " width=device-width, initial-scale=1"
43
+
44
+ title(title)
45
+ link href : " http://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" , rel : " stylesheet"
46
+ link href : " http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" , rel : " stylesheet"
47
+ link href : " http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css" , rel : " stylesheet"
48
+ }
49
+
50
+ body {
51
+ div(class :' navbar navbar-inverse navbar-fixed-top' , role :' navigation' ) {
52
+ div(class :' container' ) {
53
+ div(class :' navbar-header' ) {
54
+ button(type :' button' , class :' navbar-toggle' , ' data-toggle' :' collapse' , ' data-target' :' navbar-collaspe' ) {
55
+ span(class :' sr-only' , ' Toggle navigation' )
56
+ span(class :' icon-bar' ){}
57
+ span(class :' icon-bar' ){}
58
+ span(class :' icon-bar' ){}
59
+ }
60
+ a(class :' navbar-brand' ,href :' #' , ' Binary compatibility report' )
61
+ }
62
+ div(class :' navbar-collapse collapse' ) {
63
+ ul(class :" nav navbar-nav" ) {
64
+ li(class : ' dropdown' ) {
65
+ a(id : ' severityDropdown' , href : ' #' , class : ' dropdown-toggle' , ' data-toggle' : ' dropdown' , ' Severity <span class="caret"></span>' )
66
+ ul(class : " dropdown-menu dropdown-severity" , role : " menu" ) {
67
+ li(role : ' presentation' , class : ' active' ) {
68
+ a(role : ' menuitem' , tabindex : ' -1' , href : ' #' , ' All levels' )
69
+ }
70
+ li(role : ' presentation' ) { a(role : ' menuitem' , tabindex : ' -1' , href : ' #' , ' Error' ) }
71
+ li(role : ' presentation' ) { a(role : ' menuitem' , tabindex : ' -1' , href : ' #' , ' Warning' ) }
72
+ li(role : ' presentation' ) { a(role : ' menuitem' , tabindex : ' -1' , href : ' #' , ' Info' ) }
73
+ }
74
+ }
75
+
76
+ }
77
+ }
78
+ }
79
+ }
80
+
81
+
82
+ div(class : ' container' ) {
83
+ div(class :' jumbotron' ) {
84
+ div(class :' container' ) {
85
+ div(class : ' page-header' ) {
86
+ h1 ' Binary compatibility'
87
+ p " Comparing ${ archive} to reference ${ baseline} "
88
+ p {
89
+ yield " Be warned that this report is not perfect and depends on what "
90
+ a(href : ' https://github.com/siom79/japicmp' , ' JApicmp' )
91
+ yield " is capable to detect."
92
+ }
93
+ }
94
+ }
95
+ }
96
+ violations. each { fqcn , classViolations ->
97
+ def errors = classViolations. keySet()
98
+ def severities = errors. collect { " severity-${ it} " }
99
+ div(class : " panel panel-default ${ severities.join(' ')} " ) {
100
+ div(class : " panel-heading" ) {
101
+ h3(class : ' panel-title' , " Class $fqcn " )
102
+ }
103
+ div(class : ' panel-body' ) {
104
+ table(class : " table table-striped table-bordered" ) {
105
+ tbody {
106
+ classViolations. each { err , list ->
107
+ list. each { item ->
108
+ tr(class : " bincompat-error severity-${ err} " ) {
109
+ td {
110
+ h4 {
111
+ span(class : " label label-${ severityMapping[err]} " , err. capitalize())
112
+ }
113
+ }
114
+ td { span(item) }
115
+ }
116
+ }
117
+ }
118
+ }
119
+ }
120
+ }
121
+ }
122
+ }
123
+
124
+ script(src : " http://code.jquery.com/jquery-1.11.0.min.js" ) {}
125
+ script(src : " http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js" ) {}
126
+ script {
127
+ yieldUnescaped '''
128
+ $(document).ready(function () {
129
+ var severity = null;
130
+ doFilter();
131
+ function doFilter() {
132
+ var severityClass = "severity-" + severity;
133
+ $('.panel').hide();
134
+ $('.bincompat-error').hide();
135
+ $('.bincompat-error').filter(function () {
136
+ return (severity==null || $(this).hasClass(severityClass));
137
+ }).show();
138
+ $('.panel').filter(function () {
139
+ return (severity==null || $(this).hasClass(severityClass));
140
+ }).show();
141
+ }
142
+ $(".dropdown-severity li a").click(function() {
143
+ severity = $(this).text().toLowerCase();
144
+ if (severity==="all levels") {
145
+ severity = null;
146
+ }
147
+ doFilter();
148
+ });
149
+ });'''
150
+ }
151
+ }
152
+ }
153
+ }
0 commit comments