Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds

How-To Tutorials - Web Development

1802 Articles
article-image-enhancing-your-math-teaching-using-moodle-19-part-2
Packt
06 Jan 2010
4 min read
Save for later

Enhancing Your Math Teaching using Moodle 1.9: Part 2

Packt
06 Jan 2010
4 min read
Uploading to SlideShare Navigate your browser to http://slideshare.net. You'll need a SlideShare account. Once you've logged in you'll be able to upload your presentation: Select My Slidespace from the menu at the top of the page: Click on the Upload your first slideshow now link: Use the Upload page to choose your presentation and upload it to SlideShare: Once the file is uploaded, you can specify how it can be shared. Note that you can choose to make the presentation private (you don't have to make it available to the entire world): When you are done with the details, click on the Publish button. The presentation needs to be converted so that SlideShare can display it correctly. This can take a while, but you can check the status to see how SlideShare is getting on: Once the presentation has been converted, it's ready to view: That's it! The presentation is online and ready to go. Here are just a few of the advantages of using SlideShare to include your presentation in a Moodle course: Your students may not have PowerPoint installed on their computers nor be aware of the special player they can download (check out the Microsoft website for details). That's no problem! SlideShare will play the presentation for them. You don't have to worry about file sizes. The presentation is stored on SlideShare's computers and not in your Moodle. Using SlideShare's built-in tools, it's easy to create an audio commentary (more on this in the next section). But there can be disadvantages. For example, I tried making my presentation more engaging and entertaining by including animations (which is good if you are a visual/spatial learner). However, in SlideShare those animations no longer work. So, how do you actually include a SlideShare presentation in a Moodle course? Let's do this now: SlideShare provides a fragment of web page code along with each presentation: Right-click on the code, and choose Select All followed by Copy. In your Moodle course, you can include the slideshow using the HTML editor. I'm going to include the presentation on a Moodle web page. Click on the Toggle HTML Source button: Cursor to the end of the page's HTML code, right-click and select Paste: Click on the Toggle HTML Source button again and the slideshow gets displayed in the editor: It's that simple! Look for embedded code in your favorite content sharing websites (for example, YouTube). Audio commentaries and SlideShare—slidecasts We've already seen how we can record an audio commentary using Audacity. I've mentioned that you can create an audio commentary (or slidecast) using SlideShare. Let's do that now. I can use the recording I made previously to narrate the presentation uploaded to SlideShare: Return to your my slidespace area. Click on the Edit link under your presentation: On the Edit Slideshow Details page, click on the Create Slidecast tab: The Create Slidecast page is displayed. As the instructions on this page recommend, you will need to upload your commentary to the Internet. You won't be able to use Moodle, as your course files area isn't accessible outside of Moodle (that's one of Moodle's vital security features). I'm going to upload my narration to the Internet Archives You'll need a registered account to do this. Simply follow the instructions to upload your file: Copy the link to the audio file to the Create Slidecast page (if you are using the Internet Archive, then the individual audio files are listed at the bottom of the archive page). Click on the Link mp3 to slideshow button: Once the audio is processed, the Synchronization Tool is displayed. Use the tool to associate a slide with the correct fragment of audio: Once you are happy with your new slidecast, click on the Save & Publish button in the bottom-right corner of the page: Return to your My Slidespace page. Click on your presentation. You will now see a note in the corner of the presentation: That's it. We're done! Before we leave our discussion of SlideShare, make a note of the SlideShare sidebar. If you've more than one presentation in your course, it can make finding the right presentation easier for your students. Visit http://www.slideshare.net/widgets/blogbadge for more details.
Read more
  • 0
  • 0
  • 1506

article-image-building-form-applications-joomla-using-ck-forms
Packt
05 Jan 2010
4 min read
Save for later

Building Form Applications in Joomla! using CK Forms

Packt
05 Jan 2010
4 min read
(For more resources on Joomla!, see here.) Add a quick survey  form to your Joomla site Dynamic web application often means database at the back-end. It not only takes data from the database and shows, but also collects data from the visitors. For example, you want to add a quick survey into your Joomla! Site. Instead of searching for different extensions for survey forms, you can quickly build one survey form using an extension named CK Forms. This extensions is freely available for download at http://ckforms.cookex.eu/download/download.php. For building a quick survey, follow the steps below: Download CK Forms extension from http://ckforms.cookex.eu/download/download.php and install it from Extensions | Install/Uninstall screen in Joomla! Administration area. Once installed successfully, you see the component CK Forms in Components menu. Select Components | CK Forms and you get CK Forms screen as shown below: For creating a new form, click on New icon in the toolbar. That opens up CK Forms: [New] screen. In the General tab, type the name and title of the form. The name should be without space, but title can be fairly long and with spaces. Then select Yes in Published field if you want to show the form now. In Description field, type a brief description of the form which will be displayed before the form. In Results tab, select Yes in Save result field. This will store the data submitted by the form into database and allow you to see the data later. In Text result field, type the text that you want to display just after submission of the form. In Redirect URL field, type the URL of a page where the user will be redirected after submitting the form. In E-mail tab, select Yes in Email result field, if you want the results of the forms to be e-mailed to you. If you select Yes in this field, provide mail-to, mail cc, and Mail BCC address. Also specify subject of the mail in Mail subject field. Select Yes in Include fileupload file field if you want the uploaded file to be mailed too. If an e-mail field is present in the form and the visitor submits his/her e-mail address, you can send an acknowledgement on receiving his/her data through e-mail. For sending such receipt messages, select Yes in E-mail receipt field. Then specify e-mail receipt subject and e-mail receipt text. You can also include the data and file submitted via the form with this receipt e-mail. For doing so, select Yes in both Include data and Include fileupload file fields. In Advanced tab, you can specify whether you want to use Captcha or not. Select Yes in Use Captcha field. Then type some tips text in Captcha tips text, for example, 'Please type the text shown in the image'. You can also specify error texts in Captcha custom error text field. In Uploaded files path field, you can specify where the files uploaded by the users will be stored. The directory mentioned here must be writable. You can also specify the maximum size of uploaded file in File uploaded maximum size field. To display Powered by CK Forms text below the form, select Yes in Display "Powered by" text field. In Front-end display tab, you can choose to display IP address of the visitor. You can view help on working with CK Forms by clicking on Help tab. After filling up all the fields, click on Save icon in the toolbar. That will save the form and take you to CK Forms screen. Now you will see the newly created form listed in this screen.
Read more
  • 0
  • 0
  • 11906

article-image-calendaring-plone-3-education
Packt
31 Dec 2009
6 min read
Save for later

Calendaring with Plone 3 for Education

Packt
31 Dec 2009
6 min read
(For more resources on Plone, see here.) The techniques in this article are applicable in many organizational schemes. We present one common arrangement as an example: a top-level folder where visitors can browse the highest-profile events on the site. Show events on a calendar Plone's out-of-the-box Events folder provides a basic way to find events: it displays them in a chronological list broken into pages of 20 each. While fine for simple cases, this is cumbersome for visitors who want to look at events for a certain future date. Part of our goal is to set up a monthly calendar to make this common case easy: Our first step toward the monthly calendar is to replace Plone's stock Events folder. Out of the box, it holds individual events along with a summarizing collection that acts as its front page. If you don't need a drill-down way of browsing your events by subject—for example, if you have so few that they all fit comfortably on a calendar like the above—you can leave the default Events folder in place. Otherwise, follow the instructions below to replace it with a standalone collection; this will interact better with Plone's navigation portlet, which we will use to implement the drilldown browsing. If you choose to stick with the stock Events folder, you may still wish to adjust the criteria of its inner collection as described in the following: First, delete the Events folder. Replace it with a new collection called "Events". Give it an Item Type criterion, and tell it to pull in everything of the type Event. The original Events collection had a Start Date criterion to keep past events off the page. We won't need that, since the calendar view we are about to apply keeps past events tucked away implicitly—and we do want the ability to see old events when we navigate to previous months. The original collection also had a State criterion that limited it to showing published events. If you need only to hide unpublished events from visitors, then you can dispense with this: the internal search routines used by the collection will naturally show only what the current user has permission to see. Preventing a common contributor errorOften, a less proficient contributor will add an event, see it on his or her own calendar, and move on, neglecting to publish it. Adding the State criterion can serve as a reminder, preventing the event from appearing until properly published. The downside is that it makes the calendar useless for intranets: Events that aren't publicly visible will never show up. But if you have no non-public events to list, consider recreating the State criterion. If you never want to show access-controlled events on the main calendar add a State criterion limiting the collection to published items. The Events collection is finished. Next, we apply a monthly calendar view to our data. Meet Plone4Artists Calendar Plone's built-in event listings are rather basic. We need to do special tricks with collections and default views just to sort them in chronological order. At best, this is several extra clicks, and, at worst, it can confuse your less technical content contributors. A third-party product called Plone4Artists Calendar makes this easy and gives us several other capabilities to boot. Plone4Artists Calendar is the current frontrunner in the Plone calendaring space. It provides... Daily, weekly, monthly, and a few other calendar-like views for folders and collections Rudimentary recurring event support Hooks for pulling events from other systems in realtime, with a bit of coding Don't let the name "Plone4Artists" put you off if you aren't an artist; though the Plone4Artists suite of products came out of a project to provide artist community web sites, there's nothing particularly artist-centric about them. In fact, there has been discussion about renaming them. The runner up: CalendarXThe other Plone calendar worth considering is CalendarX, whose most recent release at the time of this writing is 0.9.1. 0.9.0 was the first update to the product since since 2005 and represents a major refit. Its ancient data-modeling internals were replaced with a modern Archetypes implementation, and one no longer needed to venture into the ZMI to do simple configuration. Speaking of configuration, CalendarX exposes a lot of it: 6 tabs packed with options for tweaking calendar format, event display, widgets, and more. There are 57 options alone regarding its CSS cosmetics. If you need a specific look and aren't comfortable writing your own CSS or template code, CalendarX may be the ticket.However, be warned that CalendarX has a history of being sporadically maintained. It lacked Plone 3 compatibility for a long time, and compatibility work began only when a group of stranded Plone 2.5 users at Pennsylvania State University put a week of development work toward it. Its internals still hold a lot of legacy that may prove difficult to maintain as Plone evolves.Plone4Artists Calendar, on the other hand, is a simpler product—both inside and outside and with all the good and bad that entails—and the winds of further community effort are blowing in its direction. Its maintainable design and the willingness of developers to work on it make it the solution least likely to leave you stranded; this is why it is our recommendation in this article. Install Plone4Artists Calendar Before we can make use of its views, we need to install the product—actually, two products and several supporting packages. Weave these directives into the proper sections of your buildout.cfg... [buildout]...other directives...eggs = ...other eggs here... p4a.plonecalendar p4a.ploneevent[instance]...other directives...zcml = ...other ZCML listings here... # Plone4Artists Calendar doesn't support Plone 3.3's auto-ZCMLloading as of 2.0a2. p4a.plonecalendar-meta p4a.plonecalendar p4a.ploneevent[productdistros]recipe = plone.recipe.distrosurls =http://plone.org/products/calendaring/releases/0.4/calendaring-0-4-0.tgz ...run buildout, restart Zope/Plone, and install the Plone4ArtistsCalendar (p4a.plonecalendar) and Recurring Events (p4a.ploneevent) products in Site Setup → Add-on Products. Now that everything is installed, we apply a monthly calendar view to the Events collection: Navigate back to the Events collection, and choose Calendar from the new Sub-types menu. If it isn't already selected, choose Month view from the Display menu. Presto—we have a monthly calendar showing every event on our site.
Read more
  • 0
  • 0
  • 7614

article-image-including-google-maps-your-posts-using-apache-roller-40
Packt
31 Dec 2009
5 min read
Save for later

Including Google Maps in your Posts Using Apache Roller 4.0

Packt
31 Dec 2009
5 min read
Google Maps, YouTube, and SlideShare There are a lot of Internet and web services which you can use along with your blog to make your content more interesting for your viewers. With a good digital camera and video production software, you can make your own videos and presentations quickly and easily, and embed them in your posts with just a few clicks! For example, with Google Maps, you can add photos of your business to a custom map, and post it in your blog to attract customers. There are a lot of possibilities, and it all depends on your creativity! Including Google Maps in your posts Using Google Maps in your blog is a good way of promoting your business because you can show your visitors your exact location. Or you can blog about your favorite places and show them as if you were there, using your own photos. Time for action – using Google Maps There are a lot of things you can do with Google Maps, one of them is including maps of your favorite places in your blog, as we'll see in a moment: Open your web browser and go to Google Maps (http://maps.google.com). Type Eiffel Tower in the search textbox, and click on the Search Maps button or press Enter. Your web browser window will split in two areas, as shown in the following screenshot: Click on the Eiffel Tower link at the bottom-left part of the screen to see the Eiffel Tower's exact position in the map at the right panel:  Now click on the Satellite button to see a satellite image of the Eiffel Tower:      Drag the Eiffel Tower upwards using your mouse, to center it on the map area: Click on the Zoom here link inside the Eiffel Tower caption to see a closer image: If you look closely at the previous screenshot, you'll notice three links above the map: Print, Send, and Link. Click on Link to open a small window: Right-click on the Paste HTML to embed in website field to select the HTML code, and then click on the Copy option from the pop-up menu: Open a new web browser window and log into your Roller weblog. In the New Entry page, type The Eiffel Tower inside the Title field, and Eiffel Tower Google Maps inside the Tags field. Then click on the Toggle HTML Source button in the Rich Text editor toolbar, type This is an Eiffel Tower satellite image, courtesy of Google Maps:<br> inside the Content Field, press Enter, and paste the code you copied from the Google Maps web page: Scroll down the New Entry page and click on the Post to Weblog button. Then click on the Permalink field's URL, to see your Google Maps image posted in your blog. Click on the Zoom here link once to see a close-up of the Eiffel Tower, as shown in the following screenshot: What just happened? Now you can add Google Maps functionality inside your blog! Isn't that great? You just need to copy and paste the HTML code that the Google Maps produce automatically for you. If you want a bigger or smaller map, you can click on the Customize and preview embedded map link to customize the HTML code that you're going to paste into your blog: Then you just copy the HTML code produced by Google Maps and paste it into your blog post: If you have a Google Maps account, you can create customized maps and show them to your visitors, add photos and videos of places you've visited, and even write reviews about your favorite restaurants and hotels. Have a go hero – explore Google Maps Now that you've seen how to embed Google Maps in your weblog, it would be a great idea to create your own Google Maps account, and start exploring all the things that you can do—inserting photos and videos about places you've visited in your own custom maps, adding reviews of restaurants and other businesses in your locality, and so on. You can explore other users' maps, too. Once you get the hang of it, you'll be traveling around the world and meeting new people from your own PC. Including YouTube videos in your posts YouTube is one of the most popular video sharing websites in the world. You can include your favorite videos in your blog, or make your own videos and show them to your visitors. However, before you start complaining that we have already seen how to insert videos on your weblog, let me tell you that the big difference between uploading a video to your own blog server and uploading a video to a YouTube server is bandwidth. When someone plays back a video from your weblog, the blog server transfers the video data to your visitor's web browser, so that he/she can begin to see it, even before the video downloads completely. This is known as video streaming. Now, imagine you have 1,000 visitors, and each one of them is viewing the same video from your weblog! There would be a big amount of data flowing from your weblog to each visitor's web browser! That amount of data flowing from one PC to another is called bandwidth. You would need a very broad connection to be capable of transmitting your video to all those visitors. That's where YouTube comes into play. They have lots of bandwidth available for you and the other millions of users who share videos daily! So, if you plan to include a lot of videos in your weblog, it would be a great idea to get a YouTube account and start uploading them. In the following exercise, I'll show you how to include a YouTube video in your post, without having to upload it to your weblog.
Read more
  • 0
  • 0
  • 6090

article-image-spicing-your-blog-uploading-files-and-images-your-weblog-using-apache-roller
Packt
30 Dec 2009
5 min read
Save for later

Spicing Up Your Blog: Uploading Files and Images to your Weblog using Apache Roller

Packt
30 Dec 2009
5 min read
This article gives you insight on weblogs and how they can be used to create a worldwide presence through the blogosphere. It also teaches you the difference between a blog and a CMS, the basics about newsfeeds and the important role they play for blogs, and how you can use them to spread information on the blogosphere. Before the action begins Before starting with this article's exercises, you need to download the support files (screenshots, videos, sounds, and so on) from http://www.packtpub.com/files/code/9508_Code.zip, and then unzip them into a folder—C:ApacheRollerBook, for example—on your hard drive. All these files are zipped in a file named chapter05.zip. Inside this file, there's an image file (chapter05_01.jpg), a sound file (seaontherocks.mp3), and several files for the video example (showvbox.mp4, showvbox_controller.swf, and FirstFrame.png). Uploading files to your weblog Now that you have the basic knowledge about how to manage your weblog, it's time to make things more interesting for you and your future visitors. So, how can we do that? Well, multimedia files (audio or video) are always a good addition to a web page, because they can express much more than using text-only posts. Imagine what you could offer to your clients, if you had an online specialty store. You could show your new items in your Roller weblog with full color photos, and you could also embed videos of your items in your posts, to give visitors a complete virtual tour of your store! To top that, you could show them a custom Google Map, where they could get directions from their location to your store! What else could you ask for? Using images on your posts An image can say a thousand words and if you include some of them in your posts, imagine the space you can save. Roller has a very friendly interface to help you upload and include images in your posts, and now you're about to learn how to do it! Time for action – uploading images into Roller In this exercise, I'll show you how to use Roller's file upload interface, so that you can add an image to an entry (post) in your blog:                                                                Open your web browser and log into Roller. The New Entry page will appear. Then click on the File Uploads link, under the Create & Edit tab: The File Uploads page will appear next, as shown in the following screenshot:      Click on the Browse... button of the first text field, and the File Upload dialog will appear. Go to the folder where you downloaded this article's support files, and double-click on the chapter5_01.png image to select it. The name of the file you selected will show up in the first textbox of the File Uploads page: Click on the Upload button to upload the image to your blog. Roller will respond with a success message as shown in the next screenshot: Take note of the URL shown in the previous message, because you'll use it when inserting the image inside a post in your blog. Now click on the New Entry link from the Create & Edit tab, and use the following screenshot as an example for your new post: Press Enter after the last line of text (Here's a screenshot of the official Website:) and click on the text editor's Insert/Modify Image button: The Insert Image dialog will show up. Type the URL of the image you uploaded to Roller (http://localhost/roller/main/resource/chapter5_01.png) inside the Image URL field, and click on the Preview button to see a small preview of the image. Then, type VirtualBox Web site in the Alternate text field and click on the OK button to insert the image in your post: You'll be taken back to the New Entry page again. To see the image, click on the Maximize/Minimize Editor button: The editor will fill up your web browser's entire workspace area and you will be able to see the image, as shown in the following screenshot: Click on the image to select it and change its size by dragging the little white square at the upper-right corner: Click on the Maximize/Minimize Editor button again to change the text editor to its original size. The image will now fit inside the text editor, as shown in the following screenshot: Use the down and right arrow keys to position the text cursor at the end of the post, press Enter and type the text shown in the following screenshot: Exit the text editor and scroll down the New Entry page until you locate the Post to Weblog button, and click on it to publish the post to the blog. Roller will show the Changes saved message inside a green box. Now click on the Front Page link in Roller's menu bar, at the upper-right corner of the screen, to go to your blog's front page: Your new post will appear on your weblog's front page, as shown in the following screenshot: You can logout from Roller and close your web browser now.
Read more
  • 0
  • 0
  • 2270

article-image-uploading-videos-and-sound-files-your-posts-using-apache-roller-40
Packt
30 Dec 2009
6 min read
Save for later

Uploading Videos and Sound Files on Your Posts Using Apache Roller 4.0

Packt
30 Dec 2009
6 min read
Using videos in your posts It's time to learn how to insert video files in your posts. You can just insert one as an HTML link, but who does that anymore? It's a good way to drive your prospective readers away! In today's world, you need to offer your spectators the easiest, quickest, and most attractive way to see what you have to offer. My job is to show you how to do that with your Roller weblog, so let's get to it! Time for action – uploading and inserting videos on your posts In this exercise, I'll show you how to upload a video file to your blog server and then insert it into a post using Apache Roller: Open your web browser and log into Roller. The New Entry page will appear. Click on the File Uploads link from the Create & Edit tab. Scroll down the File Uploads page until you locate the Manage Uploaded Files section. Type video in the New Directory field and click on the Create button, as shown in the following screenshot:  Roller will show the following success message: Scroll down the page again until you locate the video folder in the Manage Uploaded Files section, and click on it: Roller will take you to the same File Uploads page, but this time you'll be inside the video directory. Now click on the first Browse... button of the Upload files for use in weblog main section. On the File Upload dialog, go to the folder where you downloaded the support files for this article, and double-click on the FirstFrame.png image to select it. The name of this file will show up on the first textbox of the File Uploads page. Now click on the second Browse... button and double-click on the showvbox.mp4 file, so that its name appears in the second textbox of the File Uploads page. Repeat the process with the third Browse... button and the showvbox_controller.swf file. Your File Uploads page must look like the following screenshot: Click on the Upload button to upload the three files to the video directory in your blog server. Roller will return the following success page: Don't forget to write down the three URLs from the previous Roller message; you'll need them when inserting the video into an entry (post). Click on the New Entry link from the Create & Edit tab to go to the New Entry page and create a new post for your blog. Type Ubuntu Linux Virtual Machine Inside a Windows XP PC in the Title field, select Open Source in the Category field, type virtualbox windows xp linux ubuntu in the Tags field. In the Content field, and type Here's a sample video of my Ubuntu Linux Virtual Machine, running inside a Windows XP PC with VirtualBox: as shown in the following screenshot:   Click on the Toggle HTML Source button from the HTML editor and write the following code below the text you typed in step 8 (the text in bold must correspond to the URLs from step 7's screenshot): <object height="498" width="640" id="csSWF" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/ cabs/flash/swflash.cab#version=9,0,115,0"><param name="src" value="http://localhost/roller/main/ resource/video/showvbox_controller.swf" /><param name="bgcolor" value="#1a1a1a" /><param name="quality" value="best" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><param name="scale" value="showall" /><param name="flashVars" value="autostart=false" /><embed height="498" width="640" name="csSWF" src="http://localhost/roller/main/resource/ video/showvbox_controller.swf" bgcolor="#1a1a1a" quality="best" allowscriptaccess="always" allowfullscreen="true" scale="showall" flashvars="autostart=false&amp; thumb=http://localhost/roller/main/resource/ video/FirstFrame.png&amp; thumbscale=45&amp;color=0x000000,0x000000" pluginspage="http://www.macromedia.com/ shockwave/download/ index.cgi?P1_Prod_Version=ShockwaveFlash"/></object> Click on the Save as Draft button, to save a draft of your post. Then scroll down the page and click on the Full Preview button, to see how your post will look in your blog before publishing it. The preview will open in a new tab in your web browser:       Click on the play button and the video will begin to playback. When finished, close the preview tab and click on the Post to Weblog button to publish your new post. You can logout from Roller now. What just happened? The previous exercise showed you how to upload a video to your blog server and insert it in a post. As you can see, videos are a little more complicated than plain images. In this case, we used the following files: FirstFrame.png: This is the thumbnail image that shows up before the video begins to playback showvbox.mp4: The video file showvbox_controller.swf: The controller that plays back theshowvbox.mp4 file      The video was produced with Camtasia Studio, an excellent screen recording software application from TechSmith (http://www.techsmith.com). If you want to practice with your own videos, you can download a 30-day free trial version of Camtasia Studio from the following URL: http://www.techsmith.com/download/camtasiatrial.asp. What would happen if you wanted to embed a video from your camera or cell phone? Well, you can embed it directly in your blog, but the best thing to do is use a software application such as Camtasia Studio to create the .swf controller and the HTML code to embed into your post automatically. Then you just need to change the .swf controller and thumbnail URLs, as you did in step 9 of the previous exercise. You can use the same embed code to insert a different video in your blog; just be sure to change the URL in bold text. You could also upload your video to YouTube instead of uploading it into Roller, as we'll see later in this article.
Read more
  • 0
  • 0
  • 5004
Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at $19.99/month. Cancel anytime
article-image-writing-xml-data-file-system-ssis
Packt
29 Dec 2009
5 min read
Save for later

Writing XML data to the File System with SSIS

Packt
29 Dec 2009
5 min read
Integrating data into applications or reports is one of the most important, expensive and exacting activities in building enterprise data warehousing applications. SQL Server Integration Services which first appeared in MS SQL Server 2005 and continued into MS SQL Server 2008 provides a one-stop solution to the ETL Process. The ETL Process consists of extracting data from a data source, transforming the data so that it can get in cleanly into the destination followed by loading the transformed data to the destination source. Enterprise data can be of very different kinds ranging from flat files to data stored in relational databases. Recently storing data in XML data sources has become common as exchanging data in XML format has many advantages. Creating a stored procedure that retrieves XML In the present example it is assumed that you have a copy of the Northwind database. You could use any other database. We will be creating a stored procedure that selects a number of columns from a table in the database using the For XML clause. The Select query would return an XML fragment from the database. The next listing shows the stored procedure. Create procedure [dbo].[tst]asSelect FirstName, LastName, City from Employeesfor XML raw The result of executing this stored procedure[exec tst] in the SQL Server Management Studio is shown in the next listing. <row FirstName="Nancy" LastName="Davolio" City="Seattle"/><row FirstName="Andrew" LastName="Fuller" City="Tacoma"/><row FirstName="Janet" LastName="Leverling" City="Kirkland"/><row FirstName="Margaret" LastName="Peacock" City="Redmond"/><row FirstName="Steven" LastName="Buchanan" City="London"/><row FirstName="Michael" LastName="Suyama" City="London"/><row FirstName="Robert" LastName="King" City="London"/><row FirstName="Laura" LastName="Callahan" City="Seattle"/><row FirstName="Anne" LastName="Dodsworth" City="London"/> Creating a package in BIDS or Visual Studio 2008 You require SQL Server 2008 installed to create a package. In either of these programs, File | New | Projects... brings up New Project window where you can choose to create a business intelligence project with a Integration Services Project template. You create a project by providing a name for the project. Herein it was named XMLquery. After providing a name and closing the New Project window the XMLquery project will be created with a default package with the file name, Package.dtsx. The file name can be renamed by right clicking the file and clicking OK to the window that pops up regarding the change you are making. Herein the package was named XmlToFile.dtsx. The following figure shows the project created by the program. When the program is created the package designer surface will be open with a tabbed page where you can configure control flow tasks, Data Flow Tasks and Event handlers. You can also look at the package explorer to review the contents of the package. The reader may benefit by reviewing my book, Beginners Guide to SQL Server Integration Services, on this site. Adding and configuring a ExecuteSQL task Using an ExecuteSQL Task component the stored procedure on the SQL Server 2008 will be executed. The result of this will be stored in a package variable which will then be retrieved using a Script Task. In this section you will be configuring the ExecuteSQL Task. Drag and drop a Execute SQL Task under Control Flow items in the Toolbox on to the Control Flow tabbed page of the package designer. Double click Execute SQL Task component in the package designer to display the Execute SQL Task Editor as shown. It is a good practice to provide a description to the task. Herein it is, "Retrieving XML from the SQL Server" as shown. The result set can be of any of those shown in the next figure. Since the information that is retrieved running the stored procedure is XML, XML choice is the correct one to choose. The stored procedure is on the SQL Server 2008 and therefore a connection needs to be established. Leave the connection type as OLE DB and click on an empty area along the line item, Connection. This brings up the Configure OLE DB Connection Manager window where you can select an existing connection, or create a new connection. Hit the New... button to bring the Connection Manager window as shown. The window comes up with just the right provider [Native OLE DBSQL Server Native Client10.0]. You can choose the server by browsing with the drop-down handler as shown. In the present case the Windows Authentication is used with the current user as the database administrator. If this information is correct you can browse the database objects to choose the correct database which hosts the stored procedure as shown. You may also test the connection with the Test Connection button. You must close the Connection Manager window which will bring you back to the Configure OLE DB Connection Manager window which now displays the connection you just made. To proceed further you need to close this window as well. This will bring in the connection information into the Execute SQL Task editor window. The type of input is chosen to be a direct input (the others are file and variable). The query to be executed is the stored procedure, tst described early in the tutorial. The BypassPrepare is set to false. The General page of the Execute SQL Task editor is as shown here.
Read more
  • 0
  • 0
  • 12655

article-image-working-templates-apache-roller-40
Packt
28 Dec 2009
5 min read
Save for later

Working with Templates in Apache Roller 4.0

Packt
28 Dec 2009
5 min read
Your first template In essence, a theme is a set of templates, and a template is composed of HTML and Velocity code. You can make your own templates to access your weblog's data and show this to your visitors in any way you want. Creating and editing templates In Apache Roller, you can create, edit, or delete templates via the Frontpage: Templates page. Let's see how to use this wonderful tool to create and edit your own templates! Time for action – creating your first template In this exercise, you'll learn to create and edit your first custom template via Roller's admin interface: Open your web browser, log into Roller, and go to the Templates page, under the Design tab: On the Add a new template panel, type mytemplate in the Name field, leave the default custom value in the Action field, and click on the Add button: The mytemplate template you've just created will show up in the templates list: Now click on the mytemplate link under the Name field, to open the mytemplate file for editing: Leave the mytemplate value for the Name field, type mytemplate in the Link field, and type My First Template in Apache Roller! in the Description field: Then replace the <html><body></body></html> line with the following HTML code: <html><body>Welcome to my blog, <b>$model.weblog.name</b> </br>This is my first template </br>My weblog's absolute URL is: <b>$url.absoluteSite</b> </br></body></html> This is shown in the following screenshot: Scroll down the page and click on the Save button to apply the changes to your new template. Roller will show the Template updated successfully message inside a green box to confirm that your changes were saved: Now click on the [launch] link under the Link field to open a new tab in your web browser and see your template in action: You can close this tab now, but leave the Frontpage: Templates window open for the next exercise. What just happened? Now you know how to create your own templates! Although the previous example is very simple, you can use it as a starting point to create very complex templates. As I said before, templates are composed of HTML and Velocity code. The template we wrote in the previous exercise uses a few basic HTML elements, or tags: HTML Tag Definition Tip <html> , </html> Defines the start/end of an HTML document. You must write this tags at the beginning/end of each Roller template. <body>, </body> Defines the start/end of an HTML document's body. All the code you will write for your templates must go between the <body> and </body> tags. <b>, </b> Shows text in bold. Example: <b>Hello</b> shows up as Hello </br> Indicates a line break. Example: Hello</br>World shows up as Hello World Also, there are some elements from the Velocity Template Language, along with an example from the previous exercise:   Velocity Element Definition Example $model.weblog.name Shows the name of your weblog. <b>$model.weblog.name</b> shows up as Ibacsoft's Weblog $url.absoluteSite Shows the absolute URL of your weblog <b>$url.absoluteSite</b> shows up as http://alromero.no-ip.org/roller   These are just some of the basic HTML tags and Velocity elements you'll learn to use for your templates. In the following sections, we'll see some more, along with elements from the Velocity Template Language. The Velocity template language All templates in Roller use HTML tags, along with Velocity code. In the next subsections, you'll learn about some of the most widely used Velocity elements in your Roller templates. Using Velocity macros in your Roller weblog A macro in Velocity is a set of instructions that generate HTML code based on data from your weblog. They are very helpful when you need to do the same task more than once. In the following exercise, you'll learn to use some macros included in Roller in order to show your weblog data to your visitors. Time for action – showing your weblog's blogroll and most recent entries Now you will use the Velocity Template Language to show your weblog's bookmarks (blogroll) in your custom template, along with the most recent entries: Go to your custom template editing page, and type the following code just above the </body></html> line: </br>These are my favorite Web sites: </br>#set($rootFolder = $model.weblog.getBookmarkFolder("/"))#showBookmarkLinksList($rootFolder false false)
Read more
  • 0
  • 0
  • 3222

article-image-introduction-kohana-php-framework
Packt
28 Dec 2009
6 min read
Save for later

Introduction to Kohana PHP Framework

Packt
28 Dec 2009
6 min read
Overview Kohana PHP Framework is an open source PHP software development framework that helps php developers to build web applications faster, and also, more effectively by providing them with a set of built-in objects/classes. It also enforces highly organized coding standards. The Kohana PHP Framework is just like Ruby on Rails; it implements the well known software engineering design pattern—Model View Controller(MVC). The Model View Controller software design pattern guides engineers to design their software codes into three separate parts which includes: Models: The objects that manipulate data sources and data stores. Views: The html and css files with inline php codes that present the user interface and controls to the application users. Controllers: Objects in charge of the business logic, displaying the page(views), and routing the click actions from the views to the model and back to the views. Kohana was originally based upon the well documented codeigniter php framework, but it stands out due to its strict use of OOP best practices and standards. Kohana PHP is officially defined by its creators to be a PHP 5 framework that uses the model view controller architectural pattern. It aims to be secure, lightweight, and easy to use. Why use Kohana PHP framework? PHP is a very easy to use programming language, that's the reason why its loved by the web development community. It's easy to use nature and learning curve has attracted a lot of users. But PHP has one downside. Most experienced developers don’t love coding php due to its little Object orientation, and its often nasty codes. With Kohana PHP, any php developer from beginner to expert will all get to write standard codes which we see in the Java World, or the .NET world. Kohana bridges the gap between amateur web developers and designers who love php because its easy, and the experienced web developers who go fully into Object Oriented codes and nothing less. Kohana enforces true software engineering and brings it closer to the php world which has little or no standards. So the major reason why you should use Kohana PHP Framework for your php work is to ensure that your codes are of standards, and you follow the best practices which go a long way to help teams of developers from beginners to experts to easily work together with the PHP programming language. Kohana PHP Framework solves the problem of beginners, and intermediate developers who have nasty codes and are killing the overall work of the team. With the well documented and standard practices of Kohana, a developer in India can write the code and a developer in Africa can optimise the code without asking a lot of questions, because everything will clearly be a model, view or a controller, and it will be easy to understand what it was meant for exactly. Key features of Kohana PHP framework Kohana PHP has some very good features that makes it stand out from all other PHP frameworks. The features include:  Fully Object Oriented: Object oriented programming is an industry standard since the introduction of C++. Many developers working with Java programming languages are comfortable with Object and classes, and they prefer the order it brings to programming. Kohana PHP being fully Object oriented, it automatically brings this order and industry standard programming to PHP; with this, you wont get developers saying you are just a php developer because Kohana PHP is a standard software programming platform for enterprise and web applications. In built templating: Kohana PHP like most other standard web frameworks has a very easy to use template engine. You get a simple html file, covert it into a kohana template by renaming it to template.php, fit in two php variables— $title and $content, to signify where the title of the page and where the content will be displayed. That’s all you need to have a kohana php template. In built Internationalization: Kohana PHP strongly supports internationalization and good documentation. With Kohana, all you need to do is create the various language files and use an internationalization object to reference the files depending on the language from page to page. Switching the language, automatically switches the language file referenced. Robust ORM Engine: ORM stands for Object Relational Mapping. It’s a programming concept in which your codes directly manipulate the database tables as objects, while the SQL gets generated for you behind the scenes. The ORM in Kohana is easy due to its use of convention over configuration. Its the best ORM I have seen in the php world and its 100% stable. To make use of the ORM, you simply extend the ORM class in your model and that model will be able to manipulate your database without any SQL code. MVC: the framework is based on MVC, and this helps to bring about a lot of order, eases code maintenance and team work. I can get any Kohana PHP application, and easily understand what every code does because it must flow from a controller to a view or to a model then to a view. And that’s all about it. Clean and Search Engine Friendly URLs: Kohana PHP framework has a good implementation of controllers where every url call or reference in a kohana based site refers to a controller and its function, as in site/controller/function/parammeters. For example, calling a blog controller to show a post with ID 1 will be as simple as your-site.com/index.php/blog/showPost/1 where index.php is the front controller, blog is a controller object and show post a blog->showPost function that takes a parameter which is the post ID. Libraries and helpers and third party classes: With kohana php, you have a set of libraries and helpers for almost everything you need as a web developer. For instance, sending out an email is as easy as calling email::send() function. There are more helpers and libraries, getting to read about them on the Kohana php website will make you feel like your life as a developer has been taken away and you are just a secretary. Also with Kohana PHP, you can get any available php class from the internet and use it in the kohana framework by simple dropping the file in a folder in your kohana site known as vendor, and then, instantiating the class in your codes. That’s all! It sounds too good to be true but thats all you need to use that PEAR object or that zend class or that php class you have been using for years with kohana framework on your next project.
Read more
  • 0
  • 0
  • 15104

article-image-ajax-chat-implementation-part-1
Packt
28 Dec 2009
4 min read
Save for later

AJAX Chat Implementation: Part 1

Packt
28 Dec 2009
4 min read
Lets get started. We'll keep the application simple, modular, and extensible. We won't implement a login module, support for chat rooms, the online users list, and so on. By keeping it simple we'll focus on what the goal of this article is: posting and retrieving messages without causing any page reloads. We'll also let the user pick a color for her or his messages, because this involves an AJAX mechanism that is another good exercise. The chat application can be tested online at http://ajaxphp.packtpub.com, and should look like Figure 8-1: Figure 8-1: Online chat application built with AJAX and jQuery Using jQuery as a framework will simplify things: we won't need to worry about constructing XmlHttpRequest by ourselves and implementing design patterns and best practices. Technically, the application is split into two smaller applications that build the final solution: The chat application: Here we use a MySql database and AJAX to store and retrieve the users' messages and pass them between the client and the server. The code for choosing a text color: Here we use AJAX to call the PHP script that can tell us which text color was chosen by the user from the color palette. We use an image containing the entire spectrum of colors and allow the user choose any color for the text he or she writes. When the user clicks on the palette, the mouse coordinates are sent to the server, which obtain the color code, store it in the user's DB entry, and set the user's test to that color. The chat application Here we use a MySql database and AJAX to store and retrieve the users' messages and pass them between the client and the server. The chat window contacts the server periodically to send and retrieve the newest posted messages from the server to each user. Our DB will also hold username and text color information used in the application. Implementing this functionality involves creating the files and structures shown in the following figure: Figure 8-2: The components of the AJAX Chat application The application functions following our usual coding pattern as follows: The user interface is generated by index.html, which displays the chat box and the color picker. This file loads the other client-side files, which in our case are chat.js (our JavaScript chat class), jQuery-1.3.2.js (the jQuery framework), chat.css, and palette.png (the color picker image). On the server side, the main player is chat.php, which is designed to take requests from the client. In our case, client-server communication will happen between chat.js (on the client) and chat.php (on the server). The chat.php script uses three other files—config.php, error_handler.php and chat.class.php; we'll pay special attention to the latter, which is more complex and more interesting than the others. The other server-side file that listens to client requests is color.php, which is called whenever the user clicks the color palette image. When that happens, the client script calls color.php, tells it the location the user clicked on the palette, and color.php replies by telling the color at that location. You'll also need to create a new data table named chat (refer to the following figure), which holds the chat messages exchanged by the chatters. The files to which we're paying a little attention before starting to code are chat.js and chat.class.php. The chat.class.php file contains a server-side class named Chat which includes all the server-side functionality required to manipulate chat messages, as you can see in its diagram in Figure 8-3. This class contains methods for adding, deleting, and retrieving chat messages to and from the chat database table. Figure 8-3: Server-side Chat class Then we have the Chat class in the chat.js file. This is a JavaScript class that contains the client-side functionality required for our chatting application, which include functions for retrieving the list of messages from the server, sending new messages, deleting messages, displaying error messages, and so on. Most of the features are backed up by the server-side components, which are called to perform the necessary work. Figure 8-4: Client-side Chat class
Read more
  • 0
  • 0
  • 4782
article-image-ajax-chat-implementation-part-2
Packt
28 Dec 2009
9 min read
Save for later

AJAX Chat Implementation: Part 2

Packt
28 Dec 2009
9 min read
Create a new file named index.html, and add this code to it: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xml_lang="en" lang="en"> <head> <title>AJAX Chat</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link href="chat.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="jQuery-1.3.2.js" ></script> <script type="text/javascript" src="chat.js" ></script> </head> <body> <noscript> Your browser does not support JavaScript!! </noscript> <table id="content"> <tr> <td> <div id="scroll"> </div> </td> <td id="colorpicker"> <img src="palette.png" id="palette" alt="Color Palette" border="1"/> <br /> <input id="color" type="hidden" readonly="true" value="#000000" /> <span id="sampleText"> (text will look like this) </span> </td> </tr> </table> <div> <input type="text" id="userName" maxlength="10" size="10"/> <input type="text" id="messageBox" maxlength="2000" size="50" /> <input type="button" value="Send" id="send" /> <input type="button" value="Delete All" id="delete" /> </div> </body> </html> Let's deal with appearances now, creating chat.css and adding the following code to it: body { font-family: Tahoma, Helvetica, sans-serif; margin: 1px; font-size: 12px; text-align: left } #content { border: DarkGreen 1px solid; margin-bottom: 10px } input { border: #999 1px solid; font-size: 10px } #scroll { position: relative; width: 340px; height: 270px; overflow: auto } .item { margin-bottom: 6px } #colorpicker { text-align:center } It's time for another test. We still don't have the color picker in place, but other than that, we have the whole client-server chat mechanism in place. Load index.html at http://localhost/ajax/chat/index.html from multiple browsers and/or computers, and ensure everything works as planned. Figure 8-7: Screenshot of index.html Copy palette.png from the code download to your ajax/chat folder. Create a file named color.php and add the following code to it. This is actually the only step left to make the color picker work as expected. <?php // the name of the image file $imgfile='palette.png'; // load the image file $img=imagecreatefrompng($imgfile); // obtain the coordinates of the point clicked by the user $offsetx=$_GET['offsetx']; $offsety=$_GET['offsety']; // get the clicked color $rgb = ImageColorAt($img, $offsetx, $offsety); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; // return the color code echo json_encode(array("color" => sprintf('#%02s%02s%02s', dechex($r), dechex($g), dechex($b)))); ?> Make another test to ensure the color picker works and that your users can finally chat in color. What just happened? First, make sure the application works well. Load http://localhost/ajax/chat/index.html with a web browser, and you should get a page that looks like the one in Figure 8-1. If you analyze the code for a bit, the details will become clear. Everything starts with index.html. The only part that is really interesting in index.html is a scrolling region implemented in DHTML. (A little piece of information regarding scrolling can be found at http://www.dyn-web.com/code/scroll/.) The scrolling area allows our users to scroll up and down the history of the chat and ensures that any new messages that might flow out of the area are still viewed. In our example, the scroll element and its inner layers do the trick. The scroll element is the outermost layer; it has a fixed width and height; and its most useful property, overflow, determines how any content that falls (or overflows) outside of its boundaries is displayed. Generally, the content of a block box is confined to the content edges of the box. In CSS, the overflow property has four possible values that specify what should happen when an element overflows its area: visible, hidden, scroll, and auto. (For more details, please see the specification of overflow, at http://www.w3.org/TR/REC-CSS2/visufx.html.)   As you can see, the HTML file is very clean. It contains only the declarations of the HTML elements that make up the user interface. There are no event handlers and there is no JavaScript code inside the HTML file—we have a clean separation between the user interface and the programming. In our client-side JavaScript code, in the chat.js file, the action starts with the ready event, which is defined in jQuery (reference: http://docs.jQuery.com/Events/ready) as a replacement for window.onload. In other words, your ready() function, which you can see in the following code snippet, is called automatically after the HTML page has been loaded by the browser, and the page elements can be safely used and manipulated by your JavaScript code: $(document).ready(function() { } Inside this function, we do several operations involving events related to the user interface. Let's analyze each step! We want to be sure that a username always appears, that is, it should never be left empty. To do this, we can create a function that checks for this and bind it to the blur event of the textbox. // function that ensures that the username is never empty and //if so a random name is generated $('#userName').blur( function(e) { // ensures our user has a default random name when the form loads if (this.value == "") this.value = "Guest" + Math.floor(Math.random() * 1000); } ); If the username is empty, we simply generate a random username suffixing Guest with a randomly generated number. When the page first loads, no username has been set and we trigger the blur event on userName. // populate the username field with // the default value $('#userName').triggerHandler('blur'); The success() function starts by checking if the JSON response contains an errno field, which would mean that an error has happened on the server side. If an error occurred the displayPHPError() function is called passing in the error in JSON format. // function that displays a PHP error message function displayPHPError(error) { displayError ("Error number :" + error.errno + "rn" + "Text :"+ error.text + "rn" + "Location :" + error.location + "rn" + "Line :" + error.line + + "rn"); } The displayPHPError() will retrieve the information from the error and call in turn the displayError() function. The displayError() function shows the error message or a generic alert depending on whether the debugging flag is set or not. // function that displays an error message function displayError(message) { // display error message, with more technical details if debugMode is true alert("Error accessing the server! " + (debugMode ? message : "")); } Next, in our ready event, we set the default color for the sample text to black: // set the default color to black $('#sampleText').css('color', 'black'); Moving on, we hook on to the click event of the Send button. The following code is very simple, as the entire logic behind sending a message is encapsulated in sendMessage(): $('#send').click( function(e) { sendMessage(); } ); Moreover, here we hook on to the click event of the Delete all button in a similar way as the Send button. $('#delete').click( function(e) { deleteMessages(); } ); For the messageBox textbox, where we input messages, we disable autocomplete and we capture the Enter key and invoke the logic for sending a message: // set autocomplete off $('#messageBox').attr('autocomplete', 'off'); // handle the enter key event $('#messageBox').keydown( function(e) { if (e.keyCode == 13) { sendMessage(); } } ); Finally, when the page loads, we want to have the messages that have already been posted and we call retrieveNewMessages() function. Now that we have seen what happens when the page loads, it's time to analyze the logic behind sending and receiving new messages. Because everything starts when the page loads and the existing messages are retrieved, we will start with retrieveNewMessages() function. The function simply makes an AJAX request to the server indicating the retrieval of the latest messages. function retrieveNewMessages() { $.ajax({ url: chatURL, type: 'POST', data: $.param({ mode: 'RetrieveNew', id: lastMessageID }), dataType: 'json', error: function(xhr, textStatus, errorThrown) { displayError(textStatus); }, success: function(data, textStatus) { if(data.errno != null) displayPHPError(data); else readMessages(data); // restart sequence setTimeout("retrieveNewMessages();", updateInterval); } }); } The request contains as parameters the mode indicating the retrieval of new messages and the ID of the last retrieved message: data: $.param({ mode: 'RetrieveNew', id: lastMessageID }), On success, we simply read the retrieved messages and we schedule a new automatic retrieval after a specific period of time: success: function(data, textStatus) { if(data.errno != null) displayPHPError(data); else readMessages(data); // restart sequence setTimeout("retrieveNewMessages();", updateInterval); } Reading messages is the most complicated function as it involves several steps. It starts by checking whether the database has been cleared of messages and, if so, it empties the list of messages and resets the ID of the last retrieved message. function readMessages(data, textStatus) { // retrieve the flag that says if the chat window has been cleared or not clearChat = data.clear; // if the flag is set to true, we need to clear the chat window if (clearChat == 'true') { // clear chat window and reset the id $('#scroll')[0].innerHTML = ""; lastMessageID = -1; } Before retrieving the new messages, we need to check and see if the received messages have not been already processed. If not, we simply store the ID of the last received message in order to know what messages to ask for during the next requests: if (data.messages.length > 0) { // check to see if the first message // has been already received and if so // ignore the rest of the messages if(lastMessageID > data.messages[0].id) return; // the ID of the last received message is stored locally lastMessageID = data.messages[data.messages.length - 1].id; }
Read more
  • 0
  • 0
  • 5857

article-image-velocity-model-and-data-objects-apache-roller
Packt
28 Dec 2009
2 min read
Save for later

Velocity Model and Data Objects in Apache Roller

Packt
28 Dec 2009
2 min read
Velocity model and data objects in Apache Roller There are several standard model and data objects you can use in Apache Roller to access your weblog's data. Some of the most widely used are $config, $model, $url, $utils, $weblog, $weblogCategory, and $weblogPage. In the following exercise, you'll get to work with the $config object. The $config object This model is used to access Roller's site-wide configuration parameters, such as the e-mail address of Roller's administrator, the name of the Roller site, and so on. Time for action – properties of the $config model object The following exercise will show you how to use some properties of the $config model object inside your custom template: Go to your custom template editing page, and replace the six lines of code below the <body><html> line with the following lines: Welcome to my blog, <b>$model.weblog.name</b> --> <i>$config.siteDescription</i> </br>I'm using Apache Roller Version <b>$config.rollerVersion</b> </br>You can e-mail me at <b>$config.siteEmail</b> if you run into anyproblems in this site. </br>This is my first template </br>My weblog's absolute URL is: <b>$url.absoluteSite</b> </br></br> The entire code of your template should look like the following screenshot (the code you have to change is highlighted): Save your changes and click on your template's [launch] link to open a new tab in your web browser and see the results: Close the results tab if you like, but leave the Frontpage: Templates window open for the next exercise. What just happened? The following table summarizes the $config object properties you learned to use in the previous exercise, along with their value: Property Definition Value $config.siteDescription Shows your site's description. My First Installation of Apache Roller $config.rollerVersion Shows the Apache Roller version used. 4.0.1 $config.siteEmail Shows the site administrator's email. alromeromx@gmail.com You can find all $config parameters under Roller's Server Admin tab: The $model, $category, and $entry objects These objects are used to access all the data for a specific weblog: weblog entries, categories, comments, among others.
Read more
  • 0
  • 0
  • 1743

article-image-creating-roller-theme-scratch-using-apache-roller-40
Packt
28 Dec 2009
6 min read
Save for later

Creating a Roller theme from scratch using Apache Roller 4.0

Packt
28 Dec 2009
6 min read
Creating a Roller theme from scratch Now things are going to get a little rough; just kidding! In Apache Roller, it's very easy to create your own themes, and in this section I'm going to show you how. For the following exercises, you'll need to download http://www.packtpub.com/files/code/9508_Code.zip. Extract the chapter07.zip file's contents into a directory in your hard disk. For example, I used Ubuntu Linux in the exercises, created a chapter07 directory inside my Desktop directory, and copied the mytheme directory inside Desktop/chapter07. All the steps in the exercises are based on these assumptions. Creating a directory for your theme Every Roller theme has a directory and some required files such as weblog.vm, _day.vm, and theme.xml. The next exercise will show you how to create a directory for your new theme inside Roller's themes directory, and how to copy these required files from the support files. Time for action – creating a directory for your theme Now, I'll show you all the necessary steps to create your new theme directory inside Roller's themes directory in a Linux Ubuntu system, and then copy all the required files. If you're using Windows or any other flavor of Linux, the procedure is very similar: Go to your Roller themes directory and create a directory named mytheme: Open a terminal window, go to the themes subdirectory inside Desktop/chapter07, and type sudo cp * /usr/local/tomcat/webapps/roller/ themes/mytheme to copy all the mytheme files to your Roller installation: In the end, your mytheme directory will have four files, as shown in the following screenshot: Now restart Tomcat and wait until it's running again. Then open your web browser, log into Roller, and go to the Design tab to see the Weblog Theme page: Click on the Shared Theme option and select My First Roller Theme from the drop-down listbox: Click on the Update Theme button to change your current Roller theme, and then click on the See how your blog will look with this theme link: Roller will open a new web browser tab to show you a preview of the new theme you selected: Close the preview tab and leave the Front Page: Weblog Theme page open for the next exercise. What just happened? As you can see from the previous exercise, the mytheme theme has a very basic functionality. That's because the CSS stylesheet (mystylesheet.css) is empty, so I'm going to show you how to add styles to your headings, links, and all the other elements displayed in your weblog. However, first we need to see a quick introduction to the four files that every Roller theme must have in order to run without any trouble: File Definition Tip weblog.vm Describes the main page of your weblog In this file you set the structure for your weblog, using macros and elements from Roller and the Velocity template language. _day.vm Describes how to display one day's worth of entries in your weblog Here you can configure how to display each entry's title, content and comments, for example. You can set the font's color and size of each element, based on the CSS stylesheet definitions. mystylesheet.css Stylesheet override file that defines the CSS style code used by your weblog Here you define all your weblog's styles, like size and color for headings and fonts used in your posts. theme.xml Theme definition file that describes each file used in your weblog You need to include some basic data about your theme, the stylesheet file, the weblog and _day templates, and every other file and/or resource used in your weblog. In the next exercises, you'll learn how to edit these files to change your weblog's visual appearance and suit your needs. The stylesheet override file The first thing we need to do in order to change your new theme's visual appearance is edit the stylesheet override file: mystylesheet.css. We can do this in two ways: Edit the file directly from the mytheme directory inside Roller's themes directory, or use Roller's Custom Theme feature. If we use the first option, we'll need to restart Tomcat every time we make a modification to mystylesheet.css. On the other hand, if we choose the second option, we can edit the stylesheet inside Roller's admin interface and see how our changes affect our weblog's visual appearance immediately, so I'm going to show you how to use the second option. Time for action – editing the stylesheet override file It's very easy to edit the stylesheet override file for your custom theme inside Roller, and the next exercise will show you how to do it: Go to the Front Page: Weblog Theme tab in your web browser, select the Custom Theme option, click on the I want to copy the templates from an existing theme into my weblog checkbox, and click on the Update Theme button: Roller will show you the following success message: Now click on the Templates link to see a list of the templates you currently have in your custom space: Looking at the template list in the previous screenshot, there are some templates from the other custom theme which we need to remove. Click on the Remove link of the custom.css, mytemplate, and _css templates to delete them from your custom space, as we won't need them, and they don't belong to mytheme. After removing all the unneeded files, there should be only two templates inyour list: Now click on the Stylesheet link to see and start editing your mystylesheet.css file's code: As you can see, your custom stylesheet is empty. If you click on the Front Page link in Roller's menu bar, you'll see your weblog's current front page: Now click on your web browser's Back button to return to the stylesheet editing page, and add the following code to your custom stylesheet: div.dayTitle {color:brown;font-weight:bold;font-size:90%;text-transform:uppercase;border-bottom:1px dotted #666;}.entryTitle {font-weight: bold;} Your stylesheet should now contain the line beginning with /*, along with the code you've just entered: Click on the Save button to apply the changes to your stylesheet, and then select the Front Page link to see how the code you entered affects your weblog's visual appearance: If you compare the previous screenshot with the one from step 7, you'll see that the code you entered into the override stylesheet changed the way your weblog displays the day and entry titles. Now click on the Back button of your web browser to return to the stylesheet editing page, and add the following lines of code above the lines you entered in step 8: a {text-decoration: none;}a:link {color: blue;font-weight: medium;}a:visited {color: purple;font-weight: medium;}a:hover {text-decoration: underline overline;}body {font-family:"Lucida Grande", lucida, Geneva, Arial,sans-serif;background:#FFFFCC;} Your stylesheet should now look like this: Click on the Save button and then select the Front Page link to see your weblog's front page: Click on the Back button to return to your stylesheet editing page.
Read more
  • 0
  • 0
  • 2005
article-image-venturing-beyond-basics-ms-office-live-small-business
Packt
28 Dec 2009
14 min read
Save for later

Venturing Beyond the Basics in MS Office Live Small Business

Packt
28 Dec 2009
14 min read
In this article we will discuss why Office Live Small Business is the perfect site-building tool for you if you don't know (or don't want to learn) HTML, the language of web pages. And you'll certainly agree that it does a pretty decent job of it. But afer your site is functionally complete, it's only natural that you'd want to tweak little things here and there; move the text on some page a wee bit to the left, for example, or move a picture up by a pixel or two, so as to align it with the neighboring text. The trouble, though, is that Office Live Small Business doesn't allow such tweaks. You can't touch the HTML that it generates. But what if you're not very happy with this state of affairs? Don't worry! Office Live Small Business has it covered. It has two advanced features that give you a fine-grained control over the look and feel of your web pages as follows: Page Editor's HTML modules in which you can write your own HTML markup Off-the-shelf Solutions, which render customized web pages within Office Live Small Business's framework In this article, you'll explore both these advanced options. Let's get started then. About HTML modules An HTML module is a little editor that you can plop on to your page in the Page Editor, just like any other module. It holds HTML markup. With an HTML module, you can construct a web page with raw HTML markup just as the pros do. If you're conversant with HTML, the idea of having a fine-grained control over your HTML is likely to pump you up. And yet, I don't recommend using HTML modules. You read that right: I don't recommend using HTML modules. Why? Because Office Live  Small Business stores the markup in HTML modules separate from the page. When a person requests your page from his/her browser, Office Live Small Business fetches the separately-stored markup and embeds it into the rest of the page dynamically. The problem is that it does the embedding using something called frames, which happen to be little windows on a web page that display content that doesn't actually reside on that page. Why is this problematic? Because search engines can't index the content that doesn't physically reside on your web page. Therefore, people can't find it using search engines. Frankly, I don't see a point in building a site that people can't fnd. So, I strongly discourage you to build your entire site with HTML modules. Another reason to avoid HTML modules is that they load the content dynamically using JavaScript. This can be an excruciatingly slow process that can delay the loading of a page  in a user's browser. In fact, such dynamically loaded pages often tend to time out. Having said that, there are situations where they can come in handy. You may not care, for example, whether search engines index a certain page on your site, but you'd like to have great control over how that page looks. Or you may want to embed a YouTube video on your page, which search engines don't index any way. It's a good idea, therefore, to learn how to use the HTML module and that's what you'll do in this section. The first step, of course, is to add an HTML module to one of your pages. Let's use a Test page as a guinea pig. Time for action – adding an HTML module to your page Bring up the Test page in Page Editor. Place the cursor where you want to add the module. Click the Module button in the Insert group on the Page Editor's ribbon. Select HTML from the Modules menu that drops down. The HTML dialog pops up, as shown: The dialog contains a mini-editor where you can type your HTML markup. The Images and Hyperlink buttons just above the editor box help you add markup for embedding pictures and hyperlinks. As this is just a Test page, I'll type some simple HTML to show you how the module really works. I suggest that you do the same. Type the following markup in the mini-editor: <strong>Welcome to my web site.</strong> Click OK. The HTML dialog closes and you return to Page Editor, which renders the HTML you just typed as any browser would. Preview your website. The page should now look like this: Close the preview window and return to Page Editor. Editing your markup is equally easy. Right-click on the HTML module in Page Editor. A pop-up menu appears, as shown in the next image: Choose Properties…. The HTML dialog opens again with your markup in it. Change the markup to: <strong>Welcome</strong> to my web site. You'll be working with the HTML module a few more times in this article. From now on, I'll just say "Open the HTML module's HTML dialog" when I want you to edit a module's markup. Click OK. The HTML dialog closes and you return to Page Editor. Preview your website. The page should now display only the word Welcome in bold letters. Close the preview window and return to Page Editor. What just happened? You added an HTML module to a web page and typed some basic HTML in it. Before this exercise, you simply typed text on to your web pages as you would in a word processor, and Office Live Small Business took care of converting it to HTML. With an HTML module, you're writing your own HTML. Naturally, you'll have a more fine-grained control over how you want it to appear. But to make use of this newfound power, you must know HTML. So, let me give you a brief tutorial on it. There are several hundred excellent HTML tutorials on the Web (not to mention several thousand lousy ones). If you take into account the hundreds of books on the subject, you'd think that everything that needs to be said about HTML has, perhaps, already been said. Many times over, at that. Yet, I have good reason to write this brief tutorial: writing HTML for Office Live Small Business web pages is an entirely different beast. Why? Because: You don't write an entire HTML document with Office Live Small Business's design tools. All you do is write little chunks of HTML in HTML modules placed strategically on your web pages. Office Live Small Business's Page Editor combines the basic framework of your web page with these chunks of HTML and presents a finished web page to your browser. An HTML module doesn't store the HTML you type verbatim. It encodes what you type and lets the browser handle the decoding. Therefore, the page may not look exactly as you intend it to, after the browser renders it. The page on which you drop an HTML module already has a Cascaded Style Sheet (CSS) associated with it. You may be able to take advantage of the fact and minimize manual formatting. Therefore, you don't have to be an HTML guru to use Office Live Small Business's HTML module. All you need to know is a small subset of HTML that leverages the web page's features. This tutorial introduces that subset. It won't make you a fully-fledged web designer, but it will arm you with enough knowledge to impress unsuspecting folks at cocktail parties. HTML 101 Contrary to what many people believe, HTML is not a programming language. It's a markup language. Unlike programming languages, it doesn't contain step-by-step instructions that tell a computer what to do. Instead, it contains instructions that tell a browser how to format and decorate web page content. The instructions are written as Tags. Tags are keywords that reside within a pair of angular brackets (< and >). Typically, you enclose some content between a pair of tags. For example, the <strong> and </strong> in the markup you just tried out is tag pair. The pair consists of an opening tag and a closing tag. The difference between an opening tag and the corresponding closing tag is usually a forward slash (/). So, <strong> is the opening tag and </strong> is the corresponding closing tag. If you want to make some text bold, you enclose it between <strong> and </strong> tags like this: This is some text. <strong>This sentence is bold.</strong> This one isn't. And the browser displays it like this: Most HTML tags are paired like the <strong> tag. But some are not. An example is the  <br /> tag. It adds a line break to your text like this: This is some text. <br /> This is some more text but it's on the next line. And the browser displays it like this: The character < opens the tag and the character sequence /> closes it. Such tags that close themselves without corresponding closing tags are called self-closing tags. It's not mandatory to close the self-closing tags. So, if you write <br> instead of <br />, your page will work just fine. But I recommend closing all tags. I'll do so in this tutorial and so will you. Notice, by the way, that simply typing the second line of text on a new line in the editor doesn't make the text appear on the next line (go ahead, try it!). It's the <br /> tag that actually does the trick and displays the subsequent text on the next line, although you typed it as a single line in the editor. In other words, the tags determine the appearance of your web page, not how you type the text in the editor. HTML is not case sensitve. So, you can write a <br /> tag as <BR />, <Br />, or even  <bR />, if you insist, and your page won't look any different. But, I strongly advise against it. As a matter of convention, I recommend sticking to lowercase letters, as I've done throughout this tutorial. That's just about all the dirt that you really need to know on HTML. There's more,  of course, but as this is not a complete HTML tutorial, we'll look into the finer details  on a need-to-know basis. So, let's proceed to some useful HTML tags. Working with paragraphs Most writing is structured as a collection of paragraphs. While writing HTML, you must enclose the text in a paragraph between the <p> and </p> tag pair like this: <p>This is the first paragraph. It has this filler text to make it rather long so that it looks like a real paragraph.</p><p>Here is the second paragraph.</p> And the browser renders it like this: As you can see, there's no space between the paragraphs in the markup. But the <p></p> tag pair automatically introduces breaks that makes the text look like paragraphs in the browser. Because of a bug in the HTML module, it doesn't seem to treat <p> and </p> tags correctly. As a result, you don't see intended paragraph breaks in the browser. In the picture above, I sneaked in our old friend, the <br /> tag, between the two paragraphs as in <p>...</p> <br /> <p>...</p>.You may have to resort to this workaround as well. But remember that if Microsoft fixes the bug, you'll get an extra line-break on your page.Also, remember that you can add text to an HTML module without the paragraph tag pair; you can use <br /> tags instead, for example, where you want a break in text. However, I recommend that you enclose all of your text in paragraph tags. If you don't, Office Live Small Business's stylesheets may hijack the formatting of your text. Not enclosing text in paragraphs is one of the main reasons why text on so many web pages is misaligned and displayed in the wrong font. Working with horizontal rules You can draw a horizontal line across your web page simply by clicking the Horizontal line button on Page Editor's ribbon. To draw a similar line while working with the HTML module, you'll need—you guessed it—a tag! Web designers call a horizontal line a horizontal rule and so the corresponding tag is the <hr /> tag, like the <br /> tag, the <hr /> tag. Simply type <hr /> wherever you want a horizontal line  to appear. If you want it to appear between the two paragraphs in the previous example, your markup will look like this: <p>This is the first paragraph. It has this filler text to make it rather long so that it looks like a real paragraph.</p><hr /><p>Here is the second paragraph.</p> And your page will appear in the browser like this: Working with headings Headings are an important part of the text. Books, for example, use headings with varying importance. The more important a heading, the bigger its font size is. This scheme makes  it easy for readers to quickly grasp the scope of topics and sub-topics within the text. HTML uses a similar scheme. There are six levels of heading tag pairs in HTML that you can put around heading text like this: <h1>Heading 1</h1><h2>Heading 2</h2><h3>Heading 3</h3><h4>Heading 4</h4><h5>Heading 5</h5><h6>Heading 6</h6> Text included between beginning and ending tags at each level looks like this: As you can see, <h1> has the largest font size. Naturally, it's used for the most important heading on a web page. As the number inside the tag increases, its font size decreases.  So, among headings, <h6> has the smallest font size. What if you need more than six levels of headings? Well, you shouldn't; a six level deep topic hierarchy is deep enough for most people to keep track of. If you have seven or more levels, you should seriously consider rewritng your text. Generally, it's a good idea to start a page with the <h1> tag. It identifies the most important heading on the page, and it is used by search engines to take an educated guess at what  the page is all about. So, a good convention to follow is to have only one <h1> tag on every web page. But, you're better off flouting this convention when working with Office Live Small Business. Why? Because you don't write entire web pages in HTML modules; you just write individual chunks of HTML. Office Live Small Business automatically adds a <h1></h1> tag pair  to your web pages and places the title of your site between them. Similarly, it uses the <h2></h2> tag pair for your site's tag line. So, you're better off starting with a <h3> tag in every HTML module on a web page. That way, you won't drive Google's spider nuts by forcing it to wrestle with 23 <h1> tags on a single web page. When you need a sub-heading on the page, you should use the next tag downin the hierarchy; in our example, <h4>. Avoid the temptaton to skip levels. Don't jump from <h3> to <h6>, for example. And it's a good idea to use these heading tags. Don't just write plain text with large fonts instead.
Read more
  • 0
  • 0
  • 1541

article-image-data-modeling-naming-standards-ibm-infosphere-data-architect
Packt
24 Dec 2009
4 min read
Save for later

Data Modeling Naming Standards with IBM InfoSphere Data Architect

Packt
24 Dec 2009
4 min read
The Prime-Class-Modifier Words Pattern Prime words represent key business entities. In an insurance business, examples of prime word are policy and coverage. A class word is a category that qualifies a prime word; for example, in policy code name, code is a class word. policy code can further be qualified by a modifier word; for instance, previous policy code where previous is the modifier word. You can define your own naming pattern different from the above modifier prime class pattern for a specific modeling object, including the separator between words and if modifier word or class word in the pattern is optional. You can have, for instance, modifier?_prime_modifer?_class_modifier? pattern for attribute naming in a logical data model. The ? characters indicate the words are optional and the separators are _. An example name with that pattern is permanent employee last name, assuming we have defined in our standard that permanent as a modifier word, employee as a prime word, last a modifier word, and name as a class word. Note that we don’t have the last optional modifier word in this example. In a different business (not insurance), code might well be a prime word and policy might not be a prime word; hence the need to define your own specific list of prime, class and modifier words and naming patterns for their application, and that is what you build in glossary model. Building Glossary Model The InfoSphere Data Architect (IDA) allows you to build a glossary model from blank or from pre-defined enterprise model. Creating glossary model and selecting its template, blank or pre-built enterprise template The enterprise glossary model gives you a head start with its collection of words relevant across various business types, most of which would probably be applicable to your business too. You can customize the glossary: change or delete the existing words, or add new ones. Selecting an existing word or words in the list and then clicking the cross icon will delete the selected words   Clicking the plus icon allows you to add a new word into the glossary   When you add a new word, in addition to the name, you specify its Abbreviation, Alternate name, and most importantly its type (CLASS, PRIME) and if it is a Modifier word. When the glossary is applied for transforming a logical to physical model, the abbreviation is applied to the physical modeling object. Customizing a word being added   Selecting the type of a word   Before we can apply the words to naming our data model objects, we need to define the naming pattern. You can define the naming pattern for logical and physical modeling objects. The sequence of the word types in the pattern from top to bottom is left to right when you apply them in the names. You can also choose the separator for your naming pattern: space or title case for the logical model, and any character for the physical model (most preferred choice would be non alpha numeric character that is not used in any of the words in the glossary). Defining pattern for logical model objects (entity and attribute)   Defining pattern for physical model objects (table and column)   Specifying separator for logical model   Specifying separator for physical model You then choose the glossary model that you want to apply to your data models. Glossary Model.ndm in the packtpub directory is applied   When you have finished building your glossary model and defining naming pattern, you can then apply them for naming your modeling objects. (You can further adjust the words in the glossary them when such a need arises)
Read more
  • 0
  • 0
  • 7912
Modal Close icon
Modal Close icon