2 Commits

Author SHA1 Message Date
bba8fdafb0 Smarty v4 update to v4.4.1 2024-03-06 18:39:18 +09:00
ee45bd0112 Add simple composer publisher scripts 2023-10-18 10:37:19 +09:00
12 changed files with 134 additions and 5 deletions

1
publish/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.env*

1
publish/last.published Normal file
View File

@@ -0,0 +1 @@
4.3.4

1
publish/package-download/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*.zip

88
publish/publish.sh Executable file
View File

@@ -0,0 +1,88 @@
#!/usr/bin/env bash
BASE_FOLDER=$(dirname $(readlink -f $0))"/";
PACKAGE_DOWNLOAD="${BASE_FOLDER}package-download/";
if [ ! -d "${PACKAGE_DOWNLOAD}" ]; then
mkdir "${PACKAGE_DOWNLOAD}";
fi;
VERSION=$(git tag --list | sort -V | tail -n1 | sed -e "s/^v//");
file_last_published="${BASE_FOLDER}last.published";
go_flag="$1";
if [ -z "${VERSION}" ]; then
echo "Version must be set in the form x.y.z without any leading characters";
exit;
fi;
# compare version, if different or newer, deploy
if [ -f "${file_last_published}" ]; then
LAST_PUBLISHED_VERSION=$(cat ${file_last_published});
if $(dpkg --compare-versions "${VERSION}" le "${LAST_PUBLISHED_VERSION}"); then
echo "git tag version ${VERSION} is not newer than previous published version ${LAST_PUBLISHED_VERSION}";
exit;
fi;
fi;
# read in the .env.deploy file and we must have
# GITEA_UPLOAD_FILENAME
# GITLAB_USER
# GITLAB_TOKEN
# GITLAB_URL
# GITEA_USER
# GITEA_DEPLOY_TOKEN
# GITEA_URL_DL
# GITEA_URL_PUSH
if [ ! -f "${BASE_FOLDER}.env.deploy" ]; then
echo "Deploy enviroment file .env.deploy is missing";
exit;
fi;
set -o allexport;
cd ${BASE_FOLDER};
source .env.deploy;
cd -;
set +o allexport;
if [ "${go_flag}" != "go" ]; then
echo "No go flag given";
echo "Would publish ${VERSION}";
echo "[END]";
exit;
fi;
echo "[START]";
# gitea
if [ ! -z "${GITEA_UPLOAD_FILENAME}" ] &&
[ ! -z "${GITEA_URL_DL}" ] && [ ! -z "${GITEA_URL_PUSH}" ] &&
[ ! -z "${GITEA_USER}" ] && [ ! -z "${GITEA_TOKEN}" ]; then
curl -LJO \
--output-dir "${PACKAGE_DOWNLOAD}" \
${GITEA_URL_DL}/v${VERSION}.zip;
# echo "curl -LJO \
# --output-dir "${PACKAGE_DOWNLOAD}" \
# ${GITEA_URL_DL}/v${VERSION}.zip;"
curl --user ${GITEA_USER}:${GITEA_TOKEN} \
--upload-file "${PACKAGE_DOWNLOAD}${GITEA_UPLOAD_FILENAME}-v${VERSION}.zip" \
${GITEA_URL_PUSH}?version=${VERSION};
# echo "curl --user ${GITEA_USER}:${GITEA_TOKEN} \
# --upload-file "${PACKAGE_DOWNLOAD}${GITEA_UPLOAD_FILENAME}-v${VERSION}.zip" \
# ${GITEA_URL_PUSH}?version=${VERSION};"
echo "${VERSION}" > "${file_last_published}";
else
echo "Missing either GITEA_UPLOAD_FILENAME, GITEA_URL_DL, GITEA_URL_PUSH, GITEA_USER or GITEA_TOKEN environment variable";
fi;
# gitlab
if [ ! -z "${GITLAB_URL}" ] && [ ! -z "${GITLAB_DEPLOY_TOKEN}" ]; then
curl --data tag=v${VERSION} \
--header "Deploy-Token: ${GITLAB_DEPLOY_TOKEN}" \
"${GITLAB_URL}";
curl --data branch=master \
--header "Deploy-Token: ${GITLAB_DEPLOY_TOKEN}" \
"${GITLAB_URL}";
echo "${VERSION}" > "${file_last_published}";
else
echo "Missing GITLAB_DEPLOY_TOKEN environment variable";
fi;
echo "";
echo "[DONE]";
# __END__

View File

@@ -107,7 +107,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/** /**
* smarty version * smarty version
*/ */
const SMARTY_VERSION = '4.3.0'; const SMARTY_VERSION = '4.4.1';
/** /**
* define variable scopes * define variable scopes
*/ */

View File

@@ -0,0 +1,15 @@
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsModifier
*/
function smarty_modifier_implode($values, $separator = '')
{
if (is_array($separator)) {
return implode((string) ($values ?? ''), (array) $separator);
}
return implode((string) ($separator ?? ''), (array) $values);
}

View File

@@ -0,0 +1,11 @@
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsModifierCompiler
*/
function smarty_modifiercompiler_json_encode($params) {
return 'json_encode(' . $params[0] . (isset($params[1]) ? ', (int) ' . $params[1] : '') . ')';
}

View File

@@ -22,7 +22,7 @@
function smarty_modifiercompiler_lower($params) function smarty_modifiercompiler_lower($params)
{ {
if (Smarty::$_MBSTRING) { if (Smarty::$_MBSTRING) {
return 'mb_strtolower(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; return 'mb_strtolower((string) ' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
} }
// no MBString fallback // no MBString fallback
return 'strtolower((string) ' . $params[ 0 ] . ')'; return 'strtolower((string) ' . $params[ 0 ] . ')';

View File

@@ -0,0 +1,12 @@
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsModifierCompiler
*/
function smarty_modifiercompiler_substr($params) {
return 'substr((string) ' . $params[0] . ', (int) ' . $params[1] .
(isset($params[2]) ? ', (int) ' . $params[2] : '') . ')';
}

View File

@@ -20,7 +20,7 @@
function smarty_function_escape_special_chars($string) function smarty_function_escape_special_chars($string)
{ {
if (!is_array($string)) { if (!is_array($string)) {
$string = htmlspecialchars($string, ENT_COMPAT, Smarty::$_CHARSET, false); $string = htmlspecialchars((string) $string, ENT_COMPAT, Smarty::$_CHARSET, false);
} }
return $string; return $string;
} }

View File

@@ -93,7 +93,7 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
} }
// autoescape html // autoescape html
if ($compiler->template->smarty->escape_html) { if ($compiler->template->smarty->escape_html) {
$output = "htmlspecialchars((string) {$output}, ENT_QUOTES, '" . addslashes(Smarty::$_CHARSET) . "')"; $output = "htmlspecialchars((string) ({$output}), ENT_QUOTES, '" . addslashes(Smarty::$_CHARSET) . "')";
} }
// loop over registered filters // loop over registered filters
if (!empty($compiler->template->smarty->registered_filters[ Smarty::FILTER_VARIABLE ])) { if (!empty($compiler->template->smarty->registered_filters[ Smarty::FILTER_VARIABLE ])) {

View File

@@ -94,7 +94,7 @@ class Smarty_Internal_ErrorHandler
} }
if ($this->allowUndefinedArrayKeys && preg_match( if ($this->allowUndefinedArrayKeys && preg_match(
'/^(Undefined index|Undefined array key|Trying to access array offset on value of type)/', '/^(Undefined index|Undefined array key|Trying to access array offset on)/',
$errstr $errstr
)) { )) {
return; // suppresses this error return; // suppresses this error