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

Cleanup post_author logic #113

Merged
merged 3 commits into from
May 9, 2016
Merged

Cleanup post_author logic #113

merged 3 commits into from
May 9, 2016

Conversation

pathawks
Copy link
Member

As pointed out by @GarthDB in #111, the way we were doing it previously was a mess that camouflaged bugs. This builds on PR, further simplifying things and hopefully giving bugs fewer places to hide.

@GarthDB
Copy link
Contributor

GarthDB commented Apr 26, 2016

Much cleaner. 👍

@pathawks
Copy link
Member Author

Could I get an extra set of eyes from @parkr or @benbalter please?

@@ -53,26 +53,12 @@
<content type="html" xml:base="{{ post.url | prepend: url_base | xml_escape }}">{{ post.content | strip | xml_escape }}</content>

{% assign post_author = post.author | default: post.authors[0] | default: site.author %}
{% assign post_author_email = false %}
{% assign post_author_uri = false %}
{% assign post_author = site.data.authors[post_author] | default: post_author %}
Copy link
Member

Choose a reason for hiding this comment

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

Should this be post_author_data not to be confused with post_author which is just the name?

Copy link
Member Author

@pathawks pathawks Apr 27, 2016

Choose a reason for hiding this comment

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

post.author can be a string or a hash. It's kind of a mess ¯_(ツ)_/¯

If we changed this line, we would also need to change the line above it to post_author_data, but then it would seem weird to {% assign post_author_data = site.data.authors[post_author_data] | default: post_author_data %}

I am open to suggestion though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe if it is just a string, and not a reference, we assign it to author name.

Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering if, between this and Jekyll SEO Tag, it may make sense to have a shared jekyll-author gem, that would never be included directly (I guess it could?), but would handle author being a string, a hash, or a ref to _data, and would always return an object, maybe in Rubyland?

Copy link
Contributor

Choose a reason for hiding this comment

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

@benbalter that's a great idea, but it would probably be best to start by releasing a patch that fixes the documented functionality first.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe if it is just a string, and not a reference, we assign it to author name.

I don't know of a way in Liquid to see what type a variable is.

it may make sense to have a shared jekyll-author gem

Totally agree, but as @GarthDB mentioned, let's get this bug fix out first.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm on the road so I can't write out a full example, but just checking if the string is a key of the authors object and has a value, otherwise assume the string is a name.

Copy link
Contributor

Choose a reason for hiding this comment

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

but it would probably be best to start by releasing a patch that fixes the documented functionality first.

Completely agree.

@parkr
Copy link
Member

parkr commented Apr 27, 2016

Excellent work! 👍

{% assign post_author_email = false %}
{% assign post_author_uri = false %}
{% assign post_author = site.data.authors[post_author] | default: post_author %}
{% assign post_author_email = post_author.email | default: false %}
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the rationale for having a false default, rather than nil?

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right, nil makes more sense.

{% assign post_author = site.data.authors[post_author] | default: post_author %}
{% assign post_author_email = post_author.email | default: nil %}
{% assign post_author_uri = post_author.uri | default: nil %}
{% assign post_author_name = post_author.name | default: post_author %}
Copy link
Member Author

@pathawks pathawks Apr 29, 2016

Choose a reason for hiding this comment

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

Does this make more sense? (See also line 63)

Copy link
Contributor

Choose a reason for hiding this comment

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

How does the behavior change if you remove the | default: nil?

Copy link
Member Author

Choose a reason for hiding this comment

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

The behavior is the same either way, but I feel like including some sort of default is an acknowledgment that this may not be set, and that is ok.

If you do not think it makes the code easier to follow, I can remove it.

Copy link
Contributor

Choose a reason for hiding this comment

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

The behavior is the same either way, but I feel like including some sort of default is an acknowledgment that this may not be set, and that is ok.

👍

@GarthDB
Copy link
Contributor

GarthDB commented May 8, 2016

@parkr @pathawks @benbalter while waiting for this I decided to work on a jekyll-authors plugin

It should provide what would be needed by jekyll-feed and jekyll-seo-tag in the form of Jekyll hooks.

Is this something you'd be interested in using? If so, I'm happy to transfer the repo if needed and make pull requests to the 2 plugins.

I did find out that the gem name jekyll-authors is already taken by a gem that generates author pages. Not sure how we would proceed to name and publish it.

@pathawks
Copy link
Member Author

pathawks commented May 8, 2016

Is this PR good to go, or is there still something left to modify?

@benbalter
Copy link
Contributor

Is this PR good to go, or is there still something left to modify?

One style question, otherwise, 👍 (and agree we should merge this before looking into a more robust solution).

while waiting for this I decided to work on a jekyll-authors plugin

That's awesome. Thanks @GarthDB. One thing to note, that moves things from Liquid to Ruby, which isn't necessarily a bad thing, but makes things a bit trickier in terms of security.

@GarthDB
Copy link
Contributor

GarthDB commented May 9, 2016

@benbalter is there a more secure way to do it that both jekyll-seo-tag and jekyll-feed could use?

I figured jekyll hooks would be the best way to prep the data before either could use it.

@pathawks
Copy link
Member Author

pathawks commented May 9, 2016

@jekyllbot: merge

@jekyllbot jekyllbot merged commit 6e52b1a into master May 9, 2016
@jekyllbot jekyllbot deleted the pr/post_author branch May 9, 2016 17:37
jekyllbot added a commit that referenced this pull request May 9, 2016
@GarthDB
Copy link
Contributor

GarthDB commented May 9, 2016

Thanks for the work @pathawks

@jekyll jekyll locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants