You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2020/03/31 09:01:37 UTC

[GitHub] [camel-website] AemieJ opened a new pull request #295: Custom Pagination within Blog Section

AemieJ opened a new pull request #295: Custom Pagination within Blog Section
URL: https://github.com/apache/camel-website/pull/295
 
 
   I replaced the template of the pagination of Hugo with custom pagination. In this custom pagination, it has the following properties: 
   
   1. Show **<<<<** shortcut if not 1st page
   
   ![page-start](https://user-images.githubusercontent.com/44139348/78007688-3d3fd380-735c-11ea-904a-95cf06760502.png)
   
   2. Show **>>>>** shortcut if not the last page.
   
   ![page-end](https://user-images.githubusercontent.com/44139348/78007531-0bc70800-735c-11ea-824b-19a3254d964f.png)
   
   3. Show **<<** if there is a previous page
   4. Show **>>** if there is the next page
   5. Show current page number with the previous 2 pages and next 2 pages. Skip other pages with placeholder ...
   
   ![page-middle](https://user-images.githubusercontent.com/44139348/78007544-0f5a8f00-735c-11ea-9c53-deb9e589f022.png)
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-website] zregvart merged pull request #295: Custom Pagination within Blog Section

Posted by GitBox <gi...@apache.org>.
zregvart merged pull request #295: Custom Pagination within Blog Section
URL: https://github.com/apache/camel-website/pull/295
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-website] zregvart commented on issue #295: Custom Pagination within Blog Section

Posted by GitBox <gi...@apache.org>.
zregvart commented on issue #295: Custom Pagination within Blog Section
URL: https://github.com/apache/camel-website/pull/295#issuecomment-607977980
 
 
   Thanks!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-website] AemieJ commented on a change in pull request #295: Custom Pagination within Blog Section

Posted by GitBox <gi...@apache.org>.
AemieJ commented on a change in pull request #295: Custom Pagination within Blog Section
URL: https://github.com/apache/camel-website/pull/295#discussion_r401704618
 
 

 ##########
 File path: layouts/blog/list.html
 ##########
 @@ -15,9 +15,46 @@ <h3>Categories</h3>
             {{ range $pages }}
                 {{ .Render "summary" }}
             {{ end }}
-            {{ template "_internal/pagination.html" . }}
+            
+            {{ $page := .Paginator }}
+            {{ if gt $page.TotalPages 1 }}
+            {{ $.Scratch.Set "dot_rendered" false }}
+            <nav aria-label="page navigation">
+                <ul class="pagination">
+                    <!-- Don't show on 1st and 2nd page -->
+                    {{ if and (ne $page.PageNumber 1) }}
+                    <li class="page-item"><a href="{{ $page.First.URL }}" rel="first" class="page-link">««</a></li>
+                    {{ end }}
+
+                    {{ if $page.HasPrev  }}
+                    <li class="page-item"><a href="{{ $page.Prev.URL }}" rel="prev" class="page-link">«</a></li>
+                    {{ end }}
+
+                    {{ range $page.Pagers }}
+                        {{ if eq . $page }} <!-- Current Page -->
+                        <li class="page-item active"><a href="{{ .URL }}" class="page-link">{{ .PageNumber }}</a></li>
+                        {{ else if and (ge .PageNumber (sub $page.PageNumber 2)) (le .PageNumber (add $page.PageNumber 2)) }}
+                        {{ $.Scratch.Set "dot_rendered" false }} <!-- Render prev 2 page and next 2 pages -->
+                        <li class="page-item"><a href="{{ .URL }}" class="page-link">{{ .PageNumber }}</a></li>
+                        {{ else if eq ($.Scratch.Get "dot_rendered") false }} <!-- render skip pages -->
+                        {{ $.Scratch.Set "dot_rendered" true }}
+                        <li class="page-item disabled"><a class="page-link">...</a></li>
+                        {{ end }}
+                    {{ end }}
+
+                    {{ if $page.HasNext }}
+                    <li class="page-item"><a href="{{ $page.Next.URL }}" rel="next" class="page-link">»</a></li>
+                    {{ end }}
+
+                    <!-- Don't show on last and 2nd last page -->
+                    {{ if and (ne $page.PageNumber $page.TotalPages) }}
+                    <li class="page-item"><a href="{{ $page.Last.URL }}" rel="last" class="page-link">»»</a></li>
+                    {{ end }}
+                </ul>
+            </nav>
+            {{ end }}
 
 Review comment:
   Alright, I will make use of this and do the required changes.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-website] zregvart commented on a change in pull request #295: Custom Pagination within Blog Section

Posted by GitBox <gi...@apache.org>.
zregvart commented on a change in pull request #295: Custom Pagination within Blog Section
URL: https://github.com/apache/camel-website/pull/295#discussion_r401449314
 
 

 ##########
 File path: layouts/blog/list.html
 ##########
 @@ -15,9 +15,46 @@ <h3>Categories</h3>
             {{ range $pages }}
                 {{ .Render "summary" }}
             {{ end }}
-            {{ template "_internal/pagination.html" . }}
+            
+            {{ $page := .Paginator }}
+            {{ if gt $page.TotalPages 1 }}
+            {{ $.Scratch.Set "dot_rendered" false }}
+            <nav aria-label="page navigation">
+                <ul class="pagination">
+                    <!-- Don't show on 1st and 2nd page -->
 
 Review comment:
   Use [Hugo comments](https://gohugo.io/templates/introduction/#comments), no use of this in the rendered markup

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-website] zregvart commented on a change in pull request #295: Custom Pagination within Blog Section

Posted by GitBox <gi...@apache.org>.
zregvart commented on a change in pull request #295: Custom Pagination within Blog Section
URL: https://github.com/apache/camel-website/pull/295#discussion_r401454468
 
 

 ##########
 File path: layouts/blog/list.html
 ##########
 @@ -15,9 +15,46 @@ <h3>Categories</h3>
             {{ range $pages }}
                 {{ .Render "summary" }}
             {{ end }}
-            {{ template "_internal/pagination.html" . }}
+            
+            {{ $page := .Paginator }}
+            {{ if gt $page.TotalPages 1 }}
+            {{ $.Scratch.Set "dot_rendered" false }}
+            <nav aria-label="page navigation">
+                <ul class="pagination">
+                    <!-- Don't show on 1st and 2nd page -->
+                    {{ if and (ne $page.PageNumber 1) }}
+                    <li class="page-item"><a href="{{ $page.First.URL }}" rel="first" class="page-link">««</a></li>
+                    {{ end }}
+
+                    {{ if $page.HasPrev  }}
+                    <li class="page-item"><a href="{{ $page.Prev.URL }}" rel="prev" class="page-link">«</a></li>
+                    {{ end }}
+
+                    {{ range $page.Pagers }}
+                        {{ if eq . $page }} <!-- Current Page -->
+                        <li class="page-item active"><a href="{{ .URL }}" class="page-link">{{ .PageNumber }}</a></li>
+                        {{ else if and (ge .PageNumber (sub $page.PageNumber 2)) (le .PageNumber (add $page.PageNumber 2)) }}
+                        {{ $.Scratch.Set "dot_rendered" false }} <!-- Render prev 2 page and next 2 pages -->
+                        <li class="page-item"><a href="{{ .URL }}" class="page-link">{{ .PageNumber }}</a></li>
+                        {{ else if eq ($.Scratch.Get "dot_rendered") false }} <!-- render skip pages -->
+                        {{ $.Scratch.Set "dot_rendered" true }}
+                        <li class="page-item disabled"><a class="page-link">...</a></li>
+                        {{ end }}
+                    {{ end }}
+
+                    {{ if $page.HasNext }}
+                    <li class="page-item"><a href="{{ $page.Next.URL }}" rel="next" class="page-link">»</a></li>
+                    {{ end }}
+
+                    <!-- Don't show on last and 2nd last page -->
+                    {{ if and (ne $page.PageNumber $page.TotalPages) }}
+                    <li class="page-item"><a href="{{ $page.Last.URL }}" rel="last" class="page-link">»»</a></li>
+                    {{ end }}
+                </ul>
+            </nav>
+            {{ end }}
 
 Review comment:
   1. We're missing `aria-label` in `a` tags. Examine the [default template](https://github.com/gohugoio/hugo/blob/master/tpl/tplimpl/embedded/templates/pagination.html).
   2. Use `.Last` as `.First` above
   3. Avoid using scratch if possible, use explicit conditions or local variables instead (consult the internal Hugo template)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-website] zregvart commented on a change in pull request #295: Custom Pagination within Blog Section

Posted by GitBox <gi...@apache.org>.
zregvart commented on a change in pull request #295: Custom Pagination within Blog Section
URL: https://github.com/apache/camel-website/pull/295#discussion_r401448577
 
 

 ##########
 File path: layouts/blog/list.html
 ##########
 @@ -15,9 +15,46 @@ <h3>Categories</h3>
             {{ range $pages }}
                 {{ .Render "summary" }}
             {{ end }}
-            {{ template "_internal/pagination.html" . }}
+            
+            {{ $page := .Paginator }}
+            {{ if gt $page.TotalPages 1 }}
+            {{ $.Scratch.Set "dot_rendered" false }}
+            <nav aria-label="page navigation">
 
 Review comment:
   Not sure we can use multiple strings for `aria-label`, [specification says](https://www.w3.org/TR/wai-aria/#aria-label) value in singular

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-website] AemieJ commented on a change in pull request #295: Custom Pagination within Blog Section

Posted by GitBox <gi...@apache.org>.
AemieJ commented on a change in pull request #295: Custom Pagination within Blog Section
URL: https://github.com/apache/camel-website/pull/295#discussion_r401738959
 
 

 ##########
 File path: layouts/blog/list.html
 ##########
 @@ -15,9 +15,46 @@ <h3>Categories</h3>
             {{ range $pages }}
                 {{ .Render "summary" }}
             {{ end }}
-            {{ template "_internal/pagination.html" . }}
+            
+            {{ $page := .Paginator }}
+            {{ if gt $page.TotalPages 1 }}
+            {{ $.Scratch.Set "dot_rendered" false }}
+            <nav aria-label="page navigation">
+                <ul class="pagination">
+                    <!-- Don't show on 1st and 2nd page -->
+                    {{ if and (ne $page.PageNumber 1) }}
 
 Review comment:
   The command you suggested isn't performing. **not $page.First** doesn't provide any output.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-website] zregvart commented on a change in pull request #295: Custom Pagination within Blog Section

Posted by GitBox <gi...@apache.org>.
zregvart commented on a change in pull request #295: Custom Pagination within Blog Section
URL: https://github.com/apache/camel-website/pull/295#discussion_r401449847
 
 

 ##########
 File path: layouts/blog/list.html
 ##########
 @@ -15,9 +15,46 @@ <h3>Categories</h3>
             {{ range $pages }}
                 {{ .Render "summary" }}
             {{ end }}
-            {{ template "_internal/pagination.html" . }}
+            
+            {{ $page := .Paginator }}
+            {{ if gt $page.TotalPages 1 }}
+            {{ $.Scratch.Set "dot_rendered" false }}
+            <nav aria-label="page navigation">
+                <ul class="pagination">
+                    <!-- Don't show on 1st and 2nd page -->
+                    {{ if and (ne $page.PageNumber 1) }}
 
 Review comment:
   Perhaps
   
   ```suggestion
                       {{ if not .$page.First }}
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-website] AemieJ commented on a change in pull request #295: Custom Pagination within Blog Section

Posted by GitBox <gi...@apache.org>.
AemieJ commented on a change in pull request #295: Custom Pagination within Blog Section
URL: https://github.com/apache/camel-website/pull/295#discussion_r401769082
 
 

 ##########
 File path: layouts/blog/list.html
 ##########
 @@ -15,9 +15,46 @@ <h3>Categories</h3>
             {{ range $pages }}
                 {{ .Render "summary" }}
             {{ end }}
-            {{ template "_internal/pagination.html" . }}
+            
+            {{ $page := .Paginator }}
+            {{ if gt $page.TotalPages 1 }}
+            {{ $.Scratch.Set "dot_rendered" false }}
+            <nav aria-label="page navigation">
+                <ul class="pagination">
+                    <!-- Don't show on 1st and 2nd page -->
+                    {{ if and (ne $page.PageNumber 1) }}
+                    <li class="page-item"><a href="{{ $page.First.URL }}" rel="first" class="page-link">««</a></li>
+                    {{ end }}
+
+                    {{ if $page.HasPrev  }}
+                    <li class="page-item"><a href="{{ $page.Prev.URL }}" rel="prev" class="page-link">«</a></li>
+                    {{ end }}
+
+                    {{ range $page.Pagers }}
+                        {{ if eq . $page }} <!-- Current Page -->
+                        <li class="page-item active"><a href="{{ .URL }}" class="page-link">{{ .PageNumber }}</a></li>
+                        {{ else if and (ge .PageNumber (sub $page.PageNumber 2)) (le .PageNumber (add $page.PageNumber 2)) }}
+                        {{ $.Scratch.Set "dot_rendered" false }} <!-- Render prev 2 page and next 2 pages -->
+                        <li class="page-item"><a href="{{ .URL }}" class="page-link">{{ .PageNumber }}</a></li>
+                        {{ else if eq ($.Scratch.Get "dot_rendered") false }} <!-- render skip pages -->
+                        {{ $.Scratch.Set "dot_rendered" true }}
+                        <li class="page-item disabled"><a class="page-link">...</a></li>
+                        {{ end }}
+                    {{ end }}
+
+                    {{ if $page.HasNext }}
+                    <li class="page-item"><a href="{{ $page.Next.URL }}" rel="next" class="page-link">»</a></li>
+                    {{ end }}
+
+                    <!-- Don't show on last and 2nd last page -->
+                    {{ if and (ne $page.PageNumber $page.TotalPages) }}
+                    <li class="page-item"><a href="{{ $page.Last.URL }}" rel="last" class="page-link">»»</a></li>
+                    {{ end }}
+                </ul>
+            </nav>
+            {{ end }}
 
 Review comment:
   I have done except the 2nd one I had to use the **ne** condition as **not** wasn't given the expected results.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-website] zregvart commented on a change in pull request #295: Custom Pagination within Blog Section

Posted by GitBox <gi...@apache.org>.
zregvart commented on a change in pull request #295: Custom Pagination within Blog Section
URL: https://github.com/apache/camel-website/pull/295#discussion_r401452269
 
 

 ##########
 File path: layouts/blog/list.html
 ##########
 @@ -15,9 +15,46 @@ <h3>Categories</h3>
             {{ range $pages }}
                 {{ .Render "summary" }}
             {{ end }}
-            {{ template "_internal/pagination.html" . }}
+            
+            {{ $page := .Paginator }}
+            {{ if gt $page.TotalPages 1 }}
+            {{ $.Scratch.Set "dot_rendered" false }}
+            <nav aria-label="page navigation">
+                <ul class="pagination">
+                    <!-- Don't show on 1st and 2nd page -->
+                    {{ if and (ne $page.PageNumber 1) }}
+                    <li class="page-item"><a href="{{ $page.First.URL }}" rel="first" class="page-link">««</a></li>
+                    {{ end }}
+
+                    {{ if $page.HasPrev  }}
+                    <li class="page-item"><a href="{{ $page.Prev.URL }}" rel="prev" class="page-link">«</a></li>
+                    {{ end }}
+
+                    {{ range $page.Pagers }}
+                        {{ if eq . $page }} <!-- Current Page -->
+                        <li class="page-item active"><a href="{{ .URL }}" class="page-link">{{ .PageNumber }}</a></li>
+                        {{ else if and (ge .PageNumber (sub $page.PageNumber 2)) (le .PageNumber (add $page.PageNumber 2)) }}
+                        {{ $.Scratch.Set "dot_rendered" false }} <!-- Render prev 2 page and next 2 pages -->
+                        <li class="page-item"><a href="{{ .URL }}" class="page-link">{{ .PageNumber }}</a></li>
+                        {{ else if eq ($.Scratch.Get "dot_rendered") false }} <!-- render skip pages -->
+                        {{ $.Scratch.Set "dot_rendered" true }}
+                        <li class="page-item disabled"><a class="page-link">...</a></li>
+                        {{ end }}
+                    {{ end }}
+
+                    {{ if $page.HasNext }}
+                    <li class="page-item"><a href="{{ $page.Next.URL }}" rel="next" class="page-link">»</a></li>
+                    {{ end }}
+
+                    <!-- Don't show on last and 2nd last page -->
+                    {{ if and (ne $page.PageNumber $page.TotalPages) }}
+                    <li class="page-item"><a href="{{ $page.Last.URL }}" rel="last" class="page-link">»»</a></li>
+                    {{ end }}
+                </ul>
+            </nav>
+            {{ end }}
         </div>
     </main>
 </div>
 
-{{ partial "footer.html" . }}
+{{ partial "footer.html" . }}
 
 Review comment:
   No newline at EOF

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [camel-website] zregvart commented on a change in pull request #295: Custom Pagination within Blog Section

Posted by GitBox <gi...@apache.org>.
zregvart commented on a change in pull request #295: Custom Pagination within Blog Section
URL: https://github.com/apache/camel-website/pull/295#discussion_r401439902
 
 

 ##########
 File path: antora-ui-camel/src/css/doc.css
 ##########
 @@ -368,7 +368,7 @@
 .doc ol,
 .doc ul {
   margin: 0;
-  padding: 0 0 0 2rem;
+  padding: 0 0 0 1rem;
 
 Review comment:
   This change doesn't seem to be related to pagination. If it is the rule needs to be scoped to the pagination and placed in blog.css. Otherwise it affects other `ol` and `ul` elements.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services