Single YAML config
This commit is contained in:
parent
1bdc1db404
commit
307404bcdf
|
@ -17,6 +17,5 @@ It uses Russian IFWiki syntax and templates but it would be easy to alter for th
|
|||
|
||||
## Installation
|
||||
|
||||
1. Copy the `config.ini.example` to `config.ini`, edit for your liking.
|
||||
2. Copy the `config.yml.example` to `config.yml` if you need to run `bot.php`; the other two use INI config format. (I know the code is not 100% merged)
|
||||
3. Run the scripts.
|
||||
1. Copy the `config.yml.example` to `config.yml`, edit it.
|
||||
1. Run the scripts.
|
||||
|
|
12
Wikipage.php
12
Wikipage.php
|
@ -39,7 +39,7 @@ class Wikipage {
|
|||
|
||||
$this->game = $game;
|
||||
|
||||
if (!$config['DUMMY']) {
|
||||
if (!$config['DRY_RUN']) {
|
||||
try {
|
||||
// Log in to a wiki
|
||||
$api = new MediawikiApi( $config['WIKI'] );
|
||||
|
@ -52,7 +52,7 @@ class Wikipage {
|
|||
echo 'Ошибка соединения.'.PHP_EOL;
|
||||
echo $e->getMessage();
|
||||
echo $e->getTraceAsString();
|
||||
$config['DUMMY'] = true;
|
||||
$config['DRY_RUN'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ class Wikipage {
|
|||
'|' => '-'
|
||||
]);
|
||||
$exists = $this->exists($pagetitle);
|
||||
if (!$config['DUMMY'] && !$exists) {
|
||||
if (!$config['DRY_RUN'] && !$exists) {
|
||||
if (!empty($this->game->image)) {
|
||||
if ($this->services->newPageGetter()->getFromTitle($this->covername)) {
|
||||
$image = file_get_contents($this->game->image);
|
||||
|
@ -88,7 +88,7 @@ class Wikipage {
|
|||
|
||||
$this->makeContent();
|
||||
|
||||
if (!$config['DUMMY'] && !$exists) {
|
||||
if (!$config['DRY_RUN'] && !$exists) {
|
||||
$newContent = new Content( $this->content );
|
||||
$title = new Title($pagetitle);
|
||||
$identifier = new PageIdentifier($title);
|
||||
|
@ -101,7 +101,7 @@ class Wikipage {
|
|||
echo $this->content;
|
||||
return false;
|
||||
}
|
||||
if ($config['DUMMY']) {
|
||||
if ($config['DRY_RUN']) {
|
||||
echo "Черновой режим. Автосоздание невозможно.\n";
|
||||
}
|
||||
echo $this->content;
|
||||
|
@ -183,7 +183,7 @@ class Wikipage {
|
|||
*/
|
||||
protected function exists($pagename) {
|
||||
global $config;
|
||||
if ($config['DUMMY']) {
|
||||
if ($config['DRY_RUN']) {
|
||||
return false;
|
||||
}
|
||||
$page = $this->services->newPageGetter()->getFromTitle((string) $pagename);
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
STYLE = "RUS"
|
||||
FORMAT = "HTML"
|
||||
WIKI = "https://ifwiki.ru/api.php"
|
||||
WIKIUSER = "wikiuser"
|
||||
WIKIPASSWORD = "wikipassword"
|
||||
DUMMY = true
|
||||
VNDB_USER="vndbuser"
|
||||
VNDB_PASSWORD="vndbpassword"
|
|
@ -39,3 +39,8 @@ parsers: # delete unused
|
|||
classname: Steam
|
||||
STYLE: 'RUS'
|
||||
FORMAT: 'HTML'
|
||||
WIKI: "https://ifwiki.ru/api.php"
|
||||
WIKIUSER: "wikiuser"
|
||||
WIKIPASSWORD: "wikipassword"
|
||||
VNDB_USER: "vndbuser"
|
||||
VNDB_PASSWORD: "vndbpassword"
|
||||
|
|
8
run.php
8
run.php
|
@ -17,10 +17,12 @@
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
require "vendor/autoload.php";
|
||||
require "Game.php";
|
||||
require "Source.php";
|
||||
$config = parse_ini_file("./config.ini");
|
||||
$config = Yaml::parse(file_get_contents('config.yml'));
|
||||
define('STYLE',$config['STYLE']);
|
||||
define('FORMAT',$config['FORMAT']);
|
||||
$loader = new \Aura\Autoload\Loader;
|
||||
|
@ -40,7 +42,7 @@ if ($parsers === 'all' || in_array('all', $parsers)) {
|
|||
$parsers = [
|
||||
'urq',
|
||||
'anivisual',
|
||||
//'kvester',
|
||||
'kvester',
|
||||
//'vndb',
|
||||
'apero',
|
||||
'instead',
|
||||
|
@ -66,7 +68,7 @@ function check($classname, $command) {
|
|||
|
||||
check ('Urq', 'urq');
|
||||
check ('Qsp', 'qsp');
|
||||
//check ('Kvester', 'kvester');
|
||||
check ('Kvester', 'kvester');
|
||||
check ('Apero', 'apero');
|
||||
check ('Instead', 'instead');
|
||||
check ('Hyperbook', 'hyperbook_ru');
|
||||
|
|
4
wiki.php
4
wiki.php
|
@ -17,11 +17,13 @@
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
require "vendor/autoload.php";
|
||||
require "Game.php";
|
||||
require "Source.php";
|
||||
require "Wikipage.php";
|
||||
$config = parse_ini_file("./config.ini");
|
||||
$config = Yaml::parse(file_get_contents('config.yml'));
|
||||
$loader = new \Aura\Autoload\Loader;
|
||||
$loader->register();
|
||||
$loader->addPrefix('Source', 'Source');
|
||||
|
|
Reference in a new issue