Showing posts with label Web Frameworks. Show all posts
Showing posts with label Web Frameworks. Show all posts

Saturday, October 1, 2011

Wt Configuration and Experimentation - Continued...

This is a continuation of the previous post titled Wt Configuration and Experimentation.

PackRapt.com is a cloud resources search, bundler and mailer. It allows for search and distribution of disparate cloud documents. One stop search and send. In an effort to maximize efficiency while minimizing footprint and resources exploitation I'm moving PackRapt.com to the Wt framework and customizing the search and curation features. These posts document the adventure.


Wt Configuration and Experimentation - Continued...

We left off taking a look at the Wt samples that are applicable to PackRapt.com

Hangman

The Hangman example included in the Wt library offers a look at simple authentication. I've tried to roll my own authentication before. I thought it was easy. That was, until i had a Ruby guy punch so many holes my attempt it resembled the Titanic. We will, however, use the example as a foundation to creating our own. Easy? No. Fun? Yes.

An important part of the Hangman examples lies in the Wt ORM.  We will be getting into the Wt::dbo soon enough. Patience, for goodness sake! I know you're dying to dive into Wt's ORM but show some restraint!

So, here's the scoop. This is an extremely simple example of how the authentication for PackRapt.com will be implemented. 


Easy, huh? Yeah. As you can see from the login function it simply asks if the user exists. If not, it creates a new user and password in the database. Naturally, we must add an abstraction to the data via Salt/crypt. This example, however, shows one point I'd like to highlight. PackRapt.com will offer an either/or authentication. That is, a user's registration will simply exist or be created. Secure? I guess I'll find out.

I'm heading out to a charity event in Bellevue. Being a little short on time we'll keep this brief. As a review, however, I'll say that we've covered a framework for the authentication and uploads. We've still got a ways to go!

Thank you,

Aaron

Wt Configuration and Experimentation

This is a continuation of the previous post titled PackRapt.com - Outline.


PackRapt.com is a cloud resources search, bundler and mailer. It allows for search and distribution of disparate cloud documents. One stop search and send. In an effort to maximize efficiency while minimizing footprint and resources exploitation I'm moving PackRapt.com to the Wt framework and customizing the search and curation features. These posts document the adventure.


Wt Configuration and Experimentation


I hope you all got a chance to mess around with the Wt examples. Most require a bare-bones install of dependencies. For the others the "optional" dependencies include:
  • GraphicsMagick -> sudo port install GraphicsMagick 
  • FCGI Library -> sudo port install fcgi (libfcgi++ inlcuded in FCGI Library)
  • OpenSSL is -> sudo port install openssl
  • Haruhi Free PDF Library -> sudo port install libharu
  • Fastcgi -> sudo port install mode_ fcgid (Apache2 module) 
  • Asciidoc -> sudo port install asciidoc (Not included with Mac OS X Lion)
I should note that while experimenting with the Wt examples I invoked the built-in web server (wthttpd) with minor limitations. As the development progresses, however, it's likely we'll need a web server that can handle multi-threaded requests. I'll cover the multi-threaded stuff in a future post. Frankly, I'm stuck on the mod_fcgid configuration and need a little time for preparation.


We haven't gotten to the cool stuff yet. I could spend all day on configuration, as you know. As such, I'll break it up a bit and get right to the applicable examples.


For our (my) purposes we'll look into the following Wt examples:
  • Widget Gallery - FormWidgets - The FormWidgets examples shows a file upload
  • Hangman - The Hangman example offers a decent authentication example.
  • JavaScript - Wt's JavaScript example shows a very basic use of JavaScript.
  • TreeView-DragDrop - The TreeView-DragDrop example from Wt shows drag/drop and sorting.
Next we'll examine how the above examples are applicable to PackRapt.com. I'll also go over how Wt implements the parts of the examples I'll be using for PackRapt.com and touch on how we'll use them.


Widget Gallery - FormWidgets


FormWidget offers a simple look at uploads. Naturally, the PackRapt application allows for uploads. What good would a cloud document app be without uploads? Wt has a widget called Wt::WFIleUpload that offers a number of members that will be useful to PackRapt.


Members of the Wt::WFileUpload applicable to PackRapt:
  • void setMultiple () - Allows for multiple uploads
  • WString contentDescription () const - Returns the description of the file
  • WProgressBar* progressBar () - Progress bar fot the upload
  • void setProgressBar (WProgressBar *progressBar)
  • void upload () - You guessed it!
  • bool canUpload () const - Checks whether another upload can be uploaded
  • etc.
The FormWidget example from Wt does this in the following way:




You can see here that the WFileUpload object (fu) is created and set to a new WProgressBar. They both belong to the WContainerWidget object (result). The EventDisplayer object (ed_) is called for any of the three options of changing the upload, finishing the upload, and if the file is too large. This is a very simple look at the initialization of the upload and the results. Fantastic, eh?


You'll notice from the example that the upload is attached and then invokes the progress bar for the fu object. Once the file is uploaded the ed_ object calls the showSignal which displays the applicable message. Very simple. This, however offers a general look at our file upload feature.


Next post we will continue with the Hangman example. We look at rolling our own authentication.


Thank you,


Aaron



Sunday, September 18, 2011

PackRapt.com - Outline


This is a continuation of the previous post titled Application/Search Server - C++.

Where we left off...

Configuring the Boost library with CMake can yield some errors. Not to worry. For anyone who has done any coding you'll know that half the battle is with dependencies and configuration. The best option for me was to install Boost 1.47 from MacPorts.

$ sudo port install boost

From my install directory I cloned the Wt git repository.

$ git clone http://www.webtoolkit.eu/git/wt.git

Then, cd into your Wt directory create a build directory and configure with the Boost library.

$ cd wt
$ mkdir build
$ cd build
$ cmake ../

The small miracle of CMake begins and likely ends with a number of errors relating to the optional dependencies. From there you begin to build the Wt library.

$ make

The only errors I received here had to do with some deprecation warnings for the Android/SSL configuration.  From there you can install the library.

$ make install

You might see an error related to write permissions on a directory to be created. For example - file cannot create directory: usr/local/share/cmake-2.4/Modules. Yeah. You can sudo into admin and go at it.

Once you've got that under control the fun begins. Build the examples from Wt.

$ make -C examples

Work your way around the examples. I think you'll find that they offer a glimpse at the a number of important things. For sake of simplicity I'll start with hello.

The following instructions relate to the wthttpd server included in the library. Naturally, you can configure Apache as well.

For wrhttpd -

$ cd ../examples/hello
$ ln -s ../../resources .
$ ../../build/examples/hello/hello.wt --docroot . --http-address 0.0.0.0 -http-port 8080

You'll notice that the resources are linked along with a call to start the web server. You can include those docroot and web server arguments in your build config in your favorite IDE, if you'd like. It will streamline a number of things later in the project.

Once the server gets kicking you'll see:


And, there you go. You now have the Wt C++ Web Toolkit - hello example running. So, enter your name and...


I'd suggest you try a couple of the other examples. I think you'll find they're rich with possibilities.


So, how does this apply to PackRapt.com?

In consolidating the services used by PackRapt I now have the foundation for a C++ app that will be able to handle indexing, searching, authentication, etc. All-in-one. My goal is to make the search fast and decisive. I know, every search implementation says that they want fast and decisive. Without a disparate set of services like I have currently with PackRapt, however, it's much more likely to meet my expectations.

As such, the outline for building the new PackRapt.com will be:

  1. Prologue
    1. Wt Configuration and experimentation
    2. Library integration with Eclipse CDT
    3. Experiment with Wt Examples
      1. Examine the Wt ORM - Wt::dbo
      2. Integrate Wt::dbo locally
      3. Prepare Wt::dbo for deployment
    4. Create public Git repository
    5. Manymoon setup
  2. Getting into it
    1. Search
      1. Creating a local index
      2. Searching local data
    2. Authentication
      1. Local 
      2. Remote 
    3. Integrate with external sources:
      1. Google Apps
      2. Facebook
      3. Dropbox
      4. Box
      5. LinkedIn
      6. Twitter
    4. Access external services for data
      1. Index external data
      2. Search external data
      3. Internal and External Index Migration
      4. Full Search Integration
    5. Decision Engine
      1. Create
      2. Test
      3. Implement
  3. Getting out of it
    1. Style
      1. Layout and Style
    2. JavaScript Implementation
      1. ExtJS
    3. Finalize UX/UI
  4. Deployment
    1. AWS Setup
      1. EC2
      2. Elastic IP
      3. S3
    2. Test
    3. Deploy
  5. Sell! Wishful thinking again, eh?

That is a rough overview of the PackRapt plan. It'll be a ride for sure. 

There are a couple of ways you can follow and contribute to the mess. I've setup a project on Manymoon. If you'd like to follow along with the project let me know and I'll invite you. Please let me know if you're willing to contribute. I'll send you tasks to complete, as such. That would be great. I'll also create a git repository that'll be hosted on GitHub. Soon!

Well, here we go. I'll see you all soon.

Thank you,

Aaron


Wednesday, September 14, 2011

Application/Search Server - C++

I'll be documenting the redesign of my precious PackRapt.com. It will likely range from interesting banter to weepy regret. That said, however, what good is a challenge without little pain?

The redo will include implementation of a C++ Web Framework called WebToolkit.eu. If that doesn't sound painful, I don't know what does. It's quite popular and you can find a number of useful tools related to it on GitHub.

Previously I developed my PackRapt.com on the Rails 3 Framework. There is, as many of you know, a tremendous amount of community support for Rails and a slightly less amiable but ample community of Ruby devs to exploit. I do, however, enjoy a challenge and a Web Framework in C++ seems like the perfect dare.

The why...

My existing implementation of PackRapt.com relies on a disparate model of search, storage, and processing. In a feeble attempt to curb my curiosity about performance I'd like to consolidate the services as much as I can.

This is a very rough look at the existing architecture of the application:


Ideally, what I'd like in its place:


Now, I know that Heroku is hosted on Amazon Web Services and, as such, there is limited latency in the previous architecture. I thought, however, that I could try to do better. What do I know? The real question is whether I can pull it off. The cure for the insatiable curiosity of a novice is not failure, but success.

Well, let's get started with Wt and see how mad I really am. To start, let's talk about installing Wt.

Dependencies

As with any great C++ roll, the dependencies for Wt are near. The ubiquitous C++ boost library is requisite along with the lovely CMake. There are also a few optional dependencies for PDF Support (Haru) and image support (GraphicsMagick). If you've already got the ImageMagick fork installed you'll be fine - I think. I love ImageMagick, however, and I've been using if with RoR for some time. This installer for ImageMagick is mind-boggling in its simplicity. Kudos to Jon Maddox.

After you have your way with these guys the installation is as follows...

Create a build directory into your Wt root and configure the library with cmake.

$ cd wt-x.xx
$ mkdir build
$ cd build

$ cmake ../

It probably won't work. It never does, huh? If that's the case you can refer to the documentation to guide you through the cmake arguments that might suit your specific setup. It might be a bit painful but we all survive.

Now that we have gotten this far let's take a break. Goodness.

I'll chime in later this week or early next week. We'll tackle the Wt example and get into the design/architecture of PackRapt.com. We'll see...

See you in a few days.

Thank you,

Aaron