<commit_before>###!
Copyright (c) 2002-2014 "Neo Technology,"
Network Engine for Objects in Lund AB [http://neotechnology.com]

This file is part of Neo4j.

Neo4j is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
###

angular.module('neo4jApp')
.config([
  'FrameProvider'
  'Settings'
  (FrameProvider, Settings) ->

    cmdchar = Settings.cmdchar

    # convert a string into a topical keyword
    topicalize = (input) ->
      if input?
        input.toLowerCase().trim().replace /\s+/g, '-'
      else
        null

    argv = (input) ->
      rv = input?.toLowerCase().split(' ')
      rv or []

    error = (msg, exception = "Error", data) ->
      message: msg
      exception: exception
      data: data

    FrameProvider.interpreters.push
      type: 'clear'
      matches: "#{cmdchar}clear"
      exec: ['Frame', (Frame) ->
        (input) ->
          Frame.reset()
          true
      ]

    FrameProvider.interpreters.push
      type: 'style'
      matches: "#{cmdchar}style"
      exec: [
        '$rootScope', 'exportService', 'GraphStyle',
        ($rootScope, exportService, GraphStyle) ->
          (input, q) ->
            switch argv(input)[1]
              when 'reset'
                GraphStyle.resetToDefault()
              when 'export'
                exportService.download('graphstyle.grass', 'text/plain;charset=utf-8', GraphStyle.toString())
              else
                $rootScope.togglePopup('styling')
            true
      ]

    # Show command history
    FrameProvider.interpreters.push
      type: 'history'
      matches: "#{cmdchar}history"
      templateUrl: 'views/frame-history.html'
      exec: [
        'Editor',
        (Editor) ->
          (input, q) ->
            q.resolve(angular.copy(Editor.history))
            q.promise
      ]

    # FrameProvider.interpreters.push
    #   type: 'keys'
    #   templateUrl: 'views/frame-keys.html'
    #   matches: "#{cmdchar}keys"
    #   exec: ['$rootScope', ($rootScope) ->
    #     (input) -> true
    #   ]

    # Generic shell commands
    FrameProvider.interpreters.push
      type: 'shell'
      templateUrl: 'views/frame-rest.html'
      matches: "#{cmdchar}schema"
      exec: ['Server', (Server) ->
        (input, q) ->
          Server.console(input.substr(1))
          .then(
            (r) ->
              response = r.data[0]
              if response.match('Unknown')
                q.reject(error("Unknown action", null, response))
              else
                q.resolve(response)
          )
          q.promise
      ]


    # play handler
    FrameProvider.interpreters.push
      type: 'play'
      templateUrl: 'views/frame-help.html'
      matches: "#{cmdchar}play"
      exec: ['$http', ($http) ->
        step_number = 1
        (input, q) ->
          topic = topicalize(input[('play'.length+1)..]) or 'welcome'
          url = "content/guides/#{topic}.html"
          $http.get(url)
          .success(->q.resolve(page: url))
          .error(->q.reject(error("No such topic to play")))
          q.promise
      ]

    # Help/man handler
    FrameProvider.interpreters.push
      type: 'help'
      templateUrl: 'views/frame-help.html'
      matches: ["#{cmdchar}help", "#{cmdchar}man"]
      exec: ['$http', ($http) ->
        (input, q) ->
          topic = topicalize(input[('help'.length+1)..]) or 'help'
          url = "content/help/#{topic}.html"
          $http.get(url)
          .success(->q.resolve(page: url))
          .error(->q.reject(error("No such help topic")))
          q.promise
      ]

    FrameProvider.interpreters.push
      type: 'account'
      templateUrl: 'views/frame-login.html'
      matches: ["#{cmdchar}login"]
      exec: ['NTN', (NTN) ->
        (input, q) ->
          NTN.open()
          .then(q.resolve, ->
            q.reject(message: "Unable to log in")
          )
          q.promise
      ]

    FrameProvider.interpreters.push
      type: 'account'
      templateUrl: 'views/frame-logout.html'
      matches: ["#{cmdchar}logout"]
      exec: ['NTN', (NTN) ->
        (input, q) ->
          p = NTN.logout()
          p.then(q.resolve, -> q.reject(message: "Unable to log out"))
          q.promise
      ]

    FrameProvider.interpreters.push
      type: 'config'
      templateUrl: 'views/frame-config.html'
      matches: ["#{cmdchar}config"]
      exec: ['Settings', (Settings) ->
        (input, q) ->
          matches = /^[^\w]*config\s+([^:]+):?([\S\s]+)?$/.exec(input)

          if (matches?)
            [key, value] = [matches[1], matches[2]]
            if (value?)
              try
                value = eval(value)
              catch

              Settings[key] = value<commit_msg>Remove unused commands from browser.<commit_after>###!
Copyright (c) 2002-2014 "Neo Technology,"
Network Engine for Objects in Lund AB [http://neotechnology.com]

This file is part of Neo4j.

Neo4j is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
###

angular.module('neo4jApp')
.config([
  'FrameProvider'
  'Settings'
  (FrameProvider, Settings) ->

    cmdchar = Settings.cmdchar

    # convert a string into a topical keyword
    topicalize = (input) ->
      if input?
        input.toLowerCase().trim().replace /\s+/g, '-'
      else
        null

    argv = (input) ->
      rv = input?.toLowerCase().split(' ')
      rv or []

    error = (msg, exception = "Error", data) ->
      message: msg
      exception: exception
      data: data

    FrameProvider.interpreters.push
      type: 'clear'
      matches: "#{cmdchar}clear"
      exec: ['Frame', (Frame) ->
        (input) ->
          Frame.reset()
          true
      ]

    FrameProvider.interpreters.push
      type: 'style'
      matches: "#{cmdchar}style"
      exec: [
        '$rootScope', 'exportService', 'GraphStyle',
        ($rootScope, exportService, GraphStyle) ->
          (input, q) ->
            switch argv(input)[1]
              when 'reset'
                GraphStyle.resetToDefault()
              when 'export'
                exportService.download('graphstyle.grass', 'text/plain;charset=utf-8', GraphStyle.toString())
              else
                $rootScope.togglePopup('styling')
            true
      ]

    # Show command history
    FrameProvider.interpreters.push
      type: 'history'
      matches: "#{cmdchar}history"
      templateUrl: 'views/frame-history.html'
      exec: [
        'Editor',
        (Editor) ->
          (input, q) ->
            q.resolve(angular.copy(Editor.history))
            q.promise
      ]

    # FrameProvider.interpreters.push
    #   type: 'keys'
    #   templateUrl: 'views/frame-keys.html'
    #   matches: "#{cmdchar}keys"
    #   exec: ['$rootScope', ($rootScope) ->
    #     (input) -> true
    #   ]

    # Generic shell commands
    FrameProvider.interpreters.push
      type: 'shell'
      templateUrl: 'views/frame-rest.html'
      matches: "#{cmdchar}schema"
      exec: ['Server', (Server) ->
        (input, q) ->
          Server.console(input.substr(1))
          .then(
            (r) ->
              response = r.data[0]
              if response.match('Unknown')
                q.reject(error("Unknown action", null, response))
              else
                q.resolve(response)
          )
          q.promise
      ]


    # play handler
    FrameProvider.interpreters.push
      type: 'play'
      templateUrl: 'views/frame-help.html'
      matches: "#{cmdchar}play"
      exec: ['$http', ($http) ->
        step_number = 1
        (input, q) ->
          topic = topicalize(input[('play'.length+1)..]) or 'welcome'
          url = "content/guides/#{topic}.html"
          $http.get(url)
          .success(->q.resolve(page: url))
          .error(->q.reject(error("No such topic to play")))
          q.promise
      ]

    # Help/man handler
    FrameProvider.interpreters.push
      type: 'help'
      templateUrl: 'views/frame-help.html'
      matches: ["#{cmdchar}help", "#{cmdchar}man"]
      exec: ['$http', ($http) ->
        (input, q) ->
          topic = topicalize(input[('help'.length+1)..]) or 'help'
          url = "content/help/#{topic}.html"
          $http.get(url)
          .success(->q.resolve(page: url))
          .error(->q.reject(error("No such help topic")))
          q.promise
      ]

    FrameProvider.interpreters.push
      type: 'config'
      templateUrl: 'views/frame-config.html'
      matches: ["#{cmdchar}config"]
      exec: ['Settings', (Settings) ->
        (input, q) ->
          matches = /^[^\w]*config\s+([^:]+):?([\S\s]+)?$/.exec(input)

          if (matches?)
            [key, value] = [matches[1], matches[2]]
            if (value?)
              try
                value = eval(value)
              catch

              Settings[key] = value
{'fraction_non_alphanumeric': 0.1387987012987013, 'fraction_numerical': 0.004261363636363636, 'mean_word_length': 1.9698704429044893, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6077855', 'n_tokens_mistral': 2976, 'n_tokens_neox': 2897, 'n_words': 728}