Author: lucaa Date: 2008-02-05 17:33:27 +0100 (Tue, 05 Feb 2008) New Revision: 7299
Added: xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/dialog/PressReviewMailDialog.java xwiki-products/xwiki-watch/trunk/wiki/src/main/resources/WatchCode/SendPressReviewEmail Removed: xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/wizard/PressReviewMailDialog.java Modified: xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/Constants.java xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/data/DataManager.java xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/public/Watch.css xwiki-products/xwiki-watch/trunk/wiki/src/main/resources/WatchCode/PressReview xwiki-products/xwiki-watch/trunk/wiki/src/main/resources/WatchCode/Translations xwiki-products/xwiki-watch/trunk/wiki/src/main/resources/WatchCode/Translations.fr Log: XWATCH-13: Allow to send a press review by email Added the SendPressReviewEmail document that uses the mailsender plugin and the PressReview document to generate and send the press review by email. Changed PressReview formatting to match the email requirements, the DataManager to include a email sending function and the PressReviewMailDialog to invoke it. Also styled the PressReviewMailDialog. Modified: xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/Constants.java =================================================================== --- xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/Constants.java 2008-02-05 14:09:55 UTC (rev 7298) +++ xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/Constants.java 2008-02-05 16:33:27 UTC (rev 7299) @@ -61,6 +61,7 @@ public static final String PAGE_TAGCLOUD = "TagCloud"; public static final String PAGE_LOADING_STATUS = "LoadingStatus"; public static final String PAGE_PREVIEW_FEED = "PreviewFeed"; + public static final String PAGE_EMAIL_PRESSREVIEW = "SendPressReviewEmail"; public static final String IMAGE_PRESS_REVIEW = "pressreview.png"; public static final String IMAGE_ANALYSIS = "analysis.png"; Modified: xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/data/DataManager.java =================================================================== --- xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/data/DataManager.java 2008-02-05 14:09:55 UTC (rev 7298) +++ xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/data/DataManager.java 2008-02-05 16:33:27 UTC (rev 7299) @@ -460,4 +460,13 @@ watch.getXWikiServiceInstance().getDocumentContent(pressReviewPage, true, map, cb); } + public void sendEmail(FilterStatus filterStatus, String sendEmailPage, String mailSubject, + String[] mailTo, String mailContent, AsyncCallback cb) { + Map map = filterStatus.getMap(); + map.put("space", watch.getWatchSpace()); + map.put("address", mailTo); + map.put("subject", mailSubject); + map.put("content", mailContent); + watch.getXWikiServiceInstance().getDocumentContent(sendEmailPage, true, map, cb); + } } Added: xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/dialog/PressReviewMailDialog.java =================================================================== --- xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/dialog/PressReviewMailDialog.java (rev 0) +++ xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/dialog/PressReviewMailDialog.java 2008-02-05 16:33:27 UTC (rev 7299) @@ -0,0 +1,130 @@ +package com.xpn.xwiki.watch.client.ui.dialog; + +import com.xpn.xwiki.watch.client.Constants; +import com.xpn.xwiki.watch.client.Watch; +import com.xpn.xwiki.gwt.api.client.app.ModalMessageDialogBox; +import com.xpn.xwiki.gwt.api.client.app.XWikiAsyncCallback; +import com.xpn.xwiki.gwt.api.client.dialog.Dialog; +import com.google.gwt.user.client.ui.*; +import com.google.gwt.user.client.Window; + +/** + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * <p/> + * This 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 version2.1of + * the License,or(at your option)any later version. + * <p/> + * This software 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. + * <p/> + * You should have received a copy of the GNU Lesser General Public + * License along with this software;if not,write to the Free + * Software Foundation,Inc.,51 Franklin St,Fifth Floor,Boston,MA + * 02110-1301 USA,or see the FSF site:http://www.fsf.org. + * + * @author ldubost + */ + +public class PressReviewMailDialog extends Dialog { + protected TextBox mailSubjectTextBox; + protected TextBox mailToTextBox; + protected TextArea mailContentTextArea; + + public PressReviewMailDialog(Watch watch, String dialogName, int buttonModes) { + super(watch, dialogName, buttonModes); + FlowPanel main = new FlowPanel(); + main.addStyleName(getCSSName("main")); + + HTMLPanel invitationPanel = new HTMLPanel(app.getTranslation(getDialogTranslationName() + ".invitation")); + invitationPanel.addStyleName(getCssPrefix() + "-invitation"); + main.add(invitationPanel); + main.add(getParametersPanel()); + main.add(getActionsPanel()); + add(main); + + } + + protected Widget getParametersPanel() { + FlowPanel paramsPanel = new FlowPanel(); + Label mailSubjectLabel = new Label(); + mailSubjectLabel.setStyleName("mailsubject-label"); + mailSubjectLabel.setText(app.getTranslation(getDialogTranslationName() + ".mailsubject")); + paramsPanel.add(mailSubjectLabel); + + mailSubjectTextBox = new TextBox(); + mailSubjectTextBox.setVisibleLength(60); + mailSubjectTextBox.setName("mailsubject"); + mailSubjectTextBox.setStyleName(getCSSName("mailsubject")); + mailSubjectTextBox.setText(app.getTranslation(getDialogTranslationName() + ".mailsubjectdefault")); + paramsPanel.add(mailSubjectTextBox); + + Label mailToLabel = new Label(); + mailToLabel.setStyleName("mailto-label"); + mailToLabel.setText(app.getTranslation(getDialogTranslationName() + ".mailto")); + paramsPanel.add(mailToLabel); + + mailToTextBox = new TextBox(); + mailToTextBox.setVisibleLength(60); + mailToTextBox.setName("mailto"); + mailToTextBox.setStyleName(getCSSName("mailto")); + paramsPanel.add(mailToTextBox); + + Label mailContentLabel = new Label(); + mailContentLabel.setStyleName("mailcontent-label"); + mailContentLabel.setText(app.getTranslation(getDialogTranslationName() + ".mailcontent")); + paramsPanel.add(mailContentLabel); + + mailContentTextArea = new TextArea(); + mailContentTextArea.setVisibleLines(5); + mailContentTextArea.setWidth("60"); + mailContentTextArea.setName("mailcontent"); + mailContentTextArea.setStyleName(getCSSName("mailcontent")); + mailContentTextArea.setText(app.getTranslation(getDialogTranslationName() + ".mailcontentdefault")); + paramsPanel.add(mailContentTextArea); + return paramsPanel; + } + + protected boolean validateEmailDialog() { + if (this.mailToTextBox.getText().trim() == "") { + Window.alert(app.getTranslation(getDialogTranslationName() + ".noaddress")); + return false; + } + return true; + } + + protected void endDialog() { + if(validateEmailDialog()) { + //send email, all is ok + //parse emails + String[] emailsArray = this.mailToTextBox.getText().trim().split(", "); + String mailSubject = this.mailSubjectTextBox.getText(); + String mailContent = this.mailContentTextArea.getText(); + ((Watch)app).getDataManager().sendEmail(((Watch)app).getFilterStatus(), + Constants.DEFAULT_CODE_SPACE + "." + Constants.PAGE_EMAIL_PRESSREVIEW, + mailSubject, emailsArray, mailContent, new XWikiAsyncCallback(app) { + public void onSuccess(Object result) { + super.onSuccess(result); + setCurrentResult(result); + String resultText = (String) result; + endDialog2(); + ModalMessageDialogBox mmdb = new ModalMessageDialogBox(app, + app.getTranslation(getDialogTranslationName() + ".dialogtitle"), + resultText); + } + public void onFailure(Throwable caught) { + super.onFailure(caught); + } + }); + } + } + + protected void endDialog2() { + super.endDialog(); + } + +} Deleted: xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/wizard/PressReviewMailDialog.java =================================================================== --- xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/wizard/PressReviewMailDialog.java 2008-02-05 14:09:55 UTC (rev 7298) +++ xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/client/ui/wizard/PressReviewMailDialog.java 2008-02-05 16:33:27 UTC (rev 7299) @@ -1,92 +0,0 @@ -package com.xpn.xwiki.watch.client.ui.wizard; - -import com.xpn.xwiki.watch.client.Watch; -import com.xpn.xwiki.gwt.api.client.dialog.Dialog; -import com.google.gwt.user.client.ui.*; -import com.google.gwt.user.client.Window; - -/** - * See the NOTICE file distributed with this work for additional - * information regarding copyright ownership. - * <p/> - * This 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 version2.1of - * the License,or(at your option)any later version. - * <p/> - * This software 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. - * <p/> - * You should have received a copy of the GNU Lesser General Public - * License along with this software;if not,write to the Free - * Software Foundation,Inc.,51 Franklin St,Fifth Floor,Boston,MA - * 02110-1301 USA,or see the FSF site:http://www.fsf.org. - * - * @author ldubost - */ - -public class PressReviewMailDialog extends Dialog { - protected TextBox mailSubjectTextBox; - protected TextBox mailToTextBox; - protected TextArea mailContentTextArea; - - public PressReviewMailDialog(Watch watch, String dialogName, int buttonModes) { - super(watch, dialogName, buttonModes); - FlowPanel main = new FlowPanel(); - main.addStyleName(getCSSName("main")); - - HTMLPanel invitationPanel = new HTMLPanel(app.getTranslation(getDialogTranslationName() + ".invitation")); - invitationPanel.addStyleName(getCssPrefix() + "-invitation"); - main.add(invitationPanel); - main.add(getParametersPanel()); - main.add(getActionsPanel()); - add(main); - - } - - protected Widget getParametersPanel() { - FlowPanel paramsPanel = new FlowPanel(); - Label mailSubjectLabel = new Label(); - mailSubjectLabel.setStyleName("mailsubject-label"); - mailSubjectLabel.setText(app.getTranslation(getDialogTranslationName() + ".mailsubject")); - paramsPanel.add(mailSubjectLabel); - - mailSubjectTextBox = new TextBox(); - mailSubjectTextBox.setVisibleLength(60); - mailSubjectTextBox.setName("mailsubject"); - mailSubjectTextBox.setStyleName(getCSSName("mailsubject")); - mailSubjectTextBox.setText(app.getTranslation(getDialogTranslationName() + ".mailsubjectdefault")); - paramsPanel.add(mailSubjectTextBox); - - Label mailToLabel = new Label(); - mailToLabel.setStyleName("mailto-label"); - mailToLabel.setText(app.getTranslation(getDialogTranslationName() + ".mailto")); - paramsPanel.add(mailToLabel); - - mailToTextBox = new TextBox(); - mailToTextBox.setVisibleLength(60); - mailToTextBox.setName("mailto"); - mailToTextBox.setStyleName(getCSSName("mailto")); - paramsPanel.add(mailToTextBox); - - Label mailContentLabel = new Label(); - mailContentLabel.setStyleName("mailcontent-label"); - mailContentLabel.setText(app.getTranslation(getDialogTranslationName() + ".mailcontent")); - paramsPanel.add(mailContentLabel); - - mailContentTextArea = new TextArea(); - mailContentTextArea.setVisibleLines(5); - mailContentTextArea.setName("mailcontent"); - mailContentTextArea.setStyleName(getCSSName("mailcontent")); - mailContentTextArea.setText(app.getTranslation(getDialogTranslationName() + ".mailcontentdefault")); - paramsPanel.add(mailContentTextArea); - return paramsPanel; - } - - protected void endDialog() { - Window.alert(app.getTranslation(getDialogTranslationName() + ".notimplemented")); - } - -} Modified: xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/public/Watch.css =================================================================== --- xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/public/Watch.css 2008-02-05 14:09:55 UTC (rev 7298) +++ xwiki-products/xwiki-watch/trunk/gwt/src/main/java/com/xpn/xwiki/watch/public/Watch.css 2008-02-05 16:33:27 UTC (rev 7299) @@ -685,7 +685,10 @@ input.watch-technoratitag-feedname , input.watch-technoratitag-query, input.watch-feedster-feedname , -input.watch-feedster-query +input.watch-feedster-query, +input.watch-email-mailsubject, +input.watch-email-mailto, +textarea.watch-email-mailcontent { width: 380px; margin: 0 10px; @@ -704,7 +707,9 @@ div.group-label, div.mailsubject-label, div.feedurl-label, -div.query-label +div.query-label, +div.mailto-label, +div.mailcontent-label { margin: 10px 10px 0 10px; } @@ -825,5 +830,5 @@ } table.calendar-panel, button.watch-filter-date-month-button, button.watch-filter-date-year-button { - background-color: #E0B0FF; /* mauve, baby! */ + background-color: #E6EAEE; } Modified: xwiki-products/xwiki-watch/trunk/wiki/src/main/resources/WatchCode/PressReview =================================================================== --- xwiki-products/xwiki-watch/trunk/wiki/src/main/resources/WatchCode/PressReview 2008-02-05 14:09:55 UTC (rev 7298) +++ xwiki-products/xwiki-watch/trunk/wiki/src/main/resources/WatchCode/PressReview 2008-02-05 16:33:27 UTC (rev 7299) @@ -92,20 +92,23 @@ atitle = itemdoc.display("title") url = itemdoc.display("url") feedname = itemdoc.display("feedname") - println "<h2><a href=\"${url}\">${atitle}</a> $msg.get("watch.pressreview.in") ${feedname}</h2>" - println "<p>" + println "<div class='article'><span class='article-title'><a class='article-url' href=\"${url}\">${atitle}</a> $msg.get("watch.pressreview.in") ${feedname}</span>" + if ("1".equals(request.withcontent)) { + println "<p class='article-content'>" + println itemdoc.display("content") + println "</p>" + } def comments = itemdoc.getComments(true) if (comments.size()>0) { + println "<ul class='article-comments'>" for (comment in comments) { itemdoc.use(comment) author = xwiki.getLocalUserName(itemdoc.display("author", "view")) - println itemdoc.display("comment", "view") + println "<li>" + itemdoc.display("comment", "view") + "</li>" + } + println "</ul>" } - } - if ("1".equals(request.withcontent)) { - println itemdoc.display("content") - } - println "</p>" + println "</div>" } println "{/pre}" } Added: xwiki-products/xwiki-watch/trunk/wiki/src/main/resources/WatchCode/SendPressReviewEmail =================================================================== --- xwiki-products/xwiki-watch/trunk/wiki/src/main/resources/WatchCode/SendPressReviewEmail (rev 0) +++ xwiki-products/xwiki-watch/trunk/wiki/src/main/resources/WatchCode/SendPressReviewEmail 2008-02-05 16:33:27 UTC (rev 7299) @@ -0,0 +1,115 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> + +<xwikidoc> +<web>WatchCode</web> +<name>SendPressReviewEmail</name> +<language></language> +<defaultLanguage>en</defaultLanguage> +<translation>0</translation> +<parent></parent> +<creator>XWiki.Admin</creator> +<author>XWiki.Admin</author> +<customClass></customClass> +<contentAuthor>XWiki.Admin</contentAuthor> +<creationDate>1201985133000</creationDate> +<date>1202223295000</date> +<contentUpdateDate>1202223295000</contentUpdateDate> +<version>1.1</version> +<title></title> +<template></template> +<defaultTemplate></defaultTemplate> +<validationScript></validationScript> +<comment></comment> +<minorEdit>false</minorEdit> +<object> +<class> +<name>XWiki.TagClass</name> +<customClass></customClass> +<customMapping></customMapping> +<defaultViewSheet></defaultViewSheet> +<defaultEditSheet></defaultEditSheet> +<defaultWeb></defaultWeb> +<nameField></nameField> +<validationScript></validationScript> +<tags> +<cache>0</cache> +<displayType>input</displayType> +<multiSelect>1</multiSelect> +<name>tags</name> +<number>1</number> +<prettyName>Tags</prettyName> +<relationalStorage>1</relationalStorage> +<separator> </separator> +<separators> ,|</separators> +<size>30</size> +<unmodifiable>0</unmodifiable> +<values></values> +<classType>com.xpn.xwiki.objects.classes.StaticListClass</classType> +</tags> +</class> +<name>WatchCode.SendPressReviewEmail</name> +<number>0</number> +<className>XWiki.TagClass</className> +<property> +<tags/> +</property> +</object> +<content><% +//send the email only if query parameters are set +if (request.space==null) { + println "$msg.get("watch.pressreview.noquery")"; +} else if (request.address==null) { + println "$msg.get("watch.email.noaddress")"; +} else { + //get the email parameters + if (request.subject) { + subject = request.subject; + } else { + subject = ""; + } + if (request.content) { + content = request.content; + } else { + content = ""; + } + //for all the rest of parameters from the request, send them to the pressReview + prDoc = xwiki.getDocument("WatchCode.PressReview"); + url = prDoc.getExternalURL("view", "&xpage=plain"); + parameters = request.getParameterMap(); + for (par in parameters) { + if (!(par.key.equals("address") || par.key.equals("content") || par.key.equals("subject"))) { + //just perfect to pass further + if (par.value instanceof String) { + url += "&" + par.key + "=" + par.value; + } else { + url += "&" + par.key + "=" + par.value[0]; + } + } + } + //get addressses + errorMessage = ""; + error = false; + addresses = ""; + for (addr in request.getParameterValues("address")) { + message = content + "<br />" + xwiki.getURLContent(url); + //mailResult = xwiki.mailsender.sendTextMessage(xwiki.getXWikiPreference("admin_email"), addr, subject, message); + mailResult = xwiki.mailsender.sendHtmlMessage(" XWiki Watch " + "<" + xwiki.getXWikiPreference("admin_email") + ">", addr, null, null, subject, message, message, null); + if (mailResult == 0) { + if (!addresses.equals("")) { + addresses += ", "; + } + addresses += addr; + } else { + error = true; + errorMessage = errorMessage + " " + context.error; + } + } + //report + if (error) { + println "$msg.get("watch.email.error") " + errorMessage; + } else { + println "$msg.get("watch.email.success") " + addresses; + } +} +%></content> +</xwikidoc> Modified: xwiki-products/xwiki-watch/trunk/wiki/src/main/resources/WatchCode/Translations =================================================================== --- xwiki-products/xwiki-watch/trunk/wiki/src/main/resources/WatchCode/Translations 2008-02-05 14:09:55 UTC (rev 7298) +++ xwiki-products/xwiki-watch/trunk/wiki/src/main/resources/WatchCode/Translations 2008-02-05 16:33:27 UTC (rev 7299) @@ -298,6 +298,12 @@ watch.email.mailcontent=Edit the content that will be sent along the Press Review watch.email.mailcontentdefault=You have received a Press Review from XWiki Watch. It includes the following articles: watch.email.notimplemented=This feature is not available in the Beta version in order to protect recipients from spam. +watch.email.invitation=Please insert data about the Press Review email +watch.email.success=Press review email was successfully sent through email to the following addresses: +watch.email.dialogtitle=Press Review Email result +watch.chooseproutput.noselection=You have not selected any output +watch.email.noaddress=There are no addresses to send email to +watch.email.error=Press Review email sending failed due to the following reason: watch.pressreviewforspace=XWiki Watch Press Review for Space Modified: xwiki-products/xwiki-watch/trunk/wiki/src/main/resources/WatchCode/Translations.fr =================================================================== --- xwiki-products/xwiki-watch/trunk/wiki/src/main/resources/WatchCode/Translations.fr 2008-02-05 14:09:55 UTC (rev 7298) +++ xwiki-products/xwiki-watch/trunk/wiki/src/main/resources/WatchCode/Translations.fr 2008-02-05 16:33:27 UTC (rev 7299) @@ -285,6 +285,12 @@ watch.email.mailcontent=Editez le contenu qui sera envoy� avec la Revue de Presse watch.email.mailcontentdefault=Vous avez re�u une Revue de Presse depuis XWiki Watch. Elle inclut les articles suivants: watch.email.notimplemented=Cette fonction n'est pas disponible dans la version Beta afin d'emp�cher le spam. +watch.email.invitation=Veuillez renseigner les donn�es relatives a votre email +watch.email.success=La revue de presse a �t� envoy� avec succ�s aux adresses email suivantes: +watch.email.dialogtitle=R�sultat de l'envoi +watch.chooseproutput.noselection=Vous n'avez pas choisi le format de la revue de presse +watch.email.noaddress=Vous n'avez renseign� aucune adresse mail +watch.email.error=L'envoi email de la revue de presse a echou� pour la raison suivante: watch.pressreviewforspace=XWiki Watch Revue de Presse pour l'espace
_______________________________________________ notifications mailing list notifications@xwiki.org http://lists.xwiki.org/mailman/listinfo/notifications