0.4.0 • Published 8 years ago

grunt-e7-banner-validator v0.4.0

Weekly downloads
2
License
-
Repository
-
Last release
8 years ago

grunt-e7-banner-validator

Validates HTML5 banner for Bannershop

Getting Started

This plugin requires Grunt ~0.4.5

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-e7-banner-validator --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-e7-banner-validator');

The "e7_banner_validator" task

Overview

In your project's Gruntfile, add a section named e7_banner_validator to the data object passed into grunt.initConfig().

grunt.initConfig({
  e7_banner_validator: {
    options: {
      // Task-specific options go here.
    },
    your_target: {
      // Target-specific file lists and/or options go here.
    },
  },
});

Options

options.logfile

Type: String Default value: 'tmp/log_file'

Path to file where error messages are logged.

options.ad_bundles

Type: Object Default value: {}

Object with motif objects. Each motif has an array that contains the local paths to html pages that should be validated.

Default with object:

grunt.initConfig({
  e7_banner_validator: {
    options: {
      ad_bundles: {
        'motif-x': [
          'make/dist/xx-xx/motive-x/728x90-name/index.html',
          'make/dist/xx-xx/motive-x/300x250-name/index.html',
          'make/dist/xx-xx/motive-x/160x600-name/index.html',
          'make/dist/xx-xx/motive-x/800x250-name/index.html',
          'make/dist/xx-xx/motive-x/300x600-name/index.html'
        ],
        'motif-y': [...]
      }
    }
  }
});

With function that returns an object:

grunt.initConfig({
  e7_banner_validator: {
    options: {
      ad_bundles: function(){
        return {
          'ok': [
            'test/fixtures/ok/bannershop_1.html',
            'test/fixtures/ok/bannershop_2.html',
            'test/fixtures/ok/bannershop_3.html'
          ]
        };
      }
    }
  }
});

options.validate

Type: Object Default values:

grunt.initConfig({
  e7_banner_validator: {
    options: {
      validate: {
        charset: 'utf-8',
        viewport: 'width=device-width,initial-scale=1',
        banner_node: '#banner',
        push_marker: 'data-bs-type="push"',
        push_category: {
          marker: 'data-bs-category',
          values: ['location', 'footnote', 'story']
        },
        push_editable: {
          marker: 'data-bs-editable',
          values: ['true', 'false']
        },
        relative_pathes: true
      }
    }
  }
});

Object with possible validations and their expected values.

options.validate.charset

Type: String Default value: 'utf-8'

Used to check if correct value<meta charset> is set. To skip validation use charset: false.

grunt.initConfig({
  e7_banner_validator: {
    options: {
      validate: {
        charset: 'utf-8'
      }
    },
  },
});

options.validate.viewport

Type: String Default value: 'width=device-width,initial-scale=1'

Used to check if correct value<meta name="viewport"> is set. To skip validation use viewport: false.

grunt.initConfig({
  e7_banner_validator: {
    options: {
      validate: {
        viewport: 'width=device-width,initial-scale=1'
      }
    },
  },
});

options.validate.banner_node

Type: String Default value: '#banner'

Selector for root element for all pushes.

grunt.initConfig({
  e7_banner_validator: {
    options: {
      validate: {
        banner_node: '#banner'
      }
    },
  },
});

options.validate.push_marker

Type: String Default value: 'data-bs-type="push"'

Attribute that marks an element as push.

grunt.initConfig({
  e7_banner_validator: {
    options: {
      validate: {
        push_marker: 'data-bs-type="push"'
      }
    },
  },
});

options.validate.relative_pathes

Type: Boolean Default value: true

Set to true if all paths have to relative. (Checks <link href="">, <script src="">, <img src=""> and <img srcset="">.) To skip the validation set to false .

grunt.initConfig({
  e7_banner_validator: {
    options: {
      validate: {
        relative_pathes: true
      }
    },
  },
});

options.validate.find_duplicate_ids

Type: Boolean Default value: true

Set to true to check for duplicate IDs. To skip validation use find_duplicate_ids: false.

grunt.initConfig({
  e7_banner_validator: {
    options: {
      validate: {
        find_duplicate_ids: true
      }
    },
  },
});

options.validate.push_category

Type: Object Default value:

{
  marker: 'data-bs-category', // Type: String
  values: ['location', 'footnote', 'story'] // Type: Array
}

marker defines the attribute that contains a push category. Valid category types are listed in values (an array with strings).

grunt.initConfig({
  e7_banner_validator: {
    options: {
      validate: {
        push_category: {
          marker: 'data-bs-category',
          values: ['location', 'footnote', 'story']
        }
      }
    },
  },
});

options.validate.push_editable

Type: Object Default value:

{
  marker: 'data-bs-editable', // Type: String
  values: ['true', 'false'] // Type: Array
}

marker is the attribute that defines if a push is editable or not . Acceptable values are listed in values (an array with strings because attribute values are strings).

grunt.initConfig({
  e7_banner_validator: {
    options: {
      validate: {
        push_editable: {
          marker: 'data-bs-editable',
          values: ['true', 'false']
        }
      }
    },
  },
});

Release History

0.2.0 (2016-04-11) Added validation for duplicate IDs 0.3.0 (2016-04-12) Option 'ad_bundles' accepts function that returns an object with motifs.

0.4.0

8 years ago

0.3.0

8 years ago

0.2.0

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago