diff --git a/.gitignore b/.gitignore index fce340f..d29257c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,12 @@ flexisip-account-manager/ rpmbuild/ +.env.* + flexiapi/node_modules flexiapi/public/hot flexiapi/public/storage +flexiapi/public/css/*.style.css flexiapi/storage/*.key flexiapi/vendor flexiapi/.env diff --git a/flexiapi/.env.example b/flexiapi/.env.example index 3046e3c..a000f4d 100644 --- a/flexiapi/.env.example +++ b/flexiapi/.env.example @@ -5,6 +5,10 @@ APP_DEBUG=false APP_URL=http://localhost APP_SIP_DOMAIN= +INSTANCE_COPYRIGHT= +INSTANCE_INTRO_REGISTRATION= +INSTANCE_CUSTOM_THEME=false + LOG_CHANNEL=stack DB_DATABASE=/var/www/flexiapi/db.sqlite diff --git a/flexiapi/README.md b/flexiapi/README.md index 9c547d3..916037e 100644 --- a/flexiapi/README.md +++ b/flexiapi/README.md @@ -26,6 +26,41 @@ Complete all the other variables in the `.env` file: - SMTP configuration - App name, SIP domain… +### Multi instances environement + +FlexiAPI can also handle multi domains setup. + +To do so, configure several web servers virtualhosts and set a specific `APP_ENV` environement variable in each of them. + +With Apache, use the [mod_env](https://httpd.apache.org/docs/2.4/mod/mod_env.html) module. + + SetEnv APP_ENV foobar + +On nginx use `fastcgi_param` to pass the parameter directly to PHP. + + location ~ [^/]\.php(/|$) { + … + include /etc/nginx/fastcgi_params; + fastcgi_param APP_ENV foobar; + } + +Note that if `APP_ENV` is not set FlexiAPI will directly use the default `.env` file. + +FlexiAPI will then try to load a custom configuration file with the following name `.env.$APP_ENV`. So for the previous example `.env.foobar`. + +You can then configure your instances with specific values. + + INSTANCE_COPYRIGHT="FooBar - Since 1997" + INSTANCE_INTRO_REGISTRATION="Welcome on the FooBar Server" + INSTANCE_CUSTOM_THEME=true + … + +#### Custom theme + +If you set `INSTANCE_CUSTOM_THEME` to true, FlexiAPI will try to load a CSS file located in `public/css/$APP_ENV.style.css`. If the file doesn't exists it will fallback to `public/css/style.css`. + +We advise you to copy the `style.css` file and rename it to make your custom CSS configurations for your instance. + ### SELinux If you are running on a CentOS/RedHat machine, please ensure that SELinux is correctly configured. diff --git a/flexiapi/app/Configuration.php b/flexiapi/app/Configuration.php deleted file mode 100644 index cd93298..0000000 --- a/flexiapi/app/Configuration.php +++ /dev/null @@ -1,11 +0,0 @@ - '@' . config('app.sip_domain'), - 'configuration' => Configuration::first() + 'domain' => '@' . config('app.sip_domain') ]); } diff --git a/flexiapi/app/Http/Controllers/Admin/ConfigurationController.php b/flexiapi/app/Http/Controllers/Admin/ConfigurationController.php deleted file mode 100644 index efb770d..0000000 --- a/flexiapi/app/Http/Controllers/Admin/ConfigurationController.php +++ /dev/null @@ -1,34 +0,0 @@ - $configuration - ]); - } - - public function update(Request $request) - { - $configuration = Configuration::first(); - if (!$configuration) $configuration = new Configuration; - - $configuration->copyright = $request->get('copyright'); - $configuration->intro_registration = $request->get('intro_registration'); - $configuration->custom_theme = $request->input('custom_theme', false); - $configuration->save(); - - return redirect()->route('admin.configuration.update'); - } -} diff --git a/flexiapi/config/instance.php b/flexiapi/config/instance.php new file mode 100644 index 0000000..945c05c --- /dev/null +++ b/flexiapi/config/instance.php @@ -0,0 +1,7 @@ + env('INSTANCE_COPYRIGHT', null), + 'intro_registration' => env('INSTANCE_INTRO_REGISTRATION', null), + 'custom_theme' => env('INSTANCE_CUSTOM_THEME', false), +]; \ No newline at end of file diff --git a/flexiapi/database/migrations/2020_05_05_150015_create_configuration_table.php b/flexiapi/database/migrations/2020_05_05_150015_create_configuration_table.php deleted file mode 100644 index 841d792..0000000 --- a/flexiapi/database/migrations/2020_05_05_150015_create_configuration_table.php +++ /dev/null @@ -1,24 +0,0 @@ -bigIncrements('id'); - $table->string('copyright')->nullable(); - $table->text('intro_registration')->nullable(); - $table->boolean('custom_theme')->default(false); - $table->timestamps(); - }); - } - - public function down() - { - Schema::dropIfExists('configuration'); - } -} diff --git a/flexiapi/resources/views/account/index.blade.php b/flexiapi/resources/views/account/index.blade.php index 94d7d48..83ba531 100644 --- a/flexiapi/resources/views/account/index.blade.php +++ b/flexiapi/resources/views/account/index.blade.php @@ -40,12 +40,6 @@
Manage the FlexiSIP accounts
- -Configure the layout and other parameters
- @endif diff --git a/flexiapi/resources/views/account/register.blade.php b/flexiapi/resources/views/account/register.blade.php index 396d903..13c1234 100644 --- a/flexiapi/resources/views/account/register.blade.php +++ b/flexiapi/resources/views/account/register.blade.php @@ -2,8 +2,8 @@ @section('content') -@if ($configuration && !empty($configuration->intro_registration)) -{!! nl2br($configuration->intro_registration) !!}
+@if (config('instance.intro_registration')) +{!! nl2br(config('instance.intro_registration')) !!}
@endifYou already have an account? diff --git a/flexiapi/resources/views/admin/configuration/edit.blade.php b/flexiapi/resources/views/admin/configuration/edit.blade.php deleted file mode 100644 index f8c1682..0000000 --- a/flexiapi/resources/views/admin/configuration/edit.blade.php +++ /dev/null @@ -1,32 +0,0 @@ -@extends('layouts.account') - -@section('breadcrumb') -