scripting / a8c-FeedLand-Support

A public repo for discussing FeedLand at A8C.
1 stars 0 forks source link

WordPress integration #40

Open cagrimmett opened 1 year ago

cagrimmett commented 1 year ago

A rough outline of the idea:

fmfernandes commented 1 year ago

What if you could specify a page that displays your News Product on your WordPress site?

Maybe there's a way to get which categories makes a News Product? Because using the below solution I think we can get a list of feed items to display.

What if you could set a page on your WordPress site to display your news from FeedLand?

We can use https://a8c.feedland.org/getriverfromcategory?screenname=fernando&catname=all to get a list of all items on a user's feed so it may be possible to get a News Product categories and join them.

scripting commented 1 year ago

@fmfernandes -- we can get you any information that feedlandHome gets.

If you want to see what can be done with API calls, have a look here..

http://scripting.com/code/feedland/home/api.js

What do we need to call out to FeedLand from WordPress?

Glue for PHP?

scripting commented 1 year ago

There's also the FeedLand Platform. I haven't shown you that yet, because we're at a much more basic level.

@cagrimmett -- maybe you could approach it first as a user -- a FeedLand Platform app is textcaster.org. It's my linkblogging tool, works very well. It's how I do the Links tab on scripting.com.

Actually that's a really good place to start. I can give you the JS code I use to implement the Links tab. That's it right?? ;-)

http://scripting.com/?tab=links

scripting commented 1 year ago

I dug around the source of the Scripting News template, and this is how the Links page is generated.

http://feeder.scripting.com/returnlinkbloghtml?feedurl=http%3A%2F%2Fdata.feedland.org%2Ffeeds%2Fdavewiner.xml

If you click the link and do a view source, you'll see straight HTML text with the posts that are currently in the RSS feed for my personal feed managed by feedland.org.

feeder.scripting.com is open source. It does a lot of other nice things, it's good for validating feeds, for example. If you enter the URL of any feed it will show you exactly what FeedLand gets when it reads that feed (because this is the code the FL uses).

So if we want to present a simple river for WordPress users, to start, this is imho the quickest way to do it.

PS: We could copy the returnlinkbloghtml call into FeedLand so an extra app isn't needed. But we don't have to do it to get started.

fmfernandes commented 1 year ago

What do you all think of a first step for the integration, for a widget or block or something, that goes on a sidebar on your blog and pulls a specific feed from your FeedLand account (or any, really) and displays the items?

scripting commented 1 year ago

@fmfernandes -- yes, that was what we agreed to, but i think there was more discussion after you left? not sure..

fmfernandes commented 1 year ago

Yeah, my connection was spotty throughout the call 😕

Maybe @cagrimmett can confirm, but creating a plugin with a widget and/or block to display a single feed sounds like a good first step.

scripting commented 1 year ago

is it possible to run javascript code inside wordpress pages?

fmfernandes commented 1 year ago

It is! 👍🏻

scripting commented 1 year ago

How does the code get into the page?

I don't imagine I can use a <script> tag?

fmfernandes commented 1 year ago

Well, you can use this function wp_enqueue_scripts that will let you load any .js file you want and will be converted to a <script> tag with the specified src.

You can also build a custom block that uses React (which essentially is JavaScript).

You can also use something like wp_head like this:

add_action( 'wp_head', function() {
    ?>
    <script>alert( 'hi' );</script>
    <?php
} );

That will add a <script> tag to the <head> element of all WP pages.


Those snippets can be added to the functions.php file on a given theme or added as a plugin.

scripting commented 1 year ago

@cagrimmett — what I want is to include the code that renders the tabbed rivers from news products. I’ll provide more info on what that means tomorrow.

scripting commented 1 year ago

The goal is to get a tiny piece of FeedLand to run in a page in WordPress.

From what I gather from these comments is there are a variety of ways to do that.

The challenge is to narrow that down to what it will take to get the tiny piece to work.

I'm thinking about how I could create a bit of code and say -- here -- get this to run in WordPress.

And if it can't then I'll learn what limits it breaks, and then be able to think more clearly about what we can do inside WordPress pages.

Example

Suppose I want to give you a bit of code that displays a river, given a category and screenname. This is the example @fmfernandes mentioned the other day.

There's a routine in riverviewer.js called displayTraditionalRiver.

fmfernandes commented 11 months ago

Noting here that we have a WordPress plugin with a couple integrations with FeedLand available for anyone to test on https://github.com/a8cteam51/feedland

scripting commented 11 months ago

@fmfernandes -- can i post this to my linkblog?

warning -- pretty good chance you'll get not-nice email from my detractors. they are persistent but harmless.

This is what I was going to post:

A couple of WordPress plugins that use the FeedLand API to show your latest feed items on a WordPress site. Written by Fernando Fernandes who is a developer at Automattic.

fmfernandes commented 11 months ago

Hey @scripting, feel free to! It's already open source anyways.

I would just phrase it like so:

A couple of WordPress blocks that use the FeedLand API to show your latest feed items on a WordPress site. Written by Fernando Fernandes who is a developer at Automattic.

As in, it's a single plugin that includes a couple blocks 😄

scripting commented 11 months ago

https://feedland.com/?item=528426

scripting commented 11 months ago

A milestone in WordPress integration, we hope. ;-)

https://github.com/scripting/feedlandRiverInclude/