Compare commits

...

5 commits
main ... master

Author SHA1 Message Date
JcDenis
c700e68d20 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 10:28:09 +00:00
Jean-Christian Paul Denis
cb63feae70
Create release.yml 2024-12-01 11:27:40 +01:00
4f8b6cbfb5
code review 2023-10-25 10:19:04 +02:00
4ff82cd794
fix branch 2023-10-23 23:45:40 +02:00
a158a2e1d1
fix maxlength typo 2023-10-23 23:42:57 +02:00
8 changed files with 170 additions and 28 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,16 @@
construction 1.9.2 - 2023.10.25
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Code review
construction 1.9.1 - 2023.10.23
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Fix a typo
* Fix repository branch
construction 1.9 - 2023.10.15
===========================================================
* Require Dotclear 2.28

View file

@ -1,7 +1,7 @@
# README
[![Release](https://img.shields.io/badge/release-1.9-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/construction/releases)
![Date](https://img.shields.io/badge/date-2023.10.15-c44d58.svg)
[![Release](https://img.shields.io/badge/release-1.9.2-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/construction/releases)
![Date](https://img.shields.io/badge/date-2023.10.25-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/construction)
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/construction/src/branch/master/LICENSE)

View file

@ -18,7 +18,7 @@ $this->registerModule(
'Construction',
'Place your blog maintenance',
'Osku and contributors',
'1.9',
'1.9.2',
[
'requires' => [['core', '2.28']],
'permissions' => 'My',

View file

@ -2,10 +2,10 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="construction">
<name>Construction</name>
<version>1.9</version>
<version>1.9.2</version>
<author>Osku and contributors</author>
<desc>Place your blog maintenance</desc>
<file>https://git.dotclear.watch/JcDenis/construction/releases/download/v1.9/plugin-construction.zip</file>
<file>https://github.com/JcDenis/construction/releases/download/v1.9.2/plugin-construction.zip</file>
<da:dcmin>2.28</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/construction/src/branch/master/README.md</da:details>
<da:support>https://git.dotclear.watch/JcDenis/construction/issues</da:support>

View file

@ -29,7 +29,7 @@ class Backend extends Process
return false;
}
My::addBackendMenuItem(App::backend()->menus()::MENU_PLUGINS, [], '(&.*)?$', My::settings()->get('flag') ? 'construction-blog' : '');
My::addBackendMenuItem();
App::behavior()->addBehaviors([
'adminPageHTMLHead' => function (): void {

View file

@ -32,27 +32,24 @@ class Frontend extends Process
}
App::behavior()->addBehavior('publicBeforeDocumentV2', function (): void {
// nullsafe PHP < 8.0
if (!App::blog()->isDefined()) {
return;
}
if (!My::settings()->get('flag')) {
return;
}
$tplset = App::themes()->moduleInfo(App::blog()->settings()->get('system')->get('theme'), 'tplset');
if (!empty($tplset) && is_dir(implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]))) {
App::frontend()->template()->setPath(App::frontend()->template()->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]));
} else {
App::frontend()->template()->setPath(App::frontend()->template()->getPath(), implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', App::config()->defaultTplset()]));
$tplset = App::themes()->getDefine(App::blog()->settings()->get('system')->get('theme'))->get('tplset');
if (empty($tplset) || !is_dir(implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]))) {
$tplset = App::config()->defaultTplset();
}
App::frontend()->template()->appendPath(implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]));
$all_allowed_ip = json_decode((string) My::settings()->get('allowed_ip'), true);
if (!is_array($all_allowed_ip)) {
$all_allowed_ip = [];
}
$extra_urls = json_decode((string) My::settings()->get('extra_urls'), true);
if (!is_array($extra_urls)) {
$extra_urls = [];
}
if (!in_array(Http::realIP(), $all_allowed_ip)) {
App::url()->registerDefault(function (?string $args): void {
App::url()->type = 'default';

View file

@ -48,11 +48,6 @@ class Manage extends Process
return false;
}
// nullsafe PHP < 8.0
if (!App::blog()->isDefined()) {
return false;
}
$s = My::settings();
if (!empty($_POST['saveconfig'])) {
@ -93,11 +88,6 @@ class Manage extends Process
return;
}
// nullsafe PHP < 8.0
if (!App::blog()->isDefined()) {
return;
}
$s = My::settings();
$editor = App::auth()->getOption('editor');
$nb_rows = count(json_decode($s->get('allowed_ip'), true));
@ -136,14 +126,14 @@ class Manage extends Process
(new Note())->class('form-note')->text(sprintf(__('Your IP is <strong>%s</strong> - the allowed IP can view the blog normally.'), (string) Http::realIP())),
(new Para())->class('area')->items([
(new Label(__('Extra allowed URL types:'), Label::OUTSIDE_LABEL_BEFORE))->for('construction_extra_urls'),
(new Input('construction_extra_urls'))->size(20)->maxlenght(255)->class('maximal')->value(Html::escapeHTML(implode(',', json_decode($s->get('extra_urls'), true)))),
(new Input('construction_extra_urls'))->size(20)->maxlength(255)->class('maximal')->value(Html::escapeHTML(implode(',', json_decode($s->get('extra_urls'), true)))),
]),
]),
(new Div())->class('fieldset')->items([
(new Text('h4', __('Presentation'))),
(new Para())->class('area')->items([
(new Label(__('Title:'), Label::OUTSIDE_LABEL_BEFORE))->for('construction_title'),
(new Input('construction_title'))->size(20)->maxlenght(255)->class('maximal')->value(Html::escapeHTML($s->get('title'))),
(new Input('construction_title'))->size(20)->maxlength(255)->class('maximal')->value(Html::escapeHTML($s->get('title'))),
]),
(new Para())->class('area')->items([
(new Label(__('Message:'), Label::OUTSIDE_LABEL_BEFORE))->for('construction_message'),