blob: 01ca7720609c46cf03d5c090b70d18883c8626fe [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';
52 if ($this->is_valid_file('views/draft/blog', $file_html))
53 {
54 $this->load->view('draft/blog/'.$file_html);
55 }
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}