mirror of
https://github.com/tchapi/davis.git
synced 2025-03-14 01:19:49 +01:00
Add WebDAV capability
Minor fixes for env vars, comments
This commit is contained in:
parent
833c3ae338
commit
4d0414188c
9
.env
9
.env
@ -45,6 +45,13 @@ AUTH_REALM=SabreDAV
|
||||
# Do we enable caldav and carddav ?
|
||||
CALDAV_ENABLED=true
|
||||
CARDDAV_ENABLED=true
|
||||
WEBDAV_ENABLED=false
|
||||
|
||||
# What mail is used as the sender for invites ?
|
||||
INVITE_FROM_ADDRESS=no-reply@example.org
|
||||
INVITE_FROM_ADDRESS=no-reply@example.org
|
||||
|
||||
# Paths for WebDAV
|
||||
# Make sure that these directories exist, with write permissions for your server.
|
||||
# USE ABSOLUTE PATHS for better predictability
|
||||
TMP_DIR='/tmp'
|
||||
PUBLIC_DIR='/public'
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -23,4 +23,5 @@
|
||||
###< friendsofphp/php-cs-fixer ###
|
||||
|
||||
.DS_Store
|
||||
TODO.todo
|
||||
TODO.todo
|
||||
.webdav_*
|
@ -1,7 +1,7 @@
|
||||
Davis
|
||||
---
|
||||
|
||||
A simple, fully translatable admin interface for `sabre/dav` based on [Symfony 4](https://symfony.com/) and [Bootstrap 4](https://getbootstrap.com/), largely inspired by [Baïkal](https://github.com/sabre-io/Baikal).
|
||||
A simple, fully translatable admin interface and frontend for `sabre/dav` based on [Symfony 4](https://symfony.com/) and [Bootstrap 4](https://getbootstrap.com/), largely inspired by [Baïkal](https://github.com/sabre-io/Baikal).
|
||||
|
||||
# Requirements
|
||||
|
||||
|
@ -5,6 +5,7 @@ twig:
|
||||
form_themes: ['bootstrap_4_horizontal_layout.html.twig']
|
||||
globals:
|
||||
invite_from_address: '%env(INVITE_FROM_ADDRESS)%'
|
||||
calDAVEnabled: '%env(CALDAV_ENABLED)%'
|
||||
cardDAVEnabled: '%env(CARDDAV_ENABLED)%'
|
||||
calDAVEnabled: '%env(bool:CALDAV_ENABLED)%'
|
||||
cardDAVEnabled: '%env(bool:CARDDAV_ENABLED)%'
|
||||
webDAVEnabled: '%env(bool:WEBDAV_ENABLED)%'
|
||||
authRealm: '%env(AUTH_REALM)%'
|
@ -26,11 +26,14 @@ services:
|
||||
|
||||
App\Controller\DAVController:
|
||||
arguments:
|
||||
$calDAVEnabled: "%env(CALDAV_ENABLED)%"
|
||||
$cardDAVEnabled: "%env(CARDDAV_ENABLED)%"
|
||||
$inviteAddress: '%env(INVITE_FROM_ADDRESS)%'
|
||||
$authRealm: '%env(AUTH_REALM)%'
|
||||
$calDAVEnabled: "%env(bool:CALDAV_ENABLED)%"
|
||||
$cardDAVEnabled: "%env(bool:CARDDAV_ENABLED)%"
|
||||
$webDAVEnabled: "%env(bool:WEBDAV_ENABLED)%"
|
||||
$inviteAddress: "%env(INVITE_FROM_ADDRESS)%"
|
||||
$authRealm: "%env(AUTH_REALM)%"
|
||||
$publicDir: "%env(PUBLIC_DIR)%"
|
||||
$tmpDir: "%env(TMP_DIR)%"
|
||||
|
||||
App\Controller\AdminController:
|
||||
arguments:
|
||||
$authRealm: '%env(AUTH_REALM)%'
|
||||
$authRealm: "%env(AUTH_REALM)%"
|
@ -30,6 +30,7 @@ body {
|
||||
min-width: 270px;
|
||||
}
|
||||
|
||||
/* Little color swatch to show calendar color */
|
||||
#calendar_instance_calendarColor_help::after {
|
||||
content: "";
|
||||
width: 30px;
|
||||
@ -39,4 +40,4 @@ body {
|
||||
right: 19px;
|
||||
background: var(--calendar-color);
|
||||
border-radius: 2px;
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,13 @@ class DAVController extends AbstractController
|
||||
*/
|
||||
protected $cardDAVEnabled;
|
||||
|
||||
/**
|
||||
* is WebDAV enabled?
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $webDAVEnabled;
|
||||
|
||||
/**
|
||||
* Mail address to send mails from.
|
||||
*
|
||||
@ -37,12 +44,30 @@ class DAVController extends AbstractController
|
||||
*/
|
||||
protected $authRealm;
|
||||
|
||||
public function __construct($calDAVEnabled = true, $cardDAVEnabled = true, ?string $inviteAddress, ?string $authRealm)
|
||||
/**
|
||||
* WebDAV Public directory.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $publicDir;
|
||||
|
||||
/**
|
||||
* WebDAV Temporary directory.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $tmpDir;
|
||||
|
||||
public function __construct(bool $calDAVEnabled = true, bool $cardDAVEnabled = true, bool $webDAVEnabled = false, ?string $inviteAddress, ?string $authRealm, ?string $publicDir, ?string $tmpDir)
|
||||
{
|
||||
$this->calDAVEnabled = $calDAVEnabled;
|
||||
$this->cardDAVEnabled = $cardDAVEnabled;
|
||||
$this->webDAVEnabled = $webDAVEnabled;
|
||||
$this->inviteAddress = $inviteAddress ?? null;
|
||||
$this->authRealm = $authRealm ?? User::DEFAULT_AUTH_REALM;
|
||||
|
||||
$this->publicDir = $publicDir;
|
||||
$this->tmpDir = $tmpDir;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,6 +111,9 @@ class DAVController extends AbstractController
|
||||
$carddavBackend = new \Sabre\CardDAV\Backend\PDO($pdo);
|
||||
$nodes[] = new \Sabre\CardDAV\AddressBookRoot($principalBackend, $carddavBackend);
|
||||
}
|
||||
if ($this->webDAVEnabled && $this->tmpDir && $this->publicDir) {
|
||||
$nodes[] = new \Sabre\DAV\FS\Directory($this->publicDir);
|
||||
}
|
||||
|
||||
// The object tree needs in turn to be passed to the server class
|
||||
$server = new \Sabre\DAV\Server($nodes);
|
||||
@ -121,6 +149,14 @@ class DAVController extends AbstractController
|
||||
$server->addPlugin(new \Sabre\CardDAV\VCFExportPlugin());
|
||||
}
|
||||
|
||||
// WebDAV plugins
|
||||
if ($this->webDAVEnabled && $this->tmpDir && $this->publicDir) {
|
||||
$lockBackend = new \Sabre\DAV\Locks\Backend\File($this->tmpDir.'/locksdb');
|
||||
$server->addPlugin(new \Sabre\DAV\Locks\Plugin($lockBackend));
|
||||
//$server->addPlugin(new \Sabre\DAV\Browser\GuessContentType()); // Waiting for https://github.com/sabre-io/dav/pull/1203
|
||||
$server->addPlugin(new \Sabre\DAV\TemporaryFileFilterPlugin($this->tmpDir));
|
||||
}
|
||||
|
||||
$server->start();
|
||||
|
||||
// Needed for Symfony, that expects a response otherwise
|
||||
|
@ -30,6 +30,14 @@
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center list-group-item-danger">CardDAV
|
||||
<span class="badge badge-danger badge-pill">{{ "disabled"|trans }}</span></li>
|
||||
{% endif %}
|
||||
|
||||
{% if webDAVEnabled %}
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center list-group-item-success">WebDAV
|
||||
<span class="badge badge-success badge-pill">{{ "enabled"|trans }}</span></li>
|
||||
{% else %}
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center list-group-item-danger">WebDAV
|
||||
<span class="badge badge-danger badge-pill">{{ "disabled"|trans }}</span></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
@ -14,14 +14,16 @@
|
||||
flex-direction: column;
|
||||
}
|
||||
.badge-success {
|
||||
color: #fff;
|
||||
background-color: #28a745;
|
||||
}
|
||||
.badge-warning {
|
||||
color: #fff;
|
||||
background-color: #ffc107;
|
||||
}
|
||||
.badge-danger {
|
||||
background-color: #dc3545;
|
||||
}
|
||||
.badge {
|
||||
color: #fff;
|
||||
display: inline-block;
|
||||
padding: .25em .4em;
|
||||
font-size: 75%;
|
||||
@ -48,8 +50,9 @@
|
||||
<div class="hero">
|
||||
<img src="/images/logo.png" width="60px">
|
||||
<h3>{{ "davis.running"|trans }}</h3>
|
||||
<div>CalDAV : {% if calDAVEnabled %}<span class="badge badge-success">{{ "enabled"|trans }}</span>{% else %}<span class="badge badge-warning">{{ "disabled"|trans }}</span>{% endif %}</div>
|
||||
<div>CardDAV : {% if cardDAVEnabled %}<span class="badge badge-success">{{ "enabled"|trans }}</span>{% else %}<span class="badge badge-warning">{{ "disabled"|trans }}</span>{% endif %}</div>
|
||||
<div>CalDAV : {% if calDAVEnabled %}<span class="badge badge-success">{{ "enabled"|trans }}</span>{% else %}<span class="badge badge-danger">{{ "disabled"|trans }}</span>{% endif %}</div>
|
||||
<div>CardDAV : {% if cardDAVEnabled %}<span class="badge badge-success">{{ "enabled"|trans }}</span>{% else %}<span class="badge badge-danger">{{ "disabled"|trans }}</span>{% endif %}</div>
|
||||
<div>WebDAV : {% if webDAVEnabled %}<span class="badge badge-success">{{ "enabled"|trans }}</span>{% else %}<span class="badge badge-danger">{{ "disabled"|trans }}</span>{% endif %}</div>
|
||||
<a href="{{ path('dashboard') }}" class="admin">{{ "admin.interface"|trans }}</a>
|
||||
</div>
|
||||
</body>
|
||||
|
Loading…
x
Reference in New Issue
Block a user