<commit_before>'use strict';

var rewriteRulesSnippet = require('grunt-connect-rewrite/lib/utils').rewriteRequest;

module.exports = function(grunt) {
  require("time-grunt")(grunt);
  require("load-grunt-tasks")(grunt);
  require("./extract_from_archive")(grunt);
  require("./prepare_page_data")(grunt);
  require("./extract_from_tumblr")(grunt);

  grunt.initConfig({
    extract_from_archive: {
      options: {
        connection: {
          url:      'http://archive.collectivearchivepgh.org/',
          username: 'api',
          password: '<PASSWORD>'
        },
        dest: './src/data/records'
      },
    },

    extract_from_tumblr: {
      options: {
        url:   'collectivearchivepgh.tumblr.com',
        connection: {
          oauth: { consumer_key:    '<KEY>',
                  consumer_secret: '<KEY>',
          }
        },
        dest: './src/data/tumblr_posts.json'
      },
    },

    prepare_page_data: {
      records: {
        files: {
          './src/data/records.json': [ './src/data/records/**/*.json' ],
        }
      }
    },

    assemble: {
      options: {
        layout: './src/templates/layout.hbs',
        partials: ['./src/templates/**/*.hbs' ],
        helpers: './src/helpers.js',
      },
      static_pages: {
        options: {
          flatten: true,
          data:  './src/data/records.json'
        },
        files: {
          'dist/': [
            './src/templates/index.hbs',
            './src/templates/about.hbs',
            './src/templates/contact.hbs'
          ],
        }
      },
      testimonials: {
        options: {
          flatten: true,
          data:  './src/data/tumblr_posts.json'
        },
        files: {
          'dist/': [
            './src/templates/testimonials.hbs'
          ],
        }
      },
      records: {
        options: {
          pageSource: './src/data/records.json'
        },
        files: {
          'dist/': [],
        }
      },
    },

    copy: {
      dist: {
        expand: true,
        cwd:  'src/scripts/vendor',
        src:  '*',
        dest: 'dist/scripts/vendor/',
      }
    },

    concat: {
      dist: {
        src: [
          './src/scripts/**/*.js',
          '!./src/scripts/vendor/**/*.js'
        ],
        dest: './dist/scripts/main.js'
      }
    },

    sass: {
      options: {
        includePaths: [ './src/bower_components' ]
      },
      dist: {
        files: {
          './dist/styles/main.css': './src/styles/main.scss'
        }
      }
    },

    connect: {
      options: {
        port: 8000,
        livereload: 35730,
        hostname: "0.0.0.0",
        base: ["./dist"],
        middleware: function(connect, options) {
          return [rewriteRulesSnippet, connect["static"](require("path").resolve("./dist"))];
        }
      },
      rules: {
        '^/$': '/index.html',
        '(.*).css': '$1.css',
        '(.*).jpg': '$1.jpg',
        '(.*)(?!\.html)': '$1.html'
      },
      dev: {}
    },

    watch: {
      assemble: {
        files: ["src/**/*.hbs"],
        tasks: ["assemble"]
      },

      concat: {
        files: ["src/**/*.js"],
        tasks: ["concat:dist"]
      },

      sass: {
        files: ["src/**/*.{scss,sass}"],
        tasks: ["sass:dist"]
      },

      dev: {
        options: {
          livereload: "<%= connect.options.livereload %>"
        },
        files: [<commit_msg>Proxy .js files too.<commit_after>'use strict';

var rewriteRulesSnippet = require('grunt-connect-rewrite/lib/utils').rewriteRequest;

module.exports = function(grunt) {
  require("time-grunt")(grunt);
  require("load-grunt-tasks")(grunt);
  require("./extract_from_archive")(grunt);
  require("./prepare_page_data")(grunt);
  require("./extract_from_tumblr")(grunt);

  grunt.initConfig({
    extract_from_archive: {
      options: {
        connection: {
          url:      'http://archive.collectivearchivepgh.org/',
          username: 'api',
          password: '<PASSWORD>'
        },
        dest: './src/data/records'
      },
    },

    extract_from_tumblr: {
      options: {
        url:   'collectivearchivepgh.tumblr.com',
        connection: {
          oauth: { consumer_key:    '<KEY>',
                  consumer_secret: '<KEY>',
          }
        },
        dest: './src/data/tumblr_posts.json'
      },
    },

    prepare_page_data: {
      records: {
        files: {
          './src/data/records.json': [ './src/data/records/**/*.json' ],
        }
      }
    },

    assemble: {
      options: {
        layout: './src/templates/layout.hbs',
        partials: ['./src/templates/**/*.hbs' ],
        helpers: './src/helpers.js',
      },
      static_pages: {
        options: {
          flatten: true,
          data:  './src/data/records.json'
        },
        files: {
          'dist/': [
            './src/templates/index.hbs',
            './src/templates/about.hbs',
            './src/templates/contact.hbs'
          ],
        }
      },
      testimonials: {
        options: {
          flatten: true,
          data:  './src/data/tumblr_posts.json'
        },
        files: {
          'dist/': [
            './src/templates/testimonials.hbs'
          ],
        }
      },
      records: {
        options: {
          pageSource: './src/data/records.json'
        },
        files: {
          'dist/': [],
        }
      },
    },

    copy: {
      dist: {
        expand: true,
        cwd:  'src/scripts/vendor',
        src:  '*',
        dest: 'dist/scripts/vendor/',
      }
    },

    concat: {
      dist: {
        src: [
          './src/scripts/**/*.js',
          '!./src/scripts/vendor/**/*.js'
        ],
        dest: './dist/scripts/main.js'
      }
    },

    sass: {
      options: {
        includePaths: [ './src/bower_components' ]
      },
      dist: {
        files: {
          './dist/styles/main.css': './src/styles/main.scss'
        }
      }
    },

    connect: {
      options: {
        port: 8000,
        livereload: 35730,
        hostname: "0.0.0.0",
        base: ["./dist"],
        middleware: function(connect, options) {
          return [rewriteRulesSnippet, connect["static"](require("path").resolve("./dist"))];
        }
      },
      rules: {
        '^/$': '/index.html',
        '(.*).css': '$1.css',
        '(.*).jpg': '$1.jpg',
        '(.*).js': '$1.js',
        '(.*)(?!\.html)': '$1.html'
      },
      dev: {}
    },

    watch: {
      assemble: {
        files: ["src/**/*.hbs"],
        tasks: ["assemble"]
      },

      concat: {
        files: ["src/**/*.js"],
        tasks: ["concat:dist"]
      },

      sass: {
        files: ["src/**/*.{scss,sass}"],
        tasks: ["sass:dist"]
      },

      dev: {
        options: {
          livereload: "<%= connect.options.livereload %>"
        },
        files: [
{'fraction_non_alphanumeric': 0.19080392443988872, 'fraction_numerical': 0.004832332698784595, 'mean_word_length': 1.3922942206654991, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4279411', 'n_tokens_mistral': 2286, 'n_tokens_neox': 2223, 'n_words': 295}