html_cs_run_parse 0.0.3 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,21 @@
1
+ $:.unshift File.dirname(__FILE__) + '/../../modules'
2
+ $:.unshift File.dirname(__FILE__) + '/../builders'
3
+ require 'image_interaction'
4
+ require 'html_builder'
5
+ require 'page_html'
6
+ require 'app_html'
7
+ require 'row_html'
8
+ class OutputGeneration
9
+ include ImageInteraction
10
+
11
+ def initialize(app, ddl = "./data/output/files/")
12
+ app.graph.populate_graph
13
+ app.pages.each do |page|
14
+ place_image_content(ddl + page.page, page.image)
15
+ end
16
+ app_html = AppHTML.new(app)
17
+ html = app_html.build
18
+ place_image_content(ddl.split("files/")[0] + "pa11y_" + app.application_name + '_' + app.env, html, ".html")
19
+ #put html in the output folder need to remove files from ddl
20
+ end
21
+ end
@@ -0,0 +1,90 @@
1
+ $:.unshift File.dirname(__FILE__) + '/../../modules'
2
+ require 'image_interaction'
3
+ class Retrieval
4
+ include ImageInteraction
5
+ attr_accessor(:ddl)
6
+
7
+ def initialize(ddl)
8
+ @ddl = ddl
9
+ end
10
+
11
+ def retrieve_csv_collection
12
+ output = []
13
+ file_locations = return_all_files(ddl, 'csv')
14
+ file_locations.each do |file_location|
15
+ t_output = []
16
+ File.open(file_location, 'r') { |file|
17
+ content = file.read
18
+ split = content.split("\n")
19
+ split.delete_at(0)
20
+ split.each do |row|
21
+ components = row.split(',')
22
+ csv_o = CSVObject.new(components[0].tr('"', ''), components[1], components[2], components[3], components[4])
23
+ t_output.push(csv_o)
24
+ end
25
+ output.push(t_output)
26
+ }
27
+ end
28
+ output
29
+ end
30
+
31
+ def retrieve_url_collection
32
+ output = []
33
+ file_locations = return_all_files(ddl, 'txt')
34
+ file_locations.each do |file_location|
35
+ File.open(file_location, 'r') { |file|
36
+ output.push(file.read) }
37
+ end
38
+ output
39
+ end
40
+
41
+ def retrieve_image_collection
42
+ output = []
43
+ file_locations = return_all_files(ddl, 'png')
44
+ file_locations.each do |file_location|
45
+ File.open(file_location, 'r') { |file|
46
+ output.push(retrieve_image_content(file)) }
47
+ end
48
+ output
49
+ end
50
+
51
+ def retrieve_app_name
52
+ file = return_all_files(ddl, 'csv')[0]
53
+ split = split_on_underscores(file)
54
+ split[0]
55
+ end
56
+
57
+ def retrieve_page_names
58
+ files = return_all_files(ddl, 'csv')
59
+ output = []
60
+ files.each do |file|
61
+ output.push(split_on_underscores(file)[1])
62
+ end
63
+ output
64
+ end
65
+
66
+ def retrieve_env
67
+ file = return_all_files(ddl, 'csv')[0]
68
+ split = split_on_underscores(file)
69
+ split[2].split('.')[0]
70
+ end
71
+
72
+ private
73
+
74
+ def split_on_underscores(file)
75
+ file.split('/').last.split('_')
76
+ end
77
+
78
+ end
79
+
80
+ class CSVObject
81
+ attr_accessor(:error_warning, :guideline, :error_description, :html_path, :content)
82
+
83
+ def initialize(error_warning, guideline, error_description, content, html_path)
84
+ @error_warning = error_warning
85
+ @guideline = guideline
86
+ @error_description = error_description
87
+ @content = content
88
+ @html_path = html_path
89
+ end
90
+ end
@@ -0,0 +1,83 @@
1
+ $:.unshift File.dirname(__FILE__) + '/../struct_classes'
2
+ $:.unshift File.dirname(__FILE__) + '/../setup'
3
+ $:.unshift File.dirname(__FILE__) + '/../objects'
4
+ require 'score_collection'
5
+ require 'retrieval'
6
+ require 'page'
7
+ require 'row'
8
+ class Setup
9
+ attr_accessor(:csv_collection, :url_collection, :image_collection, :app_name, :page_name_collection, :env, :score_collection)
10
+
11
+ def initialize(file_location = "./data/input")
12
+ rt = Retrieval.new(file_location)
13
+ @csv_collection = rt.retrieve_csv_collection
14
+ @url_collection = rt.retrieve_url_collection
15
+ @image_collection = rt.retrieve_image_collection
16
+ @app_name = rt.retrieve_app_name
17
+ @page_name_collection = rt.retrieve_page_names
18
+ @env = rt.retrieve_env
19
+ end
20
+
21
+ def main_setup(app, file_prefix = "./data/")
22
+ app_initial_setup(app)
23
+ pages = page_initial_setup
24
+ app_additional_setup(app, pages)
25
+ pages.each_with_index do |page, index|
26
+ rows = row_initial_setup(index)
27
+ row_additional_setup(rows, file_prefix + "scores.yaml")
28
+ page_additional_setup(app, page, rows, file_prefix + "suppressed_rules.yaml")
29
+ end
30
+ end
31
+
32
+ def row_initial_setup(index)
33
+ output = []
34
+ @csv_collection[index].each do |csv|
35
+ @row = Row.new
36
+ @row.set_value("error_warning", csv.error_warning)
37
+ @row.set_value("guideline", csv.guideline)
38
+ @row.set_value("error_description", csv.error_description)
39
+ @row.set_value("html_path", csv.html_path)
40
+ @row.set_value("content", csv.content)
41
+ output.push(@row)
42
+ end
43
+ output
44
+ end
45
+
46
+ def app_initial_setup(app)
47
+ app.set_value("application_name", app_name)
48
+ app.set_value("env", env)
49
+ end
50
+
51
+ def page_initial_setup
52
+ counter = 0
53
+ output = page_name_collection.map do |page_name|
54
+ page = Page.new
55
+ page.set_value("page", page_name)
56
+ page.set_value("url", url_collection[counter])
57
+ page.set_value("image", image_collection[counter])
58
+ counter += 1
59
+ page
60
+ end
61
+ output
62
+ end
63
+
64
+ def row_additional_setup(rows, ddl = "./data/scores.yaml")
65
+ @score_collection = ScoreCollection.new(ddl)
66
+ rows.each do |row|
67
+ row.calculate_score_value(@score_collection)
68
+ end
69
+ end
70
+
71
+ def app_additional_setup(app, pages)
72
+ app.set_value("pages", pages)
73
+ end
74
+
75
+ def page_additional_setup(app, page, rows, psr_location = "./data/suppressed_rules.yaml")
76
+ page.set_value("rows", rows)
77
+ score = page.calc_page_score
78
+ page.set_value("score", score)
79
+ page.set_value("app", app)
80
+ page.access_spr(psr_location)
81
+ end
82
+
83
+ end
@@ -0,0 +1,33 @@
1
+ $:.unshift File.dirname(__FILE__) + '/../../modules'
2
+ require 'yaml_interaction'
3
+ class ScoreCollection
4
+ include YAMLInteraction
5
+ attr_accessor(:guidelines)
6
+
7
+ def initialize(ddl="./data/scores.yaml")
8
+ send("guidelines=", get_guidelines(ddl))
9
+ end
10
+
11
+ def get_guidelines(ddl)
12
+ output = []
13
+ collections = read_yaml(ddl, "GUIDELINES")
14
+ collections.each do |key, value|
15
+ score = read_yaml(ddl, "SCORES")[key]
16
+ value.each do |guideline|
17
+ temp = ScoreElement.new(key, score, guideline)
18
+ output.push(temp)
19
+ end
20
+ end
21
+ output
22
+ end
23
+ end
24
+
25
+ class ScoreElement
26
+ attr_accessor(:guideline, :score, :categorization)
27
+
28
+ def initialize(categorization, score, guideline)
29
+ send("guideline=", guideline)
30
+ send("categorization=", categorization)
31
+ send("score=", score)
32
+ end
33
+ end
@@ -0,0 +1,8 @@
1
+ class SuppressedPageRules
2
+ attr_accessor(:guideline, :content)
3
+
4
+ def initialize(guideline, content)
5
+ send("guideline=", guideline)
6
+ send("content=", content)
7
+ end
8
+ end
@@ -0,0 +1,39 @@
1
+ APPLICATION:
2
+
3
+ #includes everything
4
+ HTML: "<html>sample</html>"
5
+
6
+ # Style sheet goes here
7
+
8
+ #goes in HTML
9
+ APPLICATION_TITLE_SECTION: "<h1 id=\"page_header\">sample</h1>"
10
+
11
+ #goes in HTML, holds all other content. including page content
12
+ HTML_BODY: "<body id=\"whole body\">sample</body>"
13
+
14
+ #goes in HTML body
15
+ APPLICATION_OVERVIEW_SECTION: "<div id=\"application_overview_section\">sample</div>"
16
+
17
+ #goes in application overview section
18
+ CHART_IMAGE: '<img src=".\files\chart.png" alt="tracking chart" id="chart_image">'
19
+
20
+ #goes in application overview section
21
+ APPLICATION_OVERVIEW_TABLE_SECTION: "<div id=\"application_overview_table_section\">sample</div>"
22
+
23
+ #goes in application overview table section
24
+ APPLICATION_DATA_SECTION: "<table id=\"application_overview_information_table\">
25
+ <tbody id=\"application_overview_information_table_body\">
26
+ <tr>
27
+ <th>Application Score</th>
28
+ <th>Number of Errors</th>
29
+ <th>Number of Pages</th>
30
+ </tr>
31
+
32
+ sample
33
+
34
+ </tbody>
35
+ </table>"
36
+
37
+
38
+
39
+ APPLICATION_DATA_ROW: "<td>sample</td>"
@@ -0,0 +1,37 @@
1
+ ##OPTIONAL VALUES
2
+ PAGE_IMAGE: '<img src=".\files\sample.png" class="content_image">'
3
+ PAGE_URL: "<h1 class=\"url-for-page\">URL: sample</h1>"
4
+ PAGE_SUPPRESSED_RULES_AREA: "<table class=\"page_suppressed_rules_table\">
5
+ <tbody class=\"page_suppressed_rules_table_body\">
6
+ <tr>
7
+ <th><strong>Suppressed Page Rules</strong></th>
8
+ </tr>
9
+ sample
10
+ </tbody> </table>"
11
+ PAGE_SUPPRESSED_RULES_TABLE_VALUES: "<tr><td>sample</td></tr>"
12
+
13
+
14
+ ##LIST SECTION
15
+ COLLAPSIBLE_LIST_SECTION: "<div class=\"collapsible-list\">sample</div>"
16
+ COLLAPSIBLE_BUTTON: "<button class=\"collapsible\">
17
+ <Strong>Sample Page Name</Strong>
18
+ <strong>Total Number of Errors = </strong> sample total number of errors
19
+ <strong>Page Score = </strong>sample page score
20
+ </button>"
21
+
22
+
23
+ CONTENT: "<div class=\"content\"> sample </div>"
24
+ PAGE_INFO: "<div class=\"content_image_and_suppressed_rules_area\"> sample </div>"
25
+
26
+ WARNING_LIST_AREA: "<div class=\"warning_list_area_div\">
27
+ <table class=\"warning_list_item_table\">
28
+ <tbody class=\"warning_list_table_body\">
29
+ <tr>
30
+ header_sample
31
+ </tr>
32
+ rows_sample
33
+ </tbody>
34
+ </table>
35
+ </div>"
36
+
37
+ WARNING_LIST_HEADERS: "<th>sample</th>"
@@ -0,0 +1,4 @@
1
+ TR: "<tr>sample</tr>"
2
+ TD: "<td>sample</td>"
3
+
4
+
@@ -0,0 +1,167 @@
1
+ SCRIPT: "<script>
2
+ var coll = document.getElementsByClassName(\"collapsible\");
3
+ var i;
4
+
5
+ for (i = 0; i < coll.length; i++) {
6
+ coll[i].addEventListener(\"click\", function () {
7
+ this.classList.toggle(\"active\");
8
+ var content = this.nextElementSibling;
9
+ if (content.style.display === \"block\") {
10
+ content.style.display = \"none\";
11
+ } else {
12
+ content.style.display = \"block\";
13
+ }
14
+ });
15
+ }
16
+
17
+ </script>"
18
+
19
+ STYLE: "<style>
20
+ /*page header section*/
21
+ #page_header {
22
+ display: block;
23
+ text-align: center;
24
+ font-family: Apex New Bold, sans-serif;
25
+ font-weight: bold
26
+ }
27
+
28
+ /*application overview section*/
29
+ #application_overview_section {
30
+ display: block;
31
+ padding-top: 10px
32
+ }
33
+
34
+ #chart_image {
35
+ margin-left: auto;
36
+ margin-right: auto;
37
+ display: inline-block;
38
+ width: 47%;
39
+ padding-bottom: 10px
40
+ }
41
+
42
+ #application_overview_table_section {
43
+ display: inline;
44
+ margin-bottom: 10px;
45
+ font-family: Apex New Bold, sans-serif;
46
+ }
47
+
48
+ #suppressed_application_errors_table {
49
+ border-color: #5ba63c;
50
+ display: inline-block;
51
+ padding-top: 10px;
52
+ width: 49%;
53
+ vertical-align: top;
54
+ }
55
+
56
+ #suppressed_application_errors_table_body {
57
+ display: block;
58
+ overflow-y: scroll;
59
+ height: 70px
60
+ }
61
+
62
+ #application_overview_information_table {
63
+ display: inline-block;
64
+ border-color: #5ba63c;
65
+ padding-top: 10px;
66
+ width: 49%;
67
+ vertical-align: top;
68
+ }
69
+
70
+ #application_overview_information_table_body {
71
+ display: inline-block;
72
+ height: 70px;
73
+ }
74
+ /*Collapsible Section*/
75
+ .collapsible {
76
+ background-color: #ffffff;
77
+ color: black;
78
+ cursor: pointer;
79
+ padding: 18px;
80
+ width: 100%;
81
+ text-align: left;
82
+ outline: none;
83
+ font-size: 15px;
84
+ font-family: Apex New Bold, sans-serif;
85
+ }
86
+
87
+ .active, .collapsible:hover {
88
+ background-color: #ADEFD1FF;
89
+ }
90
+
91
+ .collapsible-list {
92
+ position: static;
93
+ font-family: Apex New Bold, sans-serif;
94
+ border-color: #F0EAD6;
95
+ border-style: solid;
96
+ border-width: thick;
97
+ border-collapse: collapse;
98
+ }
99
+ /*Collapsible Content Section*/
100
+ .content {
101
+ padding: 18px;
102
+ display: none;
103
+ overflow: hidden;
104
+ background-color: #F0EAD6;
105
+ }
106
+ /*Collapsible Content image and suppressed rules Section*/
107
+ .content_image_and_suppressed_rules_area {
108
+ width: 100%;
109
+ display: block;
110
+ }
111
+
112
+ .url-for-page {
113
+ font-size: 18px;
114
+ font-family: Apex New Bold, sans-serif;
115
+ }
116
+
117
+ .content_image {
118
+ display: inline-block;
119
+ margin-left: auto;
120
+ margin-right: auto;
121
+ width: 100%;
122
+ }
123
+
124
+ .page_suppressed_rules_table {
125
+ display: inline-block;
126
+ vertical-align: top;
127
+ border-collapse: collapse;
128
+ padding-left: 1%;
129
+ width: 50%
130
+
131
+ }
132
+
133
+ .page_suppressed_rules_table_body {
134
+ display: block;
135
+ width: 100%
136
+ }
137
+
138
+ .warning_list_area_div {
139
+ display: block;
140
+ width: 100%;
141
+ overflow-x: scroll;
142
+ }
143
+
144
+ .warning_list_table_body {
145
+ display: block;
146
+ border-collapse: collapse;
147
+
148
+ }
149
+
150
+ .warning_list_item_table {
151
+ table-layout:fixed;
152
+ }
153
+
154
+
155
+ .warning_list_table_body > tr {
156
+ border-style: solid;
157
+ }
158
+
159
+
160
+ .warning_list_table_body > tr > td {
161
+ border-style: solid;}
162
+
163
+
164
+ </style>"
165
+
166
+
167
+