-
Notifications
You must be signed in to change notification settings - Fork 767
Table of Contents Component #2030
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
Conversation
|
This pull request introduces 1 alert when merging caa947a into 1b0503c - view on LGTM.com new alerts:
|
|
This pull request introduces 1 alert when merging d4750e5 into 7434de3 - view on LGTM.com new alerts:
|
Codecov Report
@@ Coverage Diff @@
## main #2030 +/- ##
============================================
+ Coverage 86.60% 86.77% +0.16%
- Complexity 2313 2375 +62
============================================
Files 210 214 +4
Lines 6161 6361 +200
Branches 931 964 +33
============================================
+ Hits 5336 5520 +184
- Misses 329 336 +7
- Partials 496 505 +9
Continue to review full report at Codecov.
|
|
This pull request introduces 1 alert when merging 916d303 into 0767db9 - view on LGTM.com new alerts:
|
6308e61 to
df952c5
Compare
|
This pull request introduces 1 alert when merging 530f8a1 into 0767db9 - view on LGTM.com new alerts:
|
b5cfed0 to
b59c166
Compare
|
This pull request introduces 1 alert when merging b59c166 into f4c2da2 - view on LGTM.com new alerts:
|
| restrictStopLevel = currentStyle.get(PN_RESTRICT_STOP_LEVEL, String.class); | ||
| includeClasses = currentStyle.get(PN_INCLUDE_CLASSES, String[].class); | ||
| ignoreClasses = currentStyle.get(PN_IGNORE_CLASSES, String[].class); | ||
| slingHttpServletRequest.setAttribute("contains-table-of-contents", true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefix with cmp to avoid clashes with custom names: cmp:contains-table-of-contents
...re/src/main/java/com/adobe/cq/wcm/core/components/internal/servlets/CharResponseWrapper.java
Show resolved
Hide resolved
...re/src/main/java/com/adobe/cq/wcm/core/components/internal/servlets/CharResponseWrapper.java
Show resolved
Hide resolved
...re/src/main/java/com/adobe/cq/wcm/core/components/internal/servlets/CharResponseWrapper.java
Show resolved
Hide resolved
.../src/main/java/com/adobe/cq/wcm/core/components/internal/servlets/TableOfContentsFilter.java
Show resolved
Hide resolved
.../src/main/java/com/adobe/cq/wcm/core/components/internal/servlets/TableOfContentsFilter.java
Outdated
Show resolved
Hide resolved
.../src/main/java/com/adobe/cq/wcm/core/components/internal/servlets/TableOfContentsFilter.java
Show resolved
Hide resolved
.../src/main/java/com/adobe/cq/wcm/core/components/internal/servlets/TableOfContentsFilter.java
Show resolved
Hide resolved
|
It would be nice to add a few Selenium tests. |
vladbailescu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add a README file in the version root folder, similar to other components!
| CharResponseWrapper responseWrapper = new CharResponseWrapper((HttpServletResponseWrapper) response); | ||
| chain.doFilter(request, responseWrapper); | ||
| String originalContent = responseWrapper.toString(); | ||
| Boolean containsTableOfContents = (Boolean) request.getAttribute("contains-table-of-contents"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please isolate all "magic strings" into constants. Also, for Core Components we generally use BEM-style classes (see https://github.com/adobe/aem-core-wcm-components/wiki/css-coding-conventions) so this class would be best refactored to cmp-toc__placeholder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I understand to use the BEM style for all the CSS classnames used in this PR, this one is not a CSS class but a request attribute. Do we use the same style for request attributes as well or just prepend it with cmp: as pointed by @jckautzmann here?
| * @since com.adobe.cq.wcm.core.components.models.tableofcontents 1.0 | ||
| */ | ||
| default String getListType() { | ||
| return "unordered"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please define all possible values as constants in this class (or an enumeration)!
...rc/content/jcr_root/apps/core/wcm/components/tableofcontents/v1/tableofcontents/.content.xml
Show resolved
Hide resolved
| import java.io.CharArrayWriter; | ||
| import java.io.PrintWriter; | ||
|
|
||
| public class CharResponseWrapper extends HttpServletResponseWrapper { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this work across multiple encodings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wrapper just overrides the writer of the original response. Rest everything is handled by the original response object.
CharResponseWrapper extends HttpServletResponseWrapper which further extends ServletResponseWrapper which has the method setCharacterEncoding.
| com.adobe.cq.commerce.*;resolution:=optional, | ||
| com.adobe.aem.wcm.seo.*;resolution:=optional, | ||
| javax.annotation;version=0.0.0, | ||
| javax.annotation.meta;resolution:=optional, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, only javax.annotation.* is used in this repo and only javax.annotation.PostConstruct is used in this PR.
|
This pull request introduces 1 alert when merging 5fee6ff into e114d7c - view on LGTM.com new alerts:
|
|
Please add a README for this component. |
|
Please add a page to the component library with various different configurations of the TOC. |
...jcr_root/apps/core/wcm/components/tableofcontents/v1/tableofcontents/_cq_dialog/.content.xml
Show resolved
Hide resolved
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/--> | ||
| <div data-sly-use.toc="com.adobe.cq.wcm.core.components.models.TableOfContents" | ||
| data-sly-use.component="com.adobe.cq.wcm.core.components.models.Component" | ||
| class = "table-of-contents-placeholder" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See Vlad's remark above: the class name should be cmp-toc__placeholder
| data-sly-use.component="com.adobe.cq.wcm.core.components.models.Component" | ||
| class = "table-of-contents-placeholder" | ||
| id = "${component.id}" | ||
| data-list-type = "${toc.listType}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefix the data attribute with cmp-toc-:
data-cmp-toc-list-type
data-cmp-toc-start-level
data-cmp-toc-include-classes
data-cmp-toc-ignore-classes
Duplicagte IDs, small letters in JSON model
@gabrielwalt All improvements except the one mentioned above are done. I'll be back working on this item after my next week's PTO. cc - @jckautzmann , @vladbailescu |
|
@vsarya I noticed a shift in the customID index. If you have 3 titles with the same text, e.g. |
@jckautzmann Just pushed the required changes. |
|
@vsarya Please fix the build error due to the baseline error: |
|
@vsarya What is the status with the broken docs links (Github + Adobe)? |
|
@jckautzmann The sonar check on the PR is failing due to duplicate lines of code in |
# Conflicts: # examples/ui.content/src/content/jcr_root/content/core-components-examples/library/core-structure/.content.xml
@jckautzmann I had already created a CQDOC issue for the same as discussed in our weekly meetings - https://jira.corp.adobe.com/browse/CQDOC-18998 |
|
SonarCloud Quality Gate failed.
|
|
Thx @vsarya for implementing this TOC component! |
I enjoyed a lot working on it and learned a lot about core components and request filters during its development. Thanks a lot @jckautzmann and @vladbailescu for guiding me throughout the whole development phase and while doing the POC. Thank you Varun and @gabrielwalt for giving me the opportunity to work on such an interesting component. |
| chain.doFilter(request, responseWrapper); | ||
| String originalContent = responseWrapper.toString(); | ||
| Boolean containsTableOfContents = (Boolean) request.getAttribute(TableOfContentsImpl.TOC_REQUEST_ATTR_FLAG); | ||
| if (responseWrapper.getContentType().contains("text/html") && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jckautzmann we observed NPE in this line during our on-call shift
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grubyak thx for your feedback. Could you please create a ticket describing the issue and how it can be reproduced? Thx!










Uh oh!
There was an error while loading. Please reload this page.