mirror of
https://git.rtems.org/rtems-docs/
synced 2025-07-24 04:44:18 +08:00
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.
This commit is contained in:
parent
ecf82d1b3d
commit
2591ca6390
@ -55,7 +55,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- Load the catalogues and generate the content -->
|
<!-- Load the catalogues and generate the content -->
|
||||||
<script type="text/javascript" src="static/rtems/js/catalogue.js"></script>
|
<script type="text/javascript" src="static/rtems/js/catalogue.js"></script>
|
||||||
<script> loadCatalogue('catalogue.xml'); </script>
|
<script type="text/javascript" src="coverpage.js"></script>
|
||||||
|
<script> coverPageCatalogue(); </script>
|
||||||
<!-- current-bottom -->
|
<!-- current-bottom -->
|
||||||
</div>
|
</div>
|
||||||
<!-- layout-bottom -->
|
<!-- layout-bottom -->
|
13
common/html-coverpage/coverpage.js
Normal file
13
common/html-coverpage/coverpage.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/*!
|
||||||
|
* Copyright 2017 Chris Johns <chrisj@rtems.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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));
|
||||||
|
}
|
@ -29,48 +29,51 @@ function catalogueFooter() {
|
|||||||
'</table>\n';
|
'</table>\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadCatalogue(path) {
|
function paintCatalogue(xml) {
|
||||||
var el_cat_title = $('#rtems-catalogue-title');
|
var el_cat_title = $('#rtems-catalogue-title');
|
||||||
var el_cat = $('#rtems-catalogue');
|
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 = '<td></a></td>\n';
|
||||||
|
table += '<tr>\n';
|
||||||
|
if (html)
|
||||||
|
table += '<td><a href="' + html + '">' + title + '</a></td>\n';
|
||||||
|
else
|
||||||
|
table += empty;
|
||||||
|
if (pdf)
|
||||||
|
table += '<td><a href="' + '/' + pdf + '">' +
|
||||||
|
'<img src="' + pdfIcon + '" width="20" height="20"></a></td>\n';
|
||||||
|
else
|
||||||
|
table += empty;
|
||||||
|
if (singlehtml)
|
||||||
|
table += '<td><a href="' + '/' + singlehtml + '">' +
|
||||||
|
'<img src="' + htmlIcon + '" width="20" height="20"></a></td>\n';
|
||||||
|
else
|
||||||
|
table += empty;
|
||||||
|
table += '</tr>\n';
|
||||||
|
});
|
||||||
|
table += catalogueFooter();
|
||||||
|
el_cat_title.html('<h3>' + $(title).text() + '</h3>');
|
||||||
|
el_cat.html(table);
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadCatalogue(path) {
|
||||||
var f = $.get(path, function(xml) {
|
var f = $.get(path, function(xml) {
|
||||||
/*
|
paintCatalogue(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 = '<td></a></td>\n';
|
|
||||||
table += '<tr>\n';
|
|
||||||
if (html)
|
|
||||||
table += '<td><a href="' + html + '">' + title + '</a></td>\n';
|
|
||||||
else
|
|
||||||
table += empty;
|
|
||||||
if (pdf)
|
|
||||||
table += '<td><a href="' + '/' + pdf + '">' +
|
|
||||||
'<img src="' + pdfIcon + '" width="20" height="20"></a></td>\n';
|
|
||||||
else
|
|
||||||
table += empty;
|
|
||||||
if (singlehtml)
|
|
||||||
table += '<td><a href="' + '/' + singlehtml + '">' +
|
|
||||||
'<img src="' + htmlIcon + '" width="20" height="20"></a></td>\n';
|
|
||||||
else
|
|
||||||
table += empty;
|
|
||||||
table += '</tr>\n';
|
|
||||||
});
|
|
||||||
table += catalogueFooter();
|
|
||||||
el_cat_title.html('<h3>' + $(title).text() + '</h3>');
|
|
||||||
el_cat.html(table);
|
|
||||||
}, 'xml');
|
}, 'xml');
|
||||||
}
|
}
|
||||||
|
27
wscript
27
wscript
@ -9,7 +9,7 @@ path.append(abspath('common'))
|
|||||||
import waflib
|
import waflib
|
||||||
import waf as docs_waf
|
import waf as docs_waf
|
||||||
|
|
||||||
version = '4.11 (4.11.2)'
|
version = 'Master (4.11.99)'
|
||||||
|
|
||||||
build_all = ['user',
|
build_all = ['user',
|
||||||
'rsb',
|
'rsb',
|
||||||
@ -36,18 +36,39 @@ def configure(conf):
|
|||||||
def catalogue(ctx):
|
def catalogue(ctx):
|
||||||
docs_waf.xml_catalogue(ctx, building, version)
|
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):
|
def build(ctx):
|
||||||
for b in building:
|
for b in building:
|
||||||
ctx.recurse(b)
|
ctx.recurse(b)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Build the catalogue and install with the coverpage and static content.
|
# Build the catalogue, coverpage.js and install.
|
||||||
#
|
#
|
||||||
ctx(rule = catalogue,
|
ctx(rule = catalogue,
|
||||||
target = 'catalogue.xml',
|
target = 'catalogue.xml',
|
||||||
source = ['wscript', 'common/waf.py'])
|
source = ['wscript', 'common/waf.py'])
|
||||||
ctx.install_files('${PREFIX}', 'catalogue.xml')
|
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')
|
static_dir = ctx.path.find_dir('common/html-coverpage/static')
|
||||||
ctx.install_files('${PREFIX}/static',
|
ctx.install_files('${PREFIX}/static',
|
||||||
static_dir.ant_glob('**'),
|
static_dir.ant_glob('**'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user