Skip to content
Snippets Groups Projects
Gruntfile.coffee 3.42 KiB
Newer Older
Sylvain Arreckx's avatar
Sylvain Arreckx committed
# Generated on 2013-11-27 using generator-reveal 0.3.2
module.exports = (grunt) ->

    grunt.loadNpmTasks 'grunt-gh-pages'

    grunt.initConfig

        "gh-pages":
            "gh-pages":
                options:
                    base: "dist"
                src: [ '**' ]

        watch:

            livereload:
                options:
                    livereload: true
                files: [
                    'index.html'
                    'slides/*.md'
                    'slides/*.html'
                    'theme/js/*.js'
Sylvain Arreckx's avatar
Sylvain Arreckx committed
                ]

            index:
                files: [
                    'theme/templates/_index.html'
                    'theme/templates/_section.html'
Sylvain Arreckx's avatar
Sylvain Arreckx committed
                    'slides/list.json'
                ]
                tasks: ['buildIndex']

            coffeelint:
                files: ['Gruntfile.coffee']
                tasks: ['coffeelint']

            jshint:
                files: ['theme/js/*.js']
Sylvain Arreckx's avatar
Sylvain Arreckx committed
                tasks: ['jshint']

        connect:

            livereload:
                options:
                    port: 9000
                    # Change hostname to '0.0.0.0' to access
                    # the server from outside.
                    hostname: 'localhost'
                    base: '.'
                    open: true
                    livereload: true

        coffeelint:

            options:
                indentation:
                    value: 4

            all: ['Gruntfile.coffee']

        jshint:

            options:
                jshintrc: '.jshintrc'

            all: ['theme/js/*.js']
Sylvain Arreckx's avatar
Sylvain Arreckx committed

        copy:

            dist:
                files: [{
                    expand: true
                    src: [
                        'slides/**'
                        'bower_components/**'
                        'theme/css/**'
                        'theme/js/**'
                        'slides/img/**'
Sylvain Arreckx's avatar
Sylvain Arreckx committed
                    ]
Laurent Heirendt's avatar
Laurent Heirendt committed
                    dest: 'public/'
Sylvain Arreckx's avatar
Sylvain Arreckx committed
                },{
                    expand: true
                    src: ['index.html']
Laurent Heirendt's avatar
Laurent Heirendt committed
                    dest: 'public/'
Sylvain Arreckx's avatar
Sylvain Arreckx committed
                    filter: 'isFile'
                }]


    # Load all grunt tasks.
    require('load-grunt-tasks')(grunt)

    grunt.registerTask 'buildIndex',
        'Build theme/templates/_index.html and slides/list.json.',
Sylvain Arreckx's avatar
Sylvain Arreckx committed
        ->
            indexTemplate = grunt.file.read 'theme/templates/_index.html'
            sectionTemplate = grunt.file.read 'theme/templates/_section.html'
Sylvain Arreckx's avatar
Sylvain Arreckx committed
            slides = grunt.file.readJSON 'slides/list.json'

            html = grunt.template.process indexTemplate, data:
                slides:
                    slides
                section: (slide) ->
                    grunt.template.process sectionTemplate, data:
                        slide:
                            slide
            grunt.file.write 'index.html', html

    grunt.registerTask 'test',
        '*Lint* javascript and coffee files.', [
            'coffeelint'
            'jshint'
        ]

    grunt.registerTask 'server',
        'Run presentation locally and start watch process (living document).', [
            'buildIndex'
            'connect:livereload'
            'watch'
        ]

    grunt.registerTask 'dist',
Laurent Heirendt's avatar
Laurent Heirendt committed
        'Save presentation files to *public* directory.', [
Sylvain Arreckx's avatar
Sylvain Arreckx committed
            'test'
            'buildIndex'
            'copy'
        ]

    # Define default task.
    grunt.registerTask 'default', [
        'test'
        'server'
    ]