From 2591ca639056db4f6abe294cc7a81bb831c8f7f9 Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Wed, 11 Jan 2017 17:04:02 +1100 Subject: 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. --- common/html-coverpage/coverpage.html | 73 +++++++++++++++++++ common/html-coverpage/coverpage.js | 13 ++++ common/html-coverpage/index.html | 72 ------------------- common/html-coverpage/static/rtems/js/catalogue.js | 81 +++++++++++----------- wscript | 27 +++++++- 5 files changed, 152 insertions(+), 114 deletions(-) create mode 100644 common/html-coverpage/coverpage.html create mode 100644 common/html-coverpage/coverpage.js delete mode 100644 common/html-coverpage/index.html diff --git a/common/html-coverpage/coverpage.html b/common/html-coverpage/coverpage.html new file mode 100644 index 0000000..dc13f88 --- /dev/null +++ b/common/html-coverpage/coverpage.html @@ -0,0 +1,73 @@ + + + + RTEMS - Documentation + + + + + + + + + + + + + + + + + + + +
+
+
+
+ Header logo +
+
+

RTEMS - Real Time Operating System

+
+
+
+
+ + +
+ +
+
+
+
+
+
+
+
+
+
+

No catalogue found.

+
+
+
+ + + + + +
+ + +
+ + + + + diff --git a/common/html-coverpage/coverpage.js b/common/html-coverpage/coverpage.js new file mode 100644 index 0000000..4655c29 --- /dev/null +++ b/common/html-coverpage/coverpage.js @@ -0,0 +1,13 @@ +/*! + * Copyright 2017 Chris Johns + */ + +/* + * Embed the XML catalogue in this JS code to get around the Chrome on Windows + * security "feature" where loading of a local disk file under the same path as + * the HTML Chrome just loaded from disk is not allowed. + */ +function coverPageCatalogue() { + xml = '@CATALOGUE'; + paintCatalogue($.parseXML(xml)); +} diff --git a/common/html-coverpage/index.html b/common/html-coverpage/index.html deleted file mode 100644 index 301196d..0000000 --- a/common/html-coverpage/index.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - RTEMS - Documentation - - - - - - - - - - - - - - - - - - - -
-
-
-
- Header logo -
-
-

RTEMS - Real Time Operating System

-
-
-
-
- - -
- -
-
-
-
-
-
-
-
-
-
-

No catalogue found.

-
-
-
- - - - -
- - -
-
-
- Copyright 2017 RTEMS Project -
-
- - - - diff --git a/common/html-coverpage/static/rtems/js/catalogue.js b/common/html-coverpage/static/rtems/js/catalogue.js index d54def2..ae32aed 100644 --- a/common/html-coverpage/static/rtems/js/catalogue.js +++ b/common/html-coverpage/static/rtems/js/catalogue.js @@ -29,48 +29,51 @@ function catalogueFooter() { '\n'; } -function loadCatalogue(path) { +function paintCatalogue(xml) { var el_cat_title = $('#rtems-catalogue-title'); var el_cat = $('#rtems-catalogue'); + /* + * Use jquery as XMLDocument is consider not stable on Firefox's web site. + */ + var pdfIcon = 'static/images/Adobe_PDF_file_icon_32x32.png'; + var htmlIcon = 'static/images/html-xxl.png'; + var docs = $(xml).find('rtems-docs'); + var date = $(docs).attr('date'); + var title = $(docs).find('catalogue'); + var table = catalogueHeader(date); + $(docs).find('doc').each(function() { + var name = $(this).find('name').text(); + var title = $(this).find('title').text(); + var release = $(this).find('release').text(); + var version = $(this).find('version').text(); + var html = $(this).find('html').text(); + var pdf = $(this).find('pdf').text(); + var singlehtml = $(this).find('singlehtml').text(); + var empty = '\n'; + table += '\n'; + if (html) + table += '' + title + '\n'; + else + table += empty; + if (pdf) + table += '' + + '\n'; + else + table += empty; + if (singlehtml) + table += '' + + '\n'; + else + table += empty; + table += '\n'; + }); + table += catalogueFooter(); + el_cat_title.html('

' + $(title).text() + '

'); + el_cat.html(table); +} +function loadCatalogue(path) { var f = $.get(path, function(xml) { - /* - * Use jquery as XMLDocument is consider not stable on Firefox's web site. - */ - var pdfIcon = 'static/images/Adobe_PDF_file_icon_32x32.png'; - var htmlIcon = 'static/images/html-xxl.png'; - var docs = $(xml).find('rtems-docs'); - var date = $(docs).attr('date'); - var title = $(docs).find('catalogue'); - var table = catalogueHeader(date); - $(docs).find('doc').each(function() { - var name = $(this).find('name').text(); - var title = $(this).find('title').text(); - var release = $(this).find('release').text(); - var version = $(this).find('version').text(); - var html = $(this).find('html').text(); - var pdf = $(this).find('pdf').text(); - var singlehtml = $(this).find('singlehtml').text(); - var empty = '\n'; - table += '\n'; - if (html) - table += '' + title + '\n'; - else - table += empty; - if (pdf) - table += '' + - '\n'; - else - table += empty; - if (singlehtml) - table += '' + - '\n'; - else - table += empty; - table += '\n'; - }); - table += catalogueFooter(); - el_cat_title.html('

' + $(title).text() + '

'); - el_cat.html(table); + paintCatalogue(xml); }, 'xml'); } diff --git a/wscript b/wscript index 96a8574..955e68f 100644 --- a/wscript +++ b/wscript @@ -9,7 +9,7 @@ path.append(abspath('common')) import waflib import waf as docs_waf -version = '4.11 (4.11.2)' +version = 'Master (4.11.99)' build_all = ['user', 'rsb', @@ -36,18 +36,39 @@ def configure(conf): def catalogue(ctx): docs_waf.xml_catalogue(ctx, building, version) +def coverpage_js(ctx): + js = None + xml = None + for f in ctx.inputs: + if f.abspath().endswith('.js'): + with open(f.abspath()) as i: + js = i.read() + elif f.abspath().endswith('.xml'): + with open(f.abspath()) as i: + xml = i.read() + xml = xml.replace('\n', ' \\\n'); + with open(ctx.outputs[0].abspath(), 'w') as o: + o.write(js.replace('@CATALOGUE', xml)) + def build(ctx): for b in building: ctx.recurse(b) # - # Build the catalogue and install with the coverpage and static content. + # Build the catalogue, coverpage.js and install. # ctx(rule = catalogue, target = 'catalogue.xml', source = ['wscript', 'common/waf.py']) ctx.install_files('${PREFIX}', 'catalogue.xml') - ctx.install_files('${PREFIX}', 'common/html-coverpage/index.html') + ctx(rule = coverpage_js, + target = 'coverpage.js', + source = ['wscript', 'catalogue.xml', 'common/html-coverpage/coverpage.js']) + ctx.install_as('${PREFIX}/coverpage.js', 'coverpage.js') + # + # Install the static content. + # + ctx.install_as('${PREFIX}/index.html', 'common/html-coverpage/coverpage.html') static_dir = ctx.path.find_dir('common/html-coverpage/static') ctx.install_files('${PREFIX}/static', static_dir.ant_glob('**'), -- cgit v1.2.3