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

Add 'title' to collection URLs #2864

Merged
merged 11 commits into from Sep 5, 2014

Conversation

Projects
None yet
6 participants
@kansaichris

Spiritual successor to #2799.

This addresses @parkr's comment from #2799:

I'd like them to map to Liquid variables (i.e. page.name == :name, etc). Ideally, we'd have:

  1. name == File.basename(path, ".*")
  2. title == page.title in Liquid, sluggified

This also addresses @gjtorikian's comment from #2847:

Oh dang, I didn't know :title slugified.

Yeah, on documents would be grand.

Let me know what you think! ❤️

@parkr

This comment has been minimized.

Show comment
Hide comment
@parkr

parkr Sep 1, 2014

Member

This looks great! I'd like to make the handling of slug creation a bit simpler and remove it from the url_placeholders method. Maybe sluggify(name) and sluggify(title) || sluggify(name)?

Member

parkr commented Sep 1, 2014

This looks great! I'd like to make the handling of slug creation a bit simpler and remove it from the url_placeholders method. Maybe sluggify(name) and sluggify(title) || sluggify(name)?

@parkr

This comment has been minimized.

Show comment
Hide comment
@parkr

parkr Sep 1, 2014

Member

Thanks for doing the actual coding here though, it's very appreciated. ❤️

Member

parkr commented Sep 1, 2014

Thanks for doing the actual coding here though, it's very appreciated. ❤️

@gjtorikian

This comment has been minimized.

Show comment
Hide comment
@gjtorikian

gjtorikian Sep 1, 2014

Member

Brilliant. 🎉

Member

gjtorikian commented Sep 1, 2014

Brilliant. 🎉

Show outdated Hide outdated lib/jekyll/document.rb
nil
else
name.downcase.gsub(/[^\w]/, " ").strip.gsub(/\s+/, '-')
end

This comment has been minimized.

@parkr

parkr Sep 1, 2014

Member

What do you think about this simplification?

if name
  name.downcase.gsub # ...
end

Or you can use unless name.nil?. IIRC, methods return nil by default. What do you think?

@parkr

parkr Sep 1, 2014

Member

What do you think about this simplification?

if name
  name.downcase.gsub # ...
end

Or you can use unless name.nil?. IIRC, methods return nil by default. What do you think?

This comment has been minimized.

@parkr

parkr Sep 1, 2014

Member

Also can we use something else besides name? It's pseudo-reserved I think.

@parkr

parkr Sep 1, 2014

Member

Also can we use something else besides name? It's pseudo-reserved I think.

This comment has been minimized.

@alfredxing

alfredxing Sep 2, 2014

Member

I'm beginning to think that a sluggify function would turn out to be immensely useful throughout the rest of the project as well, and since it doesn't really have anything to do with Documents in the first place, would it be better to move it to Utils?

@alfredxing

alfredxing Sep 2, 2014

Member

I'm beginning to think that a sluggify function would turn out to be immensely useful throughout the rest of the project as well, and since it doesn't really have anything to do with Documents in the first place, would it be better to move it to Utils?

This comment has been minimized.

@gjtorikian

gjtorikian Sep 2, 2014

Member

I also think it should be called slugify, FWIW.

@gjtorikian

gjtorikian Sep 2, 2014

Member

I also think it should be called slugify, FWIW.

This comment has been minimized.

@gjtorikian

gjtorikian Sep 2, 2014

Member

Also, I suggest just stealing Rails method. \w is clever, but for truly "pretty" URLs it should be both lowercase and accepting of - or _.

@gjtorikian

gjtorikian Sep 2, 2014

Member

Also, I suggest just stealing Rails method. \w is clever, but for truly "pretty" URLs it should be both lowercase and accepting of - or _.

This comment has been minimized.

@parkr

parkr Sep 2, 2014

Member

👍 for moving it to Utils and for yoinking it from Rails.

@parkr

parkr Sep 2, 2014

Member

👍 for moving it to Utils and for yoinking it from Rails.

This comment has been minimized.

@kansaichris

kansaichris Sep 2, 2014

I agree 💯% and will update this pull request accordingly. 😄

Incidentally, wouldn't it also be useful to expose the slugify method in a Liquid template? If so, should that wait for a separate pull request?

@kansaichris

kansaichris Sep 2, 2014

I agree 💯% and will update this pull request accordingly. 😄

Incidentally, wouldn't it also be useful to expose the slugify method in a Liquid template? If so, should that wait for a separate pull request?

This comment has been minimized.

@parkr

parkr Sep 2, 2014

Member

Thank you!

If you want to add it to Jekyll::Filters, go ahead 😄 I think that would be a valuable add. It can just pass to Jekyll::Utils.slugify.

@parkr

parkr Sep 2, 2014

Member

Thank you!

If you want to add it to Jekyll::Filters, go ahead 😄 I think that would be a valuable add. It can just pass to Jekyll::Utils.slugify.

@parkr

This comment has been minimized.

Show comment
Hide comment
@parkr

parkr Sep 1, 2014

Member

Looking gooooooood.

Member

parkr commented Sep 1, 2014

Looking gooooooood.

@kansaichris

This comment has been minimized.

Show comment
Hide comment
@kansaichris

kansaichris Sep 2, 2014

Thanks for all the feedback, everyone! Let me know if you'd like me to make any more changes—I'd be particularly interested in suggestions for further unit tests. 😄

Thanks for all the feedback, everyone! Let me know if you'd like me to make any more changes—I'd be particularly interested in suggestions for further unit tests. 😄

@kansaichris

This comment has been minimized.

Show comment
Hide comment
@kansaichris

kansaichris Sep 4, 2014

@parkr Does this look good to merge?

@parkr Does this look good to merge?

@parkr parkr self-assigned this Sep 4, 2014

@parkr

This comment has been minimized.

Show comment
Hide comment
@parkr

parkr Sep 4, 2014

Member

I'll take a look tonight or (more realistically) in the morning tomorrow. Sorry for the delay!

Thanks for all your contributions to Jekyll!!!!

Member

parkr commented Sep 4, 2014

I'll take a look tonight or (more realistically) in the morning tomorrow. Sorry for the delay!

Thanks for all your contributions to Jekyll!!!!

@kansaichris

This comment has been minimized.

Show comment
Hide comment
@kansaichris

kansaichris Sep 4, 2014

My pleasure! 😄 Just wanted to make sure that I didn't forget anything here.

My pleasure! 😄 Just wanted to make sure that I didn't forget anything here.

# Replace each non-alphanumeric character sequence with a hyphen
slug = string.gsub(/[^a-z0-9]+/i, '-')
# Remove leading/trailing hyphen
slug.gsub!(/^\-|\-$/i, '')

This comment has been minimized.

@parkr

parkr Sep 4, 2014

Member

is this ensuring that there are no double-hyphens? i.e. no "this is my !#-fave blogs" !~> "this-is-my--fave-blogs?

@parkr

parkr Sep 4, 2014

Member

is this ensuring that there are no double-hyphens? i.e. no "this is my !#-fave blogs" !~> "this-is-my--fave-blogs?

This comment has been minimized.

@gjtorikian

gjtorikian Sep 4, 2014

Member

No, it ensures there's no starting or ending hyphen: "¡Hola!" !~> "hola".

@gjtorikian

gjtorikian Sep 4, 2014

Member

No, it ensures there's no starting or ending hyphen: "¡Hola!" !~> "hola".

This comment has been minimized.

@kansaichris

kansaichris Sep 4, 2014

What @gjtorikian said. 😄

Actually, the first regex ensures that there are no double hyphens:

string.gsub(/[^a-z0-9]+/i, '-')

Is this the desired behavior, or should we allow double hyphens in some situations?

@kansaichris

kansaichris Sep 4, 2014

What @gjtorikian said. 😄

Actually, the first regex ensures that there are no double hyphens:

string.gsub(/[^a-z0-9]+/i, '-')

Is this the desired behavior, or should we allow double hyphens in some situations?

This comment has been minimized.

@gjtorikian

gjtorikian Sep 5, 2014

Member

I've never seen a double hyphen and though "That's a good use of a double hyphen in a URL!" 😸

@gjtorikian

gjtorikian Sep 5, 2014

Member

I've never seen a double hyphen and though "That's a good use of a double hyphen in a URL!" 😸

This comment has been minimized.

@parkr

parkr Sep 5, 2014

Member

No, it ensures there's no starting or ending hyphen

Merp, yes, I meant to refer to the entire method.

the first regex ensures that there are no double hyphens

Great! Then we're good to go.

@parkr

parkr Sep 5, 2014

Member

No, it ensures there's no starting or ending hyphen

Merp, yes, I meant to refer to the entire method.

the first regex ensures that there are no double hyphens

Great! Then we're good to go.

@parkr

This comment has been minimized.

Show comment
Hide comment
@parkr

parkr Sep 4, 2014

Member

LGTM excepting the above comment about double-hyphens.

Member

parkr commented Sep 4, 2014

LGTM excepting the above comment about double-hyphens.

@parkr parkr merged commit 58a7691 into jekyll:master Sep 5, 2014

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details

parkr added a commit that referenced this pull request Sep 5, 2014

@parkr

This comment has been minimized.

Show comment
Hide comment
@parkr

parkr Sep 5, 2014

Member

Thanks for all your hard work, @kansaichris! I think I'll try to wrap up a 2.4.0 release of Jekyll sometime this weekend or on Monday.

Member

parkr commented Sep 5, 2014

Thanks for all your hard work, @kansaichris! I think I'll try to wrap up a 2.4.0 release of Jekyll sometime this weekend or on Monday.

@gjtorikian

This comment has been minimized.

Show comment
Hide comment
@gjtorikian

gjtorikian Sep 5, 2014

Member

@parkr Humble ask if we can work on tagging #2870 into 2.4.0 too? We're working on some internal shtuff that depends on these two pieces. Would prefer to talk offline because of sensitive internally stuff about this. 😀

Member

gjtorikian commented Sep 5, 2014

@parkr Humble ask if we can work on tagging #2870 into 2.4.0 too? We're working on some internal shtuff that depends on these two pieces. Would prefer to talk offline because of sensitive internally stuff about this. 😀

@kansaichris kansaichris deleted the kansaichris:add-title-to-collection-urls branch Sep 5, 2014

@kansaichris

This comment has been minimized.

Show comment
Hide comment

🎉

@hazzik

This comment has been minimized.

Show comment
Hide comment
@hazzik

hazzik Oct 1, 2014

Unfortunately, dear english-speaker contributors, there a lot more letters exist in the world other than a-z.

hazzik commented on 4adc35a Oct 1, 2014

Unfortunately, dear english-speaker contributors, there a lot more letters exist in the world other than a-z.

This comment has been minimized.

Show comment
Hide comment
@parkr

parkr Oct 1, 2014

Member

@hazzik please open an issue and mention kansaichris. thanks!

Member

parkr replied Oct 1, 2014

@hazzik please open an issue and mention kansaichris. thanks!

This comment has been minimized.

Show comment
Hide comment

Done #2965

parkr added a commit that referenced this pull request Jan 30, 2015

The :title URL placeholder for collections should be the filename slug.
This mimicks posts most closely. It can be overridden by the
YAML front matter.

Undoes some of #2864.

@jekyll jekyll locked and limited conversation to collaborators Feb 27, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.