Bug 839975 - RFE: scripts directory in brand
Summary: RFE: scripts directory in brand
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Publican
Classification: Community
Component: publican
Version: 2.3
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: 3.1
Assignee: Jeff Fearn 🐞
QA Contact: tools-bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-07-13 10:46 UTC by Joshua Wulf
Modified: 2014-10-19 23:01 UTC (History)
5 users (show)

Fixed In Version: 3.1.0
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-02-06 03:40:53 UTC
Embargoed:


Attachments (Terms of Use)

Description Joshua Wulf 2012-07-13 10:46:47 UTC
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 12:32:59 UTC
.woff web fonts are another resource that I'm bundling in my brand

Comment 2 Joshua Wulf 2012-11-02 02:45:00 UTC
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 06:29:00 UTC
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 06:30:13 UTC
^ "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 05:46:36 UTC
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 06:41:00 UTC
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 07:08:34 UTC
(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 06:49:49 UTC
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.