summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2020-07-25 12:50:37 +0200
committerYorhel <git@yorhel.nl>2020-07-25 12:50:37 +0200
commit40ea78ddfa265daea03f9904784bc0c35980b894 (patch)
treeb4235d593e099ed199a41514e1cb5dabdcd1810c
parent5ed819ce09bb2da4d143fd6aba7a20bf8f08ff93 (diff)
Reports: Nicer formatting of the reporting subject
-rw-r--r--elm/Report.elm3
-rw-r--r--lib/VNWeb/Misc/Reports.pm30
2 files changed, 21 insertions, 12 deletions
diff --git a/elm/Report.elm b/elm/Report.elm
index 5bb75aaf..8cbf498e 100644
--- a/elm/Report.elm
+++ b/elm/Report.elm
@@ -7,6 +7,7 @@ import Browser
import Browser.Navigation exposing (load)
import Lib.Html exposing (..)
import Lib.Api as Api
+import Lib.Ffi as Ffi
import Gen.Api as GApi
import Gen.Report as GR
@@ -56,7 +57,7 @@ view (state,model) =
, if state == Api.Error GApi.Success
then p [] [ text "Your report has been submitted, a moderator will look at it as soon as possible." ]
else table [ class "formtable" ] <|
- [ formField "Subject" [ a [ href model.path ] [ text model.title ] ]
+ [ formField "Subject" [ span [ Ffi.innerHtml model.title ] [] ]
, formField ""
[ text "Your report will be forwarded to a moderator."
, br [] []
diff --git a/lib/VNWeb/Misc/Reports.pm b/lib/VNWeb/Misc/Reports.pm
index 85691d4e..d229d434 100644
--- a/lib/VNWeb/Misc/Reports.pm
+++ b/lib/VNWeb/Misc/Reports.pm
@@ -6,17 +6,26 @@ my $reportsperday = 5;
my @STATUS = qw/new busy done dismissed/;
-# Requires objects with {rtype,object} fields, adds {title,path} fields.
+# Requires objects with {rtype,object} fields, adds a HTML-formatted 'title' field, which formats and links to the entry.
sub enrich_object {
- for(@_) {
- delete $_->@{'title','path'};
- if($_->{rtype} eq 't' && $_->{object} =~ /^$RE{postid}$/) {
- my $title = tuwf->dbVali(
- "SELECT 'Post #'||tp.num||' on '||t.title
- FROM threads t JOIN threads_posts tp ON tp.tid = t.id
- WHERE NOT t.hidden AND NOT t.private AND t.id =", \"$+{id}", 'AND tp.num =', \"$+{num}"
+ for my $o (@_) {
+ delete $o->{title};
+ if($o->{rtype} eq 't' && $o->{object} =~ /^$RE{postid}$/) {
+ my $post = tuwf->dbRowi(
+ 'SELECT tp.num, t.title, ', sql_user(), '
+ FROM threads t JOIN threads_posts tp ON tp.tid = t.id LEFT JOIN users u ON u.id = tp.uid
+ WHERE NOT t.hidden AND NOT t.private AND t.id =', \"$+{id}", 'AND tp.num =', \"$+{num}"
);
- $_->@{'title','path'} = ($title, "/$_->{object}") if $title;
+ if($post->{num}) {
+ $o->{title} = xml_string sub {
+ txt_ 'Post ';
+ a_ href => "/$o->{object}", "#$post->{num}";
+ txt_ ' on ';
+ a_ href => "/$o->{object}", $post->{title};
+ txt_ ' by ';
+ user_ $post;
+ };
+ }
}
}
}
@@ -31,7 +40,6 @@ my $FORM = form_compile any => {
rtype => {},
object => {},
title => {},
- path => {},
reason => { maxlength => 50 },
message => { required => 0, default => '', maxlength => 50000 },
loggedin => { anybool => 1 },
@@ -88,7 +96,7 @@ sub report_ {
txt_ $r->{ip}||'[anonymous]';
}
br_;
- a_ href => $r->{path}, $r->{title};
+ lit_ $r->{title};
br_;
txt_ $r->{reason};
div_ class => 'quote', sub { lit_ TUWF::XML::html_escape $r->{message} } if $r->{message};