geeksforsocialchange / PlaceCal

Bring your community together
https://placecal.org
GNU Affero General Public License v3.0
16 stars 6 forks source link

Support automatic importing of any ld+json schema.org events #1536

Closed erbridge closed 1 year ago

erbridge commented 1 year ago

User story

As an organiser, I need to import the events of partners, so that they appear on PlaceCal.

Acceptance criteria

Implementation notes & questions

Prompted by #1444 seeming to also use ld+json, but not be a Squarespace site.

Implementation plan

To be written by the developer

kimadactyl commented 1 year ago

It would be nice if we can find a tool (browser plugin?) that detects if a page you have has a compatible ld+json feed - be v useful for placecal organisers

erbridge commented 1 year ago

We could knock a browser extension together for that very easily, I think.

kimadactyl commented 1 year ago

i was thinking of using an existing one but our own one would have lots of benefits to be sure - if it just spots and gives you the correct link that would save a shitload of errors for admins im guessing. esp as the vendor list grows it would prob save a lot of time for people.

aaaaargZombies commented 1 year ago

started looking into this https://crxjs.dev/vite-plugin

detecting events will probably be something like

[...document.querySelectorAll('script[type="application/ld+json"]')]
.map(el => el.innerHTML)
.filter(str => str.includes('"@type": "Event"')) // do something nicer here probably with lodash
.length  > 0 // true if has events
erbridge commented 1 year ago

See also: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Build_a_cross_browser_extension

However, I think the browser extension is the least important part of this. Let's spawn a new issue for that.

erbridge commented 1 year ago

1546 for the browser extension (later).

ivan-kocienski-gfsc commented 1 year ago

So we try fetching a URL and if the response is HTML then we attempt to scan it for ld+json content?

I'm a little concerned that although ld+json is well structured in specific records there's an infinite variety of nesting structures that will have to be dealt with. i.e. we have two importers (Dice and OutSavvy) that are both ld+json but are just different enough to warrant their own extraction logic.

erbridge commented 1 year ago

Isn't this what the library we're using is for? To standardise the data structures by "expanding" or "compacting"? If they're being compliant with the standards, we should be able to implement a common parser that works for any standard-compliant implementation.

ivan-kocienski-gfsc commented 1 year ago

Do we have a list of known ld-json sources we can use to test the third criteria? It seems like it may be a bit open ended as an AC

ivan-kocienski-gfsc commented 1 year ago

I am closing this now as we can find example problem sites as we move forward.