Skip to content

Commit d6c7c6f

Browse files
author
jantje
committed
#499 first implementation
1 parent 23d9d49 commit d6c7c6f

File tree

2 files changed

+98
-28
lines changed

2 files changed

+98
-28
lines changed

io.sloeber.ui/plugin.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,16 @@ The color used by the fourth serial connection of the serial monitor
490490
value="https://www.youtube.com/playlist?list=PLCSjf7QmP3TDPSjT_5UIp0DHXzKdhIQsF">
491491
</parameter>
492492
</command>
493+
<command
494+
commandId="io.sloeber.core.open.link"
495+
id="open.upgrade.page"
496+
label="Do I need to upgrade? ..."
497+
style="push">
498+
<parameter
499+
name="io.sloeber.core.link.parameter"
500+
value="http://baeyens.it/eclipse/github_status.php?majorVersion=${MAJOR_VERSION}&amp;minorVersion=${MINOR_VERSION}&amp;microVersion=${MICRO_VERSION}&amp;qualifierVersion=${QUALIFIER_VERSION}">
501+
</parameter>
502+
</command>
493503
<separator
494504
name="io.sloeber.core.separator2"
495505
visible="true">

website/WebContent/github_status.php

Lines changed: 88 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
2828
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
2929
<![endif]-->
30+
<style>
31+
table, th, td {
32+
border: 1px solid black;
33+
}
34+
</style>
3035
</head>
3136

3237
<body>
@@ -35,42 +40,97 @@
3540
<?php include 'fragments/navbar.html';?>
3641
</nav>
3742

43+
3844
<?php
39-
// read data from local file
40-
$filter = "nightly";
41-
$githubCacheFile = "githubdata_" . $filter . "_cache.tmp";
42-
$githubUrl = "https://api.github.com/repos/jantje/arduino-eclipse-plugin/issues?labels=status:%20fixed%20in%20" . $filter;
43-
$issuesJson = "";
44-
// echo "Testing existance of ".$githubCacheFile."<br/>\n";
45-
if (file_exists ( $githubCacheFile )) {
46-
// echo $githubCacheFile." exists<br/>\n";
47-
$GithubCacheFileDate = filectime ( $githubCacheFile );
48-
if (time () <= $GithubCacheFileDate + (60 * 2)) {
49-
$issuesJson = file_get_contents ( $githubCacheFile );
50-
// echo "using cache<br/>\n";
45+
function cachedGithubJson($cachefile, $url) {
46+
// echo "geting cached data from url: <a href=" . $url . ">" . $url . "</a><br>\n";
47+
// echo "Testing existance of " . $cachefile . "<br/>\n";
48+
if (file_exists ( $cachefile )) {
49+
// echo $cachefile . " exists<br/>\n";
50+
$CacheFileDate = filectime ( $cachefile );
51+
if (time () <= $CacheFileDate + (60 * 20)) {
52+
$ret = file_get_contents ( $cachefile );
53+
if (strlen ( $ret ) > 10) {
54+
// echo "using cache<br/>\n";
55+
} else {
56+
// echo "Local cache is empty<br/>\n";
57+
$ret = "";
58+
}
59+
} else {
60+
// echo $cachefile . " Is old<br/>\n";
61+
}
62+
} else {
63+
// echo $cachefile . " does not exists<br/>\n";
5164
}
52-
// else{
53-
// echo $githubCacheFile." Is old<br/>\n";
54-
// }
55-
}
56-
// else{
57-
// echo $githubCacheFile." does not exists<br/>\n";
58-
// }
59-
if ($issuesJson == "") {
60-
$issuesJson = file_get_contents ( $githubUrl );
61-
file_put_contents ( $githubCacheFile, $issuesJson );
62-
// echo "refreshing cache<br/>\n";
65+
if ($ret == "") {
66+
$ret = file_get_contents ( $url );
67+
if ($ret === false) {
68+
// echo "<strong>failed</strong><br>\n";
69+
$ret = file_get_contents ( $cachefile );
70+
} else {
71+
file_put_contents ( $cachefile, $ret );
72+
}
73+
}
74+
return $ret;
6375
}
64-
$issues = json_decode ( $issuesJson, true );
65-
// var_dump($issues);
76+
77+
function dumpIssues($issues){
78+
echo "<table>\n";
79+
echo "<tr><th>title</th><th>domain</th><th>importance</th><th>os</th><th>other</th></tr>";
6680
foreach ( $issues as $issue ) {
67-
echo "<div><a href=" . $issue ["html_url"] . ">" . $issue ["title"] . "</a> ";
81+
$title = "<a href=" . $issue ["html_url"] . ">" . $issue ["title"] . "</a> ";
82+
$domain_label = "";
83+
$importance_label = "";
84+
$os_label = "";
85+
$rest_label = "";
86+
$importance_inbetween = "";
87+
$domain_inbetween = "";
88+
$os_inbetween = "";
89+
$rest_inbetween = "";
90+
6891
foreach ( $issue ["labels"] as $label ) {
69-
echo '<SPAN style="background-color: #' . $label ["color"] . ';"> ' . $label ["name"] . " </SPAN>&ensp;";
92+
if (0 === strpos ( $label ["name"], "domain: " )) {
93+
$domain_label = $domain_label . $domain_inbetween . '<SPAN style="background-color: #' . $label ["color"] . ';"> <b>' . substr ( $label ["name"], 8 ) . " </b></SPAN>&ensp;";
94+
$domain_inbetween = "<br>";
95+
} elseif (0 === strpos ( $label ["name"], "importance: " )) {
96+
$importance_label = $importance_label . $importance_inbetween . '<SPAN style="background-color: #' . $label ["color"] . ';"> <b>' . substr ( $label ["name"], 12 ) . " </b></SPAN>&ensp;";
97+
$importance_inbetween = "<br>";
98+
} elseif (0 === strpos ( $label ["name"], "OS: " )) {
99+
$os_label = $os_label . $os_inbetween .'<SPAN style="background-color: #' . $label ["color"] . ';"> <b>' . substr ( $label ["name"], 4 ) . " </b></SPAN>&ensp;";
100+
$os_inbetween = "<br>";
101+
} elseif (0 === strpos($label["name"], "status: fixed in")){
102+
// ignore fixed status as this is per table
103+
}
104+
else {
105+
$rest_label = $rest_label . $rest_inbetween . '<SPAN style="background-color: #' . $label ["color"] . ';"> <b>' . $label ["name"] . " </b></SPAN>&ensp;";
106+
$rest_inbetween = "<br>";
107+
}
70108
}
71-
echo "</div><br />\n";
109+
echo "<tr><td>" . $title . "</td>";
110+
echo "<td>" . $domain_label . "</td>";
111+
echo "<td>" . $importance_label . "</td>";
112+
echo "<td>" . $os_label . "</td>";
113+
echo "<td>" . $rest_label . "</td>";
114+
echo "</tr>\n";
115+
}
116+
echo "</table>";
117+
}
118+
119+
// read data from local file
120+
$labelsJson = cachedGithubJson ( "githubdata_labels_cache.tmp", "https://api.github.com/repos/Sloeber/arduino-eclipse-plugin/labels?per_page=100" );
121+
$labels = json_decode ( $labelsJson, true );
122+
$fixedLabels="";
123+
foreach ( $labels as $label ) {
124+
if (0 === strpos ( $label ["name"], "status: fixed in " )) {
125+
$curLabelversion=substr ( $label ["name"], 17 ) ;
126+
echo "fixed in " . $label["name"] ."<br>";
127+
$CurIssuesJson = cachedGithubJson ( "githubdata_".$curLabelversion."_cache.tmp", "https://api.github.com/repos/Sloeber/arduino-eclipse-plugin/issues?state=all&labels=" . urlencode($label ["name"]));
128+
$CurIssues = json_decode ( $CurIssuesJson, true );
129+
dumpIssues($CurIssues);
130+
}
72131
}
73132

133+
74134
?>
75135

76136
<div id="footer">

0 commit comments

Comments
 (0)