Skip to content

Commit

Permalink
Add build configuration to .readthedocs.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
panlatent committed Jun 22, 2024
1 parent d3d82e8 commit f453497
Show file tree
Hide file tree
Showing 71 changed files with 1,908 additions and 435 deletions.
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Do not export those files in the Composer archive
/.github/ export-ignore
/docs/ export-ignore
/tests/ export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.readthedocs.yml export-ignore
/CHANGELOG.md export-ignore
/codeception.yml export-ignore
/mkdocs.yml export-ignore
5 changes: 5 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
# Required
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.12"

# Build documentation in the docs/ directory with Sphinx
# sphinx:
# configuration: docs/conf.py
Expand Down
2 changes: 1 addition & 1 deletion UPGRADE-1.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This is a 0.x - 1.0 update note. This article assumes that you have already used

## Documentation Promise

The new version will promise a relatively complete documentation.py
The new version will promise a relatively complete documentation

## Schedule

Expand Down
2 changes: 1 addition & 1 deletion abstract/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@

abstract class Action extends SavableComponent implements ActionInterface
{

public ?string $uid = null;
}
34 changes: 34 additions & 0 deletions abstract/ConditionAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace panlatent\craft\actions\abstract;

class ConditionAction extends Action
{
public function __construct(private readonly ActionInterface $action, $config = [])
{
parent::__construct($config);
}

public function getConditions(): array
{
return [];
}

public function getAction(): ActionInterface
{
return $this->action;
}

public function validateConditions(): bool
{
return true;
}

public function execute(ContextInterface $context): bool
{



return $this->action->execute($context);
}
}
4 changes: 1 addition & 3 deletions abstract/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace panlatent\craft\actions\abstract;

use yii\base\Component;

abstract class Context extends Component implements ContextInterface
abstract class Context implements ContextInterface
{

}
3 changes: 3 additions & 0 deletions abstract/ContextInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

namespace panlatent\craft\actions\abstract;

use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;

interface ContextInterface
{
public function getContainer(): ContainerInterface;

public function getErrors(): array;

public function getLogger(): LoggerInterface;
Expand Down
8 changes: 8 additions & 0 deletions abstract/RunnerInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace panlatent\craft\actions\abstract;

interface RunnerInterface
{
public static function run(): void;
}
1 change: 0 additions & 1 deletion abstract/TriggerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@

interface TriggerInterface
{
public function trigger(): bool;
}
8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
],
"homepage": "https://github.com/panlatent/schedule",
"support": {
"docs": "https://docs.panlatent.com/schedule",
"docs": "https://docs.panlatent.com/projects/schedule",
"issues": "https://github.com/panlatent/schedule/issues"
},
"license": "MIT",
"license": "proprietary",
"authors": [
{
"name": "[email protected]",
Expand All @@ -31,9 +31,11 @@
"nesbot/carbon": "^1.22 || ^2.10 || ^3.0",
"panlatent/craft-action-abstract": "@dev",
"panlatent/cron-expression-descriptor": "^1.1",
"psr/container": "^1.0 || ^2.0",
"psr/log": "^1.0 || ^2.0 || ^3.0",
"react/event-loop": "^1.5",
"symfony/process": "^6.0 || ^7.0"
"symfony/process": "^6.0 || ^7.0",
"alexanderpas/http-enum": "^1.0"
},
"replace": {
"panlatent/craft-action-abstract": "self.version"
Expand Down
10 changes: 10 additions & 0 deletions config/schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@

return [
'schedules' => [
Schedule::closure(static fn() => true)->minute(),

Schedule::request('')->hourly()->onSuccess(function() {

}),

Schedule::exec('ls')->hourly()->onSuccess(function() {

}),

Schedule::console('db/backup')->hourly()->onSuccess(function() {

}),
],

];
Binary file added docs/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/installation-setup.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Installation and Setup



You can install Schedule via the plugin store, or through Composer.

## Craft Plugin Store
Expand Down
3 changes: 2 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
mkdocs-material
mkdocs-material
mkdocs-git-revision-date-localized-plugin
19 changes: 19 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,23 @@ theme:
- content.code.copy
- navigation.instant
- navigation.instant.progress
- navigation.footer
- navigation.path
- navigation.top
- toc.integrate
- search.suggest
- search.highlight
logo: assets/logo.png
icon:
repo: fontawesome/brands/github

copyright: Copyright © 2024 Panlatent

extra:
generator: false
social:
- icon: fontawesome/brands/github
link: https://github.com/panlatent
version:
provider: mike
# alternate:
Expand Down Expand Up @@ -90,6 +103,11 @@ markdown_extensions:
custom_checkbox: true
- pymdownx.tilde

plugins:
- search
- git-revision-date-localized:
type: timeago

nav:
- 'introduction.md'
- 'Getting Started':
Expand All @@ -103,4 +121,5 @@ nav:
- About: about.md

repo_url: https://github.com/panlatent/schedule
repo_name: panlatent/schedule
edit_uri: edit/main/docs
18 changes: 16 additions & 2 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use craft\web\UrlManager;
use panlatent\schedule\console\SchedulesController;
use panlatent\schedule\models\Settings;
use panlatent\schedule\services\Actions;
use panlatent\schedule\services\Logs;
use panlatent\schedule\services\Schedules;
use panlatent\schedule\services\Timers;
Expand All @@ -33,14 +34,15 @@
*
* @package panlatent\schedule
* @method Settings getSettings()
* @property-read Actions $actions
* @property-read Schedules $schedules
* @property-read Timers $timers
* @property-read Settings $settings
* @author Panlatent <[email protected]>
*/
class Plugin extends \craft\base\Plugin
{
public const EDITION_STANDARD = 'standard';
public const EDITION_LITE = 'lite';
public const EDITION_PRO = 'pro';

// Properties
Expand All @@ -63,6 +65,7 @@ public static function config(): array
{
return [
'components' => [
'actions' => Actions::class,
'schedules' => Schedules::class,
'timers' => Timers::class,
'logs' => Logs::class,
Expand All @@ -73,7 +76,7 @@ public static function config(): array
public static function editions(): array
{
return [
self::EDITION_STANDARD,
self::EDITION_LITE,
self::EDITION_PRO,
];
}
Expand All @@ -94,6 +97,10 @@ public function init(): void
$this->_registerProjectConfigEvents();
$this->_registerUserPermissions();
$this->_registerVariables();

if ($this->settings->enabledWebCron) {
$this->_registerWebCron();
}
});
}

Expand Down Expand Up @@ -229,4 +236,11 @@ private function _registerVariables(): void
$variable->attachBehavior('schedule', CraftVariableBehavior::class);
});
}

private function _registerWebCron()
{
Event::on(UrlManager::class, UrlManager::EVENT_REGISTER_SITE_URL_RULES, function (RegisterUrlRulesEvent $event) {
$event->rules[$this->settings->endpoint] = 'schedule/web-cron/trigger';
});
}
}
6 changes: 2 additions & 4 deletions src/Scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,8 @@ public function runSchedule(Schedule $schedule): bool
*/
public function getTriggerTimers(): array
{
$timers = Plugin::getInstance()->timers->getActiveTimers();
$now = new \DateTime('now', $this->timezone);
return array_filter($timers, static function (TimerInterface $timer) use($now) {
return (new CronExpression($timer->getCronExpression()))->isDue($now);
return array_filter(Plugin::getInstance()->timers->getActiveTimers(), static function (TimerInterface $timer) {
return $timer->isDue();
});
}

Expand Down
17 changes: 17 additions & 0 deletions src/actions/Closure.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace panlatent\schedule\actions;

use panlatent\craft\actions\abstract\Action;
use panlatent\craft\actions\abstract\ContextInterface;

class Closure extends Action
{
public ?\Closure $closure = null;

public function execute(ContextInterface $context): bool
{
return true;
}

}
Loading

0 comments on commit f453497

Please sign in to comment.