Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

Commit

Permalink
feat: auto device list, readme, license etc
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcralph committed Jul 14, 2021
1 parent abc72ed commit 8cc3716
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ node_modules/
*.jpg
*.webp
config.json
devices.csv
devices.json
package-lock.json
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 The Mue Authors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
38 changes: 29 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
# uploader
Internal uploading utility for Mue

## About
The process of uploading images to Mue was long and tedious - you had to generate a file name, add it to the database with the information, compress the image and then upload it and hope it works. This utility was made to make creating the new photo database in 5.2 a much easier process. The utility allows you to simply select a file, choose the category + photographer and click upload.

## Features
* Supports converting jpg, png, cr3, cr2, dng, raf, fff, rwl, nef, rw2, x3f and arw files to webp
* Get formatted Mue location (e.g Manchester, United Kingdom) from EXIF data
* Get camera or phone model name (e.g Canon 1300D, Samsung Galaxy S8)
* Automatic listing of photographers and categories with an option to add new ones
* Undo button in case you made a mistake

## Installation
### Requirements
* Cloudinary
* Supabase
* OpenCage (optional, used for getting location from exif coordinates)
### Instructions
1. ``git clone https://github.com/mue/uploader``
2. ``cd uploader`` and ``npm i`` (or ``yarn``)
3. Move ``config-example.json`` to ``config.json`` and fill out your Cloudinary keys, Supabase API information and OpenCage API key.
4. ``npm start`` or ``yarn``
5. Start developing!
* [Git](https://git-scm.com/)
* [Node.js](https://nodejs.org)
* [A free Cloudinary account](https://cloudinary.com/)
* [Mue API Instance](https://github.com/mue/api)
* [A free OpenCage API key](https://opencagedata.com/) (optional, used for getting location from exif coordinates)
### Starting
1. Clone the repository using ``git clone https://github.com/mue/uploader.git``
2. Run ``npm i`` (or ``yarn``) to install all needed dependencies
3. Move ``config-example.json`` to ``config.json`` and add your keys etc
4. Run ``node getdevicelist.js`` to get the phone device list
5. ``npm start`` or ``yarn``
6. Code your heart out!
### Building
1. ``npm run build``

Please note that currently it only returns a Windows build, and the uploader utility has not been tested on any other operating system. Due to the fact this program is useless without the correct setup, no prebuilt binaries are provided.

## License
[MIT](LICENSE)
3 changes: 2 additions & 1 deletion config-example.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"key": ""
},
"opencage": ""
}
},
"api_url": ""
}
17 changes: 17 additions & 0 deletions getdevicelist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const csv = require('convert-csv-to-json');
const fetch = require('node-fetch');
const fs = require('fs');

const downloadFile = (async (url, path) => {
const res = await fetch(url);
const stream = fs.createWriteStream(path);
await new Promise((resolve, reject) => {
res.body.pipe(stream);
res.body.on('error', reject);
stream.on('finish', resolve);
});
});

downloadFile('https://storage.googleapis.com/play_public/supported_devices.csv', './devices.csv').then(() => {
csv.fieldDelimiter(',').ucs2Encoding().generateJsonFileFromCsv('devices.csv', 'devices.json');
});
13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"name": "mue-uploader",
"author": "David Ralph",
"version": "1.0.0",
"private": true,
"repository": {
"url": "github:mue/uploader"
},
"license": "MIT",
"author": "The Mue Authors (https://github.com/mue/uploader/graphs/contributors)",
"version": "1.1.0",
"description": "Internal uploading utility for Mue",
"scripts": {
"start": "electron .",
Expand All @@ -15,7 +20,9 @@
"sharp": "^0.28.3"
},
"devDependencies": {
"convert-csv-to-json": "^1.3.1",
"electron": "13.1.6",
"electron-builder": "^22.11.7"
"electron-builder": "^22.11.7",
"node-fetch": "^2.6.1"
}
}
6 changes: 3 additions & 3 deletions public/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ body {
font-size: 14px;
}

#title-bar-btns {
#title-bar-buttons {
-webkit-app-region: no-drag;
position: fixed;
top: 1px;
right: 0px;
}

#title-bar-btns button {
#title-bar-buttons button {
height: 32px;
width: 32px;
background-color: transparent;
Expand All @@ -93,6 +93,6 @@ body {
cursor: pointer;
}

#title-bar-btns button:hover {
#title-bar-buttons button:hover {
background-color: var(--tab-active);
}
8 changes: 4 additions & 4 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<body>
<div id='title-bar'>
<div id='title'>Mue Uploader</div>
<div id='title-bar-btns'>
<button id='min-btn'>-</button>
<button id='max-btn'>+</button>
<button id='close-btn'>x</button>
<div id='title-bar-buttons'>
<button id='min-button'>-</button>
<button id='max-button'>+</button>
<button id='close-button'>x</button>
</div>
</div>
<h1>Uploader</h1>
Expand Down
15 changes: 6 additions & 9 deletions public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ ipcRenderer.on('addedFile', async (_event, arg, arg2) => {
const phoneInfo = devices.find(device => device.model === arg.Model);
const model = document.getElementById('model');
if (phoneInfo) {
if (phoneInfo.marketing_name.split(' ')[0] === phoneInfo.retail_branding) {
model.value = phoneInfo.marketing_name
if (phoneInfo['MarketingName'].split(' ')[0] === phoneInfo['RetailBranding']) {
model.value = phoneInfo['MarketingName'];
} else {
model.value = phoneInfo.retail_branding + ' ' + phoneInfo.marketing_name;
model.value = phoneInfo['RetailBranding'] + ' ' + phoneInfo['MarketingName'];
}
} else {
if (!arg.Make && !arg.Model) {
Expand All @@ -45,8 +45,7 @@ ipcRenderer.on('addedFile', async (_event, arg, arg2) => {
// find location from gps data
if (config.tokens.opencage !== '' && arg.latitude && arg.longitude) {
try {
const res = await fetch(`https://api.opencagedata.com/geocode/v1/json?q=${arg.latitude},${arg.longitude}&key=${config.tokens.opencage}`);
const location = await res.json();
const location = await (await fetch(`https://api.opencagedata.com/geocode/v1/json?q=${arg.latitude},${arg.longitude}&key=${config.tokens.opencage}`)).json();
document.getElementById('location').value = location.results[0].components.town ? location.results[0].components.town + ', ' + location.results[0].components.country : location.results[0].components.country;
} catch (e) {
document.getElementById('location').value = '';
Expand All @@ -58,8 +57,7 @@ ipcRenderer.on('addedFile', async (_event, arg, arg2) => {

// list of photographers
const getPhotographers = async () => {
const res = await fetch('https://api.muetab.com/images/photographers');
const photographers = await res.json();
const photographers = await (await fetch(config.api_url + '/images/photographers')).json();
const dropdown = document.getElementById('photographer');
// in the future, we probably want to make the api sort alphabetically instead of doing it here
photographers.sort().forEach((element) => {
Expand All @@ -84,8 +82,7 @@ document.getElementById('photographer').onchange = (e) => {

/// copy and pasted from above
const getCategories = async () => {
const res = await fetch('https://api.muetab.com/images/categories');
const categories = await res.json();
const categories = await (await fetch(config.api_url + '/images/categories')).json();
const dropdown = document.getElementById('category');
categories.forEach((element) => {
const option = document.createElement('option');
Expand Down
6 changes: 3 additions & 3 deletions public/titlebar.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const init = () => {
document.getElementById('min-btn').addEventListener('click', () => {
document.getElementById('min-button').addEventListener('click', () => {
ipcRenderer.send('titlebar', 'minimize');
});

document.getElementById('max-btn').addEventListener('click', () => {
document.getElementById('max-button').addEventListener('click', () => {
ipcRenderer.send('titlebar', 'maximise');
});

document.getElementById('close-btn').addEventListener('click', () => {
document.getElementById('close-button').addEventListener('click', () => {
ipcRenderer.send('titlebar', 'close');
});
};
Expand Down

0 comments on commit 8cc3716

Please sign in to comment.