Skip to content

Generate categories.json manifest file #152

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

Closed
wants to merge 0 commits into from

Conversation

rxaviers
Copy link
Member

Create manifest grunt task. It generates the categories.json manifest file. This JSON file has a list of all categories and its infos, which is used by DownloadBuilder to expand a category into its corresponding pages and posts.

OBS: remember, this needs to be cherry-picked into 1-x branches.

@rxaviers
Copy link
Member Author

This needs to be cherry-picked into 1-x branches...

@rxaviers
Copy link
Member Author

@scottgonzalez, I didnt use grunt-wordpress in this change. Because, I still wanted to encapsulate the logic to read the local categories.xml, which required xml parser anyway.

I think this implementation is pretty straightforward. But, if you still think we should use grunt-wordpress tasks to make it smaller. Please, just let me know.

@scottgonzalez
Copy link
Member

You should definitely use grunt-wordpress. For the categories, you should be reading from /dist/wordpress/taxonomies.json. You'll need to run grunt build-xml-categories to generate that file.

@rxaviers
Copy link
Member Author

Right. Updated.

@scottgonzalez
Copy link
Member

I'm not sure that this Category organization is necessary. I would expect this code to just walk the posts and build the lists in place, rather than storing off a flat list of posts and walking the list every time a category is requested. Without a Category object, this will probably be easier to read and half the size. At that point, it should just go directly into grunt.js.

@rxaviers
Copy link
Member Author

rxaviers commented Jul 1, 2013

Is that what you mean?

var categories,
categoryPosts = {};

categories = require( "../" + grunt.config( "wordpress.dir" ) + "/taxonomies" ).category.map(function( category ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this use "../" but the call to wordpress-walk-posts doesn't?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be clearer if you did the assignment, then on a separate line used a forEach(). You're not actually mapping here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, I am mapping. Although, I can split the require from the map if you wish.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note I am augmenting category object with posts Array.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this use "../" but the call to wordpress-walk-posts doesn't?

This is require, used to load the JSON. The other one is grunt.helper.

@scottgonzalez
Copy link
Member

Please move this into grunt.js and remove the tasks directory.

return category;
});

// Get all posts' manifest in advance
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is confusing. Perhaps it's no longer relevant from the changes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ops pardom

@scottgonzalez
Copy link
Member

One spacing issue, but other than that, this looks good.

@rxaviers
Copy link
Member Author

rxaviers commented Jul 1, 2013

Landed by 21703a3

@rxaviers rxaviers closed this Jul 1, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants