Skip to content
This repository was archived by the owner on Dec 11, 2018. It is now read-only.

Commit d082ebc

Browse files
authored
Merge pull request #21 from varemenos/bugfix/json-format
Bugfix/json format
2 parents 75d4664 + 14e327e commit d082ebc

File tree

3 files changed

+33
-27
lines changed

3 files changed

+33
-27
lines changed

README.md

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -49,56 +49,62 @@ apm install tool-bar-almighty
4949

5050
## Options
5151

52-
You have the ability to include [custom entries](https://github.com/varemenos/atom-toolbar-almighty#custom-entries).
53-
You also have the ability to load the [suggested defaults](https://github.com/varemenos/atom-toolbar-almighty#toolbar-entries) along side your custom entries, or only the custom entries.
52+
1. You have the ability to include [custom entries](https://github.com/varemenos/atom-toolbar-almighty#custom-entries).
53+
2. You also have the ability to load the [suggested defaults](https://github.com/varemenos/atom-toolbar-almighty#toolbar-entries) along side your custom entries, or only the custom entries.
5454

5555
## Custom entries
5656

57-
I've added basic support for custom entries in v0.4. To utilize this feature you have to go to the settings of tool-bar-almighty and enter a path relative to your `.atom` directory that contains the entries you want to add. They will be added below the default entries.
57+
You have the ability to include custom entries in the tool-bar-almighty by enabling the option in the package settings and entering a path relative to your `.atom` directory (that contains the entries you want to add).
5858

59-
The file must be a javascript module that exports an Array of entries.
59+
The file must be in JSON format that contains an Array of entries.
6060

6161
### Format
6262

63-
The format is the same as [tool-bar's](https://github.com/suda/tool-bar#example) with 2 extra properties. The first one is `type` which indicates whether the entry is a `button` or a `spacer` while the second one is `dependency` which indicates whether a button's package is not installed by default in Atom and should only be displayed if it's package is installed.
64-
The `lib/entries.coffee` is another example on how to format your entries.
63+
The format is based on [tool-bar's](https://github.com/suda/tool-bar#example) but include 2 extra properties.
64+
65+
1. `type` indicates whether the entry is a `button` or a `spacer`
66+
2. `dependency` indicates whether a button's package is not installed by default in Atom and should only be displayed if it's package is installed.
6567

6668
### Example
6769

68-
* The file's location `~/.atom/custom_entries.js`
69-
* The tool-bar-almighty setting's value must match the filename mentioned above `custom_entries.js`
70+
* Create a file inside `.atom`'s directory, in this case `~/.atom/custom_entries.json`
71+
* The tool-bar-almighty setting's value must match the filename mentioned above `custom_entries.json` (relative to the `.atom` directory)
7072
* The content of the file should look like the following:
7173

72-
```js
73-
module.exports = [
74+
```json
75+
[
76+
{
77+
"type": "button",
78+
"tooltip": "Open File",
79+
"callback": "application:open-file",
80+
"icon": "document-text",
81+
"iconset": "ion"
82+
},
7483
{
75-
type: 'button',
76-
tooltip: 'Open File',
77-
callback: 'application:open-file',
78-
icon: 'document-text',
79-
iconset: 'ion'
84+
"type": "spacer"
8085
},
8186
{
82-
type: 'button',
83-
tooltip: 'Open Folder',
84-
callback: 'application:open-folder',
85-
icon: 'folder',
86-
iconset: 'ion'
87+
"type": "button",
88+
"tooltip": "Open Folder",
89+
"callback": "application:open-folder",
90+
"icon": "folder",
91+
"iconset": "ion"
8792
},
8893
{
89-
type: 'button',
90-
tooltip: 'Merge Conflicts',
91-
dependency: 'merge-conflicts',
92-
callback: 'merge-conflicts:detect',
93-
icon: 'code-fork',
94-
iconset: 'fa'
94+
"type": "button",
95+
"tooltip": "Merge Conflicts",
96+
"dependency": "merge-conflicts",
97+
"callback": "merge-conflicts:detect",
98+
"icon": "code-fork",
99+
"iconset": "fa"
95100
}
96101
]
97102
```
98103

99104
## Known Issues / FAQ
100105

101106
* We've decided to remove the term2/term3 entries from the default entries, for more details and a possible fix read [this](https://github.com/varemenos/atom-toolbar-almighty/issues/9) issue's thread.
107+
* We've decided to only support the JSON format for the custom entries to prevent future formating issues.
102108

103109
## License
104110

lib/utils.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ utils.getCustomEntries = (filepath) ->
99
if filepath
1010
try
1111
thePath = path.join(atom.getConfigDirPath(), filepath)
12-
content = fs.readFileSync(thePath, 'utf8')
12+
content = JSON.parse fs.readFileSync(thePath, 'utf8')
1313
catch error
1414
console.error error
1515
return false

screenshot.png

100755100644
26.2 KB
Loading

0 commit comments

Comments
 (0)