baker icon indicating copy to clipboard operation
baker copied to clipboard

Links to external sites

Open stevenhahn opened this issue 14 years ago • 17 comments

I know that: Link to external site will link open the link in a new browser.

Is there any way to modify the "baker" as the 'signal'?

stevenhahn avatar Dec 25 '11 21:12 stevenhahn

another idea about links,

open the external link into baker whit a popup and a button to close the popup. i know you can open a link into baker whit the reference (?referrer=baker) , but need a button to close the url and come back the issue. a fullsceen popup i´ts a good idea.

mutador avatar Dec 26 '11 10:12 mutador

i found and modified: NSRegularExpression *referrerRegex = [NSRegularExpression regularExpressionWithPattern:@"referrer=Baker" options:NSRegularExpressionCaseInsensitive error:NULL];

from 'referrer=Baker' to a simpler expression.

Possible idea: have the expression value be a setting to eliminate the code change.

stevenhahn avatar Dec 27 '11 01:12 stevenhahn

We won't add this as a parameter, otherwise porting a book to a reader to another might break it. :) Plus, we added the parameter in this way so it's trackable by our analytics tool that the source was Baker. :)

Why did you want to change it?

folletto avatar Jan 11 '12 15:01 folletto

I would like to chime in that the '?referrer=baker' addition to the url scheme to have the link open in safari is not handled well by our CMS. Therefore the CMS is redirecting that link it can't process to our index page.

I have had to edit Baker's source code make this work.

Couldn't this be a setting in info.plist?

Dreeke avatar Jan 12 '12 11:01 Dreeke

Let's make a step back: why? What was the problem? :)

folletto avatar Jan 12 '12 11:01 folletto

Using the '?referrer=baker' parameter creates an url that the CMS ( ExpressionEngine) running the website we are linking to can't handle properly. Any url it doesn't recognize gets redirected to our homepage. The '?referrer=baker' bit that is appended to the url is not found by the CMS as a valid page, hence the redirect.

As we need our pages to open in Safari instead of inside the Baker app this is a problem. I hacked it and it is working by modifying the source, but this of course will break with every update. Therefore I figured a setting in the info.plist or something of the kind that flags the use of defaulting to external links or only using external links with the referrer addition in the url.

Dreeke avatar Jan 12 '12 11:01 Dreeke

"Any url it doesn't recognize gets redirected to our homepage."

Wow, that's incredibly naive, since it's not a page but a parameter! I might be wrong, but they aren't following the URL definition standard with that choice.

Do you have an URL that behaves in that way so I can test it?

folletto avatar Jan 12 '12 11:01 folletto

@folletto: "What was the problem?" a book that i am working on has both internal links (to other pages) and links to public websites. one of the websites that i am linking to already is expecting a "referrer=xyz", so a value of 'baker' would mess things up.

it seems that an expression like "foo=bar" would not step on anyone else code, and work just as well.

stevenhahn avatar Jan 12 '12 14:01 stevenhahn

Fantastic. We used a standard name thinking that no application would use that name for anything else apart for the referrer itself, and it happens that instead they are using it for everything but referrers! :D

The irony. :)

Well, we then need to find another solution.

The starting point for me would be something like: http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=55578

That could translate to:

http://www.example.com/?utm_source=baker&utm_medium=ipad&utm_campaign=book

But at that time we felt it was too long.

NOTE: We'd love to use the target="_blank" attribute, but unfortunately it's not handled by the Objective-C delegate. :|

folletto avatar Jan 12 '12 14:01 folletto

i agree, that example is too long. i prefer a minimalistic solution. it would be nice if the developer could specify the expression, and also have a simple, non-intrusive default. e.g. "?src=bf" (source == baker)

stevenhahn avatar Jan 12 '12 14:01 stevenhahn

I'm all for minimalistic solutions. ;)

This unfortunately is something we can't parametrize at code level, because it will then generate incompatible books between versions and readers.

Any other idea? I think we are a bit brainstorming here so the more feedback the better. :)

folletto avatar Jan 12 '12 14:01 folletto

We have got 2 issues here:

  • using the referrer query parameter for Baker makes it impossible to use it for anything else
  • passing a mandatory query parameter to every request messes with some CMS

The first issue can be solved with a namespace, i.e. making the query parameter less common. Something like hpub-link-target=browser (or a less verbose equivalent) would fit the bill. The second issue can be solved by not propagating the query parameter. It shouldn't be hard to strip it away from the request URL after we have detected it.

Stripping away the parameter has the nasty side effect of going against the principle of least surprise ("where the hell has my parameter gone?!") but I think it's an acceptable trade-off in this case, assuming we document it properly.

Simbul avatar Jan 17 '12 00:01 Simbul

@Simbul i totally agree that stripping the parameter is a munge, and should not be done without a very good reason (if at all).

it seems that the CMS issue of @Dreek can be handled by your first solution: a simple, less common query parameter. i think that the CMS, seeing the lvalue of 'referrer' then demands a valid URL. a different expression would then be ok.

i do not fully follow why it can not be a parameter at the code level or how "porting a book to a reader would break it". does this assume that only baker books are ported to a baker reader?

it still seems to be that src=bf would work out

stevenhahn avatar Jan 17 '12 02:01 stevenhahn

I'd avoid src, since it's again a common tech word and even more used than referrer, and if that's was a problem I don't want to be back again on this. Also because one of the private discussion I had is a mis-configured .htaccess that redirects any ?parameter. It might be possible to use the #id part of the URL, we'll look into that. :)

As for the reason why, that's exactly the assumptions that Hpub books need to be portable that we should try to avoid that. :)

folletto avatar Jan 17 '12 02:01 folletto

We tried a few different solutions, but right now the only one that worked in all the situations was the one that removed "referrer=Baker" before calling the external webserver.

Now that's the current behaviour.

Committed right now. :)

folletto avatar Feb 06 '12 23:02 folletto

Here's the updated documentation: Managing links and urls

Simbul avatar Feb 07 '12 00:02 Simbul

i use a jquery solution for external url into baker...if no internet conection show a page saying "no internet conection avaliable" if yes , load the external page but whit a button for come back the baker page, the button is always visible..

see jquery moblie examples for load pages whit buttoms

http://jquerymobile.com/test/docs/pages/page-dialogs.html

i am waiting for review my new app whit this solution, when the app is ready for sale , i linked the download url

mutador avatar Feb 07 '12 00:02 mutador