ferdium / ferdium-recipes

Recipes encapsulate your favourite apps into Ferdium for unified notifications handling and more
MIT License
83 stars 192 forks source link

question to create a new recipe #185

Closed spi43984 closed 2 years ago

spi43984 commented 2 years ago

I am trying to add a new service by using 'custom website' - as that doesn't work so well I started to create a new recipe for that.

I have three questions:

  1. I managed to get all links opened inside Ferdium - but how about links to pdf files or something?

    Currently if I click a link (that is linked to a pdf) in Ferdium that link is opened in the default browser - which actually doesn't open the pdf as I am not authenticated in the default browser.

    If I right click the link and choose "Open Link in Ferdium" I can download the pdf to a custom folder - not too bad.

    If I right click the link and choose "Open in Browser" the link gets opened in the browser, I need to authenticate and the service default start page is loaded - too complicated.

    Is there a smarter way to deal with link to files?

  2. Every time I restart Ferdium I need to re-authenticate - is there a way to tell a recipe to keep the session authenticated or something so I need not to re-authenticate after restarting Ferdium?

    Update: The webservice uses a PHPSESSID session cookie which probably gets deleted or renewed with every Ferdium restart.

  3. The webservice offers un-read counters. I see the I can use setBadge in webview.js to set them accordingly in Ferdium. If the webservice offers the counter in something like <span class="badge list-group-item-danger">0</span> in multiple locations - how would I code that in webview.js to parse the right number? Does anyone have a simple example? The ones in zoom and steamchat are currently way to complicate...

    Update: found some docs, am trying:

  const getMessages = () => {
    let directCount = 0;
    const directCountPerServer = document.getElementById('top-navbar').querySelectorAll('.badge.list-group-item-danger');

    for (const directCountBadge of directCountPerServer) {
      directCount += Ferdium.safeParseInt(directCountBadge.textContent);
    }

    Ferdium.setBadge(directCount);
  };

  Ferdium.loop(getMessages);
spi43984 commented 2 years ago
  1. The webservice offers un-read counters. I see the I can use setBadge in webview.js to set them accordingly in Ferdium. If the webservice offers the counter in something like <span class="badge list-group-item-danger">0</span> in multiple locations - how would I code that in webview.js to parse the right number? Does anyone have a simple example? The ones in zoom and steamchat are currently way to complicate... Update: found some docs, am trying:
  const getMessages = () => {
    let directCount = 0;
    const directCountPerServer = document.getElementById('top-navbar').querySelectorAll('.badge.list-group-item-danger');

    for (const directCountBadge of directCountPerServer) {
      directCount += Ferdium.safeParseInt(directCountBadge.textContent);
    }

    Ferdium.setBadge(directCount);
  };

  Ferdium.loop(getMessages);

That works - but for whatever reasons I am geeting a number doubled in value. Can't find any other occurence of '.badge.list-group-item-danger'. Need to investigate further. If it's doubled every time I can divide by 2 then...

hafiz-muhammad commented 2 years ago

You'll need to create a recipe of an online service that is able to view PDF files, Ferdium isn't designed for viewing PDF files or documents like that.

spi43984 commented 2 years ago

You'll need to create a recipe of an online service that is able to view PDF files, Ferdium isn't designed for viewing PDF files or documents like that.

Thx - suspected that that it's not possible to display files directly.

Would it be possible for a dedicated service to use a browser engine within Ferdium which is capable of rendering pdf files?

hafiz-muhammad commented 2 years ago

An easier way is to do this:

spi43984 commented 2 years ago

An easier way is to do this:

  • Open Ferdium
  • Click on the 'Add New Service' icon or (Ctrl + N)
  • Go to 'All Services'
  • Search for 'Custom Website' and click it
  • Then open your PDF file in the browser and copy the 'file:///' path in the address bar
  • Paste it into the 'Custom server' box on Ferdium

The pdf file link changes every time (at least it has a csrf token due to authentication) - that approach sounds pretty complicated.

hafiz-muhammad commented 2 years ago

Not sure why it would be changing for you unless you're moving the PDF to a new directory. I've just tested it and it's working for me.

spi43984 commented 2 years ago

Not sure why it would be changing for you unless you're moving the PDF to a new directory. I've just tested it and it's working for me.

The pdf link is created dynamically. I'd need to copy paste the pdf link again and again, right?

hafiz-muhammad commented 2 years ago

The pdf link is created dynamically. I'd need to copy paste the pdf link again and again, right?

Why don't you just download the PDF and save it on your computer then? If the link constantly changes then you'd need to enter it in again each time, that's why it's not working for you if that's the case.

spi43984 commented 2 years ago

The pdf link is created dynamically. I'd need to copy paste the pdf link again and again, right?

Why don't you just download the PDF and save it on your computer then? If the link constantly changes then you'd need to enter it in again each time, that's why it's not working for you if that's the case.

That's what I am currently doing as the webservice is authenticated and the pdf links are secured by csrf tokens. It would be nicer though if I could read the pdf within Ferdium if needed without downloading them first and opening in another application.

hafiz-muhammad commented 2 years ago

What is the sites name?

spi43984 commented 2 years ago

What is the sites name?

It's a private webservice on invitation only.

hafiz-muhammad commented 2 years ago

Well I can't be much help with that then.

spi43984 commented 2 years ago

Well I can't be much help with that then.

Not directly I am afraid.

Just to understand everything right:

Can't I embed another browser (which is able to render pdf files) in Ferdium for that particular service?

spi43984 commented 2 years ago

Just to understand everything right:

* Ferdium itself can't display a pdf file.

* It also can't directly open another application to open that file.

* If I click the link in Ferdium it opens the default browser - as the webservice needs authentication and the session is not authenticated in the browser the browser won't open the file.

* if I use a browser instead, authenticate and click the pdf file it is rendered within the browser.

Can't I embed another browser (which is able to render pdf files) in Ferdium for that particular service?

Could someone shed some light on those questions please?

xalt7x commented 2 years ago

@spi43984

Just to understand everything right:

* Ferdium itself can't display a pdf file.

* It also can't directly open another application to open that file.

* If I click the link in Ferdium it opens the default browser - as the webservice needs authentication and the session is not authenticated in the browser the browser won't open the file.

* if I use a browser instead, authenticate and click the pdf file it is rendered within the browser.

Can't I embed another browser (which is able to render pdf files) in Ferdium for that particular service?

Could someone shed some light on those questions please?

I'll try... Users want to download files directly from Ferdium app (click "Download", "Save" dialog appears etc). But problem is that when you click "Download" on services like "Google Chat", "Facebook Messenger", "Zulip" (and custom webistes as well) it doesn't trigger "Save" dialog within Ferdium, instead download URL opens in the default system browser where user obviously should login into service with the correct account. That's even a bigger problem if you use multiple accounts for a service.

Currently we know 2 ways to work-around it: 1) Right click on "download" button and click "Open Link in Ferdium" 2) Click on "download" button with a Shift pressed

Also all services (including "custom website") have option "Open URLs within Ferdium" but turns out it only works for a limited number of services (Discord, Skype, Steamchat and zoom). We would like to have it working for all services or at least for a "custom website" recipe.

spi43984 commented 2 years ago

Can't I embed another browser (which is able to render pdf files) in Ferdium for that particular service?

I'll try... Users want to download files directly from Ferdium app (click "Download", save dialog appears etc). But problem is that when you click "download" on services like "Google Chat", "Facebook Messenger", "Zulip" (and custom webistes as well) download url doesn't trigger "save" dialog in Ferdium, instead that url opens in the default system browser where user obviously should login into service with the correct account. That's even a bigger problem if you use multiple accounts for a service.

Currently we know 2 ways to work-around it:

  1. Right click on "download" button and click "Open Link in Ferdium"
  2. Click on "download" button with a Shift pressed

Also all services (including "custom website") have option "Open URLs within Ferdium" but turns out it only works for a limited number of services (Discord, Skype, Steamchat and zoom). We would like to have it working for all services or at least for a "custom website" recipe.

Thx for answering - if I understand correctly, Ferdium can't display pdf files. Couldn't I embed another browser which is able to render pdf files for a particular service in Ferdium?

How does Ferdium deal with the other services like Discord Skype etc. to allow links be opened within Ferdium?

And is there some 'magic' in Ferdium to keep authenticated browser sessions open? One particular sessions keeps timing out and I need to re-authenticate very often.

xalt7x commented 2 years ago

@spi43984

And is there some 'magic' in Ferdium to keep authenticated browser sessions open?
Couldn't I embed another browser which is able to render pdf files for a particular service in Ferdium?

Ferdium definitely uses built-in browser in some cases (selected services, "Open Link in Ferdium" context menu, menu "View" - "Toggle Navigation Mode" etc).

How I understand this issue:

Obviously by design Service need to stay on the specific page page. So even with a built-in browser we have limited options for URL:

So to workaround our issues with downloads from an external browser there's not much options as well:

  1. Open each URL in separate Ferdium window
  2. "Teach" service to recognize "download URLs" and handle them with a built-in browser (other should be passed to system browser).

I believe that second option could be implemented for some services. "Custom website" on the other hand is not predictable so most likely we have to resort for the 1st options there.

vraravam commented 2 years ago

Looks like the ask is different from the title of the ticket. Please search for "download" or "handle links" in other open/closed tickets. That has been answered multiple times.

xalt7x commented 2 years ago

Please search for "download" or "handle links" in other open/closed tickets. That has been answered multiple times.

@vraravam , I guess you've meant this pull request " Add new service-level option 'trapLinkUrls' ferdium/ferdium-recipes#30 ". So as this request closed now, Ferdium team probably decided that this feature will be limited to "Discord", "Skype" , "SteamChat" and "Zoom" but available as an [useless] option for all other services. That's a shame...

spi43984 commented 2 years ago

Looks like the ask is different from the title of the ticket. Please search for "download" or "handle links" in other open/closed tickets. That has been answered multiple times.

No, it was not as it covered three questions about new recipes.

vraravam commented 2 years ago

Please search for "download" or "handle links" in other open/closed tickets. That has been answered multiple times.

@vraravam , I guess you've meant this pull request " Add new service-level option 'trapLinkUrls' ferdium/ferdium-recipes#30 ". So as this request closed now, Ferdium team probably decided that this feature will be limited to "Discord", "Skype" , "SteamChat" and "Zoom" but available as an [useless] option for all other services. That's a shame...

This was done at that time since the open requests were only for those services. As you can see, there's a TODO comment that I do not want to duplicate across all services. If you or any other contributor can help move that into the main codebase, such that its reusable, we would welcome such contributions - as opposed to passing judgements

vraravam commented 2 years ago

No, it was not as it covered three questions about new recipes.

could i request you to please create 3 different tickets in that case?

spi43984 commented 2 years ago

No, it was not as it covered three questions about new recipes.

could i request you to please create 3 different tickets in that case?

Sure - I'll open another one about the authentication issue.

Done - https://github.com/ferdium/ferdium-app/issues/980