-
Notifications
You must be signed in to change notification settings - Fork 2
/
stylewriter.drush.inc
86 lines (73 loc) · 2.03 KB
/
stylewriter.drush.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
// $Id$
/**
* @file
* StyleWriter module drush integration.
*/
/**
* Implementation of hook_drush_command().
*
* @See drush_parse_command() for a list of recognized keys.
*
* @return
* An associative array describing your command(s).
*/
function stylewriter_drush_command() {
$items = array();
$items['stylewriter-cache-all'] = array(
'callback' => 'stylewriter_seed',
'description' => "Seed StyleWriter Tiles",
'options' => array(
'tileserver_url' => 'Base URL of the TileLive server'
),
'drupal dependencies' => array('stylewriter'),
);
return $items;
}
/**
* Implementation of hook_drush_help().
*/
function stylewriter_drush_help($section) {
switch ($section) {
case 'drush:stylewriter':
return dt("Cache tiles on a TileLite instance");
}
}
function stylewriter_seed() {
if ($tileserver_url = drush_get_option('tileserver_url')) {
drush_print(dt("Seeding tiles on a TileLite instance..."));
$data_facets = module_invoke_all('stylewriter_data_possible_facets');
/*
drush_print(dt("## DATA FACETS"));
foreach ($data_facets as $facet) {
drush_print(dt("* !facet", array('!facet' => $facet)));
}
*/
$mapfile_facets = module_invoke_all('stylewriter_mapfile_possible_facets');
/*
drush_print(dt("## MAPFILE FACETS"));
foreach ($mapfile_facets as $facet) {
drush_print(dt("* !facet", array('!facet' => $facet)));
}
*/
if (count($data_facets) > 1) {
exit('Only one data facet is currently supported');
}
foreach ($mapfile_facets as $facet) {
drush_print(dt('Caching !facet', array('!facet' => $facet)));
$mapfile = $facet;
$data = $data_facets[0];
$cmd = 'tileseed.py ' .
'--url="' . $tileserver_url . '" ' .
'--data="' . $data . '" ' .
'--extension="' . 'png' . '" ' .
'--mapfile="' . $mapfile . '" ' .
'0 2';
drush_print('Running ' . $cmd);
_drush_proc_open($cmd);
}
}
else {
drush_print('--tileserver_url required');
}
}