Rails: Why does embedding video work with & without protocol (http)? [duplicate] - ruby-on-rails

This question already has answers here:
Absolute URLs omitting the protocol (scheme) in order to preserve the one of the current page
(3 answers)
Closed 5 years ago.
Why do both these work when embedding a video iframe in a Rails application?
<iframe src="//player.vimeo.com/video/...>
and
<iframe src="https://player.vimeo.com/video/...>
Please enlighten me. I've seen it both ways. Which is preferable?

Using // infers the protocol from the URL from which the root page is served. Navigating to a site https://yoursite.com would mean all // links would also be served using HTTPS. This can be helpful if you're running the same page in a local environment that is using HTTP, and don't want to change it when pushing it to a production environment served using HTTPS.

Related

How to recognize a bot in rails [duplicate]

This question already has answers here:
Rails Browser Detection Methods
(3 answers)
Closed 8 years ago.
I'm trying to record visits to my site, but I keep getting crawlers accidentally setting off my code. Is there any way in rails controllers to determine whether a user is a bot such as googlebot, etc?
You can check HTTP headers, particularly the user agent string.
http://www.useragentstring.com/pages/Googlebot/
Most friendly bots have "bot" in their user agent.
Another suggestion is to use something like Google Analytics to track your visits. It's way better than implementing your own.

Disable the right click, ctrl +c , ctrl+v and selection functionalities [duplicate]

This question already has answers here:
How to Disable Copy Paste (Browser)
(12 answers)
Closed 8 years ago.
I am developing an Online Exam rails app. In the Examination interface, I want to prevent the copy(ctrl+c), paste(ctrl+v), right click and selection functionalities. How I would be able to prevent it using javascript? Please help me to have a better solution for this.
Thanks :)-
This depends on the client's browser, so you'll need to add the appropriate JScript to your page. Note that this only works if Javascript is enabled on their browser (it generally will be).

Force multiple users to remove their appcache [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
My HTML5 Application Cache Manifest is caching everything
I have made an webapp that could be cached, however the cache created a lot of problems, so I need them all to clear their cache.
Can this be done automatically on my server?
Would any these options work?
change <html manifest="cache.appcache"> to <html>
remove the cache.appcache file from the server
add NETWORK: title above all resources
Relaying on the specification the first two options should do the work. because when the manifest is not reachable a browser should remove all cached data.
https://stackoverflow.com/a/8817490/1482507

what's the meaning of "#!" in twitter's url? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
What's the shebang/hashbang (#!) in Facebook and new Twitter URLs for?
I see twitter's url is this type:
twitter/#!/username
I known that twitter's front page uses ruby on rails framework, but "#!" is not the suggest type in RoR restful routes. So why twitter uses this strange url type? Is there any special reason?
It's a hashbang URL. In the days before HTML5 JavaScript URL rewriting, there was no way to rewrite stuff in the address bar, except for the hash symbol. Natively, the hash symbol in a link points to the id of some element on the webpage. This is overridden in JavaScript to perform other actions.
It's really weird that Twitter is using it, especially since there are libraries that failover to using hashbang but use the new history.pushState function when it's available.
Twitter uses AJAX a lot on their pages. You almost never see a reloa of the whole page. By using those anchor links they avoid reloading the page but still give you a chance to store the current state of the page as a favorite or use the back button of your browser

What's this new `#!` in URL convention? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
What's the shebang/hashbang (#!) in Facebook and new Twitter URLs for?
I noticed that some popular sites started switching to a new URL (convention?), in which a URI segment is no longer prefixed by / but rather by #!/.
For example, if you type into Twitter http://twitter.com/stackoverflow, it will immediately redirect to http://twitter.com/#!/stackoverflow.
Had I seen this on Twitter only, I wouldn't have thought twice about this, but now I am seeing this in other sites.
Is this a new convention for URL redirection? Where can I learn more about this?
It was started by Google ( http://code.google.com/web/ajaxcrawling/ )
If you're running an AJAX application
with content that you'd like to appear
in search results, we have a new
process that, when implemented, can
help Google (and potentially other
search engines) crawl and index your
content. Historically, AJAX
applications have been difficult for
search engines to process because AJAX
content is produced dynamically by the
browser and thus not visible to
crawlers. While there are existing
methods for dealing with this problem,
they involve regular manual
maintenance to keep the content
up-to-date.
Look at this answer here:
What's the shebang/hashbang (#!) in Facebook and new Twitter URLs for?
The opinion on using this is split - Gawker had major issues after taking this up : http://www.webmonkey.com/2011/02/gawker-learns-the-hard-way-why-hash-bang-urls-are-evil/
It's how Google should index the page when dealing with AJAX

Resources