Posting to a web form and catching results from JavaScript code - zapier

How would I go about achieving the following
I have some HTML data triggered from an Evernote new note action
I need to pass this HTML string to a website via an http post with form variables
I then need to catch the resulting web page text in a variable to use in my next action.
For clarity the website simply takes some HTML and converts it to markdown passing it back out as the body of the resulting page
Regards in advance
Dan

Sweet! So I've got this working. In my example, text is some html I pulled out of a dummy previous step:
The output is:
Which has the markdown as a key. If you want to tweak other data based on the api params, you can do that as GET params below html
​Let me know if you've got any other questions!

Related

Kirby CMS: how to return Blocks as HTML?

I'm playing with Kirby CMS and using it as a headless CMS. I'm using Blocks field to handle rich content.
In the API, this field is returned as an array of objects:
[
{
"content": {
"level": "h2",
"text": "test"
},
"id": "02d4a71b-cd02-4382-a78c-84ff1e68324b",
"isHidden": false,
"type": "heading"
}
]
Which is great, I think. But in my case, it's annoying, as I should do all the rendering by myself.
Is there a way, or an option, to tell Kirby to render this field as HTML content?
I know there is a $blocks->toHtml() method, but I'm using a standalone React frontend, so I can't use this in my JSX.
You don't have to use the Kirby API directly in order to get content from your Kirby site. Kirby has a few different ways to respond to an ajax request - and that response can be in any format, such as JSON, an HTML snippet, or anything else. Here are a couple of the most often-used ways to achieve what you want.
CUSTOM ROUTE
You could define a custom route, which is like a 'custom api point', that your React interface could send requests to, and which would respond with the block list as an HTML snippet, as required. You could set your route at a URL like:
https://example.com/block-api
In your route, you could then use the toHTML() method, or a snippet(), or any other method, to convert the blocks into HTML that you can then send back as a string in your response.
In your route definition, you could also use a pattern that would allow you to (optionally) request a single block by ID. Your custom route URL for that would look something like this - where the last segment is the block ID:
https://example.com/blocks-api/02d4a71b-cd02-4382-a78c-84ff1e68324b
CUSTOM CONTENT REPRESENTATION
When you try to reach a page in your Kirby site via its normal URL, Kirby will put the page's content into your page's template, and return it as an HTML document. That is the 'default' behaviour. You can, however, override that.
You can define a custom content representation for your page, which tells Kirby that you want to receive the content of your page in a 'different format' - such as JSON, XML, or anything you wish. That 'different format' can even be just an HTML snippet. All you need to do is define a new template for it.
In your case, you could create a content representation that tells Kirby to return a fully-formatted HTML snippet of your blocks only - by creating a template called something like "mypage.blocks.php", with just the HTML for the blocks in it. So, if to access the page normally we'd go to URL...:
https://example.com/mypage
...to get your 'blocks' custom content representation for that page, you'd now go to:
https://example.com/mypage.blocks
Your custom content representation can have its own controller, too. This is useful if you want to get Kirby to send you the HTML code of just one single block, instead of all blocks on the page. You could use a query parameter in your URL to tell the controller which block you want the HTML for. The controller would then check the URL for the query parameter, and if the parameter is there, it returns only the required block. This would enable your React app to get the HTML code for just a single block on the page, by sending a request to an URL like:
https://example.com/mypage.blocks?id=02d4a71b-cd02-4382-a78c-84ff1e68324b

How to define the main data post body that's belong to Post page in blogger?

I'm trying to define the real <data:post.body/> that's belong to the post page in Blogger, So I can add the read more script and put the Adsense in the middle of the body, and if you can tell me more about it?! Thanks.
login to your blogger account > Template > Edit Html , now try to find the <data:post.body/> if you are using the simple blogger template you will find 3 of them the first one following to this line <b:includable id='mobile-post' var='post'>about 39 lines between.this data post body belong to the mobile template as it says. Click Enter to go to the other result of search you will find two data post body close from each others the below one is respon to convert the data of your post to shows it as text in your post page the middle one is respon about your post page following to "includable id=post" 34 lines between , If you are using another custom blogger template try to delete every one Separately when you delete two of them and see the result (nothing will happen) the meant data post body will delete your written content in your blog post page , Don't worry when you Undo this transaction the content shows up.
Now we know the main data post body code of your post page , If you add something before this code it will shows up above your content=under post title
if you add something after this code will shows up below your content=end of your post
to add the read more and adsense code in the middle of your post first set up the read more script you will find the data post body splitted to three the followed by quot item quot is the one, replace it to adsense in the middle code.
To clarify: you want a read-more script to run on an ITEM/STATIC-PAGE page type, or do you want the read-more script to run on an INDEX page type? And what do you mean that you're trying to "define" it? data:post.body goes within the post includable.

Print web page with original look

I want to achieve print functionality such that user can print out the web form and use it as paper form for the same purpose. Of course I do not need all the web page header and footer to be printed, just content of a div which take most of the page. I did play around with media print css and menage print result to look almost as original page. But the I tried to print it in another browser(Chrome) and it is all messed. (before I tried Mozilla).
For the web form I user css framework Twitter Bootstrap and I had to override its css (in print media) for almost each element individually to get some normal look in the print result.
My question is is there some way (framework/plugin) to print just what you see on the page, maybe as an image or something?
Any other suggestions are welcome.
Thanks.
If you are familiar with PHP you can try the PHP class files of TCPDF or those of FPDF.
Or there is also dompdf which renders HTML to PDF, but this will include more than just the information of one div.
And for further info here is a post on Stack where users are discussing which they think is best.

Rails take base64

In rails i need to take a base64 string, and use it to generate a picture in rails. Now i'm having trouble, because i need to interact with AJAX calls (im strictly working on the server side, another guy is doing that client work) to send pictures. So far i've been taking requests in my application by having data transferred through the url (in the AJAX requests) but now im not sure if it's possible to transfer such a huge string through the url. How could i take in the data (like how could he pass it to me) to generate a picture.
Note: i've been using paperclip for my application so far, but now uploading through the form is not an option, it needs to be in an AJAX call where data is passed in a single call.
You're right, most browsers limit the length of a URL. The limit on IE8/9 is 2083 characters. Even if your particular browser has a higher limit, many servers limit the URL length as well (apache's default limit is right around 8k). It would be best to submit the image as a POST request with the data in the POST body.
I would use jQuery to POST JSON data to the server. In the controller, if this is set up correctly, you won't have to do a thing to parse the JSON. ActiveSupport will recognize the content type and parse it out into the params hash automatically.
Actually posting the data will depend on which javascript library you're using. Here's an example in jQuery, which you'd probably want to wire up to the onclick event of a submit button. This assumes you have a named route called process_image. This code would go in your view.
$.post(<%= process_image_path %>, { b64_img: "your_base64_image_data" });
In your controller, you can access the posted data with params[:b64_img]. If you want to return something from the controller back to the client, you can do this in the controller:
render :json => #model_object
And change the jquery call to look like this so you can do something with the return value:
$.post(<%= process_image_path %>, { b64_img: "your_base64_image_data" },
function(data) {
// do something with the data returned by the controller
});
Hope this helps. You can read more about the jQuery post call I used here: http://api.jquery.com/jQuery.post/
Dan

Asp.Net MVC Form[GET]. Correct action url

I've got search form, which contains checkboxlist which is binded to my model. So when I set GET method to form I got long url:
(I even have exception:
The length of the query string for this request exceeds the configured maxQueryStringLength value.)
it's expecting, [0].IsSelected=false&[0].Id=6&[1].IsSelected=false...
But I would like url like this
www.domain.com/Action/Comma-separated-selected-idx
for example:
www.domain.com/Search/1,6,7
How can I fix,edit form get action? Thanks
I would do a POST instead, then redirect to the URL you desire.
OR
You could capture the form with some JavaScript and build the URL there.
agreed, POST or JS are your best options, I'd opt for a POST.

Resources