From 4ed2d152f871c5d5ff48030d81c101d2063971dd Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 6 Feb 2019 17:53:27 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=89=20initial=20implementation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __init__.py | 57 +++++++ gitmojis.json | 437 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 494 insertions(+) create mode 100644 __init__.py create mode 100644 gitmojis.json diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..77c5da0 --- /dev/null +++ b/__init__.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- + +"""gitmoji Picker for Albert +Usage: g: gitmoji name or description +Example: g: bug""" + +from albertv0 import * + +import os +import json + +__iid__ = "PythonInterface/v0.2" +__prettyname__ = "gitmoji picker" +__version__ = "1.0.0" +__trigger__ = "g:" +__author__ = "Andreas Schneider" +__dependencies__ = [] + +data_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "gitmojis.json") + +gitmojis = [] + +def initialize(): + with open(data_path) as f: + data = json.load(f) + + gitmojis.clear() + + for gitmoji in data["gitmojis"]: + gitmoji["tokens"] = [gitmoji["name"].lower()] + gitmoji["description"].lower().split() + gitmojis.append(gitmoji) + +def handleQuery(query): + needles = query.string.lower().split() + + matches = [] + for gitmoji in gitmojis: + matchCount = count_matches(gitmoji["tokens"], needles) + if matchCount > 0: + result = dict() + result.update(gitmoji) + result["matchCount"] = matchCount + matches.append(result) + + matches = sorted(matches, key=lambda data: data["matchCount"], reverse=True) + + if query.isValid and query.isTriggered: + return [Item(id=match["name"], completion=match["name"], icon=match["emoji"], text=match["emoji"] + " " + match["code"], subtext=match["description"], actions=[ClipAction("Copy to clipboard", match["code"])]) for match in matches] + return [] + +def count_matches(tokens, needles): + count = 0 + for token in tokens: + for needle in needles: + if needle in token: + count += 1 + return count diff --git a/gitmojis.json b/gitmojis.json new file mode 100644 index 0000000..f9f9d8d --- /dev/null +++ b/gitmojis.json @@ -0,0 +1,437 @@ +{ + "gitmojis":[ + { + "emoji":"🎨", + "entity":"🎨", + "code":":art:", + "description":"Improving structure / format of the code.", + "name":"art" + }, + { + "emoji":"⚑️", + "entity":"⚡", + "code":":zap:", + "description":"Improving performance.", + "name":"zap" + }, + { + "emoji":"πŸ”₯", + "entity":"🔥", + "code":":fire:", + "description":"Removing code or files.", + "name":"fire" + }, + { + "emoji":"πŸ›", + "entity":"🐛", + "code":":bug:", + "description":"Fixing a bug.", + "name":"bug" + }, + { + "emoji": "πŸš‘", + "entity": "🚑", + "code": ":ambulance:", + "description": "Critical hotfix.", + "name": "ambulance" + }, + { + "emoji":"✨", + "entity":"✨", + "code":":sparkles:", + "description":"Introducing new features.", + "name":"sparkles" + }, + { + "emoji":"πŸ“", + "entity":"📝", + "code":":memo:", + "description":"Writing docs.", + "name":"memo" + }, + { + "emoji":"πŸš€", + "entity":"🚀", + "code":":rocket:", + "description":"Deploying stuff.", + "name":"rocket" + }, + { + "emoji":"πŸ’„", + "entity":"&#ff99cc;", + "code":":lipstick:", + "description":"Updating the UI and style files.", + "name":"lipstick" + }, + { + "emoji":"πŸŽ‰", + "entity":"🎉", + "code":":tada:", + "description":"Initial commit.", + "name":"tada" + }, + { + "emoji":"βœ…", + "entity":"✅", + "code":":white_check_mark:", + "description":"Adding tests.", + "name":"white-check-mark" + }, + { + "emoji":"πŸ”’", + "entity":"🔒", + "code":":lock:", + "description":"Fixing security issues.", + "name":"lock" + }, + { + "emoji":"🍎", + "entity":"🍎", + "code":":apple:", + "description":"Fixing something on macOS.", + "name":"apple" + }, + { + "emoji":"🐧", + "entity":"🐧", + "code":":penguin:", + "description":"Fixing something on Linux.", + "name":"penguin" + }, + { + "emoji":"🏁", + "entity":"🏁", + "code":":checkered_flag:", + "description":"Fixing something on Windows.", + "name":"checkered-flag" + }, + { + "emoji":"πŸ€–", + "entity":"🤖", + "code":":robot:", + "description":"Fixing something on Android.", + "name":"robot" + }, + { + "emoji":"🍏", + "entity":"🍏", + "code":":green_apple:", + "description":"Fixing something on iOS.", + "name":"green-apple" + }, + { + "emoji":"πŸ”–", + "entity":"🔖", + "code":":bookmark:", + "description":"Releasing / Version tags.", + "name":"bookmark" + }, + { + "emoji":"🚨", + "entity":"🚨", + "code":":rotating_light:", + "description":"Removing linter warnings.", + "name":"rotating-light" + }, + { + "emoji":"🚧", + "entity":"🚧", + "code":":construction:", + "description":"Work in progress.", + "name":"construction" + }, + { + "emoji":"πŸ’š", + "entity":"💚", + "code":":green_heart:", + "description":"Fixing CI Build.", + "name":"green-heart" + }, + { + "emoji":"⬇️", + "entity":"⬇️", + "code":":arrow_down:", + "description":"Downgrading dependencies.", + "name":"arrow-down" + }, + { + "emoji":"⬆️", + "entity":"⬆️", + "code":":arrow_up:", + "description":"Upgrading dependencies.", + "name":"arrow-up" + }, + { + "emoji": "πŸ“Œ", + "entity": "📌", + "code": ":pushpin:", + "description": "Pinning dependencies to specific versions.", + "name": "pushpin" + }, + { + "emoji":"πŸ‘·", + "entity":"👷", + "code":":construction_worker:", + "description":"Adding CI build system.", + "name":"construction-worker" + }, + { + "emoji":"πŸ“ˆ", + "code":":chart_with_upwards_trend:", + "description":"Adding analytics or tracking code.", + "name":"chart-with-upwards-trend" + }, + { + "emoji":"♻️", + "entity":"♲", + "code":":recycle:", + "description":"Refactoring code.", + "name":"recycle" + }, + { + "emoji":"🐳", + "entity":"🐳", + "code":":whale:", + "description":"Work about Docker.", + "name":"whale" + }, + { + "emoji":"βž•", + "entity":"➕", + "code":":heavy_plus_sign:", + "description":"Adding a dependency.", + "name":"heavy-plus-sign" + }, + { + "emoji":"βž–", + "entity":"➖", + "code":":heavy_minus_sign:", + "description":"Removing a dependency.", + "name":"heavy-minus-sign" + }, + { + "emoji":"πŸ”§", + "entity":"🔧", + "code":":wrench:", + "description":"Changing configuration files.", + "name":"wrench" + }, + { + "emoji": "🌐", + "entity": "🌐", + "code": ":globe_with_meridians:", + "description": "Internationalization and localization.", + "name": "globe-with-meridians" + }, + { + "emoji":"✏️", + "entity":"", + "code":":pencil2:", + "description":"Fixing typos.", + "name":"pencil" + }, + { + "emoji":"πŸ’©", + "entity":"", + "code":":hankey:", + "description":"Writing bad code that needs to be improved.", + "name":"hankey" + }, + { + "emoji":"βͺ", + "entity":"⏪", + "code":":rewind:", + "description":"Reverting changes.", + "name":"rewind" + }, + { + "emoji":"πŸ”€", + "entity":"🔀", + "code":":twisted_rightwards_arrows:", + "description":"Merging branches.", + "name":"twisted-rightwards-arrows" + }, + { + "emoji":"πŸ“¦", + "entity":"F4E6;", + "code":":package:", + "description":"Updating compiled files or packages.", + "name":"package" + }, + { + "emoji":"πŸ‘½", + "entity":"F47D;", + "code":":alien:", + "description":"Updating code due to external API changes.", + "name":"alien" + }, + { + "emoji":"🚚", + "entity":"F69A;", + "code":":truck:", + "description":"Moving or renaming files.", + "name":"truck" + }, + { + "emoji":"πŸ“„", + "entity":"F4C4;", + "code":":page_facing_up:", + "description":"Adding or updating license.", + "name":"page-facing-up" + }, + { + "emoji":"πŸ’₯", + "entity":"💥", + "code":":boom:", + "description":"Introducing breaking changes.", + "name":"boom" + }, + { + "emoji":"🍱", + "entity":"F371", + "code":":bento:", + "description":"Adding or updating assets.", + "name":"bento" + }, + { + "emoji":"πŸ‘Œ", + "entity":"👌", + "code":":ok_hand:", + "description":"Updating code due to code review changes.", + "name":"ok-hand" + }, + { + "emoji": "♿️", + "entity":"♿", + "code": ":wheelchair:", + "description":"Improving accessibility.", + "name":"wheelchair" + }, + { + "emoji": "πŸ’‘", + "entity":"💡", + "code": ":bulb:", + "description":"Documenting source code.", + "name":"bulb" + }, + { + "emoji": "🍻", + "entity":"🍻", + "code": ":beers:", + "description": "Writing code drunkenly.", + "name":"beers" + }, + { + "emoji": "πŸ’¬", + "entity":"💬", + "code": ":speech_balloon:", + "description": "Updating text and literals.", + "name":"speech-balloon" + }, + { + "emoji": "πŸ—ƒ", + "entity":"🗃", + "code": ":card_file_box:", + "description": "Performing database related changes.", + "name":"card-file-box" + }, + { + "emoji":"πŸ”Š", + "entity":"🔊", + "code":":loud_sound:", + "description":"Adding logs.", + "name":"loud-sound" + }, + { + "emoji":"πŸ”‡", + "entity":"🔇", + "code":":mute:", + "description":"Removing logs.", + "name":"mute" + }, + { + "emoji": "πŸ‘₯", + "entity": "👥", + "code": ":busts_in_silhouette:", + "description": "Adding contributor(s).", + "name": "busts-in-silhouette" + }, + { + "emoji": "🚸", + "entity": "🚸", + "code": ":children_crossing:", + "description": "Improving user experience / usability.", + "name": "children-crossing" + }, + { + "emoji": "πŸ—", + "entity": "f3d7;", + "code": ":building_construction:", + "description": "Making architectural changes.", + "name": "building-construction" + }, + { + "emoji": "πŸ“±", + "entity": "📱" , + "code": ":iphone:", + "description": "Working on responsive design.", + "name": "iphone" + }, + { + "emoji": "🀑", + "entity": "🤡" , + "code": ":clown_face:", + "description": "Mocking things.", + "name": "clown-face" + }, + { + "emoji": "πŸ₯š", + "entity": "🥚", + "code": ":egg:", + "description": "Adding an easter egg.", + "name": "egg" + }, + { + "emoji": "πŸ™ˆ", + "entity": "bdfe7;" , + "code": ":see_no_evil:", + "description": "Adding or updating a .gitignore file", + "name": "see-no-evil" + }, + { + "emoji": "πŸ“Έ", + "entity": "📸" , + "code": ":camera_flash:", + "description": "Adding or updating snapshots", + "name": "camera-flash" + }, + { + "emoji": "βš—", + "entity": "📸" , + "code": ":alembic:", + "description": "Experimenting new things", + "name": "alembic" + }, + { + "emoji": "πŸ”", + "entity": "🔍" , + "code": ":mag:", + "description": "Improving SEO", + "name": "mag" + }, + { + "emoji":"☸️", + "entity":"☸", + "code":":wheel_of_dharma:", + "description":"Work about Kubernetes", + "name":"wheel-of-dharma" + }, + { + "emoji": "🏷️", + "entity": "🏷", + "code": ":label:", + "description": "Adding or updating types (Flow, TypeScript)", + "name": "label" + } + ] +}