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

[layout] Move layout logic to ruby plugin #2226

Closed
wants to merge 1 commit into from
Closed

Conversation

captn3m0
Copy link
Member

@captn3m0 captn3m0 commented Dec 31, 2022

We enrich the data available to liquid, and avoid complex logic in Liquid this way.

Still WIP, will make columns a bit more modular, with our sane defaults. Will avoid any mass changes to product front-matter in this PR, and retain compatibility for now. We can take those up in a later PR, since that would include schema changes and require more discussion.

Intent is to use the plugin for any complex logic:

  1. Deciding colors of columns
  2. Column ordering
  3. Default values of columns
  4. Template rendering for some columns
  5. Parse out the product description

Output of the above (such as rendered templates, description) should be available to the API directly as well.

We enrich the data available to liquid, and avoid complex
logic in Liquid this way.
@captn3m0 captn3m0 added the enhancement New feature or request label Dec 31, 2022
@captn3m0 captn3m0 self-assigned this Dec 31, 2022
field='eol'
enabled=page.eolColumn
r=r
%}

{% if page.releaseColumn != false %}
<td {% if diff <= 0 %} class = "txt-linethrough" {% endif %} > <!-- if the support finished add txt-linethrough class -->
Copy link
Member Author

Choose a reason for hiding this comment

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

This is currently broken, since diff is unavailable now.

@captn3m0 captn3m0 mentioned this pull request Dec 31, 2022
Copy link
Member

@marcwrobel marcwrobel left a comment

Choose a reason for hiding this comment

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

Looks promising !

_config.yml Show resolved Hide resolved
columns:
# The spaces before Yes/No
# are intentional to avoid the
# YAML norway problem
Copy link
Member

Choose a reason for hiding this comment

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

A link to https://www.bram.us/2022/01/11/yaml-the-norway-problem/ could be useful for those who don't know what is the "norway problem" ;)

@marcwrobel
Copy link
Member

Do you need help on this one @captn3m0 ?

@marcwrobel marcwrobel mentioned this pull request Jan 1, 2023
4 tasks
@captn3m0
Copy link
Member Author

captn3m0 commented Jan 2, 2023

I'd like feedback on the schema for the column layouts. For this PR focusing on keeping compatibility, but what will work better for all usecases (including tables in article text)?

Setting default values via _config.yml was helpful, but I'm not happy with the code complexity - it should be simpler to write this in Ruby, not harder.

@marcwrobel
Copy link
Member

I'd like feedback on the schema for the column layouts. For this PR focusing on keeping compatibility, but what will work better for all usecases (including tables in article text)?

What do you mean by "the schema for the column layouts" ?

Setting default values via _config.yml was helpful, but I'm not happy with the code complexity - it should be simpler to write this in Ruby, not harder.

Unfortunately sometimes complexity cannot be avoided. During my work on #2229 I also took a look at the product template. Here are the things I think that make it more complex :

  • The "Ends / Ended" prefix in the support / eol column. Because of this there is two calculus to be done : one for the color and the other for the text. This means in the template there are a lot of if / else logic. Because this information is already given to the user by the column title and the color, I have chosen to get rid of it in table.html for the time being (860fb14).
  • The difference between support and eol when only boolean are used. For support color must be red if the value is false, for eol this is the inverse: it must be green if eol is false (this is the same for discontinued). It would be easier to make something more generic if support was endOfActiveSupport.
  • The small rendering differences for the Latest column (if the cycle reached EOL the link is not added and the text is striked).

Taken separately those a small things, but it makes it harder to make things more generic (for instance by using table.html to generate the main table).

marcwrobel added a commit that referenced this pull request Jan 3, 2023
With this approach, enriched data is only computed once and available both in layouts and in plugins (such as the APIv1 plugin - see #2080).
This make things easier in both places.

validate.py now checks if releaseLabel is a string.

This PR relates to (and conflicts with) #2226.
marcwrobel added a commit that referenced this pull request Jan 4, 2023
With this approach, enriched data is only computed once and available both in layouts and in plugins (such as the APIv1 plugin - see #2080).
This make things easier in both places.

validate.py now checks if releaseLabel is a string.

This PR relates to (and conflicts with) #2226.
marcwrobel added a commit that referenced this pull request Jan 4, 2023
With this approach, enriched data is only computed once and available both in layouts and in plugins (such as the APIv1 plugin - see #2080).
This make things easier in both places.

validate.py now checks if releaseLabel is a string.

This PR relates to (and conflicts with) #2226.
r['text'][x] = defaults['on-false']['text']
elsif r[x].is_a? Date
diff = (r[x]-today).to_i
# If EOL is after 6 months
Copy link
Member

Choose a reason for hiding this comment

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

Current is ~4 months (I used 120 days in #2229).

page['releases'].each do |r|
r['text'] = {}
r['colors'] = {}
['eol', 'support'].each do |x|
Copy link
Member

Choose a reason for hiding this comment

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

I am not fan of computing colors in the plugin: colors must also be computed for values other than eol and support such as discontinued or custom columns.

IMHO it will be more reusable if it's implemented in a filter such as in #2229.

marcwrobel added a commit that referenced this pull request Jan 4, 2023
With this approach, enriched data is only computed once and available both in layouts and in plugins (such as the APIv1 plugin - see #2080).
This make things easier in both places.

validate.py now checks if releaseLabel is a string.

This PR relates to (and conflicts with) #2226.
marcwrobel added a commit that referenced this pull request Jan 12, 2023
With this approach, enriched data is only computed once and available both in layouts and in plugins (such as the APIv1 plugin - see #2080).
This make things easier in both places.

validate.py now checks if releaseLabel is a string.

This PR relates to (and conflicts with) #2226.
@marcwrobel
Copy link
Member

@captn3m0 should we keep this PR open ?

1 similar comment
@marcwrobel
Copy link
Member

@captn3m0 should we keep this PR open ?

@marcwrobel
Copy link
Member

Closing the PR, as it doesn't seem likely it will be revived. @captn3m0 feel free to drop the branch if there is nothing useful in it.

@marcwrobel marcwrobel closed this Jul 22, 2023
@marcwrobel marcwrobel deleted the layout-cleanup branch December 9, 2024 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants