I have for example page , and if i copy url and paste in another tab there will be the same page. Ok, this is okey, but i dont want this. Can i make that, if I open in another tab (second, or third) the same url there will be flash error and write something like: "Sorry you can open only in 1 tab"?
No, you can't check if page is already opened in browser with Ruby-on-Rails.
I am not sure if you can do it with javascript.
What you can do is to save last_visit time to page and deny to reload it or load anywhere else for current user for particular time: 1 minute, 10 minutes.
Related
I'm trying to write code in my controller download to start a download from some external url say www.abc.com/foo.mp4. So far I have built it this way:
def download
redirect_to 'www.abc.com/foo.mp4'
end
It works but the problem is that it opens a video in the same tab. What I want is that it should start a download in the browser of this video.
I searched about it in forums but couldn't find any solution. All I found was a way to download the video first using the URL and then provide it as download but that's not what I want. I want the download to start directly from the external URL.
I think this might help you: Download from a link with HTML5
In your case it would be:
download me
That way, from the same webpage you are, when the user clicks on it, it will start the download and you don't go throught the controller, but in case you want to go throught the controller "download" and then just render a page with some kind of information saying that is downloading or something else, then put that link I wrote above somewhere in that page (and if you want, you can give it a class name and with css hide that class so that link is not visible but it is there) and at the end a Javascript function that calls itself when it is loaded and performs the action of clicking to that link:
(function(){
$('#whateverIdYouGiveToTheHtmlElement').click();
})();
I should clarify that $('#whateverIdYouGiveToTheLink').click(); is jQuery and not pure Javascript, but since you are using Rails I assume the project has jQuery (by default Rails comes with jQuery).
I go to "Publishing Tools" > "Instant Articles"
I am able to select the "Production" or "Development" directories.
I click "+create" and am presented with a blank document that instructs me to 'paste in some HTML.'
I paste in the HTML for my Instant Article and click "Save"
I am able to view the Instant Article via the Page Manager App
I want to create a second IA in the same directory (Production or Development)
I go back to "Publishing Tools" > "Instant Articles"
I select which ever directory I created the first IA in
I click "+create" (for the second time now) and am again prompted to paste in HTML
I paste in the HTML for my second IA and click save
Now the second article is viewable via the Page Manager app and the first one has been deleted / overwritten / is gone
Is anyone else experiencing this problem?
I finally found the error. It seems that facebook's chache is messed up. So just add new articles to your page, pull the the stuff inside the
<content:encoded><![CDATA[ ]]></content:encoded>
from your rss feed and paste it into the code editor in facebook.
You should be able to create more articles this way.
I am new to flash coding and didn't know much more.
I want to make a flash file that send URL to web browser to open particular link.
I've made such file it execute properly but after making swf file, it does not open the link.
Any one help me regarding this small problem.
Check out navigateToURL(): http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/package.html#navigateToURL()
Note that it won't work unless it's triggered by a user action; i.e. a mouse click or a key press
I'm making some fanpages.
I have a code that show an image to the user before liking the page, and another image or content after liking the page.
I created several pages with this code and all of them worked fine.
but about 5 days ago, I created one with the same code, and it just showed the "after like" content, even when I haven't liked the page.
and today, I created a new one, and it just shows a blank page. neither the after or the before.
I've checked on the previous fanpages and those are still working, so it's just the new pages that aren't working.
they'r using the facebook php sdk
the procedure I use is:
* upload files to my server
* create a new app
* add urls for page tab (both normal and secure url)
* add app to my page
is someone having the same issue?
does someone know why is that problem and how it can be solved?
thanks,
Abraham
if you have php errors turned off, and you throw a fatal php error before any html output, you might also see a blank screen.
Try uploading a dummy file with some simple text as your main app page, and see if it works.
If so, try tracking down any error that might prevent the page from rendering.
To get output on php errors, add this to the top of your page:
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
?>
As it takes some time to prepare the content of the data to be downloaded, I want to show a message "Preparing file to download" when the user submits the request
Then when the file is ready, I use send_file to send the data
Once it's done, I need to clear the message
Thanks a lot
Here is what I would do.
1. Create a prepare_file action
First, I would create an action whose job would just be to create the file and rather than rendering HTML, it would render a JSON object with the name of the file that was created.
2. Use AJAX to call the prepare_file action
On the client, when the user clicks to download the file, you display the message, "Preparing download..." and just do an AJAX request to that action. The response you'll get back via AJAX is the name of the file created.
3. Redirect to the file download
Finally, you can hide the preparing download message and redirect the browser to the file download via JavaScript with the name of the file that was created. You would use send_file in this action.
I know that, in the question, you also wanted to be able to display to the user a message when the file is downloading and another message when it is finished. However, this isn't possible unless you write your own client-side download manager. The browser handles file downloads entirely and the user will see in the browser that the file is downloading and what the progress is. So, I understand where you're coming from, but you shouldn't feel like the user isn't being informed of what's happening.
At least with this solution, you're displaying a message to them when the file is being prepared and then once that message disappears, they'll get the download file dialog from the browser.
If you need help with actual code samples of how to do this, let me know.