{"size": 804, "ext": "js", "max_stars_repo_path": "source/js/services/blogManager.js", "max_stars_repo_name": "msafi/helium", "max_stars_repo_stars_event_min_datetime": "2016-02-05T16:38:40.000Z", "max_stars_repo_stars_event_max_datetime": "2016-02-05T16:38:40.000Z", "max_issues_repo_path": "source/js/services/blogManager.js", "max_issues_repo_name": "msafi/helium", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "source/js/services/blogManager.js", "max_forks_repo_name": "msafi/helium", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.935483871, "max_line_length": 81, "alphanum_fraction": 0.5211442786}
'use strict';

angular.module('helium')

.service('blogManager',
  function(backend, systemConfig, $q, utils, $state, config) {
    var blogManager = {}

    return angular.extend(blogManager, {
      updateConfig: function(newConfig) {
        config = angular.extend(config, newConfig)

        return backend.getFile('index.html').then(
          function success(indexHtml) {
            indexHtml = indexHtml.replace(
              /(heliumConfigurations = {(.*\n)+};;;)/gm,
              'heliumConfigurations = ' + JSON.stringify(config, null, 2) + ';;;'
            )

            return backend.uploadFile({
              key: 'index.html',
              body: indexHtml,
              acl: 'public-read',
              type: 'text/html'
            })
          }
        )
      }
    })
  }
)