-
-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1867 from tvdeyen/4.6-backports
Cherry picks changes from 4.6-stable that needs to be ported over to master Fix the sitemap wrapper height (#1861) Update Urlname translation (#1857) Introduce Page#url_path (#1859) Show url_path in page tree (#1856) Use depth for page tree serializer root_or_leaf (#1864)
- Loading branch information
Showing
25 changed files
with
264 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,7 @@ def page_includes | |
[ | ||
:tags, | ||
{ | ||
language: :site, | ||
elements: [ | ||
{ | ||
nested_elements: [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# frozen_string_literal: true | ||
|
||
module Alchemy | ||
class Page | ||
# = The url_path for this page | ||
# | ||
# Use this to build relative links to this page | ||
# | ||
# It takes several circumstances into account: | ||
# | ||
# 1. It returns just a slash for language root pages of the default langauge | ||
# 2. It returns a url path with a leading slash for regular pages | ||
# 3. It returns a url path with a leading slash and language code prefix for pages not having the default language | ||
# 4. It returns a url path with a leading slash and the language code for language root pages of a non-default language | ||
# | ||
# == Examples | ||
# | ||
# Using Rails' link_to helper | ||
# | ||
# link_to page.url | ||
# | ||
class UrlPath | ||
ROOT_PATH = "/" | ||
|
||
def initialize(page) | ||
@page = page | ||
@language = @page.language | ||
@site = @language.site | ||
end | ||
|
||
def call | ||
if @page.language_root? | ||
language_root_path | ||
elsif @site.languages.select(&:public?).length > 1 | ||
page_path_with_language_prefix | ||
else | ||
page_path_with_leading_slash | ||
end | ||
end | ||
|
||
private | ||
|
||
def language_root_path | ||
@language.default? ? ROOT_PATH : language_path | ||
end | ||
|
||
def page_path_with_language_prefix | ||
@language.default? ? page_path : language_path + page_path | ||
end | ||
|
||
def page_path_with_leading_slash | ||
@page.language_root? ? ROOT_PATH : page_path | ||
end | ||
|
||
def language_path | ||
"/#{@page.language_code}" | ||
end | ||
|
||
def page_path | ||
"/#{@page.urlname}" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.