No Linking to External Files in node.js setup?

Visto 218 veces
Saltar al primer mensaje no leído

Jeff Vance

no leída,
15 abr 2017, 21:46:0315/4/17
a TiddlyWiki
I'm experimenting with using node.js setup for the first time.  My personal TW has gotten pretty huge and I was curious to see what using the node.js setup is like.  However, one major problem is I have lots of links to PDF files using file:///path/to/file.  They worked fine before, but under node.js, my browser won't let me click them.  There are no errors or messages or anything.  I just click the link and nothing happens. I tried Firefox and Safari.  In both cases, I have to copy the link and paste it into the address bar to actually go to the file.

Is this a common problem? If there is no way around it, I might ditch the node.js idea altogether. I have tons of PDFs I've indexed this way, so not being able to link to them is a deal breaker.


Mark S.

no leída,
15 abr 2017, 22:10:4115/4/17
a TiddlyWiki
If you have any external images, they will also not show up.

node.js only serves up tiddlers, nothing else. Apparently modern browsers won't let you link to a local file or image from page served up by a server (which is how it views files from node.js). So, if you needed those images or files, you would need to run a separate file server and then change all your addresses to point to that server.

This limitation is one reason why I can't get excited about node.js. I can only assume that people using node.js aren't interested in images and other resources. To me images and supporting files are an important part of any information management system. If I only cared about text I'd probably just concentrate on SimpleNotes or other similar solutions.

Good luck!
Mark

Douglas Counts

no leída,
16 abr 2017, 0:22:1216/4/17
a tiddl...@googlegroups.com
Just a few suggestions as I don't have the time right now to do a deeper look at the problem:

Node.JS can serve up images, video, or anything else you might want.  Whether TiddlyWiki itself though is coded for that, I'm not sure. Normally one simply assigns a route using Express.JS middleware to serve up static files. So there is a way to do this, I have done so on many websites, I just don't have the time at the moment to dig deeper into how/if TiddlyWiki itself is coded for this, but it is possible with Node.JS.

Regarding your links to your PDF files, I used to make this same mistake too.  You need to use relative external links instead.  The link format is a little different from what you may have been doing, but it saves you a lot on typing too.

I used to load PDFs into a browser tab and copy the URL into TiddlyWiki before I realized relative external links were available.

So if you have a subdirectory below where your TiddlyWikis are like:
./TWDataFiles/PDFs

And you have a book located in there like so:
./TWDataFiles/PDFs/Instant TiddlyWiki Development.pdf

Then you can link to it like so:
[ext[Instant TiddlyWiki Development|TWDataFiles/PDFs/Instant TiddlyWiki Development.pdf]]

Notice that you need to not use the conventional  [[title|link]]  but instead use  [ext[title|link]]  instead.

There is actually some good documentation on external links here [Linking in WikiText].

Good luck,

-Doug

Mark S.

no leída,
16 abr 2017, 9:34:3016/4/17
a TiddlyWiki
To clarify,  TiddlyWiki running on node.js doesn't serve up images or other files. There are other applications running on node.js that do serve up images and that is one of the easiest ways to add a server to your set up if you want to go that route.

Thanks,
Mark

Jeff Vance

no leída,
16 abr 2017, 12:09:3316/4/17
a TiddlyWiki
Ok, thanks for the clarification and tips!  I was not using relative external links before (I wasn't aware that was possible).  I'm definitely switching to that way of linking now.  Especially since most of the stuff I link to are in a dropbox folder and I'm running out of storage (for the free service). So I'm probably going to move everything to a different path now.

I'm thinking I might just avoid the node.js setup, however. I liked the idea of it, and if it's a pain to set it up to link to other files, it's not worth it to me.  One benefit I noticed is the node.js version was running faster when I would save changes or delete tiddlers.  My .html version has gotten fairly big and there is now a slight delay (maybe 0.5 seconds) when it saves changes. But the node.js version is instant.  I also sync my TW in dropbox, so I liked the idea of only syncing smaller files with each change, rather than the entire thing. But linking to PDFs is far more important for me.

Jeff Vance

no leída,
16 abr 2017, 12:50:3216/4/17
a TiddlyWiki
Hi Mark:  this is interesting.  Exploring your idea of using another node.js application to serve files, I found this:

https://github.com/indexzero/http-server

I tried it on its own and it works very well, but not sure how to make it play nicely with TiddlyWiki.  Maybe there is some sort of conflict running them together and resolving the host. Starting the file server from the root of the relative path, I could navigate to any file via localhost (when TW is not running).  But when TW server is running, the file paths don't work anymore.

Mark S.

no leída,
16 abr 2017, 14:47:1816/4/17
a TiddlyWiki
Yes, that's the one I tried also.

It appears that you can't run both services on local host. But you can specify your host IP number for each (which is what you want if you want other devices on the network to see your tiddlywiki). But you need to specify a different port number. So maybe 8080 for the TW and 8090 for the images. Just tested and this appears to actually work.

This means you can't use relative paths since you're going to have specify the IP:port for any image or file you're serving up. It's effectively the same as if you were referencing an image on a website somewhere.

Good luck!
Mark
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos