Skip to content

Rich Stokoe

aerospace, cars, finance, leadership, opinion, tech

Menu
  • Learning to Fly
  • Patents
  • Publications
  • Reading List
Menu

Introducing…. Meteoric

Posted on May 31, 2012June 5, 2012 by rich
This has nothing to do with JavaScript. Sorry.

Meteoric (source: http://github.com/richstokoe/Meteoric, documentation: http://richstokoe.github.com) is a JavaScript framework that allows UIs to be built on-the-fly driven by JSON metadata. The JSON metadata is parsed by “writers“, very focussed JavaScript functions which understand the specific requirements of that metadata and spit out HTML to the DOM. Styling is done through CSS.

The idea is that you can build web applications very quickly simply by breaking down your applications into [data] and [renderers for the data].

 

Data

Consider the following JSON object representing a customer:

var customer = {
    "type": "customer",
    "id": "1234",
    "name": "John Smith Ltd.",
    "email": "john@example.com"
}

In reality, this will come from a database. ASP.NET MVC has a great way of converting IQueryable<T> objects from LINQ data sources into JSON objects. At the end of the controller action you simply call Json(object);

http://northwindCo/Customers/1234

[HttpGet]
public ActionResult Customers(Int64 id)
{
    // TODO: Some defensive programming - what if 'id' is -1?

    // Get customer
    Customer customer = this.CustomerRepository.GetCustomer(id);

    // Serialise as JSON object
    return Json(customer, JsonBehavior.AllowGet);
}

 

Writers

A Writer is a very simple JavaScript function which is registered with Meteoric against a particular type and is used to spit out HTML into the DOM.

$.meteoric.writers.customer = function (context, entity) {
    context.parent.append('<h1>' + entity.name + ' (' + entity.id + ')</h1>'
                                 + 'Contact: <a href="mailto:' + entity.email + '">' + entity.email + '</a>');
}

 

Bringing It All Together

The final step is to take your Customer object and pass it into the jQuery.meteoric extension method:

$("#customerDiv").meteoric({ entity: customer });

This will then produce the following:

 

John Smith Ltd. (1234)

Contact: john@example.com

 

Meteoric comes with a built-in generic writer for types of “businessObject”, which relies on the JSON object having a “fields” array. Each field is then parsed by a suitable writer.

You can see more examples at http://richstokoe.github.com/ and you can download the source at http://github.com/richstokoe/Meteoric/

This is a very active project, I will be updating this a lot over the next few weeks. It probably isn’t a good idea to start writing anything too critical against Meteoric yet, as the API isn’t stable. Add your feedback and feature requests in the comments below.

 

 

Category: Software

Pages

  • Learning to Fly
  • Patents
  • Publications
  • Reading List

Categories

Architecture (2) Artificial Intelligence (8) Aviation (25) Bad Company (2) Books (1) Cars (2) Civil Aviation (27) Code (16) Companies (28) Entertainment (1) Featured (18) Film (1) Finance (4) Fitness (2) Gaming (4) General Aviation (26) Internet (28) Leadership (1) Military Aviation and Space (1) Mobile (7) Motoring (2) Open Finance (1) Payments (1) People (11) Places and Events (12) Politics (8) Products (6) Quantum Computing (1) Search (6) Security (1) Social (5) Social Business (3) Social Media (6) Software (22) Sports (2) Technology (48) TV (1) Uncategorized (22)

Recent Posts

  • TOON – The AI Data Format Designed to Save You Money
  • Building a 2nd Brain: Your Personal, AI-Augmented Knowledge Manager
  • State of the AI Nation 5: Walking the Talk
  • Learning to Fly: Lesson 25 (Video)
  • Learning to Fly: Lesson 24
  • Learning to Fly: Lesson 23 (Full Flight Video)
  • State of the AI Nation 4: Open AI Update
  • Learning to Fly: Lesson 22
  • Q-Day and Post-Quantum Cryptography
  • Tabs and Pockets – The Secret to Building Highly Effective Teams
© 2025 Rich Stokoe | Powered by Minimalist Blog WordPress Theme