I have a WebApp and it works alright in both Android and iOS environments. The problem is, in one of the screens, the WebApp generates (and displays) a PDF file, which should be shareable through Email, WhatsApp, Telegram, etc.
Android does allow the share option in the standalone display mode, but iOS just doesn't. I need to know if there's any way I can actually exit the WebApp mode into plain good-old-browser mode when opening the pdf file, so that the user can actually share it with his/her contacts through the browser's native share dialog.
These are the contents of the manifest.json file
{
"name": "Test App",
"short_name": "TestApp",
"icons": [
{
"src": "/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"start_url": "https://example.com?a2hs=1",
"scope": "/",
"display": "standalone",
"orientation": "portrait",
"background_color": "#000000",
"theme_color": "#000000"
}
So far, I've tried:
using Display PDF in the pdf link.
using javascript to force-open a new window:
test
<script>
$(function(){
$('#pdf').click(function(e){
e.preventDefault();
window.open($(this).attr('href'), '_blank');
return false;
});
});
</script>
None of those solutions worked out.
Also, I tried changing the display: property in the manifest.json file to minimal-ui - that does allow to share the file/url but that removes the WebApp look & feel, so it's not an option.
Any ideas? Thanks!
I managed to find a solution. I created this alias subdomain:
pdf.example.com
Then, I linked the pdf to the alias subdomain:
Display PDF
iOS recognizes this as another server, so it automatically forces the load of the file in a new tab in Safari, exiting the current standalone mode of the webapp.
I'm able to run this extension somehow:
https://github.com/mdn/webextensions-examples/tree/master/beastify
On clicking the Browser Icon popup/choose_beast.js is invoked.
Can somebody tell me why this code(placed in the top of popup/choose_beast.js) is generating exception:
try{
var ss = require("sdk/simple-storage");
ss.storage.myArray = [1, 1, 2, 3, 5, 8, 13];
}catch(e){
alert('exception');
console.log(e);
}
Here is the relevant entry in the manifest.json:
"browser_action": {
"default_icon": "icons/beasts-32.png",
"default_title": "Beastify",
"default_popup": "popup/choose_beast.html"
}
What is the way I can store the data in this popup html so that I can retrieve anytime in the content script?
Also under which context is this page choose_beast.html running? Background, page script or content script?
A web-extension should be using storage API for this purpose.
Here is an example usage.
I want to create an extension for Google Chrome, and it will be real simple.
I will have a database on my website's server, it will check if a URL is in the "blacklist" table, and warn the user if it is.
But I don't know where to start. I tried putting all the files on my web server, and changin the manifest.json file as such:
(changed the "default_popup" line)
{
"manifest_version": 2,
"name": "My Extension",
"description": "This extension warns you if you are trying to open a blacklisted URL",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "http://www.mysite.com/my_extension/popup.html"
},
"permissions": [
"https://secure.flickr.com/"
]
}
Note : this file resides on my computer, I load it from the "Extensions" menu of Chrome.
but when I tried to install this extension, I got the error :
This web page could not be found:chrome-extension://hgfdjnsakhkijfmdnadmlacgjggggkpf/http://www.mysite.com/my_extension/popup.html
Instead of trying to hard code it in the manifest file, try putting something like this in a background page:
chrome.browserAction.setPopup({popup: "http://www.mysite.com/my_extension/popup.html"});
However, it may not be possible to specify an external popup page at all.
Nevertheless, it would be better to include the popup in the extension files and then get just the data from your server.
I can't figure out or find the documentation on how to access the source of an old commit in the new Bit Bucket format. Is this even possible anymore?
I understand you want to download an older version via the BitBucket web interface without using a Mercurial/Git client.
Check this related question. On the comments, someone says that there is no way to do that. Fortunately, that's not entirely true.
By navigating on BitBucket project pages, I found no link to download an arbitrary version. There are links to download specific tags, in the format:
https://bitbucket.org/owner/repository/get/v0.1.2.tar.gz
But by tweaking a bit the url above, changing the tag name by the commit hash, like:
https://bitbucket.org/owner/repository/get/A0B1C2D.tar.gz
You can actually download a specific version.
As mentioned by Rakka Rage in a comment, replacing .tar.gz by .zip works too.
I was trying to figure out if it's possible to browse the code of an earlier commit like you can on GitHub and it brought me here. I used the information I found here, and after fiddling around with the urls, I actually found a way to browse code of old commits as well.
When you're browsing your code the URL is something like:
https://bitbucket.org/user/repo/src/
and by adding a commit hash at the end like this:
https://bitbucket.org/user/repo/src/a0328cb
You can browse the code at the point of that commit. I don't understand why there's no dropdown box for choosing a commit directly, the feature is already there. Strange.
Step 1
Step 2
Step 3
Step 4
Final Step
Just in case anyone is in my boat where none of these answers worked exactly, here's what I did.
Perhaps our in house Bitbucket server is set up a little differently than most, but here's the URL that I'd normally go to just to view the files in the master branch:
https://<BITBUCKET_URL>/projects/<PROJECT_GROUP>/repos/<REPO_NAME>/browse
If I select a different branch than master from the drop down menu, I get this:
https://<BITBUCKET_URL>/projects/<PROJECT_GROUP>/repos/<REPO_NAME>/browse?at=refs%2Fheads%2F<BRANCH_NAME>
So I tried doing this and it worked:
https://<BITBUCKET_URL>/projects/<PROJECT_GROUP>/repos/<REPO_NAME>/browse?at=<COMMIT_ID>
Now I can browse the whole repo as it was at the time of that commit.
Great answers from a couple of years ago. Now Bitbucket has made it easier.
Tag the Commit you want to download (as mentioned in answer by Rudy Matela).
Then head over to Downloads and click the "Tags" tab and you'll get multiple options for download.
For the record, you can also toy around URLs this way :
When browsing the latest source, you have something like :
https://bitbucket.org/my/repo/src/latestcommithash/my.file?at=master
Simply change the commit hash and remove the GET parameter :
https://bitbucket.org/my/repo/src/wantedcommithash/my.file
Got to +1 #Hein A. Grønnestad above : it's all working, really wondering why there's nothing in the GUI to use it.
Add this to the end of any url: ?at=102beada4f1 (using the relevant commit SHA).
Note: the parameter is 'forgotten' with every new page load, so get ctrl + c and ctrl + v ready.
It's astonishing that BitBucket/Stash has no 'Browse files' button in the UI, like GitHub has:
Sigh.
You can view the source of the file up to a particular commit by appending
?until=<sha-of-commit> in the URL (after the file name).
The easiest way is to click on that commit and add a tag to that commit.
I have included the tag 'last_commit' with this commit
Than go to downloads in the left corner of the side nav in bit bucket.
Click on download in the left side
Now click on tags in the nav bar and download the zip from the UI.
Find your tag and download the zip
You can view it on your BitBucket web site
As explained on Atlassian community site, it's enough to go to the Source page (available from left side menu) and put your commit id in the at= query parameter of the url. So, for example, the url will end with ?at=bacf2ad3095.
I know it's too late, but with API 2.0 you can do
from command line with:
curl https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<branch>/<path_file>
or in php with:
$data = json_decode(file_get_contents("https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<branch>/<path_file>", true));
then you have the history of your file (from the most recent commit to the oldest one):
{
"pagelen": 50,
"values": [
{
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/src/<hash>/<path_file>"
},
"meta": {
"href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/src/<HEAD>/<path_file>?format=meta"
},
"history": {
"href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<HEAD>/<path_file>"
}
},
"commit": {
"hash": "<HEAD>",
"type": "commit",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/commit/<HEAD>"
},
"html": {
"href": "https://bitbucket.org/<user>/<repo>/commits/<HEAD>"
}
}
},
"attributes": [],
"path": "<path_file>",
"type": "commit_file",
"size": 31
},
{
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/src/<HEAD~1>/<path_file>"
},
"meta": {
"href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/src/<HEAD~1>/<path_file>?format=meta"
},
"history": {
"href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<HEAD~1>/<path_file>"
}
},
"commit": {
"hash": "<HEAD~1>",
"type": "commit",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/commit/<HEAD~1>"
},
"html": {
"href": "https://bitbucket.org/<user>/<repo>/commits/<HEAD~1>"
}
}
},
"attributes": [],
"path": "<path_file>",
"type": "commit_file",
"size": 20
}
],
"page": 1
}
where values > links > self provides the file at the moment in the history which you can retrieve it with curl <link> or file_get_contents(<link>).
Eventually, from the command line you can filter with:
curl https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<branch>/<path_file>?fields=values.links.self
in php, just make a foreach loop on the array $data.
Note: if <path_file> has a / you have to convert it in %2F.
See the doc here: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/filehistory/%7Bnode%7D/%7Bpath%7D
Search it for a long time, and finally, I found how to do it:)
Please check this image which illustrates steps.
In my case with Atlassian Bitbucket v6.10
https://<bitbucket.myserver.it>/projects/<myproject>/repos/<myrepo>/browse?at=<full-commit-hash>
I am very new to js and chrome extentions and am trying to make a chrome extension that gets the current tabs url and adds a '&flash=on' at the end. my code doesn't seem to want to work right
manifest.json
{
"name": "FlashOn Chrome",
"version": "0.1",
"description": "Changes default to flash player",
"permissions": [
"tabs"],
"content_scripts": [
{
"matches": ["http://www.stream.com/*"],
"js": ["script.js"]
}
]
}
script.js
function updateUrl(tab){
var currentURL = tab.url
var newurl = currentURL.replace(currentUrl + "&flash=on");
chrome.tabs.update(tab.id, {url: newurl});} chrome.browserAction.onClicked.addListener(function(tab) {updateUrl(tab);});
its for a streaming site that has html5 video and flash video but the flash is only accessible by adding the &flash=on to the end of the url
Not sure what you're trying to accomplish here: are you trying to change the location of the page, from the current URL to the URL with &flash=on` added on to it?
Also -- the script here seems to be incomplete: could you provide a complete script?
One obvious problem: you've got currentURL and currentUrl:
var newurl = currentURL.replace(currentUrl + "&flash=on");
Note that in a content script you can get and set the URL of the page with location.href.