mirror of
https://github.com/flarum/framework.git
synced 2024-12-13 23:53:42 +08:00
Change base URL etc. in config.php file
This commit is contained in:
parent
6e52762b7a
commit
dafb4c06bc
|
@ -34,10 +34,10 @@ class ForumSerializer extends Serializer
|
||||||
{
|
{
|
||||||
$attributes = [
|
$attributes = [
|
||||||
'title' => Core::config('forum_title'),
|
'title' => Core::config('forum_title'),
|
||||||
'baseUrl' => Core::config('base_url'),
|
'baseUrl' => Core::url(),
|
||||||
'basePath' => parse_url(Core::config('base_url'), PHP_URL_PATH) ?: '',
|
'basePath' => parse_url(Core::url(), PHP_URL_PATH) ?: '',
|
||||||
'debug' => Core::inDebugMode(),
|
'debug' => Core::inDebugMode(),
|
||||||
'apiUrl' => Core::config('api_url'),
|
'apiUrl' => Core::url('api'),
|
||||||
'welcomeTitle' => Core::config('welcome_title'),
|
'welcomeTitle' => Core::config('welcome_title'),
|
||||||
'welcomeMessage' => Core::config('welcome_message'),
|
'welcomeMessage' => Core::config('welcome_message'),
|
||||||
'themePrimaryColor' => Core::config('theme_primary_color'),
|
'themePrimaryColor' => Core::config('theme_primary_color'),
|
||||||
|
@ -48,7 +48,7 @@ class ForumSerializer extends Serializer
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($this->actor->isAdmin()) {
|
if ($this->actor->isAdmin()) {
|
||||||
$attributes['adminUrl'] = Core::config('admin_url');
|
$attributes['adminUrl'] = Core::url('admin');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $attributes;
|
return $attributes;
|
||||||
|
|
|
@ -30,4 +30,15 @@ class Core
|
||||||
|
|
||||||
return app('Flarum\Core\Settings\SettingsRepository')->get($key, $default);
|
return app('Flarum\Core\Settings\SettingsRepository')->get($key, $default);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function url($name = null)
|
||||||
|
{
|
||||||
|
$url = static::config('url');
|
||||||
|
|
||||||
|
if ($name) {
|
||||||
|
$url .= '/' . static::config("paths.$name");
|
||||||
|
}
|
||||||
|
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ class RequestPasswordResetHandler
|
||||||
// password route be part of core??
|
// password route be part of core??
|
||||||
$data = [
|
$data = [
|
||||||
'username' => $user->username,
|
'username' => $user->username,
|
||||||
'url' => $this->settings->get('base_url').'/reset/'.$token->id,
|
'url' => Core::url().'/reset/'.$token->id,
|
||||||
'forumTitle' => $this->settings->get('forum_title'),
|
'forumTitle' => $this->settings->get('forum_title'),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ class EmailConfirmationMailer
|
||||||
// email route be part of core??
|
// email route be part of core??
|
||||||
return [
|
return [
|
||||||
'username' => $user->username,
|
'username' => $user->username,
|
||||||
'url' => $this->settings->get('base_url').'/confirm/'.$token->id,
|
'url' => Core::url().'/confirm/'.$token->id,
|
||||||
'forumTitle' => $this->settings->get('forum_title')
|
'forumTitle' => $this->settings->get('forum_title')
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,10 +70,8 @@ class InstallAction extends Action
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$baseUrl = rtrim((string) $request->getAttribute('originalUri'), '/');
|
$baseUrl = rtrim((string) $request->getAttribute('originalUri'), '/');
|
||||||
|
$data->setBaseUrl($baseUrl);
|
||||||
|
|
||||||
$data->setSetting('admin_url', $baseUrl . '/admin');
|
|
||||||
$data->setSetting('api_url', $baseUrl . '/api.php');
|
|
||||||
$data->setSetting('base_url', $baseUrl);
|
|
||||||
$data->setSetting('forum_title', array_get($input, 'forumTitle'));
|
$data->setSetting('forum_title', array_get($input, 'forumTitle'));
|
||||||
$data->setSetting('mail_from', 'noreply@' . preg_replace('/^www\./i', '', parse_url($baseUrl, PHP_URL_HOST)));
|
$data->setSetting('mail_from', 'noreply@' . preg_replace('/^www\./i', '', parse_url($baseUrl, PHP_URL_HOST)));
|
||||||
$data->setSetting('welcome_title', 'Welcome to ' . array_get($input, 'forumTitle'));
|
$data->setSetting('welcome_title', 'Welcome to ' . array_get($input, 'forumTitle'));
|
||||||
|
|
|
@ -24,6 +24,8 @@ class DataFromUser implements ProvidesData
|
||||||
|
|
||||||
protected $questionHelper;
|
protected $questionHelper;
|
||||||
|
|
||||||
|
protected $baseUrl;
|
||||||
|
|
||||||
|
|
||||||
public function __construct(InputInterface $input, OutputInterface $output, QuestionHelper $questionHelper)
|
public function __construct(InputInterface $input, OutputInterface $output, QuestionHelper $questionHelper)
|
||||||
{
|
{
|
||||||
|
@ -44,6 +46,11 @@ class DataFromUser implements ProvidesData
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBaseUrl()
|
||||||
|
{
|
||||||
|
return $this->baseUrl = rtrim($this->ask('Base URL:'), '/');
|
||||||
|
}
|
||||||
|
|
||||||
public function getAdminUser()
|
public function getAdminUser()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@ -55,16 +62,13 @@ class DataFromUser implements ProvidesData
|
||||||
|
|
||||||
public function getSettings()
|
public function getSettings()
|
||||||
{
|
{
|
||||||
$baseUrl = rtrim($this->ask('Base URL:'), '/');
|
|
||||||
$title = $this->ask('Forum title:');
|
$title = $this->ask('Forum title:');
|
||||||
|
$baseUrl = $this->baseUrl ?: 'http://localhost';
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'admin_url' => $baseUrl . '/admin',
|
|
||||||
'allow_post_editing' => 'reply',
|
'allow_post_editing' => 'reply',
|
||||||
'allow_renaming' => '10',
|
'allow_renaming' => '10',
|
||||||
'allow_sign_up' => '1',
|
'allow_sign_up' => '1',
|
||||||
'api_url' => $baseUrl . '/api.php',
|
|
||||||
'base_url' => $baseUrl,
|
|
||||||
'custom_less' => '',
|
'custom_less' => '',
|
||||||
'default_locale' => 'en',
|
'default_locale' => 'en',
|
||||||
'default_route' => '/all',
|
'default_route' => '/all',
|
||||||
|
|
|
@ -21,6 +21,8 @@ class DefaultData implements ProvidesData
|
||||||
'prefix' => '',
|
'prefix' => '',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $baseUrl = 'http://flarum.dev';
|
||||||
|
|
||||||
protected $adminUser = [
|
protected $adminUser = [
|
||||||
'username' => 'admin',
|
'username' => 'admin',
|
||||||
'password' => 'admin',
|
'password' => 'admin',
|
||||||
|
@ -28,12 +30,9 @@ class DefaultData implements ProvidesData
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $settings = [
|
protected $settings = [
|
||||||
'admin_url' => 'http://flarum.dev/admin',
|
|
||||||
'allow_post_editing' => 'reply',
|
'allow_post_editing' => 'reply',
|
||||||
'allow_renaming' => '10',
|
'allow_renaming' => '10',
|
||||||
'allow_sign_up' => '1',
|
'allow_sign_up' => '1',
|
||||||
'api_url' => 'http://flarum.dev/api.php',
|
|
||||||
'base_url' => 'http://flarum.dev',
|
|
||||||
'custom_less' => '',
|
'custom_less' => '',
|
||||||
'default_locale' => 'en',
|
'default_locale' => 'en',
|
||||||
'default_route' => '/all',
|
'default_route' => '/all',
|
||||||
|
@ -60,6 +59,16 @@ class DefaultData implements ProvidesData
|
||||||
$this->databaseConfiguration = $databaseConfiguration;
|
$this->databaseConfiguration = $databaseConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBaseUrl()
|
||||||
|
{
|
||||||
|
return $this->baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setBaseUrl($baseUrl)
|
||||||
|
{
|
||||||
|
$this->baseUrl = $baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
public function getAdminUser()
|
public function getAdminUser()
|
||||||
{
|
{
|
||||||
return $this->adminUser;
|
return $this->adminUser;
|
||||||
|
|
|
@ -129,6 +129,11 @@ class InstallCommand extends Command
|
||||||
'prefix' => $dbConfig['prefix'],
|
'prefix' => $dbConfig['prefix'],
|
||||||
'strict' => false
|
'strict' => false
|
||||||
],
|
],
|
||||||
|
'url' => $this->dataSource->getBaseUrl(),
|
||||||
|
'paths' => [
|
||||||
|
'api' => 'api',
|
||||||
|
'admin' => 'admin',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->info('Testing config');
|
$this->info('Testing config');
|
||||||
|
|
|
@ -14,6 +14,8 @@ interface ProvidesData
|
||||||
{
|
{
|
||||||
public function getDatabaseConfiguration();
|
public function getDatabaseConfiguration();
|
||||||
|
|
||||||
|
public function getBaseUrl();
|
||||||
|
|
||||||
public function getAdminUser();
|
public function getAdminUser();
|
||||||
|
|
||||||
public function getSettings();
|
public function getSettings();
|
||||||
|
|
|
@ -38,7 +38,7 @@ abstract class Action
|
||||||
*/
|
*/
|
||||||
protected function redirectTo($url)
|
protected function redirectTo($url)
|
||||||
{
|
{
|
||||||
$url = Core::config('base_url') . $url;
|
$url = Core::url() . $url;
|
||||||
|
|
||||||
$content = sprintf('
|
$content = sprintf('
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user