diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2014-07-25 00:59:06 +0200 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2014-07-25 00:59:06 +0200 |
| commit | cee10c347b04c9bebac9e0c8328c1ab813d4ddaa (patch) | |
| tree | b8d2a724839c7849dd57e39fda6ca6f52cfd293c | |
| parent | 86adc0a0add7007d330c6daaee680ed36e5ead19 (diff) | |
| download | cgeo-cee10c347b04c9bebac9e0c8328c1ab813d4ddaa.zip cgeo-cee10c347b04c9bebac9e0c8328c1ab813d4ddaa.tar.gz cgeo-cee10c347b04c9bebac9e0c8328c1ab813d4ddaa.tar.bz2 | |
fix #2321: have a link to related webpage in cache details
The link is displayed as a bold clickable URL at the top of the long
description.
| -rw-r--r-- | main/src/cgeo/geocaching/connector/gc/GCConstants.java | 1 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/connector/gc/GCParser.java | 7 |
2 files changed, 7 insertions, 1 deletions
diff --git a/main/src/cgeo/geocaching/connector/gc/GCConstants.java b/main/src/cgeo/geocaching/connector/gc/GCConstants.java index 79e570b..7cf43dc 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCConstants.java +++ b/main/src/cgeo/geocaching/connector/gc/GCConstants.java @@ -64,6 +64,7 @@ public final class GCConstants { public final static Pattern PATTERN_INVENTORY = Pattern.compile("<span id=\"ctl00_ContentBody_uxTravelBugList_uxInventoryLabel\">\\W*Inventory[^<]*</span>[^<]*</h3>[^<]*<div class=\"WidgetBody\">([^<]*<ul>(([^<]*<li>[^<]*<a href=\"[^\"]+\"[^>]*>[^<]*<img src=\"[^\"]+\"[^>]*>[^<]*<span>[^<]+<\\/span>[^<]*<\\/a>[^<]*<\\/li>)+)[^<]*<\\/ul>)?"); public final static Pattern PATTERN_INVENTORYINSIDE = Pattern.compile("[^<]*<li>[^<]*<a href=\"[a-z0-9\\-\\_\\.\\?\\/\\:\\@]*\\/track\\/details\\.aspx\\?guid=([0-9a-z\\-]+)[^\"]*\"[^>]*>[^<]*<img src=\"[^\"]+\"[^>]*>[^<]*<span>([^<]+)<\\/span>[^<]*<\\/a>[^<]*<\\/li>"); public final static Pattern PATTERN_WATCHLIST = Pattern.compile(Pattern.quote("watchlist.aspx") + ".{1,50}" + Pattern.quote("action=rem")); + public final static Pattern PATTERN_RELATED_WEB_PAGE = Pattern.compile("id=\"ctl00_ContentBody_uxCacheUrl\" title=\"Related Web Page\" href=\"(.*?)\">"); // Info box top-right public static final Pattern PATTERN_LOGIN_NAME = Pattern.compile("\"SignedInProfileLink\">(.*?)</a>"); diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java index 020aeab..60d7856 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCParser.java +++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java @@ -544,7 +544,12 @@ public abstract class GCParser { cache.setShortDescription(TextUtils.getMatch(page, GCConstants.PATTERN_SHORTDESC, true, "")); // cache description - cache.setDescription(TextUtils.getMatch(page, GCConstants.PATTERN_DESC, true, "")); + final String longDescription = TextUtils.getMatch(page, GCConstants.PATTERN_DESC, true, ""); + String relatedWebPage = TextUtils.getMatch(page, GCConstants.PATTERN_RELATED_WEB_PAGE, true, ""); + if (StringUtils.isNotEmpty(relatedWebPage)) { + relatedWebPage = String.format("<a href=\"%s\"><b>%s</b></a><br/><br/>", relatedWebPage, relatedWebPage); + } + cache.setDescription(relatedWebPage + longDescription); // cache attributes try { |
