OSDN Git Service

Web: add "no_ad" stash parameter to hide advertise
authorhylom <hylom@users.osdn.me>
Thu, 6 Jun 2019 10:48:08 +0000 (10:48 +0000)
committerhylom <hylom@users.osdn.me>
Thu, 6 Jun 2019 10:48:08 +0000 (10:48 +0000)
src/newslash_web/lib/Newslash/Web.pm
src/newslash_web/templates/common/layout.html.tt2
src/newslash_web/templates/common/sidebar.html.tt2

index c5ad0a2..dd9fbdc 100644 (file)
@@ -251,21 +251,15 @@ sub startup {
     $r->get('/submissions')->to('timeline#submissions');
     $r->get('/polls')->to('timeline#polls');
 
-    $r->get('/recent2')->to('timeline#recent', use_tl2 => 1);
-    $r->get('/popular2')->to('timeline#popular', use_tl2 => 1);
-    $r->get('/comments2')->to('timeline#comments', use_tl2 => 1);
-    $r->get('/journals2')->to('timeline#journals', use_tl2 => 1);
-    $r->get('/submissions2')->to('timeline#submissions', use_tl2 => 1);
-
     # RSS
     $r->get('/:rss_type' => [format => ['rss', 'xml']])->to('rss#stories');
     $r->get('/journals/rss')->to('rss#journals');
 
     # Banned page
-    $r->get('/banned')->to('index#banned', noindex => 1);
+    $r->get('/banned')->to('index#banned', noindex => 1, no_ad => 1);
 
     # Login / Logout
-    $r->get('/my/login')->to('login#login');
+    $r->get('/my/login')->to('login#login', no_ad => 1);
     $r->post('/my/login')->to('login#login');
     $r->get('/my/logout')->to('login#logout');
     $r->get('/login' => sub {my $c = shift; $c->res->code(301); $c->redirect_to('/my/login');});
@@ -280,11 +274,11 @@ sub startup {
 
     # journal page
     # also see user page settings for /~username/journal/
-    $r->get('/journal/new')->to('journal#create', seclev => 1);
+    $r->get('/journal/new')->to('journal#create', seclev => 1, no_ad => 1);
     $r->get('/journal/:id/')->to('journal#single');
 
     # submission page
-    $r->get('/submission/new')->to('submission#create');
+    $r->get('/submission/new')->to('submission#create', no_ad => 1);
     $r->get('/submission/:id/')->to('submission#single');
     #$r->post('/submission')->to('submission#create');
 
@@ -335,14 +329,14 @@ sub startup {
     $r->get('/my/')->to('user#home', seclev => 1);
 
     # User Register
-    $r->get('/my/newuser')->to('login#newuser');
+    $r->get('/my/newuser')->to('login#newuser', no_ad => 1);
     $r->post('/my/newuser')->to('login#newuser', captcha_check => 1);
-    $r->get('/my/activation')->to('login#activation');
-    $r->get('/my/resetpassword')->to('login#reset_password');
+    $r->get('/my/activation')->to('login#activation', no_ad => 1);
+    $r->get('/my/resetpassword')->to('login#reset_password', no_ad => 1);
     $r->post('/my/resetpassword')->to('login#reset_password', captcha_check => 1);
 
     # Change Email
-    $r->get('/my/change_email')->to('my#change_email', seclev => 1);
+    $r->get('/my/change_email')->to('my#change_email', seclev => 1, captcha_check => 1);
 
     # search page
     $r->get('/search')->to('search#search');
@@ -373,7 +367,7 @@ sub startup {
 
     # Admin
     # pages under /admin needs seclev equal or greater than 10000;
-    my $admin = $r->under('/admin' => sub { my $c = shift; $c->stash(seclev => 10000); return 1; });
+    my $admin = $r->under('/admin' => sub { my $c = shift; $c->stash(seclev => 10000); return 1; })->detour(no_ad => 1);
 
     $admin->get('/firehose/:id/')->to('admin-firehose#single');
     $admin->get('/submissions')->to('admin-submissions#index');
index d1f593c..2ceed6f 100644 (file)
@@ -6,7 +6,7 @@
     [%- INCLUDE common/status_bar -%]
     [%- IF user.is_admin %][% INCLUDE admin/admin_bar %][% END -%]
 
-    [%- IF page && page.type != "system" %]
+    [%- IF !no_ad %]
     [%- helpers.ad_code("site-top") -%]
     [%- END -%]
 
@@ -15,7 +15,9 @@
     <div class="content">
       [% content %]
     </div>
+    [%- IF !no_ad %]
     [%- helpers.ad_code("site-bottom") -%]
+    [%- END %]
     [%- INCLUDE common/footer -%]
     [%- INCLUDE common/login_dialog -%]
   </body>
index fd0f165..8b55722 100644 (file)
@@ -1,7 +1,10 @@
 <div class="sidebar">
 
-  [%- IF page.type == "timeline" || page.type == "archive" || page.type == "tag" || helpers.page_type() == "my" -%]
+  [%- IF !no_ad %]
   [%- helpers.ad_code("sidebar-top") -%]
+  [%- END %]
+
+  [%- IF page.type == "timeline" || page.type == "archive" || page.type == "tag" || page.type == "user" || helpers.page_type() == "my" -%]
   [%- FOREACH box IN helpers.boxes() -%]
   <div class="sidebar-item [% box.type %] [% box.name %]">
     [%- box.contents -%]
@@ -9,7 +12,6 @@
   [%- END -%]
 
   [%- ELSIF page.content_type == "story" -%]
-  [%- helpers.ad_code("sidebar-top") %]
   <div class="sidebar-item related">
     <h2>関連リンク</h2>
     <ul class="list-unstyled">
@@ -24,7 +26,6 @@
       [%- END -%]
     </ul>
   </div>
-
   <div class="sidebar-item history">
     <h2>編集履歴</h2>
     [%- FOREACH item IN histories -%]
     [%- END -%]
   </div>
 
-  [%- ELSIF page.content_type == "comment" -%]
-  [%- helpers.ad_code("sidebar-top") -%]
-
   [%- ELSIF page.content_type == "poll" -%]
-  [%- helpers.ad_code("sidebar-top") -%]
   <div class="sidebar-item related">
     <h2>最近の国民投票</h2>
     <ul class="list-unstyled">
@@ -57,8 +54,5 @@
     [% INCLUDE common/user %]
   </div>
 
-  [%- ELSE -%]
-  [%- helpers.ad_code("sidebar-top") -%]
-
   [%- END -%]
 </div>