Bug 839975 - RFE: scripts directory in brand
RFE: scripts directory in brand
Status: CLOSED CURRENTRELEASE
Product: Publican
Classification: Community
Component: publican (Show other bugs)
2.3
Unspecified Unspecified
high Severity high
: 3.1
: ---
Assigned To: Jeff Fearn
tools-bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-13 06:46 EDT by Joshua Wulf
Modified: 2014-10-19 19:01 EDT (History)
5 users (show)

See Also:
Fixed In Version: 3.1.0
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-02-05 22:40:53 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Joshua Wulf 2012-07-13 06:46:47 EDT
I'm creating brands that include javascript in the html. At the moment I'm putting the javascript files into the css directory in my brand. 

Could we have a scripts directory in Common_Content for putting script files?
Comment 1 Joshua Wulf 2012-09-06 08:32:59 EDT
.woff web fonts are another resource that I'm bundling in my brand
Comment 2 Joshua Wulf 2012-11-01 22:45:00 EDT
This will also need support for the relative pathing for desktop and web output - in my Brand xsl customization i'm injecting the <script> tag. The relative path for the scripts will be different depending on whether the book is being built for the centralised web version of the brand, or the decentralised desktop version of the brand.
Comment 4 Joshua Wulf 2012-12-19 01:29:00 EST
This worked in Publican 2, but stopped working in Publican 3. 

I need this to get the Portal issue https://bugzilla.redhat.com/show_bug.cgi?id=845806 addressed, and I also need it for the MRG 2.3 release in February 2013.
Comment 5 Joshua Wulf 2012-12-19 01:30:13 EST
^ "This" means bundling the javascript in the css directory. The css directory contents are no longer installed in the web version of the brand in Publican 3, so my brand's javascript files are not showing up on the server.
Comment 9 Jeff Fearn 2013-01-08 00:46:36 EST
This fix has been committed to the devel branch for inclusion in Publican 3.1.

Sample output assuming JS files are moved to en-US/scripts

$ rpm -qilp tmp/rpm/noarch/publican-redha* | grep -E 'scripts|css'
/usr/share/publican/Common_Content/redhat-video/en-US/css
/usr/share/publican/Common_Content/redhat-video/en-US/css/lang.css
/usr/share/publican/Common_Content/redhat-video/en-US/css/menu.css
/usr/share/publican/Common_Content/redhat-video/en-US/css/overrides.css
/usr/share/publican/Common_Content/redhat-video/en-US/scripts
/usr/share/publican/Common_Content/redhat-video/en-US/scripts/code-lang-switcher.js
/usr/share/publican/Common_Content/redhat-video/en-US/scripts/jquery-1.4.2.min.js
/usr/share/publican/Common_Content/redhat-video/en-US/scripts/modernizr.js
/usr/share/publican/Common_Content/redhat-video/en-US/scripts/skynet-book.js
/var/www/html/docs/redhat-video/en-US/css
/var/www/html/docs/redhat-video/en-US/css/lang.css
/var/www/html/docs/redhat-video/en-US/css/menu.css
/var/www/html/docs/redhat-video/en-US/css/overrides.css
/var/www/html/docs/redhat-video/en-US/scripts
/var/www/html/docs/redhat-video/en-US/scripts/code-lang-switcher.js
/var/www/html/docs/redhat-video/en-US/scripts/jquery-1.4.2.min.js
/var/www/html/docs/redhat-video/en-US/scripts/modernizr.js
/var/www/html/docs/redhat-video/en-US/scripts/skynet-book.js

FYI the regression of non CSS files being dropped is also fixed, so if the JS files are left in the CSS directory they will be installed  in to /var/www/html/docs/redhat-video/en-US/css/
Comment 10 Joshua Wulf 2013-01-08 01:41:00 EST
What about the pathing in the xsl to include the JavaScript? The path is different for the web and desktop builds.

Currently I have the following, for example, in html-single.xsl:

<xsl:template name="user.footer.content">
   <div class="skynetBookID"><xsl:value-of select="//productname[1]"/>/<xsl:value-of select="//title[1]"/></div>
   <script src="Common_Content/css/modernizr.js"></script>
   <script src="Common_Content/css/jquery-1.4.2.min.js"></script>
   <script src="Common_Content/css/code-lang-switcher.js"></script>
   <script src="Common_Content/css/skynet-book.js"></script>
</xsl:template>

The script src value should be different for the web package (where the .js files are in the consolidated location path) and the desktop package (where the .js files are in the book directory).

So it seems like it needs a variable there to inject the correct path when it is being built.
Comment 11 Jeff Fearn 2013-01-08 02:08:34 EST
(In reply to comment #10)
> What about the pathing in the xsl to include the JavaScript? The path is
> different for the web and desktop builds.

You should already be able to do this. Checkout the logic in the 'template name="head.content"' in xhtml-common.xsl. You should have access to all the variables referenced in there.

So web path:

<xsl:choose>
 <xsl:when test="$embedtoc != 0">
  <!-- web path -->
   <script type="text/javascript"><xsl:attribute name="src"><xsl:value-of select="$tocpath"/>/../<xsl:value-of select="$brand"/>/scripts/$js_file</xsl:attribute></script>
 </xsl:when>
 <xsl:otherwise>
  <!-- desktop path -->
<script type="text/javascript"><xsl:attribute name="src">/usr/share/publican/Common_Content/<xsl:value-of select="$brand"/>/scripts/$js_file</xsl:attribute></script>

Untested but you get the idea.
Comment 12 xuezhi ma 2013-01-31 01:49:49 EST
Verify version: publican-3.1.0-0.el6eng.noarch ->PASS

Verify steps:
1. $publican create_brand --name=test --lang=en-US
2. $ cd publican-test/en-US
3. $ mkdir scripts, then copy test1.js and test1.css to this directory.
4. copy test2.js and test2.css to en-US/css/ directory.
5. $publican package --binary --lang=en-US
6. rpm -qilp tmp/rpm/noarch/publican-test* | grep -E 'scripts|css'

Actual results:
1. js files and css files in css directory still in that directory.
2. js files and css files in scripts directory still in that directory.

Note You need to log in before you can comment on or make changes to this bug.