Compare commits
2 commits
9f455202b3
...
45ca1c4c48
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
45ca1c4c48 | ||
|
|
645035fcc7 |
|
|
@ -6,8 +6,8 @@
|
||||||
"source": {
|
"source": {
|
||||||
"kind": "ics_feed",
|
"kind": "ics_feed",
|
||||||
"data": {
|
"data": {
|
||||||
"url": "https://export.kalender.digital/ics/0/3e10dae66950379d4cc8/gesamterkalender.ics?past_months=1&future_months=2",
|
"url": "https://www.phpclasses.org/browse/download/1/file/63438/name/example.ics",
|
||||||
"condense": false
|
"combine": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,16 @@ class struct_auth
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_source_data_ics_feed
|
||||||
|
{
|
||||||
|
public string $url;
|
||||||
|
public bool $combined;
|
||||||
|
public int $lifetime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
class struct_source
|
class struct_source
|
||||||
|
|
@ -91,7 +101,14 @@ function load(
|
||||||
function get(
|
function get(
|
||||||
) : struct_root
|
) : struct_root
|
||||||
{
|
{
|
||||||
return _state::$data;
|
if (_state::$data === null)
|
||||||
|
{
|
||||||
|
throw (new \Exception('not yet loaded'));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return _state::$data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,6 @@ class class_cache_memory
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
class class_cache_file
|
class class_cache_file
|
||||||
|
|
|
||||||
|
|
@ -296,7 +296,7 @@ function time_decode(
|
||||||
\intval(\substr($time_encoded, 0, 2)),
|
\intval(\substr($time_encoded, 0, 2)),
|
||||||
\intval(\substr($time_encoded, 2, 2)),
|
\intval(\substr($time_encoded, 2, 2)),
|
||||||
\intval(\substr($time_encoded, 4, 2)),
|
\intval(\substr($time_encoded, 4, 2)),
|
||||||
((\strlen($time_encoded >= 7) && ($time_encoded[6] === 'Z')))
|
((\strlen($time_encoded) >= 7) && ($time_encoded[6] === 'Z'))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -496,7 +496,7 @@ function vcalendar_decode(
|
||||||
fn($x) => \explode(',', $x),
|
fn($x) => \explode(',', $x),
|
||||||
\array_values(
|
\array_values(
|
||||||
\array_filter(
|
\array_filter(
|
||||||
$event_raw->additionalProperties['categories_array'],
|
($event_raw->additionalProperties['categories_array'] ?? []),
|
||||||
fn($x) => \is_string($x)
|
fn($x) => \is_string($x)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
119
source/model.php
Normal file
119
source/model.php
Normal file
|
|
@ -0,0 +1,119 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace davigil\model;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_event
|
||||||
|
{
|
||||||
|
public string $id;
|
||||||
|
public string $title;
|
||||||
|
public /*type_unix_timestamp*/int $begin;
|
||||||
|
public /*type_unix_timestamp*/?int $end;
|
||||||
|
public ?string $location;
|
||||||
|
public ?string $description;
|
||||||
|
public array $tags;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
string $id,
|
||||||
|
string $title,
|
||||||
|
/*type_unix_timestamp*/int $begin,
|
||||||
|
/*type_unix_timestamp*/?int $end,
|
||||||
|
?string $location,
|
||||||
|
?string $description,
|
||||||
|
array $tags
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
$this->title = $title;
|
||||||
|
$this->begin = $begin;
|
||||||
|
$this->end = $end;
|
||||||
|
$this->location = $location;
|
||||||
|
$this->description = $description;
|
||||||
|
$this->tags = $tags;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function event_to_raw(
|
||||||
|
struct_event $event
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $event->id,
|
||||||
|
'title' => $event->title,
|
||||||
|
'begin' => $event->begin,
|
||||||
|
'end' => $event->end,
|
||||||
|
'location' => $event->location,
|
||||||
|
'description' => $event->description,
|
||||||
|
'tags' => $event->tags,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function event_from_raw(
|
||||||
|
$event_raw
|
||||||
|
) : struct_event
|
||||||
|
{
|
||||||
|
return (new struct_event(
|
||||||
|
$event_raw['id'],
|
||||||
|
$event_raw['title'],
|
||||||
|
$event_raw['begin'],
|
||||||
|
$event_raw['end'],
|
||||||
|
$event_raw['location'],
|
||||||
|
$event_raw['description'],
|
||||||
|
$event_raw['tags'],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
class struct_calendar
|
||||||
|
{
|
||||||
|
public array $events;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
array $events
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$this->events = $events;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function calendar_to_raw(
|
||||||
|
struct_calendar $calendar
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'events' => \array_map(
|
||||||
|
fn($event) => event_to_raw($event),
|
||||||
|
$calendar->events
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
function calendar_from_raw(
|
||||||
|
$calendar_raw
|
||||||
|
) : struct_calendar
|
||||||
|
{
|
||||||
|
return (new struct_calendar(
|
||||||
|
\array_map(
|
||||||
|
fn($event_raw) => event_from_raw($event_raw),
|
||||||
|
$calendar_raw['events']
|
||||||
|
)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
@ -5,6 +5,7 @@ namespace davigil\overwrites;
|
||||||
require_once('vendor/autoload.php');
|
require_once('vendor/autoload.php');
|
||||||
require_once('helpers/call.php');
|
require_once('helpers/call.php');
|
||||||
require_once('helpers/ics.php');
|
require_once('helpers/ics.php');
|
||||||
|
require_once('model.php');
|
||||||
require_once('sources/_interface.php');
|
require_once('sources/_interface.php');
|
||||||
require_once('conf.php');
|
require_once('conf.php');
|
||||||
|
|
||||||
|
|
@ -69,32 +70,32 @@ class class_caldav_backend
|
||||||
* @todo outsource
|
* @todo outsource
|
||||||
*/
|
*/
|
||||||
private function event_to_vevent(
|
private function event_to_vevent(
|
||||||
array $event
|
\davigil\model\struct_event $event
|
||||||
) : \davigil\helpers\ics\struct_vevent
|
) : \davigil\helpers\ics\struct_vevent
|
||||||
{
|
{
|
||||||
$vevent = new \davigil\helpers\ics\struct_vevent();
|
$vevent = new \davigil\helpers\ics\struct_vevent();
|
||||||
{
|
{
|
||||||
$vevent->uid = $event['id'];
|
$vevent->uid = $event->id;
|
||||||
$vevent->dtstamp = \davigil\helpers\ics\datetime_from_unix_timestamp($event['begin']);
|
$vevent->dtstamp = \davigil\helpers\ics\datetime_from_unix_timestamp($event->begin);
|
||||||
$vevent->dtstart = new \davigil\helpers\ics\struct_dt(
|
$vevent->dtstart = new \davigil\helpers\ics\struct_dt(
|
||||||
'',
|
'',
|
||||||
\davigil\helpers\ics\datetime_from_unix_timestamp($event['begin'])
|
\davigil\helpers\ics\datetime_from_unix_timestamp($event->begin)
|
||||||
);
|
);
|
||||||
$vevent->dtend = (
|
$vevent->dtend = (
|
||||||
($event['end'] === null)
|
($event->end === null)
|
||||||
?
|
?
|
||||||
null
|
null
|
||||||
:
|
:
|
||||||
new \davigil\helpers\ics\struct_dt(
|
new \davigil\helpers\ics\struct_dt(
|
||||||
'',
|
'',
|
||||||
\davigil\helpers\ics\datetime_from_unix_timestamp($event['end'])
|
\davigil\helpers\ics\datetime_from_unix_timestamp($event->end)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$vevent->summary = $event['title'];
|
$vevent->summary = $event->title;
|
||||||
$vevent->location = $event['location'];
|
$vevent->location = $event->location;
|
||||||
$vevent->description = $event['description'];
|
$vevent->description = $event->description;
|
||||||
$vevent->class = \davigil\helpers\ics\enum_class::public_;
|
$vevent->class = \davigil\helpers\ics\enum_class::public_;
|
||||||
$vevent->categories = $event['tags'];
|
$vevent->categories = $event->tags;
|
||||||
}
|
}
|
||||||
return $vevent;
|
return $vevent;
|
||||||
}
|
}
|
||||||
|
|
@ -131,11 +132,11 @@ class class_caldav_backend
|
||||||
$principalUri
|
$principalUri
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$data = $this->source->get([]);
|
$calendar = $this->source->get([]);
|
||||||
$tags = [];
|
$tags = [];
|
||||||
foreach ($data as $entry)
|
foreach ($calendar->events as $event)
|
||||||
{
|
{
|
||||||
foreach ($entry['tags'] as $tag)
|
foreach ($event->tags as $tag)
|
||||||
{
|
{
|
||||||
$tags[$tag] = null;
|
$tags[$tag] = null;
|
||||||
}
|
}
|
||||||
|
|
@ -187,27 +188,27 @@ class class_caldav_backend
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$tag = $calendarId;
|
$tag = $calendarId;
|
||||||
$data = $this->source->get([]);
|
$calendar = $this->source->get([]);
|
||||||
$result = \array_map(
|
$result = \array_map(
|
||||||
fn($entry) => [
|
fn($event) => [
|
||||||
'calendarid' => $calendarId,
|
'calendarid' => $calendarId,
|
||||||
'id' => $entry['id'],
|
'id' => $event->id,
|
||||||
// 'uri' => \sprintf('%s.ics', $entry['id']),
|
// 'uri' => \sprintf('%s.ics', $entry['id']),
|
||||||
'uri' => $entry['id'],
|
'uri' => $event->id,
|
||||||
'lastmodified' => \time(),
|
'lastmodified' => \time(),
|
||||||
// 'etag' => null,
|
// 'etag' => null,
|
||||||
// 'size' => null,
|
// 'size' => null,
|
||||||
'component' => 'vevent',
|
'component' => 'vevent',
|
||||||
'{DAV:}displayname' => $entry['title'],
|
'{DAV:}displayname' => $event->title,
|
||||||
],
|
],
|
||||||
\array_values(
|
\array_values(
|
||||||
\array_filter(
|
\array_filter(
|
||||||
$data,
|
$calendar->events,
|
||||||
fn($entry) => \in_array(
|
fn($event) => \in_array(
|
||||||
$tag,
|
$tag,
|
||||||
\array_map(
|
\array_map(
|
||||||
fn($x) => $this->hash_tag($x),
|
fn($x) => $this->hash_tag($x),
|
||||||
$entry['tags']
|
$event->tags
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -230,18 +231,21 @@ class class_caldav_backend
|
||||||
$entries = \array_values(
|
$entries = \array_values(
|
||||||
\array_filter(
|
\array_filter(
|
||||||
$data,
|
$data,
|
||||||
fn($entry) => ($entry['id'] === $id)
|
fn($entry) => ($entry->id === $id)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if (\count($entries) !== 1)
|
if (\count($entries) < 1)
|
||||||
{
|
{
|
||||||
throw (new \Exception(\sprintf('not found or ambiguous')));
|
throw (new \Exception(\sprintf('not found: %s', $objectUri)));
|
||||||
|
}
|
||||||
|
else if (\count($entries) > 1)
|
||||||
|
{
|
||||||
|
throw (new \Exception(\sprintf('ambiguous: %s', $objectUri)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$vcalendar = $this->events_to_vcalendar($entries);
|
$vcalendar = $this->events_to_vcalendar($entries);
|
||||||
$ics = \davigil\helpers\ics\vcalendar_encode($vcalendar);
|
$ics = \davigil\helpers\ics\vcalendar_encode($vcalendar);
|
||||||
\error_log($ics);
|
|
||||||
return [
|
return [
|
||||||
'calendardata' => $ics,
|
'calendardata' => $ics,
|
||||||
'uri' => $objectUri,
|
'uri' => $objectUri,
|
||||||
|
|
|
||||||
|
|
@ -21,14 +21,24 @@ function make(
|
||||||
{
|
{
|
||||||
case 'ics_feed':
|
case 'ics_feed':
|
||||||
{
|
{
|
||||||
return (new class_source_ics_feed(
|
return (
|
||||||
$descriptor['data']['url'],
|
new class_source_ics_feed(
|
||||||
($descriptor['data']['condense'] ?? false)
|
$descriptor['data']['url'],
|
||||||
));
|
($descriptor['data']['lifetime'] ?? (60 * 15)),
|
||||||
|
($descriptor['data']['combine'] ?? false)
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
throw (new \Exception(\sprintf('unhandled source kind: %s', $descriptor['kind'])));
|
throw (
|
||||||
|
new \Exception(
|
||||||
|
\sprintf(
|
||||||
|
'unhandled source kind: %s',
|
||||||
|
$descriptor['kind']
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,23 +15,10 @@ interface interface_source
|
||||||
* password:(null|string),
|
* password:(null|string),
|
||||||
* >
|
* >
|
||||||
* }
|
* }
|
||||||
* @return array {
|
|
||||||
* list<
|
|
||||||
* record<
|
|
||||||
* id:string,
|
|
||||||
* title:string,
|
|
||||||
* begin:type_unix_timestamp,
|
|
||||||
* end:(null|type_unix_timestamp),
|
|
||||||
* location:(null|string),
|
|
||||||
* description:(null|string),
|
|
||||||
* tags:list<string>,
|
|
||||||
* >
|
|
||||||
* >
|
|
||||||
* }
|
|
||||||
*/
|
*/
|
||||||
public function get(
|
public function get(
|
||||||
array $parameters
|
array $parameters
|
||||||
) : array
|
) : \davigil\model\struct_calendar
|
||||||
;
|
;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ require_once('helpers/string.php');
|
||||||
require_once('helpers/cache.php');
|
require_once('helpers/cache.php');
|
||||||
require_once('helpers/pit.php');
|
require_once('helpers/pit.php');
|
||||||
require_once('helpers/ics.php');
|
require_once('helpers/ics.php');
|
||||||
|
require_once('model.php');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -21,31 +22,107 @@ class class_source_ics_feed
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
private bool $condense;
|
private ?int $lifetime;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
private bool $combine;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
string $url,
|
string $url,
|
||||||
bool $condense
|
?int $lifetime,
|
||||||
|
bool $combine
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
$this->condense = $condense;
|
$this->lifetime = $lifetime;
|
||||||
$this->cache_file = new \davigil\helpers\cache\class_cache_encoded(
|
$this->combine = $combine;
|
||||||
|
$this->cache_file = \davigil\helpers\call\convey(
|
||||||
new \davigil\helpers\cache\class_cache_file('data'),
|
new \davigil\helpers\cache\class_cache_file('data'),
|
||||||
fn($value) => \json_encode($value),
|
[
|
||||||
fn($value_encoded) => \json_decode($value_encoded, true)
|
fn($x) => new \davigil\helpers\cache\class_cache_encoded(
|
||||||
|
$x,
|
||||||
|
fn($value) => \json_encode($value),
|
||||||
|
fn($value_encoded) => \json_decode($value_encoded, true)
|
||||||
|
),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$this->cache_memory = \davigil\helpers\call\convey(
|
||||||
|
(new \davigil\helpers\cache\class_cache_memory()),
|
||||||
|
[
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
private function vcalendar_to_calendar(
|
||||||
|
\davigil\helpers\ics\struct_vcalendar $vcalendar
|
||||||
|
) : \davigil\model\struct_calendar
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
new \davigil\model\struct_calendar(
|
||||||
|
\array_map(
|
||||||
|
fn($vevent) => (new \davigil\model\struct_event(
|
||||||
|
// id
|
||||||
|
$vevent->uid,
|
||||||
|
// title
|
||||||
|
(
|
||||||
|
$this->combine
|
||||||
|
?
|
||||||
|
\sprintf(
|
||||||
|
'%s%s',
|
||||||
|
$vevent->summary,
|
||||||
|
\implode(
|
||||||
|
'',
|
||||||
|
\array_map(
|
||||||
|
fn($category) => \sprintf(' (%s)', $category),
|
||||||
|
$vevent->categories
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
:
|
||||||
|
$vevent->summary
|
||||||
|
),
|
||||||
|
// begin
|
||||||
|
\davigil\helpers\ics\datetime_to_unix_timestamp($vevent->dtstart->value),
|
||||||
|
// end
|
||||||
|
(
|
||||||
|
($vevent->dtend === null)
|
||||||
|
?
|
||||||
|
null
|
||||||
|
:
|
||||||
|
\davigil\helpers\ics\datetime_to_unix_timestamp($vevent->dtend->value)
|
||||||
|
),
|
||||||
|
// location
|
||||||
|
$vevent->location,
|
||||||
|
// description
|
||||||
|
$vevent->description,
|
||||||
|
// 'tags
|
||||||
|
(
|
||||||
|
$this->combine
|
||||||
|
?
|
||||||
|
['combined']
|
||||||
|
:
|
||||||
|
$vevent->categories
|
||||||
|
)
|
||||||
|
)),
|
||||||
|
$vcalendar->events
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
$this->cache_memory = new \davigil\helpers\cache\class_cache_memory();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
private function retrieve(
|
private function retrieve(
|
||||||
) : array
|
)
|
||||||
{
|
{
|
||||||
$client = new \Sabre\HTTP\Client();
|
$client = new \Sabre\HTTP\Client();
|
||||||
$request = new \Sabre\HTTP\Request(
|
$request = new \Sabre\HTTP\Request(
|
||||||
|
|
@ -62,52 +139,21 @@ class class_source_ics_feed
|
||||||
{
|
{
|
||||||
$ics = $response->getBody();
|
$ics = $response->getBody();
|
||||||
$vcalendar = \davigil\helpers\ics\vcalendar_decode($ics);
|
$vcalendar = \davigil\helpers\ics\vcalendar_decode($ics);
|
||||||
$data = \array_map(
|
$calendar = $this->vcalendar_to_calendar($vcalendar);
|
||||||
fn($vevent) => [
|
$calendar_raw = \davigil\model\calendar_to_raw($calendar);
|
||||||
'id' => $vevent->uid,
|
return $calendar_raw;
|
||||||
'title' => (
|
|
||||||
$this->condense
|
|
||||||
?
|
|
||||||
\sprintf(
|
|
||||||
'%s%s',
|
|
||||||
$vevent->summary,
|
|
||||||
\implode(
|
|
||||||
'',
|
|
||||||
\array_map(
|
|
||||||
fn($category) => \sprintf(' (%s)', $category),
|
|
||||||
$vevent->categories
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
:
|
|
||||||
$vevent->summary
|
|
||||||
),
|
|
||||||
'begin' => \davigil\helpers\ics\datetime_to_unix_timestamp($vevent->dtstart->value),
|
|
||||||
'end' => (
|
|
||||||
($vevent->dtend === null)
|
|
||||||
?
|
|
||||||
null
|
|
||||||
:
|
|
||||||
\davigil\helpers\ics\datetime_to_unix_timestamp($vevent->dtend->value)
|
|
||||||
),
|
|
||||||
'location' => $vevent->location,
|
|
||||||
'description' => $vevent->description,
|
|
||||||
'tags' => (
|
|
||||||
$this->condense
|
|
||||||
?
|
|
||||||
['dummy']
|
|
||||||
:
|
|
||||||
$vevent->categories
|
|
||||||
),
|
|
||||||
],
|
|
||||||
$vcalendar->events
|
|
||||||
);
|
|
||||||
return $data;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
throw (new \Exception(\sprintf('unhandled response status code: %u', $status_code)));
|
throw (
|
||||||
|
new \Exception(
|
||||||
|
\sprintf(
|
||||||
|
'unhandled response status code: %u',
|
||||||
|
$status_code
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -119,24 +165,29 @@ class class_source_ics_feed
|
||||||
*/
|
*/
|
||||||
public function get(
|
public function get(
|
||||||
array $parameters
|
array $parameters
|
||||||
) : array
|
) : \davigil\model\struct_calendar
|
||||||
{
|
{
|
||||||
$key = $this->url;
|
$key = $this->url;
|
||||||
return \davigil\helpers\cache\get(
|
$f1 = fn() => $this->retrieve();
|
||||||
|
$f2 = fn() => \davigil\helpers\cache\get(
|
||||||
|
$this->cache_file,
|
||||||
|
$key,
|
||||||
|
$f1,
|
||||||
|
[
|
||||||
|
'ttl' => $this->lifetime,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$f3 = fn() => \davigil\helpers\cache\get(
|
||||||
$this->cache_memory,
|
$this->cache_memory,
|
||||||
$key,
|
$key,
|
||||||
fn() => \davigil\helpers\cache\get(
|
$f2,
|
||||||
$this->cache_file,
|
|
||||||
$key,
|
|
||||||
fn() => $this->retrieve(),
|
|
||||||
[
|
|
||||||
'ttl' => (60 * 5),
|
|
||||||
]
|
|
||||||
),
|
|
||||||
[
|
[
|
||||||
'ttl' => null,
|
'ttl' => null,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
return \davigil\model\calendar_from_raw(
|
||||||
|
($f3)()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,12 @@ dir_source=source
|
||||||
dir_build=build
|
dir_build=build
|
||||||
name=index.php
|
name=index.php
|
||||||
|
|
||||||
|
|
||||||
|
## args
|
||||||
|
|
||||||
|
if [ $# -ge 1 ] ; then profile=$1 && shift ; else profile="" ; fi
|
||||||
|
|
||||||
|
|
||||||
## exec
|
## exec
|
||||||
|
|
||||||
mkdir -p ${dir_build}
|
mkdir -p ${dir_build}
|
||||||
|
|
@ -19,5 +25,4 @@ rm -f ${dir_build}/${name}
|
||||||
cp -r -u -v ${dir_source}/* ${dir_build}/
|
cp -r -u -v ${dir_source}/* ${dir_build}/
|
||||||
ln -s main.php ${dir_build}/index.php
|
ln -s main.php ${dir_build}/index.php
|
||||||
|
|
||||||
cp conf/example.json ${dir_build}/conf.json
|
test -z ${profile} || cp conf/${profile}.json ${dir_build}/conf.json
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue