Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/sales.git
nb-configuration.xml
<word>multipart</word>
<word>part's</word>
+ <word>resources'</word>
<word>sender's</word>
<word>subscriber's</word>
src/main/java/com/whitemagicsoftware/sales/service/NotifySubscriberService.java
-/*
- * The MIT License
- *
- * Copyright 2016 White Magic Software, Ltd..
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.whitemagicsoftware.sales.service;
-
-import com.whitemagicsoftware.sales.entity.Subscriber;
-import java.io.UnsupportedEncodingException;
-import javax.mail.MessagingException;
-
-/**
- * Notifies a subscriber of a list of product sales.
- *
- * @author White Magic Software, Ltd.
- */
-public interface NotifySubscriberService extends NotifyService {
- /**
- * Sends the given message to the given subscriber. This will send the message
- * in both text and HTML format as a multi-part message.
- *
- * @param recipient The recipient that is to be notified.
- * @param subject Message subject line.
- * @param markdown Message body (in markdown format).
- *
- * @throws javax.mail.MessagingException Message could not be sent.
- * @throws java.io.UnsupportedEncodingException Invalid subscriber address.
- */
- public void notify( Subscriber recipient, String subject, String markdown )
- throws MessagingException, UnsupportedEncodingException;
-}
src/main/java/com/whitemagicsoftware/sales/service/impl/DefaultNotifySubscriberService.java
-/*
- * The MIT License
- *
- * Copyright 2016 White Magic Software, Ltd..
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-package com.whitemagicsoftware.sales.service.impl;
-
-import com.whitemagicsoftware.sales.entity.Subscriber;
-import com.whitemagicsoftware.sales.service.NotifySubscriberService;
-import java.io.UnsupportedEncodingException;
-import javax.mail.MessagingException;
-
-/**
- * Responsible for sending a notification to a subscriber.
- *
- * @author White Magic Software, Ltd.
- */
-public class DefaultNotifySubscriberService
- extends DefaultNotifyService implements NotifySubscriberService {
-
- @Override
- public void notify( Subscriber recipient, String subject, String markdown )
- throws MessagingException, UnsupportedEncodingException {
-
- super.notify( recipient.getAddress(), subject, markdown );
- }
-}
src/main/java/com/whitemagicsoftware/sales/service/impl/DefaultScraperService.java
Scraper scraper = new Scraper( scMain, getWorkingDirectory() );
+ scraper.setDebug( true );
scraper.execute( scLib.getOperations() );
src/main/resources/scripts/1_com_thriftyfoods.xml
<var-def name="vendor_url">https://www.thriftyfoods.com/product/</var-def>
<var-def name="vendor_name">Thrifty Foods</var-def>
+ <var-def name="vendor_template">thriftyfoods</var-def>
<var-def name="product_page">
<var-def name="product_sale">
- <xpath expression="boolean(//div[contains(@class,'on-sale') and @itemprop='offerDetails'])">
+ <xpath expression="boolean(//div[contains(@on-sale,'on-sale') and @itemprop='offerDetails'])">
<var name="product_page" />
</xpath>
</var-def>
<var-def name="message_body">
- <call name="vendor-name" />
- <call name="product-details" />
+ <call name="vendor-name">
+ <call-param name="include_vendor_name">
+ <var name="include_vendor_name" />
+ </call-param>
+ <call-param name="vendor_name">
+ <var name="vendor_name" />
+ </call-param>
+ </call>
+ <call name="product-details">
+ <call-param name="product_sale">
+ <var name="product_sale" />
+ </call-param>
+ <call-param name="product_name">
+ <var name="product_name" />
+ </call-param>
+ <call-param name="product_price">
+ <var name="product_price" />
+ </call-param>
+ <call-param name="vendor_template">
+ <var name="vendor_template" />
+ </call-param>
+ </call>
</var-def>
</config>
src/main/resources/templates/thriftyfoods/product-listing.md
Sale price is ${product_price}.
-

Fixed detection for product sales at Thrify Foods.

Author djarvis <email>
Date 2016-07-19 00:35:03 GMT-0700
Commit 2c4e05344584bb4f5cd1ab6cc00d219e7ce6c802
Parent 35c81e2
Delta 26 lines added, 98 lines removed, 72-line decrease