Skip to content

replace absUrl with relUrl#183

Merged
pftg merged 2 commits into
masterfrom
replace-absUrl-with-relUrl
Oct 23, 2024
Merged

replace absUrl with relUrl#183
pftg merged 2 commits into
masterfrom
replace-absUrl-with-relUrl

Conversation

@AucT

@AucT AucT commented Oct 23, 2024

Copy link
Copy Markdown
Collaborator

closes #182

Summary by CodeRabbit

Release Notes

  • New Features

    • Updated URL generation methods across various pages to use relative URLs instead of absolute URLs, enhancing link behavior and consistency throughout the site.
  • Bug Fixes

    • Resolved potential issues with link resolution across different environments by changing URL formats in multiple templates, including the homepage, services, and footer.

These changes improve navigation and ensure a more reliable user experience.

@coderabbitai

coderabbitai Bot commented Oct 23, 2024

Copy link
Copy Markdown
Contributor

Walkthrough

The pull request involves modifications across several HTML layout files within the Beaver theme. The primary change is the replacement of absURL with relURL for generating links, affecting how URLs are constructed for various navigation elements. This adjustment ensures that URLs are relative to the current page context rather than absolute, which could enhance the flexibility of the site in different environments.

Changes

File Path Change Summary
themes/beaver/layouts/404.html Changed absURL to relURL for homepage and free consultation links.
themes/beaver/layouts/page/careers.html Updated "Get in Touch" button link from absURL to relURL.
themes/beaver/layouts/page/index.html Replaced multiple instances of absURL with relURL for service and consultation links.
themes/beaver/layouts/page/services.html Changed service links and "Learn More" links from absURL to relURL.
themes/beaver/layouts/page/use-cases.html Updated "Learn More" links for use cases from absURL to relURL.
themes/beaver/layouts/partials/page/footer.html Changed "Privacy Policy" link from absURL to relURL.
themes/beaver/layouts/partials/page/header.html Updated logo link from absURL to relURL.
themes/beaver/layouts/services/single.html Changed "Talk to an Expert" and "View All Clients" buttons from absURL to relURL.
themes/beaver/layouts/use-cases/single.html Updated "Talk to an Expert" and "View All Clients" buttons from absURL to relURL.

Assessment against linked issues

Objective Addressed Explanation
Remove usage of the absolute URL generation (Issue #182)

Possibly related PRs

Poem

Hop, hop, hooray, what a lovely sight,
Links now dance in the soft moonlight.
From absolute to relative, a clever change,
Our URLs now feel less strange!
With every click, a smoother ride,
In our Beaver theme, we take great pride! 🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 0a1c42f and 9cf1c1e.

📒 Files selected for processing (1)
  • themes/beaver/layouts/404.html (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • themes/beaver/layouts/404.html

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@AucT
AucT requested a review from pftg October 23, 2024 07:02

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (4)
themes/beaver/layouts/partials/page/footer.html (1)

Line range hint 126-156: Remove unnecessary absURL calls in social media section

There are multiple instances of {{ absURL "" }} in the social media section that should be addressed:

<link itemprop="url" href='{{ absURL "" }}'>

These calls appear unnecessary as they:

  1. Use an empty string as argument, resulting in just the base URL
  2. Are not needed since the social media links use absolute URLs (https://...)

Suggested fix - remove these lines entirely as they don't provide value:

 <span class="pp-social-icon" itemscope itemtype="https://schema.org/Organization">
-    <link itemprop="url" href='{{ absURL "" }}'>
     <a itemprop="sameAs" href="https://www.facebook.com/jetthoughts/" target="_blank" title="Facebook" aria-label="Facebook" role="button" rel="noopener noreferrer external">
         {{ partial "svg" "facebook-white-fa" }}
     </a>
 </span>

Apply this change to all social media icon blocks.

themes/beaver/layouts/use-cases/single.html (1)

Line range hint 259-263: Update hardcoded absolute path to use relURL

There's a hardcoded absolute path "/contact-us/" that should be updated to use relURL for consistency with the PR objective of eliminating absolute URL generation.

Apply this diff to fix the inconsistency:

-                                           <a href="https://github.com/contact-us/" target="_self" class="fl-button">
+                                           <a href="{{ relURL "contact-us/" }}" target="_self" class="fl-button">
themes/beaver/layouts/services/single.html (1)

Line range hint 293-295: Consider using relURL for contact-us link

For consistency with other changes in this PR, consider updating the hardcoded contact-us link to use relURL as well.

-                                          <a href="https://github.com/contact-us/" target="_self" class="fl-button">
+                                          <a href="{{ relURL "contact-us/" }}" target="_self" class="fl-button">
themes/beaver/layouts/page/careers.html (1)

Line range hint 435-444: Consider moving JavaScript to a separate file.

The JavaScript functions changeIcon and changeIconBack should be moved to a separate .js file for better maintainability and caching benefits.

Create a new file assets/js/careers.js:

function changeIcon(e) {
  e.getElementsByClassName('readmore-arrow')[0].style.display = "none";
  e.getElementsByClassName('readmore-arrow-hover')[0].style.display = "inline";
}

function changeIconBack(e) {
  e.getElementsByClassName('readmore-arrow')[0].style.display = "inline";
  e.getElementsByClassName('readmore-arrow-hover')[0].style.display = "none";
}

Then include it in the template:

-<script>
-  function changeIcon(e) {
-    e.getElementsByClassName('readmore-arrow')[0].style.display = "none";
-    e.getElementsByClassName('readmore-arrow-hover')[0].style.display = "inline";
-  }
-
-  function changeIconBack(e) {
-    e.getElementsByClassName('readmore-arrow')[0].style.display = "inline";
-    e.getElementsByClassName('readmore-arrow-hover')[0].style.display = "none";
-  }
-</script>
+{{ $js := resources.Get "js/careers.js" | minify | fingerprint }}
+<script src="{{ $js.RelPermalink }}"></script>
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between edd48e3 and 0a1c42f.

📒 Files selected for processing (9)
  • themes/beaver/layouts/404.html (2 hunks)
  • themes/beaver/layouts/page/careers.html (1 hunks)
  • themes/beaver/layouts/page/index.html (16 hunks)
  • themes/beaver/layouts/page/services.html (12 hunks)
  • themes/beaver/layouts/page/use-cases.html (6 hunks)
  • themes/beaver/layouts/partials/page/footer.html (1 hunks)
  • themes/beaver/layouts/partials/page/header.html (1 hunks)
  • themes/beaver/layouts/services/single.html (2 hunks)
  • themes/beaver/layouts/use-cases/single.html (2 hunks)
🧰 Additional context used
🔇 Additional comments (20)
themes/beaver/layouts/partials/page/header.html (2)

4-4: LGTM! Change aligns with PR objectives.

The switch from absURL to relURL for the logo link is appropriate and supports the goal of making the site more flexible for testing environments.


4-4: Verify JavaScript compatibility with relative URLs.

While the change to relative URLs is correct, let's verify there are no JavaScript dependencies expecting absolute URLs.

✅ Verification successful

Let me try a different approach to verify JavaScript compatibility by searching for any JavaScript files first and then analyzing their content.


After analyzing the JavaScript files in the repository, particularly in the themes/beaver directory, I can now provide a conclusive response.

The change to relative URLs is safe to proceed

The JavaScript code review shows that URL handling is limited to:

  • Navigation menu toggle functionality
  • Tab component interactions
  • Click handlers that use the href attribute directly from anchor tags without any URL manipulation

None of the JavaScript code makes assumptions about absolute URLs or performs URL manipulation that would be affected by the change from absolute to relative URLs. The only URL-related code uses attr("href") to read the existing URLs as-is.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for JavaScript files that might reference the homepage URL
# or manipulate URLs, which could be affected by this change

# Look for potential URL manipulations in JS files
echo "Checking for URL manipulations in JavaScript files..."
rg -t js "window\.location\.href|\.setAttribute\(['\"]href['\"]" 

# Look for hardcoded references to homepage
echo "Checking for hardcoded homepage references..."
rg -t js "href\s*=\s*['\"]/"

Length of output: 321


Script:

#!/bin/bash
# First, let's find all JavaScript files in the repository
echo "Finding all JavaScript files..."
fd -e js

# Then, let's check the content of any JavaScript files in themes/beaver
# since this is where our template change is located
echo -e "\nChecking content of JavaScript files in themes/beaver..."
fd -e js . themes/beaver --exec cat {}

Length of output: 9286

themes/beaver/layouts/404.html (1)

49-51: LGTM: Homepage link correctly uses relURL.

The change from absURL to relURL for the homepage link is correct and aligns with the PR objectives to improve testing flexibility.

themes/beaver/layouts/partials/page/footer.html (1)

158-158: LGTM: Correctly replaced absURL with relURL

The change from absURL to relURL for the privacy policy link aligns with the PR objectives and is implemented correctly.

themes/beaver/layouts/use-cases/single.html (2)

52-54: LGTM: Correctly updated to use relative URL

The change from absURL to relURL for the consultation link aligns with the PR objective of using relative paths.


187-189: LGTM: Correctly updated to use relative URL

The change from absURL to relURL for the clients link aligns with the PR objective of using relative paths.

themes/beaver/layouts/services/single.html (2)

49-51: LGTM: Appropriate use of relURL for consultation link

The change from absURL to relURL for the consultation link is correct and aligns with the PR objectives.


216-218: LGTM: Appropriate use of relURL for clients link

The change from absURL to relURL for the clients link is correct and aligns with the PR objectives.

themes/beaver/layouts/page/use-cases.html (2)

121-121: LGTM! Consistent URL generation changes.

The changes from absURL to relURL have been applied consistently across all "Learn More" links. This modification aligns well with the PR objective of removing absolute URL generation.

Also applies to: 163-163, 205-205, 247-247, 289-289, 331-331


121-121: Verify the navigation functionality.

The switch to relative URLs should improve testing flexibility. Let's verify that all links remain functional and that the site navigation works as expected.

Also applies to: 163-163, 205-205, 247-247, 289-289, 331-331

✅ Verification successful

Based on the shell script results, I can now generate the final response as we have sufficient information to verify the navigation functionality:

URL generation is consistent and properly implemented

The codebase analysis shows:

  • All use-case links consistently use relURL function for URL generation
  • The only remaining absURL usage is in the footer for social media organization schema, which is correct
  • Navigation links are properly structured with relative paths
  • All use-case links follow the same pattern: use-cases/[specific-case]/
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all use-case links are properly defined and accessible

# Test 1: Check if all use-case paths exist
echo "Verifying use-case paths..."
fd -t f -e html . -E "themes" | rg "use-cases/.+/"

# Test 2: Check for any remaining absolute URL usage in the theme
echo "Checking for any remaining absolute URL usage..."
rg "absURL" "themes/beaver/layouts"

# Test 3: Verify consistent URL generation method across all templates
echo "Verifying URL generation consistency..."
rg "URL" "themes/beaver/layouts" -A 1 -B 1

Length of output: 35017

themes/beaver/layouts/page/careers.html (2)

42-42: LGTM: URL generation change aligns with PR objectives.

The change from absURL to relURL for the contact page link is correct and supports the goal of making the site more flexible for testing environments.


Line range hint 1-444: LGTM: Good accessibility and SEO practices.

The template demonstrates good practices:

  • Proper semantic HTML structure
  • ARIA attributes and roles
  • Schema.org markup for job postings
themes/beaver/layouts/page/services.html (3)

59-66: LGTM: Service link changes are consistent and well-implemented.

The conversion from absURL to relURL for service links is implemented consistently across all sections, maintaining proper link structure while achieving the goal of removing absolute URL dependencies.

Also applies to: 89-96, 119-126, 162-169, 192-199, 222-229


374-374: LGTM: Use case link changes are consistent and well-implemented.

The conversion from absURL to relURL for use case links is implemented consistently across all sections, maintaining proper link structure while achieving the goal of removing absolute URL dependencies.

Also applies to: 416-416, 458-458, 500-500, 542-542, 584-584


Line range hint 1-644: Verify consistent URL function usage across the template.

Let's ensure all URL generation is consistently using relative paths.

✅ Verification successful

Based on the shell script results, I can now generate the final response:

URL function usage is consistent across the template

The verification shows:

  • No instances of absURL function calls were found
  • All URL generation consistently uses relURL function across service and use-case links
  • All 16 instances of URL generation follow the same pattern using relative paths
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining absolute URL usage in the template
# Test: Search for absURL function calls. Expect: No results
rg 'absURL' 'themes/beaver/layouts/page/services.html'

# Test: Verify all URLs are using relURL. Expect: Consistent usage
rg 'relURL' 'themes/beaver/layouts/page/services.html'

Length of output: 3812

themes/beaver/layouts/page/index.html (5)

79-81: LGTM: Free consultation link correctly uses relative URL.

The change from absURL to relURL for the consultation link aligns with the PR objectives while maintaining proper link structure.


130-132: LGTM: Use cases link correctly uses relative URL.

The change from absURL to relURL for the use cases link aligns with the PR objectives while maintaining proper link structure.


249-256: LGTM: Service links correctly use relative URLs.

All service links have been consistently updated to use relURL instead of absURL, maintaining proper link structure and following the same pattern.

Also applies to: 279-286, 309-316, 352-359, 382-389, 412-419


768-768: LGTM: Use case detail links correctly use relative URLs.

All use case detail links have been consistently updated to use relURL instead of absURL, maintaining proper link structure and following the same pattern.

Also applies to: 801-801, 834-834, 867-867, 900-900, 933-933


660-662: LGTM: Contact us link correctly uses relative URL.

The change from absURL to relURL for the contact us link aligns with the PR objectives while maintaining proper link structure.

Comment thread themes/beaver/layouts/404.html Outdated
Comment on lines +49 to 51
<a href="{{ relURL "free-consultation/" }}" target="_self" class="fl-button">
<span class="fl-button-text">Talk to an Expert</span>
</a>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Based on the results, I can now generate the final response as we have clear evidence of inconsistencies in URL handling across the theme.

URL handling inconsistencies found in theme templates

Several issues need attention:

  • absURL is still being used in partials/page/footer.html with empty strings
  • Multiple templates contain hardcoded URLs to /contact-us/ instead of using relURL
  • Blog tag links in multiple templates use hardcoded paths instead of relURL

Locations requiring updates:

  • themes/beaver/layouts/partials/page/footer.html: Replace absURL "" with appropriate relURL usage
  • Contact button URLs in multiple templates:
    • use-cases/single.html
    • clients/single.html
    • page/services.html
    • page/index.html
    • services/single.html
    • page/use-cases.html
    • page/about.html
    • page/clients.html
  • Blog tag links in:
    • blog/list.html
    • _default/single.html
    • _default/list.html
🔗 Analysis chain

Verify consistent URL generation across theme

Let's verify that all template files in the theme use relURL consistently.

Also applies to: 216-218

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining instances of absURL in theme templates
# and identify other hardcoded URLs that might need updating

echo "Checking for remaining absURL usage in theme templates..."
rg --type html 'absURL' themes/beaver/layouts/

echo "Checking for potentially hardcoded URLs in theme templates..."
rg --type html 'href="https://github.com/' themes/beaver/layouts/

Length of output: 2468

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@pftg
pftg merged commit ceda500 into master Oct 23, 2024
@pftg
pftg deleted the replace-absUrl-with-relUrl branch October 23, 2024 07:25
@pftg

pftg commented Oct 23, 2024

Copy link
Copy Markdown
Member

@AucT please create another PR to cleanup other leftovers
jetthoughts github io – footer html 2024-10-23 09-31-25

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACT] Remove usage of the absolute url generation

2 participants