Titanium appcelerator Wordpress api - shows html - json

I'm having problems with an app project I'm working on.
I'm parsing text from a wordpress api but it is coming out in html form. Any one knows how to work around this and get it in clean text format?

This is from wordpress side not #appcelerator side ! , you can using wp_strip_all_tags($html) function to strip all HTML tags including script and style .
But if you are not wordpress coder and you want solve this probelem you can use any javascript function to strip html tags like :
var StrippedString = OriginalString.replace(/(<([^>]+)>)/ig,"");

Related

Getting Image through HTML and using Python Code

I am trying to make a website that gets the user image and uses
facelandmark code(python) to tell the user about user's face shape and etc.
How can I get the imange through html and use the image file in python code and show the result to the user again? Is using django the only way? I have tried to study django in many ways and most of the stuffs I found were not directly helping on my planning website. Thank you for reading
You can use this code to directly embed the image in your HTML: Python 3
import base64
data_uri = base64.b64encode(open('Graph.png', 'rb').read()).decode('utf-8')
img_tag = '<img src="data:image/png;base64,{0}">'.format(data_uri)
print(img_tag)

How do I add inline CSS into the Wordpress Visual Composer?

I might be asking the wrong question (I'm not a coder), but I'm attempting to paste HTML and the inline stylesheet into the text-side (HTML-side) of the Wordpress Visual Composer to create an email layout, and the finished product of that is the entire stylesheet written out above the un-styled HTML layout, so I'm assuming inline stylesheets are not supported in this composer.
Some back story for clarity, I'm using the plugin 'Download After Email' which only provides the standard Wordpress visual composer in order to create the email a user receives once they 'sign up'. This seemingly limits me to either jazzing up some text a little bit like I was using Microsoft Word (which isn't sufficient for a brand-focused business), or using raw standalone HTML, which isn't really sufficient for a properly formatted template.
Are there any plugins which may assist in adding CSS styling here that will work once it's displayed externally to the website, i.e. in an email browser?
Judging by the image, you have a regular editor but not Visual Composer, and this is very good because this is the only right direction! You cannot create email templates using the constructor (Visual Composer) since creating an email template requires special old school knowledge (Tables, inline styles) and clean markup. I advise you to take a ready-made template and change it to your own.
Example: https://colorlib.com/etc/email-template/3/index.html
What you need to know:
You need to use html tables
You need to use inline css
Use full src to display images (https://yoursite.wp/.../demo.jpg) the link you can get from the media post
Not recommended:
To use css styles in the header if you are interested in Gmail App support:
https://templates.mailchimp.com/resources/email-client-css-support/
Custom fonts
Visual Composer and any other constructor
Addition:
If you can use the shortcode system I recommend creating a mini plugin for you:
plugins/my-custom-emails [Root directory of new plugin]
plugins/my-custom-emails/my-custom-emails.php [Main php file of plugin]
plugins/my-custom-emails/emails/ [Directory for for all your templates]
plugins/my-custom-emails/emails/template1.html [First demo template]
my-custom-emails.php
<?php
/*
Plugin Name: My emails
Description: My custom emails
Version: 0.1.0
*/
define('MYCELS_DIR', plugin_dir_path(__FILE__));
add_shortcode( 'myemails', 'MYCELS_SHORTCODE' );
function MYCELS_SHORTCODE($attrs) {
if(empty($attrs['id'])) {
return 'ID required';
}
$ID = $attrs['id'];
$PATH = MYCELS_DIR . 'emails/'.$ID.'.html';
if(file_exists($PATH)) {
return file_get_contents($PATH);
} else {
return 'File with '. $ID . ' ID not exists';
}
}
template1.html
<div>
Template
</div>
And using:
[myemails id=template1]
Id = template name
If you want something very customisable this plug-in would work,
https://en-gb.wordpress.org/plugins/wp-html-mail/
It’s very good and would recommend!
With this you have full control over CSS and the HTML also comes with templates and has so much more control for what you need!

How to manually define place for blog post preview using Django and CKEditor?

I have a blog written in Python + Django.
Before I started use of WYSIWYG editor, to create a blog post preview I manually added custom html tag <post_cut/> and used python slice to show only a preview. It allowed to avoid issues with fixed length for preview or breaking html tags.
Now I added Django-CKEditor and it removes all html tags which "it doesn't understand".
I tried to do something with configuration (allowedContentRules, format_tags and etc.) but no success.
The questions is how to manage "post-cut" and how to do this using CKEditor.
P.S. it would be awesome also to have button for that.
Found the answer by myself.
You need to use extraAllowedContent if you want to add some extra tags.
Also found how to add custom button by creating a custom plugin.
But still looking for good solution that will utilize django-ckeditor
CKEDITOR_CONFIGS = {
'default': {
'extraAllowedContent': {
'post_cut': True,
},
# ...
# (other options)
}
}

Wordpress Headless to reactJS with wp-api

I want to make an app with a wordpress headless server and a react app for the front end with the wp-api.
I can get my data but with html tags. I want to build my html into react, not into wordpress.
I don't know how to do this, I tried to trim the html with wpautop who makes content as plain text (https://codex.wordpress.org/Function_Reference/wpautop), but now I'm stuck because, what if I need to put a picture or a list in the middle of my content with this plaintext :D ?
I don't know if there are solutions for this, that's why I'm asking here.
Regards !
Create one common function for removing HTML tags in the react side like.
removeTags = (str) => {
if ((str===null) || (str===''))
return false;
else
str = str.toString();
return str.replace( /(<([^>]+)>)/ig, '');
}
and call it whenever you get data from Wordpress API like:
this.removeTags(post.excerpt.rendered)
You can check my repo for more information:
https://github.com/BRdhanani/headless-wordpress-with-react

htmlRenderer.PDFSharp not converting labels

I am trying to get familiar with htmlRenderer.pdfsharp and have come across an issue that I am trying to figure out. It is not rendering the following HTML:
<td><label for=\"Date\">Date</label></td>
The code I am using to generate the PDF is from one of their examples but it is as follows:
PdfDocument pdf = PdfGenerator.GeneratePdf(html, PageSize.Letter);
The rest of the HTML is populating just fine and am not sure where to go from here with the HTML Renderer. Anyone else ran into this issue and have a fix?
Edit: I removed calling it PDFSharp's html render and linked to the nuget package I am using for htmlRender.pdfsharp.