Skip to content

Commit

Permalink
master
Browse files Browse the repository at this point in the history
  • Loading branch information
AImager committed Jun 23, 2019
1 parent 346af75 commit e5c2494
Show file tree
Hide file tree
Showing 15 changed files with 199 additions and 167 deletions.
Binary file modified 055ECEC4-B7F5-4100-8CDE-A023FF61A467.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified C1563D58-8291-4E0F-A111-35D965760584.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified FA97111C-147E-495D-8A96-BB0E6F708500.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 20 additions & 4 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@
<dict>
<key>alfredfiltersresults</key>
<false/>
<key>alfredfiltersresultsmatchmode</key>
<integer>0</integer>
<key>argumenttreatemptyqueryasnil</key>
<false/>
<key>argumenttrimmode</key>
<integer>0</integer>
<key>argumenttype</key>
Expand Down Expand Up @@ -114,7 +118,7 @@
<key>uid</key>
<string>FA97111C-147E-495D-8A96-BB0E6F708500</string>
<key>version</key>
<integer>2</integer>
<integer>3</integer>
</dict>
<dict>
<key>config</key>
Expand Down Expand Up @@ -144,6 +148,10 @@
<dict>
<key>alfredfiltersresults</key>
<false/>
<key>alfredfiltersresultsmatchmode</key>
<integer>0</integer>
<key>argumenttreatemptyqueryasnil</key>
<false/>
<key>argumenttrimmode</key>
<integer>0</integer>
<key>argumenttype</key>
Expand Down Expand Up @@ -182,13 +190,17 @@
<key>uid</key>
<string>ED8263F6-7B34-41EF-9127-43C32B9F1243</string>
<key>version</key>
<integer>2</integer>
<integer>3</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>alfredfiltersresults</key>
<false/>
<key>alfredfiltersresultsmatchmode</key>
<integer>0</integer>
<key>argumenttreatemptyqueryasnil</key>
<false/>
<key>argumenttrimmode</key>
<integer>0</integer>
<key>argumenttype</key>
Expand Down Expand Up @@ -227,13 +239,17 @@
<key>uid</key>
<string>C1563D58-8291-4E0F-A111-35D965760584</string>
<key>version</key>
<integer>2</integer>
<integer>3</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>alfredfiltersresults</key>
<false/>
<key>alfredfiltersresultsmatchmode</key>
<integer>0</integer>
<key>argumenttreatemptyqueryasnil</key>
<false/>
<key>argumenttrimmode</key>
<integer>0</integer>
<key>argumenttype</key>
Expand Down Expand Up @@ -272,7 +288,7 @@
<key>uid</key>
<string>055ECEC4-B7F5-4100-8CDE-A023FF61A467</string>
<key>version</key>
<integer>2</integer>
<integer>3</integer>
</dict>
</array>
<key>readme</key>
Expand Down
Binary file modified media/vscode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/get_current_folder.applescript
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ on run theQuery
tell application "Finder"
set pathList to (quoted form of POSIX path of (folder of the front window as alias))
end tell

return pathList
end run
42 changes: 23 additions & 19 deletions src/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,30 @@

// use SimpleXMLElement;

class Log {
public static function info($info) {
$file = fopen($_SERVER['HOME'] . "/Downloads/debug.txt", "w+");
fwrite($file, "\n" . print_r($info, true));
fclose($file);
}
class Log
{
public static function info($info)
{
$file = fopen($_SERVER['HOME'] . "/Downloads/debug.txt", "w+");
fwrite($file, "\n" . print_r($info, true));
fclose($file);
}
}

try {
$src = new Source();
$term = $_SERVER['argv'][1];
$node_coll = new NodeCollection($src);

// Log::info(print_r($node_coll->find($term), true));
echo $node_coll->find($term)
->filter(strlen($term)&0xFFFFFFFE/2)
->sort()
->to_xml();
}
catch (Exception $e) {
Log::info(print_r($e->getLine(), true));
}
$src = new Source();
$term = $_SERVER['argv'][1];
$node_coll = new NodeCollection($src);


$result = $node_coll->find($term)
->filter(strlen($term) & 0xFFFFFFFE / 2)
->sort()
->to_xml();

echo $result;

// Log::info(print_r($result, true));
} catch (Exception $e) {
Log::info(print_r($e->getLine(), true));
}
32 changes: 18 additions & 14 deletions src/node/AtomNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,39 @@

namespace alfmarks;

class AtomNode extends Node {
const ATOM_EXEC = "/usr/local/bin/atom ";

class AtomNode extends Node
{
const ATOM_EXEC = "/usr/local/bin/atom ";

public $data;

public function __construct($data) {
public function __construct($data)
{
$this->data = $data;
}

public function add_to($documents) {
public function add_to($documents)
{
$item = $documents->addChild('item');

$item->addAttribute('arg', self::ATOM_EXEC . $this->data['paths']);
$item->title = $this->data['title'];
$item->subtitle = $this->data['paths'];
$item->icon = MEDIA_PATH . "atom.png";
$item->subtitle = $this->data['paths'];
$item->icon = MEDIA_PATH . "atom.png";
}

static public function build_via_file ($filename) {
static public function build_via_file($filename)
{
$objs = Node::get_objs($filename);
return Node::normalizeData($objs, function($objs) {

return Node::normalizeData($objs, function ($objs) {
if (!isset($objs['title'], $objs['paths'])) return;

return new AtomNode([
"title" => $objs['title'],
"paths" => join(" ", $objs['paths']),
"score_info" => strtolower($objs['title'])
"score_info" => strtolower($objs['title'])
]);
});
});
}
}
}
42 changes: 22 additions & 20 deletions src/node/BuildNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@

namespace alfmarks;

class BuildNode {

static public function build_via_file($type, $filename) {
// Log::info(print_r("asfsd", true));
switch ($type) {
case "atom":
return AtomNode::build_via_file($filename);
case "vscode":
return VscodeNode::build_via_file($filename);
}
class BuildNode
{
static public function build_via_file($type, $filename)
{
// Log::info(print_r("asfsd", true));
switch ($type) {
case "atom":
return AtomNode::build_via_file($filename);
case "vscode":
return VscodeNode::build_via_file($filename);
}
}

static public function build_via_data($type, $data) {
switch ($type) {
case "atom":
return new AtomNode($data);
case "vscode":
return new VscodeNode($data);
}
}
}

static public function build_via_data($type, $data)
{
switch ($type) {
case "atom":
return new AtomNode($data);
case "vscode":
return new VscodeNode($data);
}
}
}
43 changes: 23 additions & 20 deletions src/node/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,28 @@

namespace alfmarks;

class Node {
static public function normalizeData($objs, $callback) {
$nodes = array();
if ($item = $callback($objs)) {
$nodes[] = $item;
}
foreach ($objs as $value) {
if (is_array($value)) {
$nodes = array_merge($nodes, Node::normalizeData($value, $callback));
}
}
return $nodes;
class Node
{
static public function normalizeData($objs, $callback)
{
$nodes = array();
if ($item = $callback($objs)) {
$nodes[] = $item;
}
foreach ($objs as $value) {
if (is_array($value)) {
$nodes = array_merge($nodes, Node::normalizeData($value, $callback));
}
}
return $nodes;
}

static public function get_objs($filename){
if(substr($filename, -5, 5) == '.cson') {
exec("python " . SRC_PATH . "transfer/cson2json.py " . $filename);
$filename = ROOT_PATH . "projects.json";
}
return json_decode(file_get_contents($filename), true);

static public function get_objs($filename)
{
if (substr($filename, -5, 5) == '.cson') {
exec("python " . SRC_PATH . "transfer/cson2json.py " . $filename);
$filename = ROOT_PATH . "projects.json";
}
return json_decode(file_get_contents($filename), true);
}
}
}
Loading

0 comments on commit e5c2494

Please sign in to comment.