Changeset 1ce8d29 in rtems-docs


Ignore:
Timestamp:
01/11/17 06:04:02 (5 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.11
Children:
c2c29d8
Parents:
d8a1037
git-author:
Chris Johns <chrisj@…> (01/11/17 06:04:02)
git-committer:
Chris Johns <chrisj@…> (01/11/17 06:06:29)
Message:

html: Embed the catalogue XML in JS.

The is to work around a security issue with Chrome on Windows. This
patches let the cover page load on Chrome and Edge on Windows 10.

Files:
1 added
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • common/html-coverpage/coverpage.html

    rd8a1037 r1ce8d29  
    5656   <!-- Load the catalogues and generate the content -->
    5757   <script type="text/javascript" src="static/rtems/js/catalogue.js"></script>
    58    <script> loadCatalogue('catalogue.xml'); </script>
     58   <script type="text/javascript" src="coverpage.js"></script>
     59   <script> coverPageCatalogue(); </script>
    5960   <!-- current-bottom -->
    6061  </div>
  • common/html-coverpage/static/rtems/js/catalogue.js

    rd8a1037 r1ce8d29  
    3030}
    3131
    32 function loadCatalogue(path) {
     32function paintCatalogue(xml) {
    3333    var el_cat_title = $('#rtems-catalogue-title');
    3434    var el_cat = $('#rtems-catalogue');
     35    /*
     36     * Use jquery as XMLDocument is consider not stable on Firefox's web site.
     37     */
     38    var pdfIcon = 'static/images/Adobe_PDF_file_icon_32x32.png';
     39    var htmlIcon = 'static/images/html-xxl.png';
     40    var docs = $(xml).find('rtems-docs');
     41    var date = $(docs).attr('date');
     42    var title = $(docs).find('catalogue');
     43    var table = catalogueHeader(date);
     44    $(docs).find('doc').each(function() {
     45        var name = $(this).find('name').text();
     46        var title = $(this).find('title').text();
     47        var release = $(this).find('release').text();
     48        var version = $(this).find('version').text();
     49        var html = $(this).find('html').text();
     50        var pdf = $(this).find('pdf').text();
     51        var singlehtml = $(this).find('singlehtml').text();
     52        var empty = '<td></a></td>\n';
     53        table += '<tr>\n';
     54        if (html)
     55            table += '<td><a href="' + html + '">' + title + '</a></td>\n';
     56        else
     57            table += empty;
     58        if (pdf)
     59            table += '<td><a href="' + '/' + pdf + '">' +
     60            '<img src="' + pdfIcon + '" width="20" height="20"></a></td>\n';
     61        else
     62            table += empty;
     63        if (singlehtml)
     64            table += '<td><a href="' + '/' + singlehtml + '">' +
     65            '<img src="' + htmlIcon + '" width="20" height="20"></a></td>\n';
     66        else
     67            table += empty;
     68        table += '</tr>\n';
     69    });
     70    table += catalogueFooter();
     71    el_cat_title.html('<h3>' + $(title).text() + '</h3>');
     72    el_cat.html(table);
     73}
    3574
     75function loadCatalogue(path) {
    3676    var f = $.get(path, function(xml) {
    37         /*
    38          * Use jquery as XMLDocument is consider not stable on Firefox's web site.
    39          */
    40         var pdfIcon = 'static/images/Adobe_PDF_file_icon_32x32.png';
    41         var htmlIcon = 'static/images/html-xxl.png';
    42         var docs = $(xml).find('rtems-docs');
    43         var date = $(docs).attr('date');
    44         var title = $(docs).find('catalogue');
    45         var table = catalogueHeader(date);
    46         $(docs).find('doc').each(function() {
    47             var name = $(this).find('name').text();
    48             var title = $(this).find('title').text();
    49             var release = $(this).find('release').text();
    50             var version = $(this).find('version').text();
    51             var html = $(this).find('html').text();
    52             var pdf = $(this).find('pdf').text();
    53             var singlehtml = $(this).find('singlehtml').text();
    54             var empty = '<td></a></td>\n';
    55             table += '<tr>\n';
    56             if (html)
    57                 table += '<td><a href="' + html + '">' + title + '</a></td>\n';
    58             else
    59                 table += empty;
    60             if (pdf)
    61                 table += '<td><a href="' + '/' + pdf + '">' +
    62                     '<img src="' + pdfIcon + '" width="20" height="20"></a></td>\n';
    63             else
    64                 table += empty;
    65             if (singlehtml)
    66                 table += '<td><a href="' + '/' + singlehtml + '">' +
    67                     '<img src="' + htmlIcon + '" width="20" height="20"></a></td>\n';
    68             else
    69                 table += empty;
    70             table += '</tr>\n';
    71         });
    72         table += catalogueFooter();
    73         el_cat_title.html('<h3>' + $(title).text() + '</h3>');
    74         el_cat.html(table);
     77        paintCatalogue(xml);
    7578    }, 'xml');
    7679}
  • wscript

    rd8a1037 r1ce8d29  
    1010import waf as docs_waf
    1111
    12 version = '4.11 (4.11.2)'
     12version = 'Master (4.11.99)'
    1313
    1414build_all = ['user',
     
    3737    docs_waf.xml_catalogue(ctx, building, version)
    3838
     39def coverpage_js(ctx):
     40    js = None
     41    xml = None
     42    for f in ctx.inputs:
     43        if f.abspath().endswith('.js'):
     44            with open(f.abspath()) as i:
     45                js = i.read()
     46        elif f.abspath().endswith('.xml'):
     47            with open(f.abspath()) as i:
     48                xml = i.read()
     49    xml = xml.replace('\n', ' \\\n');
     50    with open(ctx.outputs[0].abspath(), 'w') as o:
     51        o.write(js.replace('@CATALOGUE', xml))
     52
    3953def build(ctx):
    4054    for b in building:
     
    4256
    4357    #
    44     # Build the catalogue and install with the coverpage and static content.
     58    # Build the catalogue, coverpage.js and install.
    4559    #
    4660    ctx(rule = catalogue,
     
    4862        source = ['wscript', 'common/waf.py'])
    4963    ctx.install_files('${PREFIX}', 'catalogue.xml')
    50     ctx.install_files('${PREFIX}', 'common/html-coverpage/index.html')
     64    ctx(rule = coverpage_js,
     65        target = 'coverpage.js',
     66        source = ['wscript', 'catalogue.xml', 'common/html-coverpage/coverpage.js'])
     67    ctx.install_as('${PREFIX}/coverpage.js', 'coverpage.js')
     68    #
     69    # Install the static content.
     70    #
     71    ctx.install_as('${PREFIX}/index.html', 'common/html-coverpage/coverpage.html')
    5172    static_dir = ctx.path.find_dir('common/html-coverpage/static')
    5273    ctx.install_files('${PREFIX}/static',
Note: See TracChangeset for help on using the changeset viewer.