From 28018cc54b7ccb0cf00994f2e2987824a1fc29e9 Mon Sep 17 00:00:00 2001 From: "scott%scott-macgregor.org" Date: Wed, 15 Jun 2005 21:32:01 +0000 Subject: [PATCH] Bug #297804 --> OPML Export should be pretty-printed patch by robert sayre sr=me --- .../newsblog/content/feed-subscriptions.js | 39 +++++++++++++++---- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/mail/extensions/newsblog/content/feed-subscriptions.js b/mail/extensions/newsblog/content/feed-subscriptions.js index 0212fed1723..e9ad25698bf 100644 --- a/mail/extensions/newsblog/content/feed-subscriptions.js +++ b/mail/extensions/newsblog/content/feed-subscriptions.js @@ -817,22 +817,32 @@ var gFeedSubscriptionsWindow = { var opmlDoc = document.implementation.createDocument("","opml",null); var opmlRoot = opmlDoc.documentElement; opmlRoot.setAttribute("version","1.0"); - + + this.generatePPSpace(opmlRoot," "); + // Make the element var head = opmlDoc.createElement("head"); + this.generatePPSpace(head, " "); var title = opmlDoc.createElement("title"); title.appendChild(opmlDoc.createTextNode(this.mBundle.getString("subscribe-OPMLExportFileTitle"))); head.appendChild(title); + this.generatePPSpace(head, " "); var dt = opmlDoc.createElement("dateCreated"); dt.appendChild(opmlDoc.createTextNode((new Date()).toGMTString())); head.appendChild(dt); + this.generatePPSpace(head, " "); opmlRoot.appendChild(head); - + + this.generatePPSpace(opmlRoot, " "); + //add s to the var body = opmlDoc.createElement("body"); - this.generateOutline(this.mRSSServer.rootFolder, body); + this.generateOutline(this.mRSSServer.rootFolder, body, 4); + this.generatePPSpace(body, " "); opmlRoot.appendChild(body); - + + this.generatePPSpace(opmlRoot, ""); + var serial=new XMLSerializer(); var rv = pickSaveAs(this.mBundle.getString("subscribe-OPMLExportTitle"),'$all', this.mBundle.getString("subscribe-OPMLExportFileName")); @@ -847,12 +857,23 @@ var gFeedSubscriptionsWindow = { } } }, + + generatePPSpace: function(aNode, indentString) + { + aNode.appendChild(aNode.ownerDocument.createTextNode("\n")); + aNode.appendChild(aNode.ownerDocument.createTextNode(indentString)); + }, - generateOutline: function(baseFolder, parent) + generateOutline: function(baseFolder, parent, indentLevel) { var folderEnumerator = baseFolder.GetSubFolders(); var done = false; + // pretty printing + var indentString = ""; + for(i = 0; i < indentLevel; i++) + indentString = indentString + " "; + while (!done) { var folder = folderEnumerator.currentItem().QueryInterface(Components.interfaces.nsIMsgFolder); @@ -864,17 +885,19 @@ var gFeedSubscriptionsWindow = { // Make a mostly empty outline element outline = parent.ownerDocument.createElement("outline"); outline.setAttribute("text",folder.prettiestName); - this.generateOutline(folder, outline); // recurse + this.generateOutline(folder, outline, indentLevel+2); // recurse + this.generatePPSpace(parent, indentString); + this.generatePPSpace(outline, indentString); parent.appendChild(outline); } else { // Add outline elements with xmlUrls var feeds = this.getFeedsInFolder(folder); - for(feed in feeds) + for (feed in feeds) { - debug("feed: " + feeds[feed]); outline = this.opmlFeedToOutline(feeds[feed],parent.ownerDocument); + this.generatePPSpace(parent, indentString); parent.appendChild(outline); } }