'Returns JSON or HTML respresentation of the dashboard.
If IPython is not imported, returns a pretty print of the dashboard
dict. Otherwise, returns an IPython.core.display.HTML display of the
dashboard.
The algorithm used to build the HTML preview involves going through
the paths of the node generator of the dashboard. The paths of the
dashboard are sequenced through from shorter to longer and whether
it\'s a box or container that lies at the end of the path determines
the action.
If it\'s a container, draw a line in the figure to divide the current
box into two and store the specs of the resulting two boxes. If the
path points to a terminal box (often containing a plot), then draw
the box id in the center of the box.
It\'s important to note that these box ids are generated on-the-fly and
they do not necessarily stay assigned to the boxes they were once
assigned to.'

def get_preview(self):

    if (IPython is None):
        pprint.pprint(self)
        return
    elif (self['layout'] is None):
        return IPython.display.HTML(dashboard_html)
    x = 0
    y = 0
    box_w = MASTER_WIDTH
    box_h = MASTER_HEIGHT
    html_figure = dashboard_html
    box_ids_to_path = self._compute_box_ids()
    path_to_box_specs = {}
    first_box_specs = {'top_left_x': x, 'top_left_y': y, 'box_w': box_w, 'box_h': box_h}
    path_to_box_specs[('first',)] = first_box_specs
    (all_nodes, all_paths) = self._make_all_nodes_and_paths()
    max_path_len = max((len(path) for path in all_paths))
    for path_len in range(1, (max_path_len + 1)):
        for path in [path for path in all_paths if (len(path) == path_len)]:
            current_box_specs = path_to_box_specs[path]
            if (self._path_to_box(path)['type'] == 'split'):
                html_figure = _draw_line_through_box(html_figure, current_box_specs['top_left_x'], current_box_specs['top_left_y'], current_box_specs['box_w'], current_box_specs['box_h'], direction=self._path_to_box(path)['direction'])
                is_horizontal = (self._path_to_box(path)['direction'] == 'horizontal')
                x = current_box_specs['top_left_x']
                y = current_box_specs['top_left_y']
                box_w = current_box_specs['box_w']
                box_h = current_box_specs['box_h']
                if is_horizontal:
                    new_box_w = (box_w / 2)
                    new_box_h = box_h
                    new_top_left_x = (x + (box_w / 2))
                    new_top_left_y = y
                else:
                    new_box_w = box_w
                    new_box_h = (box_h / 2)
                    new_top_left_x = x
                    new_top_left_y = (y + (box_h / 2))
                box_1_specs = {'top_left_x': x, 'top_left_y': y, 'box_w': new_box_w, 'box_h': new_box_h}
                box_2_specs = {'top_left_x': new_top_left_x, 'top_left_y': new_top_left_y, 'box_w': new_box_w, 'box_h': new_box_h}
                path_to_box_specs[(path + ('first',))] = box_1_specs
                path_to_box_specs[(path + ('second',))] = box_2_specs
            elif (self._path_to_box(path)['type'] == 'box'):
                for box_id in box_ids_to_path:
                    if (box_ids_to_path[box_id] == path):
                        number = box_id
                html_figure = _add_html_text(html_figure, number, path_to_box_specs[path]['top_left_x'], path_to_box_specs[path]['top_left_y'], path_to_box_specs[path]['box_w'], path_to_box_specs[path]['box_h'])
    return IPython.display.HTML(html_figure)
