blob: daefb170f70e4e22666189a4d8c1e78865cef925 [file] [log] [blame]
Luigi Santivetti7bab4942019-06-16 07:40:53 +00001<?php
2
3class Pelican extends CI_Controller {
Luigi Santivetti57a98ca2020-10-13 22:55:51 +01004 private function is_valid_file($rel_path = '/', $file_html = 'index.html')
Luigi Santivetti7bab4942019-06-16 07:40:53 +00005 {
6 $abs_path = APPPATH.$rel_path.$file_html;
Luigi Santivetti57a98ca2020-10-13 22:55:51 +01007 return file_exists($abs_path);
Luigi Santivetti7bab4942019-06-16 07:40:53 +00008 }
9
Luigi Santivetti57a98ca2020-10-13 22:55:51 +010010 public function public_author($file_name = 'index')
Luigi Santivetti7bab4942019-06-16 07:40:53 +000011 {
Luigi Santivetti57a98ca2020-10-13 22:55:51 +010012 $file_html = $file_name.'.html';
13 if ($this->is_valid_file('views/author/', $file_html))
14 {
15 $this->load->view('author/'.$file_html);
16 }
17 else
18 {
19 header('Location: https://'.$_SERVER['HTTP_HOST']);
20 }
Luigi Santivetti7bab4942019-06-16 07:40:53 +000021 }
22
Luigi Santivetti57a98ca2020-10-13 22:55:51 +010023 public function public_blog($file_name = 'index')
Luigi Santivetti7bab4942019-06-16 07:40:53 +000024 {
25 $file_html = $file_name.'.html';
26 if ($this->is_valid_file('views/blog/', $file_html))
27 {
28 $this->load->view('blog/'.$file_html);
29 }
Luigi Santivetti57a98ca2020-10-13 22:55:51 +010030 else
31 {
32 header('Location: https://'.$_SERVER['HTTP_HOST']);
33 }
34 }
35
36 public function public_category($file_name = 'index')
37 {
38 $file_html = $file_name.'.html';
39 if ($this->is_valid_file('views/category/', $file_html))
Luigi Santivetti7bab4942019-06-16 07:40:53 +000040 {
41 $this->load->view('category/'.$file_html);
42 }
Luigi Santivetti57a98ca2020-10-13 22:55:51 +010043 else
44 {
45 header('Location: https://'.$_SERVER['HTTP_HOST']);
46 }
47 }
48
49 public function public_draft($file_name = 'index')
50 {
51 $file_html = $file_name.'.html';
luigi74fc6932020-11-08 12:51:31 +000052 if ($this->is_valid_file('views/blog/draft', $file_html))
Luigi Santivetti57a98ca2020-10-13 22:55:51 +010053 {
luigi74fc6932020-11-08 12:51:31 +000054 $this->load->view('blog/draft/'.$file_html);
Luigi Santivetti57a98ca2020-10-13 22:55:51 +010055 }
56 else
57 {
58 header('Location: https://'.$_SERVER['HTTP_HOST']);
59 }
60 }
61
62 public function public_gitles()
63 {
64 $gerrit_gitles = '/gerrit/plugins/gitiles/';
65 header('Location: https://'.$_SERVER['HTTP_HOST'].$gerrit_gitles);
66 }
67
68 public function public_page($file_name = 'index')
69 {
70 $file_html = $file_name.'.html';
71 if ($this->is_valid_file('views/page/', $file_html))
Luigi Santivetti7bab4942019-06-16 07:40:53 +000072 {
73 $this->load->view('page/'.$file_html);
74 }
Luigi Santivetti57a98ca2020-10-13 22:55:51 +010075 else
76 {
77 header('Location: https://'.$_SERVER['HTTP_HOST']);
78 }
79 }
80
81 public function public_root($file_name = 'index')
82 {
83 $file_html = $file_name.'.html';
84 if ($this->is_valid_file('views/', $file_html))
Luigi Santivetti7bab4942019-06-16 07:40:53 +000085 {
86 $this->load->view($file_html);
87 }
88 else
89 {
Luigi Santivetti57a98ca2020-10-13 22:55:51 +010090 header('Location: https://'.$_SERVER['HTTP_HOST']);
Luigi Santivetti7bab4942019-06-16 07:40:53 +000091 }
92 }
93}