Skip to content

Commit

Permalink
lots of small tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuellr committed Jul 17, 2015
1 parent 15ccdf6 commit 9092017
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 22 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ AnyViewer features

* You can open a Chrome Dev Tools window via menu and shortcut.

* There are no forward/backward buttons available for history traversal,
but there are menu items and shortcuts for those functions.

* 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.

Expand Down
4 changes: 2 additions & 2 deletions app/main/menu-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ function getTemplate() {
{
label: "View",
submenu: [
{ label: "Back", accelerator: "Command+[", on_click: "onGoBack" },
{ label: "Forward", accelerator: "Command+]", on_click: "onGoForward" },
// { label: "Back", accelerator: "Command+[", on_click: "onGoBack" },
// { label: "Forward", accelerator: "Command+]", on_click: "onGoForward" },
{ label: "Reload", accelerator: "Command+R", on_click: "onReload" },
{ label: "Enter Fullscreen", on_click: "onEnterFullscreen" },
{ label: "Actual Size", accelerator: "Command+0", on_click: "onZoomActualSize" },
Expand Down
29 changes: 22 additions & 7 deletions app/main/viewers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@

"use strict"

const fs = require("fs")
const path = require("path")
const fs = require("fs")
const URL = require("url")
const path = require("path")

const shell = require("shell")
const BrowserWindow = require("browser-window")

const Vinyl = require("vinyl")
const tempfile = require("tempfile")
const BrowserWindow = require("browser-window")
const throttleDebounce = require("throttle-debounce")

const pkg = require("../package.json")
const menus = require("./menus")
const utils = require("./utils")
const plugins = require("./plugins")
const pkg = require("../package.json")
const menus = require("./menus")
const utils = require("./utils")
const plugins = require("./plugins")

//------------------------------------------------------------------------------
exports.createViewer = createViewer
Expand Down Expand Up @@ -186,6 +189,18 @@ class Viewer {

//----------------------------------------------------------------------------
didFinishLoad() {
this.browserWindow.webContents.on("will-navigate", function(e, url) {
e.preventDefault()

const urlp = URL.parse(url)

if ((urlp.protocol == "http:") || (urlp.protocol == "https:")) {
shell.openExternal(url)
}
else if (urlp.protocol == "file:") {
shell.openItem(urlp.path)
}
})
}

//----------------------------------------------------------------------------
Expand Down
17 changes: 14 additions & 3 deletions app/plugins/avpi-source-code/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,26 @@ function toHTML(iVinyl, oVinyl, cb) {
// console.log(" extName: ", extName)

const output = []
output.push("<link rel='stylesheet' href='" + AppDir + "/app/node_modules/highlight.js/styles/github.css'>")
const style = "monokai"
output.push("<!doctype html>")
output.push("<html>")
output.push("<head>")
output.push("<link rel='stylesheet' href='" + AppDir + "/app/node_modules/highlight.js/styles/" + style + ".css'>")
output.push("<style>")
output.push("body, pre, xmp, tt, code {")
output.push(" font-family: Source Code Pro, Menlo, Monaco, Courier")
output.push(" font-family: Source Code Pro, Menlo, Monaco, Courier, monospace;")
output.push("}")
output.push("pre {")
output.push(" margin: 0em;")
output.push("}")
output.push("</style>")
output.push("</head>")
output.push("<body class=hljs>")
output.push("<pre>")
output.push(highlight.highlight(extName, source, true).value)
output.push("</pre>")
output.push("</body>")
output.push("</html>")

fs.writeFileSync(oVinyl.path, output.join("\n"))
cb(null)
Expand Down Expand Up @@ -60,7 +71,7 @@ function escapeHTML(source) {
function initExtensions() {
const result = []
const languages = highlight.listLanguages()
const skipExtensions = new Set("md markdown html".split(" "))
const skipExtensions = new Set("md markdown".split(" "))

for (let language of languages) {
if (skipExtensions.has(language)) continue
Expand Down
7 changes: 0 additions & 7 deletions app/renderer/modules/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

"use strict"

const shell = require("shell")
const webFrame = require("web-frame")

window.AnyViewer = {}
window.AnyViewer.reload = reload
window.AnyViewer.openLink = openLink
window.AnyViewer.setZoomFactor = setZoomFactor

//------------------------------------------------------------------------------
Expand All @@ -24,11 +22,6 @@ function reload(newContent) {
window.scroll(x, y)
}

//------------------------------------------------------------------------------
function openLink(href) {
shell.openExternal(href)
}

//------------------------------------------------------------------------------
function setZoomFactor(zoomFactor) {
webFrame.setZoomFactor(zoomFactor)
Expand Down

0 comments on commit 9092017

Please sign in to comment.