forked from liferay/liferay-portal
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LPS-52978 Add configuration for comments and partially extract alloyE…
…ditor base config to a OSGI module
- Loading branch information
1 parent
7eb456f
commit c1648ba
Showing
9 changed files
with
248 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Bundle-Name: Liferay Comments Editor Conf | ||
Bundle-SymbolicName: com.liferay.comments.portlet.editor.conf | ||
Bundle-Version: 1.0.0 | ||
Include-Resource: classes |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0"?> | ||
<!DOCTYPE project> | ||
|
||
<project> | ||
<import file="../../../../tools/sdk/build-common-osgi-plugin.xml" /> | ||
|
||
<property name="auto.deploy.dir" value="${liferay.home}/osgi/portal" /> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0"?> | ||
|
||
<ivy-module | ||
version="2.0" | ||
xmlns:m2="http://ant.apache.org/ivy/maven" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd" | ||
> | ||
<info module="${plugin.name}" organisation="com.liferay"> | ||
<extends extendType="configurations,description,info" location="${sdk.dir}/ivy.xml" module="com.liferay.sdk" organisation="com.liferay" revision="latest.integration" /> | ||
</info> | ||
|
||
<publications> | ||
<artifact type="jar" /> | ||
<artifact type="pom" /> | ||
<artifact m2:classifier="sources" /> | ||
</publications> | ||
|
||
<dependencies defaultconf="default"> | ||
<dependency name="org.osgi.core" org="org.osgi" rev="6.0.0" /> | ||
</dependencies> | ||
</ivy-module> |
111 changes: 111 additions & 0 deletions
111
...ns-portlet/src/com/liferay/comments/portlet/editor/conf/AlloyEditorConfigContributor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/** | ||
* Copyright (c) 2000-present Liferay, Inc. All rights reserved. | ||
* | ||
* This library 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 2.1 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This library 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. | ||
*/ | ||
|
||
package com.liferay.comments.portlet.editor.conf; | ||
|
||
import com.liferay.portal.kernel.json.JSONObject; | ||
import com.liferay.portal.kernel.language.LanguageUtil; | ||
import com.liferay.portal.kernel.portlet.LiferayPortletResponse; | ||
import com.liferay.portal.kernel.portlet.LiferayPortletURL; | ||
import com.liferay.portal.kernel.util.GetterUtil; | ||
import com.liferay.portal.kernel.util.HtmlUtil; | ||
import com.liferay.portal.kernel.util.LocaleUtil; | ||
import com.liferay.portal.theme.ThemeDisplay; | ||
import com.liferay.portal.util.PortletKeys; | ||
import com.liferay.portlet.editor.config.PortletEditorConfigContributor; | ||
import org.osgi.service.component.annotations.Component; | ||
|
||
import java.util.Locale; | ||
import java.util.Map; | ||
|
||
/** | ||
* @author Sergio González | ||
*/ | ||
@Component(property = {"editor.impl=alloyeditor"}) | ||
public class AlloyEditorConfigContributor | ||
implements PortletEditorConfigContributor { | ||
|
||
public void populateConfigJSONObject( | ||
JSONObject jsonObject, Map<String, Object> inputEditorTaglibAttributes, | ||
ThemeDisplay themeDisplay, | ||
LiferayPortletResponse liferayPortletResponse) { | ||
|
||
String contentsLanguageId = (String)inputEditorTaglibAttributes.get( | ||
"liferay-ui:input-editor:contentsLanguageId"); | ||
|
||
Locale contentsLocale = LocaleUtil.fromLanguageId(contentsLanguageId); | ||
|
||
String contentsLanguageDir = LanguageUtil.get( | ||
contentsLocale, "lang.dir"); | ||
|
||
contentsLanguageId = LocaleUtil.toLanguageId(contentsLocale); | ||
|
||
jsonObject.put( | ||
"contentsLangDirection", HtmlUtil.escapeJS(contentsLanguageDir)); | ||
jsonObject.put( | ||
"contentsLanguage", contentsLanguageId.replace("iw_", "he_")); | ||
|
||
LiferayPortletURL documentSelectorURL = | ||
liferayPortletResponse.createRenderURL( | ||
PortletKeys.DOCUMENT_SELECTOR); | ||
|
||
documentSelectorURL.setParameter("mvcPath", "/view.jsp"); | ||
documentSelectorURL.setParameter( | ||
"groupId", String.valueOf(themeDisplay.getScopeGroupId())); | ||
|
||
String name = | ||
liferayPortletResponse.getNamespace() + | ||
GetterUtil.getString((String)inputEditorTaglibAttributes.get( | ||
"liferay-ui:input-editor:name")); | ||
|
||
documentSelectorURL.setParameter("eventName", name + "selectDocument"); | ||
documentSelectorURL.setParameter( | ||
"showGroupsSelector", Boolean.TRUE.toString()); | ||
|
||
Map<String, String> fileBrowserParamsMap = | ||
(Map<String, String>)inputEditorTaglibAttributes.get( | ||
"liferay-ui:input-editor:fileBrowserParams"); | ||
|
||
if (fileBrowserParamsMap != null) { | ||
for (Map.Entry<String, String> entry : | ||
fileBrowserParamsMap.entrySet()) { | ||
|
||
documentSelectorURL.setParameter(entry.getKey(), entry.getValue()); | ||
} | ||
} | ||
|
||
jsonObject.put("filebrowserBrowseUrl", documentSelectorURL.toString()); | ||
jsonObject.put( | ||
"filebrowserFlashBrowseUrl", | ||
documentSelectorURL.toString() + "&Type=flash"); | ||
jsonObject.put( | ||
"filebrowserImageBrowseLinkUrl", | ||
documentSelectorURL.toString() + "&Type=image"); | ||
jsonObject.put( | ||
"filebrowserImageBrowseUrl", | ||
documentSelectorURL.toString() + "&Type=image"); | ||
|
||
String languageId = LocaleUtil.toLanguageId(themeDisplay.getLocale()); | ||
|
||
jsonObject.put("language", languageId.replace("iw_", "he_")); | ||
jsonObject.put("srcNode", "#" + name); | ||
} | ||
|
||
public void populateOptionsJSONObject( | ||
JSONObject jsonObject, Map<String, Object> inputEditorTaglibAttributes, | ||
ThemeDisplay themeDisplay, | ||
LiferayPortletResponse liferayPortletResponse) { | ||
} | ||
|
||
} |
100 changes: 100 additions & 0 deletions
100
.../src/com/liferay/comments/portlet/editor/conf/CommentsPortletEditorConfigContributor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/** | ||
* Copyright (c) 2000-present Liferay, Inc. All rights reserved. | ||
* | ||
* This library 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 2.1 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* This library 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. | ||
*/ | ||
|
||
package com.liferay.comments.portlet.editor.conf; | ||
|
||
import com.liferay.portal.kernel.json.JSONArray; | ||
import com.liferay.portal.kernel.json.JSONFactoryUtil; | ||
import com.liferay.portal.kernel.json.JSONObject; | ||
import com.liferay.portal.kernel.portlet.LiferayPortletResponse; | ||
import com.liferay.portal.kernel.portlet.LiferayPortletURL; | ||
import com.liferay.portal.kernel.util.StringBundler; | ||
import com.liferay.portal.kernel.util.Validator; | ||
import com.liferay.portal.theme.ThemeDisplay; | ||
import com.liferay.portal.util.PortalUtil; | ||
import com.liferay.portlet.editor.config.PortletEditorConfigContributor; | ||
|
||
import java.util.Map; | ||
|
||
import org.osgi.service.component.annotations.Component; | ||
|
||
/** | ||
* @author Sergio González | ||
*/ | ||
@Component(property = {"editor.config.key=commentsEditor"}) | ||
public class CommentsPortletEditorConfigContributor | ||
implements PortletEditorConfigContributor { | ||
|
||
public void populateConfigJSONObject( | ||
JSONObject jsonObject, Map<String, Object> inputEditorTaglibAttributes, | ||
ThemeDisplay themeDisplay, | ||
LiferayPortletResponse liferayPortletResponse) { | ||
|
||
JSONObject trigger = JSONFactoryUtil.createJSONObject(); | ||
trigger.put( | ||
"resultFilters", "function(query, results) {return results;}"); | ||
trigger.put("resultTextLocator", "screenName"); | ||
|
||
LiferayPortletURL autoCompleteUserURL = | ||
liferayPortletResponse.createResourceURL("1_WAR_mentionsportlet"); | ||
|
||
String source = | ||
autoCompleteUserURL.toString() + "&" + | ||
PortalUtil.getPortletNamespace("1_WAR_mentionsportlet"); | ||
|
||
trigger.put("source", source); | ||
trigger.put("term", "@"); | ||
trigger.put("tplReplace", "{mention}"); | ||
|
||
StringBundler sb = new StringBundler(8); | ||
|
||
sb.append("<div class=\"display-style-3 taglib-user-display\">"); | ||
sb.append("<span>"); | ||
sb.append("<span class=\"user-profile-image\" "); | ||
sb.append("style=\"background-image: url('{portraitURL}');"); | ||
sb.append("background-size: 32px 32px; height: 32px; width: 32px;\""); | ||
sb.append("</span><span class=\"user-name\">{fullName}</span>"); | ||
sb.append("<span class=\"user-details\">@{screenName}</span></span>"); | ||
sb.append("</div>"); | ||
|
||
trigger.put("tplResults", sb.toString()); | ||
|
||
JSONArray array = JSONFactoryUtil.createJSONArray(); | ||
|
||
array.put(trigger); | ||
|
||
JSONObject autoCompleteConfig = JSONFactoryUtil.createJSONObject(); | ||
|
||
String extraPlugins = jsonObject.getString("extraPlugins"); | ||
|
||
if (Validator.isNotNull(extraPlugins)) { | ||
extraPlugins += ",autocomple"; | ||
} | ||
else { | ||
extraPlugins = "autocomplete"; | ||
} | ||
|
||
autoCompleteConfig.put("extraPlugins", extraPlugins); | ||
autoCompleteConfig.put("trigger", array); | ||
|
||
jsonObject.put("autocomplete", autoCompleteConfig); | ||
} | ||
|
||
public void populateOptionsJSONObject( | ||
JSONObject jsonObject, Map<String, Object> inputEditorTaglibAttributes, | ||
ThemeDisplay themeDisplay, | ||
LiferayPortletResponse liferayPortletResponse) { | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters