Consolidate and streamline Pashua wrapper
This commit is contained in:
171
YubaPrefs.php
171
YubaPrefs.php
@@ -1,12 +1,158 @@
|
||||
<?php
|
||||
|
||||
// YubaPrefs 0.1.0
|
||||
//
|
||||
// Yuba Prefs
|
||||
// //
|
||||
//////////////////////////////////////////
|
||||
|
||||
// Includes
|
||||
// Functions
|
||||
|
||||
require (__DIR__."/functions.php");
|
||||
require (__DIR__."/functions.pashua.php");
|
||||
function makeWindowString($p, $strings) {
|
||||
|
||||
$conf = "
|
||||
# Set window title
|
||||
*.title = Preferences
|
||||
*.floating = 1
|
||||
|
||||
bdest.type = openbrowser
|
||||
bdest.filetype = directory
|
||||
bdest.label = Destination
|
||||
bdest.default = ".$p['bdest']."
|
||||
bdest.width = 380
|
||||
|
||||
postflight.type = popup
|
||||
postflight.label = When finished
|
||||
postflight.option = ".$strings[0][0]."
|
||||
postflight.option = ".$strings[0][1]."
|
||||
postflight.option = ".$strings[0][2]."
|
||||
postflight.default = ".$strings[0][$p['postflight']]."
|
||||
postflight.width = 380
|
||||
|
||||
rsync_dest.type = textfield
|
||||
rsync_dest.label = rsync destination
|
||||
rsync_dest.default = ".$p['rsync_dest']."
|
||||
rsync_dest.placeholder = user@server.com:files/
|
||||
rsync_dest.width = 380
|
||||
|
||||
hr1.type = image
|
||||
hr1.path = ".__DIR__."/hr.png"."
|
||||
hr1.width = 380
|
||||
hr1.height = 2
|
||||
|
||||
stat_mode.type = popup
|
||||
stat_mode.label = POSIX stat()
|
||||
stat_mode.option = ".$strings[3][0]."
|
||||
stat_mode.option = ".$strings[3][1]."
|
||||
stat_mode.option = ".$strings[3][2]."
|
||||
stat_mode.option = ".$strings[3][3]."
|
||||
stat_mode.default = ".$strings[3][$p['stat_mode']]."
|
||||
stat_mode.width = 190
|
||||
|
||||
readability.type = checkbox
|
||||
readability.label = Abort on read errors
|
||||
readability.default = ".$p['readability']."
|
||||
readability.x = 200
|
||||
readability.y = 291
|
||||
|
||||
hr2.type = image
|
||||
hr2.path = ".__DIR__."/hr.png"."
|
||||
hr2.width = 380
|
||||
hr2.height = 2
|
||||
|
||||
spotlight.type = checkbox
|
||||
spotlight.label = Spotlight
|
||||
spotlight.default = ".$p['spotlight']."
|
||||
|
||||
meta.type = checkbox
|
||||
meta.label = Collect external metadata
|
||||
meta.default = ".$p['meta']."
|
||||
meta.x = 200
|
||||
meta.y = 227
|
||||
|
||||
thumbs.type = popup
|
||||
thumbs.label = Thumbnails
|
||||
thumbs.option = ".$strings[1][0]."
|
||||
thumbs.option = ".$strings[1][1]."
|
||||
thumbs.option = ".$strings[1][2]."
|
||||
thumbs.default = ".$strings[1][$p['thumbs']]."
|
||||
thumbs.width = 120
|
||||
|
||||
thumb_priority.type = popup
|
||||
thumb_priority.label = Priority
|
||||
thumb_priority.option = ".$strings[2][0]."
|
||||
thumb_priority.option = ".$strings[2][1]."
|
||||
thumb_priority.option = ".$strings[2][2]."
|
||||
thumb_priority.option = ".$strings[2][3]."
|
||||
thumb_priority.default = ".$strings[2][$p['thumb_priority']]."
|
||||
thumb_priority.width = 120
|
||||
thumb_priority.x = 150
|
||||
thumb_priority.y = 162
|
||||
|
||||
thumb_size.type = textfield
|
||||
thumb_size.default = ".$p['thumb_size']."
|
||||
thumb_size.label = Size
|
||||
thumb_size.placeholder = pixels
|
||||
thumb_size.width = 60
|
||||
thumb_size.x = 300
|
||||
thumb_size.y = 165
|
||||
|
||||
hash.type = checkbox
|
||||
hash.label = Generate hashes
|
||||
hash.default = ".$p['hash']."
|
||||
|
||||
hash_label.type = text
|
||||
hash_label.default = Limit
|
||||
hash_label.x = 200
|
||||
hash_label.y = 128
|
||||
hash_label.width = 40
|
||||
|
||||
hash_limit.type = textfield
|
||||
hash_limit.default = ".$p['hash_limit']."
|
||||
hash_limit.tooltip = Don't hash files larger than X GB
|
||||
hash_limit.width = 60
|
||||
hash_limit.x = 240
|
||||
hash_limit.y = 125
|
||||
|
||||
hash_label_after.type = text
|
||||
hash_label_after.default = GB
|
||||
hash_label_after.x = 304
|
||||
hash_label_after.y = 128
|
||||
hash_label_after.width = 40
|
||||
|
||||
contents.type = checkbox
|
||||
contents.label = Collect file contents
|
||||
contents.default = ".$p['contents']."
|
||||
|
||||
contents_label.type = text
|
||||
contents_label.default = Limit
|
||||
contents_label.x = 200
|
||||
contents_label.y = 88
|
||||
contents_label.width = 40
|
||||
|
||||
contents_limit.type = textfield
|
||||
contents_limit.tooltip = Don't save files larger than X kB
|
||||
contents_limit.default = ".$p['contents_limit']."
|
||||
contents_limit.width = 60
|
||||
contents_limit.x = 240
|
||||
contents_limit.y = 85
|
||||
|
||||
contents_label_after.type = text
|
||||
contents_label_after.default = kB
|
||||
contents_label_after.x = 304
|
||||
contents_label_after.y = 88
|
||||
contents_label_after.width = 40
|
||||
|
||||
profile.type = checkbox
|
||||
profile.label = Attach system profile
|
||||
profile.default = ".$p['profile']."
|
||||
|
||||
cb.type = cancelbutton
|
||||
db.type = defaultbutton
|
||||
db.label = Save
|
||||
";
|
||||
|
||||
return $conf;
|
||||
|
||||
}
|
||||
|
||||
// Read Prefs
|
||||
|
||||
@@ -22,8 +168,20 @@ if(!$p['bdest']) {
|
||||
$strings[] = array("Do nothing","Reveal result in Finder","Upload result with rsync");
|
||||
$strings[] = array("Bypass","Generate","Rebuild");
|
||||
$strings[] = array("external","ql-thumbnail","qltool","qlmanage");
|
||||
$strings[] = array("Bypass","Collect","Collect & verify","Collect & repair atimes");
|
||||
|
||||
$result = Pashua::showDialog(makeWindowString($p, $strings));
|
||||
// Launch Pashua and parse results
|
||||
|
||||
$path = __DIR__."/Pashua.app/Contents/MacOS/Pashua";
|
||||
$raw = shell_exec("echo ".escapeshellarg(makeWindowString($p, $strings))." | ".escapeshellarg($path)." - ");
|
||||
$result = array();
|
||||
foreach (explode("\n", $raw) as $line) {
|
||||
preg_match('/^(\w+)=(.*)$/', $line, $matches);
|
||||
if (empty($matches) or empty($matches[1])) {
|
||||
continue;
|
||||
}
|
||||
$result[$matches[1]] = $matches[2];
|
||||
}
|
||||
|
||||
// User cancelled
|
||||
|
||||
@@ -37,6 +195,7 @@ if (@$result['cb']) {
|
||||
$result['postflight'] = array_search($result['postflight'],$strings[0]);
|
||||
$result['thumbs'] = array_search($result['thumbs'],$strings[1]);
|
||||
$result['thumb_priority'] = array_search($result['thumb_priority'],$strings[2]);
|
||||
$result['stat_mode'] = array_search($result['stat_mode'],$strings[3]);
|
||||
|
||||
// If the user didn't specify a destpath, set to default
|
||||
|
||||
|
||||
Reference in New Issue
Block a user