OSDN Git Service

remove unused Plugins
authorhylom <hylom@users.sourceforge.jp>
Wed, 24 Apr 2019 11:19:10 +0000 (20:19 +0900)
committerhylom <hylom@users.sourceforge.jp>
Wed, 24 Apr 2019 11:19:10 +0000 (20:19 +0900)
src/newslash_web/lib/Newslash/Plugin/AddDescription.pm [deleted file]
src/newslash_web/lib/Newslash/Plugin/AddStructuredData.pm [deleted file]
src/newslash_web/lib/Newslash/Plugin/AddThumbnail.pm [deleted file]
src/newslash_web/lib/Newslash/Plugin/Canonical.pm [deleted file]
src/newslash_web/lib/Newslash/Web.pm

diff --git a/src/newslash_web/lib/Newslash/Plugin/AddDescription.pm b/src/newslash_web/lib/Newslash/Plugin/AddDescription.pm
deleted file mode 100644 (file)
index 949c7eb..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-package Newslash::Plugin::AddDescription;
-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("description");
-
-                   my $item = $c->stash("item") || $args->{item};
-                   if ($item) {
-                       if ($item->{intro_text}) {
-                           $c->stash(description => $c->extract_description($item->{intro_text}));
-                       }
-                   }
-               });
-}
-
-
-
-1;
diff --git a/src/newslash_web/lib/Newslash/Plugin/AddStructuredData.pm b/src/newslash_web/lib/Newslash/Plugin/AddStructuredData.pm
deleted file mode 100644 (file)
index 5928e07..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-package Newslash::Plugin::AddStructuredData;
-use Mojo::Base 'Mojolicious::Plugin';
-use Data::Dumper;
-
-sub register {
-    my ($self, $app, $conf) = @_;
-
-    $app->hook(before_render => sub {
-                   my ($c, $args) = @_;
-                   my $data = generate_structured_data($c, $args);
-                   $c->stash(structured_data => $data);
-               });
-}
-
-sub generate_structured_data {
-    my ($c, $args) = @_;
-    my $cfg = $c->app->config->{Site} || {};
-    my $page = $args->{page} || $c->stash("page") || {};
-
-    my $data = { '@context' => "http://schema.org",
-               };
-
-    # set content type
-    if ($page->{type} eq "single") {
-        # single content page
-        if ($page->{content_type} eq "story") {
-            $data->{'@type'} = "NewsArticle";
-        }
-        elsif ($page->{content_type} eq "journal") {
-            $data->{'@type'} = "BlogPosting";
-        }
-    }
-    elsif ($page->{type} eq "user") {
-        if ($page->{content_type} eq "recent") {
-            $data->{'@type'} = "Person";
-            my $the_user = $args->{the_user} || $c->stash("the_user");
-            if ($the_user) {
-                $data->{name} = $the_user->{nickname};
-                my $info = $the_user->{config}->{info};
-                $data->{alternateName} = $info->{realname} if $info->{realname};
-                $data->{url} = $info->{url} if $info->{url};
-                $data->{description} = $c->strip_html($info->{biography}) if $info->{biography};
-                return $data;
-            }
-        }
-        return;
-    }
-    elsif ($page->{type} eq "timeline") {
-        $data->{'@type'} = "WebSite";
-        $data->{name} = $cfg->{name};
-        $data->{alternateName} = $cfg->{alternate_name} if $cfg->{alternate_name};
-        $data->{description} = $cfg->{description};
-        $data->{url} = $cfg->{base_url};
-        $data->{potentialAction} = { '@type' => "SearchAction",
-                                     target => "$cfg->{base_url}/search?q={search_term_string}",
-                                     "query-input" => "required name=search_term_string",
-                                   };
-        $data->{sameAs} = $cfg->{same_as} if $cfg->{same_as};
-    }
-    else {
-        # no generate structured data
-        return;
-    }
-
-    $data->{headline} = $page->{title} if $page->{title};
-    $data->{datePublished} = $c->format_timestamp(mysql => $page->{create_time},
-                                                  format => 'iso8601') if $page->{create_time};
-    $data->{dateModified} = $c->format_timestamp(mysql => $page->{update_time},
-                                                  format => 'iso8601') if $page->{update_time};
-    $data->{articleBody} = $page->{description} if $page->{description};
-    $data->{image} = $page->{thumbnail} if $page->{thumbnail};
-
-    $data->{mainEntityOfPage} = { '@type' => "WebPage",
-                                  '@id' => $page->{canonical} };
-
-    # add author data
-    if ($page->{author}) {
-        my $u = $page->{author};
-        my $i = $u->{config}->{info};
-        $data->{author} = { '@type' => "Person",
-                            name => $u->{nickname} };
-        $data->{author}->{alternateName} = $i->{realname} if $i->{realname};
-        $data->{author}->{url} = $i->{homepage} if $i->{homepage};
-    }
-
-    # add publisher data
-    $data->{publisher} = { '@type' => "Organization",
-                           name => $cfg->{publisher},
-                           url => $cfg->{publisher_url},
-                           logo => { '@type' => "ImageObject",
-                                     url => $cfg->{publisher_logo},
-                                   },
-                         };
-
-    return $data;
-}
-
-1;
diff --git a/src/newslash_web/lib/Newslash/Plugin/AddThumbnail.pm b/src/newslash_web/lib/Newslash/Plugin/AddThumbnail.pm
deleted file mode 100644 (file)
index 3ea5391..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-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 && ref($item->{primary_topic}) eq "HASH") {
-                       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;
diff --git a/src/newslash_web/lib/Newslash/Plugin/Canonical.pm b/src/newslash_web/lib/Newslash/Plugin/Canonical.pm
deleted file mode 100644 (file)
index 6bb5d34..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-package Newslash::Plugin::Canonical;
-use Mojo::Base 'Mojolicious::Plugin';
-use Mojo::URL;
-
-use POSIX qw(strftime locale_h);
-
-use constant CANONICAL_TABLE => {
-                                 qr{^/~([^/]*)/journal/?} => '/~$1/journals',
-                                };
-
-sub get_canonical_path {
-    my ($self, $path) = @_;
-    for my $rex (keys %{CANONICAL_TABLE()}) {
-        my $to_path = CANONICAL_TABLE->{$rex};
-        if ($path =~ $rex) {
-            my $rep = $1;
-            $path = $to_path;
-            $path =~ s/\$1/$rep/;
-        }
-    }
-    if (substr($path, -1, 1) ne "/") {
-        $path = "$path/";
-    }
-    return $path;
-}
-
-sub register {
-    my ($self, $app, $conf) = @_;
-
-    $app->hook(before_render => sub {
-                   my ($c, $args) = @_;
-                   return if $c->stash('canonical');
-                   my $url = Mojo::URL->new($c->url_for);
-                   my $path = $self->get_canonical_path($url->path);
-
-                   $url->host('srad.jp');
-                   $url->port('');
-                   $url->scheme('https');
-                   $url->path($path);
-                   $c->stash(canonical => $url->to_string);
-               });
-    #$app->helper(canonical => sub { state $canonical = $self; });
-}
-
-
-
-1;
index 112eeac..85b1191 100644 (file)
@@ -233,17 +233,6 @@ sub startup {
     # Set page's property automatically
     $app->plugin('Newslash::Plugin::AddPageProperty');
 
-    # Generate structured data
-    #$app->plugin('Newslash::Plugin::AddStructuredData');
-
-    # Set Description automatically
-    #$app->plugin('Newslash::Plugin::AddDescription');
-
-    # Set Thumbnail automatically
-    #$app->plugin('Newslash::Plugin::AddThumbnail');
-
-    # set canocal (for test.srad.jp)
-    #$app->plugin('Newslash::Plugin::Canonical');
 
     ############################################################
     #