Blog Pile

Feed2JS Build and Style Tools

Back to code.

I modified the download-able version of our Feed2JS to provide local installations the same build and CSS select/modify tools we offer on the main site.

The primary reason is getting it set up on a server in New Zealand for my pending visits there for workshops in November.

This was a fairly quick attempt. If someone who is using the code on their own site can just check out the new build.php, style.php, pages and associated assets, I’d be appreciative.

If this kind of stuff has value, please support me by tossing a one time PayPal kibble or monthly on Patreon
Become a patron at Patreon!
Profile Picture for CogDog The Blog
An early 90s builder of web stuff and blogging Alan Levine barks at CogDogBlog.com on web storytelling (#ds106 #4life), photography, bending WordPress, and serendipity in the infinite internet river. He thinks it's weird to write about himself in the third person. And he is 100% into the Fediverse (or tells himself so) Tooting as @cogdog@cosocial.ca

Comments

  1. I have installed the new scripts, but I haven’t got it all working yet. Seems to be a cache problem, but can’t figure out the specifics yet. The magpie_debug works fine and caches the document. Build.php and the style scripts both genearate the javascript, but the rss feeds are not displayed on the web pages even though what seems to be the correct code is generated. No cache items are generated related to the build.php script.

    Must be something simple – weill keep looking at it.

  2. I also installed the new scripts, and the magpie_debug works smoothly but the style scripts are not displayed on the web pages even thought the correct code was generated. no previews are available on builds.php and style.php

  3. Sorry guys,

    I had a smal typo in feed2js.php- there is a missing semi colon at the end of line 115- it reads:

    define(‘MAGPIE_CACHE_DIR’, $MAGPIE_DIR . ‘cache/’)

    and should read

    define(‘MAGPIE_CACHE_DIR’, $MAGPIE_DIR . ‘cache/’);

    I need to add my tip for debugging the script. If you get no preview, there is likely a PHP syntax error in feed2js.php. If you use the build.php script to generate the JavaScript, take the URL part of the JS tag “src=”…” and paste that URL in a browser.

    If you see document.write statements, it is working- if there is a problem in PHP you will get an error message.

    Omari- if the styles are not being applied that it is because the pages where the JavaScript code is used needs the correct paths for linking to whereever you have put the CSS styles

  4. I added the semicolon into the feed2js.php and into the feed2php.inc docs, but I still get no preview from the build or style scripts. Documents are cached now though. Copying an pasting everything after the “src” does produce document.write statements as follows. I’m not sure if the first messages are errors or not. I commented out the header code as indicated on line 284, put there was no visilbe difference – ie, no preview.

    **************************

    es

    Notice: MagpieRSS [debug] MagpieRSS: Cache HIT in /Library/WebServer/Documents/news/rss_fetch.inc on line 235

    Warning: Cannot modify header information – headers already sent by (output started at /Library/WebServer/Documents/news/feed2js.php:1) in /Library/WebServer/Documents/news/feed2js.php on line 284

    document.write(‘

    ‘); document.write(‘

    cogdogblog

    [cdb] alan’s wacky weird web II: projects, ideas, & instructional technology

    ‘); document.write(‘

    ‘); document.write(‘

    URL-ing it your way to easy audio, video clips- John Udell on Hypermedia and Blogging’); document.write(‘

    posted on August 08, 2004 09:42:00 am’); document.write(‘

  5. Gerry,

    I am guessing from the error message and the weird linebreaks in the echo-ed output that you are running this on a Mac– and I am betting also that when you unpacked the zip the .php files got converted to Mac text types with mac line returns.

    You need to convert all unix server scripts to have unix linebreaks- go to http://www.versiontracker.com/ and look for an app called “Linebreak”, which allows you to drag and drop a pile of text files to convert the line endings to unix style or if you use BBEdit, you can change the file type from Mac to Unix.

    I do all my development and testing on my G4 laptop so can verify it wotks, but often server scripts will get tripped up with the line break issue

  6. Just a quick comment on your new feed2php.inc file. It works really well when there is only one include on the page, but falls apart due to function redefinition’s when you attempt to call the file more than once in the same page. To get around this, I removed the strip_returns segment of the feed2php.inc file (beginning around line 52) and put it into its own file, named strip_returns.inc (don’t forget to identify the contents of strip_returns.inc as php, or it will just spit it out as plain text into your html page). I then used require_once(‘strip_returns.inc) in the feed2php.inc file, which solved the function redefinition problem. You might want to think about wrapping something like this into your main distribution of the file.

  7. Ouch! Dan, you are correct. I was toying with the include approach thinking I might use it on some local sites, and had only 3/4 thought it out.

    Actually, I could pull out the configuration stuff too, which might make doing updates much easier everytine I fix the script for one of my bad typos 😉

    FYI- Gerry’s problems above were do to some stray text that wandered into his PHP code prior to the <php tags.

  8. I am getting an error that looks very similar to Gerry’s. The JS inline RSS will not display, but the text alternative will display perfectly when I use the test/debug option on the build.php page.

    Pasting the URL part of the JS tag “src=”…” into the browser gives me output identical to Gerry’s. I haven’t found any stray text outside of the php tags; the files were unzipped in Windows; and the browser previews JS inline RSS perfectly in the Maricopa pages.

  9. Laurence,

    From your symtoms I am guessing there is something funky in one of your feeds- the most likely culprit is an unexpected apostrophe.

    What happens with the item titles and descriptions is that all single quotes ‘ must be “escaped” or have a “” inserted before hand. This is because the output is writting as a document.write and a string wrapped in single quotes. If there is an unexpected single quote, it effectively prematurely ends the JavaScript command, leaving junk behind it, and rendering nothing or garbage out. The feed2js script handles this automatically for feed titles and descriptions. I helped someone recently who it turns out had a link item with a single quote in the URL (I had never seen sucha URL before).

    I cannot offer nmore without the URL for the feed not being rendered (lesson for future commenters, send the RSS URl that is not functioning).

    It is also rmeotely possible there is some other grabage character in the feed.

Comments are closed.