Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different feed.xml structure #8

Open
jengalas opened this issue Jun 21, 2016 · 18 comments
Open

Different feed.xml structure #8

jengalas opened this issue Jun 21, 2016 · 18 comments
Assignees

Comments

@jengalas
Copy link

This looks great, but it isn't working for me, I think because the feed generated by my site has a different structure than what your script is looking for.

See: https://jengalas.github.io/thegourmetmoose/feed.xml

Do you have any ideas how to fix this? Will I need to create a different template for the feed?

@chinchang
Copy link
Owner

@jengalas Yes, that is a different structure. And a valid one I suppose, according to https://validator.w3.org/feed/.

So I guess, it a different format for Atom 1.0 (old but valid) and should be supported by super-search. I'll try modifying the script to support this format. You are welcome to contribute too :)

@chinchang
Copy link
Owner

Hi @jengalas Made a patch in 0.0.4 version. Please try the latest library.

@jengalas
Copy link
Author

Thanks for the fast response! I've replaced super-search.js with the new version but I'm still getting an error. Chrome reports "Uncaught TypeError: Cannot read property 'addEventListener' of null" and Firebug reports: "TypeError: o is null".

@chinchang
Copy link
Owner

Have you passed in the correct required parameters as in the example:

superSearch({
    searchFile: '/feed.xml',
    searchSelector: '#js-search', // CSS Selector for search container element.
    inputSelector: '#js-search__input', // CSS selector for <input>
    resultsSelector: '#js-search__results' // CSS selector for results container
});

If you have it on some public website, I can check there.

@jengalas
Copy link
Author

Sure, check it out here: https://jengalas.github.io/thegourmetmoose/ Thanks for your help!

@chinchang
Copy link
Owner

@jengalas Please change the init code to this:

superSearch({
    searchFile: '//jengalas.github.io/thegourmetmoose/feed.xml',
    searchSelector: '#js-super-search', // CSS Selector for search container element.
    inputSelector: '#js-super-search__input', // CSS selector for <input>
    resultsSelector: '#js-super-search__results' // CSS selector for results container
});

@jengalas
Copy link
Author

OK, I've done that. After adjusting the z-index to work with my theme, the search box is showing, and displaying the results' titles when I type into the search box. However, right after the title I see "Invalid Date" and the search result links are trying to go to https://jengalas.github.io/thegourmetmoose/[object%20Object]

@jengalas
Copy link
Author

Noticed that your feed uses pubDate while mine uses published.

@chinchang
Copy link
Owner

Ahh...I suppose there are some more differences in the format than I initially saw. Will have to take into account all of them. Will take it up.

@jengalas
Copy link
Author

I've switched to RSS for now (by adding a feed.xml template) just to get the search working ... but since jekyll-feed is used by GitHub Pages to generate feeds, a lot of people might be using it. I think it would be worthwhile to account for the differences in your script.

I can switch back to Atom to help with testing if you'd like; just let me know.

Great work, by the way!

@garethjohnsdesign
Copy link

I'm having exactly the same issue here, the search results come up but the links and the dates don't work, is there a way to resolve this?

@chinchang
Copy link
Owner

@garethjohnsdesign While I fix this in the library itself, you can do a quick fix in the super-search.js file. Instead of pubDate on line 98, put the name of tag being used for date in your xml feed.

For eg., like @jengalas mentioned she has published instead of pubDate in her feeds. So replace pubDate with published in super-search.js. That should work.

@chinchang chinchang self-assigned this Jul 17, 2016
@garethjohnsdesign
Copy link

I'm not massively up on these the XML feed and how that works, if I wanted to get the link from this how would I do it?<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><generator uri="http://jekyllrb.com" version="3.1.6">Jekyll</generator><link href="http://inside-retail.garethjohnsdesign.com/feed.xml" rel="self" type="application/atom+xml" /><link href="http://inside-retail.garethjohnsdesign.com/" rel="alternate" type="text/html" /><updated>2016-07-17T21:06:21+00:00</updated><id>http://inside-retail.garethjohnsdesign.com/</id><title>Inside Retail</title><subtitle>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Nullam id dolor id nibh ultricies vehicula ut id elit.</subtitle><entry><title>Nine Things to Consider Before Setting up Online</title><link href="http://inside-retail.garethjohnsdesign.com/articles/nine-things-to-consider-before-setting-up-online/" rel="alternate" type="text/html" title="Nine Things to Consider Before Setting up Online" /><published>2016-07-12T17:26:00+00:00</published><updated>2016-07-12T17:26:00+00:00</updated><id>http://inside-retail.garethjohnsdesign.com/articles/nine-things-to-consider-before-setting-up-online</id><content type="html" xml:base="http://inside-retail.garethjohnsdesign.com/articles/nine-things-to-consider-before-setting-up-online/">

@garethjohnsdesign
Copy link

I tried putting post.link

@garethjohnsdesign
Copy link

But it doesn't work

@chinchang
Copy link
Owner

Your's is same as @jengalas's. Replace pubDate with published in super-search.js. Let me know.

@garethjohnsdesign
Copy link

Oh no I meant the link, I don't actually need the date in there so took that out of the JS, post.link doesn't work

@chinchang
Copy link
Owner

chinchang commented Jul 17, 2016

@garethjohnsdesign Your link is actually in the href attribute of the link tag and not as its value directly. So it won't be as trivial to fetch the url right now. But its also weird having the url in the href attribute as both RSS and Atom don't have such format. I guess it would be best to have your feed structure changed to one of the valid formats.

Edit: Also, it would help to know how is your feed xml generated. It might be valid, and I might have to support that also.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants