added 'name' field to publish

This commit is contained in:
bill bittner 2017-05-26 00:49:29 -07:00
parent 654c95e7ed
commit 5d87fe7f5e
2 changed files with 29 additions and 20 deletions

View file

@ -23,9 +23,11 @@
<br/> <br/>
<img src="" height="200" alt="Image preview..."/> <img src="" height="200" alt="Image preview..."/>
<br/> <br/>
Name: <input type="text" name="name" value="name"/>
<br/>
Title: <input type="text" name="title" value="title"/> Title: <input type="text" name="title" value="title"/>
<br/> <br/>
Description: <input type="text" name="description" value="description"/> Description: <input type="text" name="description" value="I love spee.ch!"/>
<br/> <br/>
Author: <input type="text" name="author" value="author"/> Author: <input type="text" name="author" value="author"/>
<br/> <br/>
@ -36,9 +38,9 @@
<option value="Public Domain">Public Domain</option> <option value="Public Domain">Public Domain</option>
</select> </select>
<br/> <br/>
NSFW: <select type="text" name="nsfw" value="nsfw"> NSFW: <select type="text" name="nsfw" value="false">
<option value="false">False</option>
<option value="true">True</option> <option value="true">True</option>
<option value="false">False</option>
</select> </select>
<br/> <br/>
<button type="submit">Submit</button> <button type="submit">Submit</button>

View file

@ -6,6 +6,27 @@ var multipartMiddleware = multipart();
var lbryApi = require('../helpers/lbryApi.js'); var lbryApi = require('../helpers/lbryApi.js');
var queueApi = require('../helpers/queueApi.js'); var queueApi = require('../helpers/queueApi.js');
// helper functions
function createPublishObject(req){
var publishObject = {
"method":"publish",
"params": {
"name": req.body.name,
"file_path": req.files.file.path,
"bid": 0.1,
"metadata": {
"description": req.body.description,
"title": req.body.title,
"author": req.body.author,
"language": req.body.language,
"license": req.body.license,
"nsfw": req.body.nsfw
}
}
};
return publishObject;
}
// routes to export // routes to export
module.exports = function(app){ module.exports = function(app){
// route to fetch one free public claim // route to fetch one free public claim
@ -15,25 +36,10 @@ module.exports = function(app){
}); });
// route to publish a new claim // route to publish a new claim
app.post("/publish", multipartMiddleware, function(req, res){ app.post("/publish", multipartMiddleware, function(req, res){
// receive the request
console.log(" >> POST request on /publish"); console.log(" >> POST request on /publish");
// build the data needed to publish the file // build the data needed to publish the file
var publishObject = { var publishObject = createPublishObject(req);
"method":"publish", console.log("publish", publishObject);
"params": {
"name": req.body.title,
"file_path": req.files.file.path,
"bid": 0.1,
"metadata": {
"description": req.body.description,
"title": req.body.title,
"author": req.body.author,
"language": req.body.language,
"license": req.body.license,
"nsfw": req.body.nsfw.value
}
}
};
// post the task to the que // post the task to the que
queueApi.addNewTaskToQueue(JSON.stringify({ queueApi.addNewTaskToQueue(JSON.stringify({
type: 'publish', type: 'publish',
@ -64,6 +70,7 @@ module.exports = function(app){
app.get("/", function(req, res){ app.get("/", function(req, res){
res.sendFile(path.join(__dirname, '../public', 'index.html')); res.sendFile(path.join(__dirname, '../public', 'index.html'));
}); });
// a catch-all route if someone visits a page that does not exist // a catch-all route if someone visits a page that does not exist
app.use("*", function(req, res){ app.use("*", function(req, res){
res.sendFile(path.join(__dirname, '../public', 'fourOhfour.html')); res.sendFile(path.join(__dirname, '../public', 'fourOhfour.html'));