Skip to content

Commit

Permalink
Merge branch 'release'
Browse files Browse the repository at this point in the history
  • Loading branch information
ingorichter committed Dec 18, 2014
2 parents a3fb9e7 + ea908ca commit 9ee1f08
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 37 deletions.
4 changes: 2 additions & 2 deletions samples/de/Erste Schritte/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ <h2>Dies ist Ihre Anleitung!</h2>
<em>Brackets ist eine andere Art Editor.</em>
Brackets hat ein paar einzigartige Features wie Schnelles Bearbeiten, Live-Vorschau und zahlreiche
weitere, die Sie in anderen Editoren vergeblich suchen werden. Zudem ist Brackets in JavaScript, HTML
und CSS geschrieben. Das heißt, dass die meisten Brackets-Nutzer dazu in der Lage sind, den Editor
selbst zu verändern und erweitern. Tatsächlich nutzen wir Brackets täglich, um Brackets zu verbessern.
und CSS geschrieben. Das heißt, dass die meisten Brackets-Nutzer dazu in der Lage sind, den Editor selbst
zu verändern und zu erweitern. Tatsächlich nutzen wir Brackets täglich, um Brackets zu verbessern.
Lesen Sie weiter, um mehr über die Nutzung der Hauptfeatures zu erfahren.

</p>
Expand Down
4 changes: 4 additions & 0 deletions src/LiveDevelopment/Documents/CSSPreprocessorDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ define(function CSSPreprocessorDocumentModule(require, exports, module) {
"use strict";

var _ = require("thirdparty/lodash"),
EventDispatcher = require("utils/EventDispatcher"),
CSSUtils = require("language/CSSUtils"),
EditorManager = require("editor/EditorManager"),
HighlightAgent = require("LiveDevelopment/Agents/HighlightAgent"),
Expand All @@ -62,6 +63,9 @@ define(function CSSPreprocessorDocumentModule(require, exports, module) {
this.onActiveEditorChange(null, EditorManager.getActiveEditor(), null);
};

// CSSPreprocessorDocument doesn't dispatch events, but the "live document" interface requires an on() API
EventDispatcher.makeEventDispatcher(CSSPreprocessorDocument.prototype);

/** Close the document */
CSSPreprocessorDocument.prototype.close = function close() {
this.doc.off(".CSSPreprocessorDocument");
Expand Down
10 changes: 7 additions & 3 deletions src/LiveDevelopment/Documents/JSDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@
define(function JSDocumentModule(require, exports, module) {
"use strict";

var Inspector = require("LiveDevelopment/Inspector/Inspector");
var ScriptAgent = require("LiveDevelopment/Agents/ScriptAgent");
var HighlightAgent = require("LiveDevelopment/Agents/HighlightAgent");
var EventDispatcher = require("utils/EventDispatcher"),
Inspector = require("LiveDevelopment/Inspector/Inspector"),
ScriptAgent = require("LiveDevelopment/Agents/ScriptAgent"),
HighlightAgent = require("LiveDevelopment/Agents/HighlightAgent");

/**
* @constructor
Expand All @@ -68,6 +69,9 @@ define(function JSDocumentModule(require, exports, module) {
this.editor.on("cursorActivity", this.onCursorActivity);
this.onCursorActivity();
};

// JSDocument doesn't dispatch events, but the "live document" interface requires having an on() API
EventDispatcher.makeEventDispatcher(JSDocument.prototype);

/** Close the document */
JSDocument.prototype.close = function close() {
Expand Down
4 changes: 2 additions & 2 deletions src/LiveDevelopment/LiveDevMultiBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ define(function (require, exports, module) {
}

var filteredFiltered = allFiles.filter(function (item) {
var parent = FileUtils.getDirectoryPath(item.fullPath);
var parent = FileUtils.getParentPath(item.fullPath);

return (containingFolder.indexOf(parent) === 0);
});
Expand Down Expand Up @@ -417,7 +417,7 @@ define(function (require, exports, module) {
// We found no good match
if (i === -1) {
// traverse the directory tree up one level
containingFolder = FileUtils.getDirectoryPath(containingFolder);
containingFolder = FileUtils.getParentPath(containingFolder);
// Are we still inside the project?
if (containingFolder.indexOf(projectRoot) === -1) {
stillInProjectTree = false;
Expand Down
18 changes: 4 additions & 14 deletions src/LiveDevelopment/LiveDevelopment.js
Original file line number Diff line number Diff line change
Expand Up @@ -679,16 +679,6 @@ define(function LiveDevelopment(require, exports, module) {
refPath,
i;

// TODO: FileUtils.getParentFolder()
function getParentFolder(path) {
return path.substring(0, path.lastIndexOf('/', path.length - 2) + 1);
}

function getFilenameWithoutExtension(filename) {
var index = filename.lastIndexOf(".");
return index === -1 ? filename : filename.slice(0, index);
}

// Is the currently opened document already a file we can use for Live Development?
if (doc) {
refPath = doc.file.fullPath;
Expand All @@ -715,14 +705,14 @@ define(function LiveDevelopment(require, exports, module) {
}

var filteredFiltered = allFiles.filter(function (item) {
var parent = getParentFolder(item.fullPath);
var parent = FileUtils.getParentPath(item.fullPath);

return (containingFolder.indexOf(parent) === 0);
});

var filterIndexFile = function (fileInfo) {
if (fileInfo.fullPath.indexOf(containingFolder) === 0) {
if (getFilenameWithoutExtension(fileInfo.name) === "index") {
if (FileUtils.getFilenameWithoutExtension(fileInfo.name) === "index") {
if (hasOwnServerForLiveDevelopment) {
if ((FileUtils.isServerHtmlFileExt(fileInfo.name)) ||
(FileUtils.isStaticHtmlFileExt(fileInfo.name))) {
Expand All @@ -743,7 +733,7 @@ define(function LiveDevelopment(require, exports, module) {
// We found no good match
if (i === -1) {
// traverse the directory tree up one level
containingFolder = getParentFolder(containingFolder);
containingFolder = FileUtils.getParentPath(containingFolder);
// Are we still inside the project?
if (containingFolder.indexOf(projectRoot) === -1) {
stillInProjectTree = false;
Expand Down Expand Up @@ -1052,7 +1042,7 @@ define(function LiveDevelopment(require, exports, module) {

// Domains for some agents must be enabled first before loading
var enablePromise = Inspector.Page.enable().then(function () {
Inspector.DOM.enable().then(_enableAgents);
return Inspector.DOM.enable().then(_enableAgents, _enableAgents);
});

enablePromise.done(function () {
Expand Down
21 changes: 18 additions & 3 deletions src/file/FileUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ define(function (require, exports, module) {
}

/**
* Get the parent directory of a file. If a directory is passed in the directory is returned.
* Get the parent directory of a file. If a directory is passed, the SAME directory is returned.
* @param {string} fullPath full path to a file or directory
* @return {string} Returns the path to the parent directory of a file or the path of a directory,
* including trailing "/"
Expand All @@ -453,8 +453,22 @@ define(function (require, exports, module) {
}

/**
* Get the file name without the extension.
* @param {string} filename File name of a file or directory
* Get the parent folder of the given file/folder path. Differs from getDirectoryPath() when 'fullPath'
* is a directory itself: returns its parent instead of the original path. (Note: if you already have a
* FileSystemEntry, it's faster to use entry.parentPath instead).
* @param {string} fullPath full path to a file or directory
* @return {string} Path of containing folder (including trailing "/"); or "" if path was the root
*/
function getParentPath(fullPath) {
if (fullPath === "/") {
return "";
}
return fullPath.substring(0, fullPath.lastIndexOf("/", fullPath.length - 2) + 1);
}

/**
* Get the file name without the extension. Returns "" if name starts with "."
* @param {string} filename File name of a file or directory, without preceding path
* @return {string} Returns the file name without the extension
*/
function getFilenameWithoutExtension(filename) {
Expand Down Expand Up @@ -559,6 +573,7 @@ define(function (require, exports, module) {
exports.isStaticHtmlFileExt = isStaticHtmlFileExt;
exports.isServerHtmlFileExt = isServerHtmlFileExt;
exports.getDirectoryPath = getDirectoryPath;
exports.getParentPath = getParentPath;
exports.getBaseName = getBaseName;
exports.getRelativeFilename = getRelativeFilename;
exports.getFilenameWithoutExtension = getFilenameWithoutExtension;
Expand Down
8 changes: 4 additions & 4 deletions src/nls/de/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ define({

// General file io error strings
"GENERIC_ERROR" : "(Fehler {0})",
"NOT_FOUND_ERR" : "Die Datei konnte nicht gefunden werden.",
"NOT_READABLE_ERR" : "Die Datei konnte nicht gelesen werden.",
"NOT_FOUND_ERR" : "Die Datei/der Ordner konnte nicht gefunden werden.",
"NOT_READABLE_ERR" : "Die Datei/der Ordner konnte nicht gelesen werden.",
"EXCEEDS_MAX_FILE_SIZE" : "{APP_NAME} kann keine Dateien öffnen, die größer als {0} MB sind.",
"NO_MODIFICATION_ALLOWED_ERR" : "Der Ziel-Ordner kann nicht verändert werden.",
"NO_MODIFICATION_ALLOWED_ERR_FILE" : "Die Berechtigungen erlauben Ihnen nicht, Veränderungen vorzunehmen.",
Expand Down Expand Up @@ -396,7 +396,7 @@ define({
"CMD_QUICK_OPEN" : "Schnell öffnen",
"CMD_GOTO_LINE" : "Gehe zur Zeile",
"CMD_GOTO_DEFINITION" : "Definition schnell finden",
"CMD_GOTO_FIRST_PROBLEM" : "Zum ersten Fehler/zur ersten Warnung gehen",
"CMD_GOTO_FIRST_PROBLEM" : "Zum ersten Problem gehen",
"CMD_TOGGLE_QUICK_EDIT" : "Schnell bearbeiten",
"CMD_TOGGLE_QUICK_DOCS" : "Schnell-Dokumentation",
"CMD_QUICK_EDIT_PREV_MATCH" : "Voriger Treffer",
Expand Down Expand Up @@ -628,4 +628,4 @@ define({
"DOCS_MORE_LINK" : "Weiterlesen"
});

/* Last translated for 893c065b715c211526dcd010c0294e12a8683995 */
/* Last translated for c292e896761bc7d451a9e3b95bedd20d6b355d77 */
14 changes: 6 additions & 8 deletions src/nls/es/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
/*global define */

define({

/**
* Errors
*/

// General file io error strings
"GENERIC_ERROR" : "(error {0})",
"NOT_FOUND_ERR" : "No se pudo encontrar el archivo.",
"NOT_READABLE_ERR" : "No se pudo leer el archivo.",
"NOT_FOUND_ERR" : "No se pudo encontrar el archivo/directorio.",
"NOT_READABLE_ERR" : "No se pudo leer el archivo/directorio.",
"EXCEEDS_MAX_FILE_SIZE" : "Los archivos de más de {0} MB no se pueden abrir en {APP_NAME}.",
"NO_MODIFICATION_ALLOWED_ERR" : "El directorio de destino no se puede modificar.",
"NO_MODIFICATION_ALLOWED_ERR_FILE" : "Los permisos no permiten hacer modificaciones.",
Expand All @@ -49,7 +49,6 @@ define({
"FILENAME" : "nombre de archivo",
"DIRECTORY_NAME" : "nombre de directorio",


// Project error strings
"ERROR_LOADING_PROJECT" : "Error abriendo el proyecto",
"OPEN_DIALOG_ERROR" : "Ha ocurrido un error al mostrar el aviso de apertura de archivo. (error {0})",
Expand Down Expand Up @@ -295,7 +294,6 @@ define({
"LINTER_TIMED_OUT" : "{0} ha agotado el tiempo después de esperar {1} ms",
"LINTER_FAILED" : "{0} terminó con error: {1}",


/**
* Command Name Constants
*/
Expand Down Expand Up @@ -396,7 +394,7 @@ define({
"CMD_QUICK_OPEN" : "Apertura rápida",
"CMD_GOTO_LINE" : "Ir a la línea",
"CMD_GOTO_DEFINITION" : "Búsqueda rápida de definición",
"CMD_GOTO_FIRST_PROBLEM" : "Ir al primer error/advertencia",
"CMD_GOTO_FIRST_PROBLEM" : "Ir al primer problema",
"CMD_TOGGLE_QUICK_EDIT" : "Edición rápida",
"CMD_TOGGLE_QUICK_DOCS" : "Documentación rápida",
"CMD_QUICK_EDIT_PREV_MATCH" : "Coincidencia anterior",
Expand Down Expand Up @@ -453,7 +451,7 @@ define({
"BASEURL_ERROR_HASH_DISALLOWED" : "La URL base no puede contener hashes como \"{0}\".",
"BASEURL_ERROR_INVALID_CHAR" : "Los caracteres especiales como '{0}' deben codificarse en formato %.",
"BASEURL_ERROR_UNKNOWN_ERROR" : "Error desconocido analizando la URL base",
"EMPTY_VIEW_HEADER" : "<em>Abra un archivo mientras este panel está enfocado</em>",
"EMPTY_VIEW_HEADER" : "<em>Abra un archivo mientras este panel está enfocado</em>",

// Strings for themes-settings.html and themes-general.html
"CURRENT_THEME" : "Tema actual",
Expand Down Expand Up @@ -628,4 +626,4 @@ define({
"DOCS_MORE_LINK" : "Más"
});

/* Last translated for 0b949dd02b87866d54f38631715a4353a8f927e5 */
/* Last translated for c292e896761bc7d451a9e3b95bedd20d6b355d77 */
36 changes: 35 additions & 1 deletion test/spec/FileUtils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,30 @@ define(function (require, exports, module) {
});

it("should return the unchanged directory of a posix directory path", function () {
expect(FileUtils.getDirectoryPath("C:/foo/bar/")).toBe("C:/foo/bar/");
expect(FileUtils.getDirectoryPath("/foo/bar/")).toBe("/foo/bar/");
});

it("should return the unchanged directory of a root path", function () {
expect(FileUtils.getDirectoryPath("C:/")).toBe("C:/");
expect(FileUtils.getDirectoryPath("/")).toBe("/");
});
});

describe("getParentPath", function () {

it("should get the parent directory of a normalized file path", function () {
expect(FileUtils.getParentPath("C:/foo/bar/baz.txt")).toBe("C:/foo/bar/");
expect(FileUtils.getParentPath("/foo/bar/baz.txt")).toBe("/foo/bar/");
});

it("should return the parent directory of a normalized directory path", function () {
expect(FileUtils.getParentPath("C:/foo/bar/")).toBe("C:/foo/");
expect(FileUtils.getParentPath("/foo/bar/")).toBe("/foo/");
});

it("should return '' given a root path", function () {
expect(FileUtils.getParentPath("C:/")).toBe("");
expect(FileUtils.getParentPath("/")).toBe("");
});
});

Expand Down Expand Up @@ -142,6 +165,17 @@ define(function (require, exports, module) {
expect(FileUtils.getFileExtension("foo.bar.baz..jaz.txt")).toBe("txt");
});
});

describe("getFilenameWithoutExtension", function () {

it("should remove last extension segment only", function () {
expect(FileUtils.getFilenameWithoutExtension("foo.txt")).toBe("foo");
expect(FileUtils.getFilenameWithoutExtension("foo.min.txt")).toBe("foo.min");
expect(FileUtils.getFilenameWithoutExtension("foo")).toBe("foo");

expect(FileUtils.getFilenameWithoutExtension(".foo")).toBe("");
});
});

describe("getSmartFileExtension", function () {

Expand Down
9 changes: 9 additions & 0 deletions test/spec/LiveDevelopment-MultiBrowser-test-files/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html>
<head>
<title>Test</title>
<link rel="stylesheet" href="sub/test.css" />
</head>
<body>
<h1>Hello</h1>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body { background-color: red;}

h1 { color: blue; }
12 changes: 12 additions & 0 deletions test/spec/LiveDevelopmentMultiBrowser-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,18 @@ define(function (require, exports, module) {
});
});

it("should find an index.html in a parent directory", function () {
runs(function () {
waitsForDone(SpecRunnerUtils.openProjectFiles(["sub/test.css"]), "SpecRunnerUtils.openProjectFiles sub/test.css", 1000);
});

waitsForLiveDevelopmentToOpen();

runs(function () {
expect(LiveDevelopment._getCurrentLiveDoc().doc.url).toMatch(/\/index\.html$/);
});
});

it("should send all external stylesheets as related docs on start-up", function () {
var liveDoc;
runs(function () {
Expand Down

0 comments on commit 9ee1f08

Please sign in to comment.