summaryrefslogtreecommitdiff
path: root/lib/VN3/Release/Page.pm
blob: a17dae116cc6a1cc94495fc8bc164b3ab6b01334 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
package VN3::Release::Page;

use VN3::Prelude;

# TODO: Userlist options


sub Notes {
    my $e = shift;

    Div class => 'row', sub {
        Div class => 'fixed-size-left-sidebar-md', sub {
            H2 class => 'detail-page-sidebar-section-header', 'Notes';
        };
        Div class => 'col-md', sub {
            Div class => 'description serif mb-5', sub {
                P sub { Lit bb2html $e->{notes} };
            };
        };
    } if $e->{notes};
}


sub DetailsTable {
    my $e = shift;

    # TODO: Some of these properties could be moved into the title header thing
    # (type and languages, in particular)
    # (Not even sure this table format makes sense for all properties, there's gotta be a nicer way)
    my @list = (
        @{$e->{vn}} ? sub {
            Dt @{$e->{vn}} == 1 ? 'Visual Novel' : 'Visual Novels';
            Dd sub {
                Join \&Br, sub {
                    A href => "/v$_[0]{vid}", title => $_[0]{original}||$_[0]{title}, $_[0]{title};
                }, @{$e->{vn}};
            }
        } : (),

        sub {
            Dt 'Type';
            Dd sub {
                Txt ucfirst $e->{type};
                Txt ", patch" if $e->{patch};
            }
        },

        sub {
            Dt 'Released';
            Dd sub { ReleaseDate $e->{released} };
        },

        sub {
            Dt @{$e->{lang}} > 1 ? 'Languages' : 'Language';
            Dd sub {
                Join \&Br, sub {
                    Lang $_[0]{lang};
                    Txt " $LANG{$_[0]{lang}}";
                }, @{$e->{lang}};
            }
        },

        sub {
            Dt 'Publication';
            Dd join ', ',
                $e->{freeware} ? 'Freeware' : 'Non-free',
                $e->{patch} ? () : ($e->{doujin} ? 'doujin' : 'commercial')
        },

        $e->{minage} && $e->{minage} >= 0 ? sub {
            Dt 'Age rating';
            Dd minage_display $e->{minage};
        } : (),

        @{$e->{platforms}} ? sub {
            Dt @{$e->{platforms}} == 1 ? 'Platform' : 'Platforms';
            Dd sub {
                Join \&Br, sub {
                    Platform $_[0]{platform};
                    Txt " $PLATFORMS{$_[0]{platform}}";
                }, @{$e->{platforms}};
            }
        } : (),

        @{$e->{media}} ? sub {
            Dt @{$e->{media}} == 1 ? 'Medium' : 'Media';
            Dd join ', ', map media_display($_->{medium}, $_->{qty}), @{$e->{media}};
        } : (),

        $e->{voiced} ? sub {
            Dt 'Voiced';
            Dd $VOICED[$e->{voiced}];
        } : (),

        $e->{ani_story} ? sub {
            Dt 'Story animation';
            Dd $ANIMATED[$e->{ani_story}];
        } : (),

        $e->{ani_ero} ? sub {
            Dt 'Ero animation';
            Dd $ANIMATED[$e->{ani_ero}];
        } : (),

        $e->{minage} && $e->{minage} == 18 ? sub {
            Dt 'Censoring';
            Dd $e->{uncensored} ? 'No optical censoring (e.g. mosaics)' : 'May include optical censoring (e.g. mosaics)';
        } : (),

        $e->{gtin} ? sub {
            Dt gtintype($e->{gtin}) || 'GTIN';
            Dd $e->{gtin};
        } : (),

        $e->{catalog} ? sub {
            Dt 'Catalog no.';
            Dd $e->{catalog};
        } : (),

        (map {
            my $type = $_;
            my @prod = grep $_->{$type}, @{$e->{producers}};
            @prod ? sub {
                Dt ucfirst($type) . (@prod == 1 ? '' : 's');
                Dd sub {
                    Join \&Br, sub {
                        A href => "/p$_[0]{pid}", title => $_[0]{original}||$_[0]{name}, $_[0]{name};
                    }, @prod;
                }
            } : ()
        } 'developer', 'publisher'),

        $e->{website} ? sub {
            Dt 'Links';
            Dd sub {
                A href => $e->{website}, rel => 'nofollow', 'Official website';
            };
        } : (),
    );

    Div class => 'row', sub {
        Div class => 'fixed-size-left-sidebar-md', sub {
            H2 class => 'detail-page-sidebar-section-header', 'Details';
        };
        Div class => 'col-md', sub {
            Div class => 'card card--white mb-5', sub {
                Div class => 'card__section fs-medium', sub {
                    Div class => 'row', sub {
                        Dl class => 'col-md dl--horizontal', sub { $_->() for @list[0..$#list/2] };
                        Dl class => 'col-md dl--horizontal', sub { $_->() for @list[$#list/2+1..$#list] };
                    }
                }
            }
        }
    } if @list;
}


TUWF::get qr{/$RREV_RE}, sub {
    my $e = entry r => tuwf->capture('id'), tuwf->capture('rev') or return tuwf->resNotFound;
    return tuwf->resNotFound if !$e->{id} || $e->{hidden};

    enrich vid => q{SELECT id AS vid, title, original FROM vn WHERE id IN}, $e->{vn};
    enrich pid => q{SELECT id AS pid, name, original  FROM producers WHERE id IN}, $e->{producers};

    Framework
        title => $e->{title},
        top => sub {
            Div class => 'col-md', sub {
                EntryEdit r => $e;
                Div class => 'detail-page-title', sub {
                    Txt $e->{title};
                    Debug $e;
                };
                Div class => 'detail-page-subtitle', $e->{original} if $e->{original};
            }
        },
        sub {
            DetailsTable $e;
            Notes $e;
        };
};

1;