Skip to content

Commit 1881b39

Browse files
committed
Remove the hidden gray box from the landing page
1 parent da3ef4a commit 1881b39

File tree

5 files changed

+18
-85
lines changed

5 files changed

+18
-85
lines changed

assets/src/legacy/view.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
* @license MPL-2.0
66
*/
77

8+
/**
9+
* Split and clean a keyword string and return an array of keywords.
10+
* @param keywords A string having keywords separated by commas.
11+
* @returns {string[]}
12+
*/
13+
function cleanKeywords(keywords) {
14+
return keywords.split(",").map(item => item.trim());
15+
}
16+
817
var searchProjects = function(){
918
// Hide search if there are no projects
1019
if ($("#content.container li .liz-project-title").length === 0) {
@@ -44,11 +53,11 @@ var searchProjects = function(){
4453
// Get unique keywords for visible projects
4554
var getVisibleProjectsKeywords = function() {
4655
var keywordList = [];
47-
var selector = '.liz-repository-project-item :visible .keywordList';
56+
var selector = '.liz-repository-project-item :visible .liz-project';
4857

4958
$(selector).each(function () {
50-
if ($(this).text() !== '') {
51-
var keywordsSplitByComma = $(this).text().toUpperCase().split(', ');
59+
const keywordsSplitByComma = cleanKeywords($(this).attr('data-lizmap-keywords'));
60+
if (keywordsSplitByComma.length > 0) {
5261
if (isGraph) {
5362
for (var index = 0; index < keywordsSplitByComma.length; index++) {
5463
keywordList = keywordList.concat(keywordsSplitByComma[index].split('/'));
@@ -66,9 +75,9 @@ var searchProjects = function(){
6675
var getEdges = function () {
6776
var edgeList = [];
6877

69-
$('.liz-repository-project-item :visible .keywordList').each(function () {
70-
if ($(this).text() !== '') {
71-
var keywordsSplitByComma = $(this).text().toUpperCase().split(', ');
78+
$('.liz-repository-project-item :visible .liz-project').each(function () {
79+
const keywordsSplitByComma = cleanKeywords($(this).attr('data-lizmap-keywords'));
80+
if (keywordsSplitByComma.length > 0) {
7281
for (var index = 0; index < keywordsSplitByComma.length; index++) {
7382
var keywordsInGraph = keywordsSplitByComma[index].split('/');
7483

@@ -95,9 +104,9 @@ var searchProjects = function(){
95104
$("#content.container .liz-repository-title").hide();
96105

97106
// Show project when its keywords match all keywords in selectedKeywords
98-
$('.keywordList').each(function () {
107+
$('.liz-project').each(function () {
99108
var showProject = false;
100-
var keywordListSplitByComma = $(this).text().toUpperCase().split(', ');
109+
var keywordListSplitByComma = cleanKeywords($(this).attr('data-lizmap-keywords'));
101110

102111
// Graph
103112
if (isGraph) {

lizmap/modules/view/templates/view.tpl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@
2323
data-lizmap-proj="{$p->proj}">
2424
<a class="liz-project-view" href="{$p->url}{if $hide_header}&h=0{/if}">
2525
<img width="250" height="250" loading="lazy" src="{$p->img}" alt="project image" class="_liz-project-img img-fluid">
26-
<p class="liz-project-desc" >
27-
<!-- This block is deprecated, use dataset attributes -->
28-
<b class="title">{$p->title}</b>
29-
<br/>
30-
<br/><b>{@default.project.abstract.label@}</b>&nbsp;: <span class="abstract">{$p->abstract|strip_tags|truncate:100}</span>
31-
<br/>
32-
<br/><b>{@default.project.keywordList.label@}</b>&nbsp;: <span class="keywordList">{$p->keywordList}</span>
33-
</p>
3426
</a>
3527
</div>
3628
<h5 class="liz-project-title">{$p->title}</h5>

lizmap/www/assets/css/view.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
max-width:100%;
2121
}
2222

23-
.liz-project-desc {
24-
display: none;
25-
}
26-
2723
.liz-project:hover {
2824
background-color: #f8faff;
2925
}

lizmap/www/themes/default/css/view.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
background-color: white;
33
}
44

5-
.liz-project-desc {
6-
display: none;
7-
}
8-
95
.liz-project:hover {
106
background-color: #f8faff;
117
}

tests/end2end/playwright/project-homepage.spec.js

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test.describe('Projects homepage @readonly', function () {
88
await page.goto(url, { waitUntil: 'networkidle' });
99
});
1010

11-
test('should display project metadata (cold cache)', async function ({ page }) {
11+
test('should have project metadata', async function ({ page }) {
1212

1313
let project = page.locator(
1414
'.liz-repository-project-item'
@@ -27,19 +27,6 @@ test.describe('Projects homepage @readonly', function () {
2727
await expect(project).toHaveAttribute(
2828
"data-lizmap-abstract", 'This is an abstract');
2929

30-
const allMetadata = await project.locator('.liz-project-desc');
31-
await expect(allMetadata).not.toBeVisible();
32-
33-
await project.hover();
34-
// await expect(allMetadata).toBeVisible();
35-
await expect(allMetadata.locator('.title')).toContainText('Test tags: nature, flower');
36-
await expect(allMetadata.locator('.abstract')).toContainText('This is an abstract');
37-
await expect(allMetadata.locator('.keywordList')).toContainText('nature, flower');
38-
39-
// hover on header
40-
await page.locator('#headermenu').hover();
41-
await expect(allMetadata).not.toBeVisible();
42-
4330
// another project
4431
project = page.locator(
4532
'.liz-repository-project-item'
@@ -57,52 +44,5 @@ test.describe('Projects homepage @readonly', function () {
5744
"data-lizmap-title", 'Tests tags: nature, tree');
5845
await expect(project).toHaveAttribute(
5946
"data-lizmap-abstract", 'Tags: nature, tree');
60-
61-
const allMetadataTree = project.locator('.liz-project-desc');
62-
await expect(allMetadataTree).not.toBeVisible();
63-
64-
await project.hover();
65-
// await expect(allMetadataTree).toBeVisible();
66-
await expect(allMetadataTree.locator('.title')).toContainText('Tests tags: nature, tree');
67-
await expect(allMetadataTree.locator('.abstract')).toContainText('Tags: nature, tree');
68-
await expect(allMetadataTree.locator('.keywordList')).toContainText('nature, tree');
69-
70-
// hover on header
71-
await page.locator('#headermenu').hover();
72-
await expect(allMetadataTree).not.toBeVisible();
73-
74-
});
75-
76-
test('should display project metadata (hot cache)', async function ({ page }) {
77-
78-
const project = page.locator(
79-
'.liz-repository-project-item'
80-
).filter(
81-
{ hasText: 'Test tags: nature, flower' }
82-
).locator('.liz-project');
83-
84-
await expect(project).toHaveAttribute(
85-
"data-lizmap-proj",'EPSG:4326');
86-
await expect(project).toHaveAttribute(
87-
"data-lizmap-bbox", '-1.2459627329192546, -1.0, 1.2459627329192546, 1.0');
88-
await expect(project).toHaveAttribute(
89-
"data-lizmap-keywords", 'nature, flower');
90-
await expect(project).toHaveAttribute(
91-
"data-lizmap-title", 'Test tags: nature, flower');
92-
await expect(project).toHaveAttribute(
93-
"data-lizmap-abstract", 'This is an abstract');
94-
const allMetadata = project.locator('.liz-project-desc');
95-
await expect(allMetadata).not.toBeVisible();
96-
97-
await project.hover();
98-
// await expect(allMetadata).toBeVisible();
99-
await expect(allMetadata.locator('.title')).toContainText('Test tags: nature, flower');
100-
await expect(allMetadata.locator('.abstract')).toContainText('This is an abstract');
101-
await expect(allMetadata.locator('.keywordList')).toContainText('nature, flower');
102-
103-
// hover on header
104-
await page.locator('#headermenu').hover();
105-
await expect(allMetadata).not.toBeVisible();
106-
10747
});
10848
});

0 commit comments

Comments
 (0)