Incorrect address handling when opening a local PDF

321 views
Skip to first unread message

Daniel Caleb

unread,
Oct 12, 2014, 3:03:20 PM10/12/14
to tiddl...@googlegroups.com
Hello!

I am trying to create an external link to a PDF file on my local drive in Tiddlywiki 5, running Ubuntu and FF 33... I've experimented with two different methods of linking:

<a href="/opt/sync/wiki/pdf/CumalaTechnicalInfo.pdf" target="_blank">Cumala Technical Info</a>

[ext[Cumala Technical Info|/opt/sync/wiki/pdf/CumalaTechnicalInfo.pdf]]

I have tried using the file:/// URI specification and that produces links that do nothing. The above examples open a new tab, which is fine - however it produces this URL:

http://127.0.0.1:4444/opt/sync/wiki/tiddlers/CumalaTechnicalInfo.pdf

If I remove the http://127.0.0.1:4444 portion - the file opens as it is supposed to...

Has anyone run into this before? Could this be related to the way in which tiddlywiki server is launched? I launch with:

cd /opt/sync/wiki/
/usr/local/bin/tiddlywiki  --server 4444 &

Pretty straightforward... or so it seems.

On a side note... Thanks for the hard work put into this - I just discovered Tiddlywiki and it is EPIC! Many thanks!

Regards,
Daniel

Stephan Hradek

unread,
Oct 12, 2014, 3:39:25 PM10/12/14
to tiddl...@googlegroups.com
file:/// should work. /opt will not work unless your "opt" is located below the document root of your server.

Example: If your files is located in /path/to/document/root/opt/sync/wiki/pdf/CumalaTechnicalInfo.pdf
then /opt/sync/wiki/pdf/CumalaTechnicalInfo.pdf should work.

Daniel Caleb

unread,
Oct 12, 2014, 4:13:21 PM10/12/14
to tiddl...@googlegroups.com
The root directory containing my "tiddlers" is: /opt/sync/wiki/tiddlers/

/opt/sync/wiki is the root of the tiddlywiki server - hence everything I'm attempting to reference should be relative to the tiddlywiki server root.

I've also tried:

<a href="./pdf/CumalaTechnicalInfo.pdf" target="_blank">Cumala Technical Info</a>

with a similar result, the URL produced is:

http://127.0.0.1:4444/pdf/CumalaTechnicalInfo.pdf

Using file:/// doesn't work at all - it creates the link as expected, but clicking on the link does nothing... even right-clicking and attempting to force a new tab produces no response.

Thanks for the response...
Daniel

Stephan Hradek

unread,
Oct 12, 2014, 4:14:36 PM10/12/14
to tiddl...@googlegroups.com
On second thoufght: I think the nod.js version is not configured to serve files. Maybe it's possible to add a new route to allow that?

Stephan Hradek

unread,
Oct 12, 2014, 11:14:30 PM10/12/14
to tiddl...@googlegroups.com


Am Sonntag, 12. Oktober 2014 22:13:21 UTC+2 schrieb Daniel Caleb:
The root directory containing my "tiddlers" is: /opt/sync/wiki/tiddlers/

/opt/sync/wiki is the root of the tiddlywiki server - hence everything I'm attempting to reference should be relative to the tiddlywiki server root.

Yes - but you need to leave the root out, so
 
I've also tried:

<a href="./pdf/CumalaTechnicalInfo.pdf" target="_blank">Cumala Technical Info</a>
 

with a similar result, the URL produced is:

http://127.0.0.1:4444/pdf/CumalaTechnicalInfo.pdf

That URL is correct. But as said before: The server is, I think, not configured to serve files. So you need to reconfigure it. Don't ask me how or whether it's possible at all.
 
Using file:/// doesn't work at all - it creates the link as expected, but clicking on the link does nothing... even right-clicking and attempting to force a new tab produces no response.

Can you show the resulting source?

Does that source work when you create a static HTML containing the same source?


Daniel Caleb

unread,
Oct 13, 2014, 6:07:35 AM10/13/14
to tiddl...@googlegroups.com
Thanks for your reply... Generating a static page while using the file:/// URI works properly. Which leads me to believe that you are correct; node.js needs to be configured for serving static content.

I was under the impression that others on the mailing list had gotten the syntax:

<a href="./pdf/CumalaTechnicalInfo.pdf" target="_blank">Cumala Technical Info</a>

to work properly; as in [1] and [2]. If that's the case, then this is a problem with my configuration specifically. I've not explored node.js very much... I installed it via the package manager in Ubuntu and tiddlywiki via npm -g as the ReadMe suggests. Are there any dependencies that TW5 might be missing? Any help or direction on this subject would be greatly appreciated...

Thanks again,
Daniel

[1] https://groups.google.com/d/topic/tiddlywiki/EmJFLV1XAD0/discussion

[2] https://groups.google.com/d/topic/tiddlywiki/u0pcaOIOdA4/discussion

Daniel Caleb

unread,
Oct 15, 2014, 11:13:38 AM10/15/14
to tiddl...@googlegroups.com
In case anyone comes across this thread, experiencing the same issues I had... I thought it would be helpful to post my solution. After a bit more research I came to the understanding that Tiddlywiki doesn't have the ability to serve local files. This is a feature that is somewhat overlooked since it is, normally, handled by an internet facing web server. However, in my use case - deployed on my laptop - I had no need of a web server.

I ended up installing Nginx... which is light with a small footprint. After installing, I created a simple config file to utilize tiddlywiki through a proxy and define a file root for my pdfs and images:

/etc/nginx/sites-enabled/tiddlywiki.conf:

server {
    listen           80;
    server_name      localhost;
    # vhost specific logs
    access_log       /var/log/nginx/tiddlywiki.access.log combined;
    location / {
        proxy_pass   http://127.0.0.1:4444;
        proxy_set_header        Host             $host;
        proxy_set_header        X-Real-IP        $remote_addr;
        proxy_set_header        X-Forwarded-For  $proxy_add_x_forwarded_for;
    }
    location /pdf/ {
        root /opt/sync/wiki/;
    }
    location /images/ {
        root /opt/sync/wiki/;
    }
}

Now, the common tags:

<a href="/pdf/CumalaTechnicalInfo.pdf" target="_blank">Cumala Technical Info</a>

[ext[Cumala Technical Info|/pdf/CumalaTechnicalInfo.pdf]]

Work as expected...

Hopefully this helps someone else...
Daniel
Reply all
Reply to author
Forward
0 new messages