public
Description: Core libraries for creating client apps in HTML/JS runtimes
Home | Edit | New

Home

The SpazCore Component Library

SpazCore is a set of components designed to make development of Twitter (and other “lifestream” services) clients easier. It is written in JavaScript, and suitable for applications based on AIR, Titanium, and webOS, although most browser engine-based platforms should be able to utilize many aspects.

Major Elements

SpazCore is made up of four major elements: libraries (libs), helpers, platform-specific extensions (platforms), and vendor libraries (vendors)

Libraries libs/

These are components that handle more complex functionality. Right now SpazCore has the following libs:

  • SpazCore (libs/spazcore.js): the base library
  • SpazTwit (libs/spaztwit.js): a Twitter API library
  • SpazPingFM (libs/spazpingfm.js): a Ping.fm library
  • SpazPrefs (libs/spazprefs.js): a preferences library
  • SpazShortText (libs/spazshorttext.js): a text shortening library (think txtspeak)
  • SpazShortURL (libs/spazshorturl.js): a URL shortening/expanding library
  • SpazTemplate (libs/spaztemplate.js): a simple library for storing and parsing templating methods
  • SpazTemplate (libs/spaztimeline.js): a library for updating and managing a chronological list of items in the UI (like, say, a Twitter timeline)

As of this writing, many of these libraries range from “mostly done and usable” to “barely a skeleton.” Additionally, database abstraction and possibly ORM libraries are planned.

Helpers helpers/

Helpers are single-task functions to handle common tasks. All helpers in SpazCore are under the sc.helpers.### namespace to avoid collisions. Helper definitions are separated by task into different files:

  • Date and Time (helpers/datetime.js): functions to handle common date/time tasks, like generating relative time descriptions
  • Event (helpers/event.js): event listening and triggering helpers, based on standard DOM events
  • JavaScript (helpers/javascript.js): JS language helpers for things like type checking
  • JSON (helpers/json.js): JSON encoding and decoding helpers (based on the JSON2.js library)
  • Strings (helpers/string.js): string tasks, like converting URLs and Twitter @usernames into links
  • System (helpers/sys.js): Platform and OS-related tasks like platform detection and file manipulation. Most of these require loading a platform-specific extension
  • View (helpers/view.js): Helpers for common view (UI) tasks, like removing duplicate elements in an HTML Twitter timeline
  • XML (helpers/xml.js): XML processing helpers

Platforms platforms/

SpazCore attempts to provide a common API for its functionality, regardless of the platform. Some functionality requires platform-specific code, such as file operations. To accommodate this, some function definitions in SpazCore are “stubs,” and the developer has to load a platform-specific set of definitions for their target platform. At the moment, platform-specific files are needed for the System helpers and the SpazPrefs library:

  • platforms/[platform]/helpers/sys.js
  • platforms/[platform]/libs/spazprefs.js

As of this writing, the SpazPrefs library has not had its platform-specific code separated into platform files.

Vendor Libraries vendors/

SpazCore is built on some open-source JS libraries. All of these are stored in the vendors/ folder. These include:

  • jQuery: (currently version 1.3.2); used for event handling, AJAX requests, and some View helpers
  • JSON2.js: for encoding and decoding JSON safely
  • webtoolkit.base64: for generating base64 hashes

Reducing the need for vendor libraries would be helpful, especially when they could conflict with other codebases.

Other elements

Tests tests/

We aren’t TDD monkeys or anything, but we’ve attempted to write unit tests where reasonable. Right now we have tests for a few of the string helpers, but we could use a lot more coverage.

Current Plans and Needs

Reduce the reliance on jQuery

We’ve done a lot of this already by developing the Event helpers and using those instead of jQuery binding and triggering. We should also add helpers for event delegation, as that’s something we do often and for now rely on jQuery. Our view helpers still mainly use jQuery as well, but if we move the actual DOM queries into wrapper functions and use native methods as much as possible, we can make it a lot easier for the developer to override the DOM stuff with their own code.

SpazTwit still can utilize jQuery triggering, but will only do so if a specific option is passed.

That being said, if we are careful to use jQuery in a non-conflicting manner, we should be able to utilize it fairly seamlessly, so devs using another popular framework don’t have issues.

Fill in skeletal libraries

Lots of the libraries just aren’t filled-in yet. They need to be.

Remove all inline platform-specific code

SpazPrefs especially has a lot of if (isPlatform) {...} type code in it, and this needs to be broken out into platforms.

More data/api libraries

Photo uploaders? Shortlink services? RSS/ATOM parsers?

Last edited by funkatron, Mon Jun 22 14:12:10 -0700 2009
Home | Edit | New
Versions: