Skip to content

Commit

Permalink
added prettier, eslint, spanish translations (irislib#161)
Browse files Browse the repository at this point in the history
* fix: handle missing user on metion properly

* prettier eslint

* use dep from npm registry

* fix: send from to sub callback
  • Loading branch information
fernandolguevara authored Nov 11, 2022
1 parent a4828cd commit aaa421c
Show file tree
Hide file tree
Showing 112 changed files with 22,907 additions and 8,512 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/js/lib/*.js
40 changes: 40 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'plugin:prettier/recommended',
],
overrides: [],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: ['simple-import-sort', '@typescript-eslint'],
rules: {
'simple-import-sort/imports': [
'error',
{
groups: [
// Packages `react` related packages come first.
['^react', '^@?\\w'],
// Internal packages.
['^(@|components)(/.*|$)'],
// Side effect imports.
['^\\u0000'],
// Parent imports. Put `..` last.
['^\\.\\.(?!/?$)', '^\\.\\./?$'],
// Other relative imports. Put same-folder imports and `.` last.
['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
// Style imports.
['^.+\\.?(css)$'],
],
},
],
},
};
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: 16.x
cache: "yarn"
cache: 'yarn'
- name: Install dependencies
run: yarn --frozen-lockfile
- name: Build
Expand All @@ -24,7 +24,7 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: 16.x
cache: "yarn"
cache: 'yarn'
- name: Install dependencies
run: yarn --frozen-lockfile
- name: Lint
Expand All @@ -37,7 +37,7 @@ jobs:
uses: actions/setup-node@v2
with:
node-version: 16.x
cache: "yarn"
cache: 'yarn'
- name: Install dependencies
run: yarn --frozen-lockfile
- name: Test
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src/css/cropper.min.css
build
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"useTabs": false,
"singleQuote": true,
"printWidth": 100,
"semi": true,
"trailingComma": "all",
"arrowParens": "always",
"tabWidth": 2
}
34 changes: 21 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
# Iris

Iris is like the social networking apps we're used to, but better.
* No phone number or signup required. Just type in your name or alias and go!
* Secure: It's open source. Users can validate that big brother doesn't read your private messages.
* Available: It works offline-first and is not dependent on any single centrally managed server. Users can even connect directly to each other.

- No phone number or signup required. Just type in your name or alias and go!
- Secure: It's open source. Users can validate that big brother doesn't read your private messages.
- Available: It works offline-first and is not dependent on any single centrally managed server. Users can even connect directly to each other.

![Screenshot](screenshot.png)

## Use

Browser application: [iris.to](https://iris.to)
* No installation required
* Progressive web app
* Use offline
* Save as an app to home screen or desktop

- No installation required
- Progressive web app
- Use offline
- Save as an app to home screen or desktop

Desktop application: ([download](https://github.com/irislib/iris-electron/releases), [source code](https://github.com/irislib/iris-electron)):
* Communicate and synchronize with local network peers without Internet access
* When local peers eventually connect to the Internet, your messages are relayed globally
* Bluetooth support upcoming
* Opens to background on login: stay online and get message notifications!
* More secure and available: no need to open the browser application from a server.

- Communicate and synchronize with local network peers without Internet access
- When local peers eventually connect to the Internet, your messages are relayed globally
- Bluetooth support upcoming
- Opens to background on login: stay online and get message notifications!
- More secure and available: no need to open the browser application from a server.

## Develop
``` bash

```bash
# install dependencies
yarn

Expand All @@ -41,6 +47,7 @@ yarn test
[iris-lib](https://github.com/irislib/iris-lib) is a core part of the application. You can clone it and run `yarn link` in the iris-lib directory. Then run `yarn link iris-lib` in the iris-messenger directory.

## Privacy

The application is an unaudited proof-of-concept implementation, so don't use it for security critical purposes.

Private messages are end-to-end encrypted, but message timestamps and the number of chats aren't. In a decentralized network this information is potentially available to anyone.
Expand All @@ -52,6 +59,7 @@ In that regard, Iris prioritizes decentralization and availability over perfect
Profile names, photos and online status are currently public. That can be changed when advanced group permissions are developed.

## Contact

Join our [Discord](https://discord.gg/4CJc74JEUY) (will be moved onto Iris when group chat is ready) or send me a message on [Iris](https://iris.to/?chatWith=hyECQHwSo7fgr2MVfPyakvayPeixxsaAWVtZ-vbaiSc.TXIp8MnCtrnW6n2MrYquWPcc-DTmZzMBmc2yaGv9gIU&s=HlzYzNrhUsrn2PLi4yuRt6DiFUNM3hOmN8nFpgw6T-g&k=zvDfsInsMOI1).

---
Expand Down
23 changes: 16 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"build": "preact build --no-prerender",
"serve": "sirv build --port 8080 --cors --single",
"dev": "preact watch --host localhost --sw",
"lint": "eslint src",
"lint": "eslint 'src/**/*.{js,ts,tsx}'",
"lint:fix": "eslint --fix --quiet 'src/**/*.{js,ts,tsx}'",
"format": "prettier --plugin-search-dir . --write .",
"test": "jest"
},
"eslintConfig": {
Expand All @@ -33,24 +35,31 @@
},
"devDependencies": {
"@types/jquery": "3.5.14",
"@types/lodash": "4.14.186",
"@types/lodash": "4.14.187",
"@types/react-helmet": "6.1.5",
"@types/webtorrent": "0.109.3",
"@typescript-eslint/eslint-plugin": "^5.42.0",
"@typescript-eslint/parser": "^5.42.0",
"enzyme": "^3.11.0",
"enzyme-adapter-preact-pure": "^4.0.1",
"eslint": "^8.24.0",
"eslint": "^8.26.0",
"eslint-config-preact": "^1.3.0",
"jest": "^27.0.6",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-simple-import-sort": "^8.0.0",
"gun": "^0.2020.1238",
"jest": "^29.2.2",
"jest-preset-preact": "^4.0.5",
"preact-cli": "^3.4.1",
"prettier": "^2.7.1",
"sirv-cli": "2.0.2",
"webpack-build-notifier": "^2.3.0"
},
"dependencies": {
"@walletconnect/web3-provider": "^1.8.0",
"@zxing/library": "^0.19.1",
"aether-torrent": "^0.3.0",
"alchemy-sdk": "^2.1.0",
"alchemy-sdk": "^2.2.0",
"elliptic": "^6.5.4",
"fuse.js": "^6.6.2",
"history": "5.3.0",
Expand All @@ -61,10 +70,10 @@
"jsxstyle": "^2.5.1",
"localforage": "^1.10.0",
"lodash": "^4.17.21",
"preact": "^10.11.0",
"preact": "^10.11.2",
"preact-async-route": "2.2.1",
"preact-custom-element": "^4.2.1",
"preact-render-to-string": "^5.2.4",
"preact-render-to-string": "^5.2.6",
"preact-router": "^4.1.0",
"preact-scroll-viewport": "^0.2.0",
"react-helmet": "^6.1.0",
Expand Down
12 changes: 6 additions & 6 deletions preact.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ export default {
config.plugins = config.plugins || [];
config.plugins.push(
new WebpackBuildNotifierPlugin({
title: "Iris Webpack Build",
logo: path.resolve("./src/assets/img/icon128.png"),
title: 'Iris Webpack Build',
logo: path.resolve('./src/assets/img/icon128.png'),
suppressSuccess: true, // don't spam success notifications
warningSound: false,
suppressWarning: true,
})
)
}
}
}),
);
},
};
108 changes: 55 additions & 53 deletions scripts/TranslationsToCsv.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {AVAILABLE_LANGUAGE_KEYS} from "../src/js/translations/Translation.mjs";
import fs from "fs";
import fs from 'fs';

import { AVAILABLE_LANGUAGE_KEYS } from '../src/js/translations/Translation.mjs';

// Create a csv file where each row is a translation key and the column is the translation in different languages.
// The file is created in the current working directory.
Expand All @@ -8,68 +9,69 @@ import fs from "fs";
// TODO: read translations from .mjs files in ../src/js/translations/

async function translationsToCsv() {
let csv = '';
let languages = [];
let translationKeys = [];
let translations = {};
let csv = '';
let languages = [];
let translationKeys = [];
let translations = {};

for (let lang of AVAILABLE_LANGUAGE_KEYS) {
const translation = (await import (`../src/js/translations/${lang}.mjs`)).default;
translations[lang] = translation;
languages.push(lang);
for (let key in translation) {
if (translationKeys.indexOf(key) === -1) {
translationKeys.push(key);
}
}
for (let lang of AVAILABLE_LANGUAGE_KEYS) {
const translation = (await import(`../src/js/translations/${lang}.mjs`)).default;
translations[lang] = translation;
languages.push(lang);
for (let key in translation) {
if (translationKeys.indexOf(key) === -1) {
translationKeys.push(key);
}
}
}

languages.sort();
translationKeys.sort();
languages.sort();
translationKeys.sort();

// add language names to csv
csv += '"","';
for (let i = 0; i < languages.length; i++) {
csv += languages[i];
if (i < languages.length - 1) {
csv += '","';
} else {
csv += '"\n';
}
// add language names to csv
csv += '"","';
for (let i = 0; i < languages.length; i++) {
csv += languages[i];
if (i < languages.length - 1) {
csv += '","';
} else {
csv += '"\n';
}
}

csv += '"';
for (let key of translationKeys) {
let row = key;
for (let lang of languages) {
row += '","' + (translations[lang][key] || '').replace(/"/g, '""');
}
csv += row + '"\n';
if (key !== translationKeys[translationKeys.length - 1]) {
csv += '"';
};
csv += '"';
for (let key of translationKeys) {
let row = key;
for (let lang of languages) {
row += '","' + (translations[lang][key] || '').replace(/"/g, '""');
}
csv += row + '"\n';
if (key !== translationKeys[translationKeys.length - 1]) {
csv += '"';
}
}

// output csv to file
fs.writeFileSync('translations.csv', csv);
console.log('wrote translations.csv');
// output csv to file
fs.writeFileSync('translations.csv', csv);
console.log('wrote translations.csv');
}

// convert the csv back to Translations.mjs in the same format as the original Translations.mjs file
function csvToTranslations() { // TODO: work in progress
let csv = fs.readFileSync('translations.csv', 'utf8');
let lines = csv.split('\n');
let translations = {};
let languages = lines[0].split(',');
languages.shift();
for (let i = 1; i < lines.length; i++) {
let line = lines[i].split(',');
let key = line[0];
line.shift();
for (let j = 0; j < languages.length; j++) {
translations[key][languages[j]] = line[j] || null;
}
function csvToTranslations() {
// TODO: work in progress
let csv = fs.readFileSync('translations.csv', 'utf8');
let lines = csv.split('\n');
let translations = {};
let languages = lines[0].split(',');
languages.shift();
for (let i = 1; i < lines.length; i++) {
let line = lines[i].split(',');
let key = line[0];
line.shift();
for (let j = 0; j < languages.length; j++) {
translations[key][languages[j]] = line[j] || null;
}
}
}

translationsToCsv();
translationsToCsv();
Loading

0 comments on commit aaa421c

Please sign in to comment.