Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
R3
howto-cards
Commits
d1786645
Commit
d1786645
authored
Feb 07, 2020
by
Jacek Lebioda
Browse files
fix: corrected router's code
parent
bb4365ec
Changes
1
Hide whitespace changes
Inline
Side-by-side
.ci/.autoRedirect
View file @
d1786645
...
...
@@ -15,54 +15,69 @@
});
}
// define URLs
var
internalURL
=
'
https://r3-core.pages.uni.lu/howto-cards-internal
'
;
var
externalURL
=
'
https://r3.pages.uni.lu/howto-cards
'
;
UrlExists
(
internalURL
+
'
/index.html
'
,
function
(
status
){
function
GetShortcutDestination
()
{
var
s
=
window
.
location
.
href
;
var
pathArray
=
s
.
split
(
'
?
'
);
//
c
ut the query if it exists
//
C
ut the query if it exists
if
(
pathArray
.
length
>
1
)
{
sub
=
pathArray
[
1
];
return
pathArray
[
1
];
}
else
{
sub
=
''
;
return
''
;
}
}
// Pick the shortcut link destination from URL, like: `category:subcategory:card-name`
var
sub
=
GetShortcutDestination
();
// Define URLs
var
internalPortalURL
=
'
https://r3-core.pages.uni.lu/howto-cards-internal
'
;
var
externalPortalURL
=
'
https://r3.pages.uni.lu/howto-cards
'
;
// First, check whether internal pages are accessible...
var
internalIndexURL
=
internalPortalURL
+
'
/index.html
'
;
UrlExists
(
internalIndexURL
,
function
(
status
){
if
(
status
===
200
){
// internal pages
//
If the
internal pages
are accessible, try to redirect into correct page
if
(
sub
.
length
>
0
)
{
UrlExists
(
internalURL
+
'
/stable/internal/
'
+
sub
,
function
(
status
){
if
(
status
==
200
)
{
// if sub-card is internal in the internal directory and exists
window
.
location
.
href
=
internalURL
+
'
/stable/internal/cards/
'
+
sub
;
var
internalCardURL
=
internalPortalURL
+
'
/stable/internal/cards/
'
+
sub
;
UrlExists
(
internalCardURL
,
function
(
status
){
if
(
status
==
200
)
{
// The sub-card is internal, and is accessible
window
.
location
.
href
=
internalCardURL
;
}
else
{
UrlExists
(
internal
URL
+
'
/stable/external/
'
+
sub
,
function
(
status
){
UrlExists
(
internal
PortalURL
+
'
/stable/external/
'
+
sub
,
function
(
status
){
if
(
status
==
200
)
{
// if sub-card is internal in the external directory and exists
window
.
location
.
href
=
internal
URL
+
'
/stable/external/cards/
'
+
sub
;
window
.
location
.
href
=
internal
PortalURL
+
'
/stable/external/cards/
'
+
sub
;
}
else
{
window
.
location
.
href
=
internal
URL
+
'
/stable/404.html
'
;
window
.
location
.
href
=
internal
PortalURL
+
'
/stable/404.html
'
;
}
});
}
});
}
else
{
UrlExists
(
internalURL
+
'
/stable
'
,
function
(
status
){
if
(
status
==
200
)
{
// if card is internal and exists
window
.
location
.
href
=
internalURL
+
'
/stable
'
;
}
else
{
// The user did not request specific card, redirect him just to the stable index
var
internalPortalIndexURL
=
internalPortalURL
+
'
/stable
'
;
var
internalPortal404URL
=
internalPortalURL
+
'
/stable/404.html
'
;
UrlExists
(
internalPortalIndexURL
,
function
(
status
){
if
(
status
==
200
)
{
// if page is accessible
window
.
location
.
href
=
internalPortalIndexURL
;
}
else
{
window
.
location
.
href
=
internal
URL
+
'
/stable/404.html
'
;
window
.
location
.
href
=
internal
Portal404URL
;
}
});
}
// external pages
}
else
{
if
(
sub
.
length
>
0
)
{
sub
=
'
external/
'
+
sub
;
}
UrlExists
(
externalURL
+
'
/stable/cards/
'
+
sub
,
function
(
status
){
// The internal pages are not accessible, therefore the user is redirected into correct external page
if
(
sub
.
length
>
0
)
{
sub
=
'
external/cards/
'
+
sub
;
}
var
externalPortalCardURL
=
externalPortalURL
+
'
/stable/
'
+
sub
;
var
externalPortal404URL
=
externalPortalURL
+
'
/stable/404.html
'
;
UrlExists
(
externalPortalURL
+
'
/stable/
'
+
sub
,
function
(
status
){
if
(
status
==
200
)
{
// if sub-card is internal and exists
window
.
location
.
href
=
external
URL
+
'
/stable/cards/
'
+
sub
;
window
.
location
.
href
=
external
PortalCardURL
;
}
else
{
window
.
location
.
href
=
external
URL
+
'
/stable/404.html
'
;
window
.
location
.
href
=
external
Portal404URL
;
}
});
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment