Skip to content

Commit

Permalink
test indexeddb
Browse files Browse the repository at this point in the history
  • Loading branch information
lagleki authored and lagleki committed Jun 16, 2020
1 parent aaa599b commit ed345d1
Show file tree
Hide file tree
Showing 62 changed files with 2,027 additions and 1,598 deletions.
79 changes: 42 additions & 37 deletions livla/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* jshint bitwise: false */
const lg = console.log.bind(console)
const p = (object) => JSON.stringify(object)

// livla bot
const fs = require('fs')
Expand All @@ -10,7 +9,6 @@ const R = require('ramda')
const lojban = require('lojban')
const he = require('he')
const { to } = require('await-to-js')
const rp = require('request-promise-native')
const mkdirp = require('mkdirp')

const escapeRegExp = (string) => string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
Expand All @@ -32,8 +30,6 @@ db.pragma('journal_mode = WAL')
const sanitizeHtml = require('sanitize-html')

const tato = require('./tatoeba.js')
const interv = 300000
const interm = 2900
const nodasezvafahi = "no da se zvafa'i"
const tersepli = ' + '
const commandPrefix = '.'
Expand Down Expand Up @@ -87,10 +83,9 @@ let server = 'irc.freenode.net'
let twitter_id = 'good_opinions,opinions_good,cunsku'
let consumer_key, consumer_secret, access_token_key, access_token_secret
let arr_twitter_id
let config = {}

// End default configuration
const commonConfig = require('../config/config.js')
const config = require(path.join(require('os').homedir(), '.livla/config.json'))

let userSettings = {} // Saving user preferences
userSettings[replier] = {
Expand Down Expand Up @@ -176,8 +171,8 @@ const loadConfig = () => {
twitter_id = either(localConfig, 'twitter_id', twitter_id)
arr_twitter_id = twitter_id.split(',')

if (!commonConfig.disableIrcBots && !commonConfig.disableTwitter)
startTwitterStream()
config = { ...localConfig }
if (!config.disableIrcBots && !config.disableTwitter) startTwitterStream()
}

function startTwitterStream() {
Expand Down Expand Up @@ -276,7 +271,7 @@ const updateUserSettings = (callback) => {

// IRC bot
let clientmensi
if (!commonConfig.disableIrcBots) {
if (!config.disableIrcBots) {
const Irc = require('irc-upd')
lg('channels', configmensi.options.channels)
clientmensi = new Irc.Client(
Expand Down Expand Up @@ -752,35 +747,44 @@ function prepareSutysiskuJsonDump(language) {
delete json[v.word][key]
)
})
return `sorcu["${language}"] = ${JSON.stringify(json)}`
return {
js: `sorcu["${language}"] = ${JSON.stringify(json)}`,
json: JSON.stringify(json),
}
}
const ningau_palasutysisku = (language, lojbo) => {
// write a new file parsed.js that would be used by la sutysisku
if (!language) language = 'en'
const pars = prepareSutysiskuJsonDump(language)
let t = path.join(
__dirname,
'../build/sutysisku/data',
`parsed-${language}.js`
)
fs.writeFileSync(`${t}.temp`, pars)
fs.renameSync(`${t}.temp`, t)
t = path.join(__dirname, `../build/sutysisku/${language}/`, 'webapp.appcache')
const d = new Date()
let n = d.getDate()
if (n === 1 || n === 11 || n === 21) {
try {
n = `${d.getFullYear()}-${
d.getMonth() + 1
}-${d.getDate()}T${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}`
pars = fs
.readFileSync(t, {
encoding: 'utf8',
})
.replace(/\n# .+\n/, `\n# ${n}\n`)
fs.writeFileSync(t, pars)
lg(`${t} updated`)
} catch (err) {}
for (const format of ['js', 'json']) {
const pars = prepareSutysiskuJsonDump(language)[format]
let t = path.join(
__dirname,
'../build/sutysisku/data',
`parsed-${language}.${format}`
)
fs.writeFileSync(`${t}.temp`, pars)
fs.renameSync(`${t}.temp`, t)
t = path.join(
__dirname,
`../build/sutysisku/${language}/`,
'webapp.appcache'
)
const d = new Date()
let n = d.getDate()
if (n === 1 || n === 11 || n === 21) {
try {
n = `${d.getFullYear()}-${
d.getMonth() + 1
}-${d.getDate()}T${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}`
pars = fs
.readFileSync(t, {
encoding: 'utf8',
})
.replace(/\n# .+\n/, `\n# ${n}\n`)
fs.writeFileSync(t, pars)
lg(`${t} updated`)
} catch (err) {}
}
}
}

Expand Down Expand Up @@ -875,7 +879,7 @@ const ningaumahantufa = (text, socket) => {
// // write to a file
fs.writeFileSync(whichfile, camxes, { encoding: 'utf8' })
const Terser = require('terser')
const result = camxes;
const result = camxes
// Terser.minify(camxes, {
// ecma: 5,
// mangle: {
Expand Down Expand Up @@ -986,6 +990,7 @@ async function updateXmlDumps() {
return uniques(erroredLangs)
}

updateXmlDumps()
setInterval(() => {
updateXmlDumps()
}, 1 * 1 * 60 * 60 * 1000) // update logs once an hour
Expand Down Expand Up @@ -1342,7 +1347,7 @@ async function processor({ from, towhom, text, socket }) {
if (replyToVocatives({ from, text, sendTo, socket })) return
sendDelayed({ from, sendTo, socket })

text = text.toLowerCase().trim().replace(//g,"'")
text = text.toLowerCase().trim().replace(//g, "'")
let inLanguage = defaultLanguage
if (text.charAt(0) === '#' && replyToHashed({ text, socket, sendTo })) return
if (text.indexOf(commandPrefix) === 0) {
Expand Down Expand Up @@ -1444,7 +1449,7 @@ async function processor({ from, towhom, text, socket }) {
}
}

if (!commonConfig.disableIrcBots) {
if (!config.disableIrcBots) {
clientmensi.on('message', (from, towhom, text) => {
processor({ from, towhom, text })
})
Expand Down
32 changes: 30 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "la_livla",
"version": "0.0.1",
"type": "module",
"description": "A combine of Lojban tools",
"dependencies": {
"async": "^3.2.0",
Expand Down Expand Up @@ -33,6 +32,7 @@
"ramda": "^0.27.0",
"randexp": "^0.5.3",
"recursive-readdir": "^2.2.2",
"regenerator-runtime": "^0.13.5",
"request": "^2.88.2",
"request-promise-native": "^1.0.8",
"sanitize-html": "^1.26.0",
Expand All @@ -50,7 +50,7 @@
"type": "git",
"url": "https://github.com/lagleki/livla"
},
"main": "livla/livla.js",
"main": "livla/index.js",
"scripts": {
"ncu": "ncu -u",
"start": "nodemon --ignore ./ --exec \"node livla/index.js\"",
Expand All @@ -61,8 +61,11 @@
},
"devDependencies": {
"@babel/core": "^7.10.2",
"@babel/plugin-transform-runtime": "^7.10.1",
"@babel/preset-env": "^7.10.2",
"@babel/runtime": "^7.10.2",
"babel-plugin-minify-dead-code-elimination": "^0.5.1",
"core-js": "^3.6.5",
"nodemon": "^2.0.4",
"npm-check-updates": "^6.0.1",
"terser": "^4.7.0"
Expand Down
15 changes: 15 additions & 0 deletions sutysisku/ToDo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
back button doesnt work
each language should have a native name in tejufra
CLL,2002 is a new language
en-cll
en-jvs
each word sh have a button: all langs mode - if true then bangu: undefined, shortget

on empty db => start downloading, show message of downloading with lang
first download locales
then jvs
then cll

db.cll
db.tejufra

Loading

0 comments on commit ed345d1

Please sign in to comment.