SamplePackage

An example bitweaver package that is fully functional

Created by: spiderr, Last modification: 30 Mar 2009 (00:13 UTC) by Derek Simkowiak
Sample is a fully functional bitweaver package that demonstrates capabilities and best practices for building your own package that extends the bitweaver and Liberty CMS core. This package makes a great starting place to building your own package. Bear in mind, you are not *required* to follow this coding technique. A bare bones package only needs a directory and a bit_setup_inc.php file. However, many package developers will want to integrate nicely with other bitweaver packages, and utilize other packages' services like the LibertyPackage CMS core.

Sample is entirely community driven. It is suggested that you begin here as this is a good starting point for anyone wanting to cut their teeth on getting to know the bitweaver architecture.

To Download:


To get this to work on your system:


First, extract and copy the sample folder to your bitweaver root directory.

This package requires you to run the installer because it creates its own database. If you are interesed, there is more information about the installer on the InstallPackage page.

Go to Administration -> Kernel -> Packages

Across the top, you should see an "Install Packages" tab. Click that. At the bottom of the list there is a link to the installer - Not the "Activate bitweaver Packages" button! Look where it says "To install more packages, please run the installer to choose your desired packages". Click the word "installer".

Now you are at the Package Installation page. You should see the "sample" package all checked off and ready to go. Click on the "Install Packages" link at the bottom. The table "samples" will now be created in your database. When that is complete, click "continue with install", and BitWeaver will check for conflicts with other existing packages. If there are no conflicts, click on "Continue Install Process", and you will be at the "Installation is complete" page.

Click "Enter your bitweaver site" at the bottom, and the new Sample application should be active in the menu system. WaHoo!

For an exploration of these files, and how they work - visit the SamplePackageDissection page.

Use the Sample package as a place to start your own package

Here are some simple instructions you can use to quickly convert the sample package into a package you can use as a starting point for your own custom package. They are only for unix users.
A bash script based on these instructions to make packages is available in the sample package (included in the above download locations: sample/mkpackage.sh)

  1. Get a copy of the sample code and place it in your bitweaver root directory alongside all other package directories.

You can then either do the following:

  1. Rename the sample to a package for your choice, in our example "music" and change into your new directory:
    
    <?php
    mv sample music
    cd music
    ?>
  2. Case sensitive Search and Replace all occureneces of 'sample' with your package name:
    
    <?php
    find 
    . -name "*" -exec perl --wpe "s/sample/music/g" {} \;
    find . -name "*" -exec perl --wpe "s/SAMPLE/MUSIC/g" {} \;
    find . -name "*" -exec perl --wpe "s/Sample/Music/g" {} \;
    ?>
  3. Rename all the files containing 'sample' with your package name (not Ubuntu):
    
    <?php
    find 
    . -name "*sample*" -exec rename sample music {} \;
    find . -name "*Sample*" -exec rename Sample Music {} \;
    ?>
  4. Rename all the files containing 'sample' with your package name (on Ubuntu):
    
    <?php
    find 
    . -name "*sample*" -exec rename s/sample/music/ {} \;
    find . -name "*Sample*" -exec rename s/Sample/Music/ {} \;
    ?>

Or else you can:

  1. Run the mkpackage.sh script within the sample directory from your bitweaver root directory:
    
    <?php
    ./sample/mkpackage.sh music
    ?>
    which will do all of the above for you. If using Ubuntu, you must first edit it to use the s/old/new/ syntax shown above.

Finally no matter which route you took you need to:

  1. Run the package installer to install your new package and you are up and running!