diff options
Diffstat (limited to 'lib/VNDB/Func.pm')
-rw-r--r-- | lib/VNDB/Func.pm | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm index 42d1b7f2..7549207f 100644 --- a/lib/VNDB/Func.pm +++ b/lib/VNDB/Func.pm @@ -11,7 +11,7 @@ use VNDBUtil; our @EXPORT = (@VNDBUtil::EXPORT, qw| clearfloat cssicon tagscore mt minage fil_parse fil_serialize parenttags childtags charspoil imgpath imgurl - fmtvote fmtmedia fmtvnlen fmtage fmtdatestr fmtdate fmtuser + fmtvote fmtmedia fmtvnlen fmtage fmtdatestr fmtdate fmtuser fmtrating json_encode json_decode script_json form_compare |); @@ -273,6 +273,20 @@ sub fmtuser { return !$id ? '[deleted]' : sprintf '<a href="/u%d">%s</a>', $id, xml_escape $n; } +# Turn a (natural number) vote into a rating indication +sub fmtrating { + ['worst ever', + 'awful', + 'bad', + 'weak', + 'so-so', + 'decent', + 'good', + 'very good', + 'excellent', + 'masterpiece']->[shift()-1]; +} + # JSON::XS::encode_json converts input to utf8, whereas the below functions |