 
 module.exports =
   jekyllNewPostView: null
+  disposables: []
 
   config:
     postsDir:

    line = buffer.lines[activeEditor.getCursorBufferPosition().row]

    try
      include = @scan(line, /{% include (.*?)%}/g)[0][0].split(" ")[0]
      atom.workspace.open(path.join(process.jekyllAtom.config.includes_dir, include))
    catch error
      if error.message == "Cannot read property 'include_dir' of undefined"
        # Just in case we havent read the config yet.
        setTimeout(->
          atom.packages.getActivePackage('jekyll').mainModule.openInclude()
        ,500 )

      else
        @showError(error.message)

  openConfig: ->
    atom.workspace.open("_config.yml")

      process.jekyllAtom.config.includes_dir = './_includes' unless process.jekyllAtom.config.includes_dir
      process.jekyllAtom.config.data_dir = './_data' unless process.jekyllAtom.config.data_dir

      JekyllEmitter.emit 'config-loaded', process.jekyllAtom.config

  ifConfigLoaded: (cb) ->
    if process.jekyllAtom.config
      cb(process.jekyllAtom.config)
    else
      @disposables.push JekyllEmitter.on 'config-loaded', (conf) => cb(conf)

  openLayout: ->
    activeEditor = atom.workspace.getActiveTextEditor()
    if activeEditor
      contents = activeEditor.getText()
    else
      atom.notifications.addWarning('Could not see Active Editor, do you have an editor open?')
    try
      @ifConfigLoaded (conf) ->
        layout = module.exports.scan(contents, /layout: (.*?)[\r\n|\n\r|\r|\n]/g)[0][0]
        fs.readdir path.join(atom.project.getPaths()[0], conf.layouts_dir), (err, files) ->
          for file in files
            parts = file.split(".")
            if parts[0] == layout
              fileName = file

          atom.workspace.open(path.join(process.jekyllAtom.config.layouts_dir, fileName))
    catch error
      @showError(error.message)

  openInclude: ->
    activeEditor = atom.workspace.getActiveTextEditor()
