Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5aa7985

Browse files
Updated Auto-Redirect Flow for Segments (#1339)
* CR-29590* After review fix* swap commandbarSegment values for correct configuration* CR-29589* docs: Exclude gitops collection pages from Sitemap.xml
1 parent6dcd0ca commit5aa7985

File tree

5 files changed

+159
-158
lines changed

5 files changed

+159
-158
lines changed

‎README.md‎

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,31 +64,21 @@ No actions required - the new content will be automatically reflected in both Ar
6464

6565
###Switching Between GitOps (ArgoHub) and Enterprise Segments
6666

67-
By default, users are redirected from the Enterprise segment to the GitOps (ArgoHub) segment.
67+
By default, users are redirected from the Enterprise segment to the GitOps (ArgoHub) segment.
6868

6969
####Example:
70+
7071
- Accessinghttps://codefresh.io/docs/ will redirect tohttps://codefresh.io/docs/gitops/
7172

7273
For more details, refer to the "Auto Redirect from Enterprise to ArgoHub Collection" section below.
7374

74-
####To switch segments in production:
75-
76-
- To switch to the GitOps segment, log in to Codefresh and switch to an account with the GitOps type. This will clear the Enterprise cookie.
77-
- To switch to the Enterprise segment, log in to Codefresh and switch to an account with any other type. This will set the Enterprise cookie.
78-
79-
####To switch segments in local development:
75+
####Switching Between Segments
8076

81-
In the local documentation site (`http://localhost:3131/`), open the console in developer tools and inject the appropriate cookie:
77+
- Use the segment dropdown menu in the page header to select a segment.
78+
- Use a cookie to automatically switch segments (production only):
8279

83-
-**Switch to Enterprise Segment:**
84-
```js
85-
document.cookie='cfdoctype=enterprise; SameSite=Strict; Domain=localhost; Max-age=2592000; Path=/';
86-
```
87-
88-
-**Switch to GitOps Segment:**
89-
```js
90-
document.cookie='cfdoctype=enterprise; SameSite=Strict; Domain=localhost; Max-age=0; Path=/';
91-
```
80+
-**To switch to the GitOps segment:** Log in to Codefresh and switch to an account with the GitOps type. This will set the GitOps cookie.
81+
-**To switch to the Enterprise segment:** Log in to Codefresh and switch to an account with any other type. This will clear the GitOps cookie.
9282

9383
###Reusing Existing Documents
9484

@@ -128,13 +118,26 @@ The ArgoHub home page and all pages within the ArgoHub collection are excluded f
128118

129119
- Commandbar HelpHub Search (managed via Commandbar Content Manager).
130120
- Search engines that support the`noindex` rule, such as Google.
121+
- All pages in the`gitops` collection, including the home page, are excluded from the Sitemap.xml file.
122+
123+
###Auto-Redirect: Enterprise to ArgoHub Collection
124+
125+
The documentation site automatically redirects users from any Enterprise page to the corresponding GitOps (ArgoHub) page when the GitOps cookie is present.
131126

132-
####Commandbar's HelpHub and Copilot Content Sync
127+
####Redirect Logic
133128

134-
Commandbar synchronizes the documentation site content using a crawler. However, the Auto Redirect mechanism prevents the crawler from accessing all Enterprise pages (see the "Auto Redirect from Enterprise to ArgoHub Collection" section for details). To address this issue, the Commandbar team configured the crawler to include the`cfdoctype` cookie, enabling it to access all documentation pages and bypass the redirect.
129+
```mermaid
130+
flowchart LR
131+
A[Enterprise Page] --> B{GitOps Cookie Present?}
132+
B -->|No| C[Stay on Enterprise Page]
133+
B -->|Yes| D[Redirect to GitOps Page]
134+
```
135135

136-
###Auto Redirect from Enterprise to ArgoHub Collection
136+
```mermaid
137+
flowchart LR
138+
A[GitOps Page] --> B[Stay on GitOps Page]
139+
```
137140

138-
When the GitOps client adds an ArgoHub system type cookie, the Documentation site will detect it and initiate an automatic redirect. If you open any page from the enterprise collection, the site will check for an equivalent document in the ArgoHub collection and redirect you there if one exists.
141+
####Redirect Mapping
139142

140143
Redirect links between the Enterprise and ArgoHub collections are stored in the`argohub-redirect-mapping.json` file. Running`npm run link` automatically updates the file, eliminating the need for manual updates.

‎_config.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ defaults:
129129
type:gitops
130130
values:
131131
layout:gitops
132+
sitemap:false
132133
toc:true
133134
wide:true
134135

‎_includes/scripts.html‎

Lines changed: 1 addition & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@
5959
<!-- End of Doc Search Embed Code -->
6060

6161
<script>
62-
constisEnterpriseDocumentationCookieSet=document.cookie.includes('cfdoctype=enterprise')
63-
constcommandbarSegment=isEnterpriseDocumentationCookieSet ?'3033bf7f' :'43836ac3'
62+
constcommandbarSegment=IS_GITOPS_DOC_COOKIE_SET ?'43836ac3':'3033bf7f'
6463

6564
varo=commandbarSegment,n=["Object.assign","Symbol","Symbol.for"].join("%2C"),a=window;functionr(o,n){void0===n&&(n=!1),"complete"!==document.readyState&&window.addEventListener("load",r.bind(null,o,n),{capture:!1,once:!0});vara=document.createElement("script");a.type="text/javascript",a.async=n,a.src=o,document.head.appendChild(a)}functiont(){varn;if(void0===a.CommandBar){deletea.__CommandBarBootstrap__;vart=Symbol.for("CommandBar::configuration"),e=Symbol.for("CommandBar::orgConfig"),i=Symbol.for("CommandBar::disposed"),c=Symbol.for("CommandBar::isProxy"),m=Symbol.for("CommandBar::queue"),d=Symbol.for("CommandBar::unwrap"),l=Symbol.for("CommandBar::eventSubscriptions"),s=[],u=localStorage.getItem("commandbar.lc"),f=u&&u.includes("local")?"http://localhost:8000":"https://api.commandbar.com",p=Object.assign(((n={})[t]={uuid:o},n[e]={},n[i]=!1,n[c]=!0,n[m]=newArray,n[d]=function(){returnp},n[l]=void0,n),a.CommandBar),b=["addCommand","boot","addEventSubscriber","addRecordAction","setFormFactor"],y=p;Object.assign(p,{shareCallbacks:function(){return{}},shareContext:function(){return{}}}),a.CommandBar=newProxy(p,{get:function(o,n){returnniny?p[n]:"then"!==n?b.includes(n)?function(){varo=Array.prototype.slice.call(arguments);returnnewPromise((function(a,r){o.unshift(n,a,r),p[m].push(o)}))}:function(){varo=Array.prototype.slice.call(arguments);o.unshift(n),p[m].push(o)}:void0}}),null!==u&&s.push("lc=".concat(u)),s.push("version=2"),r("".concat(f,"/latest/").concat(o,"?").concat(s.join("&")),!0)}}void0===Object.assign||"undefined"==typeofSymbol||void0===Symbol.for?(a.__CommandBarBootstrap__=t,r("https://polyfill.io/v3/polyfill.min.js?version=3.101.0&callback=__CommandBarBootstrap__&features="+n)):t();
6665
window.CommandBar.setThemeMode('dark_mode')
@@ -81,105 +80,3 @@
8180
}
8281
});
8382
</script>
84-
85-
<script>
86-
toggleSegmentDropdown=function(){
87-
constselect=document.querySelector('.custom-select');
88-
select.classList.toggle('open');
89-
};
90-
91-
handleDropdownKeydown=function(event){
92-
constselect=document.querySelector('.custom-select');
93-
constoptions=select.querySelectorAll('.option');
94-
constisOpen=select.classList.contains('open');
95-
96-
switch(event.key){
97-
case'Enter':
98-
case' ':
99-
event.preventDefault();
100-
toggleSegmentDropdown();
101-
break;
102-
case'ArrowDown':
103-
event.preventDefault();
104-
if(!isOpen)toggleSegmentDropdown();
105-
options[0].focus();
106-
break;
107-
case'Escape':
108-
if(isOpen)toggleSegmentDropdown();
109-
break;
110-
}
111-
};
112-
113-
handleOptionKeydown=function(event,option,selectedValue){
114-
constselect=document.querySelector('.custom-select');
115-
constoptions=select.querySelectorAll('.option');
116-
constcurrentIndex=Array.from(options).indexOf(option);
117-
118-
switch(event.key){
119-
case'Enter':
120-
case' ':
121-
event.preventDefault();
122-
selectSegmentOption(option,selectedValue);
123-
break;
124-
case'ArrowDown':
125-
event.preventDefault();
126-
if(currentIndex<options.length-1){
127-
options[currentIndex+1].focus();
128-
}
129-
break;
130-
case'ArrowUp':
131-
event.preventDefault();
132-
if(currentIndex>0){
133-
options[currentIndex-1].focus();
134-
}
135-
break;
136-
case'Escape':
137-
select.classList.remove('open');
138-
select.querySelector('.select-display').focus();
139-
break;
140-
}
141-
};
142-
143-
selectSegmentOption=asyncfunction(option,selectedValue){
144-
constselectDisplay=document.querySelector('.select-display');
145-
146-
selectDisplay.textContent=option.textContent;
147-
148-
constredirectMap=awaitfetchRedirectMap();
149-
150-
constpathname=window.location.pathname;
151-
constcurrentPath=pathname.replace(SITE_BASE_URL,"");
152-
153-
if(selectedValue==='enterprise'){
154-
localStorage.setItem(enterpriseDocTypeLockKey,'true');
155-
156-
constenterprisePath=Object.keys(redirectMap).find(
157-
key=>redirectMap[key]===currentPath
158-
);
159-
160-
if(enterprisePath){
161-
window.location.href=`${SITE_BASE_URL}${enterprisePath}`;
162-
}else{
163-
window.location.href=`${SITE_BASE_URL}/`;
164-
}
165-
}elseif(selectedValue==='gitops'){
166-
localStorage.setItem(enterpriseDocTypeLockKey,'false');
167-
168-
constgitOpsPath=redirectMap[currentPath];
169-
170-
if(gitOpsPath){
171-
window.location.href=`${SITE_BASE_URL}${gitOpsPath}`;
172-
}else{
173-
window.location.href=`${SITE_BASE_URL}/${SITE_GITOPS_COLLECTION}/`;
174-
}
175-
}
176-
};
177-
// Close dropdown when clicking outside
178-
document.addEventListener('click',(e)=>{
179-
constselect=document.querySelector('.custom-select');
180-
if(!select.contains(e.target)){
181-
select.classList.remove('open');
182-
}
183-
});
184-
</script>
185-

‎assets/js/src/argohub-redirect.js‎

Lines changed: 132 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,157 @@
1-
constenterpriseDocumentationCookie="cfdoctype=enterprise";
2-
constARGOHUB_MAIN_PATH=`/${SITE_GITOPS_COLLECTION}/`;
3-
constenterpriseDocTypeLockKey="enterpriseDocTypeLock";
1+
constGITOPS_DOC_COOKIE='cfdoctype=gitops'
2+
constIS_GITOPS_DOC_COOKIE_SET=document.cookie.includes(GITOPS_DOC_COOKIE)
43

5-
functioncheckIfEnterpriseDocumentationCookieSet(){
6-
returndocument.cookie.includes(enterpriseDocumentationCookie);
7-
}
4+
handleRedirect()
85

96
asyncfunctiongetArgoHubRedirectURL(currentPath){
10-
currentPath=currentPath.replace(SITE_BASE_URL,"");
7+
currentPath=currentPath.replace(SITE_BASE_URL,'')
118

12-
constredirectMap=awaitfetchRedirectMap();
9+
constredirectMap=awaitfetchRedirectMap()
1310

14-
constnewPath=redirectMap[currentPath];
15-
if(!newPath)returnnull;
11+
constnewPath=redirectMap[currentPath]
12+
if(!newPath)returnnull
1613

1714
constnewURL=
18-
newPath===ARGOHUB_MAIN_PATH
15+
newPath===`/${SITE_GITOPS_COLLECTION}/`
1916
?`${location.href}${SITE_GITOPS_COLLECTION}`
20-
:location.href.replace(currentPath,newPath);
17+
:location.href.replace(currentPath,newPath)
2118

22-
returnnewURL;
19+
returnnewURL
2320
}
2421

2522
asyncfunctionhandleRedirect(){
26-
if(shouldSkipRedirect())return;
23+
if(SITE_IS_GITOPS_COLLECTION||!IS_GITOPS_DOC_COOKIE_SET)return
2724

28-
constargoHubRedirectURL=awaitgetArgoHubRedirectURL(location.pathname);
29-
if(!argoHubRedirectURL)return;
25+
constargoHubRedirectURL=awaitgetArgoHubRedirectURL(location.pathname)
26+
if(!argoHubRedirectURL)return
3027

31-
location.href=argoHubRedirectURL;
28+
location.href=argoHubRedirectURL
3229
}
3330

3431
asyncfunctionfetchRedirectMap(){
35-
constresponse=awaitfetch(
36-
`${SITE_BASE_URL}/assets/js/src/argohub-redirect-mapping.json`
37-
);
32+
constresponse=awaitfetch(`${SITE_BASE_URL}/assets/js/src/argohub-redirect-mapping.json`)
3833
if(!response.ok){
39-
thrownewError("Failed to fetch the collections redirect map.");
34+
thrownewError('Failed to fetch the collections redirect map.')
35+
}
36+
returnresponse.json()
37+
}
38+
39+
functionsetGitOpsDocumentationCookie(){
40+
constmaxAge=2592000
41+
configureGitOpsDocumentationCookie(maxAge)
42+
}
43+
44+
functionremoveGitOpsDocumentationCookie(){
45+
configureGitOpsDocumentationCookie(0)
46+
}
47+
48+
functionconfigureGitOpsDocumentationCookie(maxAge){
49+
letcookie=`${GITOPS_DOC_COOKIE}; Max-Age=${maxAge}; Path=/; SameSite=Strict`
50+
51+
if(location.protocol==='https:'){
52+
cookie+='; Secure'
53+
}
54+
55+
if(location.hostname.endsWith('.codefresh.io')){
56+
cookie+='; Domain=.codefresh.io'
57+
}
58+
59+
document.cookie=cookie
60+
}
61+
62+
functiontoggleSegmentDropdown(){
63+
constselect=document.querySelector('.custom-select')
64+
select.classList.toggle('open')
65+
}
66+
67+
functionhandleDropdownKeydown(event){
68+
constselect=document.querySelector('.custom-select')
69+
constoptions=select.querySelectorAll('.option')
70+
constisOpen=select.classList.contains('open')
71+
72+
switch(event.key){
73+
case'Enter':
74+
case' ':
75+
event.preventDefault()
76+
toggleSegmentDropdown()
77+
break
78+
case'ArrowDown':
79+
event.preventDefault()
80+
if(!isOpen)toggleSegmentDropdown()
81+
options[0].focus()
82+
break
83+
case'Escape':
84+
if(isOpen)toggleSegmentDropdown()
85+
break
4086
}
41-
returnresponse.json();
4287
}
4388

44-
functionisEnterpriseLockPresent(){
45-
constenterpriseDocTypeLock=localStorage.getItem(enterpriseDocTypeLockKey);
46-
return!!enterpriseDocTypeLock;
89+
functionhandleOptionKeydown(event,option,selectedValue){
90+
constselect=document.querySelector('.custom-select')
91+
constoptions=select.querySelectorAll('.option')
92+
constcurrentIndex=Array.from(options).indexOf(option)
93+
94+
switch(event.key){
95+
case'Enter':
96+
case' ':
97+
event.preventDefault()
98+
selectSegmentOption(option,selectedValue)
99+
break
100+
case'ArrowDown':
101+
event.preventDefault()
102+
if(currentIndex<options.length-1){
103+
options[currentIndex+1].focus()
104+
}
105+
break
106+
case'ArrowUp':
107+
event.preventDefault()
108+
if(currentIndex>0){
109+
options[currentIndex-1].focus()
110+
}
111+
break
112+
case'Escape':
113+
select.classList.remove('open')
114+
select.querySelector('.select-display').focus()
115+
break
116+
}
47117
}
48118

49-
functionshouldSkipRedirect(){
50-
returntrue;// Redirect temporarily disabled. Will be re-enabled with a new cookie-based mechanism.
51-
// return (
52-
// isEnterpriseLockPresent() ||
53-
// SITE_IS_GITOPS_COLLECTION ||
54-
// checkIfEnterpriseDocumentationCookieSet()
55-
// );
119+
asyncfunctionselectSegmentOption(option,selectedValue){
120+
constselectDisplay=document.querySelector('.select-display')
121+
122+
selectDisplay.textContent=option.textContent
123+
124+
constredirectMap=awaitfetchRedirectMap()
125+
126+
constpathname=window.location.pathname
127+
constcurrentPath=pathname.replace(SITE_BASE_URL,'')
128+
129+
if(selectedValue==='enterprise'){
130+
removeGitOpsDocumentationCookie()
131+
132+
constenterprisePath=Object.keys(redirectMap).find((key)=>redirectMap[key]===currentPath)
133+
134+
if(enterprisePath){
135+
window.location.href=`${SITE_BASE_URL}${enterprisePath}`
136+
}else{
137+
window.location.href=`${SITE_BASE_URL}/`
138+
}
139+
}elseif(selectedValue==='gitops'){
140+
setGitOpsDocumentationCookie()
141+
142+
constgitOpsPath=redirectMap[currentPath]
143+
144+
if(gitOpsPath){
145+
window.location.href=`${SITE_BASE_URL}${gitOpsPath}`
146+
}else{
147+
window.location.href=`${SITE_BASE_URL}/${SITE_GITOPS_COLLECTION}/`
148+
}
149+
}
56150
}
57151

58-
handleRedirect();
152+
document.addEventListener('click',(e)=>{
153+
constselect=document.querySelector('.custom-select')
154+
if(!select.contains(e.target)){
155+
select.classList.remove('open')
156+
}
157+
})

‎gitops/index.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
layout: home
33
title: GitOps Home
4+
sitemap: false
45
---
56

67
<mainclass="bd-masthead bd-masthead-home"id="content"role="main">

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp