Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/sales.git

Added newline characters in templates due to bug fix in Web-Harvest.

Author djarvis <email>
Date 2016-07-03 19:13:16 GMT-0700
Commit c72958b7a0c710eeb56093f33df6524723cb350e
Parent 0db3cf5
src/main/resources/scripts/2_ca_safeway.xml
</var-def>
- <var-def name="p_n" id="product">
- <var name="product_name" />
- </var-def>
-
<var-def name="flyer_page">
- <html-to-xml id="flyer_xml" htmlparser="jsoup">
- <http method="get" url="${vendor_url}">
- <http-param name="store_code">
- <var name="store_code"/>
- </http-param>
- </http>
- </html-to-xml>
+ <html-to-text id="flyer_text">
+ <html-to-xml id="flyer_xml" htmlparser="jsoup">
+ <http method="get" url="${vendor_url}">
+ <http-param name="store_code">
+ <var name="store_code"/>
+ </http-param>
+ </http>
+ </html-to-xml>
+ </html-to-text>
</var-def>
- <regexp replace="true" id="regex">
- <regexp-pattern>[\s]*</regexp-pattern>
- <regexp-source>
- <var name="product_name" />
- </regexp-source>
- <regexp-result>
- <template>.*</template>
- </regexp-result>
- </regexp>
+ <var-def name="product_regex" id="product_regex">
+ <regexp replace="true">
+ <regexp-pattern>[\s]</regexp-pattern>
+ <regexp-source><var name="product_name" /></regexp-source>
+ <regexp-result><template>.*</template></regexp-result>
+ </regexp>
+ </var-def>
+
+ <var-def name="product_price">
+ <regexp flag-caseinsensitive="yes" flag-dotall="no">
+ <regexp-pattern id="pattern">.*<var name="product_regex"/>.*</regexp-pattern>
+ <regexp-source>
+ <var name="flyer_page" />
+ </regexp-source>
+ </regexp>
+ </var-def>
<var-def name="message_body" id="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_name">
+ <var name="product_name" />
+ </call-param>
+ <call-param name="product_price">
+ <var name="product_price" />
+ </call-param>
+ <call-param name="product_sale">true</call-param>
+ <call-param name="vendor_template">safeway</call-param>
+ </call>
</var-def>
</config>
src/main/resources/scripts/lib/common.xml
<template>
<file path="templates/header-product-name.md"/>
- <file path="templates/product-price.md"/>
+ <file path="templates/${vendor_template}/product-listing.md"/>
</template>
</if>
src/main/resources/templates/header-product-name.md
${product_name}
----------------------------
+
src/main/resources/templates/product-price.md
-Sale price is ${product_price}.
src/main/resources/templates/safeway/product-listing.md
+${product_price}
src/main/resources/templates/thriftyfoods/product-listing.md
+Sale price is ${product_price}.
src/test/java/com/whitemagicsoftware/sales/service/impl/DefaultScraperServiceTest.java
List<Product> products = createProductService().list();
- Product product = products.get( 0 );
+ Product product = products.get( 4 );
// for( Vendor vendor : vendors ) {
Delta 48 lines added, 25 lines removed, 23-line increase