viki and file:// url links

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

viki and file:// url links

Bugzilla from aharrison@gmail.com
Is it possible to make a link to feed to firefox like this:

file:///usr/home/username/docs/filename.html

I've tried a variety of things and I can't get it to talk to even make
any attempt to pass it to the browser whatsoever.  It always prompts
me to create the file:

--> File doesn't exists. Create
'/usr/home/username/Wiki/file:///usr/home/username/docs/filename.html'?
(Y/n)

I've tried constructing links like:

[[file:///usr/home/username/docs/filename.html][filename]]
[[file://usr/home/username/docs/filename.html]]
[[file:/usr/home/username/docs/filename.html]]
[[/usr/home/username/docs/filename.html]]
[[filename.html]]


Nothing works.  Can anyone point me in the right direction please?


my config details:

FreeBSD-4.10-STABLE
vim-6.3.85
multvals.vim 3.10.0
genutils.vim 1.18.3
imaps.vim dated Sun Mar 10 02:00 AM 2002

viki lines from ~/.vimrc:
let g:vikiOpenFileWith_ANY  =  '!firefox -remote "openURL(%{FILE},new-tab)"'
let g:vikiOpenUrlWith_ANY   =  '!firefox -remote "openURL(%{URL},new-tab)"'
let g:vikiOpenUrlWith_html  =  '!firefox -remote "openURL(%{URL},new-tab)"'
let g:vikiOpenFileWith_html =  '!firefox -remote "openURL(%{FILE},new-tab)"'

let g:vikiOpenUrlWith_file  =  '!firefox -remote "openURL(%{URL},new-tab)"'
" also tried with vikiOpenFileWith_file with the %{FILE} variable

let g:deplatePrg            =  "deplate -x -X "
let g:vikiUseParentSuffix   =  1

setlocal sts=3              " set soft tab stop (use same value as tabstop)
setlocal ts=3               " set tabstops to 3 spaces
setlocal sw=3               " set shiftwidth to 3 spaces
setlocal fo=atwcroq2

"
" Remapped some keys to be similar to potwiki
"
map         <buffer> <silent> <Tab>     :VikiFindNext<CR>
map         <buffer> <silent> <BS>      :VikiFindPrev<CR>

nnoremap    <buffer> <silent> <CR>      :call VikiMaybeFollowLink(1,1)<CR>
" also tried VikiMaybeFollowLink(0,1)

nnoremap    <buffer> <silent> <Leader><Leader> :call VikiGoBack()<CR>
nnoremap    <buffer> <silent> <LocalLeader>vq :VikiQuote<CR>

compiler    deplate

Thanx!

--
Andy Harrison
Reply | Threaded
Open this post in threaded view
|

Re: viki and file:// url links

John (Eljay) Love-Jensen
Hi Andy,

This worked for me on my Wiki...

[[file:///Users/eljay/test.txt][file test]]

I'm using TWiki (heavily modified) and Safari 2.0.1 browser.

Note:  I think what you are trying to do is of marginal utility, since you
must be physically on the Wiki server that has the local file reference.

If you try to access that URL on a different machine, assuming the browser
can parse that schema, the browser will try to locate that file LOCALLY, not
off the Wiki server.

HTH,
--Eljay


Reply | Threaded
Open this post in threaded view
|

Re: viki and file:// url links

Steve Hall-4
In reply to this post by Bugzilla from aharrison@gmail.com
From: Andy Harrison, Sep 14, 2005 11:03 AM
>
> Is it possible to make a link to feed to firefox like this:
>
> file:///usr/home/username/docs/filename.html

I can't speak to viki, but I use a variation on the function below to
pass the current file to the default application on both Windows and
in a GNOME environment:

  function! Cream_file_open_defaultapp()
  " Open current file with OS default application.

      " use current file
      let file = expand("%:p")

      " GNOME2
      if       has("gui_gtk2")
          let cmd = 'silent! !gnome-open ' . escape(file, ' ')
      " Windows
      elseif   has("win32")
          \ || has("dos32")
          \ || has("win16")
          \ || has("dos16")
          \ || has("win95")

          " 95/98/ME
          if has("win95")
              let cmd = 'silent! !command /c start "' . file . '"'
          " NT/2K/XP
          else
              let cmd = 'silent! !cmd /c "' . file . '"'
          endif
      else
          " no command found, exit
          call confirm(
              \ "Platform not identified, unable to open file.\n" .
              \ "\n", "&Ok", 1, "Info")
          return
      endif

      silent! execute cmd
      return 1

  endfunction

HTH.

--
Steve Hall  [ digitect mindspring com ]



Reply | Threaded
Open this post in threaded view
|

Re: viki and file:// url links

Bugzilla from aharrison@gmail.com
In reply to this post by John (Eljay) Love-Jensen
On 9/14/05, Eljay Love-Jensen <[hidden email]> wrote:
> Hi Andy,
>
> This worked for me on my Wiki...
>
> [[file:///Users/eljay/test.txt][file test]]
>
> I'm using TWiki (heavily modified) and Safari 2.0.1 browser.

I'm not trying to do it through the browser, I'm trying to get vim to
execute it.

--
Andy Harrison
Reply | Threaded
Open this post in threaded view
|

Re: viki and file:// url links

Charles E Campbell Jr
In reply to this post by Bugzilla from aharrison@gmail.com
Andy Harrison wrote:

>Is it possible to make a link to feed to firefox like this:
>
>file:///usr/home/username/docs/filename.html
>
>I've tried a variety of things and I can't get it to talk to even make
>any attempt to pass it to the browser whatsoever.  It always prompts
>me to create the file:
>
>--> File doesn't exists. Create
>'/usr/home/username/Wiki/file:///usr/home/username/docs/filename.html'?
>(Y/n)
>
>I've tried constructing links like:
>
>[[file:///usr/home/username/docs/filename.html][filename]]
>[[file://usr/home/username/docs/filename.html]]
>[[file:/usr/home/username/docs/filename.html]]
>[[/usr/home/username/docs/filename.html]]
>[[filename.html]]
>
>
>Nothing works.  Can anyone point me in the right direction please?
>...snip
>viki lines from ~/.vimrc:
>let g:vikiOpenFileWith_ANY  =  '!firefox -remote "openURL(%{FILE},new-tab)"'
>let g:vikiOpenUrlWith_ANY   =  '!firefox -remote "openURL(%{URL},new-tab)"'
>let g:vikiOpenUrlWith_html  =  '!firefox -remote "openURL(%{URL},new-tab)"'
>let g:vikiOpenFileWith_html =  '!firefox -remote "openURL(%{FILE},new-tab)"'
>
>let g:vikiOpenUrlWith_file  =  '!firefox -remote "openURL(%{URL},new-tab)"'
>" also tried with vikiOpenFileWith_file with the %{FILE} variable
>  
>

What exactly is it that's being done?   While in vim, does

:!firefox -remote "openURL( any-of-your-file:...-urls),new-tab)"

work?  ie. try to get a simpler command to work before the entire edifice.
Netrw has autocmds for file://* , file://localhost/* , and file:///* style
urls, so I'm wondering if its getting itself involved.

Regards,
Chip Campbell



:!
Reply | Threaded
Open this post in threaded view
|

Re: viki and file:// url links

Thomas-4-2
In reply to this post by Bugzilla from aharrison@gmail.com
In order to open html files with some external program, you have to
add the extension to g:vikiSpecialFiles:

> let g:vikiSpecialFiles = 'jpg\|gif\|bmp\|eps\|png\|jpeg\|wmf\|pdf\|ps\|dvi\|doc\|xls\|html'

Then at least these links should work:

> [[/usr/home/username/docs/filename.html]]
 > [[filename.html]]

I don't quite understand the file not found errors with these links
though. If the file exists, viki should have opened it in vim.

> file:///usr/home/username/docs/filename.html

You have to set the g:vikiSpecialProtocols variable in order to make
this type of URL known to viki:

> let g:vikiSpecialProtocols = 'https\?\|ftps\?\|nntp\|mailto\|mailbox\|file'

Then the above url should be highlighted and "clickable".

The handler for the file protocol currently always tries to open the
file in vim. You have to redefine VikiOpenFileUrl() in order to match
the file name against g:vikiSpecialFiles:

     fun! VikiOpenFileUrl(url) "{{{3
         let vikiSpecialFiles = <SID>GetSpecialFilesSuffixes()
         if a:url =~ '\.\('. vikiSpecialFiles .'\)$' &&
                     \ (g:vikiSpecialFilesExceptions == "" ||
                     \ !(a:url =~ g:vikiSpecialFilesExceptions))
             call VikiOpenSpecialFile(a:url)
         else
             " this is the original function body
             exec <SID>DecodeFileUrl(strpart(a:url, 6))
             if filereadable(filename)
                 call VikiOpenLink(filename, anchor)
             else
                 throw "Viki: Can't find file url: ".filename
             endif
         endif
     endfun

Because of the <SID>, this function (as it is in this example) has to be
modified right in ".vim/plugin/viki.vim".

Hope this helps. Sorry for the inconvenience.

Thomas.

Reply | Threaded
Open this post in threaded view
|

Re: viki and file:// url links

Bugzilla from aharrison@gmail.com
On 9/15/05, Thomas <[hidden email]> wrote:
> In order to open html files with some external program, you
> have to add the extension to g:vikiSpecialFiles:
>
> > let g:vikiSpecialFiles = 'jpg\|gif\|bmp\|eps\|png\|jpeg\|wmf\|pdf\|ps\|dvi\|doc\|xls\|html'

Ok, I added these to my vimrc:

let g:vikiSpecialProtocols = "https\?\|ftps\?\|nntp\|mailto\|mailbox\|file"
let g:vikiSpecialFiles     =
"jpg\|gif\|bmp\|eps\|png\|jpeg\|wmf\|pdf\|ps\|dvi\|html"

> Then at least these links should work:
>
> > [[/usr/home/username/docs/filename.html]]
>  > [[filename.html]]

I should have explained.  Those two links do bring up the
documents in vim, but they don't launch a browser.

> I don't quite understand the file not found errors with these links
> though. If the file exists, viki should have opened it in vim.
>
> > file:///usr/home/username/docs/filename.html

Not this one.  Just the ones without the file url prefix.

> The handler for the file protocol currently always
> tries to open the file in vim. You have to redefine
> VikiOpenFileUrl() in order to match the file name against
> g:vikiSpecialFiles:


I renamed the old function and added the new one as follows:

    " The new way
    fun! VikiOpenFileUrl(url) "{{{3
    let vikiSpecialFiles = <SID>GetSpecialFilesSuffixes()
        if a:url =~ '\.\('. vikiSpecialFiles .'\)$' &&
                \ (g:vikiSpecialFilesExceptions == "" ||
                \ !(a:url =~ g:vikiSpecialFilesExceptions))
           confirm("Matched conditions", "&foo\n&bar\n&baz\n", 2);
           call VikiOpenSpecialFile(a:url)
        else
            " this is the original function body
            confirm("Did Not Match conditions", "&foo\n&bar\n&baz\n", 2);
            exec <SID>DecodeFileUrl(strpart(a:url, 6))
            if filereadable(filename)
                call VikiOpenLink(filename, anchor)
            else
                throw "Viki: Can't find file url: ".filename
            endif
    endfun

I threw in the confirm() commands just to make it pop something up so
I'd know what happened.

Not much change:

* These give the same error about creating the file with the url as the filename
   * [[file:///usr/home/username/Wiki/filename.html][link]]
   * [[file://usr/home/username/Wiki/filename.html]]
   * [[file:/usr/home/username/Wiki/filename.html]]

* These simply open the file.
   * [[/usr/home/username/Wiki/filename.html]]
   * [[filename.html]]

* And this one shows me an error message
   * /usr/local/bin/username/Wiki/filename.html
      * Viki: Show me the way to the next viki name or I have to ...
1:/usr/local/bin/username/Wiki/filename.html

> Hope this helps. Sorry for the inconvenience.

No apologies.  Your work has been anything but an
inconvenience.   :)


Oh, and in answer to drchip's question, yes, I can manually
launch firefox from the vim cli exactly as I have it
configured.

--
Andy Harrison
Reply | Threaded
Open this post in threaded view
|

Re: viki and file:// url links

Manning Aalsma
I've been following this thread since I use Viki heavily as my own personal
wiki/organizer system.  I've set the vikiSpecialFiles variable in my vimrc and
tested a link of the form

[[i:/bookmarks.html]]  # -- saved bookmarks in my USB drive

The file opened up in Firefox as I expect it would.

Then I added the vikiSpecialProtocols variable and the revised function, both
in my vimrc.  However,

file:/i:/bookmarks.html

opened the HTML source right in Vim instead of launching the browser as in the
first case.

Manning


--- Andy Harrison <[hidden email]> wrote:

> On 9/15/05, Thomas <[hidden email]> wrote:
> > In order to open html files with some external program, you
> > have to add the extension to g:vikiSpecialFiles:
> >
> > > let g:vikiSpecialFiles =
> 'jpg\|gif\|bmp\|eps\|png\|jpeg\|wmf\|pdf\|ps\|dvi\|doc\|xls\|html'
>
> Ok, I added these to my vimrc:
>
> let g:vikiSpecialProtocols = "https\?\|ftps\?\|nntp\|mailto\|mailbox\|file"
> let g:vikiSpecialFiles     =
> "jpg\|gif\|bmp\|eps\|png\|jpeg\|wmf\|pdf\|ps\|dvi\|html"
>
> > Then at least these links should work:
> >
> > > [[/usr/home/username/docs/filename.html]]
> >  > [[filename.html]]
>
> I should have explained.  Those two links do bring up the
> documents in vim, but they don't launch a browser.
>
> > I don't quite understand the file not found errors with these links
> > though. If the file exists, viki should have opened it in vim.
> >
> > > file:///usr/home/username/docs/filename.html
>
> Not this one.  Just the ones without the file url prefix.
>
> > The handler for the file protocol currently always
> > tries to open the file in vim. You have to redefine
> > VikiOpenFileUrl() in order to match the file name against
> > g:vikiSpecialFiles:
>
>
> I renamed the old function and added the new one as follows:
>
>     " The new way
>     fun! VikiOpenFileUrl(url) "{{{3
>     let vikiSpecialFiles = <SID>GetSpecialFilesSuffixes()
>         if a:url =~ '\.\('. vikiSpecialFiles .'\)$' &&
>                 \ (g:vikiSpecialFilesExceptions == "" ||
>                 \ !(a:url =~ g:vikiSpecialFilesExceptions))
>            confirm("Matched conditions", "&foo\n&bar\n&baz\n", 2);
>            call VikiOpenSpecialFile(a:url)
>         else
>             " this is the original function body
>             confirm("Did Not Match conditions", "&foo\n&bar\n&baz\n", 2);
>             exec <SID>DecodeFileUrl(strpart(a:url, 6))
>             if filereadable(filename)
>                 call VikiOpenLink(filename, anchor)
>             else
>                 throw "Viki: Can't find file url: ".filename
>             endif
>     endfun
>
> I threw in the confirm() commands just to make it pop something up so
> I'd know what happened.
>
> Not much change:
>
> * These give the same error about creating the file with the url as the
> filename
>    * [[file:///usr/home/username/Wiki/filename.html][link]]
>    * [[file://usr/home/username/Wiki/filename.html]]
>    * [[file:/usr/home/username/Wiki/filename.html]]
>
> * These simply open the file.
>    * [[/usr/home/username/Wiki/filename.html]]
>    * [[filename.html]]
>
> * And this one shows me an error message
>    * /usr/local/bin/username/Wiki/filename.html
>       * Viki: Show me the way to the next viki name or I have to ...
> 1:/usr/local/bin/username/Wiki/filename.html
>
> > Hope this helps. Sorry for the inconvenience.
>
> No apologies.  Your work has been anything but an
> inconvenience.   :)
>
>
> Oh, and in answer to drchip's question, yes, I can manually
> launch firefox from the vim cli exactly as I have it
> configured.
>
> --
> Andy Harrison
>

"Football players are not geniuses. Only guys like Norman Einstein are geniuses." -- Joe Theissman
Reply | Threaded
Open this post in threaded view
|

Re: viki and file:// url links

Thomas-4-2
In reply to this post by Bugzilla from aharrison@gmail.com
> let g:vikiSpecialProtocols = "https\?\|ftps\?\|nntp\|mailto\|mailbox\|file"
> let g:vikiSpecialFiles     =
> "jpg\|gif\|bmp\|eps\|png\|jpeg\|wmf\|pdf\|ps\|dvi\|html"

Ok, I didn't quite realize it at first glance but you probably have to
put these in single quotes. Otherwise the backslashes get lost and the
regular expressions fail. It works here.

Cheers,
Thomas.

       

       
               
___________________________________________________________
Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de