add a navbar button that opens the repo in the desktop's native file browser

This should work on linux (xdg-open) and OSX (open). If the program
is not in $PATH, it falls back to opening a browser window/tab with file:///

The only tricky bit is the javascript code, that handles clicking on the
link. This is to avoid unnecessary page refreshes. Until I added the
return false at the end, the <a>'s normal click event also fired, so two
file browsers opened. I have not checked portability extensively.
This commit is contained in:
Joey Hess 2012-08-03 09:44:43 -04:00
parent 13a7362a1a
commit 1f89712e6b
4 changed files with 41 additions and 2 deletions

View file

@ -63,7 +63,7 @@ selectNavBar :: Handler [NavBarItem]
selectNavBar = ifM (inFirstRun) (return firstRunNavBar, return defaultNavBar)
inFirstRun :: Handler Bool
inFirstRun = isNothing . threadState <$> getYesod
inFirstRun = isNothing . relDir <$> getYesod
{- Used instead of defaultContent; highlights the current page if it's
- on the navbar. -}