From c8da92906c2b44849a6c4b3c83ce1e6715699a77 Mon Sep 17 00:00:00 2001 From: Ozymandias Date: Sat, 15 Feb 2020 09:16:27 +0200 Subject: [PATCH] - Prepared configs for packaging - Updated README - Minor fixes for packaging --- README.md | 62 +++---- angular.json | 9 +- electron-builder.json | 68 +++++--- main.ts | 25 +-- package.json | 6 +- poetry.lock | 161 +++++++++++++++++- pyproject.toml | 12 +- setup.py | 27 +++ .../category-tabs/tabbar.component.ts | 5 +- .../settings/settings.component.html | 2 +- .../components/settings/settings.component.ts | 10 +- src/app/services/directory.service.ts | 10 ++ src/app/services/messenger.service.ts | 7 +- src/app/services/settings.service.ts | 7 +- .../components/emoji/emoji.component.ts | 5 +- src/index.html | 3 +- src_py/__init__.py | 0 src_py/__pycache__/__init__.cpython-37.pyc | Bin 0 -> 147 bytes 18 files changed, 329 insertions(+), 90 deletions(-) create mode 100644 src_py/__init__.py create mode 100644 src_py/__pycache__/__init__.cpython-37.pyc diff --git a/README.md b/README.md index 37cc4ad7f..4d52f7977 100755 --- a/README.md +++ b/README.md @@ -1,52 +1,52 @@ # Emoji keyboard -Virtual keyboard-like emoji picker for Linux. +Virtual keyboard-like emoji palette for Linux. -Emoji artwork and metadata provided by [Emoji Two](https://emojitwo.github.io/) -by [Ranks.com](http://www.ranks.com/) and is licensed under -[CC-BY 4.0](https://creativecommons.org/licenses/by/4.0/legalcode). +Emoji support on Linux is shaky at best. Modern distributions finally support +displaying color emoji, but using emoji is inconsistent and inconvenient. -Additional artwork provided by -[Twitter Emoji](https://github.com/twitter/twemoji) -([CC-BY 4.0](https://creativecommons.org/licenses/by/4.0/legalcode)) and -[Noto Emoji](https://github.com/googlei18n/noto-emoji) -([Apache 2.0](https://github.com/googlei18n/noto-emoji/blob/master/LICENSE)). +Enter `emoji-keyboard`! Press a hotkey (default `Ctrl+Super+Space`) or choose `Palette` +from app indicator and an emoji palette opens. Then just click on emoji you want to use +and watch them appear in the active application! -## Installation +> **Tip:** hold shift when using the terminal and you can type emoji into the terminal + +> **Tip:** you can choose to copy emoji into the clipboard instead in the `Preferences` + +Easy. -You can install emoji keyboard from [pypi](https://pypi.org/project/emoji-keyboard). +Not sure which emoji to use? Press `Ctrl+Super+F` or choose `Search` from app indicator +and you can search emoji by name, short code or emoticon. -First you need pip and pygobject bindings, on Debian based distros you can get them with: +> **Tip:** don't want to use mouse after searching? Press up/down arrows and `Enter` to type -```sudo apt install python3-pip python3-gi gir1.2-gtk-3.0 gir1.2-glib-2.0``` +Got emoji you use frequently? Memorize short code (you can see it when hovering emoji +in the palette) and then just type it and watch it be replaced by the emoji. -Next run this command (on other distros it may just be `pip` depending on how you installed pip): +> **Tip:** you can disable this feature in `Preferences`. It doesn't play well with Firefox -```pip3 install --user https://github.com/OzymandiasTheGreat/emoji-keyboard/archive/master.zip``` +And of course there's eye-candy. Choose emoji set you prefer or app and panel themes to match your system. -Now start the indicator by running `emoji-keyboard` and start typing those emoji! +## Credits and License -## Usage +`emoji-keyboard` is release under GPLv3 or later license. -### Keyboard +© 2020 [Ozymandias (Tomas Ravinskas)](mailto:tomas.rav@gmail.com) -Selecting `Show Keyboard` from the app indicator menu or, if your desktop -environment supports it, middle-clicking app indicator will toggle the visibility -of the keyboard. When the picker is visible simply clicking on emoji will type it -into focused application. +Emoji artwork and metadata provided by: -### Search +[Blobmoji](https://github.com/c1710/blobmoji) by Google Inc. and is licensed under [Apache-2.0](https://github.com/C1710/blobmoji/blob/master/LICENSE) -You can search by official unicode name or by :shortname:. -Pressing `enter` will select and type the first result. +[Emoji Two](https://emojitwo.github.io/) by [Ranks.com](http://www.ranks.com/) and is licensed under [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/legalcode). -### Hotkeys +[Noto emoji](https://github.com/googlefonts/noto-emoji) by Google Inc. and is licensed under [Apache-2.0](https://github.com/googlefonts/noto-emoji/blob/master/LICENSE) -`emoji-keyboard` can be controlled from the command line. Use your desktop's -native hotkey utility to assign hotkeys to +[Twemoji](https://github.com/twitter/twemoji) by [Twitter](https://twemoji.twitter.com/) and is licensed under [CC-BY-4.0](https://github.com/twitter/twemoji/blob/master/LICENSE-GRAPHICS) -`emoji-keyboard -k` to toggle visibility of the keyboard, +[Openmoji](https://github.com/hfg-gmuend/openmoji) by [openmoji.org](https://openmoji.org/about/#team) and is licensed under [CC-BY-SA-4.0](https://creativecommons.org/licenses/by-sa/4.0/) + +## Installation -`emoji-keyboard -s` to toggle visibility of the search window. +Grab AppImage from [releases page](https://github.com/OzymandiasTheGreat/emoji-keyboard/releases) and just run it! -Run `emoji-keyboard -h` in the terminal to get full list of commands. +## Feedback is always WELCOME diff --git a/angular.json b/angular.json index 66494a5cb..1aaf7f1c4 100644 --- a/angular.json +++ b/angular.json @@ -11,18 +11,13 @@ "build": { "builder": "@angular-builders/custom-webpack:browser", "options": { - "outputPath": "dist", + "outputPath": "dist/angular/", "index": "src/index.html", "main": "src/main.ts", "tsConfig": "src/tsconfig.app.json", "polyfills": "src/polyfills.ts", "assets": [ - "src/assets", - "src/favicon.ico", - "src/favicon.png", - "src/favicon.icns", - "src/favicon.256x256.png", - "src/favicon.512x512.png" + { "glob": "**/*", "input": "src/assets/", "output": "/assets/" } ], "styles": [ "node_modules/spinkit/spinkit.min.css", diff --git a/electron-builder.json b/electron-builder.json index 4126419ae..b6606e97c 100644 --- a/electron-builder.json +++ b/electron-builder.json @@ -1,24 +1,37 @@ { - "productName": "angular-electron", + "appId": "tk.ozymandias.emoji-keyboard", + "productName": "emoji-keyboard", + "copyright": "© 2020 ${author}", "directories": { - "output": "release/" + "buildResources": "dist/resources", + "output": "dist/release/" }, - "files": [ - "**/*", - "!**/*.ts", - "!*.code-workspace", - "!LICENSE.md", - "!package.json", - "!package-lock.json", - "!src/", - "!e2e/", - "!hooks/", - "!angular.json", - "!_config.yml", - "!karma.conf.js", - "!tsconfig.json", - "!tslint.json" - ], + "electronDownload": { + "version": "8.0.1" + }, + "nodeVersion": "${current}", + "files": [ + "**/*", + "!**/*.ts", + "!**/*.py", + "!.*", + "!*.json", + "!*.md", + "!*.code-workspace", + "!*.webpack.*", + "!LICENSE", + "!package.json", + "!package-lock.json", + "!pyproject.toml", + "!poetry.lock", + "!src", + "!src_py", + "!.venv", + "!scripts", + "!sources", + "!karma.conf.js", + "!.vscode" + ], "win": { "icon": "dist", "target": [ @@ -32,9 +45,24 @@ ] }, "linux": { - "icon": "dist", + "icon": "dist/resources/icon", + "category": "Utility", "target": [ "AppImage" ] - } + }, + "appImage": { + "license": "LICENSE" + }, + "extraResources": [ + { + "from": "dist/resources/main.pyz", + "to": "main.pyz" + } + ], + "asar": true, + "asarUnpack": [ + "dist/angular/assets/data/emoji.json", + "dist/angular/assets/data/default.ini" + ] } diff --git a/main.ts b/main.ts index d11744602..4fa28ac0e 100644 --- a/main.ts +++ b/main.ts @@ -8,7 +8,7 @@ import * as PKG from "./package.json"; const DEV = process.argv.includes("--dev"); const SHELL = new PythonShell( - DEV ? "./main.py" : "emoji_keyboard.pyz", + app.isPackaged ? path.resolve(process.resourcesPath, "main.pyz") : "main.py", { mode: "json", pythonOptions: [ "-u" ], @@ -20,6 +20,11 @@ let MAIN_WINDOW: BrowserWindow = null; let PANEL_THEME = "dark"; +function getAsset(assetPath: string): string { + return path.resolve(app.getAppPath(), app.isPackaged ? "dist/angular/assets" : "src/assets", assetPath); +} + + function createIndicator(): Tray { const menu = Menu.buildFromTemplate([ { id: "palette", label: "Palette", click() { @@ -64,7 +69,7 @@ function createIndicator(): Tray { { id: "about", label: "About", click() { app.showAboutPanel(); } }, { id: "quit", label: "Quit", role: "quit" }, ]); - INDICATOR = new Tray(`./src/assets/icons/icon-${PANEL_THEME}-48.png`) // TODO + INDICATOR = new Tray(getAsset(`icons/icon-${PANEL_THEME}-16.png`)); INDICATOR.setContextMenu(menu); return INDICATOR; } @@ -72,8 +77,6 @@ function createIndicator(): Tray { function createWindow(): BrowserWindow { - let res: Promise; - // Create the browser MAIN_WINDOWdow. MAIN_WINDOW = new BrowserWindow({ width: 490, height: 330, @@ -84,25 +87,25 @@ function createWindow(): BrowserWindow { // alwaysOnTop: true, // ALSO NOT IMPLEMENTED ON LINUX fullscreenable: false, title: PKG.name.split("-").map((w) => w.slice(0, 1).toUpperCase() + w.slice(1)).join(" "), - icon: "./src/assets/icons/icon-48.png", // TODO + icon: getAsset("icons/icon-48.png"), show: false, frame: false, // backgroundColor: "", // TODO Theming webPreferences: { nodeIntegration: true, - preload: path.resolve(__dirname, "preload.js"), + preload: path.resolve(app.getAppPath(), "preload.js"), allowRunningInsecureContent: (DEV) ? true : false, }, }); if (DEV) { - require('electron-reload')(__dirname, { - electron: require(`${__dirname}/node_modules/electron`) + require('electron-reload')(app.getAppPath(), { + electron: require(`${app.getAppPath()}/node_modules/electron`) }); MAIN_WINDOW.loadURL('http://localhost:4200'); } else { MAIN_WINDOW.loadURL(url.format({ - pathname: path.join(__dirname, "dist/index.html"), + pathname: getAsset("../index.html"), protocol: 'file:', slashes: true, })); @@ -130,7 +133,7 @@ app.setAboutPanelOptions({ credits: `${PKG.author.name} <${PKG.author.email}>`, authors: [`${PKG.author.name} <${PKG.author.email}>`], website: PKG.homepage, - iconPath: "./src/assets/icons/icon.svg", + iconPath: getAsset("icons/icon.svg"), }); app.on("ready", () => { createIndicator(); @@ -150,7 +153,7 @@ ipcMain.on("python", (event, msg) => { SHELL.send(msg); }); ipcMain.on("indicator", (event, theme) => { - INDICATOR.setImage(`./src/assets/icons/icon-${theme}-48.png`); + INDICATOR.setImage(`src/assets/icons/icon-${theme}-48.png`); }); SHELL.on("message", (msg) => { if (MAIN_WINDOW) { diff --git a/package.json b/package.json index 2df4a76db..0e0fbaf39 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,9 @@ { "name": "emoji-keyboard", - "version": "3.0.0", - "description": "Virtual keyboard-like emoji palette", + "version": "3.0.0rc0", + "description": "Type emoji easily! Virtual keyboard-like emoji palette for Linux with lots of features.", "homepage": "https://github.com/OzymandiasTheGreat/emoji-keyboard", + "repository": "https://github.com/OzymandiasTheGreat/emoji-keyboard", "author": { "name": "Ozymandias (Tomas Ravinskas)", "email": "tomas.rav@gmail.com" @@ -90,7 +91,6 @@ "@mdi/font": "4.9.95", "custom-electron-titlebar": "3.2.2-hotfix62", "ini": "1.3.5", - "interactjs": "1.8.4", "object-observer": "2.5.2", "python-shell": "1.0.8", "spinkit": "2.0.1", diff --git a/poetry.lock b/poetry.lock index e0a1bc589..18c32ae3a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,3 +1,54 @@ +[[package]] +category = "dev" +description = "A simple wrapper around optparse for powerful command line utilities." +name = "click" +optional = false +python-versions = "*" +version = "6.7" + +[[package]] +category = "main" +description = "Bindings to the Linux input handling subsystem" +marker = "sys_platform == \"linux\"" +name = "evdev" +optional = false +python-versions = "*" +version = "1.3.0" + +[[package]] +category = "dev" +description = "Read resources from Python packages" +marker = "python_version < \"3.7\"" +name = "importlib-resources" +optional = false +python-versions = ">=2.7,!=3.0,!=3.1,!=3.2,!=3.3" +version = "1.0.2" + +[[package]] +category = "main" +description = "Full toolkit agnostic cross-platform clipboard access" +name = "klembord" +optional = false +python-versions = ">=3.4,<4.0" +version = "0.2.1" + +[package.dependencies] +python-xlib = ">=0.26,<0.27" +stopit = ">=1.1.2,<2.0.0" + +[[package]] +category = "main" +description = "Simple, cross-platform macros/GUI automation for python" +name = "macpy" +optional = false +python-versions = ">=3.6,<4.0" +version = "0.1.2" + +[package.dependencies] +evdev = ">=1.3.0,<2.0.0" +python-libinput = ">=0.1.0,<0.2.0" +python-xlib = ">=0.26,<0.27" + [[package]] category = "dev" description = "ISO country, subdivision, language, currency and script definitions and their translations" @@ -6,11 +57,119 @@ optional = false python-versions = "*" version = "19.8.18" +[[package]] +category = "main" +description = "Object-oriented wrapper for libinput using ctypes" +marker = "sys_platform == \"linux\"" +name = "python-libinput" +optional = false +python-versions = "*" +version = "0.1.0" + +[[package]] +category = "main" +description = "Python X Library" +marker = "sys_platform == \"linux\"" +name = "python-xlib" +optional = false +python-versions = "*" +version = "0.26" + +[package.dependencies] +six = ">=1.10.0" + +[[package]] +category = "dev" +description = "A command line utility for building fully self contained Python zipapps." +name = "shiv" +optional = false +python-versions = ">=3.6" +version = "0.1.1" + +[package.dependencies] +click = ">=6.7,<7.0 || >7.0" +pip = ">=9.0.3" +setuptools = "*" + +[package.dependencies.importlib-resources] +python = "<3.7" +version = "*" + +[[package]] +category = "main" +description = "Python 2 and 3 compatibility utilities" +marker = "sys_platform == \"linux\"" +name = "six" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" +version = "1.14.0" + +[[package]] +category = "main" +description = "Timeout control decorator and context managers, raise any exception in another thread" +marker = "sys_platform == \"linux\"" +name = "stopit" +optional = false +python-versions = "*" +version = "1.1.2" + +[[package]] +category = "dev" +description = "A built-package format for Python" +name = "wheel" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +version = "0.34.2" + +[package.extras] +test = ["pytest (>=3.0.0)", "pytest-cov"] + [metadata] -content-hash = "98a08bd04639156a3eb2ed909fa9b458d720e8e16d988b979ed2742b47c89c86" +content-hash = "b71cf09619d7e5e23fc281e74c6d9b5a15a347fca9a458d6f8919d2adcc3f5ce" python-versions = "^3.6" [metadata.files] +click = [ + {file = "click-6.7-py2.py3-none-any.whl", hash = "sha256:29f99fc6125fbc931b758dc053b3114e55c77a6e4c6c3a2674a2dc986016381d"}, + {file = "click-6.7.tar.gz", hash = "sha256:f15516df478d5a56180fbf80e68f206010e6d160fc39fa508b65e035fd75130b"}, +] +evdev = [ + {file = "evdev-1.3.0.tar.gz", hash = "sha256:b1c649b4fed7252711011da235782b2c260b32e004058d62473471e5cd30634d"}, +] +importlib-resources = [ + {file = "importlib_resources-1.0.2-py2.py3-none-any.whl", hash = "sha256:6e2783b2538bd5a14678284a3962b0660c715e5a0f10243fd5e00a4b5974f50b"}, + {file = "importlib_resources-1.0.2.tar.gz", hash = "sha256:d3279fd0f6f847cced9f7acc19bd3e5df54d34f93a2e7bb5f238f81545787078"}, +] +klembord = [ + {file = "klembord-0.2.1-py3-none-any.whl", hash = "sha256:810eff42fae25a6f7a384df427268548099f7b263bac39af66117046d3c9f4d4"}, + {file = "klembord-0.2.1.tar.gz", hash = "sha256:0785881aefa9c8ebcae548fbfea5be97ca554cf5f2876493e427a82ea9601de0"}, +] +macpy = [ + {file = "macpy-0.1.2-py3-none-any.whl", hash = "sha256:6e39dd2c2cfb98bd98db5f408b906c1e4c2cc9bd876b1c806d9bab4d3097fad9"}, + {file = "macpy-0.1.2.tar.gz", hash = "sha256:02bc984a1a93e137cdea9cf9b2cbbb20d86909b364c58398a61d15d55f3739fb"}, +] pycountry = [ {file = "pycountry-19.8.18.tar.gz", hash = "sha256:3c57aa40adcf293d59bebaffbe60d8c39976fba78d846a018dc0c2ec9c6cb3cb"}, ] +python-libinput = [ + {file = "python-libinput-0.1.0.tar.gz", hash = "sha256:e6b20e7fd889001fe74b01a1ff456e5f53c9ed01b016d6ceb65b6f573f129758"}, +] +python-xlib = [ + {file = "python-xlib-0.26.tar.bz2", hash = "sha256:b819c7e5f55830305919d78ea42b0cbd5e13687f5d12aa53556c33674b9876df"}, + {file = "python_xlib-0.26-py2.py3-none-any.whl", hash = "sha256:244570b93cb82f5ceea3e4c861b4a0fffcea36947efa10fd63b7aa69d30047a8"}, +] +shiv = [ + {file = "shiv-0.1.1-py2.py3-none-any.whl", hash = "sha256:e39944e83a45e72e67e55303e3ba0d615f945820da5d59e166562a84a5c7a258"}, + {file = "shiv-0.1.1.tar.gz", hash = "sha256:23eb1fc223ed7ca5419c22311d9073af053ef309eb4f89436c84c092133a5723"}, +] +six = [ + {file = "six-1.14.0-py2.py3-none-any.whl", hash = "sha256:8f3cd2e254d8f793e7f3d6d9df77b92252b52637291d0f0da013c76ea2724b6c"}, + {file = "six-1.14.0.tar.gz", hash = "sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a"}, +] +stopit = [ + {file = "stopit-1.1.2.tar.gz", hash = "sha256:f7f39c583fd92027bd9d06127b259aee7a5b7945c1f1fa56263811e1e766996d"}, +] +wheel = [ + {file = "wheel-0.34.2-py2.py3-none-any.whl", hash = "sha256:df277cb51e61359aba502208d680f90c0493adec6f0e848af94948778aed386e"}, + {file = "wheel-0.34.2.tar.gz", hash = "sha256:8788e9155fe14f54164c1b9eb0a319d98ef02c160725587ad60f14ddc57b6f96"}, +] diff --git a/pyproject.toml b/pyproject.toml index 43c1db28f..bcdf97046 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,15 +1,23 @@ [tool.poetry] name = "emoji-keyboard" -version = "3.0.0a0" -description = "Type emoji easily! Virtual-keyboard like emoji picker with lots of features." +version = "3.0.0rc0" +description = "Type emoji easily! Virtual keyboard-like emoji palette for Linux with lots of features." authors = ["Ozymandias "] license = "GPL-3.0-or-later" +readme = "README.md" +repository = "https://github.com/OzymandiasTheGreat/emoji-keyboard" +keywords = ["emoji", "keyboard", "picker", "palette"] +packages = [{ include = "src_py/**/*.py" }] [tool.poetry.dependencies] python = "^3.6" +macpy = "^0.1.2" +klembord = "^0.2.1" [tool.poetry.dev-dependencies] pycountry = "^19.8.18" +shiv = "^0.1.1" +wheel = "^0.34.2" [build-system] requires = ["poetry>=0.12"] diff --git a/setup.py b/setup.py index e69de29bb..9e0b30b3b 100644 --- a/setup.py +++ b/setup.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +from setuptools import setup + + +scripts = ['main.py'] +packages = ['emoji_keyboard'] +package_dir = {'emoji_keyboard': 'src_py'} +install_requires = [ + 'klembord>=0.2.1,<0.3.0', + 'macpy>=0.1.2,<0.2.0', +] + + +setup( + name = 'emoji-keyboard', + version = '3.0.0rc0', + description = 'Type emoji easily! Virtual keyboard-like emoji palette with lots of features.', + long_description = None, + author = 'Ozymandias (Tomas Ravinskas)', + author_email = 'tomas.rav@gmail.com', + url = 'https://github.com/OzymandiasTheGreat/emoji-keyboard', + scripts = scripts, + packages = packages, + package_dir = package_dir, + install_requires = install_requires, + python_requires = '>=3.6,<4.0', +) diff --git a/src/app/components/category-tabs/tabbar.component.ts b/src/app/components/category-tabs/tabbar.component.ts index 8d4e5af94..0ba9f6295 100644 --- a/src/app/components/category-tabs/tabbar.component.ts +++ b/src/app/components/category-tabs/tabbar.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit, Inject } from "@angular/core"; import { Router } from "@angular/router"; import { DomSanitizer } from "@angular/platform-browser"; import { MatIconRegistry } from "@angular/material/icon"; -import { DataService, ICategory, SettingsService } from "../../services"; +import { DirectoryService, DataService, ICategory, SettingsService } from "../../services"; // const COMPACT = true; @@ -17,6 +17,7 @@ export class TabbarComponent implements OnInit { categories: Array; compact: boolean; constructor( + @Inject(DirectoryService) private dir: DirectoryService, @Inject(DataService) private data: DataService, @Inject(SettingsService) private prefs: SettingsService, @Inject(Router) public router: Router, @@ -35,7 +36,7 @@ export class TabbarComponent implements OnInit { registry.addSvgIcon( category.icon, sanitizer.bypassSecurityTrustResourceUrl( - `../../../assets/emoji/categories/${category.icon}` + this.dir.getAsset(`emoji/categories/${category.icon}`) ) ); } diff --git a/src/app/components/settings/settings.component.html b/src/app/components/settings/settings.component.html index 4f144efe8..d9870c153 100644 --- a/src/app/components/settings/settings.component.html +++ b/src/app/components/settings/settings.component.html @@ -42,7 +42,7 @@ - None + None diff --git a/src/app/components/settings/settings.component.ts b/src/app/components/settings/settings.component.ts index ac9192294..ffbe4cd5e 100644 --- a/src/app/components/settings/settings.component.ts +++ b/src/app/components/settings/settings.component.ts @@ -3,7 +3,7 @@ import { Component, OnInit, AfterViewInit, Inject, ViewChild, ElementRef } from import { MatSelect } from "@angular/material/select"; import { MatSlideToggle } from "@angular/material/slide-toggle"; -import { SettingsService } from "../../services"; +import { DirectoryService, SettingsService } from "../../services"; @Component({ @@ -12,6 +12,7 @@ import { SettingsService } from "../../services"; styleUrls: ['./settings.component.scss'] }) export class SettingsComponent implements OnInit, AfterViewInit { + public tonePath: string; public actions: string[] = ["type", "copy"]; public emojiThemes: string[] = ["emojitwo", "twemoji", "noto-emoji", "blobmoji", "openmoji"]; public skinTones: (string | null)[] = [null, "1F3FB", "1F3FC", "1F3FD", "1F3FE", "1F3FF"]; @@ -28,7 +29,12 @@ export class SettingsComponent implements OnInit, AfterViewInit { @ViewChild("paletteHotkey") paletteHotkey: ElementRef; @ViewChild("searchHotkey") searchHotkey: ElementRef; - constructor(@Inject(SettingsService) public prefs: SettingsService) { } + constructor( + @Inject(DirectoryService) private dir: DirectoryService, + @Inject(SettingsService) public prefs: SettingsService, + ) { + this.tonePath = this.dir.getAsset("emoji/blobmoji/"); + } ngOnInit(): void { } diff --git a/src/app/services/directory.service.ts b/src/app/services/directory.service.ts index a9a2f3176..12029b2c5 100644 --- a/src/app/services/directory.service.ts +++ b/src/app/services/directory.service.ts @@ -1,8 +1,11 @@ import * as path from "path"; +import { remote } from "electron"; import { Injectable } from "@angular/core"; import * as XDG from "xdg-portable"; import * as PKG from "../../../package.json"; +const { app } = remote; + @Injectable({ providedIn: "root", @@ -13,4 +16,11 @@ export class DirectoryService { get config(): string { return path.resolve(XDG.config(), PKG.name); } + + getAsset(assetPath: string, file: boolean = false): string { + const appPath = app.getAppPath(); + return app.isPackaged + ? path.resolve(file ? `${appPath}.unpacked` : appPath, "dist/angular/assets", assetPath) + : file ? path.resolve(appPath, "src/assets", assetPath) : path.join("assets", assetPath); + } } diff --git a/src/app/services/messenger.service.ts b/src/app/services/messenger.service.ts index e3afd89e8..4e58249f6 100644 --- a/src/app/services/messenger.service.ts +++ b/src/app/services/messenger.service.ts @@ -3,9 +3,11 @@ import * as path from "path"; import { ipcRenderer, IpcRenderer } from "electron" import { Injectable, Inject } from "@angular/core"; +import { DirectoryService } from "./directory.service"; import { IEmoji } from "./data.service"; import { RecentService } from './recent.service'; import { SettingsService } from './settings.service'; +import { Dir } from '@angular/cdk/bidi'; @Injectable({ @@ -14,6 +16,7 @@ import { SettingsService } from './settings.service'; export class MessengerService { private ipc = ipcRenderer; constructor( + @Inject(DirectoryService) private dir: DirectoryService, @Inject(RecentService) private recent: RecentService, @Inject(SettingsService) private prefs: SettingsService, ) { @@ -26,7 +29,7 @@ export class MessengerService { this.ipc.send("python", { action: "skin_tone", payload: change.value }); } else if (change.path.includes("type_expand")) { if (change.value) { - this.ipc.send("python", { action: "load", payload: path.resolve("./src/assets/data/emoji.json") }); + this.ipc.send("python", { action: "load", payload: this.dir.getAsset("data/emoji.json", true) }); } else { this.ipc.send("python", { action: "unload", payload: null }); } @@ -50,7 +53,7 @@ export class MessengerService { } loadEmoji(): void { - this.ipc.send("python", { action: "load", payload: path.resolve("./src/assets/data/emoji.json") }); + this.ipc.send("python", { action: "load", payload: this.dir.getAsset("data/emoji.json", true) }); } unloadEmoji(): void { diff --git a/src/app/services/settings.service.ts b/src/app/services/settings.service.ts index 0b643c78d..6382e0ae1 100644 --- a/src/app/services/settings.service.ts +++ b/src/app/services/settings.service.ts @@ -10,9 +10,6 @@ import { Observable as ObjectObservable } from "object-observer/dist/node/object import { DirectoryService } from './directory.service'; -const DEFAULT = "src/assets/data/default.ini"; - - export interface ISettings { PREFERENCES: { action: "type" | "copy"; @@ -43,9 +40,11 @@ export interface IChanges { providedIn: "root", }) export class SettingsService { + private DEFAULT: string; private USER: string; private SETTINGS: ISettings | any; constructor(@Inject(DirectoryService) private dir: DirectoryService) { + this.DEFAULT = this.dir.getAsset("data/default.ini", true); this.USER = path.join(dir.config, "settings.ini"); const [ _default, user ] = this.load(); this.SETTINGS = ObjectObservable.from({...ini.parse(_default), ...ini.parse(user)}); @@ -62,7 +61,7 @@ export class SettingsService { } private load() { - const _default = fs.readFileSync(DEFAULT, "utf8"); + const _default = fs.readFileSync(this.DEFAULT, "utf8"); let user; try { user = fs.readFileSync(this.USER, "utf8"); diff --git a/src/app/shared/components/emoji/emoji.component.ts b/src/app/shared/components/emoji/emoji.component.ts index dbe147c44..d8325cb58 100644 --- a/src/app/shared/components/emoji/emoji.component.ts +++ b/src/app/shared/components/emoji/emoji.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit, Input, Inject } from "@angular/core"; import { Highlightable } from "@angular/cdk/a11y"; -import { SettingsService, ISettings, IEmoji, RecentService, MessengerService, ElectronService } from "../../../services"; +import { DirectoryService, SettingsService, ISettings, IEmoji, RecentService, MessengerService, ElectronService } from "../../../services"; @Component({ @@ -17,6 +17,7 @@ export class EmojiComponent implements OnInit, Highlightable { public active = false; constructor( + @Inject(DirectoryService) private dir: DirectoryService, @Inject(SettingsService) private prefs: SettingsService, @Inject(RecentService) private recent: RecentService, @Inject(MessengerService) private messenger: MessengerService, @@ -51,7 +52,7 @@ export class EmojiComponent implements OnInit, Highlightable { } getResource(): string { - return `../../../../assets/emoji/${this.theme}/${this.emoji.skinTones[this.skinTone].imagePath}`; + return this.dir.getAsset(`emoji/${this.theme}/${this.emoji.skinTones[this.skinTone].imagePath}`); } click() { diff --git a/src/index.html b/src/index.html index 0e19e0784..bcee6b90f 100644 --- a/src/index.html +++ b/src/index.html @@ -2,11 +2,10 @@ - AngularElectron - + Emoji Keyboard diff --git a/src_py/__init__.py b/src_py/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src_py/__pycache__/__init__.cpython-37.pyc b/src_py/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ce0c94a22c6815498f32fd522a9e7a2f243bb9ac GIT binary patch literal 147 zcmZ?b<>g`kf>K!yVl7qb9~6oz01O-8?!3`HPe1o6v8KO;XkRX@L~ zGB+_VB{Q*DKcFZ-D>b>KSU)v4KPyu=JGC+?Kd~sqSiiU^IliD$KR!M)FS8^*Uaz3? U7Kcr4eoARhsvXGG&p^xo0D|ZwdH?_b literal 0 HcmV?d00001