Skip to content

Commit 27a6bbc

Browse files
authored
Merge pull request #17211 from github/remove-fpt
Remove free-pro-team from URLs
2 parents 0855d36 + a8470e9 commit 27a6bbc

23 files changed

Lines changed: 170 additions & 324 deletions

File tree

content/github/creating-cloning-and-archiving-repositories/about-repositories.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ Each person and organization can own unlimited repositories and invite an unlimi
2222
{% endif %}
2323

2424
You can use repositories to manage your work and collaborate with others.
25-
- You can use issues to collect user feedback, report software bugs, and organize tasks you'd like to accomplish. For more information, see "[About issues](/github/managing-your-work-on-github/about-issues)."
26-
- {% data reusables.discussions.you-can-use-discussions %}
25+
- You can use issues to collect user feedback, report software bugs, and organize tasks you'd like to accomplish. For more information, see "[About issues](/github/managing-your-work-on-github/about-issues)."{% if currentVersion == "free-pro-team@latest" %}
26+
- {% data reusables.discussions.you-can-use-discussions %}{% endif %}
2727
- You can use pull requests to propose changes to a repository. For more information, see "[About pull requests](/github/collaborating-with-issues-and-pull-requests/about-pull-requests)."
2828
- You can use project boards to organize and prioritize your issues and pull requests. For more information, see "[About project boards](/github/managing-your-work-on-github/about-project-boards)."
2929

content/github/getting-started-with-github/keyboard-shortcuts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Below is a list of some of the available keyboard shortcuts.
3333
|-----------|------------
3434
|<kbd>g</kbd> <kbd>c</kbd> | Go to the **Code** tab
3535
|<kbd>g</kbd> <kbd>i</kbd> | Go to the **Issues** tab. For more information, see "[About issues](/articles/about-issues)."
36-
|<kbd>g</kbd> <kbd>p</kbd> | Go to the **Pull requests** tab. For more information, see "[About pull requests](/articles/about-pull-requests)."{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.21" or currentVersion == "github-ae@latest" %}
36+
|<kbd>g</kbd> <kbd>p</kbd> | Go to the **Pull requests** tab. For more information, see "[About pull requests](/articles/about-pull-requests)."{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "enterprise-server@2.21" %}
3737
|<kbd>g</kbd> <kbd>a</kbd> | Go to the **Actions** tab. For more information, see "[About Actions](/actions/getting-started-with-github-actions/about-github-actions)."{% endif %}
3838
|<kbd>g</kbd> <kbd>b</kbd> | Go to the **Projects** tab. For more information, see "[About project boards](/articles/about-project-boards)."
3939
|<kbd>g</kbd> <kbd>w</kbd> | Go to the **Wiki** tab. For more information, see "[About wikis](/articles/about-wikis)."

content/github/managing-your-work-on-github/about-issues.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ versions:
1414

1515
You can collect user feedback, report software bugs, and organize tasks you'd like to accomplish with issues in a repository. Issues can act as more than just a place to report software bugs.
1616

17+
{% if currentVersion == "free-pro-team@latest" %}
1718
Other conversations are more suitable for discussions. {% data reusables.discussions.you-can-use-discussions %}
1819

1920
{% data reusables.discussions.you-cannot-convert-a-discussion %}
21+
{% endif %}
2022

2123
{% data reusables.pull_requests.close-issues-using-keywords %}
2224

lib/find-page-in-version.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

lib/find-page.js

Lines changed: 11 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,17 @@
1-
const slash = require('slash')
2-
const patterns = require('./patterns')
3-
const allVersions = Object.keys(require('./all-versions'))
4-
const { getVersionedPathWithLanguage } = require('./path-utils')
1+
const { getLanguageCode } = require('./patterns')
52

6-
module.exports = function findPage (href, pageMap, redirects = {}, languageCode = 'en', sourceLanguage = null) {
7-
// Convert Windows backslashes to forward slashes
8-
// remove trailing slash
9-
href = slash(href).replace(patterns.trailingSlash, '$1')
3+
module.exports = function findPage (href, pageMap, redirects) {
4+
// remove any fragments
5+
href = href.replace(/#.*$/, '')
106

11-
// do an initial lookup on the path as-is
12-
let page = pageMap[removeFragment(href)]
7+
// find the page
8+
const page = pageMap[href] || pageMap[redirects[href]]
139
if (page) return page
1410

15-
// check all potential versions
16-
const versionedPathsToCheck = [...new Set(allVersions.map(version => {
17-
return getVersionedPathWithLanguage(href, version, languageCode)
18-
}))]
11+
// get the current language
12+
const currentLang = getLanguageCode.test(href) ? href.match(getLanguageCode)[1] : 'en'
1913

20-
// get the first found path of the page (account for redirects)
21-
let pathToPage = versionedPathsToCheck.find(path => {
22-
path = redirects[path] || path
23-
return pageMap[removeFragment(path)]
24-
})
25-
26-
// need to account for redirects again
27-
pathToPage = redirects[pathToPage] || pathToPage
28-
29-
// try finding the page again
30-
page = pageMap[removeFragment(pathToPage)]
31-
32-
if (page) return page
33-
34-
if (process.env.NODE_ENV !== 'test' && languageCode === 'en') {
35-
const error = sourceLanguage
36-
? `href not found in ${sourceLanguage} pages (no English fallback found)`
37-
: 'href not found'
38-
39-
// if English page can't be found, throw an error
40-
// because these errors should be surfaced and fixed right away
41-
if (sourceLanguage === 'en') {
42-
throw new Error(`${error}: ${href}`)
43-
} else {
44-
console.error(`${error}: ${href}`)
45-
}
46-
}
47-
48-
// if English page can't be found in tests, don't throw an error
49-
// or the tests will stall
50-
if (process.env.NODE_ENV === 'test' && languageCode === 'en') {
51-
if (sourceLanguage === 'en') console.log(`href not found: ${href}`)
52-
return null
53-
}
54-
55-
// if localized page can't be found, fall back to English
56-
// because localized content is not yet synced
57-
if (languageCode !== 'en') {
58-
// pass the source language so we can surface it in error messages
59-
return findPage(href, pageMap, redirects, 'en', languageCode)
60-
}
61-
}
62-
63-
// some redirects include fragments
64-
// need to remove the fragment to find the page
65-
function removeFragment (path) {
66-
if (!path) return
67-
68-
return path.replace(/#.*$/, '')
14+
// try to fall back to English if the translated page can't be found
15+
const englishHref = href.replace(`/${currentLang}/`, '/en/')
16+
return pageMap[englishHref] || pageMap[redirects[englishHref]]
6917
}

lib/get-link-data.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
const findPageInVersion = require('../lib/find-page-in-version')
2-
const { getVersionedPathWithLanguage } = require('../lib/path-utils')
1+
const path = require('path')
2+
const findPage = require('./find-page')
3+
const nonEnterpriseDefaultVersion = require('./non-enterprise-default-version')
34

45
// rawLinks is an array of paths: [ '/foo' ]
56
// we need to convert it to an array of localized objects: [ { href: '/en/foo', title: 'Foo', intro: 'Description here' } ]
@@ -9,11 +10,11 @@ module.exports = async (rawLinks, context, additionalProperties = []) => {
910
const links = []
1011

1112
for (const link of rawLinks) {
12-
const href = link.href
13-
? getVersionedPathWithLanguage(link.href, context.currentVersion, context.currentLanguage)
14-
: getVersionedPathWithLanguage(link, context.currentVersion, context.currentLanguage)
13+
const linkPath = link.href || link
14+
const version = context.currentVersion === 'homepage' ? nonEnterpriseDefaultVersion : context.currentVersion
15+
const href = path.join('/', context.currentLanguage, version, linkPath)
1516

16-
const linkedPage = findPageInVersion(href, context.pages, context.redirects, context.currentLanguage, context.currentVersion)
17+
const linkedPage = findPage(href, context.pages, context.redirects)
1718
if (!linkedPage) continue
1819

1920
const opts = { textOnly: true, encodeEntities: true }

lib/liquid-tags/link.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ const path = require('path')
22
const assert = require('assert')
33
const Liquid = require('liquid')
44
const liquid = new Liquid.Engine()
5-
const { getPathWithLanguage } = require('../path-utils')
65
const LiquidTag = require('./liquid-tag')
7-
const findPageInVersion = require('../find-page-in-version')
6+
const findPage = require('../find-page')
7+
const getApplicableVersions = require('../get-applicable-versions')
88

99
// This class supports a set of link tags. Each tag expects one parameter, a language-agnostic href:
1010
//
@@ -52,17 +52,21 @@ module.exports = class Link extends LiquidTag {
5252
}
5353

5454
// add language code
55-
fullPath = getPathWithLanguage(fullPath, ctx.currentLanguage)
55+
fullPath = path.join('/', ctx.currentLanguage, fullPath)
5656

5757
// find the page based on the full path
58-
const page = findPageInVersion(fullPath, ctx.pages, ctx.redirects, ctx.currentLanguage, ctx.currentVersion)
58+
const page = findPage(fullPath, ctx.pages, ctx.redirects)
5959

60-
// if found page should NOT render in current version, return early with an empty string
61-
// also return if it's a hidden link on a non-hidden page (hidden links on hidden pages are OK)
60+
// return an empty string if it's a hidden link on a non-hidden page (hidden links on hidden pages are OK)
6261
if (!page || (page.hidden && !ctx.page.hidden)) {
6362
return ''
6463
}
6564

65+
// also return early if the found page should not render in current version
66+
if (!getApplicableVersions(page.versions).includes(ctx.currentVersion)) {
67+
return ''
68+
}
69+
6670
// find and render the props
6771
const title = await page.renderProp('title', ctx, { textOnly: true, encodeEntities: true })
6872

lib/path-utils.js

Lines changed: 14 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,11 @@
11
const slash = require('slash')
22
const path = require('path')
33
const patterns = require('./patterns')
4-
const { deprecated, latest } = require('./enterprise-server-releases')
4+
const { latest } = require('./enterprise-server-releases')
55
const allProducts = require('./all-products')
66
const allVersions = require('./all-versions')
77
const supportedVersions = new Set(Object.keys(allVersions))
8-
const { getNewVersionedPath } = require('./old-versions-utils')
9-
10-
// This function constructs an appropriate versioned path for any given HREF.
11-
// NOTE: this gets called by findPage and various other functions, and
12-
// has to return a proper versioned link given a wide variety of incoming
13-
// modern or legacy-formatted links, so it is somewhat overloaded. At some point
14-
// this could probably be broken up into separate functions to handle different incoming
15-
// paths. But it is currently optimized to handle lots of edge cases.
16-
function getVersionedPathWithoutLanguage (href, version) {
17-
// Start clean without language code or trailing slash
18-
href = getPathWithoutLanguage(href.replace(patterns.trailingSlash, '$1'))
19-
20-
// If this is an old versioned path that includes a deprecated version, do not change!
21-
// example: /enterprise/11.10.340/admin/articles/upgrading-to-the-latest-release
22-
const oldEnterpriseVersionNumber = href.match(patterns.getEnterpriseVersionNumber)
23-
if (oldEnterpriseVersionNumber && deprecated.includes(oldEnterpriseVersionNumber[1])) {
24-
return href
25-
}
26-
27-
// Try to derive the current version from the path
28-
// example: enterprise-server@2.22 or free-pro-team@latest
29-
let versionFromPath = getVersionStringFromPath(href)
30-
31-
// If a supported version was found, add it to the path so we can go through the rest of the checks
32-
if (supportedVersions.has(versionFromPath)) {
33-
href = href.replace(href.split('/')[1], versionFromPath)
34-
}
35-
36-
// If a currently supported version was NOT found...
37-
let productObjectFromPath
38-
if (!supportedVersions.has(versionFromPath)) {
39-
// First check if the segment is instead a current product;
40-
// example: /admin/foo or /desktop/foo
41-
productObjectFromPath = allProducts[versionFromPath]
42-
43-
// If so, add the first supported version for that product to the href
44-
// (this is just to get a path with all the expected segments; the version will be updated later if needed)
45-
if (productObjectFromPath) {
46-
href = path.join('/', productObjectFromPath.versions[0], href)
47-
versionFromPath = productObjectFromPath.versions[0]
48-
} else {
49-
// Otherwise, this may be an old path that should be converted to new path;
50-
// OLD: /enterprise/2.22/admin/installation OR /enterprise/admin/installation
51-
// NEW: /enterprise-server@2.22/admin/installation
52-
href = getNewVersionedPath(href)
53-
versionFromPath = getVersionStringFromPath(href)
54-
}
55-
}
56-
57-
// If not previously found, derive the product object from the path (e.g., github or admin)
58-
if (!productObjectFromPath) {
59-
productObjectFromPath = getProductObjectFromPath(href)
60-
}
61-
62-
// If the product's versions don't include the specified version, nothing to change!
63-
if (productObjectFromPath && !productObjectFromPath.versions.includes(version)) {
64-
return slash(href)
65-
}
66-
67-
// Update the version and return the path
68-
return slash(href.replace(versionFromPath, version))
69-
}
70-
71-
// Add language code to a versioned path
72-
function getVersionedPathWithLanguage (href, version, languageCode) {
73-
return getPathWithLanguage(getVersionedPathWithoutLanguage(href, version), languageCode)
74-
}
8+
const nonEnterpriseDefaultVersion = require('./non-enterprise-default-version')
759

7610
// Add the language to the given HREF
7711
// /articles/foo -> /en/articles/foo
@@ -100,9 +34,15 @@ function getVersionStringFromPath (href) {
10034
return 'homepage'
10135
}
10236

103-
// Check if the first segment is a supported version
37+
// Get the first segment
10438
const versionFromPath = href.split('/')[1]
10539

40+
// If the first segment is a supported product, assume this is FPT
41+
if (allProducts[versionFromPath]) {
42+
return nonEnterpriseDefaultVersion
43+
}
44+
45+
// Otherwise, check if it's a supported version
10646
if (supportedVersions.has(versionFromPath)) {
10747
return versionFromPath
10848
}
@@ -133,9 +73,12 @@ function getVersionObjectFromPath (href) {
13373
// Return the product segment from the path
13474
function getProductStringFromPath (href) {
13575
href = getPathWithoutLanguage(href)
136-
const productString = href.split('/')[2]
13776

138-
return productString || 'homepage'
77+
if (href === '/') return 'homepage'
78+
79+
return allProducts[href.split('/')[2]]
80+
? href.split('/')[2]
81+
: href.split('/')[1]
13982
}
14083

14184
// Return the corresponding object for the product segment in a path
@@ -146,8 +89,6 @@ function getProductObjectFromPath (href) {
14689
}
14790

14891
module.exports = {
149-
getVersionedPathWithLanguage,
150-
getVersionedPathWithoutLanguage,
15192
getPathWithLanguage,
15293
getPathWithoutLanguage,
15394
getPathWithoutVersion,

lib/patterns.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ module.exports = {
3939
oldEnterprisePath: /\/([a-z]{2}\/)?(enterprise\/)?(\S+?@(\S+?\/))?(\d.\d+\/)?(user[/$])?/,
4040
// new versioning format patterns
4141
adminProduct: /\/admin(\/|$|\?|#)/,
42+
insightsProduct: /\/insights(\/|$|\?|#)/,
4243
enterpriseServer: /\/enterprise-server@/,
4344
getEnterpriseServerNumber: /enterprise-server@(\d+\.\d+)/
4445
}

lib/permalink.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const assert = require('assert')
22
const path = require('path')
33
const patterns = require('./patterns')
4-
const pathUtils = require('./path-utils')
54
const getApplicableVersions = require('./get-applicable-versions')
65
const allVersions = require('./all-versions')
76

@@ -14,7 +13,8 @@ class Permalink {
1413

1514
const permalinkSuffix = this.constructor.relativePathToSuffix(relativePath)
1615

17-
this.href = pathUtils.getVersionedPathWithLanguage(permalinkSuffix, pageVersion, languageCode)
16+
this.href = path.join('/', languageCode, pageVersion, permalinkSuffix)
17+
.replace(patterns.trailingSlash, '$1')
1818

1919
this.pageVersionTitle = allVersions[pageVersion].versionTitle
2020

@@ -49,7 +49,6 @@ class Permalink {
4949
return '/' + relativePath
5050
.replace('index.md', '')
5151
.replace('.md', '')
52-
.replace(patterns.trailingSlash, '$1')
5352
}
5453
}
5554

0 commit comments

Comments
 (0)