diff --git a/package.json b/package.json index a6e12fa..3c57f9b 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "server.js", "scripts": { "start": "node server.js", - "devser": "nodemon server.js", + "dev": "nodemon server.js", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { diff --git a/resources/TOS.md b/resources/TOS.md new file mode 100644 index 0000000..9f6a925 --- /dev/null +++ b/resources/TOS.md @@ -0,0 +1,41 @@ +# NoteHub Terms of Service + +### 1. Terms + + By accessing the web site at https://notehub.org, you are agreeing to be bound by these web site Terms and Conditions of Use, all applicable laws and regulations, and agree that you are responsible for compliance with any applicable local laws. If you do not agree with any of these terms, you are prohibited from using or accessing this site. The materials contained in this web site are protected by applicable copyright and trademark law. + +### 2. Use License + +a. Under this license you may not: + - i. attempt to __modify, manipulate__ or __extend__ any software contained on NoteHub's web site; + - ii. create _any_ kind of law prohibited content; + +b. This license shall automatically terminate if you violate any of these restrictions and may be terminated by NoteHub at any time. Upon terminating your viewing of these materials or upon the termination of this license, you must destroy any downloaded materials in your possession whether in electronic or printed format. + + +### 3. Disclaimer + +a. The materials on NoteHub's web site are provided "as is". NoteHub makes no warranties, expressed or implied, and hereby disclaims and negates all other warranties, including without limitation, implied warranties or conditions of merchantability, fitness for a particular purpose, or non-infringement of intellectual property or other violation of rights. Further, NoteHub does not warrant or make any representations concerning the accuracy, likely results, or reliability of the use of the materials on its Internet web site or otherwise relating to such materials or on any sites linked to this site. + +### 4. Limitations + +In no event shall NoteHub or its suppliers be liable for any damages (including, without limitation, damages for loss of data or profit, or due to business interruption,) arising out of the use or inability to use the materials on NoteHub's Internet site, even if NoteHub or a NoteHub authorized representative has been notified orally or in writing of the possibility of such damage. Because some jurisdictions do not allow limitations on implied warranties, or limitations of liability for consequential or incidental damages, these limitations may not apply to you. + +### 5. Revisions and Errata + +The materials appearing on NoteHub's web site could include technical, typographical, or photographic errors. NoteHub does not warrant that any of the materials on its web site are accurate, complete, or current. NoteHub may make changes to the materials contained on its web site at any time without notice. NoteHub does not, however, make any commitment to update the materials. + +### 6. Links + +NoteHub has not reviewed all of the sites linked to its Internet web site and is not responsible for the contents of any such linked site. The inclusion of any link does not imply endorsement by NoteHub of the site. Use of any such linked web site is at the user's own risk. + +### 7. Site Terms of Use Modifications + +NoteHub may revise these terms of use for its web site at any time without notice. By using this web site you are agreeing to be bound by the then current version of these Terms and Conditions of Use. + +### 8. Governing Law + +Any claim relating to NoteHub's web site shall be governed by the laws of Germany without regard to its conflict of law provisions. + +General Terms and Conditions applicable to Use of a Web Site. + diff --git a/resources/edit.html b/resources/edit.html index d4d7050..1d5f65a 100644 --- a/resources/edit.html +++ b/resources/edit.html @@ -14,7 +14,7 @@
-
+ @@ -23,7 +23,11 @@
  - + + 0 words diff --git a/resources/public/js/publishing.js b/resources/public/js/publishing.js index df0bddb..56c6e90 100644 --- a/resources/public/js/publishing.js +++ b/resources/public/js/publishing.js @@ -18,6 +18,12 @@ function saveDraft() { localStorage.setItem("draft", $note.value); } +function enableButton() { + var checkbox = $('tos'); + var button = $('publish-button'); + button.disabled = !checkbox.checked; +} + function onLoad() { $note = $("note"); $action = $("action").value; diff --git a/server.js b/server.js index 51b29ae..389c012 100644 --- a/server.js +++ b/server.js @@ -38,6 +38,10 @@ var log = function() { console.log.apply(console, message); } +app.get('/TOS', function(req, res) { + res.send(view.renderTOS()); +}); + app.get('/new', function(req, res) { log(req.ip, "opens /new"); res.send(view.newNotePage(getTimeStamp() + md5(Math.random()))); @@ -52,6 +56,8 @@ app.post('/note', function(req, res) { id = body.id; log(req.ip, "calls /note to", action, id); var goToNote = note => res.redirect("/" + note.id); + if (!note) + return sendResponse(res, 400, "Bad request"); if (session.indexOf(getTimeStamp()) != 0) return sendResponse(res, 400, "Session expired"); var expectedSignature = md5(session + note.replace(/[\n\r]/g, "")); diff --git a/src/view.js b/src/view.js index 87a9337..b288110 100644 --- a/src/view.js +++ b/src/view.js @@ -1,6 +1,7 @@ var marked = require("marked"); var fs = require("fs"); +var TOS = fs.readFileSync("resources/TOS.md", "utf-8"); var pageTemplate = fs.readFileSync("resources/template.html", "utf-8"); var footerTemplate = fs.readFileSync("resources/footer.html", "utf-8"); var editTemplate = fs.readFileSync("resources/edit.html", "utf-8"); @@ -15,7 +16,7 @@ var renderPage = (id, title, content, footer) => pageTemplate .replace("%MISUSE%", misuses.has(id) ? misuseScript : "") .replace("%TITLE%", title) .replace("%CONTENT%", content.replace(//gi, "").replace(//gi, "")) - .replace("%FOOTER%", footer); + .replace("%FOOTER%", footer || ""); module.exports.renderPage = renderPage; @@ -25,8 +26,10 @@ module.exports.renderStats = note => renderPage(note.id, deriveTitle(note.text), Published${note.published} Edited${note.edited || "N/A"} Views${note.views} - `, - ""); + `); + +module.exports.renderTOS = () => + renderPage("tos", "Terms of Service", marked(TOS)); module.exports.renderNote = note => renderPage(note.id, deriveTitle(note.text), marked(note.text),