Skip to content

Commit

Permalink
feat: Add analytics extension to display snv title - MEED-8096 - Meed…
Browse files Browse the repository at this point in the history
…s-io/MIPs#162 (#1338)

Add analytics extension to display snv title
  • Loading branch information
hakermi authored and exo-swf committed Feb 18, 2025
1 parent 2c450cc commit 41e3aeb
Show file tree
Hide file tree
Showing 13 changed files with 325 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ private void createWikiPageStatistic(Page page,
CMSSetting cmsSetting = getCmsService().getSetting("notePage", page.getName());
String title = page.getTitle();
if (cmsSetting != null) {
String pageReference = cmsSetting.getPageReference();
PageKey pageKey = PageKey.create(pageReference);
title = "SNV in " + pageKey.getName();
title = cmsSetting.getPageReference();
}
statisticData.addParameter("contentId", page.getId());
statisticData.addParameter("contentTitle", title);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ analytics.field.label.contentAuthor=Content: Author
analytics.field.label.contentLastModifier=Content: Last Modified Date
analytics.field.label.contentUpdatedDate=Content: Updated Date
analytics.field.label.contentCreationDate=Content: Creation date
analytics.snv.title=SNV in {0}
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ analytics.field.label.contentAuthor=Contenu : Auteur
analytics.field.label.contentLastModifier=Contenu : Date de mise \u00E0 jour
analytics.field.label.contentUpdatedDate=Contenu : Date de modification
analytics.field.label.contentCreationDate=Contenu : Date de cr\u00E9ation
analytics.snv.title=SNV dans {0}
46 changes: 46 additions & 0 deletions notes-webapp/src/main/webapp/WEB-INF/gatein-resources.xml
Original file line number Diff line number Diff line change
Expand Up @@ -521,4 +521,50 @@
</depends>
</module>

<module>
<name>analyticsExtensionNotes</name>
<load-group>commonAnalyticsVueComponentsGroup</load-group>
<script>
<path>/javascript/notesAnalyticsExtension.bundle.js</path>
</script>
<depends>
<module>vue</module>
</depends>
<depends>
<module>vuetify</module>
</depends>
<depends>
<module>eXoVueI18n</module>
</depends>
<depends>
<module>extensionRegistry</module>
</depends>
<depends>
<module>commonVueComponents</module>
</depends>
</module>

<module>
<name>NotesAnalyticsTableExtension</name>
<load-group>commonAnalyticsVueComponentsGroup</load-group>
<script>
<path>/javascript/notesAnalyticsTableExtension.bundle.js</path>
</script>
<depends>
<module>vue</module>
</depends>
<depends>
<module>vuetify</module>
</depends>
<depends>
<module>eXoVueI18n</module>
</depends>
<depends>
<module>extensionRegistry</module>
</depends>
<depends>
<module>commonVueComponents</module>
</depends>
</module>

</gatein-resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<!--
This file is part of the Meeds project (https://meeds.io/).

Copyright (C) 2025 Meeds Association contact@meeds.io

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-->

<template>
<span>
{{ attributeValue }}
</span>
</template>

<script>
export default {
data() {
return {
pageName: null,
pageRefPattern: /^[a-z_]+::[a-z_]+::[a-z_]+$/
};
},
props: {
attrValue: {
type: String,
default: null
}
},
computed: {
attributeValue() {
return this.pageName && this.$t('analytics.snv.title', {0: this.pageName}) || this.attrValue;
}
},
async created() {
if (!this.pageRefPattern.test(this.attrValue)) {
return;
}
const page = await this.getPage();
if (page?.key?.name) {
this.pageName = page.key.name;
}
},
methods: {
async getPage() {
try {
const response = await fetch(`/layout/rest/pages/byRef?pageRef=${this.attrValue}`, {
method: 'GET',
credentials: 'include',
});
if (!response.ok) {
console.error(`Error retrieving page: ${response.statusText}`);
return null;
}
return await response.json();
} catch (error) {
console.error('Fetch error:', error);
return null;
}
}
}
};
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
This file is part of the Meeds project (https://meeds.io/).
Copyright (C) 2025 Meeds Association [email protected]
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

extensionRegistry.registerExtension('AnalyticsSamples', 'SampleItem', {
type: 'noteContentTitle',
options: {
rank: 80,
vueComponent: Vue.options.components['note-content-type-attribute'],
match: (fieldName) => {
return fieldName === 'contentTitle';
}
},
});

extensionRegistry.registerExtension('AnalyticsChart', 'FieldValueName', {
type: 'noteContentTitle',
match: (fieldName, fieldValue) => {
return fieldName === 'contentTitle' && /^[a-z_]+::[a-z_]+::[a-z_]+$/.test(fieldValue);
},
getLabel: (fieldName, fieldValue) => {
return exoi18n.i18n.t('analytics.snv.title', {0: fieldValue.split('::')[2]});
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
This file is part of the Meeds project (https://meeds.io/).
Copyright (C) 2025 Meeds Association [email protected]
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

import NotesContentTypeAttribute from './componnets/NotesContentTypeAttribute.vue';

const components = {
'note-content-type-attribute': NotesContentTypeAttribute,
};

for (const key in components) {
Vue.component(key, components[key]);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
This file is part of the Meeds project (https://meeds.io/).
Copyright (C) 2025 Meeds Association [email protected]
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

import './initComponents.js';
import './extensions.js';
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--
This file is part of the Meeds project (https://meeds.io/).

Copyright (C) 2025 Meeds Association contact@meeds.io

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-->

<template>
<note-content-type-attribute
:attr-value="value" />
</template>

<script>
export default {
props: {
value: {
type: Object,
default: null
}
},
};
</script>

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
This file is part of the Meeds project (https://meeds.io/).
Copyright (C) 2025 Meeds Association [email protected]
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

extensionRegistry.registerExtension('AnalyticsTable', 'CellValue', {
type: 'noteContentTitle',
options: {
rank: 300,
vueComponent: Vue.options.components['note-content-title-cell-value'],
match: (fieldName, aggregationType) => aggregationType === 'TERMS' && fieldName === 'contentTitle.keyword'
},
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
This file is part of the Meeds project (https://meeds.io/).
Copyright (C) 2025 Meeds Association [email protected]
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

import NotesContentTypeAttribute from '../notes-analytics-extension/componnets/NotesContentTypeAttribute.vue';
import NotesContentTitleCellValue from './components/NotesContentTitleCellValue.vue';

const components = {
'note-content-type-attribute': NotesContentTypeAttribute,
'note-content-title-cell-value': NotesContentTitleCellValue
};

for (const key in components) {
Vue.component(key, components[key]);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
This file is part of the Meeds project (https://meeds.io/).
Copyright (C) 2025 Meeds Association [email protected]
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

import './initComponents.js';
import './extensions.js';
2 changes: 2 additions & 0 deletions notes-webapp/webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const config = {
termsAndConditionsView: './src/main/webapp/vue-app/terms-and-conditions/main.js',
termsAndConditionsUpdater: './src/main/webapp/vue-app/terms-and-condition-updater/main.js',
termsAndConditionsEditorExtension : './src/main/webapp/vue-app/terms-and-conditions-editor-extension/main.js',
notesAnalyticsExtension: './src/main/webapp/vue-app/notes-analytics-extension/main.js',
notesAnalyticsTableExtension: './src/main/webapp/vue-app/notes-analytics-table-extension/main.js'
},
output: {
publicPath: '',
Expand Down

0 comments on commit 41e3aeb

Please sign in to comment.