turbo drive works for a form but not a link - turbolinks

I an experimenting with turbo drive without rails.
It seems to work for forms but not links.. even when the form is set to GET.
To try to keep it minimal, I have used bash and cgi, but I saw the same thing using another web framework.
$ mkdir example
$ cd example
$ cat > index.html
<meta http-equiv="Refresh" content="0; url='/cgi-bin/index.sh'" />
$ mkdir cgi-bin
$ cat > cgi-bin/index.sh
#! /usr/bin/env bash
set -e
echo Content-Type: text/html
echo
sed "s/NEW/$RANDOM/g" << EOF
<html>
<head>
<title>DEMO</title>
<script src="/node_modules/#hotwired/turbo/dist/turbo.es2017-umd.js"></script>
</head>
<body>
<h1>DEMO</h1>
<h2>$QUERY_STRING</h2>
NEW
<form action="?">
<input type="hidden" name="val" value="NEW" />
<input type="submit" />
</form>
</body>
</html>
EOF
$ chmod +x cgi-bin/index.sh
$ npm install --save #hotwired/turbo#7.0.1
$ python3 -m http.server --cgi # or whichever server
then when I go to http://localhost:8000 I get this:
Both the both the link and the submit button load the random number displayed in the link, and prepare a new random number for loading.
The difference is that the link reloads the whole page as if turbo were not included, and the form fetches.
What do I have to do to make it ajax the link as well? Did I overlook an attribute I need in the link or something?

Stepping through the code I discovered this condition:
function isHTML(url) {
return !!getExtension(url).match(/^(?:|\.(?:htm|html|xhtml))$/);
}
So I renamed index.sh to index.html and it worked! I guess it probably works with no filename as well.
That restrictions only applies to links, not forms.

Related

WSO2 API Manager is saving hundreds of 'publisher' HTML files to directory

WSO2 API Manager is saving hundreds of 'publisher' HTML files (every day) to directory "/root"
All of the files have names like:
publisher.1
publisher.2
publisher.3
...
publisher.978
etc
How do I stop it from creating these files, or atleast how can I change the output directory for the files?
The contents of each file is HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<script>
var requestURL = '/publisher';
var ssoEnabled = 'false';
var tenantDomain = 'null';
</script>
<title>API Publisher- Login</title>
<meta charset="UTF-8">
...
...
...
<script>
var siteRoot = '/publisher/site/themes/wso2';
</script>
<script type="text/javascript" src="/publisher/site/themes/wso2/libs/jquery.cookie.js"></script>
<script type="text/javascript" src="/publisher/site/themes/wso2/templates/utils/button-loader/jquery.buttonLoader.js"></script>
</body>
</html>
Looked in a bunch of config files, and in carbon management settings, but can't find anything that looks like it controls this.
Expect no html files to be saved at all to root directory.
By going through the file content you have given, It seems, it's a rendered output of a publisher page.
Because the following script tag is coming from the base template in WSO2 API Manager publisher app.
<script>
var requestURL = '/publisher';
var ssoEnabled = 'false';
var tenantDomain = 'null';
</script>
But there is no possibility to write the rendered HTML pages to /root/ directory or to anywhere else in the file system.
And also by default (In Unix systems), only root user has Read, Write permission to the /root/ directory. So unless you run a tool with root permission, It can't write files to the /root/ directory.
WSO2 API Manager does not need root permission to run nor it's recommended to start the server with superuser privileges.
So I think, this should have done by some external tool.
For example: If you have configured a health-check tool to GET a /publisher page and write the snapshot of the page to file system each time you perform the health check and if that is configured to write to /root/ directory this could have happened.
Can you check
Whether these files are created in equal time intervals
Who is the owner of these files (ls -lh)
And also check whether WSO2 API Manager is running with the same user who has created those files (ps -aux | grep wso2server).

how to upload html file into cloude using predix

What is the procedure to upload a html file into cloud.i tried with predix mailed link.but it is given error 403 .can anybody uploaded html files into cloud used predix platform link .please do need full.
The hello world is an html file. Please try this.
https://www.predix.io/resources/tutorials/journey.html#1719
You can serve up files within your microservice that you push up to the cloud. See the rest endpoint /static in the Spring Boot doc. Try out the microservice-template project for some ideas
https://www.predix.io/resources/tutorials/tutorial-details.html?tutorial_id=1523&tag=1719&journey=Hello%20World&resources=1475,1569,1523
I have my collection of Predix.io apps in different languages including static HTML, angular, java even Scala etc.
Please look at
https://github.com/SVyatkin/CF-Hello-World-examples
According your question about HTML it is in the collection as well as just use
https://github.com/SVyatkin/CF-Hello-World-examples/tree/master/hello-html
$ git clone https://github.com/SVyatkin/CF-Hello-World-examples.git
$ cd CF-Hello-World-examples/hello-html
$ cf push -m 128M -b predix_openresty_buildpack html-hello
$ curl https://html-hello.run.aws-usw02-pr.ice.predix.io returns "HTML Predix.io - Hello World Example"

call Telegram.api in browser (Windows): sendPhoto

I am using Telegram to send pictures from a IP-cam.
This can be done on raspberry-PI like this:
curl -s -X POST "https://api.telegram.org/bot123456789:yourcode/sendPhoto" -F chat_id=123456789 -F photo="#/volume1/Data/temp/picture.jpeg"
Explanation: the picture is in the folder "/volume1/Data/temp" the name is "picture.jpeg"
I want to do the same on Windows and I constantly get message "{"ok":false,"error_code":400,"description":"Bad Request: Wrong persistent file_id specified: contains wrong characters or has wrong length"}"
This is exactly (exact for the bot and yourcode and chatid) what I transmit in the address of Google Chrome:
https://api.telegram.org/bot123456789:yourcode/sendPhoto?chat_id=123456789&photo="#C:/temp/picture.jpeg"
I can assure you the is no problem with autorisation (filling in file:///C:/temp/picture.jpeg in the browser shows me the picture).
And I have tried al kinds of variantions (with and without #, with and without ", etc. etc.). I cannot get it working.
And it works with sending text:
...../sendMessage?chat_id=123456789&text=”hello”
result is that I get the message "hello" and this in the browser: {"ok":true,"result":{"message_id" ......
I am sure I am close but do not know how to define exactly the "picture".
So the questions is: what is the exact way to transmit a picture with Telegram through a Windows browser using api.telegram.org? Please provide an example that is working.
Thanks in advance for help!
When you transmit that url in chrome (or any other browser) you are actually using "GET" method than can be used for send image with its "file_id".
But when you want to upload a file from your pc, you should use "POST" method to send it.
On of easiest ways is using a HTML form.
For an example:
<form action="https://api.telegram.org/bot2222222:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/sendPhoto" method="post" enctype="multipart/form-data">
<input type="text" name="chat_id" value="11111111" />
<input type="file" name="photo" />
<input type="submit" value="send" />
</form>
Edit:
Also if you want to do it from command line you can use windows version of cUrl. You can download it from this link:
Windows cUrl
or use Invoke-RestMethod in windows powershell.
example command:
Invoke-RestMethod -Uri $uri -Method Post -InFile $filePath -ContentType "multipart/form-data"

using curl, shell scripting how to upload all the files in Specific path to host?

i have written a script to upload all the files from a specific folder in local to the host, but there was some issue and the files are not getting uploaded to the host.
#!/bin/sh
for i in /main/folder_1/path/*
do
curl -u Pass:"Uname" -T $i http://www.example.com/folder/path/$i
done
echo "*****File Uplodaed ******"
help me to solve this. the following is the error, that i got
<html>
<head>
<title> 500 Internal Server Error </title>
</head>
<body>
<h1>
Internal Server Error
</h1>
</body>
</html>
currently i am having the script inside /main/folder_2, if i change /main/folder_1/path/ to ../folder_1/path/, i got the output as the files are moved. but i want to run the script with the complete path specified.

Open Graph and internationalization - alway's in english

This is my first web site and i manage to make everything work except that.
I use ASP.Net and "Resources" files and then set the CurrentCulture which work's fine.
Now I want to share page of my website on Facebook. So i did use Open Graph tags.
I did try many combination of tags and i did try to rescrape in the Facebook Debugger but without succes. The retrieve description and title are ALWAY'S IN ENGLISH.
<meta property="og:locale:alternate" content="en_US" />
<meta property="og:locale:alternate" content="fr_FR" />
I also try to add:
<meta property="og:locale" content="fr_FR" />
Without success. I installed curl and run a "refresh" of facebook cache... still without success.
curl -X POST -F "id=http://facteurhumain.ca/facteur/lesNouvelles" -F "scrape=true" -F locale="fr_fr" "https://graph.facebook.com" -s
I did also try to put "en_US" and "fr_FR" in lower caps ("en_us", "fr_fr") without any changes.
Any pist of solution?
Thanks!!

Resources