--- /dev/null
+package Newslash::Plugin::AddThumbnail;
+use Mojo::Base 'Mojolicious::Plugin';
+use Data::Dumper;
+sub register {
+ my ($self, $app, $conf) = @_;
+
+ $app->hook(before_render => sub {
+ my ($c, $args) = @_;
+ return if $c->stash("thumbnail");
+ my $cfg = $app->config->{Site} || {};
+ my $base_url = $cfg->{base_url};
+ my $icon_url = $base_url . $cfg->{topic_icon_base_url} . "/";
+
+ my $item = $c->stash("item") || $args->{item};
+ if ($item) {
+ if (($item->{primary_topic} || {})->{image}) {
+ $c->stash(thumbnail => $icon_url . $item->{primary_topic}->{image});
+ return;
+ }
+ }
+ if ($cfg->{default_thumbnail}) {
+ $c->stash(thumbnail => $base_url . $cfg->{default_thumbnail});
+ return;
+ }
+ });
+}
+
+
+
+1;
}
######################################################################
-#
+
+# insert_code / daclare: insert some codes programatically
+# this feature used to insert Captcha.
use constant MARKERS => qw(begin_footer);
my $marker_contents = {};
# Set Description automatically
$app->plugin('Newslash::Plugin::AddDescription');
+ # Set Thumbnail automatically
+ $app->plugin('Newslash::Plugin::AddThumbnail');
+
############################################################
#
# Routing Settings