From bcc16fbefe6d30c20d802f717c58acb22c18988e Mon Sep 17 00:00:00 2001 From: Corey Johnson & Kevin Sawicki Date: Tue, 11 Jun 2013 11:17:16 -0700 Subject: [PATCH] Remove hash params from url Load settings are now stored on the browser window. --- benchmark/benchmark-helper.coffee | 2 +- spec/jasmine-helper.coffee | 2 +- spec/spec-bootstrap.coffee | 2 +- src/app/atom.coffee | 17 +++++------------ src/app/window.coffee | 2 ++ src/atom-application.coffee | 6 +++--- src/atom-window.coffee | 12 +++++------- static/index.html | 14 ++------------ 8 files changed, 20 insertions(+), 37 deletions(-) diff --git a/benchmark/benchmark-helper.coffee b/benchmark/benchmark-helper.coffee index f46be1fd9..fd1a1ed41 100644 --- a/benchmark/benchmark-helper.coffee +++ b/benchmark/benchmark-helper.coffee @@ -56,7 +56,7 @@ window.benchmark = (args...) -> report = "#{fullname}: #{total} / #{count} = #{avg}ms" console.log(report) - if atom.exitWhenDone + if atom.getLoadSettings().exitWhenDone url = "https://github.com/_stats" data = [type: 'timing', metric: "atom.#{fullname}", ms: avg] $.ajax url, diff --git a/spec/jasmine-helper.coffee b/spec/jasmine-helper.coffee index 86a8bb625..7a1337d9d 100644 --- a/spec/jasmine-helper.coffee +++ b/spec/jasmine-helper.coffee @@ -18,7 +18,7 @@ module.exports.runSpecSuite = (specSuite, logErrors=true) -> $ = require 'jquery' TimeReporter = require 'time-reporter' - reporter = if atom.exitWhenDone + reporter = if atom.getLoadSettings().exitWhenDone new jasmine.ConsoleReporter(document, logErrors) else new AtomReporter() diff --git a/spec/spec-bootstrap.coffee b/spec/spec-bootstrap.coffee index 410262423..8370c19d7 100644 --- a/spec/spec-bootstrap.coffee +++ b/spec/spec-bootstrap.coffee @@ -7,4 +7,4 @@ try runSpecSuite "spec-suite" catch e console.error(e.stack ? e) - atom.exit(1) if window.location.params.exitWhenDone + atom.exit(1) if atom.getLoadSettings().exitWhenDone diff --git a/src/app/atom.coffee b/src/app/atom.coffee index cfb0bbef9..69c648638 100644 --- a/src/app/atom.coffee +++ b/src/app/atom.coffee @@ -7,25 +7,19 @@ remote = require 'remote' crypto = require 'crypto' window.atom = - exitWhenDone: window.location.params.exitWhenDone - devMode: window.location.params.devMode loadedThemes: [] loadedPackages: {} activePackages: {} packageStates: {} + getLoadSettings: -> + remote.getCurrentWindow().loadSettings + getPathToOpen: -> - window.location.params.pathToOpen + @getLoadSettings().pathToOpen setPathToOpen: (pathToOpen) -> - window.location.params.pathToOpen = pathToOpen - @saveWindowParameters() - - saveWindowParameters: -> - hashSegments = [] - for name, value of window.location.params - hashSegments.push("#{encodeURIComponent(name)}=#{encodeURIComponent(value)}") - window.location.hash = '#' + hashSegments.join('&') + @getLoadSettings().pathToOpen = pathToOpen getPackageState: (name) -> @packageStates[name] @@ -211,7 +205,6 @@ window.atom = remote.getCurrentWindow().toggleDevTools() reload: -> - @saveWindowParameters() remote.getCurrentWindow().restart() focus: -> diff --git a/src/app/window.coffee b/src/app/window.coffee index 4a0ce0e7f..82de573f6 100644 --- a/src/app/window.coffee +++ b/src/app/window.coffee @@ -18,6 +18,8 @@ windowEventHandler = null # This method is called in any window needing a general environment, including specs window.setUpEnvironment = -> + window.resourcePath = remote.getCurrentWindow().loadSettings.resourcePath + Config = require 'config' Syntax = require 'syntax' Pasteboard = require 'pasteboard' diff --git a/src/atom-application.coffee b/src/atom-application.coffee index db8a63b9e..f35d5139e 100644 --- a/src/atom-application.coffee +++ b/src/atom-application.coffee @@ -222,11 +222,11 @@ class AtomApplication windowForPath: (pathToOpen) -> return null unless pathToOpen - for atomWindow in @windows when atomWindow.pathToOpen? - if pathToOpen is atomWindow.pathToOpen + for atomWindow in @windows when atomWindow.getPathToOpen()? + if pathToOpen is atomWindow.getPathToOpen() return atomWindow - if pathToOpen.indexOf(path.join(atomWindow.pathToOpen, path.sep)) is 0 + if pathToOpen.indexOf(path.join(atomWindow.getPathToOpen(), path.sep)) is 0 return atomWindow null diff --git a/src/atom-window.coffee b/src/atom-window.coffee index ad2457744..ff24cb4b0 100644 --- a/src/atom-window.coffee +++ b/src/atom-window.coffee @@ -6,19 +6,17 @@ module.exports = class AtomWindow browserWindow: null - constructor: ({bootstrapScript, resourcePath, @pathToOpen, exitWhenDone, @isSpec}) -> + constructor: ({bootstrapScript, resourcePath, pathToOpen, exitWhenDone, @isSpec}) -> global.atomApplication.addWindow(this) @browserWindow = new BrowserWindow show: false, title: 'Atom' @handleEvents() - url = "file://#{resourcePath}/static/index.html#" - url += "bootstrapScript=#{encodeURIComponent(bootstrapScript)}" - url += "&resourcePath=#{encodeURIComponent(resourcePath)}" - url += "&pathToOpen=#{encodeURIComponent(@pathToOpen)}" if @pathToOpen - url += '&exitWhenDone=1' if exitWhenDone + @browserWindow.loadSettings = {pathToOpen, bootstrapScript, resourcePath, exitWhenDone} + @browserWindow.loadUrl "file://#{resourcePath}/static/index.html" - @browserWindow.loadUrl url + getPathToOpen: -> + @browserWindow.loadSettings.pathToOpen handleEvents: -> @browserWindow.on 'destroyed', => diff --git a/static/index.html b/static/index.html index a8e6ee671..7e65f1b02 100644 --- a/static/index.html +++ b/static/index.html @@ -4,24 +4,14 @@