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

GP: Duplicate meta descriptions #716

Merged
merged 36 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0c6cd67
GpTerms: add page description
xbpcb Dec 16, 2024
56a8eb7
GpNetwTools: add page descr
xbpcb Dec 16, 2024
ca63a22
GpNetwork: add page descr
xbpcb Dec 16, 2024
ed075a6
GpAPI: add page descr
xbpcb Dec 16, 2024
96a36ea
GpAuthApi: add page descr
xbpcb Dec 16, 2024
7b3c1be
GpNetTools: fix title handling
xbpcb Dec 17, 2024
23b1700
Merge branch 'master' into gh-715
xbpcb Dec 18, 2024
cd286cd
GpNetTools: fix navigation to a new page
xbpcb Dec 18, 2024
3f0d00a
GpNetTools: upd title-descr logic
xbpcb Dec 18, 2024
69737a1
GpNetTools: upd comment
xbpcb Dec 18, 2024
aab2427
Update descriptions
MartinKolarik Dec 19, 2024
fece164
GpNetTools: upd title and descr logic
xbpcb Dec 19, 2024
12c9c39
Merge branch 'gh-715' of https://github.com/jsdelivr/www.jsdelivr.com…
xbpcb Dec 19, 2024
da90967
GpNetTools: mv computed title and descr to onconfig event
xbpcb Dec 19, 2024
9ed5789
GpNetTools: fix title,descr handling
xbpcb Dec 19, 2024
cb49bcd
Gp: mod routes to handle redirect on wrong meas type
xbpcb Dec 20, 2024
cd4e8c3
Gp: small fix to net-tools routing
xbpcb Dec 20, 2024
cc8bf4d
Gp: improve net-tools routing, add comments
xbpcb Dec 20, 2024
e2123b7
Gp: mod net-tools routing
xbpcb Dec 20, 2024
80e2fed
GpNetTools: rm unnecessary checks and redirections
xbpcb Dec 20, 2024
4d634f8
Fix linter issues
xbpcb Dec 20, 2024
c681dda
GpNetTools: fix typo
xbpcb Dec 20, 2024
7424219
GpNetTools: get rid of redundant logic and vars
xbpcb Dec 20, 2024
ffbc5e4
Gp: fix netTools route
xbpcb Dec 23, 2024
526e482
Merge pull request #719 from jsdelivr/gh-715-rework
xbpcb Dec 23, 2024
ede1820
Merge branch 'master' into gh-715
MartinKolarik Dec 30, 2024
c80b168
Update globalping.js
MartinKolarik Dec 30, 2024
9dc747b
GpNetTools: fix raw loc parsing
xbpcb Dec 30, 2024
39d03c5
Gp: fix net-tools routing
xbpcb Dec 30, 2024
7f8cc5d
GpNetTools: fix rawLoc hadling
xbpcb Dec 30, 2024
144dbe9
GpNetTools: redirect pure test types to from-world
xbpcb Dec 30, 2024
1bfb25c
GpNetTools: mod client side url handling
xbpcb Dec 30, 2024
5e3a4e6
Gp: fix routing
xbpcb Dec 30, 2024
ea0778e
Gp: fix netTools routing case handling
xbpcb Dec 30, 2024
017d3be
Merge branch 'gh-715' of github.com:jsdelivr/www.jsdelivr.com into gh…
MartinKolarik Jan 2, 2025
8852f4e
Merge branch 'master' into gh-715
MartinKolarik Jan 2, 2025
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
47 changes: 39 additions & 8 deletions src/routes/globalping.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,53 @@ koaElasticUtils.addRoutes(router, [
* Network tools pages.
*/
koaElasticUtils.addRoutes(router, [
[ '/network-tools', '/network-tools/:params' ],
[ '/network-tools/:params?' ],
], async (ctx) => {
let data = {
params: ctx.params.params || '',
};
let data;
let { params = '' } = ctx.params;
let splitPoint = '-from-';
let splitPointIdx = params.indexOf(splitPoint);
let [ testType, target ] = splitPointIdx === -1
? params.split(splitPoint)
: [ params.slice(0, splitPointIdx), params.slice(splitPointIdx + splitPoint.length) ];

try {
// check if test type is correct
switch (testType.toLowerCase()) {
case 'ping':
case 'dns':
case 'mtr':
case 'http':
case 'traceroute':
data = {
params: ctx.params.params || '',
};

break;

default:
throw new Error(`Measurement type ${testType} is incorrect!`);
}

// if there is -from- part in the path but no target provided by user
if (splitPointIdx !== -1 && !target) {
throw new Error('Target was not provided!');
}

ctx.body = await ctx.render('pages/globalping/network-tools.html', data);
ctx.maxAge = 5 * 60;
} catch (e) {
if (app.env === 'development') {
console.error(e);
}
// TODO: 715 app call leas to Reference error: undefined
// if (app.env === 'development') {
// console.error(e);
// }

ctx.status = 301;
return ctx.redirect('/');

// redirect conserving the target or just to default ping test page
let newPath = target ? `ping-from-${target}` : 'ping';

return ctx.redirect(`/network-tools/${newPath}`);
}
});

Expand Down
1 change: 1 addition & 0 deletions src/views/pages/globalping/docs/api.globalping.io.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
data () {
return {
title: 'Globalping API',
description: 'Use the Globalping API to access thousands of global probes and build your own tools and integrations.',
};
},
computed: {
Expand Down
1 change: 1 addition & 0 deletions src/views/pages/globalping/docs/auth.globalping.io.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
data () {
return {
title: 'Globalping Authentication API',
description: 'Authenticate your Globalping integrations using our OAuth API for the best user flow.',
};
},
computed: {
Expand Down
95 changes: 40 additions & 55 deletions src/views/pages/globalping/network-tools.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ <h1>{{displayingTestType}} from {{#if locationData.probesCnt}}multiple locations

<span>test</span>
</div>
{{elseif placeholerLocation}}
{{elseif rawLocationToDisplay}}
<h1>{{displayingTestType}} from multiple locations in </h1>
<span class="gp-nettools_main-info_content_temp-location">
{{#if placeholerLocation.toLowerCase() !== 'world'}}
{{placeholerLocation}},
{{#if rawLocationToDisplay.toLowerCase() !== 'world'}}
{{rawLocationToDisplay}},
{{/if}}

<a target="_blank" rel="noopener noreferrer" href="{{global.location.origin}}/network-tools/{{selectedTestType}}-from-world" class="gp-nettools_green-text">
Expand Down Expand Up @@ -277,15 +277,30 @@ <h1>{{displayingTestType}} from multiple locations in </h1>
probesParsed: false,
testReqParams: null,
rawLocation: null,
rawLocationToDisplay: null,
allRequiredDataReady: false,
};
},
onconfig () {
if (!Ractive.isServer) {
let title, description;
let { rawTestType, rawLocation, rawLocationToDisplay } = this.getInitialRawDataFromUrl();

// create temp title, descr before any checks, required by GA
title = this.createMetaTitle(rawTestType, rawLocationToDisplay);
description = this.createMetaDescr(rawTestType, rawLocationToDisplay);

this.set('title', title);
this.set('description', description);
this.set('selectedTestType', rawTestType);
this.set('rawLocation', rawLocation);
this.set('rawLocationToDisplay', rawLocationToDisplay);
}
},
oninit () {
if (!Ractive.isServer) {
this.getGlobalpingProbesData();

this.getParamsFromUrl();

this.observe('selectedTestType', (selectedTestType) => {
if (selectedTestType) {
switch (selectedTestType.toLowerCase()) {
Expand Down Expand Up @@ -356,7 +371,7 @@ <h1>{{displayingTestType}} from multiple locations in </h1>
let rawLocation = this.get('rawLocation');

// handle locationData, highLevelLocationHref
if (rawLocation && rawLocation !== 'world') {
if (rawLocation && rawLocation.toLowerCase() !== 'world') {
let locationData = this.getLocDataByLocValue(rawLocation);

if (locationData) {
Expand All @@ -366,6 +381,8 @@ <h1>{{displayingTestType}} from multiple locations in </h1>
} else {
// when testType correct but location absent at the moment among the probes or incorrect
this.moveToNewPageURL(selectedTestType, null, true);

return;
}
} else {
this.set('locationData', { from: 'World', probesCnt: this.get('totalProbesCnt') });
Expand All @@ -374,7 +391,7 @@ <h1>{{displayingTestType}} from multiple locations in </h1>

// handle meta tag title and description once location is confirmed as presented
let locationData = this.getLocDataByLocValue(rawLocation);
let title = this.createMetaTitle(selectedTestType, locationData ? locationData.name : 'world');
let title = this.createMetaTitle(selectedTestType, locationData ? locationData.name : 'World');
let description = this.createMetaDescr(selectedTestType, locationData ? locationData.name : 'world');

this.set('title', title);
Expand Down Expand Up @@ -756,54 +773,6 @@ <h1>{{displayingTestType}} from multiple locations in </h1>
http.fetchGlobalpingProbes().then(this.handleProbesResponse(false));
}
},
getParamsFromUrl () {
let rawParamsValue = this.get('params');

// if user tries to get the network-tools page without providing at least testType
// navigate to default network-tools page
if (rawParamsValue === null || typeof rawParamsValue === 'undefined') {
this.moveToNewPageURL(INITIAL_OPTS_VALUES.type, null, true);

return;
}

let clearParamsValue = rawParamsValue.replace(/\/network-tools\/?/, '').toLowerCase();
let splitPoint = '-from-';
let splitPointIdx = clearParamsValue.indexOf(splitPoint);
let [ rawTestType, rawLocation ] = splitPointIdx === -1
? clearParamsValue.split(splitPoint)
: [ clearParamsValue.slice(0, splitPointIdx), clearParamsValue.slice(splitPointIdx + splitPoint.length) ];

// if testType provided by user is incorrect
// navigate to default network-tools testType page but conserve the location
if (!this.checkIfTestTypeCorrect(rawTestType)) {
let isFullParam = clearParamsValue.includes(splitPoint) && rawLocation && rawTestType;

this.moveToNewPageURL(INITIAL_OPTS_VALUES.type, isFullParam ? rawLocation : null, !isFullParam);

return;
}

// if testType provided by user is correct but there is no location provided
// navigate to provided by user testType network-tools page
if (clearParamsValue.includes(splitPoint) && !rawLocation) {
this.moveToNewPageURL(rawTestType, null, true);

return;
}

this.set('selectedTestType', rawTestType);
this.set('rawLocation', rawLocation || 'world');
let placeholderLocation = _.capitalizeStrEveryFirstLetter((rawLocation || 'world').split('-').join(' '), CAPITALIZE_EXCLUDE_LIST);
this.set('placeholerLocation', placeholderLocation);

// set temp meta tag title, descr
let title = this.createMetaTitle(rawTestType, placeholderLocation);
let description = this.createMetaDescr(rawTestType, placeholderLocation);

this.set('title', title);
this.set('description', description);
},
checkIfTestTypeCorrect (testType) {
if (!testType) { return false; }

Expand Down Expand Up @@ -886,5 +855,21 @@ <h1>{{displayingTestType}} from multiple locations in </h1>

return true;
},
getInitialRawDataFromUrl () {
let rawParamsValue = this.get('params');
let clearParamsValue = rawParamsValue.replace(/\/network-tools\/?/, '').toLowerCase();
let splitPoint = '-from-';
let splitPointIdx = clearParamsValue.indexOf(splitPoint);
let [ rawTestType, rawLocation ] = splitPointIdx === -1
? clearParamsValue.split(splitPoint)
: [ clearParamsValue.slice(0, splitPointIdx), clearParamsValue.slice(splitPointIdx + splitPoint.length) ];
let rawLocationToDisplay = _.capitalizeStrEveryFirstLetter((rawLocation || 'world').split('-').join(' '), CAPITALIZE_EXCLUDE_LIST);

return {
rawTestType,
rawLocation,
rawLocationToDisplay,
};
},
};
</script>
2 changes: 1 addition & 1 deletion src/views/pages/globalping/network.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
data () {
return {
title: 'Network - Globalping',
description: 'Network - Globalping',
description: 'Explore the global network map of Globalping probes.',
availableFilters: [
{
name: 'Europe',
Expand Down
1 change: 1 addition & 0 deletions src/views/pages/globalping/terms.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ <h1 class="page-content_main_title">Terms &amp; Policies</h1>
data () {
return {
title: 'Terms & Policies - Globalping',
description: 'Learn about the terms of usage of the global network testing platform Globalping.',
currentPolicy: 'terms-of-use',
};
},
Expand Down