Skip to content

Commit

Permalink
Adds constants to LWT and its API that declare their version.
Browse files Browse the repository at this point in the history
See issue #163 for details.
  • Loading branch information
HugoFara committed Dec 29, 2023
1 parent b56b7c2 commit 897235b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
14 changes: 12 additions & 2 deletions api.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
require_once __DIR__ . '/inc/ajax_edit_impr_text.php';


/**
* @var string Version of this current LWT API.
*/
define('LWT_API_VERSION', "0.1.1");

/**
* @var string Date of the last released change of the LWT API.
*/
define('LWT_API_RELEASE_DATE', "2023-12-29");

/**
* Send JSON response and exit.
*
Expand Down Expand Up @@ -126,8 +136,8 @@ function endpoint_exits($method, $requestUri)
function rest_api_version($get_req): array
{
return array(
"version" => "0.1.1",
"release_date" => "2023-12-29"
"version" => LWT_API_VERSION,
"release_date" => LWT_API_RELEASE_DATE
);
}

Expand Down
3 changes: 3 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ ones are marked like "v1.0.0-fork".
### Added

* `unloadformcheck.js` no declares a new object `lwt_form_check` that contains all the functions needed.
* New globals ([#163](https://github.com/HugoFara/lwt/issues/163)):
* On `inc/kernel_utility.php`: `LWT_APP_VERSION` and `LWT_RELEASE_DATE`.
* On `api.php`: `LWT_API_VERSION` and `LWT_API_RELEASE_DATE`.

### Fixed

Expand Down
8 changes: 7 additions & 1 deletion docs/info.html
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ <h2 name="current" id="current">
</h2>

<p>
The current version is 2.9.1-fork (December 29 2023).
The current version is 2.9.1-fork (December 29, 2023).
<br>
<a href="#CHANGELOG">View the Changelog.</a>
</p>
Expand Down Expand Up @@ -2187,6 +2187,12 @@ <h4>Added</h4>
<ul>
<li>
<code>unloadformcheck.js</code> no declares a new object <code>lwt_form_check</code> that contains all the functions needed.</li>
<li>New globals (<a href="https://github.com/HugoFara/lwt/issues/163">#163</a>):
<ul>
<li>On <code>inc/kernel_utility.php</code>: <code>LWT_APP_VERSION</code> and <code>LWT_RELEASE_DATE</code>.</li>
<li>On <code>api.php</code>: <code>LWT_API_VERSION</code> and <code>LWT_API_RELEASE_DATE</code>.</li>
</ul>
</li>
</ul>
<h4>Fixed</h4>
<ul>
Expand Down
19 changes: 13 additions & 6 deletions inc/kernel_utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@

require __DIR__ . '/settings.php';

/**
* @var string Version of this current LWT application.
*/
define('LWT_APP_VERSION', '2.9.1-fork');

/**
* @var string Date of the last published release of LWT
*/
define('LWT_RELEASE_DATE', "2023-12-29");

/**
* Return LWT version for humans
Expand All @@ -30,9 +39,8 @@
function get_version(): string
{
global $debug;
$release_number = '2.9.1-fork';
$release_date = 'December 29 2023';
$version = "$release_number ($release_date)";
$formattedDate = date("F d Y", strtotime(LWT_RELEASE_DATE));
$version = LWT_APP_VERSION . " ($formattedDate)";
if ($debug) {
$version .= ' <span class="red">DEBUG</span>';
}
Expand Down Expand Up @@ -548,11 +556,10 @@ function annotation_to_json($ann): string|false
*/
function getreq($s)
{
if (isset($_REQUEST[$s]) ) {
if (isset($_REQUEST[$s])) {
return trim($_REQUEST[$s]);
} else {
return '';
}
return '';
}

/**
Expand Down

0 comments on commit 897235b

Please sign in to comment.