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

Refactor sitemaps to use centralised events #5069

Merged
merged 1 commit into from
Apr 7, 2015

Conversation

ErisDS
Copy link
Member

@ErisDS ErisDS commented Mar 24, 2015

This is the result of me being bored on a plane for a few hours, it's a refactor of the sitemap generation to use a centralised event system.

The idea is to use this for sitemaps and XMLRPC, potentially RSS and other things too.

This is now a working PR, with tests and a bugfix. Once this is in, I'll do further work to update XMLRPC and RSS to be generated based on these events.

fixes #5104, refs #4348, #2263

  • Create a centralised event module
  • Hook it up for posts, pages, tags and users
  • Use it in sitemaps instead of direct method calls
  • Check events are fired in model tests
  • Update sitemap tests to work with new code
  • Fix a bug where invited users were appearing in sitemaps

events.emit(model.resourceType() + '.published.edited', model);
}

events.emit(model.resourceType() + '.edited', model);

This comment was marked as abuse.

This comment was marked as abuse.

@@ -24,10 +25,16 @@ function BaseSiteMapGenerator() {
}

_.extend(BaseSiteMapGenerator.prototype, {
dataEvents: events,

This comment was marked as abuse.

@ErisDS
Copy link
Member Author

ErisDS commented Apr 2, 2015

@jgable thanks for the feedback, all good ideas!

I'm currently a little bit stuck on how to write tests for this - once I've got the tests in I'll be able to be certain the logic transferred correctly - until then the answer is just 'I think so' haha.

If anyone has any good links on patterns for testing event emitters send em my way - otherwise I think my problem is trying to rewrite the current integration tests when I probably need to change it completely into two sets - one to test the events get fired correctly on the models and one to test that when firing the events the sitemap behaves correctly.

@ErisDS ErisDS force-pushed the event-refactor branch 2 times, most recently from 12ed0b8 to 8d1eb83 Compare April 4, 2015 21:28
@ErisDS ErisDS changed the title [WIP] Refactor sitemaps to use centralised events Refactor sitemaps to use centralised events Apr 4, 2015
@ErisDS ErisDS force-pushed the event-refactor branch 2 times, most recently from 08be1a9 to b18094c Compare April 4, 2015 21:43
@ErisDS
Copy link
Member Author

ErisDS commented Apr 4, 2015

Have updated this with the recommended changes + tests on both the models and the sitemap. Also changed the way the user events were fired and picked up so that invited users are no longer included fixing #5104.

fixes TryGhost#5104, refs TryGhost#4348, TryGhost#2263

- Create a centralised event module
- Hook it up for posts, pages, tags and users
- Use it in sitemaps instead of direct method calls
- Use it for xmlrpc calls
- Check events are fired in model tests
- Update sitemap tests to work with new code
- Fix a bug where invited users were appearing in sitemaps
- Move sitemaps and xmlrpc into a directory together
@ErisDS
Copy link
Member Author

ErisDS commented Apr 5, 2015

I've updated this one again with two additional changes:

  • xmlrpc is now also event driven. This means it will only fire for published posts, whereas before it was also firing for pages, which I think was incorrect
  • xmlrpc and sitemaps have both been moved into /server/data/xml/ as it seems like they ought to live together

@ErisDS ErisDS mentioned this pull request Apr 6, 2015
14 tasks
@jgable
Copy link
Contributor

jgable commented Apr 6, 2015

Sorry, haven't had time to really give this a thorough look through. But, it looks good to me from a cursory glance. Doesn't seem like it could hurt with all the unit tests working and fixes for xmlrpc.

:shipit:

@ErisDS ErisDS added the P2 - High [triage] High priority for immediate patch release label Apr 7, 2015
jaswilli added a commit that referenced this pull request Apr 7, 2015
Refactor sitemaps to use centralised events
@jaswilli jaswilli merged commit 6065703 into TryGhost:master Apr 7, 2015
@ErisDS ErisDS deleted the event-refactor branch June 22, 2015 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 - High [triage] High priority for immediate patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invited users appear in sitemaps
3 participants