Browse Source

Début svg

merge-requests/1/head
JamesRezo 4 years ago
parent
commit
236cf274de
  1. 72
      modeles/supported-versions.html
  2. 86
      supportedversions_fonctions.php

72
modeles/supported-versions.html

@ -1,12 +1,13 @@
<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 <?php echo $width ?> <?php echo $height ?>" width="<?php echo $width ?>" height="<?php echo $height ?>">
<svg xmlns="http://www.w3.org/2000/svg"
viewbox="0 0 [(#SVG{margin_left}|width)] [(#SVG{header_height}|height)]"
width="[(#SVG{margin_left}|width)]"
height="[(#SVG{header_height}|height)]"
>
<style type="text/css">
<![CDATA[
@import url(/fonts/Fira/fira.css);
text {
fill: #333;
font-family: "Fira Sans", "Source Sans Pro", Helvetica, Arial, sans-serif;
font-size: <?php echo (2 / 3) * $header_height; ?>px;
[font-size: (#SVG{header_height}|mult{2}|div{3})px;]
}
g.eol rect,
@ -28,6 +29,11 @@
fill: #9c9;
}
g.future rect,
.branches rect.future {
fill: #c15e92;
}
.branch-labels text {
dominant-baseline: central;
text-anchor: middle;
@ -54,50 +60,24 @@
]]>
</style>
<!-- Branch labels -->
<g class="branch-labels">
<?php foreach ($branches as $branch => $version): ?>
<g class="<?php echo get_branch_support_state($branch) ?>">
<rect x="0" y="<?php echo $version['top'] ?>" width="<?php echo 0.5 * $margin_left ?>" height="<?php echo $branch_height ?>" />
<text x="<?php echo 0.25 * $margin_left ?>" y="<?php echo $version['top'] + (0.5 * $branch_height) ?>">
<?php echo htmlspecialchars($branch) ?>
</text>
</g>
<?php endforeach ?>
</g>
<!-- Branch labels -->
<g class="branch-labels">
<BOUCLE_active_branches(DATA){source json, #CHEMIN{data/releases.json}}>[(#EOL|>={#DATE}|ou{#EOL|intval|non})
<g[ class="(#VALEUR|state)"]">
<rect x="0" y="[(#BRANCH|top)]" width="[(#SVG{margin_left}|mult{0.5})]" height="#SVG{branch_height}" />
<text x="[(#SVG{margin_left}|mult{0.25})]" y="[(#BRANCH|top|top_for_text)]">
#BRANCH
</text>
</g>]
</BOUCLE_active_branches>
</g>
<!-- Branch blocks -->
<g class="branches">
<?php foreach ($branches as $branch => $version): ?>
<?php
$x_release = date_horiz_coord(get_branch_release_date($branch));
$x_bug = date_horiz_coord(get_branch_bug_eol_date($branch));
$x_eol = date_horiz_coord(get_branch_security_eol_date($branch));
?>
<rect class="stable" x="<?php echo $x_release ?>" y="<?php echo $version['top'] ?>" width="<?php echo $x_bug - $x_release ?>" height="<?php echo $branch_height ?>" />
<rect class="security" x="<?php echo $x_bug ?>" y="<?php echo $version['top'] ?>" width="<?php echo $x_eol - $x_bug ?>" height="<?php echo $branch_height ?>" />
<?php endforeach ?>
<BOUCLE_active_branches_2(DATA){source json, #CHEMIN{data/releases.json}}>[(#EOL|>={#DATE}|ou{#EOL|intval|non})
<rect class="stable" x="[(#INITIAL_RELEASE|horiz_coord)]" y="[(#BRANCH|top)]" width="[(#ACTIVE_SUPPORT|horiz_coord|moins{#INITIAL_RELEASE|horiz_coord})]" height="#SVG{branch_height}" />
<rect class="security" x="[(#ACTIVE_SUPPORT|horiz_coord)]" y="[(#BRANCH|top)]" width="[(#EOL|horiz_coord|moins{#ACTIVE_SUPPORT|horiz_coord})]" height="#SVG{branch_height}" />]
</BOUCLE_active_branches_2>
</g>
<!-- Year lines -->
<g class="years">
<?php foreach ($years as $date): ?>
<line x1="<?php echo date_horiz_coord($date) ?>" y1="<?php echo $header_height ?>" x2="<?php echo date_horiz_coord($date) ?>" y2="<?php echo $header_height + (count($branches) * $branch_height) ?>" />
<text x="<?php echo date_horiz_coord($date) ?>" y="<?php echo 0.8 * $header_height; ?>">
<?php echo $date->format('j M Y') ?>
</text>
<?php endforeach ?>
</g>
<!-- Today -->
<g class="today">
<?php
$now = new DateTime;
$x = date_horiz_coord($now);
?>
<line x1="<?php echo $x ?>" y1="<?php echo $header_height ?>" x2="<?php echo $x ?>" y2="<?php echo $header_height + (count($branches) * $branch_height) ?>" />
<text x="<?php echo $x ?>" y="<?php echo $header_height + (count($branches) * $branch_height) + (0.8 * $footer_height) ?>">
<?php echo 'Today: '.$now->format('j M Y') ?>
</text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

86
supportedversions_fonctions.php

@ -34,3 +34,89 @@ function state(array $valeurs) {
function balise_SVG_dist($p) {
return balise_ENV_dist($p, '$GLOBALS["svg"]');
}
function min_date() {
$now = new DateTime('January 1');
return $now->sub(new DateInterval('P3Y'));
}
function max_date() {
$now = new DateTime('January 1');
return $now->add(new DateInterval('P5Y'));
}
function date_horiz_coord(DateTime $date) {
global $svg;
$diff = $date->diff(min_date());
if (!$diff->invert) {
return $svg['margin_left'];
}
return $svg['margin_left'] + ($diff->days / (365.24 / $svg['year_width']));
}
function horiz_coord($date) {
if ($date) {
return date_horiz_coord(date_create_from_format('Y-m-d', $date));
}
return '';
}
function years() {
static $years = [];
if (empty($years)) {
$years = iterator_to_array(new DatePeriod(min_date(), new DateInterval('P1Y'), max_date()));
}
return $years;
}
function balise_YEARS_dist($p) {
return balise_ENV_dist($p, 'years()');
}
function branches() {
static $branches = [];
if (empty($branches)) {
$branches = array_map(
function ($branch) { return $branch['branch']; },
json_decode(file_get_contents(find_in_path('data/releases.json')), true)
);
}
return $branches;
}
function top($branch) {
global $svg;
$i = array_search($branch, branches(), true);
return $svg['header_height'] + ($svg['branch_height'] * $i++);
}
function top_for_text($top) {
global $svg;
$top = $top + (0.5 * $svg['branch_height']);
return $top;
}
function width($margin_left) {
global $svg;
return $margin_left + $svg['margin_right'] + ((count(years()) - 1) * $svg['year_width']);
}
function height($header_height) {
global $svg;
return $header_height + $svg['footer_height'] + (count(branches()) * $svg['branch_height']);
}

Loading…
Cancel
Save