How to test the google +1 button local - google-plus

I am just creating an html file to test out the google +1 button. I guess the problem my html is not deployed on a server. How can you test the google+1 button on your local machine. This code doesn't render anything.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Google+1</title>
<!-- <link rel="stylesheet" href="css/main.css" type="text/css" /> -->
<script type=”text/javascript” src=”http://apis.google.com/js/plusone.js”></script>
</head>
<body >
<g:plusone></g:plusone>
</body>
</html>

I assume it can't be done because Google's API check the source of the request, otherwise many security holes would be exist.
Why won't you check it online? Just upload the site to it's domain and try to +1 from your account.
Another option for design purposes only: download an image of the +1 button and use it in the offline version.

You're probably just opening the HTML file locally. You can run the Google+ widgets on your local machine and will need to have internet access to load the external scripts. What you need to do is start up a web server and open the file from there. This is due to permissions for JavaScript required from the +1 code.
If you are on a Mac, you can do this either through the built-in Apache server (copy the file to /Library/WebServer/Documents and navigate to localhost/filename.html) or by spinning up a Python web server in the same folder as the file with the following command:
python -m SimpleHTTPServer 8000
After starting the Python web server, you can navigate to localhost port 8000.
If you are running on a Windows PC, you can find a number of web servers and install them, WAMP is a pretty simple option. Again, you would just install WAMP and then put your HTML file in the web/www folder that WAMP created and navigate there from localhost. You can also install Python and use the built-in web server as mentioned before.

Related

Programmatically retrieving the contents of the chrome://gpu url

I am trying to programmatically retrieve the contents of the chrome://gpu url.
As a start I tried to load up chrome://gpu from the command-line, but chromium refuses to start up with a url that is prefixed with a chrome: prefix.
Then I tried to out-clever that limitation by using a redirect page:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="7; url='chrome://gpu'" />
</head>
<body>
<p>Please follow this link.</p>
</body>
</html>
But that page, although it can be launched from command line, would not refresh for me.
Even clicking the link does not work, which leads me to determine that you cannot link to chrome://gpu at all.
When I tried right-click open-in-tab on the link, I get:
Which means that chromium is actively blocking access to it, unless it is typed out by the user.
I have two questions:
Can this block be disabled?
If not, how can I retrieve this information programmatically? Can I somehow feed artificial keystrokes into chromium?
Update 1
Tried to add virtual key-strokes with:
$ wtype test
Compositor does not support the virtual keyboard protocol
Update 2
I have gotten further: I can use ydotool to make chromium browse to chrome://gpu and then do Save-As, but that saves a nearly empty html page that references a gpu_internals.js script.
Is it possible to save the output of that script instead?
Access to the "chrome://gpu" URL is restricted and cannot be directly accessed programmatically. This restriction is in place to prevent malicious actors from manipulating the internal settings of the browser.
An alternative approach could be to use a headless browser like Puppeteer or Selenium to automate the process of retrieving the information from the "chrome://gpu" page.
I've found ydotool to be a good solution for this.
With it, you can automatically open a page to chrome://gpu and then click in the browser window, followed by Ctrl+A, Ctrl+C to retrieve to contents to the clipboard.
You can then use wl-paste from the wl-clipboard package to get it.

stream RTSP to HTML website

I would like to display IP cameras streaming in RTSP into a web page.
I've tried many solutions, like using VLC to transcode the stream, but none of them seems to be reliable enough to create a real web service.
I'm thinking on using some media server like flussonic or Red5. But I don't know if it will work.
This is why I would like to know what is the best (and the simple) solution to display RTSP streams on a webpage.
...to create a real web service.
I've been looking for an answer for the past two or three days (I need support on as many browsers as possible, and latency as low as possible, so WebRTC was the way to go (is there anything better?)) and I've finally found it.
Check out this repo.
From the repo's readme + the additional steps I had to take (on Ubuntu 18.04) to make this work:
Install go
$ sudo snap install go --classic
Get the code on your local device (Could someone enlighten me on what the export is for?).
$ export GO111MODULE=on
$ go get github.com/deepch/RTSPtoWebRTC
This step didn't work for me, so I just downloaded the code in a .zip file and extracted it in the given directory and proceeded. (What did I miss? The src directory was not there before I made it)
$ cd ~/go/src/github.com/deepch/RTSPtoWebRTC
Run from current directory.
$ go run .
Then I opened the link below a web browser ( I tested on Chrome, iOS Safari, but it also works on Firefox).
http://127.0.0.1:8083
This took me very little time to implement. Big thanks to the guys making this. All the other stuff I've found is either 5-7 years old and not working or non-WebRTC or a marketed paid service asking for unreasonable amounts of money.
I hope I answered your question.
After tried the "plugins" way suggested in
How can I display an RTSP video stream in a web page?
And the "conversion" way suggested in
https://www.npmjs.com/package/html5_rtsp_player
I finally found a really straight forward solution using this plugin, works for Chrome only which is ok for my project.
https://www.videoexpertsgroup.com/vxg-chrome-plugin/
This is how the html code look like
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<script type="text/javascript" src="/assets/vxgplayer-1.8.31/vxgplayer-1.8.31.min.js"></script>
<link href="/assets/vxgplayer-1.8.31/vxgplayer-1.8.31.min.css" rel="stylesheet" />
</head>
<body>
<div class="vxgplayer"
id="vxg_media_player1"
width="640"
height="480"
url="rtsp://admin:admin#192.168.1.117/defaultPrimary0?streamtype=u"
nmf-src="/assets/vxgplayer-1.8.31/pnacl/Release/media_player.nmf"
nmf-path="media_player.nmf"
useragent-prefix="MMP/3.0"
latency="10000"
autohide="2"
volume="0.7"
avsync
autostart
controls
mute
aspect-ratio
aspect-ratio-mode="1"
auto-reconnect
connection-timeout="5000"
connection-udp="0"
custom-digital-zoom></div>
</body>
</html>
You can integrate VLC library into your website and VLC will take care of everything you need for playing RTSP stream:
https://wiki.videolan.org/index.php?title=HowTo_Integrate_VLC_plugin_in_your_webpage&action=edit&oldid=19150

HTA apps in Windows 10 phone

Is HTA supposed to work on Windows 10 phones? It seems like it knows it's supposed to launch it, but something isn't right.
The HTA file that I tried to run, looks like this:
<html>
<head>
<meta charset="utf-8"/>
<title>Test HTA app</title>
<hta:application id="myApp"
applicationname="monster"
border="none"
caption="no"
showintaskbar="yes"
singleinstance="yes"
sysmenu="no"
windowstate="maximize">
</head>
<body>
<p>If you can read this, HTA works!</p>
</body>
</html>
And, before I tried to launch it, I went to Security > For developers, and set the Developer features to "Developer mode" instead of the original option "Windows Store apps".
Then I downloaded the HTA file, clicked on it from my Downloads app, and all I get is a message saying
LAUNCH FILE
Something went wrong. Could not launch the file.
Is there something I can do to make it work?
And just to avoid possibly having another question later; is Javascript going to work?
No, I believe HTA will not work for Windows Phone 10.
Edge (Windows phone 10's browser) does not support it.
See this link: https://connect.microsoft.com/IE/feedback/details/785055/hta-application-tag-does-not-work-in-ie10

Unable to save specific file via dropbox saver

I am trying to save Visual Studio Community Edition 2015 from this url (http://download.microsoft.com/download/D/4/5/D4510E81-0900-425F-85F3-A09AFFADFA45/vs2015.rc_com_enu.iso) to my dropbox, using this code.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Saver</title>
<script type="text/javascript" src="https://www.dropbox.com/static/api/2/dropins.js" id="dropboxjs" data-app-key="MY-APP-KEY"></script>
</head>
<body>
Click here to save.
</body>
</html>
running on a local server. But this always returns the warning sign.
I tried with another file on some different domain and it worked. Can somebody point me to what I may be doing wrong?
Thanks.
If you set up the Dropbox Saver using JavaScript, you can implement an error callback that will give you more information in cases of failures like this.
I just did that with your link, and when doing that (after a good bit of time) I also see it fail, with the error message:
Job timed out
So, unfortunately, it seems the hosting serving is serving too slowly and/or the file is too big, making the save job take longer than the Dropbox Saver will allow.

Cannot load custom dojo module

I'm trying to follow the custom module tutorial at http://dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo/modules-and-namespaces/creating-your-own-modul
I've got a local deployment of dojo at http://localhost:8081/dojo-1.3.2/dojo/dojo.js
For my custom module I've created the following javascript file at http://localhost:8081/dojo-1.3.2/explosive/space/Modulator.js:
dojo.provide("explosive.space.Modulator");
dojo.declare("explosive.space.Modulator",null,{
bob:1
});
In my html page I have the following:
<script type="text/javascript" src="http://localhost:8081/dojo-1.3.2/dojo/dojo.js"></script>
<script type="text/javascript">
dojo.require("explosive.space.Modulator");
</script>
And when I pull up my site in firefox I get the error:
Error: Could not load
'explosive.space.Modulator'; last
tried
'../explosive/space/Modulator.js'
Any ideas on what I'm doing wrong?
EDIT: After more testing it appears the code works on IE8 and IE8 compatibility mode but not in Firefox, Chrome, or Opera.
EDIT2: My html file was on a different domain but I didn't think that should make any difference. After reading Seth's comment (thanks Seth!) I tried it both ways.
I have two tomcat instances, one on port 8080 and one on port 8081. I've placed index.htm in both instances and started them both up.
http://localhost:8081/test/index.htm works in both FF and IE. http://localhost:8080/test/index.htm does not work as expected in FF, but does work in IE.
Show XmlHTTPRequests shows that FF is making a call to "GET http://localhost:8081/dojo-1.3.2/explosive/space/Modulator.js" which is coming back with an empty response for some reason.
Here's the entirety of my code for index.htm if it's any help.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=7" />
<title>Create Map</title>
<script type="text/javascript" src="http://localhost:8081/dojo-1.3.2/dojo/dojo.js"></script>
<script type="text/javascript">
dojo.require("explosive.space.Modulator");
function init(){
var eludiumFuel36 = new explosive.space.Modulator();
alert(eludiumFuel36.bob);
}
dojo.addOnLoad(init);
</script>
</head>
<body class="tundra">
<h1>Hello World!</h1>
</body>
</html>
It looks ok from what you have here. When you bring up the page, are you going to http://localhost:8081/testpage.html (or somesuch)? Or are you going to a different domain?
Do you have firebug installed? If not, install it and turn on 'Show XMLHttpRequests'. That will show what URL it's trying to access in the console (and any other possibly relevant errors).
Otherwise, there might be something else on the page outside of what you posted messing with dojo's load path.
Edit
When dojo does an dojo.require, it does a XHR call for the file. The includes the host and port in it. So, it's violating cross domain security when the html page is on localhost:8081 but the javascript is on localhost:8080. You can get around this by using a cross-domain build version of the file (or make sure all requests come on the same port and host). Truth be told, I'm not quite sure why IE works with the different ports though.