Browse Source

Préfixer la globale, les fonctions et les classes css avec supver_ pour éviter des collisions.

Fix #1
merge-requests/3/head
nicod 4 years ago
parent
commit
e16d0130b1
  1. 14
      css/supported-versions.css
  2. 100
      modeles/supported-versions.html
  3. 2
      modeles/supportedversions_legend.html
  4. 100
      modeles/supportedversions_svg.html
  5. 4
      modeles/supportedversions_table.html
  6. 0
      supportedversions.svg.html
  7. 58
      supportedversions_fonctions.php
  8. 2
      supportedversions_options.php

14
css/supported-versions.css

@ -1,32 +1,32 @@
/* Branches page */
table.standard tr.eol td:first-child {
table.supportedversions tr.eol td:first-child {
background: #e29ea2;
color: white;
}
table.standard tr.security td:first-child {
table.supportedversions tr.security td:first-child {
background: #fceaae;
}
table.standard tr.stable td:first-child {
table.supportedversions tr.stable td:first-child {
background: #c3e2c5;
}
table.standard tr.future td:first-child {
table.supportedversions tr.future td:first-child {
background: #edcbdc;
}
@media (max-width: 767px) {
table.standard th {
table.supportedversions th {
font-size: 1rem;
}
table.standard td.collapse-phone {
table.supportedversions td.collapse-phone {
padding: 0;
}
table.standard td.collapse-phone * {
table.supportedversions td.collapse-phone * {
display: none;
}
}

100
modeles/supported-versions.html

@ -1,100 +0,0 @@
<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[
text {
fill: #333;
[font-size: (#SVG{header_height}|mult{2}|div{3})px;]
}
g.eol rect,
.branches rect.eol {
fill: #e29ea2;
}
g.eol text {
fill: white;
}
g.security rect,
.branches rect.security {
fill: #fceaae;
}
g.stable rect,
.branches rect.stable {
fill: #c3e2c5;
}
g.future rect,
.branches rect.future {
fill: #edcbdc;
}
.branch-labels text {
dominant-baseline: central;
text-anchor: middle;
}
.today line {
stroke: #f33;
stroke-dasharray: 7,7;
stroke-width: 3px;
}
.today text {
fill: #f33;
text-anchor: middle;
}
.years line {
stroke: black;
}
.years text {
text-anchor: middle;
}
]]>
</style>
<!-- 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">
<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|strmoins{#INITIAL_RELEASE|horiz_coord})]" height="#SVG{branch_height}" />
<rect class="security" x="[(#ACTIVE_SUPPORT|horiz_coord)]" y="[(#BRANCH|top)]" width="[(#EOL|horiz_coord|strmoins{#ACTIVE_SUPPORT|horiz_coord})]" height="#SVG{branch_height}" />]
</BOUCLE_active_branches_2>
</g>
<!-- Year lines -->
<g class="years">
<BOUCLE_years(DATA){source table, #NULL|years}>
<line x1="[(#VALEUR|horiz_coord)]" y1="#SVG{header_height}" x2="[(#VALEUR|horiz_coord)]" y2="[(#SVG{header_height}|height)]" />
<text x="[(#VALEUR|horiz_coord)]" y="[(#SVG{header_height}|mult{0.8})]">
[(#VALEUR|affdate{M Y})]
</text>
</BOUCLE_years>
</g>
<!-- Today -->
<g class="today">
<line x1="[(#DATE|affdate{Y-m-d}|horiz_coord)]" y1="#SVG{header}" x2="[(#DATE|affdate{Y-m-d}|horiz_coord)]" y2="[(#SVG{header_height}|height)]" />
<text x="[(#DATE|affdate{Y-m-d}|horiz_coord)]" y="[(#SVG{header_height}|height|strplus{#SVG{footer_height}|mult{0.8}})]">
[<:info_aujourdhui:> (#DATE|affdate)]
</text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 3.2 KiB

2
modeles/legend.html → modeles/supportedversions_legend.html

@ -1,4 +1,4 @@
<table class="spip standard">
<table class="spip supportedversions">
<tr class="future">
<td><:supportedversions:unreleased:></td>
<td><:supportedversions:unreleased_definition:></td>

100
modeles/supportedversions_svg.html

@ -0,0 +1,100 @@
<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)]"
>
<style type="text/css">
<![CDATA[
text {
fill: #333;
[font-size: (#SUPVER_SVG{header_height}|mult{2}|div{3})px;]
}
g.supver_eol rect,
.supver_branches rect.supver_eol {
fill: #e29ea2;
}
g.supver_eol text {
fill: white;
}
g.supver_security rect,
.supver_branches rect.supver_security {
fill: #fceaae;
}
g.supver_stable rect,
.supver_branches rect.supver_stable {
fill: #c3e2c5;
}
g.supver_future rect,
.supver_branches rect.supver_future {
fill: #edcbdc;
}
.supver_branch-labels text {
dominant-baseline: central;
text-anchor: middle;
}
.supver_today line {
stroke: #f33;
stroke-dasharray: 7,7;
stroke-width: 3px;
}
.supver_today text {
fill: #f33;
text-anchor: middle;
}
.supver_years line {
stroke: black;
}
.supver_years text {
text-anchor: middle;
}
]]>
</style>
<!-- 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)]">
#BRANCH
</text>
</g>]
</BOUCLE_active_branches>
</g>
<!-- 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}" />]
</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})]">
[(#VALEUR|affdate{M Y})]
</text>
</BOUCLE_years>
</g>
<!-- 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}})]">
[<:info_aujourdhui:> (#DATE|affdate)]
</text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.7 KiB

4
modeles/table.html → modeles/supportedversions_table.html

@ -1,5 +1,5 @@
<B_active_branches>
<table class="spip standard">
<table class="spip supportedversions">
<thead>
<tr>
<th><:supportedversions:branch:></th>
@ -11,7 +11,7 @@
</thead>
<tbody>
<BOUCLE_active_branches(DATA){source json, #CHEMIN{data/releases.json}}>[(#EOL|>={#DATE}|ou{#EOL|intval|non})
<tr[ class="(#VALEUR|state)"]>
<tr[ class="(#VALEUR|supver_state)"]>
<td>#BRANCH</td>
<td>[(#PHP|array_shift)][ - (#PHP|array_pop)]</td>
<td>[(#INITIAL_RELEASE|affdate)]</td>

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

58
supportedversions_fonctions.php

@ -12,7 +12,7 @@ function supportedversions_header_prive_css($flux) {
return supportedversions_insert_head_css($flux);
}
function state(array $valeurs) {
function supver_state(array $valeurs) {
$now = new DateTime;
$initial = new DateTime($valeurs['initial_release']);
$bug = $valeurs['active_support'] ? new DateTime($valeurs['active_support']) : null;
@ -31,43 +31,43 @@ function state(array $valeurs) {
return '';
}
function balise_SVG_dist($p) {
return balise_ENV_dist($p, '$GLOBALS["svg"]');
function balise_SUPVER_SVG_dist($p) {
return balise_ENV_dist($p, '$GLOBALS["supver_svg"]');
}
function min_date() {
function supver_min_date() {
$now = new DateTime('January 1');
return $now->sub(new DateInterval('P3Y'));
}
function max_date() {
function supver_max_date() {
$now = new DateTime('January 1');
return $now->add(new DateInterval('P5Y'));
}
function date_horiz_coord(DateTime $date) {
global $svg;
function supver_date_horiz_coord(DateTime $date) {
global $supver_svg;
$diff = $date->diff(min_date());
$diff = $date->diff(supver_min_date());
if (!$diff->invert) {
return $svg['margin_left'];
return $supver_svg['margin_left'];
}
return $svg['margin_left'] + ($diff->days / (365.24 / $svg['year_width']));
return $supver_svg['margin_left'] + ($diff->days / (365.24 / $supver_svg['year_width']));
}
function horiz_coord($date) {
function supver_horiz_coord($date) {
if ($date) {
return date_horiz_coord(date_create_from_format('Y-m-d', $date));
return supver_date_horiz_coord(date_create_from_format('Y-m-d', $date));
}
//return '';
return date_horiz_coord(max_date());
return supver_date_horiz_coord(supver_max_date());
}
function years() {
function supver_years() {
static $years = [];
if (empty($years)) {
@ -75,14 +75,14 @@ function years() {
function ($year) {
return $year->format('Y-m-d');
},
iterator_to_array(new DatePeriod(min_date(), new DateInterval('P1Y'), max_date()))
iterator_to_array(new DatePeriod(supver_min_date(), new DateInterval('P1Y'), supver_max_date()))
);
}
return $years;
}
function branches() {
function supver_branches() {
static $branches = [];
if (empty($branches)) {
@ -97,30 +97,30 @@ function branches() {
return $branches;
}
function top($branch) {
global $svg;
function supver_top($branch) {
global $supver_svg;
$i = array_search($branch, branches(), true);
$i = array_search($branch, supver_branches(), true);
return $svg['header_height'] + ($svg['branch_height'] * $i++);
return $supver_svg['header_height'] + ($supver_svg['branch_height'] * $i++);
}
function top_for_text($top) {
global $svg;
function supver_top_for_text($top) {
global $supver_svg;
$top = $top + (0.5 * $svg['branch_height']);
$top = $top + (0.5 * $supver_svg['branch_height']);
return $top;
}
function width($margin_left) {
global $svg;
function supver_width($margin_left) {
global $supver_svg;
return $margin_left + $svg['margin_right'] + ((count(years()) - 1) * $svg['year_width']);
return $margin_left + $supver_svg['margin_right'] + ((count(supver_years()) - 1) * $supver_svg['year_width']);
}
function height($header_height) {
global $svg;
function supver_height($header_height) {
global $supver_svg;
return $header_height + $svg['footer_height'] + (count(branches()) * $svg['branch_height']);
return $header_height + $supver_svg['footer_height'] + (count(supver_branches()) * $supver_svg['branch_height']);
}

2
supportedversions_options.php

@ -1,7 +1,7 @@
<?php
// Sizing constants.
$GLOBALS['svg'] = [
$GLOBALS['supver_svg'] = [
'margin_left' => 80,
'margin_right' => 50,
'header_height' => 24,

Loading…
Cancel
Save