Skip to content

Commit

Permalink
fixed title for senses with Synonym & Opposite
Browse files Browse the repository at this point in the history
  • Loading branch information
bikenik committed Apr 11, 2019
1 parent 04cb860 commit 00ad6e0
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 22 deletions.
2 changes: 1 addition & 1 deletion info.plist
Expand Up @@ -5638,7 +5638,7 @@ Search for entries with the given headword</string>
<string>language</string>
</array>
<key>version</key>
<string>1.4.0</string>
<string>1.4.1</string>
<key>webaddress</key>
<string>https://github.com/bikeNik/alfred-ldoce#readme</string>
</dict>
Expand Down
6 changes: 2 additions & 4 deletions src/api/body/index.js
Expand Up @@ -13,15 +13,14 @@ const {notFound} = require('../../utils/engine').warning
const regularRender = require('./regular-senses')

const {wordOfURL} = process.env
// Const wordOfURL = '/v2/dictionaries/entries/cqAFmvgmaf'

const fileBody = './src/input/body.json'
try {
fs.unlinkSync(fileBody)
process.stdout.write('successfully deleted: fileBody')
// Process.stderr.write('successfully deleted: fileBody')
} catch (error) {
if (error.code !== 'ENOENT') {
process.stderr.write(error)
// Process.stderr.write(error)
}
}

Expand Down Expand Up @@ -199,7 +198,6 @@ alfy.fetch(url).then(data => {
items.push(item.getProperties())
}

// Const itemsResult = items.filter(item => item.title)
const itemsResult = items.filter(item => item && item.title)
alfy.input = alfy.input.replace(/.*?\u2023[\s]/gm, '')
const variantsToSingleChoose = alfy.inputMatches(itemsResult, 'title').map(x => ({
Expand Down
9 changes: 0 additions & 9 deletions src/api/body/internal-function.js

This file was deleted.

7 changes: 2 additions & 5 deletions src/api/body/regular-senses.js
Expand Up @@ -2,8 +2,6 @@
const Render = require('../../utils/engine')
const {notFound} = require('../../utils/engine').warning

const {typeOfAddition} = require('./internal-function')

const objectOfSense = (sense, $) => {
return {
checkForEmpty: sense.examples || sense.definition,
Expand Down Expand Up @@ -62,8 +60,7 @@ const grammaticalCom = obj => {
const grammaticalSynAndOpp = (obj, $) => {
const {sense, gramaticalExample, examples, quicklookurl} = obj
let {item} = obj
const title = `${gramaticalExample.pattern || sense.signpost || $.headword || sense.definition[0]}\t 🔦 ${typeOfAddition(sense)}: ${sense.synonym || sense.opposite}`

const title = `${gramaticalExample.pattern || sense.signpost || $.headword || sense.definition[0]}\t 🔦 ${sense.synonym ? 'SYN' : 'OPP'}: ${sense.synonym || sense.opposite}`
item = new Render('Words with Synonyms & opposites',
'title', 'subtitle', 'sentence', 'icon', 'arg', 'mods')
item.title = title
Expand All @@ -90,7 +87,7 @@ const grammaticalSynAndOpp = (obj, $) => {

const seeAlso = obj => {
const {sense, examples, quicklookurl, $} = obj
const title = `${sense.signpost || $.headword || sense.definition[0]}\t 🔦 ${typeOfAddition(sense)}: ${sense.synonym || sense.opposite}`
const title = `${sense.signpost || $.headword || sense.definition[0]}\t 🔦 ${sense.synonym ? 'SYN' : 'OPP'}: ${sense.synonym || sense.opposite}`
const item = new Render('words with synonyms & opposites case 2',
'title', 'subtitle', 'sentence', 'icon', 'arg', 'mods')
item.title = title
Expand Down
1 change: 0 additions & 1 deletion src/api/mydata.js
Expand Up @@ -5,7 +5,6 @@ const md5 = require('md5')
const streamToPromise = require('stream-to-promise')

const config = require('../config')
// eslint-disable-next-line import/no-unresolved
const mainDataExp = require('../input/body.json')
const header = require('../input/header.json')

Expand Down
13 changes: 11 additions & 2 deletions src/input/header.json
@@ -1,3 +1,12 @@
[
{}
]
{
"Headword": "example",
"Brit_audio": "/v2/dictionaries/assets/ldoce/gb_pron/example0205.mp3",
"Amer_audio": "/v2/dictionaries/assets/ldoce/us_pron/example.mp3",
"Part_of_speech": "noun",
"Type_of_gramm": "countable",
"Inflections": {
"plural": "examples"
}
}
]

0 comments on commit 00ad6e0

Please sign in to comment.