Compare commits

...

6 commits
v2.3 ... master

Author SHA1 Message Date
JcDenis
c9d77b1637 Update dcstore.xml
Some checks failed
Release package / check_release (push) Has been cancelled
Release package / do_release (push) Has been cancelled
2024-12-01 22:15:30 +00:00
Jean-Christian Paul Denis
ec15115ef5
Create release.yml 2024-12-01 23:14:59 +01:00
b5993081a8
fix repo branch 2023-10-24 00:15:01 +02:00
9d8aa28988
upgrade to Dotclear 2.28 2023-10-15 22:15:37 +02:00
b6ac8bdba8
fix ZIP URL 2023-08-07 23:17:32 +02:00
b6f55526ea
use static badge 2023-08-07 01:02:00 +02:00
9 changed files with 249 additions and 109 deletions

142
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,142 @@
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,3 +1,15 @@
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
===========================================================
* Require Dotclear 2.27

View file

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

View file

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

View file

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

View file

@ -1,22 +1,20 @@
<?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);
namespace Dotclear\Plugin\countdown;
use dcCore;
use Dotclear\App;
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
{
public static function init(): bool
@ -30,7 +28,7 @@ class Backend extends Process
return false;
}
dcCore::app()->addBehavior('initWidgets', [Widgets::class, 'initWidgets']);
App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...));
return true;
}

View file

@ -1,22 +1,20 @@
<?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);
namespace Dotclear\Plugin\countdown;
use dcCore;
use Dotclear\App;
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
{
public static function init(): bool
@ -30,7 +28,7 @@ class Frontend extends Process
return false;
}
dcCore::app()->addBehavior('initWidgets', [Widgets::class, 'initWidgets']);
App::behavior()->addBehavior('initWidgets', Widgets::initWidgets(...));
return true;
}

View file

@ -1,15 +1,5 @@
<?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);
namespace Dotclear\Plugin\countdown;
@ -17,8 +7,14 @@ namespace Dotclear\Plugin\countdown;
use Dotclear\Module\MyPlugin;
/**
* This module definitions.
* @brief countdown My helper.
* @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
{
// Use default permissions
}

View file

@ -1,34 +1,32 @@
<?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);
namespace Dotclear\Plugin\countdown;
use dcCore;
use Dotclear\App;
use Dotclear\Helper\Date;
use Dotclear\Helper\Html\Html;
use Dotclear\Plugin\widgets\WidgetsStack;
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
{
public static function initWidgets(WidgetsStack $w): void
{
if (is_null(dcCore::app()->blog)) {
if (!App::blog()->isDefined()) {
return;
}
$tz = dcCore::app()->blog->settings->get('system')->get('blog_timezone');
$tz = App::blog()->settings()->get('system')->get('blog_timezone');
$array_year = $array_month = $array_day = $array_hour = [];
$array_minute = $array_number_of_times = [];
@ -59,7 +57,7 @@ class Widgets
$w->create(
'CountDown',
__('Countdown'),
[self::class, 'parseWidget'],
self::parseWidget(...),
null,
__('A countdown to a future date or stopwatch to a past date')
)
@ -145,15 +143,15 @@ class Widgets
public static function parseWidget(WidgetsElement $w): string
{
if (is_null(dcCore::app()->blog)
if (!App::blog()->isDefined()
|| $w->__get('offline')
|| !$w->checkHomeOnly(dcCore::app()->url->type)
|| !$w->checkHomeOnly(App::url()->type)
) {
return '';
}
# get local time
$local_time = Date::addTimeZone(dcCore::app()->blog->settings->get('system')->get('blog_timezone'));
$local_time = Date::addTimeZone(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);
# get difference
@ -197,7 +195,7 @@ class Widgets
$str = implode('', $times);
}
if (!$w->dynamic || is_null(dcCore::app()->ctx)) {
if (!$w->dynamic) {
$res = ($w->title ? $w->renderTitle(Html::escapeHTML($w->title)) : '') .
'<p>' . $text . '<span>' . $str . '</span></p>';
@ -205,11 +203,11 @@ class Widgets
}
# dynamic display with Countdown for jQuery
if (!is_numeric(dcCore::app()->ctx->__get('countdown'))) {
dcCore::app()->ctx->__set('countdown', 0);
if (!is_numeric(App::frontend()->context()->__get('countdown'))) {
App::frontend()->context()->__set('countdown', 0);
}
$id = (int) dcCore::app()->ctx->__get('countdown');
dcCore::app()->ctx->__set('countdown', $id + 1);
$id = (int) App::frontend()->context()->__get('countdown');
App::frontend()->context()->__set('countdown', $id + 1);
$script = '';
@ -218,7 +216,7 @@ class Widgets
My::jsLoad('jquery.plugin.min.js') .
My::jsLoad('jquery.countdown.min.js');
$l10n_file = 'jquery.countdown-' . dcCore::app()->blog->settings->get('system')->get('lang') . '.js';
$l10n_file = 'jquery.countdown-' . App::blog()->settings()->get('system')->get('lang') . '.js';
if (file_exists(__DIR__ . '/../js/' . $l10n_file)) {
$script .= My::jsLoad($l10n_file);
}