Hello,

I've rewrote Newspaper to work without XSLTProcessor, which turned out to be even easier and shorter, and now it works with all web browsers.

Background

Once a page is validated to be of type feed, the executes two main actions to generate an HTML page.

Function renderXML(xmlFile, atomRules) to gather data bfrom the file and generate an HTML out of it.

Function extensionLoader() which adds CSS stylesheet and some functions of accessibility and navigation.

This script has been tested successfully with all formats: Atom, ActivityStream, JSON, RDF and RSS.

Issue

However, the part of extensionLoader() doesn't always work, and the reason is unknown to me.

Below are two feeds on the same server of same content but different formats (one is XML and the other is JSON); the function extensionLoader() works only with the JSON feed.

https://www.jsonfeed.org/feed.xml
https://www.jsonfeed.org/feed.json

This post is not related to this thread

Please help!

Kindly,
Schimon

This is the function in question.

function extensionLoader(url) {
  purgeStylesheets();
  formatDate();
  setCssStylesheet();
  decorateEntry();
  linksBar();
  follow(url);
  subToMe(url);
  aboutPage();
  donatePage();
  settleFilters();
  scrollDown();
  statusBar();
  mailTo();
}

The functions formatDate(), linksBar(), aboutPage, donatePage and statusBar() do work for the XML feed, but not all the rest of the functions, such as setCssStylesheet();.

Styling functions tend to work in more cases when loading them to the generated document before setting it with the original document, but I'm interested in doing all the post-work after the HTML file is ready.

https://furbo.org/feed/atom/


Setting arbitrary MIME Type (document.contentType) using Open in Browser will result in the following findings:

Opening as "text/plain", "text/html" will make everything work.

Opening as "text/xml" (including "application/xml" etc.) will only build HTML file, without CSS related additions.

Attempting to set MIME Type using this code has failed:

request.setRequestHeader('Content-Type', 'text/plain;charset=UTF-8');

Testing feeds:
https://www.kaidan.im/atom.xml
https://www.falkon.org/atom.xml
https://www.jsonfeed.org/feed.xml
https://furbo.org/feed/atom/


Setting arbitrary MIME Type (document.contentType) using Open in Browser will result in the following findings:

Opening as "text/plain", "text/html" will make everything work.

Opening as "text/xml" (including "application/xml" etc.) will only build HTML file, without CSS related additions.


Attempting to set MIME Type using this code has failed:

request.setRequestHeader('Content-Type', 'text/plain;charset=UTF-8');

Testing feeds:
https://www.kaidan.im/atom.xml
https://www.falkon.org/atom.xml
https://www.jsonfeed.org/feed.xml