Understanding dojo.require

Dojo provides a feature-rich system for including JavaScript modules. Before we begin this journey to explore this concept in depth, you should know that absolutely no knowledge of the Dojo module, packaging, and build system are required to use Dojo.

You can easily get started using Dojo by using a script element referring to a copy of Dojo on the AOL or Google CDNs. If you want to host your own version of Dojo, you can easily download dojo.js, include it in a web page using a script element, and be off and running with Dojo Base.

For those new to Dojo, the following resources give a quick overview of Dojo Base:

In general, dojo.js is a lot like jquery.js or prototype js: you get a competitive set of features founds in most JavaScript libraries that are essential for building great web applications. Those features include:

  • JavaScript Language Helpers
  • Object utilities
  • Array utilities
  • DOM Manipulation
  • A normalized event system
  • Ajax & Cross domain requests
  • JSON utilities
  • Simple effects
  • Browser sniffing

Continue reading

Can Flash Thrive Going Forward?

The short answer: Yes, if it changes its strategy to one that embraces and augments the open web ecosystem, rather than continuing down the path of trying to compete with or replace it.

With the recent anti-Flash, pro-HTML5 buzz caused by the iPad and sites like YouTube offering HTML5-enabled video alternatives, I thought it would be useful to share my thoughts on the opportunities and struggles Adobe faces with the Flash platform. Given my propensity as a strong open-source advocate, it may seem odd that I bother to discuss this, but it’s an interesting thought experiment for me on where Flash still excels compared to the open web, and how it can leverage that to thrive as part of the world going forward.

Continue reading

Object Capability Model and Facets in Perstore/Pintura

This entry is part 6 of 12 in the series Server-Side JavaScript, Pintura, and Persevere 2.0

The object capability model is an approach to security that utilizes object references as the primary means of controlling access and providing authority. Capability-based security follows the principle of using unforgeable capabilities to provide access to resources. Object capability builds on capability-based security by leveraging object references as the primary representation of capabilities, which are naturally unforgeable in memory safe languages. Object capability based security is an elegant approach to security because the goals of object-oriented principles of encapsulation and information hiding are realized in virtually the same exact manner as the principle of least authority that is at the heart of object capability security. This type of security is extremely flexible and customizable since it is based on object-oriented design. Plus, writing good code naturally leads to secure code, security can be designed with object encapsulation hand-in-hand.

Continue reading

Learning Dojo

There is so much existing information about the Dojo Toolkit that it can be challenging to know where to begin. The following is a Dojo curriculum (I use this term loosely) highlighting community resources and a logical path for self-learning the foundational parts of Dojo.  If you understand the purpose of a variable and function, or you are new to Dojo, then this is for you.

Continue reading

Pintura JSGI Modules

This entry is part 5 of 12 in the series Server-Side JavaScript, Pintura, and Persevere 2.0

Pintura is a REST-style web framework that provides a comprehensive solution for Ajax-based thin-server applications. However, Pintura has a very modular design, and many of the modules in Pintura are extremely useful as standalone JavaScript/CommonJS components that can be used with Node, Narwhal and other projects. Let’s look at the JSGI middleware modules. JSGI middleware modules are designed to be used in a JSGI HTTP request handling stack, adding functionality to a web application. An example of using a JSGI middleware:

exports.app = MiddleWare( // wrapped my application with middleware
  function(request){
     ... my JSGI application ...
  });

Continue reading

General Interface – Dojo Integration and Runtime Metadata

General Interface (GI) recently joined the Dojo Foundation as part of a transition to a true comprehensive 100-point open source project. TIBCO open sourced GI a number of years ago, but now GI can enjoy the benefits of running under the Dojo Foundation and being integrated with the infrastructure for open SVN, bug tracking, and more. Not only is GI is part of the foundation, but GI now includes significant integration with the Dojo Toolkit. The powerful GI builder, a web-based visual IDE for building client side web applications, now is capable of utilizing Dojo widgets as well as the GI set of widgets.

gi-dojo.png

Continue reading

CommonJS Utilities

This entry is part 4 of 12 in the series Server-Side JavaScript, Pintura, and Persevere 2.0

CommonJS Utils is a collection of general purpose CommonJS-compliant modules. These modules can be used on Narwhal, Node, and other CommonJS platforms. The modules include:

  • json-schema.js – This is a JSON Schema validator module. It can be used to validate data structures using JSON schema definitions. For example:
    var validate = require("json-schema").validate;
    var data = {name: "Test"};
    var schema = {
      properties: {
         name: {type: "string"},
         age: {type: "number"}
      }
    };
    var validation = validate(data, schema);
    validation.valid -> false
    validation.errors -> indicates that age was not provided
    data.age = 30;
    var validation = validate(data, schema);
    validation.valid -> true
    

    This module also supports using standard native constructors as type definitions. The schema above could be written
    more briefly:

    var schema = {
      properties: {
         name: String,
         age: Number
      }
    };
    
  • Continue reading