Skip to content

Commit

Permalink
Merge pull request #8 from timschwab/feature.standard-formatting
Browse files Browse the repository at this point in the history
Add Prettier and git commit hooks
  • Loading branch information
Tim Schwab authored Feb 11, 2019
2 parents 0beddfb + 2418592 commit 3dc145c
Show file tree
Hide file tree
Showing 22 changed files with 3,739 additions and 1,500 deletions.
7 changes: 7 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"useTabs": true,
"singleQuote": true,
"arrowParens": "avoid",
"bracketSpacing": false,
"semi": false
}
30 changes: 19 additions & 11 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ function main() {
const menu = Menu.buildFromTemplate([
{
label: 'File',
submenu: [
{ label: 'Install sheet' },
{ label: 'Remove sheet' }
]
submenu: [{label: 'Install sheet'}, {label: 'Remove sheet'}]
},
{
label: 'View',
Expand All @@ -46,12 +43,24 @@ function main() {
}

// Routes
ipcMain.on('search', (event, query) => { timeLog(event, query, searchHandler.search) })
ipcMain.on('get', (event, id) => { timeLog(event, id, getHandler.get) })
ipcMain.on('add', (event, data) => { timeLog(event, data, addHandler.add) })
ipcMain.on('edit:get', (event, data) => { timeLog(event, data, editHandler.get) })
ipcMain.on('edit:change', (event, data) => { timeLog(event, data, editHandler.change) })
ipcMain.on('delete', (event, id) => { timeLog(event, id, deleteHandler.delete) })
ipcMain.on('search', (event, query) => {
timeLog(event, query, searchHandler.search)
})
ipcMain.on('get', (event, id) => {
timeLog(event, id, getHandler.get)
})
ipcMain.on('add', (event, data) => {
timeLog(event, data, addHandler.add)
})
ipcMain.on('edit:get', (event, data) => {
timeLog(event, data, editHandler.get)
})
ipcMain.on('edit:change', (event, data) => {
timeLog(event, data, editHandler.change)
})
ipcMain.on('delete', (event, id) => {
timeLog(event, id, deleteHandler.delete)
})

// Wrap the handlers in a timer
function timeLog(event, request, fn) {
Expand All @@ -65,4 +74,3 @@ function timeLog(event, request, fn) {

// Start app
app.on('ready', main)

7 changes: 5 additions & 2 deletions client/AddForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Vue.component('add-form', {
if (this.solution) {
return marked(this.solution)
} else {
return "<p>Preview of markdown rendering of the solution</p>"
return '<p>Preview of markdown rendering of the solution</p>'
}
}
},
Expand All @@ -55,7 +55,10 @@ Vue.component('add-form', {
if (!this.problem) {
this.$emit('message', 'You gotta input a problem to add it, bro')
} else if (!this.solution) {
this.$emit('message', 'It isn\'t very helpful to have a problem with no solution, now is it?')
this.$emit(
'message',
"It isn't very helpful to have a problem with no solution, now is it?"
)
} else if (this.keywords.length == 0) {
this.$emit('message', 'Keywords are your friend')
} else {
Expand Down
2 changes: 1 addition & 1 deletion client/AddPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const addForm = require('./AddForm')
let vm

Vue.component('add-page', {
created: function (){
created: function() {
vm = this
},
template: `
Expand Down
15 changes: 4 additions & 11 deletions client/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ document.addEventListener('DOMContentLoaded', () => {
},
computed: {
showSearchPage: function() {
return (this.page == 'search')
return this.page == 'search'
},
showViewPage: function() {
return (this.page.slice(0,5) == 'view:')
return this.page.slice(0, 5) == 'view:'
},
showAddPage: function() {
return (this.page == 'add')
return this.page == 'add'
},
showEditPage: function() {
return (this.page.slice(0,5) == 'edit:')
return this.page.slice(0, 5) == 'edit:'
},
viewingKey: function() {
if (this.showViewPage) {
Expand Down Expand Up @@ -82,10 +82,3 @@ document.addEventListener('DOMContentLoaded', () => {
`
})
})







2 changes: 1 addition & 1 deletion client/EditPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const addForm = require('./AddForm')
let vm

Vue.component('edit-page', {
created: function (){
created: function() {
vm = this
},
props: ['snippetKey'],
Expand Down
1 change: 0 additions & 1 deletion client/MessageDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ Vue.component('message-display', {
})

module.exports = {}

8 changes: 3 additions & 5 deletions client/SearchPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const Vue = require('vue/dist/vue.js')
let vm

Vue.component('search-page', {
created: function (){
created: function() {
vm = this
},
data: function() {
Expand Down Expand Up @@ -49,7 +49,7 @@ ipcRenderer.on('search-result', (event, results) => {
vm.results = results

if (results.length == 0) {
vm.$emit('message', 'Search returned no results :\'(')
vm.$emit('message', "Search returned no results :'(")
} else {
vm.$emit('message', 'Showing ' + results.length + ' results.')
}
Expand All @@ -64,8 +64,6 @@ ipcRenderer.on('delete-result', (event, result) => {
}
})



Vue.component('snippet-preview', {
props: ['snippet'],
template: `
Expand All @@ -82,4 +80,4 @@ Vue.component('snippet-preview', {
}
})

module.exports = {}
module.exports = {}
2 changes: 1 addition & 1 deletion client/ViewPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ ipcRenderer.on('delete-result', (event, result) => {
}
})

module.exports = {}
module.exports = {}
20 changes: 9 additions & 11 deletions client/index.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>CheatSheet</title>

<head>
<meta charset="UTF-8">
<title>CheatSheet</title>

<link rel="stylesheet" type="text/css" href="style.css">
<script src="App.js"></script>
</head>

<body>
<div id="app"></div>
</body>
<link rel="stylesheet" type="text/css" href="style.css" />
<script src="App.js"></script>
</head>

<body>
<div id="app"></div>
</body>
</html>
3 changes: 0 additions & 3 deletions client/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@
#query {
width: 50%;
}



6 changes: 1 addition & 5 deletions data/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"excluded-words": [
"the",
"and",
"it"
],
"excluded-words": ["the", "and", "it"],
"allowed-characters": [
{"character": ",", "allowed": false},
{"character": "-", "allowed": true},
Expand Down
14 changes: 2 additions & 12 deletions data/sheets/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,12 @@
"name": "test",
"sheet": [
{
"keywords": [
"html",
"new",
"tab",
"link"
],
"keywords": ["html", "new", "tab", "link"],
"problem": "How do I have a link open a new tab?",
"solution": "<a href='' target='_blank'></a>"
},
{
"keywords": [
"C#",
"exit",
"terminate",
"stop"
],
"keywords": ["C#", "exit", "terminate", "stop"],
"problem": "How do I stop execution in C#?",
"solution": "Environment.Exit([exit code]);"
}
Expand Down
Loading

0 comments on commit 3dc145c

Please sign in to comment.