Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies to enable Greenkeeper 🌴 #3

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.png binary
*.jpg binary
*.ico binary
*.svg binary
*.pdf binary
*.icns binary
*.jpeg binary
*.wasm binary
29 changes: 9 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
os: osx
language: node_js
node_js: node
node_js:
- node
sudo: required
services:
- docker
install:
- brew update
- brew install wine mono gnu-tar graphicsmagick xz
- npm install
- docker run -dit --name emscripten -v $(pwd):/src trzeci/emscripten:sdk-incoming-64bit bash
- npm install
script:
- npm run test
before_deploy:
- npm run build
deploy:
provider: releases
api_key:
secure: mL2CKY5DSjwcrX2xvo6l9lrkUrxYky3OE9HK7HsxZ6s3XUrRyXQO/472Bamo7CKXwyfUa/48L1OAC41R6VTQ2A3c/AJo6PrXPv9d2lZ4icomf5ocovF+DWmtVXnW1wIY48mv0xmB/iqTSDqoV/DBFnbQgY7y7W5CBJY3gjNLrtfdKw+dJbOOJMN77R8SjGBa1PU7WqnNAhidbX2DitFM9OBIj05o6lvBkbFjM5fVV77lfV5jrSXTweHF6Kq7Puv8iODNHTYtF7YF58VI4sI4gNHd/HSUscjr3Wl+jIcrqZBtzxdbyN6WpWIzVBOyjismQrefsfhX+fajzkIHS5Jizw9ObuP8PRdDRzL34W2IngsOF78j5AuslbSStLccqYjBmzDBmVvY/N5QXgCGauMIWjfYv2s822+Yw9yUaYEWEbfAwbpxlcqrNu85bA1H+h3J85gNqz9HaUJDadtpapZLm9w4byLAGUelJo2D/1UDyLFPy3cECI5ajQ4jnnDu+4v0bmZuGhpstT93QEYhfoxfFy0t2gPpkyOIzB3MrW3tDkPzOyR2DHh09TirqstVBmGa4aNvbcNObxHGTcgl2vWUPG0tgEvM7AFZ/qnpNkYaHMrUmhPgdKKYA42Ydyu7EjnPuDW+jtt4QcY4ingoSXGWZbAFmKfyBm6VdNUZjDsetes=
file_glob: true
file: 'dist/*.{dmg,AppImage,exe}'
on:
tags: true
repo: ta2gch/yomu
env:
global:
secure: PolFGPP7geB2ht6niCDB6CM/0YE0guaLid0YW/oRrTIAComo2Lf/0nfxuK7PitLiV2u9pL8kXCKxy/d1E19TNYwHtNF/XghZSxgyS3/v8lXUp3gm43Xu9LylWwt5KdniRrVbsOiOv4OZaan1A6FdCArbjrHnTjPJQFlssP/3yKJyKroJ1A2Wl1759YNux0nf3ZXwR4t6+Bliswu12/KRVgewmPUz3ecSGwP7YMFjZyH1WHJ1m/IvUEqfgVIpUi0MA3DYJbsdGT5d7ou7BGfDBn8V4Y/+SthiVnOk37PSCcZsnyRmX0Vad0WGmY9N+3q0K07lQtkXHZA4dy1hBkXqkmEaB+OY6nD1el4TIvHrru97TDmwmVxaidux+WQzX0F7fjJjHJCfTKKRtx1EHvLMnjFdipRX9uAXihDOcQm2bVri+K60+8PYfFgI+akc6ydV4R+DcvauXFbkMSRQ1JVPxdJ/OaiB3fbEohmnKNCo+SIv00CePBiJGAeG93RGQDaTIkW0YVSfyar2iSWCthnvMHbS3fhHvc/AvpTNcXjwoZPccovx3vxxTgqC6SNPwCLNjNBGdIFFVfUxmjLZYL+2bRkl0HW48AimG5DSzN15RHXOW+aGQ0eX2SbAXRpsl+U6xI/xd6wck+7C+HCANXTSMsOZAafFttqt7xetb0fP9gE=
- docker exec -it emscripten make
- npm test
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
all:
cd src && make
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div align="center">
<img src="https://ta2gch.github.io/yomu/src/icon.png" width="100">
<img src="https://asciian.github.io/yomu/src/icon.png" width="100">
<h1>yomu</h1>
   <p>英和辞書付きPDF閲覧ソフト</p>
<a href="https://travis-ci.org/ta2gch/yomu">
Expand All @@ -9,33 +9,36 @@

## 特徴

[![Greenkeeper badge](https://badges.greenkeeper.io/asciian/yomu.svg)](https://greenkeeper.io/)

- PDF.jsをベースにしたPDF閲覧ソフト
- 標準でオフライン英和辞書を内蔵
- 曖昧検索に対応

## インストール方法

[リリースページ](https://github.com/ta2gch/yomu/releases)よりWindows版/macOS版/Linux版をダウンロードしてください。
また、[ブラウザ版](https://ta2gch.github.io/yomu/src/pdf.js/web/viewer.html)もお使いただけます。
[リリースページ](https://github.com/asciian/yomu/releases)よりWindows版/macOS版/Linux版をダウンロードしてください。
また、[ブラウザ版](https://asciian.github.io/yomu/src/pdf.js/web/viewer.html)もお使いただけます。

### NPM版

npm からもインストール可能になりました。

```
npm install -g ta2gch/yomu
npm install -g electron
npm install -g asciian/yomu
```

## 使い方

調べたい英単語をドラックあるいはダブルクリックすることで、
単語の意味を単語周辺に表示します。

![screenshot](https://ta2gch.github.io/yomu/screenshot/Screenshot.png)
![screenshot](https://asciian.github.io/yomu/screenshot/Screenshot.png)

## 関連リンク

- [yomu](http://github.com/ta2gch/yomu) (ホスティングサイト)
- [yomu](http://github.com/asciian/yomu) (ホスティングサイト)
- [PDF.js](https://mozilla.github.io/pdf.js/) (PDF表示用ライブラリ)
- [EJDict](https://github.com/kujirahand/EJDict) (パブリックドメインの英和辞書)

Expand Down
136 changes: 0 additions & 136 deletions Vagrantfile

This file was deleted.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
{
"name": "yomu",
"version": "1.1.0",
"version": "1.2.0",
"description": "PDF viewer (with English Japanese dictionary)",
"main": "src/main.js",
"author": "TANIGUCHI Masaya",
"license": "Apache-2.0",
"scripts": {
"test": "echo 'Hello, World.'",
"test": "echo 'This software is awesome!'",
"clean": "rm -rf dist **/*~",
"dist-clean": "npm run clean && rm -rf node_modules",
"build": "build -mwl"
},
"devDependencies": {
"electron-builder": "^16.6.1"
"electron": "^2.0.2",
"electron-builder": "^20.15.1"
},
"build": {
"appId": "space.moffice.yomu",
"mac": {
"category": "public.app-category.utilities"
"category": "public.app-category.utilities"
},
"linux": {
"category": "Office"
"category": "Office"
}
},
"bin": "bin/cli.js",
"dependencies": {
"electron": "^1.6.2",
"about-window": "^1.6.1"
}
}
13 changes: 13 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CC = emcc
SRC = dictionary.cpp bindings.cpp
OUT = pdf.js/web/bindings.js
OPT = -O2 -std=c++1z
OPT += --bind
OPT += -s WASM=1
OPT += -s TOTAL_MEMORY=52428800
OPT += -s MODULARIZE=1

all: $(OUT)

$(OUT): $(SRC)
$(CC) $(SRC) -o $(OUT) $(OPT)
39 changes: 39 additions & 0 deletions src/bindings.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <emscripten/bind.h>
#include <emscripten/val.h>
#include <unordered_map>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <optional>
#include <fstream>
#include <locale>
#include <codecvt>
#include "dictionary.hpp"

Dictionary makeDictionary(emscripten::val data) {
std::unordered_map<std::string, std::string> source;
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> cv;
auto entries = emscripten::val::global("Object").call<emscripten::val>("entries", data);
for(int i = 0; i < entries["length"].as<int>(); i++) {
std::pair<std::string, std::string> entry;
entry.first = cv.to_bytes(entries[i][0].as<std::wstring>());
entry.second = cv.to_bytes(entries[i][1].as<std::wstring>());
source.insert(entry);
}
return Dictionary(source, 3);
}

std::wstring value_or(const std::optional<std::string>& opt, const std::string& otherwise) {
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> cv;
return cv.from_bytes(opt.value_or(std::forward<const std::string&>(otherwise)));
}

EMSCRIPTEN_BINDINGS(dictionary) {
emscripten::function("makeDictionary", &makeDictionary);
emscripten::class_<std::optional<std::string>>("Optional")
.function("valueOr", &value_or);
emscripten::class_<Dictionary>("Dictionary")
.function("correct", &Dictionary::correct)
.function("lookup", &Dictionary::lookup);
}
63 changes: 63 additions & 0 deletions src/dictionary.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include <string>
#include <unordered_map>
#include <optional>
#include <regex>
#include <iostream>
#include "dictionary.hpp"

Dictionary::Dictionary(const std::unordered_map<std::string, std::string>& source, int max_depth)
: max_depth(max_depth)
, source(source)
, suffix(std::regex("ing$|ies$"))
, alphabet("abcdefghijklmnopqrstuvwxyz") {}

std::optional<std::string> Dictionary::edit(const std::string& word, int depth) const {
if (depth == max_depth) {
return (source.find(word) != std::end(source)) ? std::make_optional(word) : std::nullopt;
}

std::optional<std::string> result;
for(int i = word.length() - 1; !result.has_value() && i > 0; --i) {
for(auto c = std::begin(alphabet); !result.has_value() && c != std::end(alphabet); ++c) {
std::string replacement = word;
replacement[i] = *c;
result = edit(replacement, depth+1);
}
}
for(int i = word.length() - 1; !result.has_value() && i >= 0; --i) {
std::string replacement = word;
replacement[i] ^= replacement[i+1];
replacement[i+1] ^= replacement[i];
replacement[i] ^= replacement[i+1];
result = edit(replacement, depth+1);
}
for(int i = word.length() - 1; !result.has_value() && i >= 0; --i) {
std::string replacement = word;
replacement.erase(std::begin(replacement)+i);
result = edit(replacement, depth+1);
}
for(int i = word.length() - 1; !result.has_value() && i > 0; --i) {
for(auto c = std::begin(alphabet); !result.has_value() && c != std::end(alphabet); ++c) {
std::string replacement = word;
replacement.insert(std::begin(replacement)+i, *c);
result = edit(replacement, depth+1);
}
}
return result;
}

std::optional<std::string> Dictionary::correct(const std::string& word) const {
std::string replacement(std::regex_replace(word, suffix, "i"));
std::optional<std::string> result = std::nullopt;
for(int i = max_depth; !result.has_value() && i > 0; --i) {
result = edit(replacement, i);
}
return result;
}

std::optional<std::string> Dictionary::lookup(const std::string& word) const {
auto keyword = correct(word);
return keyword.has_value()
? std::make_optional(source.at(keyword.value()))
: std::nullopt;
}
Loading