diff --git a/mozilla/editor/ui/composer/content/ComposerCommands.js b/mozilla/editor/ui/composer/content/ComposerCommands.js
index 7796e351d28..a3f67f1593b 100644
--- a/mozilla/editor/ui/composer/content/ComposerCommands.js
+++ b/mozilla/editor/ui/composer/content/ComposerCommands.js
@@ -461,7 +461,7 @@ var nsPublishCommand =
if (filename)
{
// Try to get site data from the document url
- publishData = GetPublishDataFromUrl(docUrl);
+ publishData = CreatePublishDataFromUrl(docUrl);
// If none, use default publishing site
//XXX Should we do this? Maybe bring up dialog instead?
@@ -480,8 +480,7 @@ var nsPublishCommand =
// User needs to supply a filename or we didn't find publish data above
// Bring up the dialog via cmd_publishAs,
- // but set commandnode "state" attribute to "" to use default initial site
- doStatefulCommand("cmd_publishAs", "");
+ goDoCommand("cmd_publishAs")
return true;
}
return false;
@@ -501,25 +500,10 @@ var nsPublishAsCommand =
{
FinishHTMLSource();
- // SiteName is stored in the "state" attribute on the command node
- var siteName;
- var commandNode = document.getElementById(aCommand);
- if (commandNode)
- siteName = commandNode.getAttribute("state");
-
- var docUrl = GetDocumentUrl();
- var filename = GetFilename(docUrl);
- var publishData;
-
- // Try to publish to a particular site
- if (filename && siteName && (publishData = GetPublishDataFromSiteName(siteName, docUrl)))
- return Publish(publishData);
-
- // User needs to supply a filename or sitename or we didn't find publish data above
- // Launch the publish dialog to initialized with requested sitename (or default if none)
window.ok = false;
publishData = {};
- window.openDialog("chrome://editor/content/EditorPublish.xul","_blank", "chrome,close,titlebar,modal", "", siteName, publishData);
+ window.openDialog("chrome://editor/content/EditorPublish.xul","_blank",
+ "chrome,close,titlebar,modal", "", "", publishData);
window._content.focus();
if (window.ok)
return Publish(publishData);
@@ -850,15 +834,28 @@ var gEditorOutputProgressListener =
dump("\n");
}
- // This is how to detect end of file upload of HTML file:
+ // Detect end of file upload of HTML file:
if (gPublishData)
{
var pubSpec = gPublishData.publishUrl + gPublishData.docDir + gPublishData.filename;
+
if ((aStateFlags & nsIWebProgressListener.STATE_STOP) &&
(aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK)
&& requestSpec && requestSpec == pubSpec)
{
// Do window.editorShell.doAfterSave(true, docUrl) and related stuff here
+
+ // Get the new docUrl from the "browse location" in case "publish location" was FTP
+ var urlstring = GetDocUrlFromPublishData(gPublishData);
+
+ try {
+ window.editorShell.doAfterSave(true, urlstring); // we need to update the url before notifying listeners
+ var editor = window.editorShell.editor.QueryInterface(Components.interfaces.nsIEditor);
+ editor.ResetModificationCount(); // this should cause notification to listeners that document has changed
+
+ // Set UI based on whether we're editing a remote or local url
+ SetSaveAndPublishUI(urlstring);
+ } catch (e) {}
}
}
},
@@ -1246,7 +1243,6 @@ function SaveDocument(aSaveAs, aSaveCopy, aMimeType)
}
catch (e)
{
- // XXX we need to change these strings if we are publishing!!!
var saveDocStr = GetString("SaveDocument");
var failedStr = GetString("SaveFileFailed");
AlertWithTitle(saveDocStr, failedStr);
@@ -1261,7 +1257,7 @@ function SaveDocument(aSaveAs, aSaveCopy, aMimeType)
window.editorShell.editor.ResetModificationCount(); // this should cause notification to listeners that document has changed
// Set UI based on whether we're editing a remote or local url
- SetSaveAndPublishUI(urlString);
+ SetSaveAndPublishUI(urlstring);
} catch (e) {}
}
return success;
@@ -1280,84 +1276,18 @@ function Publish(publishData)
if (!docURI)
return false;
- // Set global for username password requests
+ // Set data in global for username password requests
+ // and to do "post saving" actions after monitoring nsIWebProgressListener messages
+ // and we are sure file transfer was successful
gPublishData = publishData;
var otherFilesURI = CreateURIFromPublishData(publishData, false);
var success = OutputFileWithPersistAPI(window.editorShell.editorDocument,
docURI, otherFilesURI, window.editorShell.contentsMIMEType);
- if (success)
- {
- //XXX We really shouldn't continue here unless we get confirmation that file was really uploaded
- // Get the new docUrl from the "browse location" in case "publish location" was FTP
- var urlString = GetDocUrlFromPublishData(publishData);
-
- try {
- window.editorShell.doAfterSave(true, urlString); // we need to update the url before notifying listeners
- window.editorShell.editor.ResetModificationCount(); // this should cause notification to listeners that document has changed
-
- // Set UI based on whether we're editing a remote or local url
- SetSaveAndPublishUI(urlString);
- } catch (e) {}
- }
return success;
}
-function InitPublishMenu()
-{
- var publishSitesSeparator = document.getElementById("publishSitesSeparator");
- if (!publishSitesSeparator)
- return;
-
- var menupopup = publishSitesSeparator.parentNode;
- if (!menupopup)
- return;
-
- // Clear existing site items
- var next = publishSitesSeparator.nextSibling;
- while (next)
- {
- var tmp = next.nextSibling
- menupopup.removeChild(next);
- next = tmp
- }
-
- // Get site name list: sorted, but put default name is first
- var siteNameList = GetSiteNameList(true, true);
- if (!siteNameList)
- {
- // No site data in prefs yet
- SetElementHidden(publishSitesSeparator, true);
- return;
- }
-
- SetElementHidden(publishSitesSeparator, false);
-
- // Append sitenames to submenu
- for (var i = 0; i < siteNameList.length; i++)
- {
- var menuItem = document.createElementNS(XUL_NS, "menuitem");
- if (menuItem)
- {
- var accessKey;
- if (i <= 9)
- accessKey = String(i+1);
- else if (i == 10)
- accessKey = "0";
- else
- accessKey = " ";
-
- menuItem.setAttribute("label", accessKey+" " + siteNameList[i]);
- menuItem.setAttribute("value", siteNameList[i]);
- if (accessKey != " ")
- menuItem.setAttribute("accesskey", accessKey);
-
- menupopup.appendChild(menuItem);
- }
- }
-}
-
// Create a nsIURI object filled in with all required publishing info
function CreateURIFromPublishData(publishData, doDocUri)
{
@@ -1415,24 +1345,27 @@ function GetDocUrlFromPublishData(publishData)
// 3. Shift accel+S keybinding to Save or Publish commands
// Note: A new, unsaved file is treated as a local file
// (XXX Have a pref to treat as remote for user's who mostly edit remote?)
-function SetSaveAndPublishUI(urlString)
+function SetSaveAndPublishUI(urlstring)
{
// Associate the "save" keybinding with Save for local files,
// or with Publish for remote files
- var scheme = GetScheme(urlString);
+ var scheme = GetScheme(urlstring);
var menuItem1;
var menuItem2;
var saveButton = document.getElementById("saveButton");
var publishButton = document.getElementById("publishButton");
var command;
+
if (!scheme || scheme == "file")
{
+ // Editing a new or local file
menuItem1 = document.getElementById("publishMenuitem");
menuItem2 = document.getElementById("saveMenuitem");
command = "cmd_save";
+
+ // Hide "Publish". Show "Save" toolbar and menu items
SetElementHidden(publishButton, true);
SetElementHidden(saveButton, false);
- SetElementHidden(menuItem2, false);
}
else
{
@@ -1440,10 +1373,15 @@ function SetSaveAndPublishUI(urlString)
menuItem1 = document.getElementById("saveMenuitem");
menuItem2 = document.getElementById("publishMenuitem");
command = "cmd_publish";
+
+ // Hide "Save", show "Publish" toolbar and menuitems
SetElementHidden(saveButton, true);
SetElementHidden(publishButton, false);
- SetElementHidden(menuItem1, true);
}
+
+ SetElementHidden(menuItem1, true);
+ SetElementHidden(menuItem2, false);
+
var key = document.getElementById("savekb");
if (key && command)
key.setAttribute("observes", command);
@@ -1662,7 +1600,9 @@ var nsPrintCommand =
{
// In editor.js
FinishHTMLSource();
- window.editorShell.Print();
+ try {
+ window.editorShell.Print();
+ } catch (e) {}
}
};
diff --git a/mozilla/editor/ui/composer/content/editorOverlay.xul b/mozilla/editor/ui/composer/content/editorOverlay.xul
index 2f5dd752c7e..2404604c40f 100644
--- a/mozilla/editor/ui/composer/content/editorOverlay.xul
+++ b/mozilla/editor/ui/composer/content/editorOverlay.xul
@@ -140,8 +140,7 @@
-
-
+
-
+
@@ -673,7 +663,7 @@
tooltiptext="&saveToolbarCmd.tooltip;"/>
+ tooltiptext="&publishToolbarCmd.tooltip;" hidden="true"/>
diff --git a/mozilla/editor/ui/composer/content/editorUtilities.js b/mozilla/editor/ui/composer/content/editorUtilities.js
index 7e997540ed0..13f734bf9af 100644
--- a/mozilla/editor/ui/composer/content/editorUtilities.js
+++ b/mozilla/editor/ui/composer/content/editorUtilities.js
@@ -217,7 +217,7 @@ function SetElementHidden(element, hide)
if (element)
{
if (hide)
- element.setAttribute("hidden", true);
+ element.setAttribute("hidden", "true");
else
element.removeAttribute("hidden");
}
@@ -689,20 +689,47 @@ function GetFilename(url)
return filename ? filename : "";
}
-// Return the url with username and password (preHost) removed
-function StripUsernamePassword(url)
+// Return the url without username and password
+// Optional output objects return extracted username and password strings
+// This uses just string routines via nsIIOServices
+function StripUsernamePassword(url, usernameObj, passwordObj)
{
- if (url)
+ url = TrimString(url);
+ if (!url || IsUrlAboutBlank(url))
+ return url;
+
+ var IOService = GetIOService();
+ if (!IOService)
+ return url;
+
+ if (usernameObj)
+ usernameObj.value = "";
+ if (passwordObj)
+ passwordObj.value = "";
+
+ // "@" must exist else we will never detect username or password
+ var atIndex = url.indexOf("@");
+ if (atIndex > 0)
{
try {
- uri = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI);
- uri.spec = url;
- return StripUsernamePasswordFromURI(uri);
- } catch (e) {}
+ var startU = {value :0};
+ var username = IOService.extractUrlPart(url, IOService.url_Username, startU, {end:0});
+ var password = IOService.extractUrlPart(url, IOService.url_Password, {start:0}, {end:0});
+
+ if (usernameObj && username)
+ usernameObj.value = username;
+ if (passwordObj && password)
+ passwordObj.value = password;
+
+ if (username)
+ return url.slice(0, startU.value) + url.slice(atIndex+1);
+
+ } catch (e) {}
}
return url;
}
+// Version to use when you have an nsIURI object
function StripUsernamePasswordFromURI(uri)
{
var url = "";
diff --git a/mozilla/editor/ui/composer/content/publishprefs.js b/mozilla/editor/ui/composer/content/publishprefs.js
index e67bcc81b21..75bb6efa325 100644
--- a/mozilla/editor/ui/composer/content/publishprefs.js
+++ b/mozilla/editor/ui/composer/content/publishprefs.js
@@ -108,7 +108,7 @@ function GetDefaultPublishSiteName()
// Return object with all info needed to publish
// from database of sites previously published to.
-function GetPublishDataFromUrl(docUrl)
+function CreatePublishDataFromUrl(docUrl)
{
if (!docUrl || IsUrlAboutBlank(docUrl) || GetScheme(docUrl) == "file")
return null;
@@ -137,21 +137,27 @@ function GetPublishDataFromUrl(docUrl)
// Document wasn't found in publish site database
// Create data just from URL
+ // Extract username and password from docUrl
+ var userObj = {};
+ var passObj = {};
+ var pubUrl = StripUsernamePassword(docUrl, userObj, passObj);
+
// Strip off filename
- var lastSlash = docUrl.lastIndexOf("\/");
- var pubUrl = docUrl.slice(0, lastSlash);
+ var lastSlash = pubUrl.lastIndexOf("\/");
+ //XXX Look for "?", "=", and "&" ?
+ pubUrl = pubUrl.slice(0, lastSlash+1);
publishData = {
siteName : pubUrl,
filename : GetFilename(docUrl),
- username : "",
- password : "",
+ username : userObj.value,
+ password : passObj.value,
savePassword : false,
publishUrl : pubUrl,
browseUrl : pubUrl,
- docDir : "/",
- otherDir : "/",
- dirList : ["/"],
+ docDir : "",
+ otherDir : "",
+ dirList : [""],
notInSiteData : true
}
@@ -242,11 +248,11 @@ function GetPublishData_internal(publishBranch, siteName)
otherDir : FormatDirForPublishing(GetPublishStringPref(publishBranch, prefPrefix+"other_dir"))
}
// Get password from PasswordManager
- publishData.password = GetPassword(publishData);
+ publishData.password = GetSavedPassword(publishData);
// Build history list of directories
// Always supply the root dir
- publishData.dirList = ["/"];
+ publishData.dirList = [""];
// Get the rest from prefs
var dirCount = {value:0};
@@ -297,7 +303,7 @@ function SavePublishSiteDataToPrefs(siteArray, defaultName)
}
// Assure that we have a default name
if (siteArray.length && !defaultFound)
- defaultName == siteArray[0].siteName;
+ defaultName = siteArray[0].siteName;
}
// Save default site name
@@ -367,6 +373,8 @@ function SavePublishData_Internal(publishPrefsBranch, publishData, siteIndex)
SetPublishStringPref(publishPrefsBranch, "site_name."+siteIndex, publishData.siteName);
+ FixupUsernamePasswordInPublishData(publishData);
+
var prefPrefix = "site_data." + publishData.siteName + "."
SetPublishStringPref(publishPrefsBranch, prefPrefix+"url", publishData.publishUrl);
SetPublishStringPref(publishPrefsBranch, prefPrefix+"browse_url", publishData.browseUrl);
@@ -394,7 +402,7 @@ function SavePublishData_Internal(publishPrefsBranch, publishData, siteIndex)
var dir = publishData.dirList[j];
// Don't store the root dir
- if (dir != "/")
+ if (dir && dir != "/")
{
SetPublishStringPref(publishPrefsBranch, prefPrefix + "dir." + dirIndex, dir);
dirIndex++;
@@ -579,28 +587,69 @@ function SetPublishStringPref(prefBranch, name, value)
}
}
-// Assure that a publishing URL does not end in "/"
+// Assure that a publishing URL ends in "/", "=", "&" or "?"
+// Username and password should always be extracted as separate fields
+// and are not allowed to remain embeded in publishing URL
function FormatUrlForPublishing(url)
{
- url = TrimString(url);
- if (url && url.charAt(url.length-1) == "/")
- url = url.slice(0,url.length-1);
-
+ url = TrimString(StripUsernamePassword(url));
+ if (url)
+ {
+ var lastChar = url.charAt(url.length-1);
+ if (lastChar != "/" && lastChar != "=" && lastChar != "&" && lastChar != "?")
+ return (url + "/");
+ }
return url;
}
-// Assure that a publishing directory begins and ends with "/"
+// Username and password present in publish url are
+// extracted into the separate "username" and "password" fields
+// of the publishData object
+// Returns true if we did change the publishData
+function FixupUsernamePasswordInPublishData(publishData)
+{
+ var ret = false;
+ if (publishData && publishData.publishUrl)
+ {
+ var userObj = {value:""};
+ var passObj = {value:""};
+ publishData.publishUrl = FormatUrlForPublishing(StripUsernamePassword(publishData.publishUrl, userObj, passObj));
+ if (userObj.value)
+ {
+ publishData.username = userObj.value;
+ ret = true;
+ }
+ if (passObj.value)
+ {
+ publishData.password = passObj.value;
+ ret = true;
+ }
+ // While we're at it, be sure browse URL is proper format
+ publishData.browseUrl = FormatUrlForPublishing(publishData.browseUrl);
+ }
+ return ret;
+}
+
+// Assure that a publishing directory ends with "/" and does not begin with "/"
// Input dir is assumed to be a subdirectory string, not a full URL or pathname
function FormatDirForPublishing(dir)
{
dir = TrimString(dir);
- if (!dir || dir.charAt(0) != "/")
- dir = "/" + dir;
+ // The "//" case is an expected "typo" filter
+ // that simplifies code below!
+ if (!dir || dir == "/" || dir == "//")
+ return "";
+ // Remove leading "/"
+ if (dir.charAt(0) == "/")
+ dir = dir.slice(1);
+
+ // Append "/" at the end if necessary
var dirLen = dir.length;
- if (dirLen > 1 && dir.charAt(dirLen-1) != "/")
- dir = dir + "/";
+ var lastChar = dir.charAt(dirLen-1);
+ if (dirLen > 1 && lastChar != "/" && lastChar != "=" && lastChar != "&" && lastChar != "?")
+ return (dir + "/");
return dir;
}
@@ -618,7 +667,7 @@ function GetPasswordManager()
return gPasswordManager
}
-function GetPassword(publishData)
+function GetSavedPassword(publishData)
{
if (!publishData || !publishData.savePassword)
return "";
diff --git a/mozilla/editor/ui/composer/locale/en-US/editorOverlay.dtd b/mozilla/editor/ui/composer/locale/en-US/editorOverlay.dtd
index 658771262d9..b892876d181 100644
--- a/mozilla/editor/ui/composer/locale/en-US/editorOverlay.dtd
+++ b/mozilla/editor/ui/composer/locale/en-US/editorOverlay.dtd
@@ -50,10 +50,8 @@
-
-
-
+
diff --git a/mozilla/editor/ui/dialogs/content/EditorPublish.js b/mozilla/editor/ui/dialogs/content/EditorPublish.js
index 5ade234cb34..2ed914f4422 100644
--- a/mozilla/editor/ui/dialogs/content/EditorPublish.js
+++ b/mozilla/editor/ui/dialogs/content/EditorPublish.js
@@ -61,14 +61,13 @@ function Startup()
gDialog.SiteList = document.getElementById("SiteList");
gDialog.DocDirList = document.getElementById("DocDirList");
gDialog.OtherDirCheckbox = document.getElementById("OtherDirCheckbox");
+ gDialog.OtherDirRadiogroup = document.getElementById("OtherDirRadiogroup");
+ gDialog.SameLocationRadio = document.getElementById("SameLocationRadio");
+ gDialog.UseSubdirRadio = document.getElementById("UseSubdirRadio");
gDialog.OtherDirList = document.getElementById("OtherDirList");
- gDialog.MoreSection = document.getElementById("MoreSection");
- gDialog.MoreFewerButton = document.getElementById("MoreFewerButton");
-
// Settings Panel
gDialog.SettingsPanel = document.getElementById("SettingsPanel");
- gDialog.ServerSettingsBox = document.getElementById("ServerSettingsBox");
gDialog.SiteNameInput = document.getElementById("SiteNameInput");
gDialog.PublishUrlInput = document.getElementById("PublishUrlInput");
gDialog.BrowseUrlInput = document.getElementById("BrowseUrlInput");
@@ -85,31 +84,22 @@ function Startup()
gDefaultSiteName = GetDefaultPublishSiteName();
gPreviousDefaultSite = gDefaultSiteName;
- InitDialog();
-
- SeeMore = (gDialog.MoreFewerButton.getAttribute("more") != "1");
- onMoreFewerPublish();
-
- // If there's no current site data, start a new item in the Settings panel
- if (!gPublishSiteData)
- AddNewSite();
- else
- SetTextboxFocus(gDialog.PageTitleInput);
-
- // This sets enable states on buttons
- doEnabling();
-
- SetWindowLocation();
-}
-
-function InitDialog()
-{
+ var addNewSite = false;
if (gPublishSiteData)
+ {
FillSiteList();
+ }
+ else
+ {
+ // No current site data, start a new item in the Settings panel
+ AddNewSite();
+ addNewSite = true;
+ }
var docUrl = GetDocumentUrl();
var scheme = GetScheme(docUrl);
var filename = "";
+
if (scheme)
{
filename = GetFilename(docUrl);
@@ -123,7 +113,7 @@ function InitDialog()
var dirObj = {};
var siteIndex = FindSiteIndexAndDocDir(gPublishSiteData, docUrl, dirObj);
- // Select this site only if the same as user's intended site, or there wasnt' one
+ // Select this site only if the same as user's intended site, or there wasn't one
if (siteIndex != -1 && (gInitialSiteIndex == -1 || siteIndex == gInitialSiteIndex))
{
// Select the site we found
@@ -139,17 +129,30 @@ function InitDialog()
//XXX HOW DO WE DECIDE WHAT "OTHER" DIR TO USE?
//gPublishSiteData[siteIndex].otherDir = docDir;
}
+ else
+ {
+ // Not found in site database
+ // Setup for a new site and use data from a remote URL
+ if (!addNewSite)
+ AddNewSite();
+
+ addNewSite = true;
+
+ var publishData = CreatePublishDataFromUrl(docUrl);
+ if (publishData)
+ {
+ filename = publishData.filename;
+ gDialog.SiteNameInput.value = publishData.siteName;
+ gDialog.PublishUrlInput.value = publishData.publishUrl;
+ gDialog.BrowseUrlInput.value = publishData.browseUrl;
+ gDialog.UsernameInput.value = publishData.username;
+ gDialog.PasswordInput.value = publishData.password;
+ gDialog.SavePassword.checked = false;
+ }
+ }
}
}
}
-
- // We haven't selected a site -- use initial or default site
- if (gDialog.SiteList.selectedIndex == -1)
- gDialog.SiteList.selectedIndex = (gInitialSiteIndex != -1) ? gInitialSiteIndex : gDefaultSiteIndex;
-
- // Fill in all the site data for currently-selected site
- SelectSiteList();
-
try {
gPreviousTitle = editorShell.GetDocumentTitle();
} catch (e) {}
@@ -157,8 +160,43 @@ function InitDialog()
gDialog.PageTitleInput.value = gPreviousTitle;
gDialog.FilenameInput.value = filename;
+ if (!addNewSite)
+ {
+ // If not adding a site and we haven't selected a site -- use initial or default site
+ if (gDialog.SiteList.selectedIndex == -1)
+ gDialog.SiteList.selectedIndex = (gInitialSiteIndex != -1) ? gInitialSiteIndex : gDefaultSiteIndex;
+
+ // Fill in all the site data for currently-selected site
+ SelectSiteList();
+ SetTextboxFocus(gDialog.PageTitleInput);
+ }
+
//XXX TODO: How do we decide whether or not to save associated files?
+ // And whether to save in same location as page if yes?
gDialog.OtherDirCheckbox.checked = true;
+
+ if (gDialog.SiteList.selectedIndex == -1)
+ {
+ // No selected site -- assume same directory
+ gDialog.OtherDirRadiogroup.selectedItem = gDialog.selectedItem = gDialog.SameLocationRadio;
+ }
+ else
+ {
+ // For now, check "same location" if dirs are already set to same directory
+ if (gPublishSiteData[gDialog.SiteList.selectedIndex].docDir ==
+ gPublishSiteData[gDialog.SiteList.selectedIndex].otherDir)
+ {
+ gDialog.OtherDirRadiogroup.selectedItem = gDialog.selectedItem = gDialog.SameLocationRadio;
+ }
+ else
+ {
+ gDialog.OtherDirRadiogroup.selectedItem = gDialog.selectedItem = gDialog.OtherDirRadiogroup;
+ }
+ }
+
+ doEnabling();
+
+ SetWindowLocation();
}
function FillSiteList()
@@ -192,7 +230,10 @@ function FillSiteList()
function doEnabling()
{
- gDialog.OtherDirList.disabled = !gDialog.OtherDirCheckbox.checked;
+ var disableOther = !gDialog.OtherDirCheckbox.checked;
+ gDialog.SameLocationRadio.disabled = disableOther;
+ gDialog.UseSubdirRadio.disabled = disableOther;
+ gDialog.OtherDirList.disabled = (disableOther || gDialog.SameLocationRadio.selected);
}
function SelectSiteList()
@@ -236,8 +277,8 @@ function SelectSiteList()
}
else
{
- gDialog.DocDirList.value = "/";
- gDialog.OtherDirList.value = "/";
+ gDialog.DocDirList.value = "";
+ gDialog.OtherDirList.value = "";
}
gDialog.SiteNameInput.value = siteName;
@@ -248,30 +289,6 @@ function SelectSiteList()
gDialog.SavePassword.checked = savePassword;
}
-function onMoreFewerPublish()
-{
- if (SeeMore)
- {
- gDialog.MoreSection.setAttribute("collapsed","true");
- gDialog.ServerSettingsBox.setAttribute("collapsed","true");
- window.sizeToContent();
-
- gDialog.MoreFewerButton.setAttribute("more","0");
- gDialog.MoreFewerButton.setAttribute("label",GetString("More"));
- SeeMore = false;
- }
- else
- {
- gDialog.MoreSection.removeAttribute("collapsed");
- gDialog.ServerSettingsBox.removeAttribute("collapsed");
- window.sizeToContent();
-
- gDialog.MoreFewerButton.setAttribute("more","1");
- gDialog.MoreFewerButton.setAttribute("label",GetString("Less"));
- SeeMore = true;
- }
-}
-
function AddNewSite()
{
// Button in Publish panel allows user
@@ -320,22 +337,9 @@ function SwitchPanel(panel)
// Trigger setting of style for the tab widgets
gDialog.SettingsTab.selected = "true";
gDialog.PublishTab.selected = null;
-
- // We collapse part of the Settings panel so the Publish Panel can be more compact
- if (gDialog.ServerSettingsBox.getAttribute("collapsed"))
- {
- gDialog.ServerSettingsBox.removeAttribute("collapsed");
- window.sizeToContent();
- }
} else {
gDialog.PublishTab.selected = "true";
gDialog.SettingsTab.selected = null;
-
- if (!SeeMore)
- {
- gDialog.ServerSettingsBox.setAttribute("collapsed","true");
- window.sizeToContent();
- }
}
gCurrentPanel = panel;
}
@@ -410,8 +414,16 @@ function ValidateSettings()
return false;
}
- var publishUrl = GetPublishUrlInput();
- if (!publishUrl)
+ // Extract username and password while removing them from publishingUrl
+ var urlUserObj = {};
+ var urlPassObj = {};
+ var publishUrl = StripUsernamePassword(gDialog.PublishUrlInput.value, urlUserObj, urlPassObj);
+ if (publishUrl)
+ {
+ publishUrl = FormatUrlForPublishing(publishUrl);
+ gDialog.PublishUrlInput.value = publishUrl;
+ }
+ else
{
ShowErrorInPanel(gSettingsPanel, "MissingPublishUrlError", gDialog.PublishUrlInput);
return false;
@@ -420,11 +432,25 @@ function ValidateSettings()
//TODO: If publish scheme = "ftp" we should encourage user to supply the http BrowseUrl
var browseUrl = GetBrowseUrlInput();
- //XXXX We don't get a prompt dialog if username is missing (bug ?????)
- // If not, we must force user to supply one here
var username = TrimString(gDialog.UsernameInput.value);
var savePassword = gDialog.SavePassword.checked;
var password = gDialog.PasswordInput.value;
+
+ //XXX If there was a username and/or password in the publishUrl
+ // AND in the input field, which do we use?
+ // Let's use those in url only if input is empty
+ if (!username)
+ {
+ username = urlUserObj.value;
+ gDialog.UsernameInput.value = username;
+ gSettingsChanged = true;
+ }
+ if (!password)
+ {
+ password = urlPassObj.value;
+ gDialog.PasswordInput.value = password;
+ gSettingsChanged = true;
+ }
// Update or add data for a site
var siteIndex = gDialog.SiteList.selectedIndex;
@@ -445,9 +471,9 @@ function ValidateSettings()
gDefaultSiteName = siteName;
}
gPublishSiteData[siteIndex] = {};
- gPublishSiteData[siteIndex].docDir = "/";
- gPublishSiteData[siteIndex].otherDir = "/";
- gPublishSiteData[siteIndex].dirList = ["/"];
+ gPublishSiteData[siteIndex].docDir = "";
+ gPublishSiteData[siteIndex].otherDir = "";
+ gPublishSiteData[siteIndex].dirList = [""];
newSite = true;
}
gPublishSiteData[siteIndex].siteName = siteName;
@@ -499,6 +525,11 @@ function ValidateSettings()
// And directory for images and other files
var otherDir = GetOtherDirInput();
+ if (gDialog.SameLocationRadio.selected)
+ otherDir = docDir;
+ else
+ otherDir = GetOtherDirInput();
+
if (gDialog.OtherDirList.selectedIndex == -1)
AppendDirToSelectedSite(otherDir);
@@ -569,7 +600,11 @@ function onAccept()
var title = TrimString(gDialog.PageTitleInput.value);
if (title != gPreviousTitle)
- editorShell.SetDocumentTitle(title);
+ {
+ try {
+ editorShell.SetDocumentTitle(title);
+ } catch (e) {}
+ }
SaveWindowLocation();
window.opener.ok = true;
diff --git a/mozilla/editor/ui/dialogs/content/EditorPublish.xul b/mozilla/editor/ui/dialogs/content/EditorPublish.xul
index 2683da5db44..455c8f71048 100644
--- a/mozilla/editor/ui/dialogs/content/EditorPublish.xul
+++ b/mozilla/editor/ui/dialogs/content/EditorPublish.xul
@@ -88,44 +88,38 @@
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
-
-
+
+
-
+
+
diff --git a/mozilla/editor/ui/dialogs/content/EditorPublishOverlay.xul b/mozilla/editor/ui/dialogs/content/EditorPublishOverlay.xul
index f6bec3c9133..11b064fdc50 100644
--- a/mozilla/editor/ui/dialogs/content/EditorPublishOverlay.xul
+++ b/mozilla/editor/ui/dialogs/content/EditorPublishOverlay.xul
@@ -43,6 +43,7 @@
+
@@ -62,6 +63,7 @@
+
diff --git a/mozilla/editor/ui/dialogs/content/EditorPublishSettings.js b/mozilla/editor/ui/dialogs/content/EditorPublishSettings.js
index 4382c169287..620a968e474 100644
--- a/mozilla/editor/ui/dialogs/content/EditorPublishSettings.js
+++ b/mozilla/editor/ui/dialogs/content/EditorPublishSettings.js
@@ -28,7 +28,8 @@ var gPreviousDefaultSite;
var gPreviousTitle;
var gSettingsChanged = false;
var gSiteDataChanged = false;
-var gNewSite = false;
+var gAddNewSite = false;
+var gCurrentSiteIndex = -1;
// Dialog initialization code
function Startup()
@@ -72,7 +73,10 @@ function InitDialog()
function FillSiteList()
{
+ // Prevent triggering SelectSiteList() actions
+ gIsSelecting = true;
ClearListbox(gDialog.SiteList);
+ gIsSelecting = false;
gDefaultSiteIndex = -1;
// Fill the site list
@@ -102,12 +106,12 @@ function SetPublishItemStyle(item)
function AddNewSite()
{
// Save any pending changes locally first
- if (gSettingsChanged && !UpdateSettings())
+ if (!ApplyChanges())
return;
// Initialize Setting widgets to none of the selected sites
InitSiteSettings(-1);
- gNewSite = true;
+ gAddNewSite = true;
SetTextboxFocus(gDialog.SiteNameInput);
}
@@ -122,6 +126,7 @@ function RemoveSite()
if (index != -1)
{
item = gDialog.SiteList.selectedItems[0];
+ var nameToRemove = item.getAttribute("label");
// Remove one item from site data array
gPublishSiteData.splice(index, 1);
@@ -134,6 +139,12 @@ function RemoveSite()
index--;
InitSiteSettings(index);
+ if (nameToRemove == gDefaultSiteName)
+ {
+ // Deleting current default -- set to new selected item
+ // Arbitrary, but what else to do?
+ SetDefault();
+ }
gSiteDataChanged = true;
}
}
@@ -159,7 +170,8 @@ function SetDefault()
}
}
-// Recursion prevention: InitSiteSettings() changes selected item
+// Recursion prevention:
+// Use when you don't want to trigger ApplyChanges and InitSiteSettings
var gIsSelecting = false;
function SelectSiteList()
@@ -168,22 +180,34 @@ function SelectSiteList()
return;
gIsSelecting = true;
+ var newIndex = gDialog.SiteList.selectedIndex;
// Save any pending changes locally first
- if (gSettingsChanged && !UpdateSettings())
+ if (!ApplyChanges())
return;
- InitSiteSettings(gDialog.SiteList.selectedIndex);
+ InitSiteSettings(newIndex);
gIsSelecting = false;
}
-function InitSiteSettings(selectedSiteIndex)
+// Use this to prevent recursion in SelectSiteList
+function SetSelectedSiteIndex(index)
{
+ gIsSelecting = true;
+ gDialog.SiteList.selectedIndex = index;
+ gIsSelecting = false;
+}
+
+function InitSiteSettings(selectedSiteIndex)
+{
+ // Index to the site we will need to update if settings changed
+ gCurrentSiteIndex = selectedSiteIndex;
+
var savePassord = false;
+ SetSelectedSiteIndex(selectedSiteIndex);
var haveData = (gPublishSiteData && selectedSiteIndex != -1);
- gDialog.SiteList.selectedIndex = selectedSiteIndex;
gDialog.SiteNameInput.value = haveData ? gPublishSiteData[selectedSiteIndex].siteName : "";
gDialog.PublishUrlInput.value = haveData ? gPublishSiteData[selectedSiteIndex].publishUrl : "";
@@ -204,6 +228,17 @@ function onInputSettings()
gSettingsChanged = true;
}
+function ApplyChanges()
+{
+ if (gSettingsChanged && !UpdateSettings())
+ {
+ // Restore selection to previously current site
+ SetSelectedSiteIndex(gCurrentSiteIndex);
+ return false;
+ }
+ return true;
+}
+
function UpdateSettings()
{
// Validate and add new site
@@ -220,81 +255,67 @@ function UpdateSettings()
return false;
}
- var siteIndex = -1;
+ // Start assuming we're updating existing site at gCurrentSiteIndex
+ var newSiteData = false;
+
if (!gPublishSiteData)
{
- // Create the first site profile
+ // First time used - Create the first site profile
gPublishSiteData = new Array(1);
- siteIndex = 0;
- gNewSite = true;
+ gCurrentSiteIndex = 0;
+ newSiteData = true;
}
- else
+ else if (gCurrentSiteIndex == -1)
{
+ // No currently-selected site,
+ // must be adding a new site
// Add new data at the end of list
- siteIndex = gPublishSiteData.length;
+ gCurrentSiteIndex = gPublishSiteData.length;
+ newSiteData = true;
}
- if (gNewSite || gDialog.SiteList.selectedIndex == -1)
+ if (newSiteData)
{
- // Init new site object
- gPublishSiteData[siteIndex] = {};
- gPublishSiteData[siteIndex].docDir = "/";
- gPublishSiteData[siteIndex].otherDir = "/";
- gPublishSiteData[siteIndex].dirList = ["/"];
- }
- else
- {
- // Update existing site profile
- siteIndex = gDialog.SiteList.selectedIndex;
+ // Init new site profile
+ gPublishSiteData[gCurrentSiteIndex] = {};
+ gPublishSiteData[gCurrentSiteIndex].docDir = "/";
+ gPublishSiteData[gCurrentSiteIndex].otherDir = "/";
+ gPublishSiteData[gCurrentSiteIndex].dirList = ["/"];
}
- gPublishSiteData[siteIndex].siteName = newName;
- gPublishSiteData[siteIndex].publishUrl = newUrl;
- gPublishSiteData[siteIndex].browseUrl = FormatUrlForPublishing(gDialog.BrowseUrlInput.value);
- gPublishSiteData[siteIndex].username = TrimString(gDialog.UsernameInput.value);
- gPublishSiteData[siteIndex].password= gDialog.PasswordInput.value;
- gPublishSiteData[siteIndex].savePassword = gDialog.SavePassword.checked;
+ gPublishSiteData[gCurrentSiteIndex].siteName = newName;
+ gPublishSiteData[gCurrentSiteIndex].publishUrl = newUrl;
+ gPublishSiteData[gCurrentSiteIndex].browseUrl = FormatUrlForPublishing(gDialog.BrowseUrlInput.value);
+ gPublishSiteData[gCurrentSiteIndex].username = TrimString(gDialog.UsernameInput.value);
+ gPublishSiteData[gCurrentSiteIndex].password= gDialog.PasswordInput.value;
+ gPublishSiteData[gCurrentSiteIndex].savePassword = gDialog.SavePassword.checked;
- if (siteIndex == gDefaultSiteIndex)
+ if (gCurrentSiteIndex == gDefaultSiteIndex)
gDefaultSiteName = newName;
- var count = gPublishSiteData.length;
- if (count > 1)
- {
- // XXX Ascii sort, not locale-aware
- gPublishSiteData.sort();
-
- //Find previous items in sorted list
- for (var i = 0; i < count; i++)
- {
- if (gPublishSiteData[i].siteName == newName)
- {
- siteIndex = i;
- break;
- }
- }
- }
-
// When adding the very first site, assume that's the default
- if (count == 1 && !gDefaultSiteName)
+ if (gPublishSiteData.length == 1 && !gDefaultSiteName)
{
gDefaultSiteName = gPublishSiteData[0].siteName;
gDefaultSiteIndex = 0;
}
FillSiteList();
- gDialog.SiteList.selectedIndex = siteIndex;
+
+ // Select current site in list
+ SetSelectedSiteIndex(gCurrentSiteIndex);
// Signal saving data to prefs
gSiteDataChanged = true;
// Clear current site flags
gSettingsChanged = false;
- gNewSite = false;
+ gAddNewSite = false;
return true;
}
+
function doHelpButton()
{
openHelp("site_settings");
@@ -303,7 +324,7 @@ function doHelpButton()
function onAccept()
{
// Save any pending changes locally first
- if (gSettingsChanged && !UpdateSettings())
+ if (!ApplyChanges())
return false;
if (gSiteDataChanged)
diff --git a/mozilla/editor/ui/dialogs/locale/en-US/EditorPublish.dtd b/mozilla/editor/ui/dialogs/locale/en-US/EditorPublish.dtd
index cac1884d9b9..d84d5787323 100644
--- a/mozilla/editor/ui/dialogs/locale/en-US/EditorPublish.dtd
+++ b/mozilla/editor/ui/dialogs/locale/en-US/EditorPublish.dtd
@@ -32,8 +32,10 @@
-
-
+
+
+
+
@@ -49,8 +51,8 @@
-
-
-
+
+
+