Browse Source

balise SUPPORTED_VERSIONS, modèle svg -> calendar, diverses corrections

merge-requests/3/head
JamesRezo 4 years ago
parent
commit
bc7d11bce1
  1. 6
      README.md
  2. 36
      modeles/supportedversions_calendar.html
  3. 2
      supported-versions.svg.html
  4. 31
      supportedversions_fonctions.php
  5. 33
      supportedversions_options.php

6
README.md

@ -4,9 +4,9 @@ SPIP Plugin backport of [PHP Supported Versions](http://php.net/supported-versio
## Models
- `<table|>` : a table of actively supported versions
- `<supported-versions|>` : a calendar view of the table above
- `<legend|>` : colors and style explanations
- `<supportedversions|table>` : a table of actively supported versions
- `<supportedversions|calendar>` : a calendar view of the table above
- `<supportedversions|legend>` : colors and style explanations
## Other usage

36
modeles/supportedversions_svg.html → modeles/supportedversions_calendar.html

@ -1,37 +1,37 @@
<svg xmlns="http://www.w3.org/2000/svg"
viewbox="0 0 [(#SUPVER_SVG{margin_left}|supver_width)] [(#SUPVER_SVG{header_height}|supver_height)]"
width="[(#SUPVER_SVG{margin_left}|supver_width)]"
height="[(#SUPVER_SVG{header_height}|supver_height)]"
viewbox="0 0 [(#SUPPORTED_VERSIONS{svg/margin_left}|supver_width)] [(#SUPPORTED_VERSIONS{svg/header_height}|supver_height)]"
width="[(#SUPPORTED_VERSIONS{svg/margin_left}|supver_width)]"
height="[(#SUPPORTED_VERSIONS{svg/header_height}|supver_height)]"
>
<style type="text/css">
<![CDATA[
text {
fill: #333;
[font-size: (#SUPVER_SVG{header_height}|mult{2}|div{3})px;]
[font-size: (#SUPPORTED_VERSIONS{svg/header_height}|mult{2}|div{3})px;]
}
g.supver_eol rect,
.supver_branches rect.supver_eol {
fill: #e29ea2;
fill: [(#SUPPORTED_VERSIONS{colors/eol/background})];
}
g.supver_eol text {
fill: white;
fill: [(#SUPPORTED_VERSIONS{colors/eol/color})];
}
g.supver_security rect,
.supver_branches rect.supver_security {
fill: #fceaae;
fill: [(#SUPPORTED_VERSIONS{colors/security/background})];
}
g.supver_stable rect,
.supver_branches rect.supver_stable {
fill: #c3e2c5;
fill: [(#SUPPORTED_VERSIONS{colors/stable/background})];
}
g.supver_future rect,
.supver_branches rect.supver_future {
fill: #edcbdc;
fill: [(#SUPPORTED_VERSIONS{colors/future/background})];
}
.supver_branch-labels text {
@ -63,9 +63,9 @@
<!-- Branch labels -->
<g class="supver_branch-labels">
<BOUCLE_active_branches(DATA){source json, #CHEMIN{data/releases.json}}>[(#EOL|>={#DATE}|ou{#EOL|intval|non})
<g[ class="(#VALEUR|supver_state)"]>
<rect x="0" y="[(#BRANCH|supver_top)]" width="[(#SUPVER_SVG{margin_left}|mult{0.5})]" height="#SUPVER_SVG{branch_height}" />
<text x="[(#SUPVER_SVG{margin_left}|mult{0.25})]" y="[(#BRANCH|supver_top|supver_top_for_text)]">
<g[ class="supver_(#VALEUR|supver_state)"]>
<rect x="0" y="[(#BRANCH|supver_top)]" width="[(#SUPPORTED_VERSIONS{svg/margin_left}|mult{0.5})]" height="#SUPPORTED_VERSIONS{svg/branch_height}" />
<text x="[(#SUPPORTED_VERSIONS{svg/margin_left}|mult{0.25})]" y="[(#BRANCH|supver_top|supver_top_for_text)]">
#BRANCH
</text>
</g>]
@ -75,16 +75,16 @@
<!-- Branch blocks -->
<g class="supver_branches">
<BOUCLE_active_branches_2(DATA){source json, #CHEMIN{data/releases.json}}>[(#EOL|>={#DATE}|ou{#EOL|intval|non})
<rect class="supver_stable" x="[(#INITIAL_RELEASE|supver_horiz_coord)]" y="[(#BRANCH|supver_top)]" width="[(#ACTIVE_SUPPORT|supver_horiz_coord|strmoins{#INITIAL_RELEASE|supver_horiz_coord})]" height="#SUPVER_SVG{branch_height}" />
<rect class="supver_security" x="[(#ACTIVE_SUPPORT|supver_horiz_coord)]" y="[(#BRANCH|supver_top)]" width="[(#EOL|supver_horiz_coord|strmoins{#ACTIVE_SUPPORT|supver_horiz_coord})]" height="#SUPVER_SVG{branch_height}" />]
<rect class="supver_stable" x="[(#INITIAL_RELEASE|supver_horiz_coord)]" y="[(#BRANCH|supver_top)]" width="[(#ACTIVE_SUPPORT|supver_horiz_coord|strmoins{#INITIAL_RELEASE|supver_horiz_coord})]" height="#SUPPORTED_VERSIONS{svg/branch_height}" />
<rect class="supver_security" x="[(#ACTIVE_SUPPORT|supver_horiz_coord)]" y="[(#BRANCH|supver_top)]" width="[(#EOL|supver_horiz_coord|strmoins{#ACTIVE_SUPPORT|supver_horiz_coord})]" height="#SUPPORTED_VERSIONS{svg/branch_height}" />]
</BOUCLE_active_branches_2>
</g>
<!-- Year lines -->
<g class="supver_years">
<BOUCLE_years(DATA){source table, #NULL|supver_years}>
<line x1="[(#VALEUR|supver_horiz_coord)]" y1="#SUPVER_SVG{header_height}" x2="[(#VALEUR|supver_horiz_coord)]" y2="[(#SUPVER_SVG{header_height}|supver_height)]" />
<text x="[(#VALEUR|supver_horiz_coord)]" y="[(#SUPVER_SVG{header_height}|mult{0.8})]">
<line x1="[(#VALEUR|supver_horiz_coord)]" y1="#SUPPORTED_VERSIONS{svg/header_height}" x2="[(#VALEUR|supver_horiz_coord)]" y2="[(#SUPPORTED_VERSIONS{svg/header_height}|supver_height)]" />
<text x="[(#VALEUR|supver_horiz_coord)]" y="[(#SUPPORTED_VERSIONS{svg/header_height}|mult{0.8})]">
[(#VALEUR|affdate{M Y})]
</text>
</BOUCLE_years>
@ -92,8 +92,8 @@
<!-- Today -->
<g class="supver_today">
<line x1="[(#DATE|affdate{Y-m-d}|supver_horiz_coord)]" y1="#SUPVER_SVG{header}" x2="[(#DATE|affdate{Y-m-d}|supver_horiz_coord)]" y2="[(#SUPVER_SVG{header_height}|supver_height)]" />
<text x="[(#DATE|affdate{Y-m-d}|supver_horiz_coord)]" y="[(#SUPVER_SVG{header_height}|supver_height|strplus{#SUPVER_SVG{footer_height}|mult{0.8}})]">
<line x1="[(#DATE|affdate{Y-m-d}|supver_horiz_coord)]" y1="#SUPPORTED_VERSIONS{svg/header}" x2="[(#DATE|affdate{Y-m-d}|supver_horiz_coord)]" y2="[(#SUPPORTED_VERSIONS{svg/header_height}|supver_height)]" />
<text x="[(#DATE|affdate{Y-m-d}|supver_horiz_coord)]" y="[(#SUPPORTED_VERSIONS{svg/header_height}|supver_height|strplus{#SUPPORTED_VERSIONS{svg/footer_height}|mult{0.8}})]">
[<:info_aujourdhui:> (#DATE|affdate)]
</text>
</g>

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

2
supportedversions.svg.html → supported-versions.svg.html

@ -1,2 +1,2 @@
#HTTP_HEADER{Content-Type: image/svg+xml}<?xml version="1.0" encoding="utf-8" ?>
#MODELE{supported-versions}
#MODELE{supportedversions_calendar}

31
supportedversions_fonctions.php

@ -31,8 +31,8 @@ function supver_state(array $valeurs) {
return '';
}
function balise_SUPVER_SVG_dist($p) {
return balise_ENV_dist($p, '$GLOBALS["supver_svg"]');
function balise_SUPPORTED_VERSIONS_dist($p) {
return balise_ENV_dist($p, '$GLOBALS["supportedversions"]');
}
function supver_min_date() {
@ -48,14 +48,15 @@ function supver_max_date() {
}
function supver_date_horiz_coord(DateTime $date) {
global $supver_svg;
global $supportedversions;
$diff = $date->diff(supver_min_date());
if (!$diff->invert) {
return $supver_svg['margin_left'];
return $supportedversions['svg']['margin_left'];
}
return $supver_svg['margin_left'] + ($diff->days / (365.24 / $supver_svg['year_width']));
return $supportedversions['svg']['margin_left'] +
($diff->days / (365.24 / $supportedversions['svg']['year_width']));
}
function supver_horiz_coord($date) {
@ -98,29 +99,33 @@ function supver_branches() {
}
function supver_top($branch) {
global $supver_svg;
global $supportedversions;
$i = array_search($branch, supver_branches(), true);
return $supver_svg['header_height'] + ($supver_svg['branch_height'] * $i++);
return $supportedversions['svg']['header_height'] + ($supportedversions['svg']['branch_height'] * $i++);
}
function supver_top_for_text($top) {
global $supver_svg;
global $supportedversions;
$top = $top + (0.5 * $supver_svg['branch_height']);
$top = $top + (0.5 * $supportedversions['svg']['branch_height']);
return $top;
}
function supver_width($margin_left) {
global $supver_svg;
global $supportedversions;
return $margin_left + $supver_svg['margin_right'] + ((count(supver_years()) - 1) * $supver_svg['year_width']);
return $margin_left +
$supportedversions['svg']['margin_right'] +
((count(supver_years()) - 1) * $supportedversions['svg']['year_width']);
}
function supver_height($header_height) {
global $supver_svg;
global $supportedversions;
return $header_height + $supver_svg['footer_height'] + (count(supver_branches()) * $supver_svg['branch_height']);
return $header_height +
$supportedversions['svg']['footer_height'] +
(count(supver_branches()) * $supportedversions['svg']['branch_height']);
}

33
supportedversions_options.php

@ -1,11 +1,28 @@
<?php
// Sizing constants.
$GLOBALS['supver_svg'] = [
'margin_left' => 80,
'margin_right' => 50,
'header_height' => 24,
'year_width' => 120,
'branch_height' => 30,
'footer_height' => 24,
// Sizing & Color constants.
$GLOBALS['supportedversions'] = [
'svg' => [
'margin_left' => 80,
'margin_right' => 50,
'header_height' => 24,
'year_width' => 120,
'branch_height' => 30,
'footer_height' => 24,
],
'colors' => [
'future' => [
'background' => '#edcbdc',
],
'stable' => [
'background' => '#c3e2c5',
],
'security' => [
'background' => '#fceaae',
],
'eol' => [
'background' => '#e29ea2',
'color' => 'white',
],
]
];

Loading…
Cancel
Save