This repository has been archived by the owner on Feb 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start #129, create a rough lexicon of commands
- Loading branch information
Showing
7 changed files
with
122 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,53 @@ | ||
const ejs = require("ejs"); | ||
const path = require("path"); | ||
const fs = require("fs"); | ||
const { markdown } = require("markdown"); | ||
const MarkdownIt = require("markdown-it"); | ||
|
||
const markdown = new MarkdownIt({ | ||
html: true, | ||
breaks: true, | ||
typographer: true, | ||
}); | ||
|
||
const CHANGELOG = path.normalize(path.join(__dirname, "../CHANGELOG.md")); | ||
const OUTPUT = path.normalize( | ||
const CHANGELOG_OUTPUT = path.normalize( | ||
path.join(__dirname, "../extension/views/CHANGELOG.html") | ||
); | ||
const TEMPLATE = OUTPUT + ".ejs"; | ||
const CHANGELOG_TEMPLATE = CHANGELOG_OUTPUT + ".ejs"; | ||
const CHANGELOG_TEXT = fs.readFileSync(CHANGELOG, { encoding: "UTF-8" }); | ||
|
||
const context = { content: markdown.toHTML(CHANGELOG_TEXT) }; | ||
const context = { content: markdown.render(CHANGELOG_TEXT) }; | ||
|
||
ejs.renderFile(TEMPLATE, context, {}, function(err, str) { | ||
ejs.renderFile(CHANGELOG_TEMPLATE, context, {}, function(err, str) { | ||
if (err) { | ||
console.error("Error rendering template:", err); | ||
process.exit(1); | ||
return; | ||
} | ||
fs.writeFileSync(OUTPUT, str, { encoding: "UTF-8" }); | ||
console.log(`${OUTPUT} written`); | ||
fs.writeFileSync(CHANGELOG_OUTPUT, str, { encoding: "UTF-8" }); | ||
console.log(`${CHANGELOG_OUTPUT} written`); | ||
}); | ||
|
||
const LEXICON = path.normalize(path.join(__dirname, "../docs/lexicon.md")); | ||
const LEXICON_OUTPUT = path.normalize( | ||
path.join(__dirname, "../extension/views/lexicon.html") | ||
); | ||
const LEXICON_TEMPLATE = LEXICON_OUTPUT + ".ejs"; | ||
const LEXICON_TEXT = fs.readFileSync(LEXICON, { encoding: "UTF-8" }); | ||
|
||
const lexiconContext = { content: markdown.render(LEXICON_TEXT) }; | ||
|
||
ejs.renderFile( | ||
LEXICON_TEMPLATE, | ||
lexiconContext, | ||
{ dialect: "maruku" }, | ||
function(err, str) { | ||
if (err) { | ||
console.error("Error rendering template:", err); | ||
process.exit(1); | ||
return; | ||
} | ||
fs.writeFileSync(LEXICON_OUTPUT, str, { encoding: "UTF-8" }); | ||
console.log(`${LEXICON_OUTPUT} written`); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!-- See the bottom of this page for information on how to update this --> | ||
|
||
# Search the web | ||
|
||
Returns results from the default search engine. | ||
|
||
**Example** | ||
|
||
_Search for hiking in Denver_ | ||
|
||
# Website specific search | ||
|
||
Returns results from search feature on a specific website. | ||
|
||
> **Example** | ||
> | ||
> _Search my Gmail for tickets to Hamilton_ | ||
> _Lookup The Book Of Thief on GoodReads_ | ||
> _Find HTML on MDN_ | ||
> | ||
> **Supported sites:** Gmail, Google Calendar/Docs, MDN, GoodReads, Spotify, Amazon, Wikipedia, Yelp, Twitter, Reddit. | ||
<!-- | ||
Updating this file: | ||
- This is a Markdown file, using Common Mark: https://commonmark.org | ||
- Say "help" to open this file in the browser | ||
- To regenerate the lexicon.html file: `npm run build:markdown` | ||
- You can use `npm run build:markdown` and then reload the page in the extension | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
this.intents.read = (function() { | ||
this.intentRunner.registerIntent({ | ||
name: "self.cancelIntent", | ||
match: ` | ||
cancel | ||
nevermind | ||
never mind | ||
`, | ||
async run(context) { | ||
context.done(0); | ||
}, | ||
}); | ||
|
||
this.intentRunner.registerIntent({ | ||
name: "self.openLexicon", | ||
examples: ["Tell me about Firefox Voice", "Help", "What can I do?"], | ||
match: ` | ||
tell me about (this | firefox voice | this extension | voice) | ||
help | ||
what can I do | ||
`, | ||
async run(context) { | ||
await browser.tabs.create({ | ||
url: browser.runtime.getURL("/views/lexicon.html"), | ||
}); | ||
}, | ||
}); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>Firefox Voice Changes and Updates</title> | ||
<!-- <link rel="stylesheet" href="../css/vendor/tailwind.min.css" /> --> | ||
</head> | ||
<body> | ||
<h1>Firefox Voice Commands</h1> | ||
|
||
<div id="contents"> | ||
<%- content %> | ||
</div> | ||
|
||
<footer> | ||
For more information on Firefox Voice see our | ||
<a href="https://github.com/mozilla/firefox-voice">GitHub repository</a>. | ||
</footer> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters