From: Ian Jackson Date: Sat, 31 Oct 2009 20:32:21 +0000 (+0000) Subject: Merge branch 'stable-5.x' X-Git-Tag: 6.0~24 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.web-live.git;a=commitdiff_plain;h=e85ef56a3b2eff647efc77e44ba5ba0a19e53393;hp=3f93cfabd49eeaaca06358f87d9324a5b2e6c211 Merge branch 'stable-5.x' --- diff --git a/yarrg/Commods.pm b/yarrg/Commods.pm index 0d45c5e..5161af2 100644 --- a/yarrg/Commods.pm +++ b/yarrg/Commods.pm @@ -22,6 +22,7 @@ package Commods; use IO::File; +use IO::Pipe; use HTTP::Request::Common (); use POSIX; use LWP::UserAgent; @@ -45,7 +46,8 @@ BEGIN { &pipethrough_run_gzip &http_useragent &version_core &http_useragent_string_map &cgipostform &yarrgpostform &cgi_get_caller - &set_ctype_utf8 $masterinfoversion); + &set_ctype_utf8 $masterinfoversion + &source_tarball); %EXPORT_TAGS = ( ); @EXPORT_OK = qw(); @@ -268,6 +270,7 @@ sub fetch_with_rsync ($) { sub parse_info_serverside () { parse_info1('source-info.txt','s',0); + parse_info1('tree-info.txt','t',1); } sub parse_info_serverside_ocean ($) { my ($oceanname) = @_; @@ -472,4 +475,38 @@ sub http_useragent ($) { return $ua; } +sub source_tarball ($$) { + my ($sourcebasedir,$spitoutfn) = @_; + + my $pipe= new IO::Pipe or die $!; + my $pid= fork(); defined $pid or die $!; + if (!$pid) { + $ENV{'YPPSC_YARRG_SRCBASE'}= $sourcebasedir; + $pipe->writer(); + exec '/bin/sh','-c',' + cd -P "$YPPSC_YARRG_SRCBASE" + ( + git-ls-files -z; + git-ls-files -z --others --exclude-from=.gitignore; + if test -d .git; then find .git -print0; fi + ) | ( + cpio -Hustar -o --quiet -0 -R 1000:1000 || \ + cpio -Hustar -o --quiet -0 + ) | gzip + '; + die $!; + } + $pipe->reader(); + + my ($d, $l); + while ($l= read $pipe, $d, 65536) { + $spitoutfn->($d); + } + waitpid $pid,0; + defined $l or die "read pipe $!"; + $pipe->error and die "pipe error $!"; + close $pipe; + # deliberately ignore errors +} + 1; diff --git a/yarrg/CommodsWeb.pm b/yarrg/CommodsWeb.pm index ab2a4a3..5e12003 100644 --- a/yarrg/CommodsWeb.pm +++ b/yarrg/CommodsWeb.pm @@ -52,7 +52,7 @@ BEGIN { &to_json_shim &to_json_protecttags &set_ctype_utf8 &webdatadir &expected_error &dbw_lookup_string - &printable &tr_datarow + &printable &tr_datarow &escerrq &prettyprint_age &meta_prettyprint_age); %EXPORT_TAGS = ( ); @@ -222,6 +222,13 @@ sub tr_datarow ($$) { } } +sub escerrq ($) { + return '"'.CGI::escapeHTML($_[0]).'"'; + # Prettier qotes as below are not in HTML 3.2: +# return '“'.CGI::escapeHTML($_[0]).'”'; +# return '‘'.CGI::escapeHTML($_[0]).'’'; +} + package CommodsWeb::ExpectedError; sub emsg ($) { diff --git a/yarrg/README b/yarrg/README index 10555f4..526d466 100644 --- a/yarrg/README +++ b/yarrg/README @@ -167,14 +167,15 @@ Master). This yarrg screenscraper and upload client was written entirely from -scratch by me, Ian Jackson, with assistance from Stephen Early and -Clare Boothby. It is part of ypp-sc-tools, a set of third-party tools -for assisting players of Yohoho Puzzle Pirates. +scratch by me, Ian Jackson, with assistance from Clare Boothby, +Stephen Early, and Naath. It is part of ypp-sc-tools, a set of +third-party tools for assisting players of Yohoho Puzzle Pirates. ypp-sc-tools and YARRG are Copyright (C) 2009 Ian Jackson Copyright (C) 2009 Clare Boothby Copyright (C) 2009 Steve Early +Copyright (C) 2009 Naath Cousins This program is free software: you can redistribute it and/or modify it under the terms of diff --git a/yarrg/TODO b/yarrg/TODO index be9fda0..1648c6d 100644 --- a/yarrg/TODO +++ b/yarrg/TODO @@ -1,6 +1,3 @@ -unticking trades doesn't work?! - - UPLOADER -------- diff --git a/yarrg/commod-results-processor b/yarrg/commod-results-processor index 9525330..8ede371 100755 --- a/yarrg/commod-results-processor +++ b/yarrg/commod-results-processor @@ -51,6 +51,7 @@ sub bs_read ($$) { return if @v <= $c; my ($price,$qty) = @v[$c..$c+1]; return if !length($price) && !length($qty); + die "$price ?" unless $price =~ m/^\d/; die "$_ ?" unless length($price) && length($qty); $commod{$commod}{$bs}{$stall}= { Stall => $stall, @@ -63,6 +64,10 @@ while (<>) { chomp; @v= split /\t/; #print STDERR "[".join("|",@v)."]\n"; + foreach (@v[2..$#v]) { + s/\,//g; + die "$_ ?" if m/.\D/; + } ($commod,$stall) = @v; push @commods_inorder, $commod unless exists $commod{$commod}; bs_read(Buy, 2); @@ -205,8 +210,8 @@ sub bs_p_tsv ($$) { } } -sub write_tsv ($) { - my ($f) = @_; +sub write_tsv ($$) { + my ($f,$showhold) = @_; foreach $commod (sort keys %commod) { $current= $commod{$commod}; my %stalls; @@ -216,6 +221,9 @@ sub write_tsv ($) { printf($f "%s\t%s", $commod, $stall) or die $!; bs_p_tsv($f, Buy); bs_p_tsv($f, Sell); + if ($showhold && $commod{$commod}{Hold}) { + printf($f "\t%s", $commod{$commod}{Hold}) or die $!; + } print($f "\n") or die $!; } } @@ -224,7 +232,7 @@ sub write_tsv ($) { } sub main__tsv () { - write_tsv(\*STDOUT); + write_tsv(\*STDOUT,1); } sub undef_printable { my ($ov)= @_; defined $ov ? $ov : '?'; }; @@ -485,7 +493,7 @@ sub main__uploadyarrg () { $o{'timestamp'}= $ENV{'YPPSC_DATA_TIMESTAMP'} or die; my $tf= pipethrough_prep(); - write_tsv($tf); + write_tsv($tf,0); my $oz= pipethrough_run_gzip($tf); $o{'data'}= [ undef, 'deduped.tsv.gz', Content_Type => 'application/octet-stream', diff --git a/yarrg/commod-update-receiver b/yarrg/commod-update-receiver index d01b6de..e03a918 100755 --- a/yarrg/commod-update-receiver +++ b/yarrg/commod-update-receiver @@ -3,22 +3,22 @@ # This script is invoked when the yarrg client uploads to # the chiark database. -# This is part of ypp-sc-tools, a set of third-party tools for assisting -# players of Yohoho Puzzle Pirates. +# This is part of the YARRG website. YARRG is a tool and website +# for assisting players of Yohoho Puzzle Pirates. # # Copyright (C) 2009 Ian Jackson # # This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. # # This program 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 General Public License for more details. +# GNU Affero General Public License for more details. # -# You should have received a copy of the GNU General Public License +# You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # # Yohoho and Puzzle Pirates are probably trademarks of Three Rings and @@ -41,8 +41,6 @@ our $now= time; defined $now or die $!; my $re_any= "^(.*)\$"; -parse_info_serverside(); - sub fail ($) { my ($msg) = @_; addlog("failing $msg"); @@ -63,6 +61,15 @@ sub must_param ($$) { my %o; +if (param('get_source')) { + # There's another copy of this in dictionary-update-receiver. Sorry. + print header('application/octet-stream') or die $!; + source_tarball('..', sub { print $_[0] or die $!; }); + exit 0; +} + +parse_info_serverside(); + my $midtmp= "_mid-pid$$.hold"; open MIDTMP, ">$midtmp" or die "$midtmp $!"; stat MIDTMP or die $!; diff --git a/yarrg/db-idempotent-populate b/yarrg/db-idempotent-populate index c4bd4a7..0ecde9e 100755 --- a/yarrg/db-idempotent-populate +++ b/yarrg/db-idempotent-populate @@ -7,22 +7,22 @@ # creates or updates OCEAN-Oceanname.db # from source-info.txt -# This is part of ypp-sc-tools, a set of third-party tools for assisting -# players of Yohoho Puzzle Pirates. +# This is part of the YARRG website. YARRG is a tool and website +# for assisting players of Yohoho Puzzle Pirates. # # Copyright (C) 2009 Ian Jackson # # This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. # # This program 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 General Public License for more details. +# GNU Affero General Public License for more details. # -# You should have received a copy of the GNU General Public License +# You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # # Yohoho and Puzzle Pirates are probably trademarks of Three Rings and diff --git a/yarrg/dictionary-update-receiver b/yarrg/dictionary-update-receiver index 352b9bb..3baef66 100755 --- a/yarrg/dictionary-update-receiver +++ b/yarrg/dictionary-update-receiver @@ -3,29 +3,28 @@ # This script is invoked when the yarrg wants to send an update to the # dictionary server. See README.privacy. -# This is part of ypp-sc-tools, a set of third-party tools for assisting -# players of Yohoho Puzzle Pirates. +# This is part of the YARRG website. YARRG is a tool and website +# for assisting players of Yohoho Puzzle Pirates. # # Copyright (C) 2009 Ian Jackson # # This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. # # This program 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 General Public License for more details. +# GNU Affero General Public License for more details. # -# You should have received a copy of the GNU General Public License +# You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # # Yohoho and Puzzle Pirates are probably trademarks of Three Rings and # are used without permission. This program is not endorsed or # sponsored by Three Rings. - # upload testing runes: # # YPPSC_YARRG_DICT_UPDATE=./ YPPSC_YARRG_DICT_SUBMIT=./ ./yarrg --ocean midnight --pirate aristarchus --find-island --same --raw-tsv >raw.tsv @@ -43,6 +42,13 @@ use IO::Handle; use Commods; +if (param('get_source')) { + # There's another copy of this in commod-update-receiver. Sorry. + print header('application/octet-stream') or die $!; + source_tarball('..', sub { print $_[0] or die $!; }); + exit 0; +} + my $aadepth=2; #---------- pixmaps ---------- diff --git a/yarrg/ocean-topology-graph b/yarrg/ocean-topology-graph index e609e35..2336b43 100755 --- a/yarrg/ocean-topology-graph +++ b/yarrg/ocean-topology-graph @@ -1,5 +1,27 @@ #!/usr/bin/perl -w +# This is part of the YARRG website. YARRG is a tool and website +# for assisting players of Yohoho Puzzle Pirates. +# +# Copyright (C) 2009 Ian Jackson +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +# Yohoho and Puzzle Pirates are probably trademarks of Three Rings and +# are used without permission. This program is not endorsed or +# sponsored by Three Rings. + use strict (qw(vars)); use CommodsDatabase; diff --git a/yarrg/update-master-info b/yarrg/update-master-info index c668745..adad34c 100755 --- a/yarrg/update-master-info +++ b/yarrg/update-master-info @@ -30,22 +30,22 @@ # ./update-master-info -b -d ~ftp/users/ijackson/yarrg/ -a # ./update-master-info -b -d ~ftp/users/ijackson/yarrg/ -O ... -# This is part of ypp-sc-tools, a set of third-party tools for assisting -# players of Yohoho Puzzle Pirates. +# This is part of the YARRG website. YARRG is a tool and website +# for assisting players of Yohoho Puzzle Pirates. # # Copyright (C) 2009 Ian Jackson # # This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. # # This program 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 General Public License for more details. +# GNU Affero General Public License for more details. # -# You should have received a copy of the GNU General Public License +# You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # # Yohoho and Puzzle Pirates are probably trademarks of Three Rings and diff --git a/yarrg/web/check_capacitystring b/yarrg/web/check_capacitystring index 52eab28..b958dff 100644 --- a/yarrg/web/check_capacitystring +++ b/yarrg/web/check_capacitystring @@ -96,9 +96,9 @@ my $parse_values= sub { FROM commods WHERE commodname LIKE ?"); my ($emsg,$commod,@umv)= dbw_lookup_string($spec,$commodsth,1,0,0, - "No commodity or unit matches \`$spec'", - "Ambiguous commodity (or unit) \`$spec'", - undef); + "No commodity or unit matches ".escerrq($spec), + "Ambiguous commodity (or unit) ".escerrq($spec), + undef); expected_error($emsg) if defined $emsg; $debugf->("VALUE COMMOD FOUND '$commod' @umv"); foreach my $mvi (0,1) { @@ -109,7 +109,8 @@ my $parse_values= sub { push @canon, $commod; } else { s/\s+$//; - expected_error("Did not understand value \`$_'"); + expected_error("Did not understand value ". + escerrq($_)); } } }; @@ -131,14 +132,15 @@ my $parse_term= sub { push @canon, sprintf "%g%%", $pct; } elsif (!m/[^a-z]/i) { $debugf->("TERM NAME"); - expected_error("Name (should be unit or commodity) \`$_'". + expected_error("Name (should be unit or commodity)". + escerrq($_). " without preceding quantity") unless $first_term; my $sth= $dbh->prepare("SELECT name,mass,volume". " FROM vessels WHERE name LIKE ?"); my ($emsg,$ship,@smv)= dbw_lookup_string($_,$sth,1,1,2, - "Ship name `$_' not understood.", + "Ship name ".escerrq($_)." not understood.", "Too many matching ship types.", sub { "Ambiguous - could be $_[1]" }); expected_error($emsg) if defined $emsg; diff --git a/yarrg/web/check_capitalstring b/yarrg/web/check_capitalstring index 53aceec..24617d7 100644 --- a/yarrg/web/check_capitalstring +++ b/yarrg/web/check_capitalstring @@ -53,7 +53,7 @@ if (!m/\S/) { $capital= $1; $canon= "$capital PoE"; } else { - expected_error("Cannot understand capital \`$_'."); + expected_error("Cannot understand capital ".escerrq($_)."."); } return ($canon,$capital); diff --git a/yarrg/web/check_commodstring b/yarrg/web/check_commodstring index de7cda8..a6aa726 100644 --- a/yarrg/web/check_commodstring +++ b/yarrg/web/check_commodstring @@ -45,11 +45,11 @@ SELECT commodname,commodid <%method nomatch> - no commodity matches "<% $ARGS{spec} |h %>" + no commodity matches <% $ARGS{specq} %> <%method ambiguous> - ambiguous commodity "<% $ARGS{spec} |h %>", + ambiguous commodity <% $ARGS{specq} %>, could be <% $ARGS{couldbe} |h %> diff --git a/yarrg/web/check_distance b/yarrg/web/check_distance index 223cc5a..4d1a4e3 100644 --- a/yarrg/web/check_distance +++ b/yarrg/web/check_distance @@ -59,7 +59,7 @@ if (!m/\S/) { $leagues= $1; $canon= "$leagues leagues"; } else { - expected_error("Cannot understand distance \`$_'."); + expected_error("Cannot understand distance ".escerrq($_)."."); } return ($canon,$leagues); diff --git a/yarrg/web/check_islandstring b/yarrg/web/check_islandstring index e8664d5..bb33db1 100644 --- a/yarrg/web/check_islandstring +++ b/yarrg/web/check_islandstring @@ -45,11 +45,11 @@ maxambig => 5 <%method nomatch> - no island matches "<% $ARGS{spec} |h %>" + no island matches <% $ARGS{specq} %> <%method ambiguous> - ambiguous island "<% $ARGS{spec} |h %>", + ambiguous island <% $ARGS{specq} %>, could be <% $ARGS{couldbe} |h %> diff --git a/yarrg/web/check_lossperleague b/yarrg/web/check_lossperleague index 9375355..a37382e 100644 --- a/yarrg/web/check_lossperleague +++ b/yarrg/web/check_lossperleague @@ -54,7 +54,7 @@ if (!m/\S/) { $pct= 100.0/$1; $str= sprintf("1/%d", $1); } else { - expected_error("Cannot understand loss per league \`$_'."); + expected_error("Cannot understand loss per league ".escerrq($_)."."); } return ("$str per league", $pct); diff --git a/yarrg/web/check_routestring b/yarrg/web/check_routestring index cfa7ec7..6741eae 100644 --- a/yarrg/web/check_routestring +++ b/yarrg/web/check_routestring @@ -47,11 +47,11 @@ UNION ALL SELECT DISTINCT archipelago,NULL,archipelago <%method nomatch> - no island or arch matches "<% $ARGS{spec} |h %>" + no island or arch matches <% $ARGS{specq} %> <%method ambiguous> - ambiguous island or arch "<% $ARGS{spec} |h %>", + ambiguous island or arch <% $ARGS{specq} %>, could be <% $ARGS{couldbe} |h %> diff --git a/yarrg/web/copyrightdate b/yarrg/web/copyrightdate index 6af4e75..fe21797 100644 --- a/yarrg/web/copyrightdate +++ b/yarrg/web/copyrightdate @@ -1 +1 @@ -Copyright 2009 Ian Jackson, Clare Boothby, Steve Early \ No newline at end of file +Copyright 2009 Ian Jackson, Clare Boothby, Steve Early, Naath Cousins \ No newline at end of file diff --git a/yarrg/web/devel b/yarrg/web/devel index fed459f..e23d0af 100755 --- a/yarrg/web/devel +++ b/yarrg/web/devel @@ -33,32 +33,16 @@ - -YARRG (Yet Another Revenue Research Gatherer) - - - - -
- +<& docshead &>

YARRG development, contribution and troubleshooting

Free Software (aka Open Source) licensing

YARRG is Free Software - you may share and modify it. See the licences for details. Not only the client but also the website code -is Free. The yarrg client, support files, and so forth are under -the GNU GPL (v3 or later); the website is under the GNU Affero GPL (v3 -or later). +is Free. The yarrg client, support files, and so forth are under the +GNU GPL (v3 or later); the website and database backend is under the +GNU Affero GPL (v3 or later).

@@ -82,21 +66,35 @@ the source for their version, the website code itself lets you download an up-to-date of its actually-running source code. So this link gives you the source code for the pages you are now looking at. -

YARRG lookup website instances

+

YARRG website code instances

+ +

Lookup website

-Each of these allows you to download its own source code so you -can get both the testing and the main version of the website. -

You can add the form parameter ?debug=1 to each of the -above to get a version of the site with debugging output enabled. +website URLs above to get a version of the site with debugging output enabled. + +

Database and dictionary update receiver

+ +On the live system there are different trees, potentially with +different versions, for receiving updates and managing the database, +to the ones for displaying the website. The database management trees +are normally accessed only via the upload client but you may also +download their source directly: + +

Data

@@ -145,5 +143,6 @@ Email Ian Jackson ijackson (at) chiark.greenend.org.uk. Or talk to any Fleet Officer or above of the crew Special Circumstances on the Midnight Ocean. +

<& footer, isdevel => 1 &> diff --git a/yarrg/web/dhandler b/yarrg/web/dhandler index 2cdb09c..aec56ca 100644 --- a/yarrg/web/dhandler +++ b/yarrg/web/dhandler @@ -1,7 +1,7 @@ <%perl> my $arg= $m->dhandler_arg; if ($arg =~ m,^/?$,) { - $m->redirect('lookup'); + $m->redirect('intro'); } else { $r->header_out('Status','404 Not found'); diff --git a/yarrg/web/docs b/yarrg/web/docs index 02cbeeb..8c48814 100755 --- a/yarrg/web/docs +++ b/yarrg/web/docs @@ -33,22 +33,7 @@ -Website documentation - YARRG - - - - -
- +<& docshead &>

Looking up data in YARRG

YARRG (Yet Another Revenue Research Gatherer) is a third-party tool @@ -66,6 +51,11 @@ Hopefully you will be able to work it without too much help, but this documentation page contains information about the database website which you may not be able to divine from the online user interface. +

+ +If this page is all too complicated for you, you may prefer to read +the introduction instead. +

Bookmarkable URLs

Mostly, you can bookmark the specific pages and queries. Select the @@ -75,8 +65,8 @@ URL.

-(An exception to this is if you select the `Update' option from the -`Trades for route' lookup; the list of (de)selected stalls is too long +(An exception to this is if you select the "Update" option from the +"Trades for route" lookup; the list of (de)selected stalls is too long to fit in a URL.)

Dynamic confirmation of meaning of text entry boxes

@@ -84,7 +74,7 @@ to fit in a URL.) If you have Javascript enabled, the various text entry boxes will be annotated with a brief explanation of the system's interpretation of your current entry string. To get the actual results updated, you -must still hit `Go' or `Update'. +must still hit "Go" or "Update".

Trades for route

@@ -102,7 +92,7 @@ archipelago, you must enter the archipelago name twice.

After getting the results, you can untick various trades individually, -and select `Update' to get a new plan. The unticked trades will be +and select "Update" to get a new plan. The unticked trades will be excluded from the voyage plan (if any) and also from the totals.

Vessel capacity

diff --git a/yarrg/web/docshead b/yarrg/web/docshead new file mode 100644 index 0000000..66e393d --- /dev/null +++ b/yarrg/web/docshead @@ -0,0 +1,19 @@ +<%method head> + +YARRG (Yet Another Revenue Research Gatherer) + + +<%method style> + + + +<& SELF:head &> +<& SELF:style &> + + +
diff --git a/yarrg/web/intro b/yarrg/web/intro index 8e993a0..a28bf0d 100755 --- a/yarrg/web/intro +++ b/yarrg/web/intro @@ -5,6 +5,7 @@ Copyright (C) 2009 Ian Jackson Copyright (C) 2009 Clare Boothby + Copyright (C) 2009 Naath Cousins YARRG's client code etc. is covered by the ordinary GNU GPL (v3 or later). The YARRG website is covered by the GNU Affero GPL v3 or later, which @@ -33,23 +34,22 @@ - -YARRG (Yet Another Revenue Research Gatherer) - - - +<& docshead:head &> +
-

Introduction to YARRG

+ +

Guide to YARRG

YARRG (Yet Another Revenue Research Gatherer) is a third-party tool for helping find profitable trades and trade routes in Yohoho Puzzle @@ -58,72 +58,297 @@ Pirates. It was inspired by

-The system has two main parts: this website which maintains a -searchable database of commodity prices, and an upload client, which -screenscrapes the commodity data from the Puzzle Pirates game client -and uploads it to the database. +Information about commodity prices is collected by pirates like you +and uploaded to the YARRG server, using the special yarrg upload +client. You can then query and search on this website for commodity +prices and good trade routes. -

Market prices database

-The lookup page gives access to the uploaded data; -there is also documentation to help with using that -website. +

-

Uploading from Linux

+
+

Quick start for experts

-The YARRG upload client uploads both to YARRG and -PCTB. +

Straight to the commodity prices database

+ +If you already know about trading on Puzzle Pirates, understand what +the YARRG website is for, and just want to get down to playing with +it right away, simply select your ocean:

+

+% my @oceans= ocean_list(); +% my $delim= ''; +% foreach my $ocean (@oceans) { +% my $uri= URI->new('lookup'); +% $uri->query_form('ocean', $ocean) if $ocean ne 'Midnight'; +<% $delim %><% $ocean |h %> +% $delim=' | '; +% } +
+ +

But before you start ...

-The current official version of YARRG for use as an upload -client can browsed here: - http://www.chiark.greenend.org.uk/~ijackson/ypp-sc-tools/master/ -See particularly the -YARRG README. +If you are going to use YARRG seriously you will almost certainly want +to upload your own data. See Uploading to YARRG +for details.

-To install the client, install the `git' version control system -and the other dependencies listed in the `Installation requirements' -section of the README and then run: -

-git-clone http://www.chiark.greenend.org.uk/~ijackson/ypp-sc-tools/master/.git ypp-sc-tools
-cd ypp-sc-tools
-cd yarrg
-make
-
-this will download the code into the directory ypp-sc-tools, -and build the software. (If your Linux is very up to date you may -find that it complains that it doesn't know the command git-core. -In that case, use git core, with a space, instead.) + +You will also probably at some point want to read the +Documentation for Experts which covers some +features of the website which you might not guess just from using it. + +
+ +

How to use the YARRG website

+ +YARRG is designed to help pirates make profitable trades. It is not +designed as a trading tutorial and some familiarity with trading in +YPP is assumed. yppedia.puzzlepirates.com/Trading +contains some advice on trading basics. + +

So how do I use it then?

+ +

First look at the top of the page. You need to select your Ocean, +the sort of Interface you would like and the type of Query you wish to +ask. + +

+ +

Selecting your Ocean

+ +

+ +Which ocean do you want to trade on? +Just click on that ocean's name. + +

+ +

Selecting your Interface

+ +

You can choose to enter commodity and island names by typing them +into a text entry field or by selecting them from a drop down menu. +The "select from menu" option allows only a restricted number of +options to be entered into each field.

-When new versions of the upload client are released, you can: -

-cd .../ypp-sc-tools
-git-pull
-cd yarrg
-make
-
-to fetch the new version. (Again, you may need git pull -instead of git-pull.) +

Type of Query

+ +

+ +There are currently four types of query available which answer +slightly different questions. + +

+ +

Trades for route

+ +

+ +For pirates who know where they are going. Trades for route allows +you to enter a route that you are planning to sail and find out if +there are any profitable trades you can make along the way. This is +for pirates who already have a definite sailing plan for some reason. +Under "Enter Route" you need to type (or select from menus) the names +of the islands or Archipelagoes that you plan to visit. If you wish +to know about arbitrage opportunities at an island you can enter just +that island name. If you enter only one Archipelago then you will get +arbitrage opportunities in that archipelago; if you enter the same +archipelago twice you'll get trades within that archipelago. -

Uploading from Windows

+

-There is not currently an upload client for Windows which feeds data -into YARRG. It would probably be straightforward to modify the -Windows PCTB v5 upload client to upload to YARRG as well. +

Prices for commodity

+ +

+ +For pirates wanting to sell or buy a specific commodity prices for +commodity returns the best buy and sell prices for the selected +commodity at each island where trades are available. Type (or select +from a menu) the name of one commodity at a time. This is useful for +pirates wishing to purchase or sell a specific commodity and wanting +the best price. + +

+ +

Offers at location

+ +

+ +For pirates wanting more details about commodity prices at specified +locations. Offers at location returns all the offers to buy and sell +wood at the selected location(s). Type (or select) a commodity and the +islands (or achipelagos) you are interested in. This is useful when +the best buy or sell offer is for only a small quantity: you can check +what the others offers are like. + +

+ +

Find Profitable route

+ +

+ +For pirates just wanting to make some poe moving commodities about. Find +Profitable Route finds you a profitable trading route: first select +either "open-ended" (which might take you anywhere) or "circular" +(which takes you back to where you started) then type (or select) your +starting point (or points - you may for instance have two ships in +different locations either of which you could use).

-See our Developers' information page. +

Data age

+ +

+ +Data age tells you how long ago data was uploaded from each island in +your ocean. Data changes very quickly and trusting old data to be +accurate is unlikely to be rewarding. + +

+ +

What do the results mean

+ +

+ +"Prices for commodity" and "Offers at location" give very similar results; +there will be two tables: the first titled "Offers to BUY" your +commodity, the second "Offers to SELL" it. The tables can be sorted +as you wish by clicking on the arrows in the headings. + +

+ +"Trades for route" and "Find profitable route" both return voyage plans. +"Find profitable route" has an additional step to get at your results - +when you enter your query you are given a list of 15 good routes for +total profit and 15 good routes for profit per league which visit +different islands. Select your preferred route: perhaps you will choose +to take the best profit or perhaps you need to miss out one island +because it is blockaded or another because you don't have the charts +to get to or from it. If you have asked for a trade for route or +after selecting the profitable route you prefer you will get a Voyage +trading plan - this provides you with instructions for what to do (buy +this, sell that, sail there). + +

+ +Sometimes no useful trades are available. In this case the results +section says simply "No profitable trading opportunities were found". + +

+ +After this there is a table reporting the age of the data used. And +then a table of "Relevant trades" which lists just about everything you +could want to know about each trade the plan suggests you make (yes, +this table is fairly complicated). The ticky boxes down the side of +this table allow you to choose which trades you like the look of - +untick any that you are not interested in (for instance you may be +uninterested in trades with a low profit margin). + +

+ +

What are the Advanced options

+ +

+ +These options are very useful, and not very advanced, but not needed +for searching the data. + +

+ +

Capacity

+ +

+ +You can't trade more than fits in your hold. If you don't say +anything YARRG assumes that you have infinite hold space (perhaps you +will go over the route many times). You can enter a ship-type, a mass +or a volume; additionally you can subtract quantities of commodities +from a ship-type (for instance 'sloop - 10 grog' gives the capacity of +a sloop that has 10 grog already on board); click the ? by this field +to get a full description of permitted entries here. + +

+ +

Capital

+ +

+ +How much poe do you have? If you don't say anything YARRG assumes you +have infinite poe to spend, but you probably don't. Enter the amount +you are willing to spend on commodities for trading with. + +

+ +

Expected losses

+ +

+ +How much do you expect to lose to the dastardly brigands? Enter either +a % (as eg - 1%) or a fraction (as eg - 1/100) of the goods you +expect to loose to Brigands. Brigands take 10% if they defeat you, +but only you know how often you are defeated. Note that this doesn't +include rum-consumed so you will need to account for that +seperately. + +

+ +

Max distance

+ +

+ +How far are you willing to sail today? The default is 20 leagues, the +maximum supported is 35. Are you willing to sail all the way across +the ocean for a profit? Or would you prefer to go only a short way? + +

+ +

Other fairly useful information

+ +

+ +The search information is encoded in the URL - you can bookmark pages +for searches you want to perform a lot and go straight to them without +re-entering you data (or you can copy the URL and tell your hearties +and crew mates if you want to). There's no need to come back to the +introductory page each time. + +

+ +Javascript magic: when you type things into the text entry fields +YARRG will try to guess what you meant. If you pause for a moment then +beneath the text entry field you'll see what YARRG thinks you meant. +If it's got it correct you don't have to type any more of that +commodity/island name: just go on to the next one. + +

+ +You'll probably want to upload data to ensure you have fresh data +available. Unfortunately YARRG only has a Linux upload client at +present (a windows one is in the works). You should read about how to upload: particularly the linked +README page for information about the client which contain +easy-to-follow instructions to download, install and run it in the +form of a few comand line instructions that you can copy and paste. + +

+ +It's all free, both free-as-in-beer or free-as-in-speech. If you're +interested, read the Development pages for more +info about how to contribute or how to run your own website using +YARRG data (perhaps you don't like our colour choices) + +

Contacting the YARRG developers

Email Ian Jackson ijackson (at) chiark.greenend.org.uk. Or talk to any Fleet Officer or above of the crew Special Circumstances on the Midnight Ocean. +

<& footer &> diff --git a/yarrg/web/lookup b/yarrg/web/lookup index 365ed58..eb9f53d 100755 --- a/yarrg/web/lookup +++ b/yarrg/web/lookup @@ -129,7 +129,7 @@ $ours <% ucfirst $ahtml{Query} %> - YARRG