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

Merge Meeds-io/MIPs#161 #264

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions content-service/src/main/java/io/meeds/news/model/News.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,5 +137,7 @@ public class News {

private String illustrationURL;

private String latestVersionId;

private NotePageProperties properties;
}
Original file line number Diff line number Diff line change
Expand Up @@ -992,16 +992,18 @@ public News createNewsArticlePage(News newsArticle, String newsArticleCreator) t
newsArticlePage.setAuthor(newsArticle.getAuthor());
newsArticlePage.setLang(null);
newsArticlePage.setProperties(newsArticle.getProperties());
if (newsArticlePage.getProperties() == null) {
newsArticlePage.setProperties(new NotePageProperties(Long.valueOf(draftNewsId), null, null, true));
}
newsArticlePage = noteService.createNote(wiki, newsArticlesRootNotePage.getName(), newsArticlePage, poster);
// create the version
noteService.createVersionOfNote(newsArticlePage, poster.getUserId());
if (newsArticlePage != null) {
PageVersion pageVersion = noteService.getPublishedVersionByPageIdAndLang(Long.parseLong(newsArticlePage.getId()), null);
// set properties
newsArticle.setId(newsArticlePage.getId());
newsArticle.setLang(newsArticlePage.getLang());
newsArticle.setCreationDate(pageVersion.getCreatedDate());
newsArticle.setProperties(newsArticlePage.getProperties());
newsArticle.setLatestVersionId(pageVersion.getId());
newsArticle.setIllustrationURL(NewsUtils.buildIllustrationUrl(newsArticlePage.getProperties(), newsArticle.getLang()));

NewsPageVersionObject newsArticleVersionMetaDataObject = new NewsPageVersionObject(NEWS_METADATA_PAGE_VERSION_OBJECT_TYPE,
Expand Down Expand Up @@ -1827,6 +1829,7 @@ private News updateArticle(News news, Identity updater, String newsUpdateType) t
// create the version
if (newsUpdateType.equalsIgnoreCase(CONTENT_AND_TITLE.name())) {
noteService.createVersionOfNote(existingPage, updater.getUserId());
news.setLatestVersionId(noteService.getPublishedVersionByPageIdAndLang(Long.valueOf(news.getId()), news.getLang()).getId());
// remove the draft
DraftPage draftPage = noteService.getLatestDraftPageByUserAndTargetPageAndLang(Long.parseLong(existingPage.getId()),
updater.getUserId(),
Expand Down Expand Up @@ -1908,6 +1911,7 @@ private News buildArticle(String newsId, String lang, boolean fetchOriginal) thr
news.setUpdateDate(new Date(metadataItem.getUpdatedDate()));
news.setProperties(pageVersion.getProperties());
news.setUrl(NewsUtils.buildNewsArticleUrl(news, currentUsername));
news.setLatestVersionId(pageVersion.getId());
if (news.getProperties() != null && news.getProperties().getFeaturedImage() != null
&& news.getProperties().getFeaturedImage().getId() != 0) {
news.setIllustrationURL(NewsUtils.buildIllustrationUrl(news.getProperties(), pageVersion.getLang()));
Expand Down Expand Up @@ -1954,7 +1958,7 @@ private News updateDraftArticleForExistingPage(News news, String updater, Page p
draftPage.setProperties(news.getProperties());

draftPage = noteService.updateDraftForExistPage(draftPage, page, null, System.currentTimeMillis(), updater);

news.setId(draftPage.getId());
news.setDraftUpdateDate(draftPage.getUpdatedDate());
news.setDraftUpdater(draftPage.getAuthor());
news.setTargetPageId(draftPage.getTargetPageId());
Expand Down Expand Up @@ -2015,7 +2019,6 @@ private News buildLatestDraftArticle(String parentPageId, String currentIdentity
}
News draftArticle = buildDraftArticle(latestDraft.getId(), currentIdentityId);

draftArticle.setId(latestDraft.getId());
draftArticle.setTargetPageId(latestDraft.getTargetPageId());
draftArticle.setLang(latestDraft.getLang());
return draftArticle;
Expand Down Expand Up @@ -2114,6 +2117,7 @@ private News addNewArticleVersionWithLang(News news, Identity versionCreator, Sp
}
existingPage.setProperties(properties);
noteService.createVersionOfNote(existingPage, versionCreator.getUserId());
news.setLatestVersionId(noteService.getPublishedVersionByPageIdAndLang(Long.valueOf(newsId), news.getLang()).getId());
news.setIllustrationURL(NewsUtils.buildIllustrationUrl(news.getProperties(), news.getLang()));
DraftPage draftPage = noteService.getLatestDraftPageByTargetPageAndLang(Long.parseLong(newsId), news.getLang());
if (draftPage != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ news.composer.placeholderSummaryInput=Summary
news.composer.placeholderContentInput=Body
news.composer.draft=My drafts ({0})
news.composer.draft.savingDraftStatus=Saving the draft...
content.draft.title.untitled=Untitled
news.composer.draft.savedDraftStatus=Draft saved.
news.composer.draft.delete.confirmation=Are you sure you want to delete this draft?
news.composer.postArticle=Post an Article
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ news.composer.placeholderSummaryInput=Résumé
news.composer.placeholderContentInput=Contenu
news.composer.draft=Brouillons ({0})
news.composer.draft.savingDraftStatus=Sauvegarde en cours...
content.draft.title.untitled=Sans titre
news.composer.draft.savedDraftStatus=Brouillon sauvegardé
news.composer.draft.delete.confirmation=Etes-vous sûr de vouloir supprimer ce brouillon ?
news.composer.postArticle=Publier un article
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,7 @@ public void testPostNews() throws Exception {
newsArticlePage.setContent(newsArticle.getBody());
newsArticlePage.setParentPageId(rootPage.getId());
newsArticlePage.setAuthor(newsArticle.getAuthor());
newsArticlePage.setProperties(new NotePageProperties(Long.valueOf(newsArticle.getId()), null, null, true));
newsArticlePage.setLang(null);

Page createdPage = mock(Page.class);
Expand All @@ -536,7 +537,6 @@ public void testPostNews() throws Exception {

// Then
verify(noteService, times(1)).createNote(wiki, rootPage.getName(), newsArticlePage, identity);
verify(noteService, times(1)).createVersionOfNote(createdPage, identity.getUserId());
verify(noteService, times(1)).getPublishedVersionByPageIdAndLang(1L, null);
verify(metadataService, atLeast(1)).createMetadataItem(any(MetadataObject.class),
any(MetadataKey.class),
Expand Down Expand Up @@ -768,7 +768,7 @@ public void testUpdateNewsArticle() throws Exception {
// Then
verify(noteService, times(1)).updateNote(any(Page.class), any(), any());
verify(noteService, times(1)).createVersionOfNote(existingPage, identity.getUserId());
verify(noteService, times(1)).getPublishedVersionByPageIdAndLang(1L, null);
verify(noteService, times(2)).getPublishedVersionByPageIdAndLang(1L, null);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@
<import>war:/conf/news/metadata-plugins-configuration.xml</import>
<import>war:/conf/news/gamification-configuration.xml</import>
<import>war:/conf/news/ckeditor-configuration.xml</import>
<import>war:/conf/news/feature-flags-configuration.xml</import>

</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
* This file is part of the Meeds project (https://meeds.io/).
*
* Copyright (C) 2024 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.
-->
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.exoplatform.org/xml/ns/kernel_1_3.xsd http://www.exoplatform.org/xml/ns/kernel_1_3.xsd"
xmlns="http://www.exoplatform.org/xml/ns/kernel_1_3.xsd">

<component>
<key>ContentFeatureProperties</key>
<type>org.exoplatform.container.ExtendedPropertyConfigurator</type>
<init-params>
<properties-param>
<name>ContentFeatureProperties</name>
<description>Content Feature enablement flag</description>
<property name="exo.feature.newPublicationDrawer.enabled"
value="${exo.feature.newPublicationDrawer.enabled:false}"/>
</properties-param>
</init-params>
</component>

<external-component-plugins>
<target-component>org.exoplatform.groovyscript.text.TemplateService</target-component>
<component-plugin>
<name>UIPortalApplication-head</name>
<set-method>addTemplateExtension</set-method>
<type>org.exoplatform.groovyscript.text.TemplateExtensionPlugin</type>
<init-params>
<values-param>
<name>templates</name>
<description>The list of templates to include in HTML Page Header with UIPortalApplication.gtmpl
</description>
<value>war:/groovy/webui/workspace/UIContentHeadTemplate.gtmpl</value>
</values-param>
</init-params>
</component-plugin>
</external-component-plugins>
</configuration>
3 changes: 3 additions & 0 deletions content-webapp/src/main/webapp/WEB-INF/gatein-resources.xml
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@
<minify>false</minify>
<path>/js/newsDetails.bundle.js</path>
</script>
<depends>
<module>NotesPublication</module>
</depends>
<depends>
<module>vue</module>
</depends>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<%
import org.exoplatform.commons.api.settings.ExoFeatureService;
def rcontext = _ctx.getRequestContext();
ExoFeatureService featureService = uicomponent.getApplicationComponent(ExoFeatureService.class);
def userName = rcontext.getRemoteUser();
%>

<script type="text/javascript" id="contentHeadScripts">
eXo.env.portal.newPublicationDrawerEnabled = <%=featureService.isFeatureActiveForUser("newPublicationDrawer", userName)%>;
</script>
Loading