Open scripting opened 2 years ago
Success. I followed the instructions and put a filter.js file in one of my PagePark test domain folders, and my News Product for the Duke River of News is displayed at http://drum.stor.im.
Anton
On Fri, Sep 30, 2022 at 11:27 AM Dave Winer @.***> wrote:
If FeedLand were a public thing I'd post this on my blog, but I can't. But I did want to document this for later.
This involves PagePark and Node.js and JavaScript -- but you don't have to understand the last two to get this to work, but you do have to be running PagePark. I think @mistersugar https://github.com/mistersugar could do this if he did every step very very carefully. 😄 How I did it
I wanted to have news.scripting.com be a FeedLand news product site.
The problem is the urlSiteContent config option doesn't pass through search params. I can't go digging in PagePark now to fix this without risking breaking a lot of other stuff, so instead I used its filter capability. If there's a file called filter.js in a folder, it loads and runs the script and lets it fully handle the request.
At the end I've included the source of the filter.js script I wrote and putin the news.scripting.com sub-folder of the domains folder in PagePark.
If you change the value of urlTemplate at the top of the script, to point to your OPML file, you can do the same thing. You don't have to understand how the code works.
Yes, it could be even simpler if I worked a bit on PagePark, but it works! :-) The code
var urlTemplate = "http://scripting.com/publicfolder/feedland/products/newsScriptingCom.opml";
const request = require ("request");
function httpRespond (code, type, val, headers) {
if (headers === undefined) {
headers = new Object (); }
if (type === undefined) { //7/20/18 by DW
type = "text/plain"; }
headers ["Content-Type"] = type;
options.httpResponse.writeHead (code, headers);
options.httpResponse.end (val);
}
var urlServer = "http://product.scripting.com/?template=" + urlTemplate;
request (urlServer, function (err, response, htmltext) {
if (err) {
httpRespond (500, "text/plain", err.message); }
else {
httpRespond (200, "text/html", htmltext); }
});
— Reply to this email directly, view it on GitHub https://github.com/scripting/feedlandSupport/issues/79, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5LBHL523JZB3CDVBC6FLLWA4BHVANCNFSM6AAAAAAQZ4B7DQ . You are receiving this because you were mentioned.Message ID: @.***>
@mistersugar -- I knew you could do it. You've just written your first Node.js app. Something you can add to your CV.
If FeedLand were a public thing I'd post this on my blog, but I can't. But I did want to document this for later.
This involves PagePark and Node.js and JavaScript -- but you don't have to understand the last two to get this to work, but you do have to be running PagePark. I think @mistersugar could do this if he did every step very very carefully. :smile:
How I did it
I wanted to have news.scripting.com be a FeedLand news product site.
The problem is the urlSiteContent config option doesn't pass through search params. I can't go digging in PagePark now to fix this without risking breaking a lot of other stuff, so instead I used its filter capability.
If there's a file called filter.js in a folder, it loads and runs the script and lets it fully handle the request. The docs are pretty sparse, but there are some.
At the end I've included the source of the filter.js script I wrote and putin the news.scripting.com sub-folder of the domains folder in PagePark.
If you change the value of urlTemplate at the top of the script, to point to your OPML file, you can do the same thing. You don't have to understand how the code works.
Yes, it could be even simpler if I worked a bit on PagePark, but it works! :-)
Why I used an outline
Because I need space to work, and I'm going to do at least 10 news products, so I have to do outlines for at least 9 of them.
I also probably will want to add more flexibility to the product parser, if you're willing to use outlines. There's more room over there too, if it doesn't have to flow through a dialog, and FeedLand. The outline is its own thing.
The code