7 Okt 2013

Using fancybox in yii without extension

There are several guides that help you use fancybox in yii, e.g. http://www.yiiframework.com/extension/fancybox/  or http://www.yiiframework.com/wiki/357/how-to-render-a-view-in-fancybox-using-ajax/ . But if you prefer a direct way, here's how to use fancybox in yii.

  1. Download fancybox from http://fancyapps.com/fancybox/. Extract in your base application directory, e.g. /fancybox
  2. Insert the following code in any view files:
  3. Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/fancybox/source/jquery.fancybox.pack.js');
    Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl.'/fancybox/source/jquery.fancybox.css');
    
  4. And add your image html code like:
  5. CHtml::link('', 'big.jpg', array('class'=>'myphotos', 'rel'=>'group1'));
    
  6. Finally
  7. <? php
    // in case you have not loaded jquery
    Yii::app()->clientScript->registerCoreScript("jquery");
    
    ?>
    $(document).ready(function() {
    
     /* This is basic - uses default settings */
     
     $("a.myphotos").fancybox();
     
     /* Using custom settings */
     
     $("a#inline").fancybox({
      'hideOnContentClick': true
     });
    
     /* Apply fancybox to multiple items */
     
     $("a.group").fancybox({
      'transitionIn' : 'elastic',
      'transitionOut' : 'elastic',
      'speedIn'  : 600, 
      'speedOut'  : 200, 
      'overlayShow' : false
     });
     
    });
    

3 Apr 2013

Installing webmin on Raspberry pi

Make sure you have installed apache. If not, do this command:

pi@raspberrypi ~ $ sudo apt-get install apache2

Download webmin, I prefer to get a debian package instead of other formats since I'm using Raspbian wheezy.

wget http://prdownloads.sourceforge.net/webadmin/webmin_1.620_all.deb

Install webmin:

pi@raspberrypi ~ $ sudo dpkg -i webmin_1.620_all.deb

 Selecting previously unselected package webmin.  
 (Reading database ... 62437 files and directories currently installed.)  
 Unpacking webmin (from webmin_1.620_all.deb) ...  
 dpkg: dependency problems prevent configuration of webmin:  
  webmin depends on libnet-ssleay-perl; however:  
  Package libnet-ssleay-perl is not installed.  
  webmin depends on libauthen-pam-perl; however:  
  Package libauthen-pam-perl is not installed.  
  webmin depends on libio-pty-perl; however:  
  Package libio-pty-perl is not installed.  
  webmin depends on apt-show-versions; however:  
  Package apt-show-versions is not installed.  
 dpkg: error processing webmin (--install):  
  dependency problems - leaving unconfigured  
 Errors were encountered while processing:  
  webmin  

Don't worry, we will resolve dependency with:

pi@raspberrypi ~ $ sudo apt-get -f install


 Reading package lists... Done  
 Building dependency tree  
 Reading state information... Done  
 Correcting dependencies... Done  
 The following extra packages will be installed:  
  apt-show-versions libapt-pkg-perl libauthen-pam-perl libio-pty-perl libnet-ssleay-perl  
 The following NEW packages will be installed:  
  apt-show-versions libapt-pkg-perl libauthen-pam-perl libio-pty-perl libnet-ssleay-perl  
 0 upgraded, 5 newly installed, 0 to remove and 4 not upgraded.  
 1 not fully installed or removed.  
 Need to get 503 kB of archives.  
 After this operation, 1,675 kB of additional disk space will be used.  
 Do you want to continue [Y/n]? Y  
 Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libnet-ssleay-perl armhf 1.48-1 [317 kB]  
 Get:2 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libauthen-pam-perl armhf 0.16-2 [31.2 kB]  
 Get:3 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libio-pty-perl armhf 1:1.08-1 [39.3 kB]  
 Get:4 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libapt-pkg-perl armhf 0.1.26+b1 [80.9 kB]  
 Get:5 http://mirrordirector.raspbian.org/raspbian/ wheezy/main apt-show-versions all 0.20 [34.9 kB]  
 Fetched 503 kB in 11s (45.4 kB/s)  
 Selecting previously unselected package libnet-ssleay-perl.  
 (Reading database ... 86030 files and directories currently installed.)  
 Unpacking libnet-ssleay-perl (from .../libnet-ssleay-perl_1.48-1_armhf.deb) ...  
 Selecting previously unselected package libauthen-pam-perl.  
 Unpacking libauthen-pam-perl (from .../libauthen-pam-perl_0.16-2_armhf.deb) ...  
 Selecting previously unselected package libio-pty-perl.  
 Unpacking libio-pty-perl (from .../libio-pty-perl_1%3a1.08-1_armhf.deb) ...  
 Selecting previously unselected package libapt-pkg-perl.  
 Unpacking libapt-pkg-perl (from .../libapt-pkg-perl_0.1.26+b1_armhf.deb) ...  
 Selecting previously unselected package apt-show-versions.  
 Unpacking apt-show-versions (from .../apt-show-versions_0.20_all.deb) ...  
 Processing triggers for man-db ...  
 Setting up libnet-ssleay-perl (1.48-1) ...  
 Setting up libauthen-pam-perl (0.16-2) ...  
 Setting up libio-pty-perl (1:1.08-1) ...  
 Setting up libapt-pkg-perl (0.1.26+b1) ...  
 Setting up apt-show-versions (0.20) ...  
 ** initializing cache. This may take a while **  
 Setting up webmin (1.620) ...  
 Webmin install complete. You can now login to https://raspberrypi:10000/  
 as root with your root password, or as any user who can use sudo  
 to run commands as root.  

After that, point your browser to https://YourRaspberryIP:10000 
That's it :).