/
Module.php
191 lines (161 loc) · 4.3 KB
/
Module.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<?php
namespace jacmoe\mdpages;
/*
* This file is part of
* the yii2 _
* _ __ ___ __| |_ __ __ _ __ _ ___ ___
* | '_ ` _ \ / _` | '_ \ / _` |/ _` |/ _ \/ __|
* | | | | | | (_| | |_) | (_| | (_| | __/\__ \
* |_| |_| |_|\__,_| .__/ \__,_|\__, |\___||___/
* |_| |___/
* module
*
* Copyright (c) 2016 - 2017 Jacob Moen
* Licensed under the MIT license
*/
/**
* mdpages module definition class
*/
class Module extends \yii\base\Module
{
/**
* Link to the Github repository where the content is stored
* @var string http://github.com/owner/repo.git
*/
public $repository_url = '';
/**
* Github token used when calling the Github API
* @var string
*/
public $github_token = '';
/**
* Repository owner
* @var string The 'owner' part of http://github.com/owner/repo
*/
public $github_owner = '';
/**
* Repository name
* @var string The 'repo' part of http://github.com/owner/repo
*/
public $github_repo = '';
/**
* Repository branch
* @var string What branch the content repository is using
*/
public $github_branch = 'master';
/**
* The directory in which the wiki content is stored
* @var string
*/
public $root_directory = '@runtime';
/**
* The extension used to indicate markdown files
* @var string
*/
public $page_extension = '.md';
/**
* The directory where the wiki content is stored
* @var string
*/
public $pages_directory = '@runtime/content';
/**
* The directory where the Flywheel database is written
* @var string
*/
public $flywheel_config = '@runtime/flywheel';
/**
* The name of the Flywheel database
* @var string
*/
public $flywheel_repo = 'pages';
/**
* Use absolute links for wiki links
* @var string
*/
public $absolute_wikilinks = false;
/**
* The amount of time in seconds to cache content
* @var integer
*/
public $caching_time = 60;
/**
* Should the Markdown page parser generate page toc?
* @var bool
*/
public $generate_page_toc = true;
/**
* Snippets for the SnippetParser
* @var array
*/
public $snippets = null;
/**
* [$feed_title description]
* @var string
*/
public $feed_title = 'Pages';
/**
* [$feed_description description]
* @var string
*/
public $feed_description = 'The pages feed';
/**
* [$feed_author description]
* @var string
*/
public $feed_author_email = 'noreply@yoursite.com';
/**
* [$feed_author_name description]
* @var string
*/
public $feed_author_name = 'Pages Feed';
/**
* [$feed_ordering description]
* @var string
*/
public $feed_ordering = 'updated DESC';
/**
* [$feed_filtering description]
* @var [type]
*/
public $feed_filtering = false;
/**
* [$feed_filter description]
* @var array
*/
public $feed_filter = array('published', '==', true);
/**
* Generate contributor data like avatars, Github URL, etc.
* @var [type]
*/
public $generate_contributor_data = true;
/**
* @inheritdoc
*/
public $controllerNamespace = 'jacmoe\mdpages\controllers';
/**
* @inheritdoc
*/
public $defaultRoute = 'page/index';
/**
* @inheritdoc
*/
public function init()
{
parent::init();
\Yii::configure($this, require(__DIR__ . '/config.php'));
if (\Yii::$app instanceof \yii\console\Application) {
$this->controllerNamespace = 'jacmoe\mdpages\commands';
}
$important = array(
$this->repository_url,
$this->github_token,
$this->github_owner,
$this->github_repo
);
$results = array_filter($important, function($v){return empty($v);});
if(count($results) > 0) {
throw new \yii\base\InvalidConfigException("Important configuration values have not been set.\nOne or more of the following configuration values are empty:\nrepository_url\ngithub_token\ngithub_owner\ngithub_repo\n\nPlease check your module configuration.");
}
\Yii::setAlias('@pages', $this->pages_directory);
}
}