Here's the brand where it is working: https://github.com/jwulf/publican-redhat-video/ A breakdown of how it works: Javascript files are found here: https://github.com/jwulf/publican-redhat-video/tree/master/en-US/scripts Inject the javascript into the book html through xsl (there's some schema.org metadata thrown in there as a bonus) [from https://github.com/jwulf/publican-redhat-video/blob/master/xsl/html-single.xsl]: <!-- set the onload of the page --> <!-- http://www.sagehill.net/docbookxsl/BodyAtts.html --> <xsl:template name="body.attributes"> <xsl:attribute name="onLoad">skynetBookLoad()</xsl:attribute> <xsl:attribute name="itemscope"/> <xsl:attribute name="itemtype">http://schema.org/TechArticle</xsl:attribute> </xsl:template> <xsl:template name="user.header.content"> <meta itemprop="aboutProduct"> <xsl:attribute name="content"> <xsl:value-of select="concat(//productname[1], ' ', //productnumber[1])"/> </xsl:attribute> </meta> </xsl:template> <!-- inject our javascript into the footer --> <!-- http://www.sagehill.net/docbookxsl/InsertExtHtml.html --> <!-- Inject a div.skynetBookID with Product_Name/Book_Name This is used for cookies for the book --> <xsl:template name="user.footer.content"> <div class="skynetBookID"><xsl:value-of select="//productname[1]"/>/<xsl:value-of select="//title[1]"/>/<xsl:value-of select="//productnumber[1]"/></div> <xsl:choose> <xsl:when test="$embedtoc != 0"> <!-- web path --> <script type="text/javascript"> <xsl:attribute name="src"> <xsl:value-of select="concat($tocpath, '/../', $brand, '/', $langpath, '/scripts/jquery-1.4.2.min.js')"/> </xsl:attribute> </script> <script type="text/javascript"> <xsl:attribute name="src"> <xsl:value-of select="concat($tocpath, '/../', $brand, '/', $langpath, '/scripts/utils.js')"/> </xsl:attribute> </script> <script type="text/javascript"> <xsl:attribute name="src"> <xsl:value-of select="concat($tocpath, '/../', $brand, '/', $langpath, '/scripts/code-lang-switcher.js')"/> </xsl:attribute> </script> <script type="text/javascript"> <xsl:attribute name="src"> <xsl:value-of select="concat($tocpath, '/../', $brand, '/', $langpath, '/scripts/changelogs.js')"/> </xsl:attribute> </script> <script type="text/javascript"> <xsl:attribute name="src"> <xsl:value-of select="concat($tocpath, '/../', $brand, '/', $langpath, '/scripts/skynet-book.js')"/> </xsl:attribute> </script> </xsl:when> <xsl:otherwise> <!-- desktop path --> <script type="text/javascript"> <xsl:attribute name="src">Common_Content/scripts/jquery-1.4.2.min.js</xsl:attribute> </script> <script type="text/javascript"> <xsl:attribute name="src">Common_Content/scripts/utils.js</xsl:attribute> </script> <script type="text/javascript"> <xsl:attribute name="src">Common_Content/scripts/code-lang-switcher.js</xsl:attribute> </script> <script type="text/javascript"> <xsl:attribute name="src">Common_Content/scripts/changelogs.js</xsl:attribute> </script> <script type="text/javascript"> <xsl:attribute name="src">Common_Content/scripts/skynet-book.js</xsl:attribute> </script> </xsl:otherwise> </xsl:choose> </xsl:template>
Do we have an example of a book with multi language examples like this?
http://documentation-devel.engineering.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_MRG/3/html/Messaging_Programming_Reference/index.html content spec id: 8025
I'd like to go for a simpler structure in the XML. e.g. <informalexample role="switchery"> <programlisting langauge="Perl"> ... some perl code </programlisting> <programlisting langauge="C++"> ... some C++ code </programlisting> <programlisting langauge="Java"> ... some Java code </programlisting> </informalexample>
Added code language switch, including cookie to set default language. Example at: http://jfearn.fedorapeople.org/HTML5_Test/html/pref-Publican-Users_Guide-Introduction.html To ssh://git.fedorahosted.org/git/publican.git 1e53c5e..6652bcf devel -> devel
Tested https://bugzilla.redhat.com/show_bug.cgi?id=1092351#c3 sample on common-db5 brand. The generated example shows a tabbed code box where users can switch between the languages: http://file.bne.redhat.com/~ddomingo/tests/bz1092351/ Setting as VERIFIED.
A fix for this shipped in Publican 4.2.0.