Set PWA start_url in web app manifest based on the URL that was added to homescreen - progressive-web-apps

I would like to make the start_url in the manifest at the where user visit the landing page.
https://example.com/1234
https://example.com/4321
this is my php to fetch whole url {{ Request::fullUrl() }}
I put at "start_url" : "{{ Request::fullUrl() }}", it doesn't fetch in json file.
I had try change the manifest.json to manifest.php, but don't know how to convert the json content into php to make it work.
<link rel="manifest" href="/_manifest.php?start_url=val" data-pwa-version="set_in_manifest_and_pwa_js">
I know this is old question and I search all over the internet still can't find the solution.
Set start_url in web app manifest based on the URL that was added to homescreen
this doesn't have a solution. delete the start_url doesn't make the PWA work.
Any expert could help me? Appreciate!
I'm newbie on coding, please forgive my limited knowledge.

Chrome (and most other browsers) require you provide the start_url in the manifest, and it can't be dynamic.
You could build this behaviour by saving the page the user was on when the PWA was installed. Then, set the start_url to a simple redirect page that checks to see what page the user was on when they installed, and redirect them to that page.
To save the page the user is on when the PWA is installed, listen for the appinstalled event, then save the page to localStorage:
window.addEventListener('appinstalled', () => {
localStorage['installedFrom'] = window.location.pathname;
});
Then, in the redirect page, do something like:
const installedFrom = localStorage['installedFrom'];
if (installedFrom) {
window.location.replace(installedFrom);
} else {
// No install page saved, send them to the home page?
}

Related

Links with target=_blank opens in browser

In my PWA website, I have in a few places, links that open in new tab using target="_blank". I want to maintain this functionality but not if the user has installed the PWA.
Currently, if the user installs the PWA and click on that link, the user is taken to the browser and the page loads there.
I have tried all different kinds of scope but all give same result.
/
./
https://beta.domain.com/
// Add this script after </body>
<script>
if (window.matchMedia('(display-mode: standalone)').matches) {
// if webapp installed, remove 'target' attribute of links
document.querySelectorAll('a[target=_blank]').forEach(function(a) {
a.removeAttribute('target');
});
}
</script>

How do I redirect my Prestashop home page to another URL or page on my website?

I have a website where I installed Prestahop on a /shop directory but will want to redirect the homepage to the main homepage while other product pages function normal without using a module and without redirecting all pages to the new URL.
EG. I want to change example.com/shop to examplae.com while other pages like example.com/shop/category/product1 work normal.
I posted the question because there seem to be very little resources
on this topic as most answers I got while researching are eighter directing users to buy
modules or to do a general redirect.
It worked for me. In my case, I changed the home page to another URL which is mine. Other product pages still work normal. To do that, go to controllers/front/IndexController.php and change add the following code somewhere in the initContent function.
Tools::redirect('http://newwebsiteurl.com/');
That is you will delete all the contents in the function below
{
parent::initContent();
$this->addJS(_THEME_JS_DIR_.'index.js');
$this->context->smarty->assign(array('HOOK_HOME' => Hook::exec('displayHome'),
'HOOK_HOME_TAB' => Hook::exec('displayHomeTab'),
'HOOK_HOME_TAB_CONTENT' => Hook::exec('displayHomeTabContent')
));
$this->setTemplate(_PS_THEME_DIR_.'index.tpl');
}
and replace it with something like this:
{
parent::initContent();
Tools::redirect('http://newwebsiteurl.com/');
}
It worked for me on my website Soup Embassy and I hope does for you too. If you check the URL on Soup Category here, you will see that it is in a directory /buy-online/ and when you click on the home link or logo, it will redirect you to a URL without the extension. I hope you find this helpful.

Website Redirection Fix?

I run an anime website with embeded links for players, multiple per page/per episode so I have quite a few, and on some of the pages, the players are redirecting the user to adultfriendfinder, which is very annoying because it doesn't redirect them through a popup or a new tab, it redirects my site to their page, and this happens even with adblock.
here is a link to my website, and a page that will display this:
http://animewolf.tv/anime/death-note-episode-1-dubbed/
if you click on 'mp4upload' it will redirect to adultfriendfinder.com, you'll need to press back and play the video, which is very annoying.
If it doesn't redirect you and you want to see, just look around the site's episodes ( http://animewolf.tv/watch-anime/ )
Is there anything I can do to get around this? any plugin, anything I can do to block the site? anything?
thx.
if you see from the firebug, i find network error (404) in http://www.myanimelinks.com/nanotabs.js which redirect you to google-ads(adsense). It is known that if no proper ads exists based on your site will force google to redirect the ads to other ads or blank (and google dislike ads inside a frame.
Besides, links to access http://www.myanimelinks.com/nanotabs.js is denied, blocked or redirect to 404 page.
if you access this following link> without frame, everything is going well:
http://animewolf.tv/wp-content/plugins/anime/embed/auengine.php?id=e5XVDRmg
In this case, you should remove other links available which causes error.
UPDATE:1
this links > http://animewolf.tv/wp-content/plugins/anime/video_source.php?source=YToxOntpOjA7YTozOntzOjI6ImlkIjtzOjEyOiI2aGMzY2w1b3NjZzkiO3M6NDoidHlwZSI7czoxOiI5IjtzOjY6Im51bWJlciI7czoxOiI3Ijt9fQ== go to encrypted page content then you add it to your page within frame. this causes this.
now try to add this link > http://animewolf.tv/wp-content/plugins/anime/embed/auengine.php?id=e5XVDRmg directly to the src="" of your frame. perhaps, it can work.
UPDATE:2
Try this and place on your page which globally relate to them:
<script>
$(document.body).ready(function(){
$(document).on('click', 'a', function(e){
e.preventDefault();
e.stopImmediatePropagation();
return false;
});
});
</script>
otherwise, see this:
http://stackoverflow.com/questions/15811079/stop-redirecting-in-javascript

AddThis and History.js - automatic redirection to wrong URL

I have a problem with AddThis widget and History.js script.
Once user shares some page on Facebook using AddThis widget, some hashtag is appended to URL (e.g. #.U-S_Q-q0tE8.facebook).
Then, if user clicks such link on Facebook and goes to my website with URL e.g.: http://domain.com/path/to/content,123.html#.U-S_Q-q0tE8.facebook, they get redirected to http://domain.com/path/to/.U-S_Q-q0tE8.facebook which throws error 404.
The weird thing is that History.js is not even initialized or used. It's just embed on the site with <script...> tag.
Is there any solution to this? Is it possible to disable such behavior in History.js?
I have the exact same problem, and while I don't know if you can disable the history.js behavior, you can disable the addthis hashes by adding the following before the addthis script
<script type="text/javascript">
var addthis_config = {
data_track_clickback: false
}
</script>
This means you wont be able to track how many click that link gets using addthis, but something like Google Analytics is able to show traffic source.
Source

Working out if a Sinatra route is coming from within my webapp

I have a web app built upon Sinatra/Padrino that is up and running, but I want to make a small change to it in order to assist us with marketing it.
At the moment, when users type in the browser address bar www.mygreatapp.com they are taken to the app main page, which is probably a little confusing for a new user or prospect. Ideally, we would like it so that when they come to our home page from another site or a google search or manually typing in the URL, they are shown a separate landing page which explains the site in more detail, before they can then head to the actual home page.
Bear in mind that WITHIN the web app, there are links from deeper pages which redirect back to the home page, and we would like THOSE links to still go to the actual home page.
At the moment, the route handler for the home page is something like:
get '/' do
render 'homepage'
end
What I essentially want it to be able to do is:
get '/' do
if {{ This was called from within www.mygreatapp.com }}
render 'homepage'
else {{ This was called from externally or another site }}
render 'landingpage'
end
end
Is this possible? Is this even the best way to handle this sort of thing? Perhaps there is another way to accomplish this that I am missing?
Yes, it's possible and there are plenty of ways to do it. Personally, I'd give the landing page its own route, and place an eternal cookie (and maybe other stuff too in case cookies get wiped) on first visit that indicates someone has already been to the site. If they have the cookie, don't do anything. If they don't, they're new, redirect them to the landing page.