URI Question and can we use space to split into link/pretty link?

Folks,

If we drag and drop a uri/url link from a browser address bar into a drop zone, it will have the “title” in the following form;
[[https://plugins.tiddlyhost.com/ Plugins - for TiddlyWiki — Support on and libraries]]

Can we now find away to split this reliably?, as follows is not perfect?

{{{ [[https://plugins.tiddlyhost.com/ Plugins - for TiddlyWiki — Support on and libraries]split[ ]first[]] }}}
{{{ [[https://plugins.tiddlyhost.com/ Plugins - for TiddlyWiki — Support on and libraries]split[ ]bufirst[]join[ ]] }}}
  • I want to find a reliable method to do this so I can continue to store url/pretty links in this form?

I don’t think that there is one way to handle the drag and drop feature.

To fulfil my private wishes it would be noice to have a drag and drop feature for the canonical_uri field. :wink:

Can you specify a little more what you want with the canonical field. From where to where?

There I am mostly after how to parse that format of libk

For security reasons, regular browsers do not expose the path to the dragged file, which makes it impossible to construct a _canonical_uri tiddler.

The “External Attachments” plugin from the official plugin library does what you want but it requires the use of TiddlyDesktop instead of a regular browser.

Hi @TW_Tones ,

my use case is really very special, I think.
Ok, let me describe what I am doing here.
I am member of a boyscott group and we have collected tons ons songs with lyrics and notes from the past. Of course all of them on paper. We scanned them and still collecting and scanning, so this is an ongoing process.
We decided to use tiddlywiki as songbook due to the fact that it is lean if we use it in this way as I describe it here.

  1. We have one folder named “songbook” and there is only the tiddlywiki saved
  2. We have several subfolders with the pdf files in this songbook folder
  3. For each song we create a tiddler with the name of the song
    3a. Some tags or fields will be added if we know who wrote the text and who made the melody, but this is optional. Also we add tags or fields if the song has a special character like “sea shanties”.
  4. We add the path and filename as canonical_uri e.g. ./subfolder1./Blue mountains.pdf

Why we do that in this way? The community is big, really big. :slight_smile:
In the past when we sit around the campfire and sing we used paper songbooks. If some of use don’t have the song available it was difficult and change them out.
We are in the 21st century now. Most of us have a tablet instead of paper songbook.
We don’t have always a internet available therefore we want to have a local working solution.
In the case that someone has a song in the songbook but some of us not we can easily export the tiddler and pdf and all of us are able to import the song to their own songbook. And sometimes we have meetings only to exchange the songs to each other.

Everything what will help us not to copy the filename and path from the explorer (or finder in case of using an apple device) and to paste it in the canonical_uri field and to have may be automatically the Tiddler named with the filename, will make the life easier.

Finally, why we do not import the pdfs directly? Simple we speak about hundreds of pdfs. The tiddlywiki songbook will be too big to use on a tablet or smartphone.

So, that is the use case. A little bit longer but helpfully to understand my super special private wish. And I understand that not always and everything can be realised. We are happy to have this tool.

Stefan

@stefan_from_germany

Take a look at these links for bulk import of local images. I guess something similar can be done for PDFs.

https://kookma.github.io/TW-Scripts/#Create%20External%20Images%20from%20A%20Directory

You can even use tiddlyclip for this purpose similar to bulk image import as seen in this discussion - Bulk import local images · buggyj/tiddlyclip-plugin · Discussion #120 · GitHub

In this sort of use, I think I would try to work in 2 times.
First you create a xls or csv file to create the database of your local files. You can there create as many columns as field you would like to insert in your tiddlers.
There is tools to bulk import the local links from a directory (for example : LibreOffice Calc 6 - "batch" hyperlink to files in folder? - English - Ask LibreOffice)
Then when the xls/csv file is ready use, install the XLSX Utils: XLSX spreadsheet utilities plugin from the TW official plugin library to import an create in the same time --ALL the tiddlers-- at once !

It needs a little bit of understanding of those tools, but you will gain a lot of time instead of manually modify your tiddlers. And the XLS file cans be used to easily modify fields by copy/paste and then push those modifications back to you wiki at any time…

1 Like

I am interested in everyone else’s journey, but we have strayed from the Original Topic I raise for a specific reason.

Can we parse a URL with it’s pretty link in the same title or field? and reliably separate the link from the text based pretty link?

I believe urls must not contain a space so this should be possible, but I am not sure, there are a lot of ways to craft a url.

why does using split[ ]first[] not work? URLs are not allowed to have spaces (see ietf.org/rfc/rfc3986.txt Appendix A for URI syntax) and so would need to be encoded. if an external link always imports with the URL first, then that should work?

1 Like

@arunnbabu81

Thank you for your answer but my problem is not the bulk import.
It is more the effort to copy the path and filename and to paste it in the canonical_uri field to the tiddler and to paste it also in the title.

But thank for the idea
Stefan

Stephan. I started this topic and you are taking it off topic

If I encode the whole string, spaces become %20 how do I split the pretty text off? Like tiddler or ? Search strings in the url?

Is the only problem the typo? It’s “butfirst”, not “bufirst”? With that, it seems reliable in some minimal tests I tried.

I was wondering in general and detail. It looks l like l need to ask a LLM or read a RFC.

Thanks all anyway.

have you tried debug-log filter? that will help you find after which step the output become empty.

Introducing the debug-log[] filter

What is not perfect about split[ ]first[]? Do you have a failing test case? As @Scribs said, the url part should not have spaces. I tried in firefox with a url having spaces (example https://tiddlywiki.com/#a%20b%20c%20d) and the filter worked fine. The filter won’t see $20 as a space.

What are you trying to accomplish with encoding the whole string?

It is possible to do this with tiddlyclip plugin on desktop browsers - open a new thread if you would like more information.

1 Like

@btheado I will just try and restate this; I am browsing a website and find a link on the page I want to keep, click and drag the link, drop on tiddlywiki and it imports an “Untitled” tiddler containing this;

https://www.womensweeklyfood.com.au/mandarin-recipes-31141 24 magical mandarin recipes

  • Now I could just split on space and use split[ ]first[] to get the url and use the rest to get the pretty name magical mandarin recipes.
  • But is this always true?
    • are there other cases where a space can be part of the url?

I am keen to be able to drag and drop links and capture the link and its pretty name. I know how to do this but I am unsure if all the possible urls will obey this “all before the first space rule”.

Also if I drag and drop such a link on a list such as made by the list-links draggable macro, I get the example in the OT

  • [[https://plugins.tiddlyhost.com/ Plugins - for TiddlyWiki — Support on and libraries]] and it follows a similar pattern.
  • I can put an action on drop to convert this to a link eg `[[Plugins - for TiddlyWiki — Support on and libraries|https://plugins.tiddlyhost.com/]]

If this split on the first space “is the rule” then I will build a way to parse the links into tiddlywiki or html href’s with pretty link.

  • I am just not sure if this rule will hold.

As @Scribs already said:

Therefore, the rule will hold for all cases and you can safely split on the first space.

1 Like

While from a URL syntax perspective you will be fine, be aware browsers behave differently.

If you open the javascript console and type $tw.log.IMPORT=true and they drag and drop the url, then you can see the dataTransfer object details.

In firefox it has the title information:

Available data types:
type text/plain https://tiddlywiki.com/
type text/x-moz-url https://tiddlywiki.com/ TiddlyWiki — a non-linear personal web notebook 
type text/html <a href="https://tiddlywiki.com/">TiddlyWiki — a non-linear personal web notebook</a> 
Importing data type 'text/x-moz-url', data: 'https://tiddlywiki.com/ TiddlyWiki — a non-linear personal web notebook'

But for me, chrome is putting much less data in the dataTransfer object and you don’t get the title:

Available data types:
type text/plain tiddlywiki.com
type text/uri-list https://tiddlywiki.com/
Importing data type 'URL', data: 'https://tiddlywiki.com/'

BTW, to drag the url, I click on the url address bar, the text highlights and I drag the highlighted text. Not sure if there is another way in which you are doing it.