Skip to content

Commit

Permalink
🎉 Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuhrmann committed Mar 26, 2018
0 parents commit 10ed8d4
Show file tree
Hide file tree
Showing 64 changed files with 244 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = crlf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{md,rst,txt}]
indent_size = 2
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 <copyright holders>

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.
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Keypirinha Plugin: gitmoji

This is gitmoji, a plugin for the
[Keypirinha](http://keypirinha.com) launcher.

Search for [gitmoji](https://github.com/carloscuesta/gitmoji) and copy them to your clipboard. Include them in your commit messages to a better way of identifying the purpose of a commit.

## Download

https://github.com/Fuhrmann/keypirinha-gitmoji/releases


## Install

#### Managed

[@ueffel](https://github.com/ueffel) wrote [PackageControl](https://github.com/ueffel/Keypirinha-PackageControl), a package manager that eases the install of third-party packages.
It must be installed manually.

#### Manual

Once the `gitmoji.keypirinha-package` file is installed,
move it to the `InstalledPackage` folder located at:

* `Keypirinha\portable\Profile\InstalledPackages` in **Portable mode**
* **Or** `%APPDATA%\Keypirinha\InstalledPackages` in **Installed mode** (the
final path would look like
`C:\Users\%USERNAME%\AppData\Roaming\Keypirinha\InstalledPackages`)


## Usage

Open Keypirinha and type 'gitmoji'. Once the suggestion appears press TAB or ENTER to open all suggestions.


## Change Log

### v1.0
* Released

## License

This package is distributed under the terms of the MIT license.

## Credits
[@carloscuesta](https://github.com/carloscuesta), developer of [gitmoji](https://github.com/carloscuesta/gitmoji)

[@leolabs](https://github.com/leolabs), developer of [gitmoji for Alfred](https://github.com/leolabs/alfred-gitmoji/)
Binary file added build/Gitmoji.keypirinha-package
Binary file not shown.
57 changes: 57 additions & 0 deletions make.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
@echo off
setlocal

set PACKAGE_NAME=Gitmoji
set INSTALL_DIR=%APPDATA%\Keypirinha\InstalledPackages

if "%1"=="" goto help
if "%1"=="-h" goto help
if "%1"=="--help" goto help
if "%1"=="help" (
:help
echo Usage:
echo make help
echo make clean
echo make build
echo make install
echo make py [python_args]
goto end
)

if "%BUILD_DIR%"=="" set BUILD_DIR=%~dp0build
if "%KEYPIRINHA_SDK%"=="" (
echo ERROR: Keypirinha SDK environment not setup.
echo Run SDK's "kpenv" script and try again.
exit /b 1
)

if "%1"=="clean" (
if exist "%BUILD_DIR%" rmdir /s /q "%BUILD_DIR%"
goto end
)

if "%1"=="build" (
if not exist "%BUILD_DIR%" mkdir "%BUILD_DIR%"
pushd "%~dp0"
call "%KEYPIRINHA_SDK%\cmd\kparch" ^
"%BUILD_DIR%\%PACKAGE_NAME%.keypirinha-package" ^
-r LICENSE* README* src
popd
goto end
)

if "%1"=="install" (
echo TODO: ensure the INSTALL_DIR variable declared at the top of this
echo script complies to your configuration and remove this message
exit /1

copy /Y "%BUILD_DIR%\*.keypirinha-package" "%INSTALL_DIR%\"
goto end
)

if "%1"=="py" (
call "%KEYPIRINHA_SDK%\cmd\kpy" %2 %3 %4 %5 %6 %7 %8 %9
goto end
)

:end
Binary file added src/gitmoji.ico
Binary file not shown.
105 changes: 105 additions & 0 deletions src/gitmoji.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Keypirinha launcher (keypirinha.com)

import keypirinha as kp
import keypirinha_util as kpu
import keypirinha_net as kpnet
import json
from datetime import datetime
import os.path

class gitmoji(kp.Plugin):
"""
Search for gitmoji and copy then to your clipboard
This plugin was based on: http://www.packal.org/workflow/gitmoji-0 and http://www.packal.org/workflow/gitmoji
"""

GITMOJI_URL = "https://raw.githubusercontent.com/carloscuesta/gitmoji/master/src/data/gitmojis.json"
DAYS_KEEP_CACHE = 7
ITEMCAT = kp.ItemCategory.USER_BASE + 1

def __init__(self):
super().__init__()
self.emojis = []

def on_start(self):
self.generate_cache()
self.get_gitmoji()
pass

def on_catalog(self):
self.set_catalog([
self.create_item(
category=kp.ItemCategory.KEYWORD,
label="gitmoji",
short_desc="Search gitmoji and copy them to your clipboard",
target="gitmoji",
args_hint=kp.ItemArgsHint.REQUIRED,
hit_hint=kp.ItemHitHint.KEEPALL
)
])

def on_suggest(self, user_input, items_chain):
if not items_chain or items_chain[0].category() != kp.ItemCategory.KEYWORD:
return

suggestions = self.filter_emojis(user_input)
self.set_suggestions(suggestions, kp.Match.ANY, kp.Sort.LABEL_ASC)

def filter_emojis(self, user_input):
return list(filter(lambda item: self.has_title_description(item, user_input), self.emojis))

def has_title_description(self, item, user_input):
if user_input.lower() in item.label().lower() or user_input.lower() in item.short_desc().lower():
return item

return False

def on_execute(self, item, action):
kpu.set_clipboard(item.target())

def generate_cache(self):
cache_path = self.get_cache_path()
should_generate = False
try:
last_modified = datetime.fromtimestamp(os.path.getmtime(cache_path)).date()
if ((last_modified - datetime.today().date()).days > self.DAYS_KEEP_CACHE):
should_generate = True
except Exception as exc:
should_generate = True

if not should_generate:
return False

try:
opener = kpnet.build_urllib_opener()
with opener.open(self.GITMOJI_URL) as request:
response = request.read()
except Exception as exc:
self.err("Could not reach the gitmoji repository file to generate the cache: ", exc)

data = json.loads(response)
with open(cache_path, "w") as index_file:
json.dump(data, index_file, indent=2)

def get_gitmoji(self):
if not self.emojis:
with open(self.get_cache_path(), "r") as emojis_file:
data = json.loads(emojis_file.read())
for item in data['gitmojis']:
suggestion = self.create_item(
category=self.ITEMCAT,
label=item['code'],
short_desc=item['description'],
target=item['code'],
args_hint=kp.ItemArgsHint.FORBIDDEN,
hit_hint=kp.ItemHitHint.IGNORE,
icon_handle=self.load_icon('res://{}/icons/{}.png'.format(self.package_full_name(), item['name']))
)

self.emojis.append(suggestion)

return self.emojis

def get_cache_path(self):
cache_path = self.get_package_cache_path(True)
return os.path.join(cache_path, 'gitmoji.json')
Binary file added src/icons/alien.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 added src/icons/ambulance.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 added src/icons/apple.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 added src/icons/arrow-down.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 added src/icons/arrow-up.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 added src/icons/art.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 added src/icons/beers.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 added src/icons/bento.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 added src/icons/bookmark.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 added src/icons/boom.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 added src/icons/bug.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 added src/icons/building-construction.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 added src/icons/bulb.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 added src/icons/busts-in-silhouette.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 added src/icons/card-file-box.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 added src/icons/chart-with-upwards-trend.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 added src/icons/checkered-flag.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 added src/icons/children-crossing.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 added src/icons/clown-face.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 added src/icons/construction-worker.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 added src/icons/construction.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 added src/icons/egg.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 added src/icons/fire.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 added src/icons/globe-with-meridians.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 added src/icons/green-apple.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 added src/icons/green-heart.png
Binary file added src/icons/hankey.png
Binary file added src/icons/heavy-minus-sign.png
Binary file added src/icons/heavy-plus-sign.png
Binary file added src/icons/iphone.png
Binary file added src/icons/lipstick.png
Binary file added src/icons/lock.png
Binary file added src/icons/loud-sound.png
Binary file added src/icons/memo.png
Binary file added src/icons/mute.png
Binary file added src/icons/ok-hand.png
Binary file added src/icons/package.png
Binary file added src/icons/page-facing-up.png
Binary file added src/icons/pencil.png
Binary file added src/icons/penguin.png
Binary file added src/icons/pushpin.png
Binary file added src/icons/recycle.png
Binary file added src/icons/rewind.png
Binary file added src/icons/robot.png
Binary file added src/icons/rocket.png
Binary file added src/icons/rotating-light.png
Binary file added src/icons/see-no-evil.png
Binary file added src/icons/sparkles.png
Binary file added src/icons/speech-balloon.png
Binary file added src/icons/tada.png
Binary file added src/icons/truck.png
Binary file added src/icons/twisted-rightwards-arrows.png
Binary file added src/icons/whale.png
Binary file added src/icons/wheelchair.png
Binary file added src/icons/white-check-mark.png
Binary file added src/icons/wrench.png
Binary file added src/icons/zap.png

0 comments on commit 10ed8d4

Please sign in to comment.