Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EBI-Framework
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ebiwd
EBI-Framework
Commits
e74c7587
Commit
e74c7587
authored
5 years ago
by
Ken Hawkins
Browse files
Options
Downloads
Patches
Plain Diff
Improve announcements matching
Only match subpaths when using `/*`
parent
78fa9f8d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#62376
passed with stage
in 1 minute and 19 seconds
Changes
4
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+1
-2
1 addition, 2 deletions
README.md
js/ebi-global-includes/script/4_ebiFrameworkContent.js
+29
-18
29 additions, 18 deletions
js/ebi-global-includes/script/4_ebiFrameworkContent.js
js/script.js
+20
-9
20 additions, 9 deletions
js/script.js
js/script.min.js
+1
-1
1 addition, 1 deletion
js/script.min.js
with
51 additions
and
30 deletions
README.md
+
1
−
2
View file @
e74c7587
...
...
@@ -164,5 +164,4 @@ Releases are available via NPM at https://www.npmjs.com/package/ebi-framework
Todo: Run the build process and serve with gulp and browsersync.
## Roadmap
-
v1.4: Documentation, EMBL integration, abstracting core structure into a reusable "Framework for the Life Sciences"
-
v1.5: Patterns, accessibility.
-
v1.4: Transition to
[
the Visual Framework 2.0
](
https://visual-framework.github.io/vf-welcome/
)
This diff is collapsed.
Click to expand it.
js/ebi-global-includes/script/4_ebiFrameworkContent.js
+
29
−
18
View file @
e74c7587
...
...
@@ -390,6 +390,7 @@ function ebiInjectAnnouncements(message) {
/**
* Load the downtime/announcement messages, if any.
* We do match not by comparison but by find a url as an array key.
* For more info, see: https://gitlab.ebi.ac.uk/ebiwd/ebi.emblstatic.net-root-assets/tree/master/src
*/
function
ebiFrameworkIncludeAnnouncements
()
{
...
...
@@ -401,16 +402,18 @@ function ebiFrameworkIncludeAnnouncements() {
var
currentHost
=
window
.
location
.
hostname
,
currentPath
=
window
.
location
.
pathname
;
// don't treat wwwdev as distinct from www
currentHost
=
currentHost
.
replace
(
/wwwdev/g
,
"
www
"
);
// don't treat
`
wwwdev
`
as distinct from
`
www
`
currentHost
=
currentHost
.
replace
(
/wwwdev/g
,
"
www
"
);
// try to show any possible variations of the url
// Note: this is pretty simple stupid, but maybe it's more effective than a sophisticated solution?
ebiInjectAnnouncements
(
messages
[
currentHost
]);
ebiInjectAnnouncements
(
messages
[
currentHost
+
'
/
'
]);
ebiInjectAnnouncements
(
messages
[
currentHost
+
'
/*
'
]);
// if the page has a path, try to make matches
// don't try to much no path or '/'
if
(
currentPath
.
length
>
1
)
{
// don't try to much no path or '/'
// Is there an exact match
// console.log('matching:', currentHost+currentPath);
ebiInjectAnnouncements
(
messages
[
currentHost
+
currentPath
]);
ebiInjectAnnouncements
(
messages
[
currentHost
+
currentPath
+
'
/
'
]);
// Handle wildcard matches like `/about/*`
var
currentPathArray
=
currentPath
.
split
(
'
/
'
);
// construct a list of possible paths to match
...
...
@@ -418,24 +421,32 @@ function ebiFrameworkIncludeAnnouncements() {
// - /style-lab/frag1/frag2
// - /style-lab/frag1
// - /style-lab
var
pathsToMatch
=
[
currentHost
+
currentPathArray
[
0
]];
var
pathsToMatch
=
[
currentHost
+
currentPathArray
[
0
]];
for
(
var
i
=
1
;
i
<
currentPathArray
.
length
;
i
++
)
{
var
tempPath
=
pathsToMatch
[
i
-
1
];
pathsToMatch
.
push
(
tempPath
+
'
/
'
+
currentPathArray
[
i
])
var
tempPath
=
pathsToMatch
[
i
-
1
];
pathsToMatch
.
push
(
tempPath
+
'
/
'
+
currentPathArray
[
i
])
;
}
// console.log(pathsToMatch);
for
(
var
i
=
0
;
i
<
pathsToMatch
.
length
;
i
++
)
{
// console.log('matching:',pathsToMatch[i]);
ebiInjectAnnouncements
(
messages
[
pathsToMatch
[
i
]]);
ebiInjectAnnouncements
(
messages
[
pathsToMatch
[
i
]
+
'
*
'
]);
ebiInjectAnnouncements
(
messages
[
pathsToMatch
[
i
]
+
'
/*
'
]);
// console.log('matching:',
pathsToMatch[i]
+'*'
);
// we only match partial paths if they end in *
ebiInjectAnnouncements
(
messages
[
pathsToMatch
[
i
]
+
'
*
'
]);
ebiInjectAnnouncements
(
messages
[
pathsToMatch
[
i
]
+
'
/*
'
]);
}
}
else
{
// no current path means we're on the root domain
// `https://www.ebi.ac.uk` should match `www.ebi.ac.uk` and `www.ebi.ac.uk/` and `www.ebi.ac.uk/*`
// console.log('matching:', currentHost);
ebiInjectAnnouncements
(
messages
[
currentHost
]);
ebiInjectAnnouncements
(
messages
[
currentHost
+
'
/
'
]);
ebiInjectAnnouncements
(
messages
[
currentHost
+
'
/*
'
]);
}
}
}
function
loadRemoteAnnouncements
(
file
)
{
if
(
window
.
XMLHttpRequest
)
{
var
xmlhttp
=
new
XMLHttpRequest
();
var
xmlhttp
=
new
XMLHttpRequest
();
}
xmlhttp
.
open
(
"
GET
"
,
file
,
true
);
xmlhttp
.
onload
=
function
(
e
)
{
...
...
@@ -461,5 +472,5 @@ function ebiFrameworkIncludeAnnouncements() {
}
else
{
loadRemoteAnnouncements
(
'
https://ebi.emblstatic.net/announcements.js
'
);
}
}
This diff is collapsed.
Click to expand it.
js/script.js
+
20
−
9
View file @
e74c7587
...
...
@@ -479,6 +479,7 @@ function ebiInjectAnnouncements(message) {
/**
* Load the downtime/announcement messages, if any.
* We do match not by comparison but by find a url as an array key.
* For more info, see: https://gitlab.ebi.ac.uk/ebiwd/ebi.emblstatic.net-root-assets/tree/master/src
*/
function
ebiFrameworkIncludeAnnouncements
()
{
...
...
@@ -490,16 +491,18 @@ function ebiFrameworkIncludeAnnouncements() {
var
currentHost
=
window
.
location
.
hostname
,
currentPath
=
window
.
location
.
pathname
;
// don't treat wwwdev as distinct from www
// don't treat
`
wwwdev
`
as distinct from
`
www
`
currentHost
=
currentHost
.
replace
(
/wwwdev/g
,
"
www
"
);
// try to show any possible variations of the url
// Note: this is pretty simple stupid, but maybe it's more effective than a sophisticated solution?
ebiInjectAnnouncements
(
messages
[
currentHost
]);
ebiInjectAnnouncements
(
messages
[
currentHost
+
'
/
'
]);
ebiInjectAnnouncements
(
messages
[
currentHost
+
'
/*
'
]);
// if the page has a path, try to make matches
// don't try to much no path or '/'
if
(
currentPath
.
length
>
1
)
{
// don't try to much no path or '/'
// Is there an exact match
// console.log('matching:', currentHost+currentPath);
ebiInjectAnnouncements
(
messages
[
currentHost
+
currentPath
]);
ebiInjectAnnouncements
(
messages
[
currentHost
+
currentPath
+
'
/
'
]);
// Handle wildcard matches like `/about/*`
var
currentPathArray
=
currentPath
.
split
(
'
/
'
);
// construct a list of possible paths to match
...
...
@@ -513,12 +516,20 @@ function ebiFrameworkIncludeAnnouncements() {
pathsToMatch
.
push
(
tempPath
+
'
/
'
+
currentPathArray
[
i
]);
}
// console.log(pathsToMatch);
for
(
var
i
=
0
;
i
<
pathsToMatch
.
length
;
i
++
)
{
// console.log('matching:',pathsToMatch[i]);
ebiInjectAnnouncements
(
messages
[
pathsToMatch
[
i
]]);
// console.log('matching:',
pathsToMatch[i]
+'*'
);
// we only match partial paths if they end in *
ebiInjectAnnouncements
(
messages
[
pathsToMatch
[
i
]
+
'
*
'
]);
ebiInjectAnnouncements
(
messages
[
pathsToMatch
[
i
]
+
'
/*
'
]);
}
}
else
{
// no current path means we're on the root domain
// `https://www.ebi.ac.uk` should match `www.ebi.ac.uk` and `www.ebi.ac.uk/` and `www.ebi.ac.uk/*`
// console.log('matching:', currentHost);
ebiInjectAnnouncements
(
messages
[
currentHost
]);
ebiInjectAnnouncements
(
messages
[
currentHost
+
'
/
'
]);
ebiInjectAnnouncements
(
messages
[
currentHost
+
'
/*
'
]);
}
}
...
...
This diff is collapsed.
Click to expand it.
js/script.min.js
+
1
−
1
View file @
e74c7587
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment