Permalink
Browse files

First commit

  • Loading branch information...
0 parents commit 0c0e8986f6931555ba566096f5033f80c849743d @geckotang committed Jul 1, 2014
@@ -0,0 +1,12 @@
+### OSX ###
+.DS_Store
+.AppleDouble
+.LSOverride
+Icon
+
+# Thumbnails
+._*
+
+# Files that might appear on external disk
+.Spotlight-V100
+.Trashes
Binary file not shown.
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2014 Shotaro Sakamaki
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
@@ -0,0 +1,11 @@
+LGTM.in for [Alfred 2](http://www.alfredapp.com/)
+========================
+
+![](screenshots/ss.jpg)
+
+Please refer to http://www.lgtm.in/
+
+## Quick and Easy
+
+1. Type ``lgtm``
+2. Press Enter to paste lgtm image.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>bundleid</key>
+ <string>com.geckotang.lgtmin</string>
+ <key>category</key>
+ <string>Tools</string>
+ <key>connections</key>
+ <dict>
+ <key>D4DA7C80-5973-4657-BB41-5E5102F729B1</key>
+ <array>
+ <dict>
+ <key>destinationuid</key>
+ <string>E75679B2-4400-43F9-ADE4-AA8E4CBFD1A1</string>
+ <key>modifiers</key>
+ <integer>0</integer>
+ <key>modifiersubtext</key>
+ <string></string>
+ </dict>
+ </array>
+ </dict>
+ <key>createdby</key>
+ <string>@GeckoTang</string>
+ <key>description</key>
+ <string>Copy LGTM.in image to Clipboard</string>
+ <key>disabled</key>
+ <false/>
+ <key>name</key>
+ <string>LGTM</string>
+ <key>objects</key>
+ <array>
+ <dict>
+ <key>config</key>
+ <dict>
+ <key>autopaste</key>
+ <false/>
+ <key>clipboardtext</key>
+ <string>{query}</string>
+ </dict>
+ <key>type</key>
+ <string>alfred.workflow.output.clipboard</string>
+ <key>uid</key>
+ <string>E75679B2-4400-43F9-ADE4-AA8E4CBFD1A1</string>
+ <key>version</key>
+ <integer>0</integer>
+ </dict>
+ <dict>
+ <key>config</key>
+ <dict>
+ <key>argumenttype</key>
+ <integer>2</integer>
+ <key>escaping</key>
+ <integer>0</integer>
+ <key>keyword</key>
+ <string>lgtm</string>
+ <key>runningsubtext</key>
+ <string>Please Wait...</string>
+ <key>script</key>
+ <string>require_once("lgtm.php");</string>
+ <key>subtext</key>
+ <string>Loading...</string>
+ <key>title</key>
+ <string>Copy LGTM</string>
+ <key>type</key>
+ <integer>1</integer>
+ <key>withspace</key>
+ <false/>
+ </dict>
+ <key>type</key>
+ <string>alfred.workflow.input.scriptfilter</string>
+ <key>uid</key>
+ <string>D4DA7C80-5973-4657-BB41-5E5102F729B1</string>
+ <key>version</key>
+ <integer>0</integer>
+ </dict>
+ </array>
+ <key>readme</key>
+ <string></string>
+ <key>uidata</key>
+ <dict>
+ <key>D4DA7C80-5973-4657-BB41-5E5102F729B1</key>
+ <dict>
+ <key>ypos</key>
+ <real>10</real>
+ </dict>
+ <key>E75679B2-4400-43F9-ADE4-AA8E4CBFD1A1</key>
+ <dict>
+ <key>ypos</key>
+ <real>10</real>
+ </dict>
+ </dict>
+ <key>webaddress</key>
+ <string>https://github.com/geckotang/alfred-lgtmin-workflow</string>
+</dict>
+</plist>
@@ -0,0 +1,52 @@
+<?php
+require_once('workflows.php');
+$wf = new Workflows();
+
+# GET LGTM JSON
+$url = "http://www.lgtm.in/g";
+$opts = array(
+ 'http'=>array(
+ 'method' => "GET",
+ 'header' => "Accept:application/json, text/javascript"
+ )
+);
+$context = stream_context_create($opts);
+$json = json_decode(file_get_contents($url, false, $context));
+
+# Get LGTM Image
+$image_dir = './thumb';
+$image_url = $json->actualImageUrl;
+$image_type = substr($image_url, strrpos($image_url, '.') + 1);
+$image_path = $image_dir.'/icon.'.$image_type;
+
+# Delete old images
+$res_dir = opendir( $image_dir );
+while( $file_name = readdir($res_dir)) {
+ if(is_file($image_dir.'/'.$file_name)) {
+ unlink($image_dir.'/'.$file_name);
+ }
+}
+
+# Markdown's image syntax
+$wf->result(
+ time(),
+ "![{$json->imageUrl}]({$json->imageUrl})",
+ "Copy Markdown's syntax to Clipboard",
+ "Good:{$json->likes} Bad:{$json->dislikes}",
+ $image_path
+);
+
+# Raw image url
+$wf->result(
+ time(),
+ $json->imageUrl,
+ "Copy raw image url to Clipboard",
+ "Good:{$json->likes} Bad:{$json->dislikes}",
+ $image_path
+);
+echo $wf->toxml();
+
+# Create Icon
+$image_data = file_get_contents($image_url);
+file_put_contents($image_path, $image_data);
+?>
Oops, something went wrong.

0 comments on commit 0c0e898

Please sign in to comment.