From 2a665697d5b8f5a57b503439527173c933ccaa2b Mon Sep 17 00:00:00 2001 From: Nikos Vasileiadis Date: Tue, 24 Jan 2017 00:28:55 +0000 Subject: [PATCH 01/22] Add W3C Validation Dependency to package.json This helps to maintain an updated bundle of dependencies among different branches, devs and machines. --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 8962ae6128..86c5c571ba 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "grunt-real-favicon": "^0.1.3", "grunt-sass": "^1.1.0", "grunt-scss-lint": "0.3.8", + "grunt-w3c-html-validation": "^0.1.8", "jquery": "1.x", "jsdom": "^8.4.0", "matchdep": "^1.0.1", From ebbad57c2732d50f65e1bfe167c09c3d3c2da12a Mon Sep 17 00:00:00 2001 From: Nikos Vasileiadis Date: Tue, 24 Jan 2017 00:31:23 +0000 Subject: [PATCH 02/22] Add Error Keeping Directory & Error Output Template This folder will contain any errors, in a formated and timestamped way, after the grunt is run. --- .../w3c_validation_error_Template.html | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 w3cErrorFolder/w3c_validation_error_Template.html diff --git a/w3cErrorFolder/w3c_validation_error_Template.html b/w3cErrorFolder/w3c_validation_error_Template.html new file mode 100644 index 0000000000..9da8df172d --- /dev/null +++ b/w3cErrorFolder/w3c_validation_error_Template.html @@ -0,0 +1,44 @@ + + + + W3C Error Report for {{filename}} + + + + + + + + + + + + + + + + + + + {{#each error}} + + + + + + + + + {{/each}} + +
W3C Validation Report +
{{filename}} | Error Count : {{error.length}} +
Error Number + Error Type + Line Number + Error Message + Error Source Code Reference + Error Explanation +
{{@index}} {{type}} {{lastLine}} {{message}} {{errSrcFirstPart}}{{{errSrcToHighlight}}}{{errSrcSecondPart}} {{{explanation}}}
+ + \ No newline at end of file From 2836afdf40a843d5ddf64cf21b085982323f2a32 Mon Sep 17 00:00:00 2001 From: Nikos Vasileiadis Date: Tue, 24 Jan 2017 00:32:41 +0000 Subject: [PATCH 03/22] Update gitignore for Validation related files Those two files added are containing a raw output of the validation run and are overwritten every time. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index f63b6ab7c9..97adda1eb5 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,5 @@ pulsar.zip /fonts/_config.fonts.scss /.csscomb.json +/validation-status.json +/validation-report.json From c559ea6fbcc3114bf1393f2ff7beb9a1e38d81d9 Mon Sep 17 00:00:00 2001 From: Nikos Vasileiadis Date: Tue, 24 Jan 2017 00:33:12 +0000 Subject: [PATCH 04/22] Update Gruntfile to run with W3C Validation --- Gruntfile.js | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index a2e4ba6ab9..ea19eb1c61 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -157,7 +157,7 @@ module.exports = function(grunt) { js: { files: ['js/**/*.js', 'tests/js/**/*', 'package.json'], tasks: ['browserify'] - } + }, }, jshint: { @@ -474,6 +474,25 @@ module.exports = function(grunt) { reloadOnRestart: true, watchTask: true } + }, + + validation: { + options: { + reset: grunt.option('reset') || false, + stoponerror: false, + maxTry: 3, + relaxerror: ['Bad value X-UA-Compatible for attribute http-equiv on element meta.'], //ignores these errors + generateReport: true, + errorHTMLRootDir: "w3cErrorFolder", + useTimeStamp: true, + errorTemplate: "w3cErrorFolder/w3c_validation_error_Template.html" + }, + files: { + src: ['dist/views/*.html', + 'emails/dist/*.html', + 'emails/examples/*.html', + 'emails/src/*.html'] + } } }); @@ -494,6 +513,8 @@ module.exports = function(grunt) { ] }); + grunt.loadNpmTasks('grunt-w3c-html-validation'); + grunt.registerTask('default', [ 'copy', 'scsslint', @@ -501,9 +522,10 @@ module.exports = function(grunt) { 'autoprefixer', 'bless', 'browserify', + 'email-build', + 'validation', 'browserSync', - 'watch', - 'email-build' + 'watch' ]); grunt.registerTask('post-merge', [ From d1b69d46ac1471e546bfb8749ddc91b1bc3d8bab Mon Sep 17 00:00:00 2001 From: Nikos Vasileiadis Date: Thu, 26 Jan 2017 00:24:32 +0000 Subject: [PATCH 05/22] Relocate File to /tests/validation --- .../w3c_validation_error_Template.html | 44 ------------------- 1 file changed, 44 deletions(-) delete mode 100644 w3cErrorFolder/w3c_validation_error_Template.html diff --git a/w3cErrorFolder/w3c_validation_error_Template.html b/w3cErrorFolder/w3c_validation_error_Template.html deleted file mode 100644 index 9da8df172d..0000000000 --- a/w3cErrorFolder/w3c_validation_error_Template.html +++ /dev/null @@ -1,44 +0,0 @@ - - - - W3C Error Report for {{filename}} - - - - - - - - - - - - - - - - - - - {{#each error}} - - - - - - - - - {{/each}} - -
W3C Validation Report -
{{filename}} | Error Count : {{error.length}} -
Error Number - Error Type - Line Number - Error Message - Error Source Code Reference - Error Explanation -
{{@index}} {{type}} {{lastLine}} {{message}} {{errSrcFirstPart}}{{{errSrcToHighlight}}}{{errSrcSecondPart}} {{{explanation}}}
- - \ No newline at end of file From 40f354a5f3ceb49182a04b1d78d79c82db11681c Mon Sep 17 00:00:00 2001 From: Nikos Vasileiadis Date: Thu, 26 Jan 2017 00:25:24 +0000 Subject: [PATCH 06/22] Update gitignore to bypass tests/validation This is for W3C Validation grunt task. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 97adda1eb5..056cdf4b19 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ pulsar.zip /.csscomb.json /validation-status.json /validation-report.json +/tests/validation/* \ No newline at end of file From ec65bb1541f92817a2f8f82823d05417649d9ca3 Mon Sep 17 00:00:00 2001 From: Nikos Vasileiadis Date: Thu, 26 Jan 2017 00:26:45 +0000 Subject: [PATCH 07/22] Add directories to gitattributes The file produced and the directory used by W3C Validation. --- .gitattributes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitattributes b/.gitattributes index 53031f0533..90b9fea709 100644 --- a/.gitattributes +++ b/.gitattributes @@ -30,6 +30,9 @@ /phpunit.xml.dist export-ignore /pulsar.sublime-project export-ignore /Vagrantfile export-ignore +/tests/validation export-ignore +/validation-status.json export-ignore +/validation-report.json export-ignore ## ## /libs/ From cf1e835637e526583dd075a719131e1d6a376ce4 Mon Sep 17 00:00:00 2001 From: Nikos Vasileiadis Date: Thu, 26 Jan 2017 00:29:45 +0000 Subject: [PATCH 08/22] Update Gruntfile for W3C Validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes: 1. Move error reports directory and template to /tests/validation 2. Correct indentation and spacing 3. Remove obsolete loadNpmTasks 4. Make ‘validate’ a separate task --- Gruntfile.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index ea19eb1c61..5e97150bc5 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -481,17 +481,17 @@ module.exports = function(grunt) { reset: grunt.option('reset') || false, stoponerror: false, maxTry: 3, - relaxerror: ['Bad value X-UA-Compatible for attribute http-equiv on element meta.'], //ignores these errors + relaxerror: ['Bad value X-UA-Compatible for attribute http-equiv on element meta.'], // ignores these errors generateReport: true, - errorHTMLRootDir: "w3cErrorFolder", + errorHTMLRootDir: "tests/validation", useTimeStamp: true, - errorTemplate: "w3cErrorFolder/w3c_validation_error_Template.html" + errorTemplate: "tests/validation/w3c_validation_error_Template.html" }, files: { src: ['dist/views/*.html', - 'emails/dist/*.html', - 'emails/examples/*.html', - 'emails/src/*.html'] + 'emails/dist/*.html', + 'emails/examples/*.html', + 'emails/src/*.html'] } } @@ -513,8 +513,6 @@ module.exports = function(grunt) { ] }); - grunt.loadNpmTasks('grunt-w3c-html-validation'); - grunt.registerTask('default', [ 'copy', 'scsslint', @@ -522,10 +520,9 @@ module.exports = function(grunt) { 'autoprefixer', 'bless', 'browserify', - 'email-build', - 'validation', 'browserSync', - 'watch' + 'watch', + 'email-build' ]); grunt.registerTask('post-merge', [ @@ -588,6 +585,10 @@ module.exports = function(grunt) { 'exec:updateNpm' ]); + grunt.registerTask('validate', [ + 'validation' + ]); + // load all grunt tasks require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); From b426b6eb69ad1c439d2fdedc8833ddfdbd5fe640 Mon Sep 17 00:00:00 2001 From: Nikos Vasileiadis Date: Thu, 26 Jan 2017 00:37:22 +0000 Subject: [PATCH 09/22] Update ignore to include only newly generated folders Changed the gitingore and gitattibutes to include only the folders and files generated after the task run. The previous settings were ignoring the error template. --- .gitattributes | 2 +- .gitignore | 2 +- .../w3c_validation_error_Template.html | 44 +++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 tests/validation/w3c_validation_error_Template.html diff --git a/.gitattributes b/.gitattributes index 90b9fea709..10c6144cc7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -30,7 +30,7 @@ /phpunit.xml.dist export-ignore /pulsar.sublime-project export-ignore /Vagrantfile export-ignore -/tests/validation export-ignore +/tests/validation/w3cError* export-ignore /validation-status.json export-ignore /validation-report.json export-ignore diff --git a/.gitignore b/.gitignore index 056cdf4b19..780451cbc9 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,4 @@ pulsar.zip /.csscomb.json /validation-status.json /validation-report.json -/tests/validation/* \ No newline at end of file +/tests/validation/w3cErrors* \ No newline at end of file diff --git a/tests/validation/w3c_validation_error_Template.html b/tests/validation/w3c_validation_error_Template.html new file mode 100644 index 0000000000..9da8df172d --- /dev/null +++ b/tests/validation/w3c_validation_error_Template.html @@ -0,0 +1,44 @@ + + + + W3C Error Report for {{filename}} + + + + + + + + + + + + + + + + + + + {{#each error}} + + + + + + + + + {{/each}} + +
W3C Validation Report +
{{filename}} | Error Count : {{error.length}} +
Error Number + Error Type + Line Number + Error Message + Error Source Code Reference + Error Explanation +
{{@index}} {{type}} {{lastLine}} {{message}} {{errSrcFirstPart}}{{{errSrcToHighlight}}}{{errSrcSecondPart}} {{{explanation}}}
+ + \ No newline at end of file From cf084163641a1ae5331f2c6d026d7a0430f2d281 Mon Sep 17 00:00:00 2001 From: Nikos Vasileiadis Date: Thu, 26 Jan 2017 14:52:59 +0000 Subject: [PATCH 10/22] Remove Email Related Folders from Validate Task --- Gruntfile.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 5e97150bc5..31e5b46c54 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -488,10 +488,7 @@ module.exports = function(grunt) { errorTemplate: "tests/validation/w3c_validation_error_Template.html" }, files: { - src: ['dist/views/*.html', - 'emails/dist/*.html', - 'emails/examples/*.html', - 'emails/src/*.html'] + src: ['dist/views/*.html'] } } From 9fc1d78030fe2256761c2f3e311eadc037620189 Mon Sep 17 00:00:00 2001 From: Nikos Vasileiadis Date: Wed, 29 Mar 2017 14:28:56 +0100 Subject: [PATCH 11/22] Add Casper JS File --- js/casper.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 js/casper.js diff --git a/js/casper.js b/js/casper.js new file mode 100644 index 0000000000..5beab4b1a1 --- /dev/null +++ b/js/casper.js @@ -0,0 +1,9 @@ +var fs = require('fs'); + +casper.start('http://google.com', function() { + fs.write('dist/htmloutput/page.html', this.getPageContent(), 'w'); +}); + +casper.run(function() { + this.exit(); +}) From 6ab3c56bec5640c83d541c4c585bf88c5a197138 Mon Sep 17 00:00:00 2001 From: Nikos Vasileiadis Date: Wed, 29 Mar 2017 14:53:13 +0100 Subject: [PATCH 12/22] Add CasperJS Dependency to the Project --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 2c57a647f9..eec5ac6276 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "grunt-browser-sync": "^2.2.0", "grunt-browserify": "^5.0.0", "grunt-bump": "^0.7.2", + "grunt-casperjs": "^2.2.1", "grunt-contrib-clean": "^1.0.0", "grunt-contrib-compress": "^1.2.0", "grunt-contrib-copy": "^1.0.0", From 713c2a399a77b71e5cbe7e81a03a8cf0f7f32d2f Mon Sep 17 00:00:00 2001 From: Nikos Vasileiadis Date: Fri, 31 Mar 2017 12:55:36 +0100 Subject: [PATCH 13/22] Add New Folder Structure to gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e389dc8029..d1ab691f80 100644 --- a/.gitignore +++ b/.gitignore @@ -29,4 +29,5 @@ pulsar.zip /.csscomb.json /validation-status.json /validation-report.json -/tests/validation/w3cErrors* \ No newline at end of file +/tests/validation/error_reports/* +/tests/validation/html_output/* From 9e8b90979b7f57c1c1b94851b6715c57084ada80 Mon Sep 17 00:00:00 2001 From: Nikos Vasileiadis Date: Fri, 31 Mar 2017 12:55:56 +0100 Subject: [PATCH 14/22] Add CasperJS to Gruntfile --- Gruntfile.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 396d9b4869..5f3993a449 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -474,25 +474,35 @@ module.exports = function(grunt) { reloadOnRestart: true, watchTask: true } - }, + }, + + casperjs: { + options: { + async: { + parallel: false + }, + silent: false + }, + files: ['../pulsar/js/casper.js'] + }, validation: { options: { reset: grunt.option('reset') || false, stoponerror: false, maxTry: 3, - relaxerror: ['Bad value X-UA-Compatible for attribute http-equiv on element meta.'], // ignores these errors + relaxerror: ['Bad value X-UA-Compatible for attribute http-equiv on element meta.'], // ignores these errors generateReport: true, - errorHTMLRootDir: "tests/validation", + errorHTMLRootDir: "tests/validation/error_reports", useTimeStamp: true, errorTemplate: "tests/validation/w3c_validation_error_Template.html" }, files: { - src: ['dist/views/*.html'] + src: ['../pulsar/tests/validation/html_output/*.html'] } }, - 'gh-pages': { + 'gh-pages': { options: { base: 'docs/_site', repo: 'https://github.com/jadu/pulsar.git' @@ -591,6 +601,7 @@ module.exports = function(grunt) { ]); grunt.registerTask('validate', [ + 'casperjs', 'validation' ]); From d094ad7ac6fb26d9c4adb93bd23ef303c35edcf0 Mon Sep 17 00:00:00 2001 From: Nikos Vasileiadis Date: Fri, 31 Mar 2017 12:56:29 +0100 Subject: [PATCH 15/22] Add CasperJS Browsing Steps --- js/casper.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/js/casper.js b/js/casper.js index 5beab4b1a1..d708d76409 100644 --- a/js/casper.js +++ b/js/casper.js @@ -1,7 +1,27 @@ var fs = require('fs'); +var links; -casper.start('http://google.com', function() { - fs.write('dist/htmloutput/page.html', this.getPageContent(), 'w'); +function getLinks() { +// Scrape the links from primary nav of the website + var links = document.querySelectorAll('.nav-link.t-nav-link'); + return Array.prototype.map.call(links, function (e) { + return e.getAttribute('href') + }); +} + +casper.start('http://192.168.13.37/index.php', function() { + fs.write('tests/validation/html_output/index.html', this.getPageContent(), 'w'); +}); + +casper.then(function () { + links = this.evaluate(getLinks); + for(var i in links) { + console.log(i,' Outer:', links[i]); + casper.start(links[i], function() { + console.log(i, ' Inner:', links[i]); + fs.write('tests/validation/html_output/page-' + i + '.html', this.getPageContent(), 'w'); + }); + } }); casper.run(function() { From 56583e9cb09dfbcea6da93af4d10268b51b232e9 Mon Sep 17 00:00:00 2001 From: Nikos Vasileiadis Date: Tue, 11 Apr 2017 14:00:29 +0100 Subject: [PATCH 16/22] Fix For Loop to Iterate Every Link in Primary Nav --- js/casper.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/js/casper.js b/js/casper.js index d708d76409..29cfbb6480 100644 --- a/js/casper.js +++ b/js/casper.js @@ -2,7 +2,6 @@ var fs = require('fs'); var links; function getLinks() { -// Scrape the links from primary nav of the website var links = document.querySelectorAll('.nav-link.t-nav-link'); return Array.prototype.map.call(links, function (e) { return e.getAttribute('href') @@ -10,17 +9,24 @@ function getLinks() { } casper.start('http://192.168.13.37/index.php', function() { - fs.write('tests/validation/html_output/index.html', this.getPageContent(), 'w'); + fs.write('tests/validation/html_output/homepage.html', this.getPageContent(), 'w'); }); casper.then(function () { - links = this.evaluate(getLinks); - for(var i in links) { - console.log(i,' Outer:', links[i]); - casper.start(links[i], function() { - console.log(i, ' Inner:', links[i]); - fs.write('tests/validation/html_output/page-' + i + '.html', this.getPageContent(), 'w'); + var links = this.evaluate(getLinks); + var current = 1; + var end = links.length; + + for (;current < end;) { + //console.log(current,' Outer:', current); + (function(cntr) { + casper.thenOpen(links[cntr], function() { + console.log(cntr, ' Inner:', links[cntr]); + fs.write('tests/validation/html_output/_' + cntr + '.html', this.getPageContent(), 'w'); }); + })(current); + + current++; } }); From 06587924eddb1fb08ece7be3c9f2c46a6aa16aba Mon Sep 17 00:00:00 2001 From: Nikos Vasileiadis Date: Wed, 12 Apr 2017 09:32:06 +0100 Subject: [PATCH 17/22] Resolve Duplicate HTML Outputs Issue Now it should output properly different report for each page. --- js/casper.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/js/casper.js b/js/casper.js index 29cfbb6480..4aa48168bb 100644 --- a/js/casper.js +++ b/js/casper.js @@ -14,19 +14,16 @@ casper.start('http://192.168.13.37/index.php', function() { casper.then(function () { var links = this.evaluate(getLinks); - var current = 1; + var current = 0; var end = links.length; for (;current < end;) { - //console.log(current,' Outer:', current); - (function(cntr) { - casper.thenOpen(links[cntr], function() { - console.log(cntr, ' Inner:', links[cntr]); - fs.write('tests/validation/html_output/_' + cntr + '.html', this.getPageContent(), 'w'); - }); - })(current); - - current++; + (function(cntr) { + casper.thenOpen('http://192.168.13.37/' + links[cntr] + '', function() { + fs.write('tests/validation/html_output/_' + cntr + '.html', this.getPageContent(), 'w'); + }); + })(current); + current++; } }); From 07e3581cc91b8b2984cf149bfbeaf32f2c885912 Mon Sep 17 00:00:00 2001 From: Nikos Vasileiadis Date: Fri, 12 May 2017 17:05:52 +0100 Subject: [PATCH 18/22] Add Filter of URL Names for Use in Output Files --- js/casper.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/js/casper.js b/js/casper.js index 4aa48168bb..9bd5af9570 100644 --- a/js/casper.js +++ b/js/casper.js @@ -4,23 +4,37 @@ var links; function getLinks() { var links = document.querySelectorAll('.nav-link.t-nav-link'); return Array.prototype.map.call(links, function (e) { - return e.getAttribute('href') + return e.getAttribute('href'); }); } casper.start('http://192.168.13.37/index.php', function() { - fs.write('tests/validation/html_output/homepage.html', this.getPageContent(), 'w'); + fs.write('tests/validation/html_output/index.html', this.getPageContent(), 'w'); }); casper.then(function () { var links = this.evaluate(getLinks); var current = 0; var end = links.length; + // Get the word before .html.twig, the word before the last '/' and the word in urls like '/lexicon' + var regex = /((\w*)(\/|.html.twig)$)|(\/\w*$)/gm; + var match = []; + + // Get Page Name from URL + for (var i = 0; i < links.length; i++) { + if (links[i].match(regex) != null ) { // Remove null items that didn't pass the regex + var link = links[i].match(regex); + var filtered = link[0]; // Get just the name from the results array + var splited = filtered.split('.'); // Split dots to remove .html.twig part + var replaced = splited[0].replace('/', ''); // Remove '/' + match.push(replaced); // Keep just the names in a separata array + }; + }; for (;current < end;) { (function(cntr) { casper.thenOpen('http://192.168.13.37/' + links[cntr] + '', function() { - fs.write('tests/validation/html_output/_' + cntr + '.html', this.getPageContent(), 'w'); + fs.write('tests/validation/html_output/_' + match[cntr] + '.html', this.getPageContent(), 'w'); }); })(current); current++; From 1719aa09a3a7e70297eaaf8fee11584689f3b129 Mon Sep 17 00:00:00 2001 From: Nikos Vasileiadis Date: Fri, 12 May 2017 22:31:42 +0100 Subject: [PATCH 19/22] Fix Output File Names to Match the URLs --- js/casper.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/js/casper.js b/js/casper.js index 9bd5af9570..8a718c5541 100644 --- a/js/casper.js +++ b/js/casper.js @@ -19,11 +19,19 @@ casper.then(function () { // Get the word before .html.twig, the word before the last '/' and the word in urls like '/lexicon' var regex = /((\w*)(\/|.html.twig)$)|(\/\w*$)/gm; var match = []; + var newlinks = []; - // Get Page Name from URL + // Remove links within the same page for (var i = 0; i < links.length; i++) { - if (links[i].match(regex) != null ) { // Remove null items that didn't pass the regex - var link = links[i].match(regex); + if (links[i].indexOf('#') == -1) { + newlinks.push(links[i]); + }; + }; + + // Get Page Name from URL + for (var i = 0; i < newlinks.length; i++) { + if (newlinks[i].match(regex) != null ) { // Remove null items that didn't pass the regex + var link = newlinks[i].match(regex); var filtered = link[0]; // Get just the name from the results array var splited = filtered.split('.'); // Split dots to remove .html.twig part var replaced = splited[0].replace('/', ''); // Remove '/' @@ -33,7 +41,7 @@ casper.then(function () { for (;current < end;) { (function(cntr) { - casper.thenOpen('http://192.168.13.37/' + links[cntr] + '', function() { + casper.thenOpen('http://192.168.13.37' + newlinks[cntr] + '', function() { fs.write('tests/validation/html_output/_' + match[cntr] + '.html', this.getPageContent(), 'w'); }); })(current); From 9b1f7681f19ab00630ad5f83afa57e91384dff8b Mon Sep 17 00:00:00 2001 From: Nikos Vasileiadis Date: Fri, 12 May 2017 22:47:55 +0100 Subject: [PATCH 20/22] Improve Report File Name Title Readability --- js/casper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/casper.js b/js/casper.js index 8a718c5541..3c06ee61d7 100644 --- a/js/casper.js +++ b/js/casper.js @@ -42,7 +42,7 @@ casper.then(function () { for (;current < end;) { (function(cntr) { casper.thenOpen('http://192.168.13.37' + newlinks[cntr] + '', function() { - fs.write('tests/validation/html_output/_' + match[cntr] + '.html', this.getPageContent(), 'w'); + fs.write('tests/validation/html_output/_' + match[cntr] + '_.html', this.getPageContent(), 'w'); }); })(current); current++; From 81e8e44afe886ef285178fb3d2c9658ec0baf5a2 Mon Sep 17 00:00:00 2001 From: Nikos Vasileiadis Date: Tue, 16 May 2017 09:09:48 +0100 Subject: [PATCH 21/22] Refactoring Based on Peer Review and Hound --- js/casper.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/js/casper.js b/js/casper.js index 3c06ee61d7..1ae583a395 100644 --- a/js/casper.js +++ b/js/casper.js @@ -9,6 +9,7 @@ function getLinks() { } casper.start('http://192.168.13.37/index.php', function() { + "use strict"; fs.write('tests/validation/html_output/index.html', this.getPageContent(), 'w'); }); @@ -23,14 +24,14 @@ casper.then(function () { // Remove links within the same page for (var i = 0; i < links.length; i++) { - if (links[i].indexOf('#') == -1) { + if (links[i].indexOf('#') === -1) { newlinks.push(links[i]); - }; - }; + } + } // Get Page Name from URL - for (var i = 0; i < newlinks.length; i++) { - if (newlinks[i].match(regex) != null ) { // Remove null items that didn't pass the regex + for (i = 0; i < newlinks.length; i++) { + if (newlinks[i].match(regex)) { // Remove null items that didn't pass the regex var link = newlinks[i].match(regex); var filtered = link[0]; // Get just the name from the results array var splited = filtered.split('.'); // Split dots to remove .html.twig part @@ -50,5 +51,6 @@ casper.then(function () { }); casper.run(function() { + "use strict"; this.exit(); -}) +}); From eb9e2124a79deea8f67d4174e0961447e0367bd8 Mon Sep 17 00:00:00 2001 From: Nikos Vasileiadis Date: Tue, 16 May 2017 09:22:13 +0100 Subject: [PATCH 22/22] Improve Index Output Naming --- js/casper.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/casper.js b/js/casper.js index 1ae583a395..3951a00155 100644 --- a/js/casper.js +++ b/js/casper.js @@ -10,7 +10,7 @@ function getLinks() { casper.start('http://192.168.13.37/index.php', function() { "use strict"; - fs.write('tests/validation/html_output/index.html', this.getPageContent(), 'w'); + fs.write('tests/validation/html_output/_index.html', this.getPageContent(), 'w'); }); casper.then(function () {