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

Fix case-sensitive categories will override each other. #1412

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hSATAC
Copy link
Contributor

@hSATAC hSATAC commented Nov 6, 2013

Let's say I have 2 categories Git and git.

For category links, they were generated by category.to_url so they will link to the same url categories/git

But in plugins/category_generator.rb, they were treated like different categories, so one of them will be overridden by the other. I think we should treat these as the same category. After all, they're generated to the same folder, and linked to the same url.

@parkr
Copy link
Collaborator

parkr commented Nov 6, 2013

Looks like old, non-downcase categories will be saved in the new Hash. Is that intended?

@hSATAC
Copy link
Contributor Author

hSATAC commented Nov 6, 2013

Which lines are you referring to?

Basically this changes did two things:

  1. downcase the categories and loop them into write_category_index
  2. Method swizzling site_payload, downcase and merge categories and their posts for CategoryIndex#render

@@ -127,6 +127,26 @@ def write_category_indexes
end
end

# Convert categories into downcase keys to solve issue that 'Git' and 'git' will override each other
alias orig_site_payload site_payload
def site_payload
Copy link

Choose a reason for hiding this comment

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

This seems rather verbose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you suggesting removing the comment?

Copy link

Choose a reason for hiding this comment

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

No, I was refering to the code below, sorry -- It just seems like a lot of intermediate assignments. The comment above is actually great as it gives the reason for this being there.

@parkr
Copy link
Collaborator

parkr commented Nov 13, 2013

I've had people complain to me about downcasing of categories. For example, I really want the category Cornell to have that capital C, but maybe for git I don't care about case. To me, the user should be managing categories and we shouldn't necessarily be saying, "look, I don't care about the case in your categories, it's all the same to me".

@hSATAC
Copy link
Contributor Author

hSATAC commented Nov 13, 2013

@parkr I agree with your point of view, but the problem here is that, there are 2 parts of this thing: links and folders. This plugin downcase links but not the folders. What I am trying to do here is make this consistent - either downcase all of them or just leave them alone.

@parkr
Copy link
Collaborator

parkr commented Nov 14, 2013

@hSATAC That makes sense. Won't it break links on current sites?

@hSATAC
Copy link
Contributor Author

hSATAC commented Nov 14, 2013

AFAIK it won't.

The links was generate by category.to_url, which I did not change. And all the strings after to_url will be downcased Git => git, git => git. This is exactly what this PR is for.

see:
https://github.com/hSATAC/octopress/blob/07e160580de7cba65ac494169dc5cd6c8ebb3fbb/plugins/category_generator.rb#L195

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

Successfully merging this pull request may close these issues.

None yet

3 participants