Skip to content

Commit

Permalink
polish
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuellr committed Jul 22, 2015
1 parent 9e0cbe9 commit a2fcc72
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 10 deletions.
52 changes: 47 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ plugins
In order to have a custom HTML renderer for a particular file extension, you'll
need to install a plugin. A plugin is an node package installed in a particular
location. That location is the directory named `plugins` in the AnyViewer data
directory. The AnyViewer data directory is located at:

* Mac OS X - `~/Library/Application Support/AnyViewer`
directory. The AnyViewer data directory in your home directory, named
`.AnyViewer`, and stores other preference-y data.

Each plugin should be in a separate directory, in the same vein as node's
`node_modules` directory. The `package.json` file for each package should have
Expand Down Expand Up @@ -56,13 +55,55 @@ properties:
as `err` on success, else an Error object.

The path set in `vinylOut` is a temporary file name, which you can use
to generate HTML. The file will be erased when the viewer window
to generate HTML into. The file will be erased when the viewer window
closes.

* `extensions`: an array of strings of extensions supported by this plugin.
Expected to include the `"."` character at the beginning of each string,
like [vinyl's extname property](https://www.npmjs.com/package/vinyl#extname).


sample plugin
--------------------------------------------------------------------------------

By default, AnyViewer can view `.html` with syntax highlighting. This sample
plugin views `.html` file as the rendered HTML. It's not terribly practical -
this plugin does not fix relatively referenced resources (images, css files,
etc), so those files won't be loaded when the HTML is rendered in Anyviewer.
But, it's a simple example.

These files should be stored in the directory `.AnyViewer/plugins/avpi-html`
in your home directory.

### file `package.json`

```json
{
"name": "avpi-html",
"description": "AnyViewer plugin for HTML",
"AnyViewer": {
"plugin": "./plugin"
}
}
```

### file `plugin.js`

```js
const fs = require("fs")

exports.toHTML = toHTML
exports.extensions = [".html"]

function toHTML(iVinyl, oVinyl, cb) {
const content = fs.readFileSync(iVinyl.path, "utf8")
fs.writeFileSync(oVinyl.path, content)

cb()
}
```


AnyViewer features
--------------------------------------------------------------------------------

Expand All @@ -78,6 +119,8 @@ AnyViewer features
* A file which is being viewed is tracked for changes; when the file changes
on disk, the view will be reloaded with the new contents.

* Print files with background colors and images, with a font-size that
renders the text fairly readable on a tablet when printed to PDF file.

install
--------------------------------------------------------------------------------
Expand All @@ -103,7 +146,6 @@ to make it easier to test a development version while you have a stable version
installed at the same time, on your boxen.



hacking
--------------------------------------------------------------------------------

Expand Down
2 changes: 0 additions & 2 deletions app/main/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ const mkdirp = require("mkdirp")

const PrefsFileName = getPrefsFileName("preferences.json")

console.log("PrefsFileName: " + PrefsFileName)

//------------------------------------------------------------------------------
exports.create = create
exports.getPrefsBasePath = getPrefsBasePath
Expand Down
2 changes: 0 additions & 2 deletions app/main/viewers.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ class Viewer {
const oVinyl = new Vinyl({path: this.htmlFileName})
const prefs = this.prefs

// app.addRecentDocument(this.fullFileName)

try {
plugins.renderHTML(iVinyl, oVinyl, prefs, next)
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"babel": "5.6.x",
"cakex": "0.1.x",
"coffee-script": "1.9.x",
"electron-prebuilt": "0.28.x",
"electron-prebuilt": "0.30.x",
"eslint": "0.24.x",
"plist": "1.1.x"
}
Expand Down

0 comments on commit a2fcc72

Please sign in to comment.