Strapi CMS CKEditor html support issue - content-management-system

Using CKEditor 5 marketplace plugin in Strapi CMS.
I want to extend the usage of all html tags.
configured as per documentation.
htmlSupport: {
allow: [
{
name: /.*/,
attributes: true,
classes: true,
styles: true
}
],
},
Tried adding div to source but it doesn't work when I switch back or even save the data. Gets replaced with p tag only.

Related

How to update the meta tag in ionic dynamically? So that it can work in facebook social sharing

In the ionic project, there is only one head section where we write all the meta tag that is in the index.html page. For example, to make the Facebook sharing work perfectly we need this meta tag given bleow:
<meta property="og:title" content="Title">
<meta property="og:description" content="description">
<meta property="og:image" content="Image Url you want to show">
<meta property="og:url" content="http://yourUrl.com">
So how can we update this meta tag from other pages? For example, if we go to a news detail page the meta tag of that page will be changed accordingly. So how can I achieve this in my Ionic4 with angular project?
I believe that you can do it in a way similar to this:
var link = document.createElement('meta');
link.setAttribute('property', 'og:url');
link.content = document.location;
document.getElementsByTagName('head')[0].appendChild(link);
In my existing Ionic 4 project, I want to use Angular Universal but I got into so many errors. So I created a new project using Ionic 5. And move all my previous work to the new Ionic 5. I follow these steps to add Angular Universal to my project.
At first, create an app and update it to the latest version of Angular using these commands.
ionic start myApp blank --type angular
cd myApp
ng update #angular/core #angular/cli
npm install #angular/animations
Then add Express engine for Angular Universal using this command.
ng add #nguniversal/express-engine
Then you need to install the #ionic/angular-server module using this command.
npm install #ionic/angular-server#dev
For testing in the localhost, your server-side rendering is working correctly you need to use this command.
npm run dev:ssr
For more detailed information on how to setup Angular Universal for server-side-rendering you can see the ionic blog link SSR with Angular Universal And Ionic.
After setting, angular universal you need to add title, add, or update meta tag. You can follow my sample code given below:
import { Component, OnInit} from '#angular/core';
import { Title, Meta } from '#angular/platform-browser';
#Component({
selector: 'app-sample',
templateUrl: './sample.page.html',
styleUrls: ['./sample.page.scss'],
})
export class SamplePage implements OnInit {
constructor(private titleService: Title, private meta: Meta) { }
ngOnInit() {
this.titleService.setTitle("Your Title");
this.meta.updateTag({ property: 'og:url', content:'http://yoururl.com'});
this.meta.updateTag({ property: 'og:title', content:"Your Title" });
this.meta.updateTag({ property: 'og:image', content: "your image link"});
this.meta.updateTag({ property: 'og:description', content: "description"});
}
}
Now your social share will work perfectly. Because when it crawls not it will get the metatag with data. You need to update the meta tag based on the social share you want to add.
I got this working last week using Renderton as described in this post by Jeff Delaney. You'll still need to setup server side rendering (SSR) through this artcle. Lastly, make sure none of your code references the window, which will break SSR and Rendetron.
One can use ionic's pre build hooks to modify the index.html after building. Add hooks in your ionic.config.json file
{
"name": "xxxx",
"integrations": {
"capacitor": {}
},
"type": "vue",
"id": "xxxxx",
"hooks": {
"build:after": "./deploy/after-build.js"
}
}
and then in your project folder (top level) create folder deploy with file after-build.js with following content:
var fs = require('fs')
module.exports = (ctx) => {
const index = `${ctx.project.dir}/dist/index.html`;
fs.readFile(index , 'utf8', (err, html) => {
const meta = '<meta name="NEW-META" />';
html = html.replace(/<meta name="OLD-META".*?">/, meta);
fs.writeFile(index, html, 'utf8', err => err && console.log( err ));
});
};

Generic template image_url does not load in Messenger - Facebook Messenger Platform

I am using the Facebook Messenger Platform to create a generic template. I am currently using ngrok to test locally, and the image_url I input for the generic template never shows in Messenger. The generic template is sent, and the image is just blank. Using Inspect, I can see that the CSS for the image is:
background-image: url("https://external.xx.fbcdn.net/safe_image.php?d=AQA1nM3pKJnllzq0&url=https%3A%2F%2Fdc3858ef.ngrok.io%2Fassets%2Fimages%2Fvideo_image.jpg&_nc_hash=AQAlBOE-vbT8cl-i");
If I open this URL, it is just a black screen with one white pixel in the middle.
Here is the message data that I use:
messageData = {
recipient: {
id: senderID
},
message:{
attachment:{
type: "template",
payload: {
template_type: "generic",
elements: [
{
title:"Test Video Link",
image_url: MY-NGROK_DOMAIN + "/assets/images/video_image.jpg",
subtitle: "Check out this video!",
default_action: {
type: "web_url",
url: "www.google.com"
}
}
]
}
}
}
};
This image_url works fine if I open it in a browser. Similarly, if I create an 'image' type message data rather than 'template', this image is loaded in Messenger.
How can I get my image_url to load properly for a generic template?
I have the same issue. I and the problem appears when the webhook domain is the same as the image url. If you use an image on a different server, it works.
I had the same issue. I've put my local web application behind ngrok. Requesting the image directly in the browser worked fine, but when it's loaded via Facebook's safe_image.php script it would show a blank image. After a lot of debugging it turned out to be the tunnelling service itself. I switched to another service (localtunnel) and there it worked fine.
More information can also be found on this issue registered on FB:
https://developers.facebook.com/support/bugs/2151860088174161/
Update
Contacted ngrok about this and got a quick reply, this is due to Facebook blocking ngrok for this script.

Set start_url in web app manifest based on the URL that was added to homescreen

My site has several subsections. When a user adds the site to their homescreen, I'd like to make sure that the home screen icon launches them into the subsection they were on when they added to homescreen.
I can register a different manifest for each subsection, but this doesn't work for single page apps where there's no page reload. I'm considering storing the subsection in a cookie and then redirecting from a generic start URL based on that cookie.
Is there a better way to do this?
If you remove the start_url from the manifest.json file then it will default to the page user was browsing while adding pwa app to homescreen.
ref : https://developers.google.com/web/tools/lighthouse/audits/manifest-contains-start_url
Have you tried changing the web app manifest url when the user navigates between different subsections?
document.querySelector('link[rel=manifest]').href = '/example-manifest.json';
One solution is for each page do you have a separated manifest with attribute start_url specific to each page.
Editing:
in the HTML for /your_path:
<link rel="manifest" href="/path/to/your_path-manifest.json">
in the HTML for other pages:
<link rel="manifest" href="/path/to/any_other_page-manifest.json">
Had the same problem just now. Here is my solution:
I completely removed the manifest tag from the initial HTML. Instead I now put the manifest together entirely in JS with the start_url set to window.location.href. Then I add it to the head as a Base64 data URL:
const manifest = {
name: 'My App',
short_name: 'My App',
display: 'standalone',
theme_color: '#ffffff',
background_color: '#ffffff',
icons: [
{ src: `${window.location.origin}/path/to/icon.png`, sizes: '192x192', type: 'image/png' },
{ src: `${window.location.origin}/path/to/icon.png`, sizes: '512x512', type: 'image/png' },
{ src: `${window.location.origin}/path/to/icon.png`, sizes: '192x192', type: 'image/png', purpose: 'maskable' },
{ src: `${window.location.origin}/path/to/icon.png`, sizes: '512x512', type: 'image/png', purpose: 'maskable' }
],
start_url: window.location.href
};
const link = document.createElement('link');
link.rel = 'manifest';
link.href = `data:application/json;base64,${btoa(JSON.stringify(manifest))}`;
document.head.appendChild(link);
Seems to work on both Android and iOS.
Note: Since data URLs don't have a root you cannot specify any root-relative URLs within the manifest (e.g. for icons). But it's easy to fix by prepending with window.location.origin. Also the start_url may not be relative. E.g. using just window.location.pathname doesn't work, that's why I am using window.location.href.
Note 2: If you are using a tool to autogenerate the PWA support of your app make sure this tool doesn't generate its own manifest during the build. Usually there should be a config option to disable this. For the Vite PWA Plugin I was able to configure manifest: false.
Had the same problem and tried messing about with the start_url applying many suggestions and none worked. What did work is to remove start_url all together.
Now I'm able to go to any page under and subdirectory and save the page to my phone home screen, when clicking on the save link I taken to the correct page.
Tested this in Chrome, Safari, Firefox and Edge.
Hope that helps.

ckeditor image plugin for selecting image to upload

Here, I am using ckeditor and I want to upload an image using ckeditor.
I found link and I did like it says but I couldn't get button to upload an image for that.
Link is here for an image. My ckeditor version is CKEditor 4.5.6.
What can I do for upload an image?
Do remember that by default CKEditor does not include a file manager/uploader, so you need to integrate some server-side component to handle that. It can be either CKFinder (the file manager created by CKSource, the company behind CKEditor that can be easily integrated with the editor), some third-party product of your choice or your own solution.
Please refer to the CKEditor documentation about file upload - there is plenty of it, including samples with source code ready to copy and use in your own implementation:
File Upload through Dialogs and Drag&Drop sample
File Manager Integration documentation.
CKFinder Integration documentation
File Browser API - Creating a Custom File Manager documentation
CKFinder + CKEditor demo
Image upload in server and set url in ckeditor
https://stackblitz.com/edit/angular-ivy-jqy4ni <== demo link for angular
<ckeditor [editor]="editor"
[config]=" {
ckfinder: {
options: {
resourceType: 'Images'
},
uploadUrl: "BACK_END_MAPPING_URL_FOR_SAVE_IMG
},
}"
rows="6"> </ckeditor>
=> for back end use file name "upload"
Ex.
#RequestParam(value = "upload") List<MultipartFile> multipartFile
And response
FOR SUCCESS ================
{
"uploaded": true,
"url": "http://file/img/get_image_url.jpeg"
}
FOR ERROR ================
{
"uploaded": false,
"error": {
"message": "could not upload this image"
}
}

Sencha touch and facebook integration?

i am trying to develop an app using sencha touch. Is it possible to integrate facebook into the app? Any sample code would be appreciate.
Thanks
Sencha is a HTML5 framework with mobile event integration. I don't think there is anything in Sencha that allows you to work better with Facebook, I could be wrong, but saying that I would look into http://touch.facebook.com/#!/home.php , it's Facebooks better integrated touch site designed to work with tablets. You may want to integrate to this functionality when working with the framework.
Facebook also has the original mobile site at m.facebook.com
It depends how you want to integrate it I guess, here is how I do it using JSONP. If you sign up for facebook developers and create an app, give it a name and you will be given an App ID and secret key. If you then head over to tools, Graph API explorer you can type in your Facebook page ID number e.g. 509796964 to get an example query. You can find your ID in several ways, just google around a bit.
You will see an access token given at the top. You can then append this to your URL just like any other JSONP call in Sencha, and you will get back results that you can tie to components (for example, I have tied my response to a list).
Here is an example list view:
Ext.define('TCApp.view.FacebookList', {
extend: 'Ext.dataview.List',
requires: [
'Ext.plugin.PullRefresh'
],
alias: 'widget.facebooklist',
config: {
loadingText: 'Loading Movies...',
plugins: [
{ type: 'pullrefresh' }
],
store: 'Facebook',
itemTpl: [
'<div class="wholeitem"><img src="{picture}" class="facebookthumb" />{message}</div>',
'<div class="smalltext">{description}</div></div>',
]
}
});
my store:
Ext.define('TCApp.store.Facebook', {
extend: 'Ext.data.Store',
requires: [
'TCApp.model.Facebook'
],
config: {
autoLoad: true,
model: 'TCApp.model.Facebook',
storeId: 'Facebook',
proxy: {
type: 'jsonp',
url: 'https://graph.facebook.com/51539791474/feed?access_token=AAAFnhgQ0ZAHIBAO0s9iDUGZAIomBGmLJgpvSE03FmMNSPZAXo35wNKWa0ul0L8Twb9fLsssJTXO0BwthCck5MGViQxbDm0laido30OoYwZDZD',
reader: {
type: 'json',
rootProperty: 'data'
}
}
}
});
You have to change the end of the URL token to your own, and it will work, just remember to create a model too with the items you want in your list, for example I have image, text, description and link.
The only thing I can't work out so far is that this access token expires after 2 weeks!!! If you can work out how to request a new token each time it would be awesome, but best in another question I think!
:-)
I haven't try this yet but I guess you will get problem when implement this in a packaged app.
Btw, others say that they succeeded with https://github.com/mgcrea/cordova-facebook-connect/
I'll try both solutions and figure it out soon. But this question is old, I don't know if you still need my answer.
Good luck!