File tree Expand file tree Collapse file tree 5 files changed +62
-4
lines changed
Expand file tree Collapse file tree 5 files changed +62
-4
lines changed Original file line number Diff line number Diff line change @@ -10,5 +10,25 @@ composer require "digitaldiff/diffbase" -w && php craft plugin/install diffbase
1010- Test the API Key by going to ``` yourdomain.com/api/info?key= ```
1111- Copy the API key to flow.diff.ch/admin and make a new entry with the API key and the site url
1212
13+ ## Cronjob
14+ ```
15+ cd /home/<CHANGEME>/public_html/<CRAFT_DIRECTORY> && composer update digitaldiff/diffbase --no-interaction --no-progress
16+ ```
17+
1318## Compatibility
14- Only works/tested with Craft CMS 5.x
19+ Only works/tested with Craft CMS 5.x
20+
21+ ## roadmap / ideas
22+ - domain check
23+ - spf check
24+ - licence infos
25+ - history (uptime)
26+ - default dashboard widgets
27+ - contact
28+ - support
29+ - urgent informations
30+ - diff.blog
31+ - start que from dashboard
32+ - empty cache from dashboard
33+ - go directly to /admin
34+ -
Original file line number Diff line number Diff line change @@ -81,7 +81,8 @@ function(RegisterTemplateRootsEvent $event) {
8181 UrlManager::class,
8282 UrlManager::EVENT_REGISTER_SITE_URL_RULES ,
8383 function (RegisterUrlRulesEvent $ event ) {
84- $ event ->rules ['api/info ' ] = 'diffbase/api/info ' ; // Maps 'api/info' to the ApiController
84+ $ event ->rules ['api/info ' ] = 'diffbase/api/info ' ; // Bestehend
85+ // $event->rules['actions/diffbase/update/composer-update'] = 'diffbase/update/composer-update'; // Neu
8586 }
8687 );
8788
Original file line number Diff line number Diff line change @@ -414,7 +414,7 @@ private function processCraftUpdates($cmsUpdate): array
414414 'package_name ' => $ cmsUpdate ->packageName ?? 'craftcms/cms ' ,
415415 'php_constraint ' => $ cmsUpdate ->phpConstraint ?? null ,
416416 'total_releases ' => count ($ cmsUpdate ->releases ?? []),
417- 'releases ' => array_slice ($ cmsUpdate ->releases ?? [], 0 , 3 )
417+ // 'releases' => array_slice($cmsUpdate->releases ?? [], 0, 3)
418418 ];
419419 }
420420
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace digitaldiff \diffbase \controllers ;
4+
5+ use Craft ;
6+ use craft \web \Controller ;
7+ use yii \web \Response ;
8+
9+ class UpdateController extends Controller
10+ {
11+ protected array |bool |int $ allowAnonymous = ['composer-update ' ];
12+ public $ enableCsrfValidation = false ;
13+
14+ public function actionComposerUpdate (): Response
15+ {
16+ $ plugin = Craft::$ app ->getPlugins ()->getPlugin ('diffbase ' );
17+ $ settings = $ plugin ->getSettings ();
18+
19+ $ providedKey = Craft::$ app ->getRequest ()->getParam ('key ' ) ??
20+ Craft::$ app ->getRequest ()->getHeaders ()->get ('X-API-Key ' );
21+
22+ if (!$ providedKey || $ providedKey !== $ settings ->apiKey ) {
23+ return $ this ->asJson (['error ' => 'Invalid API key ' ], 401 );
24+ }
25+
26+ set_time_limit (300 );
27+
28+ $ command = 'cd ' . CRAFT_BASE_PATH . ' && composer update digitaldiff/diffbase 2>&1 ' ;
29+ $ output = shell_exec ($ command );
30+
31+ return $ this ->asJson ([
32+ 'success ' => !str_contains ($ output , 'error ' ),
33+ 'output ' => $ output ,
34+ 'timestamp ' => date ('Y-m-d H:i:s ' )
35+ ]);
36+ }
37+ }
Original file line number Diff line number Diff line change 4343 Kopieren
4444 </button >
4545
46- <form method =" post" action =" {{ actionUrl(' _diffbase /cp/generate-api-key' ) }}" style =" display: inline;" >
46+ <form method =" post" action =" {{ actionUrl(' diffbase /cp/generate-api-key' ) }}" style =" display: inline;" >
4747 {{ csrfInput() }}
4848 {{ redirectInput(' _diffbase' ) }}
4949 <button type =" submit" class =" btn submit" >
You can’t perform that action at this time.
0 commit comments