diff options
author | Nicolas Vigier <boklm@mars-attacks.org> | 2013-09-09 23:11:06 +0200 |
---|---|---|
committer | Nicolas Vigier <boklm@mars-attacks.org> | 2013-09-09 23:44:53 +0200 |
commit | 4f0c842ea3d803365cf431b5a87fb5b2b2ab3ac7 (patch) | |
tree | d448f2ecf553005769cee0c45ef921feca187920 | |
parent | 7c7940dba616de47d0552f6c86801bf457979774 (diff) | |
download | mgaadvisories-4f0c842ea3d803365cf431b5a87fb5b2b2ab3ac7.tar mgaadvisories-4f0c842ea3d803365cf431b5a87fb5b2b2ab3ac7.tar.gz mgaadvisories-4f0c842ea3d803365cf431b5a87fb5b2b2ab3ac7.tar.bz2 mgaadvisories-4f0c842ea3d803365cf431b5a87fb5b2b2ab3ac7.tar.xz mgaadvisories-4f0c842ea3d803365cf431b5a87fb5b2b2ab3ac7.zip |
Add menu to filter advisories list
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | static/advisories.css | 7 | ||||
-rw-r--r-- | tmpl/advisories.html | 140 |
3 files changed, 146 insertions, 3 deletions
@@ -1,3 +1,5 @@ +- add menu to filter advisories list + Version 0.15 - correctly encode html in rss feed diff --git a/static/advisories.css b/static/advisories.css index 462a148..e1c8737 100644 --- a/static/advisories.css +++ b/static/advisories.css @@ -10,3 +10,10 @@ padding-top: 1em; padding-bottom: 1em; } + +#adv_menu { + text-align: left; + padding-left: 2em; + padding-top: 1em; + background: #fff; +} diff --git a/tmpl/advisories.html b/tmpl/advisories.html index e5fa506..eab4bf8 100644 --- a/tmpl/advisories.html +++ b/tmpl/advisories.html @@ -1,17 +1,151 @@ -[% USE date -%] +[%- USE JSON ( pretty => 1 ) -%] +[%- USE date -%] +[%- + jsadvdb = []; + mga_releases = {}; + FOREACH adv IN advdb.sorted; + a = {}; + a.src = []; + pkgs = {}; + FOREACH rel IN advdb.advisories.$adv.src.keys; + FOREACH media IN advdb.advisories.$adv.src.$rel.keys; + FOREACH srpm IN advdb.advisories.$adv.src.$rel.$media; + SET srcname = tools.pkgname(srpm); + IF ! pkgs.$srcname; + pkgs.$srcname = 1; + a.src.push(srcname); + END; + END; + END; + END; + a.CVE = advdb.advisories.$adv.CVE; + a.rel = advdb.advisories.$adv.src.keys; + FOREACH rel IN a.rel; + mga_releases.$rel = 1; + END; + a.type = advdb.advisories.$adv.type; + html = BLOCK -%] + <tr> + <td width='100'> + [% date.format(advdb.advisories.$adv.status.published, format => '%Y-%m-%d', gmt => 1) %] + </td> + <td width='150'><a href="[% basename.ID(adv) %].html">[% adv %]</a></td> + <td> + [% SET sep = '' %] + [% FOREACH srcname IN a.src -%] + [%- sep -%] + [%- SET sep = ', ' -%] + <a href="[% basename.src(srcname) %].html">[% srcname %]</a> + [%- END -%] + </td> + <td>[% advdb.advisories.$adv.type %]</td> + <td> + [% SET sep = '' %] + [% FOREACH rel IN advdb.advisories.$adv.src.keys %] + [% sep %] + [% SET sep = ', ' %] + <a href="[% basename.rel(rel) %].html">[% rel %]</a> + [% END %] + </td> + <td> + [% SET sep = '' %] + [% FOREACH cve IN advdb.advisories.$adv.CVE %] + [% sep %] + [% SET sep = ', ' %] + <a href="[% basename.CVE(cve) %].html">[% cve %]</a> + [% END %] + </td> + </tr> + [%- END; + a.html = html.collapse; + jsadvdb.push(a); + END; +-%] <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Mageia Advisories</title> <link rel="alternate" type="application/rss+xml" title="RSS" href="[% config.site_url %]/advisories.rss" /> [%- INCLUDE head.html -%] + <script type="text/javascript"> + function make_table() { + var advdb = [% jsadvdb.json %]; + var table_start = "<table id='adv_table' border='0'>\ + <tr>\ + <th>\ + Date\ + </th>\ + <th>\ + ID\ + </th>\ + <th>\ + Source Package(s)\ + </th>\ + <th>\ + Type\ + </th>\ + <th>\ + Affected release(s)\ + </th>\ + <th>\ + CVE\ + </th>\ + </tr>"; + var table_end = "</table>"; + var table_content = ''; + var rel_index = document.getElementById('sel_rel').selectedIndex; + var rel = document.getElementById('sel_rel').options[rel_index].text; + var type_index = document.getElementById('sel_type').selectedIndex; + var type = document.getElementById('sel_type').options[type_index].text; + for (var i = 0; i < advdb.length; i++) { + if (rel != 'all' && advdb[i].rel.indexOf(rel) == -1) + continue; + if (type != 'all' && type != advdb[i].type) + continue; + var input_src = document.getElementById("txt_src").value; + if (input_src != '' && advdb[i].src.indexOf(input_src) == -1) + continue; + var input_cve = document.getElementById("txt_cve").value; + if (input_cve != '' && advdb[i].CVE.indexOf(input_cve) == -1) + continue; + table_content += advdb[i].html; + } + if (table_content == '') + document.getElementById("adv_table").innerHTML = 'No matching advisory found'; + else + document.getElementById("adv_table").innerHTML = table_start + table_content + table_end; + } + </script> </head> <body> [%- INCLUDE body_top.html -%] <h1 id='mgnavt'><a href="index.html">Advisories</a> ยป All <a href="advisories.rss"><img src="http://static.mageia.org/g/images/smi/feed-16x16.png" alt="rss" /></a></h1> - <div class="content"> - [% INCLUDE advisories_table.html advlst = advdb.sorted %] + <div id="adv_menu"> + <form name="adv_form"> + Mageia release: + <select id="sel_rel" onchange="make_table();"> + <option>all</option> + [%- FOREACH rel IN mga_releases.keys.sort %] + <option>[% rel %]</option> + [%- END %] + </select> + Type: + <select id="sel_type" onchange="make_table();"> + <option>all</option> + <option>security</option> + <option>bugfix</option> + </select> + Source package: + <input type="text" id="txt_src" size="10" onchange="make_table();" oninput="make_table();" /> + CVE: + <input type="text" id="txt_cve" size="10" onchange="make_table();" oninput="make_table();" /> + </form> </div> + <div id="adv_table" class="content"> + </div> + <script type="text/javascript"> + make_table(); + </script> </body> </html> |