• Stars
    star
    303
  • Rank 137,655 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 13 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Semantic Interaction Framework for JavaScript

VIE Vienna IKS Editables

VIE is a utility library for implementing decoupled Content Management systems. VIE is developed as part of the EU-funded IKS project.

Decoupled CMS communications

  • In French, vie means life, showcasing how VIE makes your website come alive
  • In English, vie means striving for victory or superiority

VIE development is now targeting a 2.0 release. Read this blog post to find out the changes from VIE 1.0. There is also a good introductory post on VIE on the IKS blog.

VIE integration in nutshell

Adding VIE to your system is as easy as:

  1. Mark up your pages with RDFa annotations
  2. Include vie.js into the pages
  3. Implement Backbone.sync

Changes

Please refer to the CHANGES.md document.

Common representation of content on HTML level

A web editing tool has to understand the contents of the page. It has to understand what parts of the page should be editable, and how they connect together. If there is a list of news for instance, the tool needs to understand it enough to enable users to add new news items. The easy way of accomplishing this is to add some semantic annotations to the HTML pages. These annotations could be handled via Microformats, HTML5 microdata, but the most power lies with RDFa.

RDFa is a way to describe the meaning of particular HTML elements using simple attributes. For example:

<div id="myarticle" typeof="http://rdfs.org/sioc/ns#Post" about="http://example.net/blog/news_item">
    <h1 property="dcterms:title">News item title</h1>
    <div property="sioc:content">News item contents</div>
</div>

Here we get all the necessary information for making a blog entry editable:

  • typeof tells us the type of the editable object. On typical CMSs this would map to a content model or a database table
  • about gives us the identifier of a particular object. On typical CMSs this would be the object identifier or database row primary key
  • property ties a particular HTML element to a property of the content object. On a CMS this could be a database column

As a side effect, this also makes pages more understandable to search engines and other semantic tools. So the annotations are not just needed for UI, but also for SEO.

Common representation of content on JavaScript level

Having contents of a page described via RDFa makes it very easy to extract the content model into JavaScript. We can have a common utility library for doing this, but we also should have a common way of keeping track of these content objects. Enter Backbone.js:

Backbone supplies structure to JavaScript-heavy applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing application over a RESTful JSON interface.

With Backbone, the content extracted from the RDFa-annotated HTML page is easily manageable via JavaScript. Consider for example:

v = new VIE();
v.use(new v.RdfaService());
v.load({element: jQuery('#myarticle')}).from('rdfa').execute().success(function(entities) {
    _.forEach(entities, function(entity) {
        entity.set({'dcterms:title': 'Hello, world'});
        entity.save(null, {
            success: function(savedModel, response) {
                alert("Your article '" + savedModel.get('dcterms:title') + "' was saved to server");
            }
        });
    })
    console.log("We got " + entities.length + " editable objects from the page");
});

The classic VIE API will also work:

var v = new VIE({classic: true});
var objectInstance = v.RDFaEntities.getInstance(jQuery('#myarticle'));
objectInstance.set({'dcterms:title': 'Hello, world'});
objectInstance.save(null, {
    success: function(savedModel, response) {
        alert("Your article '" + savedModel.get('dcterms:title') + "' was saved to server");
    }
});

This JS would work across all the different CMS implementations. Backbone.js provides a quite nice RESTful implementation of communicating with the server with JSON, but it can be easily overridden with CMS-specific implementation by just implementing a new Backbone.sync method.

Example

There is a full static HTML example of VIE at work. Saving outputs the edited contents as JSON into the JavaScript console:

Be sure to read the annotated VIE source code for API documentation.

I/O operations

All Input/Output operations of VIE are based on the jQuery Deferred object, which means that you can attach callbacks to them either before they run, or also after they've been run.

The operations may either succeed, in which case the then callbacks will fire, or be rejected, in which case the fail callbacks will fire. Any then callbacks will fire in either case.

Dependencies

VIE uses the following JavaScript libraries:

Some functionality in VIE additionally uses:

  • RdfQuery as a triplestore and for reasoning over rules

Integrations

Using VIE on Node.js

VIE is a CommonJS library that works on both browser and the server. On Node.js you can install it with:

npm install vie

Here is a simple Node.js script that uses VIE for parsing RDFa:

var jQuery = require('jquery');
var vie = require('vie');

// Instantiate VIE
var VIE = new vie.VIE();

// Enable the RDFa service
VIE.use(new VIE.RdfaService());

var html = jQuery('<p xmlns:dc="http://purl.org/dc/elements/1.1/" about="http://www.example.com/books/wikinomics">In his latest book <cite property="dc:title">Wikinomics</cite>, <span property="dc:creator">Don Tapscott</span> explains deep changes in technology, demographics and business.</p>');

// 
VIE.load({element: html}).from('rdfa').execute().done(function() {

  var objectInstance = VIE.entities.get('http://www.example.com/books/wikinomics');

  console.log(objectInstance.get('dc:title'));

});

Development

VIE development is coordinated using Git at bergie/VIE.

Feel free to report issues or send pull requests if you have ideas for pushing VIE forward. Contributions that include their own unit tests appreciated!

Development discussions happen on the VIE mailing list and the #iks channel on Freenode. See also VIE on Ohloh.

Code organization

VIE source code is inside the src directory. Each separate unit of functionality should be handled in its own file, with the src/VIE.js being the entry point to the system.

VIE architecture

Building VIE

The VIE library consists of many individual pieces that we merge together in the build process. You'll need Grunt. Then just run:

$ grunt build

The built VIE library will appear in the dist folder.

Core-only distribution

In addition to the regular full build, there is also a slimmer build of VIE available that only includes the core parts of the library and no external service. To build that instead, run:

$ grunt build:core

Running Unit Tests

Direct your browser to the test/index.html file to run VIE's QUnit tests.

Unit tests on Node.js

The Grunt testing setup includes multiple parts. With it, you can test the library on both Node.js and a headless browser. Run:

$ grunt test

or:

$ npm test

Automatic unit tests

You can also run the Grunt setup in watch mode, where any change in VIE sources or tests will trigger a rebuild and test run:

$ grunt watch

Continuous integration

VIE uses Travis for continuous integration. Simply add your fork there and every time you push you'll get the tests run.

Build Status Greenkeeper badge

More Repositories

1

create

Midgard Create, a generic web editing interface for any CMS
JavaScript
2,473
star
2

hallo

Simple rich text editor (contentEditable) for jQuery UI
CoffeeScript
2,435
star
3

dnode-php

DNode RPC protocol implementation for PHP
PHP
429
star
4

where

Geographical utilities for location-based Node.js applications
JavaScript
56
star
5

MidgardAppServerBundle

Run Symfony2 applications on the AppServer-in-PHP
PHP
46
star
6

blogsiple

Simple NodeXT CMS serving as the official Create integration testbed
JavaScript
31
star
7

ViePalsu

Collaborative meeting tool
CoffeeScript
27
star
8

resource-juggling

CRUD in Node.js made easy
CoffeeScript
24
star
9

dotfiles

My Linux dotfiles
Vim Script
23
star
10

nodext

Plugin-driven Node.js applications
CoffeeScript
19
star
11

noweb.php

Literate programming tool for PHP
PHP
18
star
12

actionbar

Android-style Action Bar for Backbone.js
JavaScript
15
star
13

midgardmvc_helper_urlize

Clean URL name generator for PHP
PHP
10
star
14

flowcopter

NoFlo and AR.Drone examples
HTML
7
star
15

zombie-qunit

Example of running QUnit client-side tests with the Zombie headless browser
JavaScript
7
star
16

MidgardToolbarBundle

Simple toolbars system for Symfony2
PHP
6
star
17

MidgardMvcCompatBundle

Compatibility bundle for running Midgard MVC components and applications in Symfony2
PHP
6
star
18

org_couchdb_replication

Midgard MVC interface to CouchDb replication protocol
PHP
5
star
19

urlizer_service

Heroku PHP app for converting strings to clean URL names
PHP
5
star
20

subethaedit-zenburn

Zenburn color schemes for the SubEthaEdit collaborative editor
5
star
21

midgardmvc_helper_location

Location services for Midgard MVC
PHP
5
star
22

talks

Various presentation slides
CSS
5
star
23

nodext-create

Create CMS UI extension for nodext
CoffeeScript
4
star
24

buscatcher

See Helsinki buses and trams moving on map in real time
Python
4
star
25

midgardmvc_helper_workflow

Workflow engine for Midgard MVC
PHP
4
star
26

xpress-demo

noflo-xpress demo app
JavaScript
4
star
27

basecamptools

Tools for working with Basecamp
PHP
3
star
28

net_nemein_avaudu

Midgard2 based microblogging client
JavaScript
3
star
29

wikipedia2poi

Script for populating maemomapper POI database with local Wikipedia entries
3
star
30

midgardmvc_ui_forms

Forms designer for Midgard MVC
PHP
3
star
31

MidgardConnectionBundle

Midgard2 repository connection for Symfony2
PHP
3
star
32

org_midgardproject_productsite

Midgard-based product site system for Open Source apps
JavaScript
3
star
33

node-socket-repeater

CoffeeScript
3
star
34

Symfony2ForMidgardians

Symfony2 tutorial for Midgard developers
2
star
35

org_midgardproject_documentation

Midgard documentation viewer
PHP
2
star
36

ocs-test

Open Collaboration Services API tests
CoffeeScript
2
star
37

quteqaiku

QML Qaiku client
C++
2
star
38

bergie.github.com

Sources for my website
HTML
2
star
39

midgardmvc_ui_learn

Midgard MVC documentation browser
PHP
2
star
40

MidgardMidcomCompatBundle

Compatibility bundle for running MidCOM 8.09 components and applications in Symfony2
PHP
2
star
41

heroku-buildpack-midgardmvc

Heroku build pack for Midgard MVC PHP applications
Shell
2
star
42

org_midgardproject_news

News aggregation and display component for Midgard Project website
PHP
2
star
43

playfield

1
star
44

grunt-component

Wrapper around component(1) for grunt
JavaScript
1
star
45

tmp

Testing stuff
CoffeeScript
1
star
46

heroku-buildpack-midgard-mvc

Heroku buildpack for running Midgard MVC applications
1
star
47

noadmin-noflo-components

NoFlo components for the NoAdmin PoC
1
star
48

routabackup

Batch process for backing up an old MidCOM site from Wayback Machine
CoffeeScript
1
star
49

dwm

My custom version of dwm
C
1
star