From afb60b9061109d06fa678c730a3b0716d5718777 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Thu, 2 Feb 2017 15:02:32 -0800 Subject: [PATCH 1/2] modification of notices. --- README.md | 11 ++++++++ development/notices.json | 1 - development/states/first-time.json | 2 +- notices/notice-delete.js | 27 ++++++++++++++++++++ {development => notices}/notice-generator.js | 10 ++++---- notices/notices.json | 1 + package.json | 3 ++- 7 files changed, 47 insertions(+), 8 deletions(-) delete mode 100644 development/notices.json create mode 100644 notices/notice-delete.js rename {development => notices}/notice-generator.js (65%) create mode 100644 notices/notices.json diff --git a/README.md b/README.md index 3a7277f3f..aa79f4564 100644 --- a/README.md +++ b/README.md @@ -153,3 +153,14 @@ gource \ --output-framerate 30 \ | ffmpeg -y -r 30 -f image2pipe -vcodec ppm -i - -b 65536K metamask-dev-history.mp4 ``` + +## Generating Notices + +To add a notice: +``` +npm run generateNotice +``` +To delete a notice: +``` +npm run deleteNotice +``` diff --git a/development/notices.json b/development/notices.json deleted file mode 100644 index ffe67097a..000000000 --- a/development/notices.json +++ /dev/null @@ -1 +0,0 @@ -[{"read":false,"date":"Fri Dec 16 2016","title":"Ending Morden Support","body":"Due to [recent events](https://blog.ethereum.org/2016/11/20/from-morden-to-ropsten/), MetaMask is now deprecating support for the Morden Test Network.\n\nUsers will still be able to access Morden through a locally hosted node, but we will no longer be providing hosted access to this network through [Infura](http://infura.io/).\n\nPlease use the new Ropsten Network as your new default test network.\n\nYou can fund your Ropsten account using the buy button on your account page.\n\nBest wishes!\nThe MetaMask Team\n\n","id":0}] diff --git a/development/states/first-time.json b/development/states/first-time.json index d6d95fe06..598adc4cb 100644 --- a/development/states/first-time.json +++ b/development/states/first-time.json @@ -11,7 +11,7 @@ "network": null, "accounts": {}, "transactions": [], - "isDisclaimerConfirmed": true, + "isDisclaimerConfirmed": false, "unconfMsgs": {}, "messages": [], "shapeShiftTxList": [], diff --git a/notices/notice-delete.js b/notices/notice-delete.js new file mode 100644 index 000000000..652f96159 --- /dev/null +++ b/notices/notice-delete.js @@ -0,0 +1,27 @@ +var fs = require('fs') +var path = require('path') +var prompt = require('prompt') +var open = require('open') +var extend = require('extend') +var notices = require('./notices.json') + + +console.log('List of Notices') +console.log(`ID \t DATE \t\t\t TITLE`) +notices.forEach((notice) => { + console.log(`${(' ' + notice.id).slice(-2)} \t ${notice.date} \t ${notice.title}`) +}) +prompt.get(['id'], (error, res) => { +prompt.start() + if (error) { + console.log("Exiting...") + process.exit() + } + var index = notices.findIndex((notice) => { return notice.id == res.id}) + if (index === -1) { + console.log('Notice not found. Exiting...') + } + notices.splice(index, 1) + fs.unlink(`notices/archive/notice_${res.id}.md`) + fs.writeFile(`notices/notices.json`, JSON.stringify(notices)) +}) diff --git a/development/notice-generator.js b/notices/notice-generator.js similarity index 65% rename from development/notice-generator.js rename to notices/notice-generator.js index 08b0c9843..a691bca15 100644 --- a/development/notice-generator.js +++ b/notices/notice-generator.js @@ -13,23 +13,23 @@ var notice = { date: date, } -fsp.readdir('notices') +fsp.readdir('notices/archive') .then((files) => { files.forEach(file => { id ++ }) Promise.resolve() }).then(() => { - fsp.writeFile(`notices/notice_${id}.md`,'Message goes here. Please write out your notice and save before proceeding at the command line.') + fsp.writeFile(`notices/archive/notice_${id}.md`,'Message goes here. Please write out your notice and save before proceeding at the command line.') .then(() => { - open(`notices/notice_${id}.md`) + open(`notices/archive/notice_${id}.md`) prompt.start() prompt.get(['title'], (err, result) => { notice.title = result.title - fsp.readFile(`notices/notice_${id}.md`) + fsp.readFile(`notices/archive/notice_${id}.md`) .then((body) => { notice.body = body.toString() notice.id = id notices.push(notice) - return fsp.writeFile(`development/notices.json`, JSON.stringify(notices)) + return fsp.writeFile(`notices/notices.json`, JSON.stringify(notices)) }) }) }) diff --git a/notices/notices.json b/notices/notices.json new file mode 100644 index 000000000..0637a088a --- /dev/null +++ b/notices/notices.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/package.json b/package.json index 770318214..ecf906684 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "testem": "npm run buildMock && testem", "ci": "npm run buildMock && npm run buildCiUnits && testem ci -P 2", "announce": "node development/announcer.js", - "generateNotice": "node development/notice-generator.js" + "generateNotice": "node notices/notice-generator.js", + "deleteNotice": "node notices/notice-delete.js" }, "browserify": { "transform": [ From 88882f547ea2935bd0810710ed2f8f035fc9fef7 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Thu, 2 Feb 2017 15:59:39 -0800 Subject: [PATCH 2/2] Change filepath for new location of notices. --- app/scripts/notice-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/scripts/notice-controller.js b/app/scripts/notice-controller.js index 00c87c670..c3777b4b1 100644 --- a/app/scripts/notice-controller.js +++ b/app/scripts/notice-controller.js @@ -1,5 +1,5 @@ const EventEmitter = require('events').EventEmitter -const hardCodedNotices = require('../../development/notices.json') +const hardCodedNotices = require('../../notices/notices.json') module.exports = class NoticeController extends EventEmitter {