From a059e48189927477c605cf44299b7bf84650d844 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Tue, 26 Jan 2016 09:51:27 +0100 Subject: write a table with more info in description --- .../org/xapek/yvesf/classifieds/Dumper.groovy | 26 ++++++++++++++++++++-- .../org/xapek/yvesf/classifieds/Model.groovy | 2 +- 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main/groovy/org/xapek/yvesf/classifieds/Dumper.groovy b/src/main/groovy/org/xapek/yvesf/classifieds/Dumper.groovy index 5fb0568..017cdf3 100644 --- a/src/main/groovy/org/xapek/yvesf/classifieds/Dumper.groovy +++ b/src/main/groovy/org/xapek/yvesf/classifieds/Dumper.groovy @@ -1,6 +1,7 @@ package org.xapek.yvesf.classifieds import groovy.xml.MarkupBuilder +import org.xapek.yvesf.classifieds.Model.Classified import org.xapek.yvesf.classifieds.Model.ClassifiedsList @@ -11,15 +12,36 @@ class Dumper { channel { title('Glocals') } - classifiedList.each { Model.Classified classified -> + classifiedList.each { Classified classified -> item { title("${classified.type} - ${classified.title} - ${classified.composedLocation}") guid(classified.id) author(classified.mem_name) - description(classified.description) + description(getDescription(classified) + classified.description) } } } } } + + static String getDescription(Classified classified) { + final descriptionOs = new ByteArrayOutputStream() + final description = new MarkupBuilder(new PrintWriter(descriptionOs)) + description.table { + tr { + th('Price') + td("${classified.price} ${classified.currency}") + } + tr { + th('Views') + td(classified.views) + } + tr { + th('Member') + td(classified.mem_name) + } + br() + } + return descriptionOs.toString() + } } diff --git a/src/main/groovy/org/xapek/yvesf/classifieds/Model.groovy b/src/main/groovy/org/xapek/yvesf/classifieds/Model.groovy index cd62c25..6303d3e 100644 --- a/src/main/groovy/org/xapek/yvesf/classifieds/Model.groovy +++ b/src/main/groovy/org/xapek/yvesf/classifieds/Model.groovy @@ -61,7 +61,7 @@ class Model { } String getComposedLocation() { - return "${location}, ${city}" + return location + (city != location ? ', ' + city : '') } } -- cgit v1.2.1