Skip to content
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
2 changes: 1 addition & 1 deletion apps/src/code-studio/initApp/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -2191,7 +2191,7 @@ function parsePath() {

const geRegion = getGlobalEditionRegion();
if (geRegion) {
pathname = pathname.replace(`/global/${geRegion}/`, '/');
pathname = pathname.replace(`/${geRegion}/`, '/');
}

// We have a hash based route. Replace the hash with a slash, and append to
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Adds carousel functionality to code.org/global/fa/videos
// Adds carousel functionality to code.org/fa/videos

// This installs the Swiper library WebComponent.
// See docs here: https://swiperjs.com/swiper-api#web-component.
Expand Down
2 changes: 1 addition & 1 deletion apps/src/templates/GlobalEditionWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const GlobalEditionWrapper: React.FunctionComponent<
const pageConfig: RegionConfigurationPageObject | undefined = pages
.filter(
filterInfo =>
RegExp('^/global/.*' + filterInfo.path + '(?:/.*)?').test(
RegExp('^/.*' + filterInfo.path + '(?:/.*)?').test(
window.location.pathname
) && componentId in filterInfo.components
)
Expand Down
10 changes: 4 additions & 6 deletions apps/src/userHeaderEventLogger/userHeaderEventLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,9 @@ $(document).ready(function () {
const headerCreateMenu = document.getElementById('header_create_menu');
const pageUrl = window.location.href;

if (!pageUrl.includes('/global/')) {
if (getScriptData('isSignedOut')) {
addSignedOutMetrics(pageUrl, headerCreateMenu);
} else {
addSignedInMetrics(pageUrl, headerCreateMenu);
}
if (getScriptData('isSignedOut')) {
addSignedOutMetrics(pageUrl, headerCreateMenu);
} else {
addSignedInMetrics(pageUrl, headerCreateMenu);
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ describe('TeacherHomepage - Farsi Global Edition', () => {

beforeEach(() => {
delete window.location;
window.location = new URL('https://studio.code.org/global/fa/home');
window.location = new URL('https://studio.code.org/fa/home');
stubRedux();
store = getStore();
});
Expand Down
176 changes: 176 additions & 0 deletions config/global_editions/la.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
# Latin-America Global Region

# The general region for Latin-America.

locales: [es-MX, es-LA]
countries: [LA]

# The top bar on the site consisting of dropdown menus and navigation links
header:
# The topbar (which is collapsed into the hamburger in certain contexts)
top:
signed_out:
- title: teach
id: header-teach
domain: code.org
url: /la/teacher
- title: about
id: header-about
domain: code.org
url: /la/about
- title: csf
id: header-csf
domain: code.org
url: /la/csf
- title: hour_of_code
id: header-hoc
domain: code.org
url: /la/hourofcode
- title: videos
id: header-videos
domain: code.org
url: /la/videos

student:
- title: my_dashboard
url: /la/home
domain: studio.code.org
id: header-student-home
- title: course_catalog
url: /la/catalog
domain: studio.code.org
id: header-student-courses

teacher:
- title: my_dashboard
url: /la/home
domain: studio.code.org
id: header-student-home
- title: course_catalog
url: /la/catalog
domain: studio.code.org
id: header-teacher-courses
- title: professional_learning
url: /la/my-professional-learning
domain: studio.code.org
id: header-teacher-professional-learning

# The three-bar "hamburger" menu
hamburger:
student:
- title: learn
domain: studio.code.org
url: /la/catalog
id: learn
- title: legal
type: expander
id: legal_entries
subentries:
- title: legal_privacy
domain: code.org
url: /privacy
- title: legal_cookie_notice
domain: code.org
url: /cookies
- title: legal_tos
domain: code.org
url: /tos

teacher:
- title: learn
domain: studio.code.org
url: /la/catalog
id: learn
- title: legal
type: expander
id: legal_entries
subentries:
- title: legal_privacy
domain: code.org
url: /privacy
- title: legal_cookie_notice
domain: code.org
url: /cookies
- title: legal_tos
domain: code.org
url: /tos

# Help button (?)
help:
# The report_bug item is special in that it only appears when appropriate
- title: report_bug
url: https://support.code.org/hc/es-la/requests/new
id: report-bug

# The navigation region found at the bottom of each page
footer:
links:
studio:
- title: privacy
url: /privacy
domain: code.org
style: "color: #ffa400;"
- title: cookie_notice
url: /cookies
domain: code.org
- title: translate
url: /translate
domain: code.org
- title: help_support
url: https://support.code.org
target: _blank
loc_prefix: landing.
id: support
- title: store
url: https://store.code.org
- title: tos_short
url: /tos
domain: code.org
code_org:
- title: privacy_policy
url: /privacy
domain: code.org
style: "color: #ffa400;"
- title: cookie_notice
url: /cookies
domain: code.org
- title: about
url: /about
domain: code.org
- title: partners
url: /partners
domain: code.org
- title: blog
url: https://medium.com/@codeorg
target: _blank
- title: donate
url: /donate
domain: code.org
- title: store
url: shop
domain: code.org
- title: support
url: http://support.code.org/
target: _blank
- title: terms
url: /tos
domain: code.org
hour_of_code:
- title: contact
url: http://support.code.org/hc/es-la/requests/new
target: _blank
- title: support
url: http://support.code.org
target: _blank
- title: terms
url: /tos
domain: code.org
target: _blank
- title: privacy
url: /privacy
domain: code.org
target: _blank
- title: cookie
domain: hourofcode.com
url: /cookies
target: _blank
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This is the configuration for /global/en
# (which is mirroring the main site at the moment)

locales: [en-US]
locales: [en-US, es-US, es-MX]

header:
# The topbar (which is collapsed into the hamburger in certain contexts)
Expand Down
11 changes: 7 additions & 4 deletions lib/cdo/global_edition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,27 @@ module Cdo
# Lazily loads global configurations for regional pages
module GlobalEdition
REGION_KEY = 'ge_region'
ROOT_PATH = '/global'
ROOT_PATH = ''

# Retrieves a list a global region names.
REGIONS = Dir.glob('*.yml', base: CDO.dir('config', 'global_editions')).map {|f| File.basename(f, '.yml')}.freeze
LOCALES = (Cdo::I18n::LOCALE_CONFIGS.keys.map(&:to_s) + %w[es es-LA en]).freeze

TARGET_HOSTNAMES = Set[
CDO.dashboard_hostname,
CDO.pegasus_hostname,
].freeze

# @example Matches paths like `/global/fa/home`, capturing:
# - ge_prefix: "/global/fa"
# - ge_region: "fa"
# @example Matches paths like `/fa/home` or `/la/es-LA/home` capturing:
# - ge_prefix: "/fa", "/la/es-LA"
# - ge_region: "fa", "la"
# - ge_locale: nil, "es-LA'
# - main_path: "/home"
PATH_PATTERN = Regexp.new <<~REGEXP.gsub(/\s+/, '')
^(?<ge_prefix>
#{ROOT_PATH}/
(?<ge_region>#{REGIONS.join('|')})
(?:/(?<ge_locale>#{LOCALES.join('|')}))?
)
(?<main_path>/.*|$)
REGEXP
Expand Down
15 changes: 8 additions & 7 deletions lib/cdo/rack/global_edition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ def call
setup_region(new_region)
setup_redirect_to(redirect_path)
elsif Cdo::GlobalEdition::PATH_PATTERN.match?(request.path_info)
ge_prefix, ge_region, main_path = request_path_vars(:ge_prefix, :ge_region, :main_path)
ge_prefix, ge_region, ge_locale, main_path = request_path_vars(:ge_prefix, :ge_region, :ge_locale, :main_path)

if Cdo::GlobalEdition.region_available?(ge_region) && dashboard_route?(main_path)
# Strips the Global Edition path prefix (e.g., `/global/fa`) from the request path.
if Cdo::GlobalEdition.region_available?(ge_region) && (ge_locale.nil? || Cdo::GlobalEdition.locale_available?(ge_region, ge_locale)) && dashboard_route?(main_path)
# Strips the Global Edition path prefix (e.g., `/fa`, `/la/es`) from the request path.
# request.path == request.script_name + request.path_info
# - `request.script_name` strips the prefix from the request path
# so the application processes requests as if it were running at the root level.
Expand All @@ -61,7 +61,7 @@ def call
request.path_info = main_path
end

setup_region(ge_region)
setup_region(ge_region, ge_locale)
elsif Cdo::GlobalEdition.region_available?(request.cookies[REGION_KEY])
# Redirects to the regional version if it is available.
setup_region_redirect(request.cookies[REGION_KEY])
Expand Down Expand Up @@ -91,13 +91,13 @@ def call
Cdo::GlobalEdition::PATH_PATTERN.match(request.path_info)&.values_at(*keys) || []
end

private def setup_region(region)
private def setup_region(region, locale = nil)
# Resets the region if it's `nil` or sets it only if it's available.
return unless region.nil? || Cdo::GlobalEdition.region_available?(region)

# Sets the request cookies to apply changes immediately without needing to reload the page.
request.cookies[REGION_KEY] = region
request.cookies[LOCALE_KEY] = request.locale = site_locale(region)
request.cookies[LOCALE_KEY] = request.locale = site_locale(region, locale)

# Updates the global `ge_region` cookie to lock the platform to the regional version.
set_global_cookie(REGION_KEY, region, high_priority: true)
Expand Down Expand Up @@ -129,8 +129,9 @@ def call
false
end

private def site_locale(region)
private def site_locale(region, locale = nil)
site_locale = request.cookies[LOCALE_KEY]
site_locale = locale if !locale.nil? && Cdo::GlobalEdition.locale_available?(region, locale)

if Cdo::GlobalEdition.region_available?(region)
unless Cdo::GlobalEdition.locale_available?(region, site_locale)
Expand Down