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

use localized link for thunderbird/all. fixes #198 #208

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ def build_notes(self):
# Build htaccess files for sysreq and release notes redirects.
sysreq_path = os.path.join(self.renderpath, 'system-requirements')
notes_path = os.path.join(self.renderpath, 'notes')
write_htaccess(sysreq_path, settings.CANONICAL_URL + helper.thunderbird_url('system-requirements'))
write_htaccess(notes_path, settings.CANONICAL_URL + helper.thunderbird_url('releasenotes'))
write_htaccess(sysreq_path, settings.CANONICAL_URL + helper.thunderbird_url({'LANG':'en-US'},'system-requirements'))
write_htaccess(notes_path, settings.CANONICAL_URL + helper.thunderbird_url({'LANG':'en-US'},'releasenotes'))

def build_assets(self):
"""Build assets, that is, bundle and compile the LESS and JS files in `settings.ASSETS`."""
Expand Down
10 changes: 7 additions & 3 deletions helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ def download_thunderbird(ctx, channel='release', dom_id=None,
return jinja2.Markup(html)


def thunderbird_url(page, channel='None'):
@jinja2.contextfunction
def thunderbird_url(ctx, page, channel='None'):
"""
Return a product-related URL like /thunderbird/all/ or /thunderbird/beta/60.0/releasenotes/.
page = ('system-requirements', 'all', 'releasenotes')
Expand All @@ -300,18 +301,21 @@ def thunderbird_url(page, channel='None'):
{{ thunderbird_url('system-requirements', channel) }}
"""

lang = ctx['LANG']
channel = channel or 'release'
version = thunderbird_desktop.latest_version(channel)
# replace 'b1', 'b2' etc in beta version with just 'beta', since we don't generate
# new notes for each beta iteration.
version = re.sub(r"b[1-9][0-9]?", "beta", version)

# system reqs and release notes don't get localized
url = '/en-US/thunderbird/{0}/{1}/'.format(version, page)

# but the 'all' page does
if page == 'all':
url = '/en-US/thunderbird/{0}/{1}/'.format(channel, page)
url = '/{0}/thunderbird/{1}/{2}/'.format(lang, channel, page)
if channel == 'release':
url = '/en-US/thunderbird/{0}/'.format(page)
url = '/{0}/thunderbird/{1}/'.format(lang, page)

return url

Expand Down