Skip to content

Gizra/zariz

Repository files navigation

Build Status

"Site preview" module suite for Drupal 7.x

Zariz is a suite of Drupal modules and methodology, that models content (nodes) creation and editing similar to Git's branches, and allows generating static sites from the Drupal backend.

Posts and videos

Live Demo

  1. Launch a sandbox in http://simplytest.me/project/zariz/7.x-1.x
  2. Navigate to /live/user and login (user: admin pass: admin)
  3. Navigate to admin/content/migrate and migate the content
  4. Back in the homepage, you can now branch, create and edit content, and merge

Creating branch

The OG (Organic groups) group type Branch is equivalent to a Git branch.

// Create a new "master" branch. There can be only a single master on the site.
$live_node = zariz_create_branch('live');

// Branch out fom the live branch.
$dev_node = zariz_create_branch('dev', $live_node);

Merging branches

We can check if there are merge conflicts - meaning that there is already a newer content in the "to branch". Zariz will auto-detect the parent branch.

$conflicts = zariz_get_merge_conflicts($dev_node->nid);

If there are no conflicts, we can merge - meaning that content from the "from branch" will be cloned into the "to branch".

$snapshot = zariz_merge_branch($dev_node->nid);

Working with Snapshots

Snapshots holds information about the content of a branch at a certain time. This is done by simply holding the last entity ID (e.g. node) that existed. The last entity ID can keep changing as long as the snapshot is not locked.

// Get the last snapshot from a branch.
$snapshot = zariz_get_snapshot_from_branch($live_node->nid);

// Check if a snapshot is locked.
$snpashot->isLocked()

// Lock a snpashot.
$snpashot->lock()

Query alter

Zariz can alter a query to the node table, to reflect the content in a certain branch. The altering is opt-in, by settings the zariz query tag. For example:

$query = new EntityFieldQuery();
$result = $query
  ->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'article')
  // Set the Zariz query tag.
  ->addTag('zariz')
  // Set explicitly the Branch ID. If this Metadata is omitted, the
  // OG-context will be used.
  ->addMetaData('zariz', array('branch_id' => $branch_id))
  ->propertyOrderBy('nid')
  ->execute();

The same query tag can be also used in Views. For example in /admin/structure/views/view/branch_content/edit under Query settings => Query Tags notice that the zariz tag was added.

Dependencies

Commerce integration

"Zariz commerce" module integrates with commerce and allows smart revisioning of commerce products.

Typical permissions setup

  • In admin/people/permissions grant authenticated user Branch: Create new content
  • In admin/config/group/permissions/node/branch grant non-member and member roles the following permissions:
  • Merge branch
  • Create Article content
  • Edit any Article content

Example module

Enable zariz_example module and follow its README Here is the Drush command to download and install Zariz Example:

drush dl entityreference_prepopulate replicate node_clone
drush dl og --dev
drush en zariz_example

Static site

It is possible (and optional) to export Zariz sites in a scalable manner using generator-zariz.

Developed by Gizra