From b6eb4c076b8fe2a1030d2afa08dd32c4e1464d55 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Fri, 23 Jun 2017 09:33:29 -0700 Subject: [PATCH 1/5] image selection does not override name --- public/assets/js/claimPublish.js | 6 ++++-- views/partials/publish.handlebars | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/public/assets/js/claimPublish.js b/public/assets/js/claimPublish.js index 96952337..6901cbd4 100644 --- a/public/assets/js/claimPublish.js +++ b/public/assets/js/claimPublish.js @@ -27,6 +27,7 @@ function previewAndStageFile(selectedFile){ var preview = document.getElementById('image-preview'); var dropzone = document.getElementById('drop-zone'); var previewReader = new FileReader(); + var nameInput = document.getElementById('publish-name'); preview.style.display = 'block'; dropzone.style.display = 'none'; @@ -36,9 +37,10 @@ function previewAndStageFile(selectedFile){ }; if (selectedFile) { - console.log(selectedFile); previewReader.readAsDataURL(selectedFile); // reads the data and sets the img src - document.getElementById('publish-name').value = selectedFile.name.substring(0, selectedFile.name.indexOf('.')); // updates metadata inputs + if (nameInput.value === "") { + nameInput.value = selectedFile.name.substring(0, selectedFile.name.indexOf('.')); + } stagedFiles = [selectedFile]; // stores the selected file for upload } else { preview.src = ''; diff --git a/views/partials/publish.handlebars b/views/partials/publish.handlebars index 93d050e9..c143d265 100644 --- a/views/partials/publish.handlebars +++ b/views/partials/publish.handlebars @@ -10,7 +10,7 @@
- +


-- 2.45.2 From b48e04f4ac56f7c23e2e131bb05b7c63207bc139 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Fri, 23 Jun 2017 10:06:43 -0700 Subject: [PATCH 2/5] added regex for publish name --- public/assets/js/claimPublish.js | 14 +++++++++++++- views/partials/publish.handlebars | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/public/assets/js/claimPublish.js b/public/assets/js/claimPublish.js index 6901cbd4..ada4ce40 100644 --- a/public/assets/js/claimPublish.js +++ b/public/assets/js/claimPublish.js @@ -86,11 +86,21 @@ function dragend_handler(ev) { /* configure the submit button */ document.getElementById('publish-submit').addEventListener('click', function(event){ event.preventDefault(); + var name = document.getElementById('publish-name').value; + var invalidCharacters = /[^\w,-]/.exec(name); + // validate 'name' + if (invalidCharacters) { + alert(invalidCharacters + ' is not allowed. A-Z, a-z, 0-9, "_" and "-" only.'); + return; + } else if (name.length < 1) { + alert("You must enter a name for your claim"); + return; + } // make sure a file was selected if (stagedFiles) { // make sure only 1 file was selected if (stagedFiles.length > 1) { - alert("Only one file allowed at a time"); + alert("Only one file is allowed at a time"); return; } // make sure the content type is acceptable @@ -105,6 +115,8 @@ document.getElementById('publish-submit').addEventListener('click', function(eve alert("Only .png, .jpeg, .gif, and .mp4 files are currently supported"); break; } + } else { + alert("Please select a file"); } }) diff --git a/views/partials/publish.handlebars b/views/partials/publish.handlebars index c143d265..20f8a9da 100644 --- a/views/partials/publish.handlebars +++ b/views/partials/publish.handlebars @@ -10,7 +10,7 @@

- +


-- 2.45.2 From 6bf5b69800ea7012caf043327f50f39c85b04229 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Fri, 23 Jun 2017 10:26:38 -0700 Subject: [PATCH 3/5] updated package.json --- package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 1b7d43f4..1204d3e9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "name": "spee.ch-backend", + "name": "spee.ch", "version": "0.0.1", - "description": "a back end for spee.ch", + "description": "a single-serving site that reads and publishes images to and from the LBRY blockchain", "main": "server.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", @@ -12,19 +12,19 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/billbitt/spee.ch-backend.git" + "url": "git+https://github.com/lbryio/spee.ch.git" }, "keywords": [ "spee.ch", "lbry", "blockchain" ], - "author": "@billbitt @vxn", + "author": "@billbitt @kauffj @filipnyquist", "license": "MIT", "bugs": { - "url": "https://github.com/billbitt/spee.ch-backend/issues" + "url": "https://github.com/lbryio/spee.ch/issues" }, - "homepage": "https://github.com/billbitt/spee.ch-backend#readme", + "homepage": "https://github.com/lbryio/spee.ch#readme", "dependencies": { "axios": "^0.16.1", "body-parser": "^1.17.1", -- 2.45.2 From 1398a4f957f0445aaa860ecd0c1c1ebb20c7b491 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Fri, 23 Jun 2017 10:47:01 -0700 Subject: [PATCH 4/5] front end validation for meme publish --- public/assets/js/memeDraw.js | 1 - public/assets/js/memePublish.js | 20 +++++++++++++++----- views/partials/memeFodderMaker.handlebars | 6 +++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/public/assets/js/memeDraw.js b/public/assets/js/memeDraw.js index dbfb4f31..9ee0fb0a 100644 --- a/public/assets/js/memeDraw.js +++ b/public/assets/js/memeDraw.js @@ -6,7 +6,6 @@ var fontSize = 28; var topText = document.getElementById('top-text'); var bottomText = document.getElementById('bottom-text'); var ctx = canvas.getContext('2d'); -var claimNameInput = document.getElementById("file-name-input"); // create the canvas img.onload = function() { diff --git a/public/assets/js/memePublish.js b/public/assets/js/memePublish.js index 3fc50965..d830bb85 100644 --- a/public/assets/js/memePublish.js +++ b/public/assets/js/memePublish.js @@ -5,7 +5,7 @@ var uploader = new SocketIOFileUpload(socket); var stagedFiles = null; var license = 'Creative Commons'; var nsfw = false; -var claimName; +var nameInput = document.getElementById("publish-name"); function dataURItoBlob(dataURI) { // convert base64/URLEncoded data component to raw binary data held in a string @@ -31,8 +31,7 @@ function startPublish() { //download the image var dataUrl = canvas.toDataURL('image/jpeg'); // canvas defined in memeDraw.js var blob = dataURItoBlob(dataUrl) - claimName = claimNameInput.value; // claimNameInput.value defined in memeDraw.js - var fileName = claimNameInput.value + ".jpg"; + var fileName = nameInput.value + ".jpg"; //note: need to dynamically grab type var file = new File([blob], fileName, {type: 'image/jpeg', lastModified: Date.now()}); console.log(file); stageAndPublish(file); @@ -59,6 +58,16 @@ function createProgressBar(element, size){ } function stageAndPublish(file) { + var name = nameInput.value; + var invalidCharacters = /[^\w,-]/.exec(name); + // validate 'name' + if (invalidCharacters) { + alert(invalidCharacters + ' is not allowed. A-Z, a-z, 0-9, "_" and "-" only.'); + return; + } else if (name.length < 1) { + alert("You must enter a name for your claim"); + return; + } // stage files stagedFiles = [file]; // stores the selected file for // make sure a file was selected @@ -80,8 +89,9 @@ function stageAndPublish(file) { alert("Only .png, .jpeg, .gif, and .mp4 files are currently supported"); break; } + } else { + alert("Please select a file"); } - } // update the publish status @@ -91,7 +101,7 @@ function updatePublishStatus(msg){ /* socketio-file-upload listeners */ uploader.addEventListener('start', function(event){ - event.file.meta.name = claimName; + event.file.meta.name = nameInput.value; event.file.meta.license = license; event.file.meta.nsfw = nsfw; event.file.meta.type = stagedFiles[0].type; diff --git a/views/partials/memeFodderMaker.handlebars b/views/partials/memeFodderMaker.handlebars index e7a84d30..d9dcfd54 100644 --- a/views/partials/memeFodderMaker.handlebars +++ b/views/partials/memeFodderMaker.handlebars @@ -14,13 +14,13 @@

-
+


-
- +
+

-- 2.45.2 From b5ae816af65c0465140286a2970ce80df6e369b4 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Fri, 23 Jun 2017 10:58:22 -0700 Subject: [PATCH 5/5] fixed typos --- public/assets/js/memePublish.js | 2 +- views/partials/memeFodderMaker.handlebars | 2 +- views/partials/publish.handlebars | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/assets/js/memePublish.js b/public/assets/js/memePublish.js index d830bb85..d0e343b2 100644 --- a/public/assets/js/memePublish.js +++ b/public/assets/js/memePublish.js @@ -90,7 +90,7 @@ function stageAndPublish(file) { break; } } else { - alert("Please select a file"); + alert("Please select a file"); } } diff --git a/views/partials/memeFodderMaker.handlebars b/views/partials/memeFodderMaker.handlebars index d9dcfd54..b556818d 100644 --- a/views/partials/memeFodderMaker.handlebars +++ b/views/partials/memeFodderMaker.handlebars @@ -20,7 +20,7 @@


- +

diff --git a/views/partials/publish.handlebars b/views/partials/publish.handlebars index 20f8a9da..c143d265 100644 --- a/views/partials/publish.handlebars +++ b/views/partials/publish.handlebars @@ -10,7 +10,7 @@

- +


-- 2.45.2