Remove hash params from url

Load settings are now stored on the browser window.
This commit is contained in:
Corey Johnson & Kevin Sawicki
2013-06-11 11:17:16 -07:00
parent a57c5c7c93
commit bcc16fbefe
8 changed files with 20 additions and 37 deletions

View File

@@ -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,

View File

@@ -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()

View File

@@ -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

View File

@@ -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: ->

View File

@@ -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'

View File

@@ -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

View File

@@ -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', =>

View File

@@ -4,24 +4,14 @@
<title></title>
<script>
window.location.params = {}
var params = window.location.hash.substring(1).split('&')
params.forEach(function(param) {
var pair = param.split("=");
window.location.params[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
});
window.resourcePath = window.location.params.resourcePath;
var bootstrapScript = window.location.params.bootstrapScript;
window.onload = function() {
var currentWindow = require('remote').getCurrentWindow();
try {
require('coffee-script');
require('coffee-cache').setCacheDir('/tmp/atom-coffee-cache');
if (bootstrapScript) require(bootstrapScript);
require(currentWindow.loadSettings.bootstrapScript);
}
catch (error) {
var currentWindow = require('remote').getCurrentWindow();
currentWindow.openDevTools();
console.error(error.stack || error);
}