Bug 4048 - CSS and JS libs must be outside of translated paths
Summary: CSS and JS libs must be outside of translated paths
Status: RESOLVED DUPLICATE of bug 8623
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Owen Leonard
QA Contact:
URL:
Keywords:
Depends on: 4503
Blocks: 2774 3146
  Show dependency treegraph
 
Reported: 2010-01-18 09:08 UTC by Nahuel Angelinetti
Modified: 2012-08-13 10:09 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
follow-up: Fix favicon path for doc-head-close-receipt.inc (1.22 KB, patch)
2012-05-15 14:41 UTC, Julian Maurice
Details | Diff | Splinter Review
follow-up: changes for all .tt and .inc files (167.85 KB, patch)
2012-05-15 15:00 UTC, Julian Maurice
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Cormack 2010-05-21 01:22:33 UTC


---- Reported by nahuel.angelinetti@biblibre.com 2010-01-18 09:08:56 ----

Like the yui library, this must be outside of the translated path, and accessible via intranet and opac at the same url.
YUI must be updated too.



---- Additional Comments From oleonard@myacpl.org 2010-01-19 15:16:12 ----

A couple of questions:
 - Will jquery libs be moved as well?
 - Will the yuipath system preference be updated to point to the new YUI version? 



---- Additional Comments From henridamien@koha-fr.org 2010-01-19 21:42:27 ----

imho, jquery should be also language independent now. So should follow yui.

About yui update, it seems that the way templates are coded makes yui update a real pain. 




--- Bug imported by chris@bigballofwax.co.nz 2010-05-21 01:22 UTC  ---

This bug was previously known as _bug_ 4048 at http://bugs.koha.org/cgi-bin/bugzilla3/show_bug.cgi?id=4048

Actual time not defined. Setting to 0.0

Comment 1 Owen Leonard 2010-07-06 16:13:03 UTC
I don't see any sign of this patch, so I'm removing the PATCH-sent status and considering this a new bug again.
Comment 2 Owen Leonard 2010-10-01 20:05:31 UTC
I've completed a draft of this change, modifying both the OPAC and staff client. Testers welcome: http://gitorious.org/koha-dev/koha-dev/commits/ip-Bug-4048-js-libs-path-2010-09-17
Comment 3 Owen Leonard 2011-10-26 13:40:45 UTC
And again, updated for latest master:

http://gitorious.org/koha-dev/koha-dev/commits/ip-bug-4048-js-css-libs-path-2011-10-25
Comment 4 Owen Leonard 2012-02-24 20:24:05 UTC
Even without trying to change everything in one go these changes are too large to be attached as a patch. The updated branch is here:

http://gitorious.org/koha-dev/koha-dev/commits/ip-bug-4048-js-css-libs-path-2012-02-24

Here's the commit message:

    This patch is an attempt to tackle Bug 4048 in a more incremental
    way. As suggested by Paul, this patch leaves in place a copy of
    the CSS and JS files in their original location to allow
    full implementation to be gradual.
    
    1. Template.pm has been modified to pass an "interface" variable
       to the templates so that references to [% themelang %] can be
       replaced with [% interface %]/[% theme %] ("intranet-tmpl/prog")
       where appropriate.
    
    2. The staff client's css, js, and lib directories have been copied
       to intanet-tmpl/prog where the img directory is.
    
    3. The staff client's primary document header include files have
       been updated with the new paths. These are the files that
       define the paths to all the core CSS and JS files.
    
    4. Relative image paths in the moved CSS files have been corrected to
       point to the right directory.
    
    TO TEST:
    
    After applying the patch, look at any page in the staff client.
    If the CSS paths are correct everything should look normal. View
    source to confirm that core assets are being pulled from the new
    location. If you use Firefox and have Firebug enabled it should
    report no "NetworkError: 404" errors.
Comment 5 Jared Camins-Esakov 2012-02-25 21:44:57 UTC
I tested this, and it works perfectly for *core* JS and CSS in the staff client. A signed off patch can be found at: https://github.com/jcamins/koha/tree/bug_4048_qa
Comment 6 Ian Walls 2012-03-12 11:25:57 UTC
This patch, since it adds files copied outside git, breaks our git blame for all the intranet CSS and JS.

Alternatives:  git mv all the files as necessary, then add symlinks for the old directories

Moving to "In Discussion" while we work out what approach will be the best for this fix.
Comment 7 Owen Leonard 2012-03-12 12:38:39 UTC
Good point about the git blame. Since the goal is to eventually git rid of the CSS and JS inside the language directories perhaps it's enough to git mv the files and then copy them back to the old location? The files in the proper place would have correct info and the others would be only temporary.
Comment 8 Julian Maurice 2012-03-20 10:07:57 UTC
Hmm I think git blame is not the problem. I tried to 'git mv' a file (mainpage.pl to oldmainpage.pl), commit, then add a change (remove strict and warnings pragma in favor of Modern::Perl) commit, and then git blame oldmainpage.pl shows me this:

...
93d4c90a mainpage.pl    (Chris Cormack  2011-11-21 20:26:01 +1300 19) # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
13f6840c mainpage.pl    (rych           2007-03-09 20:33:59 +0000 20) 
6902a023 oldmainpage.pl (Julian Maurice 2012-03-20 10:56:51 +0100 21) use Modern::Perl;
13f6840c mainpage.pl    (rych           2007-03-09 20:33:59 +0000 22) use CGI;
1ca8a9ce mainpage.pl    (hdl            2007-04-24 13:56:06 +0000 23) use C4::Output;
...

History of the file is preserved. But git log -p oldmainpage shows me only two commits (1 for the move, 1 for the modif)
Is this really a problem which must prevent the patch to be pushed ?
Comment 9 Owen Leonard 2012-04-26 16:59:17 UTC
Yet another updated branch here: http://gitorious.org/koha-dev/koha-dev/commits/ip-bug-4048-css-js-libs-2012-04-24

Revised commit message:

        This patch is an attempt to tackle Bug 4048 in a more incremental
        way. As suggested by Paul, this patch leaves in place a copy of
        the CSS and JS files in their original location to allow
        full implementation to be gradual.
    
        1. Template.pm has been modified to pass an "interface" variable
           to the templates so that references to [% themelang %] can be
           replaced with [% interface %]/[% theme %] ("intranet-tmpl/prog")
           where appropriate.
    
        2. The staff client's css, js, and lib directories have been
           'git mv'ed to intanet-tmpl/prog where the img directory is.
           'git mv' was used to preserve the git history of the files
           which are in their correct location.
    
        3. The staff client's css, js, and lib directories have been
           copied back to their original location in order to provide
           a fallback as we make corrections to individual templates.
           These files have lost their git history, but will ultimately
           be deleted anyway.
    
        4. The staff client's primary document header include files have
           been updated with the new paths. These are the files that
           define the paths to all the core CSS and JS files.
    
        5. Relative image paths in the moved CSS files have been corrected to
           point to the right directory.
    
        TO TEST:
    
        After applying the patch, look at any page in the staff client.
        If the CSS paths are correct everything should look normal. View
        source to confirm that core assets are being pulled from the new
        location. If you use Firefox and have Firebug enabled it should
        report no "NetworkError: 404" errors.
Comment 10 Julian Maurice 2012-05-15 14:41:19 UTC Comment hidden (obsolete)
Comment 11 Julian Maurice 2012-05-15 15:00:26 UTC
Created attachment 9589 [details] [review]
follow-up: changes for all .tt and .inc files

This patch make all necessary changes in .tt and .inc files. (intranet interface only since Owen's patch moves only intranet files)

Files have been modified using this command:

git grep -l themelang | grep -v 'opac-tmpl' | grep '(\.inc|\.tt)$' | tr '\n' ' ' | xargs sed -i 's/\[% themelang %\]/[% interface %]\/[% theme %]/g'

I checked all modifications manually and replaced [% interface %]/[% theme %] by [% themelang %] where needed.

You can test by removing completely koha-tmpl/intranet-tmpl/prog/en/(lib|css|js) repertories and display any page in staff interface
Comment 12 Katrin Fischer 2012-06-17 07:26:32 UTC
I checked out Owen's branch and applied Julian's patches on top of those. I had to fix some conflicts in the second patch, which I hopefully did right.
I then deleted the lib, css and js directories from intranet-tmpl.

Following problems have been found while testing:

1) http://localhost:8080/cgi-bin/koha/about.pl > Tabs are broken

2) http://localhost:8080/cgi-bin/koha/admin/systempreferences.pl > New preference button broken

3) http://localhost:8080/cgi-bin/koha/admin/branches.pl > New buttons are broken

4) http://localhost:8080/cgi-bin/koha/admin/itemtypes.pl?op=add_form&itemtype=BK > tabs layout slightly broken, still functional

5) http://localhost:8080/cgi-bin/koha/admin/authorised_values.pl > toolbar broken

6) http://localhost:8080/cgi-bin/koha/admin/authorised_values.pl?op=add_form&id=21&offset=0 > tabs layout slightly broken, still functional

7) http://localhost:8080/cgi-bin/koha/cataloguing/addbooks.pl > toolbar broken

8) http://localhost:8080/cgi-bin/koha/cataloguing/addbiblio.pl > layout of framework and tabs broken

9) http://localhost:8080/cgi-bin/koha/authorities/auth_finder.pl?authtypecode=PERSO_NAME&index=tag_100_subfield_a_320307_288334&value_main= > autocomplete of auth-finder plugin broken

Stopping here, I think some problems have the same source, but more work is needed. I think including this in Koha soon would be good, because there is still plenty of time until the next release, so bugs could be found and fixed until then.
Comment 13 Owen Leonard 2012-07-23 20:04:59 UTC
Revised again following major changes to jQuery and YUI assets. The correction in Julian's first patch has been incorporated. Yet another updated branch here: http://gitorious.org/koha-dev/koha-dev/commits/ip-bug-4048-css-js-libs-2012-04-24

        This patch is an attempt to tackle Bug 4048 in a more incremental
        way. As suggested by Paul, this patch leaves in place a copy of
        the CSS and JS files in their original location to allow
        full implementation to be gradual.
    
        1. Template.pm has been modified to pass an "interface" variable
           to the templates so that references to [% themelang %] can be
           replaced with [% interface %]/[% theme %] ("intranet-tmpl/prog")
           where appropriate.
    
        2. The staff client's css, js, and lib directories have been
           'git mv'ed to intanet-tmpl/prog where the img directory is.
           'git mv' was used to preserve the git history of the files
           which are in their correct location.
    
        3. The staff client's css, js, and lib directories have been
           copied back to their original location in order to provide
           a fallback as we make corrections to individual templates.
           These files have lost their git history, but will ultimately
           be deleted anyway.
    
        4. The staff client's primary document header include files have
           been updated with the new paths. These are the files that
           define the paths to all the core CSS and JS files.
    
        5. Relative image paths in the moved CSS files have been corrected to
           point to the right directory.
    
        TO TEST:
    
        After applying the patch, look at any page in the staff client.
        If the CSS paths are correct everything should look normal. View
        source to confirm that core assets are being pulled from the new
        location. If you use Firefox and have Firebug enabled it should
        report no "NetworkError: 404" errors.
Comment 14 Kyle M Hall (khall) 2012-08-03 17:08:08 UTC
I'm afraid there are a huge number of conflicts when I attempted to apply. Even using git am -3.
Comment 15 Owen Leonard 2012-08-13 10:09:43 UTC

*** This bug has been marked as a duplicate of bug 8623 ***