iherman / respec2epub Goto Github PK
View Code? Open in Web Editor NEWPython based service to convert a respec document into EPUB3
License: Other
Python based service to convert a respec document into EPUB3
License: Other
The usage of os.path join and split may be a good approach to solve the current issue when producing a folder
Hello Ivan,
first of all: cool project :)
I was playing with the demo site:
https://labs.w3.org/epub-generator/
...using this Respec URL:
http://w3c.github.io/dpub-accessibility/
(works great)
The HTTP GET URL works fine too:
https://labs.w3.org/epub-generator/cgi-bin/epub-generator.py?type=html&url=http%3A%2F%2Fw3c.github.io%2Fdpub-accessibility
...but unfortunately there are no CORS headers included in the HTTP response, so I cannot fetch the application/epub+zip
payload from a web browser (that is to say, from XmlHttpRequest
).
Here's the list of HTTP headers returned by a curl
HEAD request:
$ curl --head "https://labs.w3.org/epub-generator/cgi-bin/epub-generator.py?type=html&url=http%3A%2F%2Fw3c.github.io%2Fdpub-accessibility"
HTTP/1.1 200 OK
Date: Thu, 10 Mar 2016 16:05:00 GMT
Server: Apache/2.2.22 (Debian)
Expires: Thu, 10 Mar 2016 16:05:00 GMT
Content-Disposition: attachment; filename=index.epub
Last-Modified: Thu, 10 Mar 2016 16:05:00 GMT
Content-Length: 145203
Content-Type: application/epub+zip
Strict-Transport-Security: max-age=15552015; preload
Public-Key-Pins: pin-sha256="cN0QSpPIkuwpT6iP2YjEo1bEwGpH/yiUn6yhdy+HNto="; pin-sha256="WGJkyYjx1QMdMe0UqlyOKXtydPDVrk7sl2fV+nNm1r4="; pin-sha256="LrKdTxZLRTvyHM4/atX2nquX9BeHRZMCxg3cf4rhc2I="; max-age=864000
So, I tried using a CORS proxy, unfortunately to no avail:
https://crossorigin.me/https://labs.w3.org/epub-generator/cgi-bin/epub-generator.py?type=html&url=http%3A%2F%2Fw3c.github.io%2Fdpub-accessibility
$ curl --head "https://crossorigin.me/https://labs.w3.org/epub-generator/cgi-bin/epub-generator.py?type=html&url=http%3A%2F%2Fw3c.github.io%2Fdpub-accessibility"
HTTP/2.0 500
server:cloudflare-nginx
date:Thu, 10 Mar 2016 16:07:56 GMT
content-type:text/html; charset=iso-8859-1
set-cookie:__cfduid=d2232775d992c99ef835d9fcfc48f8dd61457626075; expires=Fri, 10-Mar-17 16:07:55 GMT; path=/; domain=.crossorigin.me; HttpOnly
access-control-allow-origin:*
access-control-allow-credentials:false
access-control-allow-headers:Content-Type
expires:Fri, 11 Mar 2016 16:07:55 GMT
cf-ray:281805be638334fa-LHR
There are alternative CORS proxies, such as:
http://cors.io/?u=https%3A%2F%2Flabs.w3.org%2Fepub-generator%2Fcgi-bin%2Fepub-generator.py%3Ftype%3Dhtml%26url%3Dhttp%253A%252F%252Fw3c.github.io%252Fdpub-accessibility
...but unfortunately in this case the response content-type is incorrect.
So ideally, could https://labs.w3.org/epub-generator/cgi-bin/epub-generator.py itself be updated to emit CORS headers?
PS: I am just toying with the idea of using Readium to read ReSpec EPUBs directly from your HTTP URLs :)
Thanks!
The cover page refers to base.css in Assets. That has to change to be adapted to the new set up with css files
I was trying to export an EPUB version of https://w3c.github.io/jlreq/ , but got the following error:
Traceback (most recent call last):
File "/home/ivan/htdocs/cgi-bin/epub-generator.py", line 189, in
Generator().process()
File "/home/ivan/htdocs/cgi-bin/epub-generator.py", line 175, in process
wrapper = self.generate_ebook()
File "/home/ivan/htdocs/cgi-bin/epub-generator.py", line 163, in generate_ebook
logger=logger
File "/home/ivan/lib/python/rp2epub/doc2epub.py", line 84, in __init__
session = HttpSession(CONVERTER + url if is_respec else url, raise_exception=True, is_respec=is_respec)
File "/home/ivan/lib/python/rp2epub/utils.py", line 514, in __init__
handle_exception("There seems to be a problem with the spec generator service ('%s' should be tested separately)" % url)
File "/home/ivan/lib/python/rp2epub/utils.py", line 502, in handle_exception
raise R2EError(message)
R2EError: "There seems to be a problem with the spec generator service ('https://labs.w3.org/spec-generator/?type=respec&url=https://w3c.github.io/jlreq/' should be tested separately)"
See https://labs.w3.org/epub-generator/cgi-bin/epub-generator.py?type=respec&url=https%3A%2F%2Fw3c.github.io%2Fjlreq%2F for the error.
I'm not sure it is an issue of spec generator or epub generator, so filing an issue here first.
And relies on the exitence in Asset (whilst it is not there any more). This is in the header
The margin has disappeared with the new setup, but that may not work; it seems that iBook still needs it (like in the old days:-(
Trying to gen from http://w3c.github.io/manifest/ I get:
Epub Generator Exception
Traceback (most recent call last):
File "/home/ivan/htdocs/cgi-bin/epub-generator.py", line 176, in
Generator().process()
File "/home/ivan/htdocs/cgi-bin/epub-generator.py", line 162, in process
wrapper = self.generate_ebook()
File "/home/ivan/htdocs/cgi-bin/epub-generator.py", line 150, in generate_ebook
logger=logger
File "/home/ivan/lib/python/rp2epub/doc2epub.py", line 79, in __init__
session = HttpSession(CONVERTER + url if is_respec else url, raise_exception=True)
File "/home/ivan/lib/python/rp2epub/utils.py", line 386, in __init__
handle_exception("%s cannot be reached" % url)
File "/home/ivan/lib/python/rp2epub/utils.py", line 375, in handle_exception
raise R2EError(message)
R2EError: https://labs.w3.org/spec-generator/?type=respec&url=http://w3c.github.io/manifest/ cannot be reached
For the new setup with CSS the config files should be drastically reduced
The current style may really look crazy in an epub. Check it and possibly find a trick to change that...
Maybe worth moving the full TOC to the nav file (mainly if the TOC is itself encoded in a 'nav')
The current logic means that CSS files are retrieved twice: once when the import statements are extracted, and then again when the data is stored. This may be reduced...
The new setup for including css seems to work, but has only been tested on the new, 2016 TR style
It was really a temporary stupidity...
Look at the annotation protocol book, it contains, in the opf files, something like:
<item href="annotation-protocol/ https://w3c.github.io/test-results/annotation-protocol/all.xhtml" id="annotation-protocol- https:--w3c-github-io-test-results-annotation-protocol-all-xhtml" media-type="application/xhtml+xml"/>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.