[ 5 posts ]

sjJNL

  • Username: sjJNL
  • Joined: Thu Jul 08, 2010 6:58 am
  • Posts: 42
  • GitHub: sjJNL
  • Gists: sjJNL
  • Offline
  • Profile

YUI combo loader and YAHOO CDN

Post Posted: Wed Jun 27, 2012 10:46 am
+0-
I am using the following components from YUI3 library.

"gallery-aui-carousel"
"reversing an animation"

When I link to yui-min.js in my examples, it of course loads (JS & CSS) files from YAHOO CDN.

What is the simplest way to load these files locally? Can I load these files like we did in YUI2? Plain and Simple.

I have read a lot of articles all over the web related to loading files and I am totally confused.

Could anybody direct me to the best resource on this?

Daniel Ji

  • Username: humblepie
  • Joined: Tue Feb 28, 2012 10:30 am
  • Posts: 147
  • GitHub: humblepie
  • Gists: humblepie
  • Offline
  • Profile

Re: YUI combo loader and YAHOO CDN

Post Posted: Wed Jun 27, 2012 11:14 am
+0-
Hey sj :)

Yeah, what you're trying to do is load gallery modules locally, which is a bit trickier. I have a code snippet I created a while ago that was used to load YUI2 and Gallery modules.

Basically, you need to download the galleries you want locally and point YUI to use that local file(s). Anywhere you see '../..' you'd have to change to where you have your files at.

I forget the exact directory structure you get w/ the YUI Gallery files. But atleast with YUI2 and YUI3, you download a sizeable zip file and all you want from there is /build directory.

Here's a code sample

Code:
<script type="text/javascript">
    var YUI3_CONFIG_OBJ = {
        base: '../../../web/scripts/yui/3.5.0pr2/build/',
        combine: false,
        groups: {
            yui2: {
                combine: false,
                base: '../../../web/scripts/yui2in3/2.9.0/build/',
                patterns: {
                    'yui2-': {
                        configFn: function(me) {
                            if (/-skin|reset|fonts|grids|base/.test(me.name)) {
                                me.type = 'css';
                                me.path = me.path.replace(/\.js/, '.css');
                                me.path = me.path.replace(/\/yui2-skin/, '/assets/skins/sam/yui2-skin');
                            }
                        }
                    }
                }
            }
            ,
            gallery: {
                combine: true,
                base: '?action=1&mod=',
                comboBase: '?action=1&',
                root: 'mod=',
                patterns: {
                    'gallery-': {
                        configFn: function(me) {
                            if (/-skin/.test(me.name)) {
                                me.type = 'css';
                                me.path = me.path.replace(/\.js/, '.css');
                                me.path = me.path.substring(0, me.path.lastIndexOf('/')) + '/css' + me.path.substring(me.path.lastIndexOf('/'));
                            }
                        }
                    }
                }
            }
        }
    };
    YUI(YUI3_CONFIG_OBJ).use('event', 'yui2-dragdrop', 'yui2-datatable', function (Y) {

        var YAHOO = Y.YUI2;
    ....

sjJNL

  • Username: sjJNL
  • Joined: Thu Jul 08, 2010 6:58 am
  • Posts: 42
  • GitHub: sjJNL
  • Gists: sjJNL
  • Offline
  • Profile

Re: YUI combo loader and YAHOO CDN

Post Posted: Fri Jun 29, 2012 12:51 pm
+0-
Alright, after reading your reply and researching a bit, I got the yui-core to work locally.

But, I am unable to get the yui-gallery modules to work locally

The code I used is:

<script type="text/javascript">
YUI_config = {
filter: "raw",
comboBase: "/combo?",
root: "static/js/yui3/build/",
base: "/static/js/yui3/build/",
combine: false,
//insertBefore: "styleoverrides",
groups: {
// set up for locally served gallery
gallery: {
combine: false,
base: "/static/js/yui3-gallery/build/",
root: "static/js/yui3-gallery/build/",
comboBase: "/combo?",
patterns: {
"gallery-": {},
"gallerycss-": { type: "css" }
}
}
}
};
</script>

I can see in Firebug, the path of the gallery-aui-carousel is displaced by a "/" in the front:
/static/js/yui3-gallery/build/gallery-aui-carousel/gallery-aui-carousel.js

Instead, it should be :
static/js/yui3-gallery/build/gallery-aui-carousel/gallery-aui-carousel.js

What am I missing here?

Daniel Ji

  • Username: humblepie
  • Joined: Tue Feb 28, 2012 10:30 am
  • Posts: 147
  • GitHub: humblepie
  • Gists: humblepie
  • Offline
  • Profile
Tags:

Re: YUI combo loader and YAHOO CDN

Post Posted: Mon Jul 02, 2012 5:57 pm
+0-
Try removing comboBase for the main config and the gallery group - that shouldn't be needed (unless you really are using your own combo loader)

Daniel Ji

  • Username: humblepie
  • Joined: Tue Feb 28, 2012 10:30 am
  • Posts: 147
  • GitHub: humblepie
  • Gists: humblepie
  • Offline
  • Profile

Re: YUI combo loader and YAHOO CDN

Post Posted: Wed Aug 22, 2012 9:57 am
+0-
So I finally had a chance to actually get the YUI configured to load gallery modules from a local source. This is how it worked for me.

Download the entire gallery https://github.com/yui/yui3-gallery (just like how you download the entire YUI3 codebase). Point the YUI config to use the gallery as a group as shown below:

Code:
var YUI3_CONFIG_OBJ = {
        base: '../../../main/webapp/web/scripts/yui/3.6.0/build/',
        combine: false,
        groups: {
            gallery: {
                base: '../../../main/webapp/web/scripts/yui-gallery/build/',
                patterns: {
                    "gallery-":    {},
                    "gallerycss-": { type: "css" }
                }
            }
        }
    };
    YUI(YUI3_CONFIG_OBJ).use('gallery-clipboard', function (Y) {
        ...
    });


With this setup, I was able to use the gallery-clipboard module just fine. As reference here are some links on this topic.

https://gist.github.com/943498
http://www.yuiblog.com/blog/2010/05/27/ ... o-offline/
  [ 5 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum