Add support to override application constants
This commit is contained in:
parent
2a67751e84
commit
16f0bd4966
4
.gitignore
vendored
4
.gitignore
vendored
@ -38,3 +38,7 @@ Thumbs.db
|
|||||||
*~
|
*~
|
||||||
*.lock
|
*.lock
|
||||||
*.out
|
*.out
|
||||||
|
|
||||||
|
# App specific #
|
||||||
|
################
|
||||||
|
config.php
|
@ -118,3 +118,25 @@ You can report feeds that doesn't works properly too.
|
|||||||
Miniflux is tested with the latest versions of Mozilla Firefox, Google Chrome and Safari.
|
Miniflux is tested with the latest versions of Mozilla Firefox, Google Chrome and Safari.
|
||||||
|
|
||||||
I don't use Microsoft products, then I have no idea if Miniflux works correctly with Internet Explorer.
|
I don't use Microsoft products, then I have no idea if Miniflux works correctly with Internet Explorer.
|
||||||
|
|
||||||
|
### How to override application variables?
|
||||||
|
|
||||||
|
There is few settings that can't be changed by the user interface.
|
||||||
|
These parameters are defined with PHP constants.
|
||||||
|
|
||||||
|
To override them, create a `config.php` file at the root of the project and change yourself the values.
|
||||||
|
|
||||||
|
By example, to override the default HTTP timeout value:
|
||||||
|
|
||||||
|
# file config.php
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// My specific HTTP timeout (5 seconds)
|
||||||
|
define('HTTP_TIMEOUT', 5);
|
||||||
|
|
||||||
|
Actually, the following constants can be overrided:
|
||||||
|
|
||||||
|
- `HTTP_TIMEOUT` => default value is 10 seconds
|
||||||
|
- `APP_VERSION` => default value is master
|
||||||
|
- `DB_FILENAME` => default value is `data/db.sqlite`
|
||||||
|
18
common.php
18
common.php
@ -9,26 +9,20 @@ require 'vendor/PicoDb/Table.php';
|
|||||||
require 'schema.php';
|
require 'schema.php';
|
||||||
require 'model.php';
|
require 'model.php';
|
||||||
|
|
||||||
|
if (file_exists('config.php')) require 'config.php';
|
||||||
|
|
||||||
const DB_VERSION = 9;
|
defined('APP_VERSION') or define('APP_VERSION', 'master');
|
||||||
const APP_VERSION = 'master';
|
defined('HTTP_TIMEOUT') or define('HTTP_TIMEOUT', 10);
|
||||||
const HTTP_TIMEOUT = 10;
|
defined('DB_FILENAME') or define('DB_FILENAME', 'data/db.sqlite');
|
||||||
|
|
||||||
|
|
||||||
function get_db_filename()
|
|
||||||
{
|
|
||||||
return 'data/db.sqlite';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PicoTools\container('db', function() {
|
PicoTools\container('db', function() {
|
||||||
|
|
||||||
$db = new PicoDb\Database(array(
|
$db = new PicoDb\Database(array(
|
||||||
'driver' => 'sqlite',
|
'driver' => 'sqlite',
|
||||||
'filename' => get_db_filename()
|
'filename' => DB_FILENAME
|
||||||
));
|
));
|
||||||
|
|
||||||
if ($db->schema()->check(DB_VERSION)) {
|
if ($db->schema()->check(Model\DB_VERSION)) {
|
||||||
|
|
||||||
return $db;
|
return $db;
|
||||||
}
|
}
|
||||||
|
@ -394,7 +394,7 @@ Router\get_action('optimize-db', function() {
|
|||||||
Router\get_action('download-db', function() {
|
Router\get_action('download-db', function() {
|
||||||
|
|
||||||
Response\force_download('db.sqlite.gz');
|
Response\force_download('db.sqlite.gz');
|
||||||
Response\binary(gzencode(file_get_contents(get_db_filename())));
|
Response\binary(gzencode(file_get_contents(DB_FILENAME)));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -439,7 +439,7 @@ Router\get_action('config', function() {
|
|||||||
Response\html(Template\layout('config', array(
|
Response\html(Template\layout('config', array(
|
||||||
'errors' => array(),
|
'errors' => array(),
|
||||||
'values' => Model\get_config(),
|
'values' => Model\get_config(),
|
||||||
'db_size' => filesize(get_db_filename()),
|
'db_size' => filesize(DB_FILENAME),
|
||||||
'languages' => Model\get_languages(),
|
'languages' => Model\get_languages(),
|
||||||
'autoflush_options' => Model\get_autoflush_options(),
|
'autoflush_options' => Model\get_autoflush_options(),
|
||||||
'paging_options' => Model\get_paging_options(),
|
'paging_options' => Model\get_paging_options(),
|
||||||
@ -472,7 +472,7 @@ Router\post_action('config', function() {
|
|||||||
Response\html(Template\layout('config', array(
|
Response\html(Template\layout('config', array(
|
||||||
'errors' => $errors,
|
'errors' => $errors,
|
||||||
'values' => $values,
|
'values' => $values,
|
||||||
'db_size' => filesize(get_db_filename()),
|
'db_size' => filesize(DB_FILENAME),
|
||||||
'languages' => Model\get_languages(),
|
'languages' => Model\get_languages(),
|
||||||
'autoflush_options' => Model\get_autoflush_options(),
|
'autoflush_options' => Model\get_autoflush_options(),
|
||||||
'paging_options' => Model\get_paging_options(),
|
'paging_options' => Model\get_paging_options(),
|
||||||
|
Loading…
Reference in New Issue
Block a user