Compare commits

..

No commits in common. "master" and "v2.3" have entirely different histories.
master ... v2.3

9 changed files with 109 additions and 249 deletions

View file

@ -1,142 +0,0 @@
name: Release package
on:
push:
workflow_dispatch:
env:
DC_TYPE: plugin
DC_MIN: 2.32
# required to set secrets in
# https://github.com/xxx/xxx/settings/secrets/actions
# TELEGRAM_ID, TELEGRAM_TOKEN
jobs:
check_release:
if: (contains(github.event.head_commit.message, 'release') || (github.event_name != 'push'))
runs-on: ubuntu-latest
outputs:
version: ${{ steps.dotclear.outputs.version }}
dcmin: ${{ steps.dotclear.outputs.dcmin }}
exists: ${{ steps.repository.outputs.release-exists }}
steps:
- name: Checkout repository master branch
uses: actions/checkout@master
# Parser from https://github.com/franck-paul
- name: Run PHP code
id: dotclear
shell: php {0}
run: |
<?php
$version = '';
$dcmin = '${{ env.DC_MIN }}';
$df = file_get_contents('./_define.php');
if (preg_match('/registerModule\((.*?),(.*?)[\'\"],(.*?)[\'\"],(.*?)[\'\"](.*?)[\'\"](.*?)(,.*)\)/s',$df,$matches)) {
if (isset($matches[5])) {
$version = $matches[5];
if (isset($matches[7])) {
$str = $matches[7];
if (preg_match('/\[(.*?)[\'\"]core[\'\"](.*?),(.*?)[\'\"](.*?)[\'\"](.*?)\]/s',$str,$submatches)) {
$dcmin = $submatches[4];
}
}
}
}
file_put_contents(getenv('GITHUB_OUTPUT'), "version=$version\n", FILE_APPEND);
file_put_contents(getenv('GITHUB_OUTPUT'), "dcmin=$dcmin\n", FILE_APPEND);
- name: Check repository releases
id: repository
uses: insightsengineering/release-existence-action@v1.0.0
with:
release-tag: 'v${{ steps.dotclear.outputs.version }}'
do_release:
needs: check_release
if: needs.check_release.outputs.exists == 'false'
runs-on: ubuntu-latest
steps:
- name: Checkout repository master branch
uses: actions/checkout@master
- name: Get repository name
id: repository
uses: MariachiBear/get-repo-name-action@v1.1.0
with:
with-owner: 'false'
- name: Get download URL
id: download
run: |
fulltag=${{ github.ref_name }}
echo download-url="https://github.com/${{ github.repository }}/releases/download/v${{ needs.check_release.outputs.version }}/${{ env.DC_TYPE }}-${{ steps.repository.outputs.repository-name }}.zip" >> $GITHUB_OUTPUT
# Parser from https://github.com/franck-paul
- name: Read dcstore
id: readstore
shell: php {0}
run: |
<?php
if (file_exists('dcstore.xml')) {
$ds = file_get_contents('dcstore.xml');
if ($ds) {
$ds = preg_replace('/<version>(.*?)<\/version>/s',"<version>${{ needs.check_release.outputs.version }}</version>",$ds);
$ds = preg_replace('/<file>(.*?)<\/file>/s',"<file>${{ steps.download.outputs.download-url }}</file>",$ds);
$ds = preg_replace('/<da:dcmin>(.*?)<\/da:dcmin>/s',"<da:dcmin>${{ needs.check_release.outputs.dcmin }}</da:dcmin>",$ds);
if ($ds) {
file_put_contents('dcstore.xml',$ds);
}
}
}
- name: Write dcstore
id: writestore
shell: bash
run: |
test=$(git diff --name-only -- dcstore.xml)
if [[ "$test" != "" ]]; then
echo "dcstore.xml modified, need to be commit"
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
git add dcstore.xml
git commit -m "Update dcstore.xml"
git push
else
echo "dcstore.xml not modified"
fi
- name: Create archive
id: writearchive
uses: thedoctor0/zip-release@0.7.6
with:
type: 'zip'
directory: ..
path: '${{ steps.repository.outputs.repository-name }}'
filename: '${{ env.DC_TYPE }}-${{ steps.repository.outputs.repository-name }}.zip'
exclusions: '*.git* /*node_modules/* .editorconfig'
- name: Create release with archive
id: writerelease
uses: ncipollo/release-action@v1.14.0
with:
artifacts: '../${{ env.DC_TYPE }}-${{ steps.repository.outputs.repository-name }}.zip'
token: ${{ secrets.GITHUB_TOKEN }}
commit: master
draft: false
prerelease: false
generateReleaseNotes: true
name: ${{ steps.repository.outputs.repository-name }} ${{ needs.check_release.outputs.version }}
tag: 'v${{ needs.check_release.outputs.version }}'
- name: Send Telegram Message Ok
uses: appleboy/telegram-action@v1.0.0
with:
to: ${{ secrets.TELEGRAM_ID }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: markdown
message: |
__Github workflow run__
- Trigger: ${{ github.event_name }}
- Release: ${{ steps.repository.outputs.repository-name }} ${{ needs.check_release.outputs.version }}
- Download URL: ${{ steps.download.outputs.download-url }}

View file

@ -1,15 +1,3 @@
countdown 2.4.1 - 2023.10.123
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Fix repository branch
countdown 2.4 - 2023.10.15
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Upgrade to Dotclear 2.28
countdown 2.3 - 2023.08.06 countdown 2.3 - 2023.08.06
=========================================================== ===========================================================
* Require Dotclear 2.27 * Require Dotclear 2.27

View file

@ -1,22 +1,25 @@
# README # README
[![Release](https://img.shields.io/badge/release-2.4.1-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/countdown/releases) [![Release](https://img.shields.io/github/v/release/JcDenis/countdown)](https://git.dotclear.watch/JcDenis/countdown/releases)
![Date](https://img.shields.io/badge/date-2023.10.23-c44d58.svg) [![Date](https://img.shields.io/github/release-date/JcDenis/countdown)](https://git.dotclear.watch/JcDenis/countdown/releases)
[![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download) [![Issues](https://img.shields.io/github/issues/JcDenis/countdown)](https://git.dotclear.watch/JcDenis/countdown/issues)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/countdown) [![Dotclear](https://img.shields.io/badge/dotclear-v2.27-blue.svg)](https://fr.dotclear.org/download)
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/countdown/src/branch/master/LICENSE) [![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/countdown)
[![License](https://img.shields.io/github/license/JcDenis/countdown)](https://git.dotclear.watch/JcDenis/countdown/blob/master/LICENSE)
## ABOUT ## WHAT IS COUNTDOWN ?
_countdown_ is a plugin for the open-source web publishing software called [Dotclear](https://www.dotclear.org). _countdown_ is a plugin for the open-source
web publishing software called Dotclear.
> Add widget showing a countdown since/from a predefined date. It adds widget showing a countdown since/from a predefined date.
## REQUIREMENTS ## REQUIREMENTS
* Dotclear 2.28 _countdown_ requires:
* PHP 8.1
* Dotclear permissions to manage widgets * permissions to manage widgets
* Dotclear 2.27
## USAGE ## USAGE
@ -28,23 +31,22 @@ It uses jquery for dynamic countdown.
## LINKS ## LINKS
* [License](https://git.dotclear.watch/JcDenis/countdown/src/branch/master/LICENSE) * License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
* [Packages & details](https://git.dotclear.watch/JcDenis/countdown/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/countdown)) * Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/countdown) or [GitHub Page](https://github.com/JcDenis/countdown)
* [Sources & contributions](https://git.dotclear.watch/JcDenis/countdown) (or on [GitHub](https://github.com/JcDenis/countdown)) * Packages & details : [Gitea Page](https://git.dotclear.watch/JcDenis/countdown/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/countdown)
* [Issues & security](https://git.dotclear.watch/JcDenis/countdown/issues) (or on [GitHub](https://github.com/JcDenis/countdown/issues)) * Discuss & help : [Dotclear forum](https://forum.dotclear.org/viewforum.php?id=16)
* [Discuss & help](https://forum.dotclear.org/viewforum.php?id=16)
## CONTRIBUTORS ## CONTRIBUTORS
* [Moe](http://gniark.net/) (author) * [Moe](http://gniark.net/) (author)
* Pierre Van Glabeke * Pierre Van Glabeke
* Jean-Christian Denis (latest) * Jean-Christian Denis
You are welcome to contribute to this code. You are welcome to contribute to this code.
## JQUERY PLUGIN ## JQUERY PLUGIN
Dynamic display uses plugin jQuery Countdown; See: Dynamic display uses plugin jQuery Countdown; See:
* [Plugin](http://keith-wood.name/countdown.html) * [Plugin](http://keith-wood.name/countdown.html)
* [Formats](http://keith-wood.name/countdownRef.html#format) * [Formats](http://keith-wood.name/countdownRef.html#format)
* [Display](http://keith-wood.name/countdownRef.html#layout) * [Display](http://keith-wood.name/countdownRef.html#layout)

View file

@ -1,30 +1,32 @@
<?php <?php
/** /**
* @file * @brief countdown, a plugin for Dotclear 2
* @brief The plugin countdown definition
* @ingroup countdown
* *
* @defgroup countdown Plugin countdown. * @package Dotclear
* @subpackage Plugin
* *
* Countdown and stopwatch. * @author Moe (http://gniark.net/) and contributors
* *
* @author Moe (author) * @copyright Jean-Christian Denis
* @author Jean-Christian Denis (latest) * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
declare(strict_types=1); if (!defined('DC_RC_PATH')) {
return;
}
$this->registerModule( $this->registerModule(
'CountDown', 'CountDown',
'Countdown and stopwatch', 'Countdown and stopwatch',
'Moe (http://gniark.net/) and contributors', 'Moe (http://gniark.net/) and contributors',
'2.4.1', '2.3',
[ [
'requires' => [['core', '2.28']], 'requires' => [['core', '2.27']],
'permissions' => 'My', 'permissions' => dcCore::app()->auth->makePermissions([
'type' => 'plugin', dcCore::app()->auth::PERMISSION_ADMIN,
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues', ]),
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md', 'type' => 'plugin',
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml', 'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
] ]
); );

View file

@ -2,11 +2,11 @@
<modules xmlns:da="http://dotaddict.org/da/"> <modules xmlns:da="http://dotaddict.org/da/">
<module id="countdown"> <module id="countdown">
<name>CountDown</name> <name>CountDown</name>
<version>2.4.1</version> <version>2.3</version>
<author>Moe (http://gniark.net/) and contributors</author> <author>Moe (http://gniark.net/) and contributors</author>
<desc>Countdown and stopwatch</desc> <desc>Countdown and stopwatch</desc>
<file>https://github.com/JcDenis/countdown/releases/download/v2.4.1/plugin-countdown.zip</file> <file>https://gitea.dotclear.watch/JcDenis/countdown/releases/download/v2.3/plugin-countdown.zip</file>
<da:dcmin>2.28</da:dcmin> <da:dcmin>2.27</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/countdown/src/branch/master/README.md</da:details> <da:details>https://git.dotclear.watch/JcDenis/countdown/src/branch/master/README.md</da:details>
<da:support>https://git.dotclear.watch/JcDenis/countdown/issues</da:support> <da:support>https://git.dotclear.watch/JcDenis/countdown/issues</da:support>
</module> </module>

View file

@ -1,20 +1,22 @@
<?php <?php
/**
* @brief countdown, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Moe (http://gniark.net/) and contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1); declare(strict_types=1);
namespace Dotclear\Plugin\countdown; namespace Dotclear\Plugin\countdown;
use Dotclear\App; use dcCore;
use Dotclear\Core\Process; use Dotclear\Core\Process;
/**
* @brief countdown backend class.
* @ingroup countdown
*
* @author Moe (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Backend extends Process class Backend extends Process
{ {
public static function init(): bool public static function init(): bool
@ -28,7 +30,7 @@ class Backend extends Process
return false; return false;
} }
App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...)); dcCore::app()->addBehavior('initWidgets', [Widgets::class, 'initWidgets']);
return true; return true;
} }

View file

@ -1,20 +1,22 @@
<?php <?php
/**
* @brief countdown, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Moe (http://gniark.net/) and contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1); declare(strict_types=1);
namespace Dotclear\Plugin\countdown; namespace Dotclear\Plugin\countdown;
use Dotclear\App; use dcCore;
use Dotclear\Core\Process; use Dotclear\Core\Process;
/**
* @brief countdown frontend class.
* @ingroup countdown
*
* @author Moe (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Frontend extends Process class Frontend extends Process
{ {
public static function init(): bool public static function init(): bool
@ -28,7 +30,7 @@ class Frontend extends Process
return false; return false;
} }
App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...)); dcCore::app()->addBehavior('initWidgets', [Widgets::class, 'initWidgets']);
return true; return true;
} }

View file

@ -1,5 +1,15 @@
<?php <?php
/**
* @brief countdown, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Moe (http://gniark.net/) and contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1); declare(strict_types=1);
namespace Dotclear\Plugin\countdown; namespace Dotclear\Plugin\countdown;
@ -7,14 +17,8 @@ namespace Dotclear\Plugin\countdown;
use Dotclear\Module\MyPlugin; use Dotclear\Module\MyPlugin;
/** /**
* @brief countdown My helper. * This module definitions.
* @ingroup countdown
*
* @author Moe (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
class My extends MyPlugin class My extends MyPlugin
{ {
// Use default permissions
} }

View file

@ -1,32 +1,34 @@
<?php <?php
/**
* @brief countdown, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Moe (http://gniark.net/) and contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
declare(strict_types=1); declare(strict_types=1);
namespace Dotclear\Plugin\countdown; namespace Dotclear\Plugin\countdown;
use Dotclear\App; use dcCore;
use Dotclear\Helper\Date; use Dotclear\Helper\Date;
use Dotclear\Helper\Html\Html; use Dotclear\Helper\Html\Html;
use Dotclear\Plugin\widgets\WidgetsStack; use Dotclear\Plugin\widgets\WidgetsStack;
use Dotclear\Plugin\widgets\WidgetsElement; use Dotclear\Plugin\widgets\WidgetsElement;
/**
* @brief countdown widgets class.
* @ingroup countdown
*
* @author Moe (author)
* @author Jean-Christian Denis (latest)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Widgets class Widgets
{ {
public static function initWidgets(WidgetsStack $w): void public static function initWidgets(WidgetsStack $w): void
{ {
if (!App::blog()->isDefined()) { if (is_null(dcCore::app()->blog)) {
return; return;
} }
$tz = App::blog()->settings()->get('system')->get('blog_timezone'); $tz = dcCore::app()->blog->settings->get('system')->get('blog_timezone');
$array_year = $array_month = $array_day = $array_hour = []; $array_year = $array_month = $array_day = $array_hour = [];
$array_minute = $array_number_of_times = []; $array_minute = $array_number_of_times = [];
@ -57,7 +59,7 @@ class Widgets
$w->create( $w->create(
'CountDown', 'CountDown',
__('Countdown'), __('Countdown'),
self::parseWidget(...), [self::class, 'parseWidget'],
null, null,
__('A countdown to a future date or stopwatch to a past date') __('A countdown to a future date or stopwatch to a past date')
) )
@ -143,15 +145,15 @@ class Widgets
public static function parseWidget(WidgetsElement $w): string public static function parseWidget(WidgetsElement $w): string
{ {
if (!App::blog()->isDefined() if (is_null(dcCore::app()->blog)
|| $w->__get('offline') || $w->__get('offline')
|| !$w->checkHomeOnly(App::url()->type) || !$w->checkHomeOnly(dcCore::app()->url->type)
) { ) {
return ''; return '';
} }
# get local time # get local time
$local_time = Date::addTimeZone(App::blog()->settings()->get('system')->get('blog_timezone')); $local_time = Date::addTimeZone(dcCore::app()->blog->settings->get('system')->get('blog_timezone'));
$ts = mktime((int) $w->hour, (int) $w->minute, (int) $w->second, (int) $w->month, (int) $w->day, (int) $w->year); $ts = mktime((int) $w->hour, (int) $w->minute, (int) $w->second, (int) $w->month, (int) $w->day, (int) $w->year);
# get difference # get difference
@ -195,7 +197,7 @@ class Widgets
$str = implode('', $times); $str = implode('', $times);
} }
if (!$w->dynamic) { if (!$w->dynamic || is_null(dcCore::app()->ctx)) {
$res = ($w->title ? $w->renderTitle(Html::escapeHTML($w->title)) : '') . $res = ($w->title ? $w->renderTitle(Html::escapeHTML($w->title)) : '') .
'<p>' . $text . '<span>' . $str . '</span></p>'; '<p>' . $text . '<span>' . $str . '</span></p>';
@ -203,11 +205,11 @@ class Widgets
} }
# dynamic display with Countdown for jQuery # dynamic display with Countdown for jQuery
if (!is_numeric(App::frontend()->context()->__get('countdown'))) { if (!is_numeric(dcCore::app()->ctx->__get('countdown'))) {
App::frontend()->context()->__set('countdown', 0); dcCore::app()->ctx->__set('countdown', 0);
} }
$id = (int) App::frontend()->context()->__get('countdown'); $id = (int) dcCore::app()->ctx->__get('countdown');
App::frontend()->context()->__set('countdown', $id + 1); dcCore::app()->ctx->__set('countdown', $id + 1);
$script = ''; $script = '';
@ -216,7 +218,7 @@ class Widgets
My::jsLoad('jquery.plugin.min.js') . My::jsLoad('jquery.plugin.min.js') .
My::jsLoad('jquery.countdown.min.js'); My::jsLoad('jquery.countdown.min.js');
$l10n_file = 'jquery.countdown-' . App::blog()->settings()->get('system')->get('lang') . '.js'; $l10n_file = 'jquery.countdown-' . dcCore::app()->blog->settings->get('system')->get('lang') . '.js';
if (file_exists(__DIR__ . '/../js/' . $l10n_file)) { if (file_exists(__DIR__ . '/../js/' . $l10n_file)) {
$script .= My::jsLoad($l10n_file); $script .= My::jsLoad($l10n_file);
} }